|
1 | 1 | import { writable } from 'svelte/store'; |
2 | | -import { ApiService, type Models } from '@appwrite.io/console'; |
| 2 | +import { ServiceId, type Models } from '@appwrite.io/console'; |
3 | 3 |
|
4 | 4 | export type Service = { |
5 | 5 | label: string; |
6 | | - method: ApiService; |
| 6 | + method: ServiceId; |
7 | 7 | value: boolean | null; |
8 | 8 | }; |
9 | 9 |
|
| 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 | + |
10 | 104 | function createServices() { |
11 | 105 | 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) |
64 | 107 | }); |
65 | 108 |
|
66 | 109 | return { |
67 | 110 | subscribe, |
68 | 111 | set, |
69 | 112 | 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) }); |
118 | 114 | } |
119 | 115 | }; |
120 | 116 | } |
|
0 commit comments