mirror of
https://github.com/appwrite/console.git
synced 2026-04-07 19:17:46 +00:00
hide command prompt, prompts based on roles
This commit is contained in:
@@ -40,4 +40,5 @@ export const canSeeBilling = derived(scopes, ($scopes) => $scopes.includes('bill
|
||||
export const canSeeProjects = derived(scopes, ($scopes) => $scopes.includes('projects.read'));
|
||||
export const canSeeDatabases = derived(scopes, ($scopes) => $scopes.includes('databases.read'));
|
||||
export const canSeeFunctions = derived(scopes, ($scopes) => $scopes.includes('functions.read'));
|
||||
export const canSeeBuckets = derived(scopes, ($scopes) => $scopes.includes('projects.read'));
|
||||
export const canSeeBuckets = derived(scopes, ($scopes) => $scopes.includes('buckets.read'));
|
||||
export const canSeeMessages = derived(scopes, ($scopes) => $scopes.includes('messages.read'));
|
||||
@@ -43,6 +43,7 @@
|
||||
import { headerAlert } from '$lib/stores/headerAlert';
|
||||
import { UsageRates } from '$lib/components/billing';
|
||||
import { base } from '$app/paths';
|
||||
import { canSeeProjects } from '$lib/stores/roles';
|
||||
|
||||
function kebabToSentenceCase(str: string) {
|
||||
return str
|
||||
@@ -66,9 +67,10 @@
|
||||
keys: ['g', 'p'],
|
||||
group: 'navigation',
|
||||
disabled:
|
||||
$page.url.pathname.includes('/console/organization-') &&
|
||||
!$page.url.pathname.endsWith('/members') &&
|
||||
!$page.url.pathname.endsWith('/settings'),
|
||||
($page.url.pathname.includes('/console/organization-') &&
|
||||
!$page.url.pathname.endsWith('/members') &&
|
||||
!$page.url.pathname.endsWith('/settings')) ||
|
||||
!$canSeeProjects,
|
||||
rank: -1
|
||||
},
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { requestedMigration } from '$routes/store';
|
||||
import { openMigrationWizard } from '../(migration-wizard)';
|
||||
import { base } from '$app/paths';
|
||||
import { isOwner } from '$lib/stores/roles';
|
||||
|
||||
export let data;
|
||||
|
||||
@@ -22,7 +23,7 @@
|
||||
goto(`${base}/organization-${data.organization.$id}/members`);
|
||||
},
|
||||
keys: ['g', 'm'],
|
||||
disabled: $page.url.pathname.endsWith('/members'),
|
||||
disabled: $page.url.pathname.endsWith('/members') || !$isOwner,
|
||||
group: 'navigation'
|
||||
},
|
||||
{
|
||||
@@ -31,7 +32,7 @@
|
||||
goto(`${base}/organization-${data.organization.$id}/settings`);
|
||||
},
|
||||
keys: ['g', 's'],
|
||||
disabled: $page.url.pathname.endsWith('/settings'),
|
||||
disabled: $page.url.pathname.endsWith('/settings') || !$isOwner,
|
||||
group: 'navigation'
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
showCreate = true;
|
||||
},
|
||||
keys: ['c'],
|
||||
disabled: $readOnly && !GRACE_PERIOD_OVERRIDE,
|
||||
disabled: ($readOnly && !GRACE_PERIOD_OVERRIDE) || !$canWriteProjects,
|
||||
group: 'projects',
|
||||
icon: 'plus'
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import { MigrationBox } from '$lib/components';
|
||||
import { page } from '$app/stores';
|
||||
import { base } from '$app/paths';
|
||||
import { canSeeBuckets, canSeeDatabases, canSeeFunctions, canSeeMessages, canWriteProjects } from '$lib/stores/roles';
|
||||
|
||||
onMount(() => {
|
||||
return sdk.forConsole.client.subscribe(['project', 'console'], (response) => {
|
||||
@@ -43,7 +44,8 @@
|
||||
goto(`${base}/project-${$project.$id}/databases`);
|
||||
},
|
||||
keys: ['g', 'd'],
|
||||
group: 'navigation'
|
||||
group: 'navigation',
|
||||
disabled: !$canSeeDatabases
|
||||
},
|
||||
{
|
||||
label: 'Go to Functions',
|
||||
@@ -51,7 +53,8 @@
|
||||
goto(`${base}/project-${$project.$id}/functions`);
|
||||
},
|
||||
keys: ['g', 'f'],
|
||||
group: 'navigation'
|
||||
group: 'navigation',
|
||||
disabled: !$canSeeFunctions
|
||||
},
|
||||
{
|
||||
label: 'Go to Messaging',
|
||||
@@ -59,7 +62,7 @@
|
||||
goto(`${base}/project-${$project.$id}/messaging`);
|
||||
},
|
||||
keys: ['g', 'm'],
|
||||
disabled: $page.url.pathname.endsWith('messaging'),
|
||||
disabled: $page.url.pathname.endsWith('messaging') || !$canSeeMessages,
|
||||
group: 'navigation'
|
||||
},
|
||||
{
|
||||
@@ -68,7 +71,8 @@
|
||||
goto(`${base}/project-${$project.$id}/storage`);
|
||||
},
|
||||
keys: ['g', 's'],
|
||||
group: 'navigation'
|
||||
group: 'navigation',
|
||||
disabled: !$canSeeBuckets
|
||||
},
|
||||
{
|
||||
label: 'Go to Settings',
|
||||
@@ -76,7 +80,8 @@
|
||||
goto(`${base}/project-${$project.$id}/settings`);
|
||||
},
|
||||
keys: ['g', 'e'],
|
||||
group: 'navigation'
|
||||
group: 'navigation',
|
||||
disabled: !$canWriteProjects
|
||||
},
|
||||
{
|
||||
label: 'Go to Overview',
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { addSubPanel, registerCommands, updateCommandGroupRanks } from '$lib/commandCenter';
|
||||
import { TeamsPanel, UsersPanel } from '$lib/commandCenter/panels';
|
||||
import { readOnly } from '$lib/stores/billing';
|
||||
import { canWriteTeams, canWriteUsers } from '$lib/stores/roles';
|
||||
import { GRACE_PERIOD_OVERRIDE } from '$lib/system';
|
||||
import { project } from '../store';
|
||||
import { showCreateUser } from './+page.svelte';
|
||||
@@ -23,7 +24,7 @@
|
||||
group: 'users',
|
||||
icon: 'plus',
|
||||
rank: $page.url.pathname.endsWith('auth') ? 10 : 0,
|
||||
disabled: $readOnly && !GRACE_PERIOD_OVERRIDE
|
||||
disabled: ($readOnly && !GRACE_PERIOD_OVERRIDE) || !$canWriteUsers
|
||||
},
|
||||
{
|
||||
label: 'Create team',
|
||||
@@ -38,7 +39,7 @@
|
||||
group: 'teams',
|
||||
icon: 'plus',
|
||||
rank: $page.url.pathname.endsWith('teams') ? 10 : 0,
|
||||
disabled: $readOnly && !GRACE_PERIOD_OVERRIDE
|
||||
disabled: ($readOnly && !GRACE_PERIOD_OVERRIDE) || !$canWriteTeams
|
||||
},
|
||||
{
|
||||
label: 'Go to teams',
|
||||
@@ -68,7 +69,7 @@
|
||||
},
|
||||
group: 'navigation',
|
||||
rank: 1,
|
||||
disabled: $page.url.pathname.endsWith('security')
|
||||
disabled: $page.url.pathname.endsWith('security') || !$canWriteUsers
|
||||
},
|
||||
{
|
||||
label: 'Go to settings',
|
||||
@@ -78,7 +79,7 @@
|
||||
},
|
||||
group: 'navigation',
|
||||
rank: 1,
|
||||
disabled: $page.url.pathname.endsWith('settings')
|
||||
disabled: $page.url.pathname.endsWith('settings') || !$canWriteUsers
|
||||
},
|
||||
{
|
||||
label: 'Find users',
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
showCreate = true;
|
||||
},
|
||||
keys: ['c'],
|
||||
disabled: showCreate || isCreationDisabled,
|
||||
disabled: showCreate || isCreationDisabled || !$canWriteDatabases,
|
||||
icon: 'plus',
|
||||
group: 'databases',
|
||||
rank: 10
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
import CreateCollection from './createCollection.svelte';
|
||||
import { showCreate } from './store';
|
||||
import { CollectionsPanel } from '$lib/commandCenter/panels';
|
||||
import { canWriteCollections, canWriteDatabases } from '$lib/stores/roles';
|
||||
|
||||
const project = $page.params.project;
|
||||
const databaseId = $page.params.database;
|
||||
@@ -36,7 +37,7 @@
|
||||
}
|
||||
},
|
||||
keys: $page.url.pathname.endsWith(databaseId) ? ['c'] : ['c', 'c'],
|
||||
disabled: $page.url.pathname.includes('collection-'),
|
||||
disabled: $page.url.pathname.includes('collection-') || !$canWriteCollections,
|
||||
group: 'collections',
|
||||
icon: 'plus'
|
||||
},
|
||||
@@ -68,7 +69,7 @@
|
||||
},
|
||||
disabled:
|
||||
$page.url.pathname.includes('/settings') ||
|
||||
$page.url.pathname.includes('collection-'),
|
||||
$page.url.pathname.includes('collection-') || !$canWriteDatabases,
|
||||
keys: ['g', 's'],
|
||||
group: 'collections'
|
||||
},
|
||||
|
||||
+9
-6
@@ -32,6 +32,7 @@
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import CreateDocument from './createDocument.svelte';
|
||||
import { base } from '$app/paths';
|
||||
import { canWriteCollections } from '$lib/stores/roles';
|
||||
|
||||
let unsubscribe: { (): void };
|
||||
|
||||
@@ -69,7 +70,8 @@
|
||||
addSubPanel(CreateAttributePanel);
|
||||
},
|
||||
icon: 'plus',
|
||||
group: 'attributes'
|
||||
group: 'attributes',
|
||||
disabled: !$canWriteCollections
|
||||
},
|
||||
{
|
||||
label: 'Go to documents',
|
||||
@@ -134,7 +136,7 @@
|
||||
`${base}/project-${$project?.$id}/databases/database-${$database?.$id}/collection-${$collection?.$id}/settings`
|
||||
);
|
||||
},
|
||||
disabled: $page.url.pathname.endsWith('settings'),
|
||||
disabled: $page.url.pathname.endsWith('settings') || !$canWriteCollections,
|
||||
group: 'collections'
|
||||
},
|
||||
{
|
||||
@@ -147,7 +149,7 @@
|
||||
group: 'collections',
|
||||
disabled:
|
||||
$page.url.pathname.endsWith('display-name') ||
|
||||
$page.url.pathname.endsWith('settings'),
|
||||
$page.url.pathname.endsWith('settings') || !$canWriteCollections,
|
||||
icon: 'eye'
|
||||
},
|
||||
{
|
||||
@@ -160,7 +162,7 @@
|
||||
group: 'collections',
|
||||
disabled:
|
||||
$page.url.pathname.endsWith('permissions') ||
|
||||
$page.url.pathname.endsWith('settings'),
|
||||
$page.url.pathname.endsWith('settings') || !$canWriteCollections,
|
||||
icon: 'puzzle'
|
||||
},
|
||||
{
|
||||
@@ -173,7 +175,7 @@
|
||||
group: 'collections',
|
||||
disabled:
|
||||
$page.url.pathname.endsWith('document-security') ||
|
||||
$page.url.pathname.endsWith('settings'),
|
||||
$page.url.pathname.endsWith('settings') || !$canWriteCollections,
|
||||
icon: 'lock-closed'
|
||||
},
|
||||
{
|
||||
@@ -183,7 +185,8 @@
|
||||
initCreateIndex();
|
||||
},
|
||||
icon: 'plus',
|
||||
group: 'indexes'
|
||||
group: 'indexes',
|
||||
disabled: !$canWriteCollections
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { addSubPanel, registerCommands } from '$lib/commandCenter';
|
||||
import { FunctionsPanel } from '$lib/commandCenter/panels';
|
||||
import { canSeeFunctions } from '$lib/stores/roles';
|
||||
|
||||
$registerCommands([
|
||||
{
|
||||
@@ -9,7 +10,8 @@
|
||||
addSubPanel(FunctionsPanel);
|
||||
},
|
||||
group: 'functions',
|
||||
rank: -1
|
||||
rank: -1,
|
||||
disabled: !$canSeeFunctions
|
||||
}
|
||||
]);
|
||||
</script>
|
||||
|
||||
@@ -74,9 +74,9 @@
|
||||
keys: ['c'],
|
||||
disabled:
|
||||
$wizard.show ||
|
||||
isServiceLimited('functions', $organization?.billingPlan, $functionsList?.total),
|
||||
isServiceLimited('functions', $organization?.billingPlan, $functionsList?.total) || !$canWriteFunctions,
|
||||
icon: 'plus',
|
||||
group: 'functions'
|
||||
group: 'functions',
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
+14
-7
@@ -9,6 +9,7 @@
|
||||
import { project } from '../../store';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { base } from '$app/paths';
|
||||
import { canWriteFunctions } from '$lib/stores/roles';
|
||||
|
||||
onMount(() => {
|
||||
let previousStatus = null;
|
||||
@@ -47,7 +48,8 @@
|
||||
},
|
||||
keys: $page.url.pathname.endsWith($func.$id) ? ['c'] : ['c', 'd'],
|
||||
group: 'functions',
|
||||
icon: 'plus'
|
||||
icon: 'plus',
|
||||
disabled: !$canWriteFunctions
|
||||
},
|
||||
{
|
||||
label: 'Permissions',
|
||||
@@ -58,7 +60,8 @@
|
||||
scrollBy({ top: -100 });
|
||||
},
|
||||
icon: 'search',
|
||||
group: 'functions'
|
||||
group: 'functions',
|
||||
disabled: !$canWriteFunctions
|
||||
},
|
||||
{
|
||||
label: 'Events',
|
||||
@@ -69,7 +72,8 @@
|
||||
scrollBy({ top: -100 });
|
||||
},
|
||||
icon: 'calendar',
|
||||
group: 'functions'
|
||||
group: 'functions',
|
||||
disabled: !$canWriteFunctions
|
||||
},
|
||||
{
|
||||
label: 'Variables',
|
||||
@@ -79,7 +83,8 @@
|
||||
);
|
||||
},
|
||||
icon: 'list',
|
||||
group: 'functions'
|
||||
group: 'functions',
|
||||
disabled: !$canWriteFunctions
|
||||
},
|
||||
{
|
||||
label: 'Timeout',
|
||||
@@ -89,7 +94,8 @@
|
||||
);
|
||||
},
|
||||
icon: 'x-circle',
|
||||
group: 'functions'
|
||||
group: 'functions',
|
||||
disabled: !$canWriteFunctions
|
||||
},
|
||||
{
|
||||
label: 'Schedule',
|
||||
@@ -100,7 +106,8 @@
|
||||
scrollBy({ top: -100 });
|
||||
},
|
||||
icon: 'clock',
|
||||
group: 'functions'
|
||||
group: 'functions',
|
||||
disabled: !$canWriteFunctions
|
||||
},
|
||||
{
|
||||
label: 'Go to deployments',
|
||||
@@ -140,7 +147,7 @@
|
||||
keys: ['g', 's'],
|
||||
group: 'navigation',
|
||||
rank: 10,
|
||||
disabled: $page.url.pathname.endsWith('settings')
|
||||
disabled: $page.url.pathname.endsWith('settings') || !$canWriteFunctions
|
||||
}
|
||||
]);
|
||||
</script>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import { messagesSearcher } from '$lib/commandCenter/searchers/messages';
|
||||
import { providersSearcher } from '$lib/commandCenter/searchers/providers';
|
||||
import { topicsSearcher } from '$lib/commandCenter/searchers/topics';
|
||||
import { canWriteMessages } from '$lib/stores/roles';
|
||||
import { project } from '../store';
|
||||
|
||||
// TODO: finalize the commands
|
||||
@@ -23,7 +24,8 @@
|
||||
addSubPanel(CreateMessagePanel);
|
||||
},
|
||||
icon: 'plus',
|
||||
group: 'messaging'
|
||||
group: 'messaging',
|
||||
disabled: !$canWriteMessages
|
||||
},
|
||||
{
|
||||
label: 'Go to Topics',
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
import { total } from '$lib/helpers/array';
|
||||
import type { Metric } from '$lib/sdk/usage';
|
||||
import { periodToDates } from '$lib/layout/usage.svelte';
|
||||
import { canWriteProjects } from '$lib/stores/roles';
|
||||
|
||||
$: projectId = $page.params.project;
|
||||
$: path = `${base}/project-${projectId}/overview`;
|
||||
@@ -56,7 +57,8 @@
|
||||
addSubPanel(PlatformsPanel);
|
||||
},
|
||||
icon: 'plus',
|
||||
group: 'integrations'
|
||||
group: 'integrations',
|
||||
disabled: !$canWriteProjects
|
||||
},
|
||||
{
|
||||
label: 'Create API Key',
|
||||
@@ -65,7 +67,8 @@
|
||||
createApiKey();
|
||||
},
|
||||
keys: ['c', 'k'],
|
||||
group: 'integrations'
|
||||
group: 'integrations',
|
||||
disabled: !$canWriteProjects
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { registerCommands, updateCommandGroupRanks } from '$lib/commandCenter';
|
||||
import { canWriteProjects } from '$lib/stores/roles';
|
||||
import { openWebhooksWizard } from './webhooks/+page.svelte';
|
||||
|
||||
$: $registerCommands([
|
||||
@@ -11,7 +12,8 @@
|
||||
callback: () => {
|
||||
openWebhooksWizard();
|
||||
},
|
||||
group: 'webhooks'
|
||||
group: 'webhooks',
|
||||
disabled: !$canWriteProjects
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import { readOnly } from '$lib/stores/billing';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { canWriteProjects } from '$lib/stores/roles';
|
||||
|
||||
export let data;
|
||||
let migration: Models.Migration = null;
|
||||
@@ -57,7 +58,8 @@
|
||||
icon: 'download',
|
||||
keys: ['i', 'd'],
|
||||
callback: openImportWizard,
|
||||
group: 'migrations'
|
||||
group: 'migrations',
|
||||
disabled: !$canWriteProjects
|
||||
},
|
||||
isSelfHosted
|
||||
? {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { page } from '$app/stores';
|
||||
import { addSubPanel, registerCommands, updateCommandGroupRanks } from '$lib/commandCenter';
|
||||
import { BucketsPanel } from '$lib/commandCenter/panels';
|
||||
import { canWriteBuckets } from '$lib/stores/roles';
|
||||
import { project } from '../store';
|
||||
import { showCreateBucket } from './+page.svelte';
|
||||
|
||||
@@ -18,7 +19,8 @@
|
||||
},
|
||||
keys: $page.url.pathname.endsWith('storage') ? ['c'] : ['c', 'b'],
|
||||
icon: 'plus',
|
||||
group: 'buckets'
|
||||
group: 'buckets',
|
||||
disabled: !$canWriteBuckets
|
||||
},
|
||||
{
|
||||
label: 'Go to usage',
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
updateCommandGroupRanks
|
||||
} from '$lib/commandCenter';
|
||||
import { fileSearcher } from '$lib/commandCenter/searchers';
|
||||
import { canWriteBuckets } from '$lib/stores/roles';
|
||||
import { project } from '../../store';
|
||||
import { showCreateFile } from './+page.svelte';
|
||||
import { bucket } from './store';
|
||||
@@ -34,7 +35,8 @@
|
||||
scrollBy({ top: -100 });
|
||||
},
|
||||
group: 'buckets',
|
||||
icon: 'key'
|
||||
icon: 'key',
|
||||
disabled: !$canWriteBuckets
|
||||
},
|
||||
{
|
||||
label: 'Extensions',
|
||||
@@ -44,7 +46,8 @@
|
||||
);
|
||||
},
|
||||
group: 'buckets',
|
||||
icon: 'puzzle'
|
||||
icon: 'puzzle',
|
||||
disabled: !$canWriteBuckets
|
||||
},
|
||||
{
|
||||
label: 'File security',
|
||||
@@ -55,7 +58,8 @@
|
||||
scrollBy({ top: -100 });
|
||||
},
|
||||
group: 'buckets',
|
||||
icon: 'lock-closed'
|
||||
icon: 'lock-closed',
|
||||
disabled: !$canWriteBuckets
|
||||
},
|
||||
{
|
||||
label: 'Go to files',
|
||||
@@ -82,7 +86,7 @@
|
||||
callback() {
|
||||
goto(`${base}/project-${$project.$id}/storage/bucket-${$bucket.$id}/settings`);
|
||||
},
|
||||
disabled: $page.url.pathname.endsWith('settings'),
|
||||
disabled: $page.url.pathname.endsWith('settings') || !$canWriteBuckets,
|
||||
keys: ['g', 's'],
|
||||
group: 'navigation',
|
||||
rank: 10
|
||||
|
||||
Reference in New Issue
Block a user