Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Setting as pages #3813

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bb031fe
Basic setup
Mikehrn Dec 26, 2024
7f60503
Combine delete invite dialog
Mikehrn Jan 2, 2025
d743202
Merge branch 'main' into mike/settings-as-pages
Mikehrn Jan 7, 2025
f038bc9
Merge branch 'main' into mike/settings-as-pages
Mikehrn Jan 7, 2025
8090691
Changed to slug instead of id
Mikehrn Jan 9, 2025
ba87130
Clean up code, remove redirects
Mikehrn Jan 9, 2025
0829194
Updated UserNav
Mikehrn Jan 9, 2025
e3ad819
Add billing redirects
Mikehrn Jan 9, 2025
cf404e8
Remove collapisble
Mikehrn Jan 9, 2025
a91c7e7
Fix General workspace settings
Mikehrn Jan 13, 2025
490190a
Fix sidebar active state
Mikehrn Jan 13, 2025
b3ea9da
Updated routes
Mikehrn Jan 13, 2025
26b5add
Fixed sidebar
Mikehrn Jan 13, 2025
1ec477d
Add back link for mobile
Mikehrn Jan 14, 2025
b0377e7
Merged main
Mikehrn Jan 14, 2025
c218fbf
Linting fixes
Mikehrn Jan 14, 2025
a88eb52
Get ID before getting members
Mikehrn Jan 14, 2025
ae4ab3c
Minor fix
Mikehrn Jan 14, 2025
4bace0d
Fixed state
Mikehrn Jan 14, 2025
e5ef994
Fix tooltip
Mikehrn Jan 14, 2025
93d30e0
Cleanup redirects
Mikehrn Jan 14, 2025
3cc7b80
Update copy
Mikehrn Jan 14, 2025
abcee78
Add middleware check for server settings routes
Mikehrn Jan 15, 2025
584cb51
Add middleware check for server settings routes
Mikehrn Jan 15, 2025
d68549f
Change to existing middleware
Mikehrn Jan 15, 2025
c9fbd83
Fix titles
Mikehrn Jan 15, 2025
b27b6e8
Merge branch 'main' into mike/settings-as-pages
Mikehrn Jan 17, 2025
82f1c01
Addressed merge comments
Mikehrn Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 4 additions & 57 deletions packages/frontend-2/components/header/NavUserMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@
</div>
<MenuItem v-if="activeUser" v-slot="{ active }">
<NuxtLink
:to="settingsRoutes.user.profile.route"
:class="[
active ? 'bg-highlight-1' : '',
'text-body-xs flex px-2 py-1 text-foreground cursor-pointer transition mx-1 rounded'
]"
@click="toggleSettingsDialog(SettingMenuKeys.User.Profile)"
>
Settings
</NuxtLink>
</MenuItem>
<MenuItem v-if="isAdmin" v-slot="{ active }">
<NuxtLink
:to="settingsRoutes.server.general.route"
:class="[
active ? 'bg-highlight-1' : '',
'text-body-xs flex px-2 py-1 text-foreground cursor-pointer transition mx-1 rounded'
]"
@click="toggleSettingsDialog(SettingMenuKeys.Server.General)"
>
Server settings
</NuxtLink>
Expand Down Expand Up @@ -125,52 +125,31 @@
</Transition>
</Menu>
<InviteDialogServer v-model:open="showInviteDialog" />
<SettingsDialog
v-model:open="showSettingsDialog"
v-model:target-menu-item="settingsDialogTarget"
v-model:target-workspace-id="workspaceSettingsDialogTarget"
/>
<FeedbackDialog v-model:open="showFeedbackDialog" />
</div>
</template>
<script setup lang="ts">
import { isString } from 'lodash'
import { useBreakpoints } from '@vueuse/core'
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
import { ChevronDownIcon } from '@heroicons/vue/24/outline'
import { Roles } from '@speckle/shared'
import { TailwindBreakpoints } from '~~/lib/common/helpers/tailwind'
import { useActiveUser } from '~~/lib/auth/composables/activeUser'
import { useAuthManager } from '~~/lib/auth/composables/auth'
import { useTheme } from '~~/lib/core/composables/theme'
import { downloadManagerUrl } from '~/lib/common/helpers/route'
import { downloadManagerUrl, settingsRoutes } from '~/lib/common/helpers/route'
import type { RouteLocationRaw } from 'vue-router'
import { ToastNotificationType, useGlobalToast } from '~~/lib/common/composables/toast'
import { useServerInfo } from '~/lib/core/composables/server'
import {
SettingMenuKeys,
type AvailableSettingsMenuKeys
} from '~/lib/settings/helpers/types'

defineProps<{
loginUrl?: RouteLocationRaw
}>()

const route = useRoute()
const { logout } = useAuthManager()
const { activeUser, isGuest } = useActiveUser()
const { isDarkTheme, toggleTheme } = useTheme()
const router = useRouter()
const { triggerNotification } = useGlobalToast()
const { serverInfo } = useServerInfo()
const breakpoints = useBreakpoints(TailwindBreakpoints)
const menuButtonId = useId()

const showInviteDialog = ref(false)
const showSettingsDialog = ref(false)
const settingsDialogTarget = ref<string | null>(null)
const workspaceSettingsDialogTarget = ref<string | null>(null)
const menuButtonId = useId()
const isMobile = breakpoints.smaller('md')
const showFeedbackDialog = ref(false)

const version = computed(() => serverInfo.value?.version)
Expand All @@ -180,39 +159,7 @@ const toggleInviteDialog = () => {
showInviteDialog.value = true
}

const toggleSettingsDialog = (target: AvailableSettingsMenuKeys) => {
showSettingsDialog.value = true

// On mobile open the modal but dont set the target
settingsDialogTarget.value = !isMobile.value ? target : null
}

const deleteSettingsQuery = (): void => {
const currentQueryParams = { ...route.query }
delete currentQueryParams.settings
router.push({ query: currentQueryParams })
}

const openFeedbackDialog = () => {
showFeedbackDialog.value = true
}

onMounted(() => {
const settingsQuery = route.query?.settings

if (settingsQuery && isString(settingsQuery)) {
if (settingsQuery.includes('server') && !isAdmin.value) {
triggerNotification({
type: ToastNotificationType.Danger,
title: "You don't have access to server settings"
})

return
}

showSettingsDialog.value = true
settingsDialogTarget.value = settingsQuery
deleteSettingsQuery()
}
})
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
max-width="md"
:buttons="dialogButtons"
>
<template #header>Unsaved Changes</template>
<template #header>Unsaved changes</template>
<div class="space-y-4">
<p>You have unsaved changes. Do you want to save them before leaving?</p>
</div>
Expand Down Expand Up @@ -113,12 +113,12 @@ const resetLocalState = () => {

const dialogButtons = computed<LayoutDialogButton[]>(() => [
{
text: 'Discard Changes',
text: 'Discard changes',
props: { color: 'outline' },
onClick: handleRedirection
},
{
text: 'Save Changes',
text: 'Save changes',
props: {
submit: true
},
Expand Down
Loading