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

Feat: Setting as pages #3813

wants to merge 28 commits into from

Conversation

Mikehrn
Copy link
Contributor

@Mikehrn Mikehrn commented Jan 14, 2025

This PR moves away from the settings modal in favor of having them as pages. Some clean-up and bugfixes have been done for the content overall no changes have been made. There is still some room for improvement there, but we can address these in follow-up PRs

@@ -21,6 +21,71 @@ export const defaultZapierWebhookUrl =
'https://hooks.zapier.com/hooks/catch/12120532/2m4okri/'
export const guideBillingUrl = 'https://speckle.guide/workspaces/billing.html'

export const settingsRoutes = {
user: {
profile: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both route and name are needed, because they are used in different scenarios (for example checking if a route by name needs SSO access)

@@ -123,3 +123,11 @@ export const workspaceWizardRegionQuery = graphql(`
}
}
`)

export const workspaceGetIdBySlugQuery = graphql(`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some queries are not possible with workspaceBySlug, as nested properties in some cases need an ID and don't work with slug, so this call is done first to get the id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There used to be that hack where we just take the workspace's id from the apollo cache, cause it should already be there from the access checks done in middlewares. Can we do that here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you remember which hack this was, or maybe @andrewwallacespeckle knows? I vaguely remember it, but dont remember where we are doing this

@Mikehrn Mikehrn marked this pull request as ready for review January 15, 2025 11:15
Copy link
Contributor

@fabis94 fabis94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks very good for the most part, great to see a lot of this cleaned up

title: 'General',
component: SettingsWorkspaceGeneral,
getRoute: (slug?: string) =>
slug ? settingsRoutes.workspace.general.route(slug) : '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this? Seems like it needs a slug to be able to build the route, so why not make it non-optional? If its because you're typing it as SettingsMenuItem[] where all entries have the same type, then maybe we shouldn't do that?

If you just want to assert that it should fit that type, but may also have extra typing info besides that you can do [..] satisfies SettingsMenuItem[]

packages/frontend-2/components/settings/Sidebar.vue Outdated Show resolved Hide resolved
packages/frontend-2/components/settings/Sidebar.vue Outdated Show resolved Hide resolved
packages/frontend-2/components/settings/Sidebar.vue Outdated Show resolved Hide resolved
@@ -27,6 +27,15 @@ import {
} from '~~/lib/server-management/graphql/queries'
import { useQuery } from '@vue/apollo-composable'

definePageMeta({
middleware: ['auth', 'settings', 'admin'],
Copy link
Contributor

@fabis94 fabis94 Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to define these on every single settings page - not only that's WET, but someone will definitely at some point forget to add them to a new one. If the settings pages are correctly set up as nested pages from a top-level settings.vue page (that embeds further pages through <NuxtPage>), you can just apply these middlewares once to that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes for 'admin' - assuming all admin pages go under settings/server/*, you can just add that middleware to server.vue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik this will also create a route for /settings, /user & /server, do you know if there a way to avoid it? I can redirect those, but I don't know if that's worth the trade-off of just defining the middleware

packages/frontend-2/pages/settings/user/profile.vue Outdated Show resolved Hide resolved
@@ -8,20 +8,20 @@
class="mb-6"
/>
<LayoutTabsHorizontal v-model:active-item="activeTab" :items="tabItems">
<template #default="{ activeItem }">
<template v-if="workspace" #default="{ activeItem }">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike the fact that you need to load to completion the workspace GQL query before you can even start mounting the subsequent components and their queries. This is why I think I'd rather rely on the apollo.cache hack

@@ -116,9 +110,9 @@
</div>

<SettingsWorkspacesSecurityDomainRemoveDialog
v-if="removeDialogDomain"
v-if="removeDialogDomain && workspace"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto, every time we do v-if="workspace" on a component we're making the components load in serially, so if they have their own queries they're executed serially instead of in parallel

const mutationResult = await apollo.mutate({
mutation: SettingsUpdateWorkspaceSecurityDocument,
variables: {
input: {
id: props.workspaceId,
id: workspace.value?.id,
discoverabilityEnabled: newVal
}
},
optimisticResponse: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we at least add a FIXME here to clean this up? the optimisticResponse still doesn't make any sense to me and cache.modify should be replaced with modifyObjectField

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also: if workspace.value?.id is gonna be undefined (i see the optional chaining), this will probably fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants