mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: permissions
This commit is contained in:
+13
-9
@@ -46,10 +46,11 @@
|
||||
let repositoryPrivate = true;
|
||||
let selectedInstallationId = '';
|
||||
let selectedRepository = '';
|
||||
let showSiteConfig = false;
|
||||
let showConfig = false;
|
||||
let silentMode = false;
|
||||
let entrypoint = '';
|
||||
let scopes: string[] = [];
|
||||
let selectedScopes: string[] = [];
|
||||
let execute = false;
|
||||
let variables: Partial<Models.Variable>[] = [];
|
||||
|
||||
onMount(async () => {
|
||||
@@ -83,7 +84,7 @@
|
||||
);
|
||||
repository.set(repo);
|
||||
selectedRepository = repo.id;
|
||||
showSiteConfig = true;
|
||||
showConfig = true;
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
@@ -107,7 +108,7 @@
|
||||
id,
|
||||
name,
|
||||
runtime as Runtime,
|
||||
undefined,
|
||||
undefined, //excute ? permissions || undefined : undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
@@ -115,7 +116,7 @@
|
||||
undefined,
|
||||
entrypoint,
|
||||
undefined,
|
||||
scopes,
|
||||
selectedScopes?.length ? selectedScopes : undefined,
|
||||
$installation.$id,
|
||||
$repository.id,
|
||||
branch,
|
||||
@@ -206,7 +207,7 @@
|
||||
confirmExit>
|
||||
<Form bind:this={formComponent} onSubmit={create} bind:isSubmitting>
|
||||
<Layout.Stack gap="xl">
|
||||
{#if selectedRepository && showSiteConfig}
|
||||
{#if selectedRepository && showConfig}
|
||||
<Layout.Stack gap="xxl">
|
||||
<Card isTile padding="s" radius="s">
|
||||
<Layout.Stack
|
||||
@@ -224,7 +225,7 @@
|
||||
size="s"
|
||||
secondary
|
||||
on:click={() => {
|
||||
showSiteConfig = false;
|
||||
showConfig = false;
|
||||
}}>
|
||||
Update
|
||||
</Button>
|
||||
@@ -265,7 +266,10 @@
|
||||
<Layout.Stack gap="xxl">
|
||||
<Details bind:name bind:id bind:runtime bind:entrypoint {options} />
|
||||
|
||||
<Permissions bind:templateScopes={data.template.scopes} />
|
||||
<Permissions
|
||||
templateScopes={data.template.scopes}
|
||||
bind:selectedScopes
|
||||
bind:execute />
|
||||
|
||||
<ConnectBehaviour bind:connectBehaviour />
|
||||
</Layout.Stack>
|
||||
@@ -308,7 +312,7 @@
|
||||
repository.set(e.detail);
|
||||
repositoryName = e.detail.name;
|
||||
selectedRepository = e.detail.id;
|
||||
showSiteConfig = true;
|
||||
showConfig = true;
|
||||
}} />
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
|
||||
+21
-24
@@ -3,24 +3,17 @@
|
||||
import { Fieldset, Layout, Selector } from '@appwrite.io/pink-svelte';
|
||||
|
||||
export let templateScopes: string[];
|
||||
export let selectedScopes: string[];
|
||||
export let execute = false;
|
||||
|
||||
let execute = false;
|
||||
// onMount(() => {
|
||||
// $templateConfig.execute = $template.permissions.includes('any');
|
||||
// templateScopes = scopes
|
||||
// .filter((scope) => $template.scopes.includes(scope.scope))
|
||||
// .map((scope) => ({
|
||||
// ...scope,
|
||||
// active: true
|
||||
// }));
|
||||
// });
|
||||
|
||||
// $: $templateConfig.scopes = templateScopes
|
||||
// ?.filter((scope) => scope.active)
|
||||
// ?.map((scope) => scope.scope);
|
||||
|
||||
$: console.log(templateScopes);
|
||||
$: console.log(scopes);
|
||||
let scopeList = scopes
|
||||
.filter((s) => templateScopes.includes(s.scope))
|
||||
.map((s) => {
|
||||
return {
|
||||
value: s,
|
||||
checked: false
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<Fieldset legend="Permissions">
|
||||
@@ -33,14 +26,18 @@
|
||||
bind:checked={execute}>
|
||||
</Selector.Switch>
|
||||
|
||||
{#if templateScopes.length > 0}
|
||||
{#each templateScopes as s}
|
||||
{@const scope = scopes.find((sc) => sc.scope === s)}
|
||||
{#if scopeList.length > 0}
|
||||
{#each scopeList as scope}
|
||||
<Selector.Switch
|
||||
id={scope.scope}
|
||||
label={scope.scope}
|
||||
description={scope.description}
|
||||
bind:checked={execute}>
|
||||
id={scope.value.scope}
|
||||
label={scope.value.scope}
|
||||
description={scope.value.description}
|
||||
bind:checked={scope.checked}
|
||||
on:change={() => {
|
||||
selectedScopes = scopeList
|
||||
.filter((s) => s.checked)
|
||||
.map((s) => s.value.scope);
|
||||
}}>
|
||||
</Selector.Switch>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user