Skip to content

Commit 9db4cec

Browse files
authored
Merge pull request #2976 from appwrite/fix-project-services-region-and-sdk-list
fix(console): regional Projects API for service toggles + full ApiSer…
2 parents 05ff668 + 8a41ff7 commit 9db4cec

File tree

16 files changed

+566
-182
lines changed

16 files changed

+566
-182
lines changed

bun.lock

Lines changed: 3 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@67539a6",
23+
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@f063676",
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",
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { writable } from 'svelte/store';
2+
import { ProtocolId, type Models } from '@appwrite.io/console';
3+
4+
export type Protocol = {
5+
label: string;
6+
method: ProtocolId;
7+
value: boolean | null;
8+
};
9+
10+
function projectProtocolRows(project: Models.Project | null): Protocol[] {
11+
return [
12+
{
13+
label: 'REST',
14+
method: ProtocolId.Rest,
15+
value: project?.protocolStatusForRest ?? null
16+
},
17+
{
18+
label: 'GraphQL',
19+
method: ProtocolId.Graphql,
20+
value: project?.protocolStatusForGraphql ?? null
21+
},
22+
{
23+
label: 'WebSocket',
24+
method: ProtocolId.Websocket,
25+
value: project?.protocolStatusForWebsocket ?? null
26+
}
27+
];
28+
}
29+
30+
function createProtocols() {
31+
const { subscribe, set } = writable({
32+
list: projectProtocolRows(null)
33+
});
34+
35+
return {
36+
subscribe,
37+
set,
38+
load: (project: Models.Project) => {
39+
set({ list: projectProtocolRows(project) });
40+
}
41+
};
42+
}
43+
44+
export const protocols = createProtocols();

src/lib/stores/project-services.ts

Lines changed: 98 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,116 @@
11
import { writable } from 'svelte/store';
2-
import { ApiService, type Models } from '@appwrite.io/console';
2+
import { ServiceId, type Models } from '@appwrite.io/console';
33

44
export type Service = {
55
label: string;
6-
method: ApiService;
6+
method: ServiceId;
77
value: boolean | null;
88
};
99

10+
function projectServiceRows(project: Models.Project | null): Service[] {
11+
const rows: Service[] = [
12+
{
13+
label: 'Account',
14+
method: ServiceId.Account,
15+
value: project?.serviceStatusForAccount ?? null
16+
},
17+
{
18+
label: 'Avatars',
19+
method: ServiceId.Avatars,
20+
value: project?.serviceStatusForAvatars ?? null
21+
},
22+
{
23+
label: 'Databases',
24+
method: ServiceId.Databases,
25+
value: project?.serviceStatusForDatabases ?? null
26+
},
27+
{
28+
label: 'Functions',
29+
method: ServiceId.Functions,
30+
value: project?.serviceStatusForFunctions ?? null
31+
},
32+
{
33+
label: 'GraphQL',
34+
method: ServiceId.Graphql,
35+
value: project?.serviceStatusForGraphql ?? null
36+
},
37+
{
38+
label: 'Health',
39+
method: ServiceId.Health,
40+
value: project?.serviceStatusForHealth ?? null
41+
},
42+
{
43+
label: 'Locale',
44+
method: ServiceId.Locale,
45+
value: project?.serviceStatusForLocale ?? null
46+
},
47+
{
48+
label: 'Messaging',
49+
method: ServiceId.Messaging,
50+
value: project?.serviceStatusForMessaging ?? null
51+
},
52+
{
53+
label: 'Migrations',
54+
method: ServiceId.Migrations,
55+
value: project?.serviceStatusForMigrations ?? null
56+
},
57+
{
58+
label: 'Project',
59+
method: ServiceId.Project,
60+
value: project?.serviceStatusForProject ?? null
61+
},
62+
// @todo Re-enable when Proxy is ready for public release.
63+
// {
64+
// label: 'Proxy',
65+
// method: ServiceId.Proxy,
66+
// value: project?.serviceStatusForProxy ?? null
67+
// },
68+
{
69+
label: 'Sites',
70+
method: ServiceId.Sites,
71+
value: project?.serviceStatusForSites ?? null
72+
},
73+
{
74+
label: 'Storage',
75+
method: ServiceId.Storage,
76+
value: project?.serviceStatusForStorage ?? null
77+
},
78+
{
79+
label: 'TablesDB',
80+
method: ServiceId.Tablesdb,
81+
value: project?.serviceStatusForTablesdb ?? null
82+
},
83+
{
84+
label: 'Teams',
85+
method: ServiceId.Teams,
86+
value: project?.serviceStatusForTeams ?? null
87+
},
88+
{
89+
label: 'Users',
90+
method: ServiceId.Users,
91+
value: project?.serviceStatusForUsers ?? null
92+
}
93+
// @todo Re-enable when VCS is ready for public release.
94+
// {
95+
// label: 'VCS',
96+
// method: ServiceId.Vcs,
97+
// value: project?.serviceStatusForVcs ?? null
98+
// }
99+
];
100+
101+
return rows.sort((a, b) => a.label.localeCompare(b.label));
102+
}
103+
10104
function createServices() {
11105
const { subscribe, set } = writable({
12-
list: [
13-
{
14-
label: 'Account',
15-
method: ApiService.Account,
16-
value: null
17-
},
18-
{
19-
label: 'Avatars',
20-
method: ApiService.Avatars,
21-
value: null
22-
},
23-
{
24-
label: 'Databases',
25-
method: ApiService.Databases,
26-
value: null
27-
},
28-
{
29-
label: 'Functions',
30-
method: ApiService.Functions,
31-
value: null
32-
},
33-
{
34-
label: 'Locale',
35-
method: ApiService.Locale,
36-
value: null
37-
},
38-
{
39-
label: 'Messaging',
40-
method: ApiService.Messaging,
41-
value: null
42-
},
43-
{
44-
label: 'Storage',
45-
method: ApiService.Storage,
46-
value: null
47-
},
48-
{
49-
label: 'Teams',
50-
method: ApiService.Teams,
51-
value: null
52-
},
53-
{
54-
label: 'Users',
55-
method: ApiService.Users,
56-
value: null
57-
},
58-
{
59-
label: 'GraphQL',
60-
method: ApiService.Graphql,
61-
value: null
62-
}
63-
]
106+
list: projectServiceRows(null)
64107
});
65108

66109
return {
67110
subscribe,
68111
set,
69112
load: (project: Models.Project) => {
70-
const list = [
71-
{
72-
label: 'Account',
73-
method: ApiService.Account,
74-
value: project.serviceStatusForAccount
75-
},
76-
{
77-
label: 'Avatars',
78-
method: ApiService.Avatars,
79-
value: project.serviceStatusForAvatars
80-
},
81-
{
82-
label: 'Databases',
83-
method: ApiService.Databases,
84-
value: project.serviceStatusForDatabases
85-
},
86-
{
87-
label: 'Functions',
88-
method: ApiService.Functions,
89-
value: project.serviceStatusForFunctions
90-
},
91-
{
92-
label: 'Locale',
93-
method: ApiService.Locale,
94-
value: project.serviceStatusForLocale
95-
},
96-
{
97-
label: 'Messaging',
98-
method: ApiService.Messaging,
99-
value: project.serviceStatusForMessaging
100-
},
101-
{
102-
label: 'Storage',
103-
method: ApiService.Storage,
104-
value: project.serviceStatusForStorage
105-
},
106-
{
107-
label: 'Teams',
108-
method: ApiService.Teams,
109-
value: project.serviceStatusForTeams
110-
},
111-
{
112-
label: 'Users',
113-
method: ApiService.Users,
114-
value: project.serviceStatusForUsers
115-
}
116-
];
117-
set({ list });
113+
set({ list: projectServiceRows(project) });
118114
}
119115
};
120116
}

src/routes/(console)/project-[region]-[project]/settings/+page.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { invalidate } from '$app/navigation';
88
import { Dependencies } from '$lib/constants';
99
import UpdateName from './updateName.svelte';
10+
import UpdateProtocols from './updateProtocols.svelte';
1011
import UpdateServices from './updateServices.svelte';
1112
import UpdateInstallations from './updateInstallations.svelte';
1213
import DeleteProject from './deleteProject.svelte';
@@ -89,6 +90,7 @@
8990
{#if $canWriteProjects}
9091
<UpdateName />
9192
<UpdateLabels />
93+
<UpdateProtocols />
9294
<UpdateServices />
9395
<UpdateInstallations {...data.installations} limit={data.limit} offset={data.offset} />
9496
<UpdateVariables

0 commit comments

Comments
 (0)