-
Notifications
You must be signed in to change notification settings - Fork 238
fix: hide granular project access behind flag #3073
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,12 @@ | ||||||||||||||||||
| import { Dependencies, PAGE_LIMIT } from '$lib/constants'; | ||||||||||||||||||
| import { flags } from '$lib/flags'; | ||||||||||||||||||
| import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load'; | ||||||||||||||||||
| import { sdk } from '$lib/stores/sdk'; | ||||||||||||||||||
| import { Query } from '@appwrite.io/console'; | ||||||||||||||||||
| import type { PageLoad } from './$types'; | ||||||||||||||||||
|
|
||||||||||||||||||
| export const load: PageLoad = async ({ url, params, route, depends }) => { | ||||||||||||||||||
| export const load: PageLoad = async ({ url, params, route, depends, parent }) => { | ||||||||||||||||||
| const { account, organization } = await parent(); | ||||||||||||||||||
| depends(Dependencies.ORGANIZATION); | ||||||||||||||||||
| depends(Dependencies.MEMBERS); | ||||||||||||||||||
|
Comment on lines
+8
to
11
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -13,18 +15,22 @@ export const load: PageLoad = async ({ url, params, route, depends }) => { | |||||||||||||||||
| const limit = getLimit(url, route, PAGE_LIMIT); | ||||||||||||||||||
| const offset = pageToOffset(page, limit); | ||||||||||||||||||
|
|
||||||||||||||||||
| const supportsProjectRoles = flags.granularProjectAccess({ account, organization }); | ||||||||||||||||||
|
|
||||||||||||||||||
| const [organizationMembers, orgProjects] = await Promise.all([ | ||||||||||||||||||
| sdk.forConsole.teams.listMemberships({ | ||||||||||||||||||
| teamId: params.organization, | ||||||||||||||||||
| queries: [Query.limit(limit), Query.offset(offset)], | ||||||||||||||||||
| search | ||||||||||||||||||
| }), | ||||||||||||||||||
| sdk.forConsole | ||||||||||||||||||
| .organization(params.organization) | ||||||||||||||||||
| .listProjects({ | ||||||||||||||||||
| queries: [Query.limit(100), Query.equal('teamId', params.organization)] | ||||||||||||||||||
| }) | ||||||||||||||||||
| .catch(() => null) | ||||||||||||||||||
| supportsProjectRoles | ||||||||||||||||||
| ? sdk.forConsole | ||||||||||||||||||
| .organization(params.organization) | ||||||||||||||||||
| .listProjects({ | ||||||||||||||||||
| queries: [Query.limit(100), Query.equal('teamId', params.organization)] | ||||||||||||||||||
| }) | ||||||||||||||||||
| .catch(() => null) | ||||||||||||||||||
| : null | ||||||||||||||||||
| ]); | ||||||||||||||||||
|
|
||||||||||||||||||
| return { | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supportsProjectRolesreactive statement does not coerce the last operand to boolean, so its type isboolean | undefinedrather thanboolean. While Svelte's{#if}treatsundefinedas falsy, the equivalent derived values increateMember.svelteandedit.svelteboth use!!for consistency. Keeping the same style avoids subtle surprises if this value is ever passed to a function that checks strict type equality.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!