-
Notifications
You must be signed in to change notification settings - Fork 249
Expand file tree
/
Copy path+page.svelte
More file actions
120 lines (109 loc) · 4.33 KB
/
Copy path+page.svelte
File metadata and controls
120 lines (109 loc) · 4.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<script lang="ts">
import { sdk } from '$lib/stores/sdk';
import { ID } from '@appwrite.io/console';
import { onMount } from 'svelte';
import { addNotification } from '$lib/stores/notifications';
import { project } from '../store';
import { Container } from '$lib/layout';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import UpdateName from './updateName.svelte';
import UpdateProtocols from './updateProtocols.svelte';
import UpdateServices from './updateServices.svelte';
import UpdateInstallations from './updateInstallations.svelte';
import DeleteProject from './deleteProject.svelte';
import { Submit, trackEvent } from '$lib/actions/analytics';
import { canWriteProjects } from '$lib/stores/roles';
import ChangeOrganization from './changeOrganization.svelte';
import UpdateVariables from '../updateVariables.svelte';
import { page } from '$app/state';
import UpdateLabels from './updateLabels.svelte';
import PremiumGeoDB from './premiumGeoDB.svelte';
import { isCloud } from '$lib/system';
import type { PageData } from './$types';
import { Alert } from '@appwrite.io/pink-svelte';
let { data }: { data: PageData } = $props();
onMount(() => {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const alert = urlParams.get('alert') ?? '';
let notified = false;
if (alert === 'installation-created') {
addNotification({
type: 'success',
message: `Git installation has imported to your project`
});
trackEvent(Submit.InstallationCreate);
notified = true;
} else if (alert === 'installation-updated') {
addNotification({
type: 'success',
message: `Git installation has been successfully updated`
});
trackEvent(Submit.InstallationCreate);
notified = true;
}
if (notified) {
window.history.replaceState(
{},
document.title,
window.location.origin + window.location.pathname
);
}
});
async function sdkCreateVariable(key: string, value: string, secret: boolean) {
await sdk
.forProject(page.params.region, page.params.project)
.projectApi.createVariable({ variableId: ID.unique(), key, value, secret });
await invalidate(Dependencies.PROJECT_VARIABLES);
}
async function sdkUpdateVariable(
variableId: string,
key: string,
value: string,
secret: boolean
) {
await sdk
.forProject(page.params.region, page.params.project)
.projectApi.updateVariable({ variableId, key, value, secret });
await invalidate(Dependencies.PROJECT_VARIABLES);
}
async function sdkDeleteVariable(variableId: string) {
await sdk
.forProject(page.params.region, page.params.project)
.projectApi.deleteVariable({ variableId });
await invalidate(Dependencies.PROJECT_VARIABLES);
}
</script>
<Container>
{#if $project}
{#if !$canWriteProjects}
<Alert.Inline status="info" title="Read-only project settings">
You can open this settings area, but editing project-level settings requires the
<code>projects.write</code> scope.
</Alert.Inline>
{/if}
<UpdateName />
<UpdateLabels />
<UpdateProtocols />
<UpdateServices />
<UpdateInstallations {...data.installations} limit={data.limit} offset={data.offset} />
{#if isCloud && $canWriteProjects}
<PremiumGeoDB addons={data.addons} addonPrice={data.addonPrice} />
{/if}
<UpdateVariables
{sdkCreateVariable}
{sdkUpdateVariable}
{sdkDeleteVariable}
disabled={!$canWriteProjects}
isGlobal
variableList={data.variables}
backendPagination
variablesOffset={data.variablesOffset}
variablesLimit={data.limit}
project={data.project}
analyticsSource="project_settings" />
<ChangeOrganization />
<DeleteProject />
{/if}
</Container>