|
8 | 8 | import CreateWeb from './createWeb.svelte'; |
9 | 9 | import { createPlatform } from './wizard/store'; |
10 | 10 | import { Click, trackEvent } from '$lib/actions/analytics'; |
11 | | - import type { PlatformType } from '@appwrite.io/console'; |
12 | 11 |
|
13 | 12 | export enum Platform { |
14 | 13 | Web, |
|
31 | 30 | platform: Platform, |
32 | 31 | name: string, |
33 | 32 | key: string, |
34 | | - type: PlatformType |
| 33 | + type: string |
35 | 34 | ) { |
36 | 35 | createPlatform.set({ |
37 | 36 | name: name, |
38 | 37 | key: key, |
| 38 | + hostname: null, |
39 | 39 | type: type |
40 | 40 | }); |
41 | 41 |
|
|
84 | 84 | } from '@appwrite.io/pink-icons-svelte'; |
85 | 85 | import type { ComponentType } from 'svelte'; |
86 | 86 | import DualTimeView from '$lib/components/dualTimeView.svelte'; |
| 87 | + import type { AnyPlatform } from '$lib/helpers/platform'; |
87 | 88 |
|
88 | 89 | import { page } from '$app/state'; |
89 | 90 | import type { PageProps } from './$types'; |
90 | | - import type { Models } from '@appwrite.io/console'; |
91 | 91 | import { |
92 | 92 | type DeleteOperationState, |
93 | 93 | type DeleteOperation, |
|
97 | 97 | import { Submit, trackError } from '$lib/actions/analytics'; |
98 | 98 | import { invalidate } from '$app/navigation'; |
99 | 99 | import { Dependencies } from '$lib/constants'; |
| 100 | + import { getPlatformIdentifier } from '$lib/helpers/platform'; |
100 | 101 |
|
101 | 102 | const { data }: PageProps = $props(); |
102 | 103 |
|
103 | 104 | const PlatformTypes = { |
104 | | - 'apple-ios': 'iOS', |
105 | | - 'apple-macos': 'macOS', |
106 | | - 'apple-watchos': 'watchOS', |
107 | | - 'apple-tvos': 'tvOS', |
108 | 105 | android: 'Android', |
109 | | - 'flutter-android': 'Android', |
110 | | - 'flutter-ios': 'iOS', |
111 | | - 'flutter-linux': 'Linux', |
112 | | - 'flutter-macos': 'macOS', |
113 | | - 'flutter-windows': 'Windows', |
114 | | - 'flutter-web': 'Web', |
115 | | - 'react-native-android': 'Android', |
116 | | - 'react-native-ios': 'iOS', |
117 | | - web: 'Web' |
| 106 | + apple: 'Apple', |
| 107 | + web: 'Web', |
| 108 | + windows: 'Windows', |
| 109 | + linux: 'Linux' |
118 | 110 | } as const; |
119 | 111 |
|
120 | | - function getPlatformInfo(platform: string): ComponentType { |
121 | | - if (platform.includes('flutter')) { |
122 | | - return IconFlutter; |
123 | | - } else if (platform.includes('react-native')) { |
124 | | - return IconReact; |
125 | | - } else if (platform.includes('apple')) { |
126 | | - return IconApple; |
127 | | - } else if (platform.includes('android')) { |
128 | | - return IconAndroid; |
129 | | - } else { |
130 | | - return IconCode; |
| 112 | + function getPlatformIcon(platform: string): ComponentType { |
| 113 | + switch (platform) { |
| 114 | + case 'apple': |
| 115 | + return IconApple; |
| 116 | + case 'android': |
| 117 | + return IconAndroid; |
| 118 | + case 'web': |
| 119 | + return IconCode; |
| 120 | + default: |
| 121 | + return IconCode; |
131 | 122 | } |
132 | 123 | } |
133 | 124 |
|
134 | | - function getPlatformPath(platform: Models.Platform) { |
| 125 | + function getPlatformPath(platform: AnyPlatform) { |
135 | 126 | return resolve('/(console)/project-[region]-[project]/overview/platforms/[platform]', { |
136 | 127 | region: page.params.region, |
137 | 128 | project: page.params.project, |
|
143 | 134 | batchDelete: DeleteOperation |
144 | 135 | ): Promise<DeleteOperationState> { |
145 | 136 | const result = await batchDelete((platformId) => |
146 | | - sdk.forConsole.projects.deletePlatform({ |
147 | | - projectId: page.params.project, |
| 137 | + sdk.forProject(page.params.region, page.params.project).project.deletePlatform({ |
148 | 138 | platformId |
149 | 139 | }) |
150 | 140 | ); |
|
187 | 177 | </Table.Cell> |
188 | 178 | <Table.Cell {root}> |
189 | 179 | <Layout.Stack direction="row" gap="s" alignItems="center"> |
190 | | - <Icon icon={getPlatformInfo(platform.type)} /> |
| 180 | + <Icon icon={getPlatformIcon(platform.type)} /> |
191 | 181 | {PlatformTypes[platform.type]} |
192 | 182 | </Layout.Stack> |
193 | 183 | </Table.Cell> |
194 | 184 | <Table.Cell {root}> |
195 | | - {#if platform.type.includes('web') || platform.type === 'web'} |
196 | | - {platform.hostname || '—'} |
197 | | - {:else} |
198 | | - {platform.key || platform.hostname || '—'} |
199 | | - {/if} |
| 185 | + {getPlatformIdentifier(platform) || '—'} |
200 | 186 | </Table.Cell> |
201 | 187 | <Table.Cell {root}> |
202 | 188 | {#if platform.$updatedAt} |
|
0 commit comments