Skip to content

Commit ecdf051

Browse files
authored
Merge pull request #3078 from appwrite/feat-project-specific-roles-plan-flag
feat: gate project-specific roles on supportsProjectSpecificRoles plag
2 parents 378c7c6 + 08d0060 commit ecdf051

7 files changed

Lines changed: 15 additions & 37 deletions

File tree

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"dependencies": {
2222
"@ai-sdk/svelte": "^1.1.24",
23-
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@5c7f8e5",
23+
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@82069e6",
2424
"@appwrite.io/pink-icons": "0.25.0",
2525
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@bfe7ce3",
2626
"@appwrite.io/pink-legacy": "^1.0.3",

src/lib/flags.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ function isFlagEnabled(name: string) {
2020

2121
export const flags = {
2222
multiDb: isFlagEnabled('multi-db'),
23-
granularProjectAccess: isFlagEnabled('granular-project-access'),
2423
oauth2Server: isFlagEnabled('oauth2-server')
2524
};

src/routes/(console)/organization-[organization]/createMember.svelte

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
1212
import { isCloud, isSelfHosted } from '$lib/system';
1313
import { roles, buildProjectRole } from '$lib/stores/billing';
14-
import { flags } from '$lib/flags';
15-
import { user } from '$lib/stores/user';
1614
import InputSelect from '$lib/elements/forms/inputSelect.svelte';
1715
import Roles from '$lib/components/roles/roles.svelte';
1816
import { Icon, Popover, Layout } from '@appwrite.io/pink-svelte';
@@ -28,11 +26,7 @@
2826
oncreated?: (team: Models.Membership) => void;
2927
} = $props();
3028
31-
const supportsProjectRoles = $derived(
32-
isCloud &&
33-
flags.granularProjectAccess({ account: $user, organization: $organization }) &&
34-
!!$currentPlan?.supportsOrganizationRoles
35-
);
29+
const supportsProjectRoles = $derived(isCloud && !!$currentPlan?.supportsProjectSpecificRoles);
3630
3731
let email = $state('');
3832
let name = $state('');

src/routes/(console)/organization-[organization]/members/+page.svelte

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020
} from '$lib/helpers/tooltipContent';
2121
import { addNotification } from '$lib/stores/notifications';
2222
import { currentPlan, newMemberModal, organization } from '$lib/stores/organization';
23-
import { flags } from '$lib/flags';
2423
import { isOwner } from '$lib/stores/roles';
2524
import { sdk } from '$lib/stores/sdk';
26-
import { user } from '$lib/stores/user';
2725
import type { Models } from '@appwrite.io/console';
2826
import Delete from '../deleteMember.svelte';
2927
import Edit from './edit.svelte';
@@ -62,10 +60,8 @@
6260
$: isLimited = limit !== 0 && limit < Infinity;
6361
$: isButtonDisabled =
6462
isCloud && (($readOnly && !GRACE_PERIOD_OVERRIDE) || (isLimited && memberCount >= limit));
65-
$: supportsProjectRoles =
66-
isCloud &&
67-
flags.granularProjectAccess({ account: $user, organization: $organization }) &&
68-
$currentPlan?.supportsOrganizationRoles;
63+
$: supportsOrgRoles = isCloud && !!$currentPlan?.supportsOrganizationRoles;
64+
$: supportsProjectRoles = isCloud && !!$currentPlan?.supportsProjectSpecificRoles;
6965
7066
const resend = async (member: Models.Membership) => {
7167
try {
@@ -223,7 +219,7 @@
223219
</Button.Button>
224220
<div style:min-width="232px" slot="tooltip">
225221
<ActionMenu.Root>
226-
{#if supportsProjectRoles}
222+
{#if supportsOrgRoles || supportsProjectRoles}
227223
<ActionMenu.Item.Button
228224
trailingIcon={IconPencil}
229225
on:click={() => {

src/routes/(console)/organization-[organization]/members/+page.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
2-
import { flags } from '$lib/flags';
32
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
43
import { sdk } from '$lib/stores/sdk';
54
import { Query } from '@appwrite.io/console';
65
import type { PageLoad } from './$types';
76

87
export const load: PageLoad = async ({ url, params, route, depends, parent }) => {
9-
const { account, organization } = await parent();
8+
await parent();
109
depends(Dependencies.ORGANIZATION);
1110
depends(Dependencies.MEMBERS);
1211

@@ -15,22 +14,18 @@ export const load: PageLoad = async ({ url, params, route, depends, parent }) =>
1514
const limit = getLimit(url, route, PAGE_LIMIT);
1615
const offset = pageToOffset(page, limit);
1716

18-
const supportsProjectRoles = flags.granularProjectAccess({ account, organization });
19-
2017
const [organizationMembers, orgProjects] = await Promise.all([
2118
sdk.forConsole.teams.listMemberships({
2219
teamId: params.organization,
2320
queries: [Query.limit(limit), Query.offset(offset)],
2421
search
2522
}),
26-
supportsProjectRoles
27-
? sdk.forConsole
28-
.organization(params.organization)
29-
.listProjects({
30-
queries: [Query.limit(100), Query.equal('teamId', params.organization)]
31-
})
32-
.catch(() => null)
33-
: null
23+
sdk.forConsole
24+
.organization(params.organization)
25+
.listProjects({
26+
queries: [Query.limit(100), Query.equal('teamId', params.organization)]
27+
})
28+
.catch(() => null)
3429
]);
3530

3631
return {

src/routes/(console)/organization-[organization]/members/edit.svelte

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
buildProjectRole
2020
} from '$lib/stores/billing';
2121
import { isCloud, isSelfHosted } from '$lib/system';
22-
import { flags } from '$lib/flags';
23-
import { user } from '$lib/stores/user';
2422
import ProjectAccessSelector from '../projectAccessSelector.svelte';
2523
2624
let {
@@ -33,11 +31,7 @@
3331
onupdated?: (membership: Models.Membership) => void;
3432
} = $props();
3533
36-
const supportsProjectRoles = $derived(
37-
isCloud &&
38-
flags.granularProjectAccess({ account: $user, organization: $organization }) &&
39-
!!$currentPlan?.supportsOrganizationRoles
40-
);
34+
const supportsProjectRoles = $derived(isCloud && !!$currentPlan?.supportsProjectSpecificRoles);
4135
const defaultRole = isSelfHosted ? 'owner' : 'developer';
4236
4337
let error = $state<string>(null);

0 commit comments

Comments
 (0)