|
1 | 1 | <script lang="ts"> |
2 | | - import { app } from '$lib/stores/app'; |
3 | | - import AppwriteLogoDark from '$lib/images/appwrite-logo-dark.svg'; |
4 | | - import AppwriteLogoLight from '$lib/images/appwrite-logo-light.svg'; |
5 | 2 | import { Vcs, Client } from '@appwrite.io/console'; |
6 | 3 | import { onMount } from 'svelte'; |
7 | 4 | import { getApiEndpoint } from '$lib/stores/sdk'; |
| 5 | + import { Badge, Layout, Typography } from '@appwrite.io/pink-svelte'; |
| 6 | + import { Button } from '$lib/elements/forms'; |
8 | 7 |
|
9 | | - export let data; |
| 8 | + const { data } = $props(); |
10 | 9 |
|
11 | 10 | const endpoint = getApiEndpoint(); |
12 | 11 | const client = new Client(); |
13 | 12 | const vcs = new Vcs(client); |
14 | 13 |
|
15 | | - let installationId: string; |
16 | | - let repositoryId: string; |
17 | | - let providerPullRequestId: string; |
18 | | -
|
19 | | - let error = ''; |
20 | | - let success = ''; |
21 | | - let loading = false; |
| 14 | + let error = $state(''); |
| 15 | + let success = $state(''); |
| 16 | + let loading = $state(false); |
22 | 17 |
|
23 | 18 | onMount(async () => { |
24 | | - repositoryId = data.repositoryId; |
25 | | - installationId = data.installationId; |
26 | | - providerPullRequestId = data.providerPullRequestId; |
27 | | -
|
28 | 19 | client.setEndpoint(endpoint).setProject(data.projectId).setMode('admin'); |
29 | 20 | }); |
30 | 21 |
|
|
39 | 30 |
|
40 | 31 | try { |
41 | 32 | await vcs.updateExternalDeployments({ |
42 | | - installationId, |
43 | | - repositoryId, |
44 | | - providerPullRequestId |
| 33 | + installationId: data.installationId, |
| 34 | + repositoryId: data.repositoryId, |
| 35 | + providerPullRequestId: data.providerPullRequestId |
45 | 36 | }); |
46 | 37 | success = 'Deployment approved successfully! Build will start soon.'; |
47 | 38 | } catch (e) { |
|
52 | 43 | } |
53 | 44 | </script> |
54 | 45 |
|
55 | | -<section class="container" style="display: grid; place-items: center; min-height: 100vh;"> |
56 | | - <div class="u-flex u-flex-vertical u-cross-center" style="width: 100%"> |
57 | | - <div class="card" style="min-width: 600px; max-width: 100%;"> |
58 | | - <h1 class="heading-level-2">Authorize External Deployment</h1> |
59 | | - <small style="margin-block-start: 8px;display: block;" |
60 | | - >The deployment for pull request <code class="inline-code" |
61 | | - >#{providerPullRequestId}</code> is awaiting approval. When authorized, deployments |
62 | | - will be started. |
63 | | - </small> |
64 | | - |
65 | | - <div class="with-borders" style="margin-block-start: 1rem;display: block;"> |
66 | | - <button disabled={loading} on:click={approveDeployment} class="button" type="button" |
67 | | - >Approve Deployment</button> |
68 | | - </div> |
69 | | - |
70 | | - {#if error} |
71 | | - <p style="margin-block-start: 1rem" class="u-color-text-danger">{error}</p> |
72 | | - {/if} |
73 | | - |
74 | | - {#if success} |
75 | | - <p style="margin-block-start: 1rem" class="u-color-text-success">{success}</p> |
76 | | - {/if} |
77 | | - </div> |
78 | | - <div class="u-gap-4 u-flex u-main-center u-cross-center" style="margin-block-start: 2rem;"> |
79 | | - <span class="text">Powered by</span> |
80 | | - <a |
81 | | - href="https://appwrite.io/" |
82 | | - target="_blank" |
83 | | - style="display: grid;place-items: center;"> |
84 | | - {#if $app.themeInUse === 'dark'} |
85 | | - <img |
86 | | - src={AppwriteLogoDark} |
87 | | - width="120" |
88 | | - class="u-block u-only-dark" |
89 | | - alt="Appwrite Logo" /> |
90 | | - {:else} |
91 | | - <img |
92 | | - src={AppwriteLogoLight} |
93 | | - width="120" |
94 | | - class="u-block u-only-light" |
95 | | - alt="Appwrite Logo" /> |
96 | | - {/if} |
97 | | - </a> |
98 | | - </div> |
99 | | - </div> |
100 | | -</section> |
| 46 | +<Layout.Stack gap="l" alignItems="center" style="max-width: 500px;"> |
| 47 | + {#if success} |
| 48 | + <Badge type="success" variant="secondary" content={success} /> |
| 49 | + {:else if error} |
| 50 | + <Badge type="error" variant="secondary" content={error} /> |
| 51 | + {/if} |
| 52 | + <Typography.Title size="l" align="center"> |
| 53 | + The deployment for pull request #{data.providerPullRequestId} |
| 54 | + is awaiting approval. When authorized, deployments will be started. |
| 55 | + </Typography.Title> |
| 56 | + <Button on:click={approveDeployment} secondary>Approve Deployment</Button> |
| 57 | +</Layout.Stack> |
0 commit comments