mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: git configuration
This commit is contained in:
1 parent
a1501b4fe7
commit
b37ee64e59
4 files changed
+205
-29
No files matched your search
@@ -175,6 +175,7 @@ export enum Submit {
|
||||
FunctionUpdateLogging = 'submit_function_update_logging',
|
||||
FunctionUpdateTimeout = 'submit_function_update_timeout',
|
||||
FunctionUpdateEvents = 'submit_function_update_events',
|
||||
FunctionDisconnectRepo = 'submit_function_disconnect_repo',
|
||||
DeploymentCreate = 'submit_deployment_create',
|
||||
DeploymentDelete = 'submit_deployment_delete',
|
||||
DeploymentUpdate = 'submit_deployment_update',
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { func } from '../store';
|
||||
|
||||
export let show = false;
|
||||
const functionId = $page.params.function;
|
||||
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
await sdk.forProject.functions.update(
|
||||
functionId,
|
||||
$func.name,
|
||||
$func.execute || undefined,
|
||||
$func.events || undefined,
|
||||
$func.schedule || undefined,
|
||||
$func.timeout || undefined,
|
||||
$func.enabled,
|
||||
$func.logging,
|
||||
$func.entrypoint,
|
||||
$func.buildCommand,
|
||||
$func.installCommand,
|
||||
$func.vcsInstallationId,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined
|
||||
);
|
||||
await invalidate(Dependencies.FUNCTION);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Repository has been disconnected from your function`
|
||||
});
|
||||
trackEvent(Submit.FunctionDisconnectRepo);
|
||||
show = false;
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.FunctionDisconnectRepo);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show onSubmit={handleSubmit} icon="exclamation" state="warning" headerDivider={false}>
|
||||
<svelte:fragment slot="header">Disconnect Git repository</svelte:fragment>
|
||||
<p data-private>
|
||||
Are you sure you want to disconnect {$func.name}? This will affect future deployments to
|
||||
this function.
|
||||
</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (show = false)}>Cancel</Button>
|
||||
<Button secondary submit>Disconnect</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
+32
-14
@@ -112,21 +112,34 @@
|
||||
>.
|
||||
</p>
|
||||
{#if repositoriesList?.total}
|
||||
{#each repositoriesList.repositories as repo}
|
||||
<ul class="u-flex u-gap-16 u-cross-center">
|
||||
<li>
|
||||
<label class="input-radio">
|
||||
<input
|
||||
type="radio"
|
||||
name={repo.name}
|
||||
bind:group={selectedRepo}
|
||||
value={repo.id} />
|
||||
<ul class="table is-remove-outer-styles u-sep-block-start">
|
||||
{#each repositoriesList.repositories as repo}
|
||||
<li class="table-row">
|
||||
<label class="table-col u-cursor-pointer">
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
<input
|
||||
class="is-small u-margin-inline-end-8"
|
||||
type="radio"
|
||||
name={repo.name}
|
||||
bind:group={selectedRepo}
|
||||
value={repo.id} />
|
||||
<div class="avatar is-size-x-small">
|
||||
<img src="" alt={repo.name} />
|
||||
</div>
|
||||
<div class="u-flex u-gap-8">
|
||||
<span class="text">{repo.name}</span>
|
||||
|
||||
<time
|
||||
class="u-color-text-gray"
|
||||
datetime="2011-11-18T14:54:39.929">
|
||||
30m ago
|
||||
</time>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</li>
|
||||
|
||||
<span class="text">{repo.name}</span>
|
||||
</ul>
|
||||
{/each}
|
||||
{/each}
|
||||
</ul>
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {repositoriesList?.total}</p>
|
||||
<PaginationInline
|
||||
@@ -172,6 +185,11 @@
|
||||
loading...
|
||||
{:then}
|
||||
<Box>
|
||||
<svelte:fragment slot="image">
|
||||
<div class="avatar is-size-x-small">
|
||||
<img src="" alt={$func.name} />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="title">
|
||||
<h6 class="u-bold u-trim-1">{selectedRepo}</h6>
|
||||
</svelte:fragment>
|
||||
@@ -192,7 +210,7 @@
|
||||
<InputChoice
|
||||
id="silent"
|
||||
label="Silent mode"
|
||||
tooltip="I don't know 🤷"
|
||||
tooltip="Don't create comments when pushing to this repository"
|
||||
bind:value={silentMode} />
|
||||
{/await}
|
||||
{/if}
|
||||
|
||||
+110
-15
@@ -4,13 +4,23 @@
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { AvatarGroup, CardGrid, Collapsible, CollapsibleItem, Heading } from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
FormList,
|
||||
InputChoice,
|
||||
InputSelect,
|
||||
InputText
|
||||
} from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { func } from '../store';
|
||||
import GitInstallationModal from '$routes/console/project-[project]/settings/GitInstallationModal.svelte';
|
||||
import GitConfigurationModal from './gitConfigurationModal.svelte';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { onMount } from 'svelte';
|
||||
import DisconnectRepo from './disconnectRepo.svelte';
|
||||
|
||||
export let installations: Models.InstallationList;
|
||||
const functionId = $page.params.function;
|
||||
@@ -19,6 +29,20 @@
|
||||
let installCmd: string;
|
||||
let buildCmd: string;
|
||||
let showGit = false;
|
||||
let branchesList: Models.BranchList;
|
||||
let selectedBranch: string;
|
||||
let silentMode = false;
|
||||
let selectedDir: string;
|
||||
let showDisconnect = false;
|
||||
|
||||
onMount(() => {
|
||||
entrypoint = $func?.entrypoint;
|
||||
installCmd = $func?.installCommand;
|
||||
buildCmd = $func?.buildCommand;
|
||||
selectedBranch = $func?.vcsBranch;
|
||||
silentMode = $func?.vcsSilentMode ?? false;
|
||||
selectedDir = $func?.vcsRootDirectory;
|
||||
});
|
||||
|
||||
async function updateConfiguration() {
|
||||
try {
|
||||
@@ -29,7 +53,16 @@
|
||||
$func.events || undefined,
|
||||
$func.schedule || undefined,
|
||||
$func.timeout || undefined,
|
||||
$func.enabled
|
||||
$func.enabled,
|
||||
$func.logging,
|
||||
$func.entrypoint,
|
||||
$func.buildCommand,
|
||||
$func.installCommand,
|
||||
$func.vcsInstallationId,
|
||||
$func.vcsRepositoryId,
|
||||
selectedBranch,
|
||||
silentMode,
|
||||
selectedDir
|
||||
);
|
||||
await invalidate(Dependencies.FUNCTION);
|
||||
addNotification({
|
||||
@@ -45,6 +78,23 @@
|
||||
trackError(error, Submit.FunctionUpdateConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
async function getBranches(installation: string, repo: string) {
|
||||
branchesList = await sdk.forProject.vcs.listRepositoryBranches(installation, repo);
|
||||
selectedBranch = $func?.vcsBranch ?? branchesList.branches[0].name;
|
||||
}
|
||||
|
||||
$: if ($func?.vcsInstallationId && $func?.vcsRepositoryId) {
|
||||
getBranches($func.vcsInstallationId, $func.vcsRepositoryId);
|
||||
}
|
||||
|
||||
$: isUpdateButtonEnabled =
|
||||
entrypoint !== $func?.entrypoint ||
|
||||
installCmd !== $func?.installCommand ||
|
||||
buildCmd !== $func?.buildCommand ||
|
||||
selectedBranch !== $func?.vcsBranch ||
|
||||
silentMode !== $func?.vcsSilentMode ||
|
||||
selectedDir !== $func?.vcsRootDirectory;
|
||||
</script>
|
||||
|
||||
<Form onSubmit={updateConfiguration}>
|
||||
@@ -66,8 +116,49 @@
|
||||
<Collapsible>
|
||||
<CollapsibleItem>
|
||||
<svelte:fragment slot="title">Git settings</svelte:fragment>
|
||||
{#if false}
|
||||
test
|
||||
{#if $func?.vcsInstallationId && $func?.vcsRepositoryId}
|
||||
<div class="box" style:--box-border-radius="var(--border-radius-small)">
|
||||
<div class="u-flex u-gap-16">
|
||||
<div class="avatar is-size-x-small">
|
||||
<img src="" alt={$func.name} />
|
||||
</div>
|
||||
<div class="u-cross-child-center u-line-height-1-5">
|
||||
<h6 class="u-bold u-trim-1">{$func?.vcsRepositoryId}</h6>
|
||||
<p>Last updated: {toLocaleDateTime($func?.vcsRepositoryId)}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="u-margin-block-start-24">
|
||||
<FormList>
|
||||
<InputSelect
|
||||
id="branch"
|
||||
label="Branch"
|
||||
options={branchesList?.branches?.map((branch) => {
|
||||
return {
|
||||
value: branch.name,
|
||||
label: branch.name
|
||||
};
|
||||
}) ?? []}
|
||||
bind:value={selectedBranch} />
|
||||
<InputText
|
||||
id="root"
|
||||
label="Root directory"
|
||||
bind:value={selectedDir} />
|
||||
<InputChoice
|
||||
id="silent"
|
||||
label="Silent mode"
|
||||
tooltip="Don't create comments when pushing to this repository"
|
||||
bind:value={silentMode} />
|
||||
</FormList>
|
||||
</div>
|
||||
<div class="u-margin-block-start-24 u-flex u-gap-16 u-main-end">
|
||||
<Button text on:click={() => (showDisconnect = true)}
|
||||
>Disconnect repository</Button>
|
||||
<Button secondary href={$func?.vcsBranch} external>
|
||||
View in GitHub
|
||||
<span class="icon-external-link" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<article class="card-git card is-border-dashed is-no-shadow">
|
||||
<div class="u-flex u-cross-center u-flex-vertical u-gap-32">
|
||||
@@ -91,22 +182,24 @@
|
||||
</CollapsibleItem>
|
||||
<CollapsibleItem>
|
||||
<svelte:fragment slot="title">Build settings</svelte:fragment>
|
||||
<InputText
|
||||
label="Install command"
|
||||
placeholder="Enter an install commad (e.g. 'npm install')"
|
||||
id="install"
|
||||
bind:value={installCmd} />
|
||||
<InputText
|
||||
label="Build command"
|
||||
placeholder="Enter a build commad (e.g. 'npm run build')"
|
||||
id="build"
|
||||
bind:value={buildCmd} />
|
||||
<FormList>
|
||||
<InputText
|
||||
label="Install command"
|
||||
placeholder="Enter an install commad (e.g. 'npm install')"
|
||||
id="install"
|
||||
bind:value={installCmd} />
|
||||
<InputText
|
||||
label="Build command"
|
||||
placeholder="Enter a build commad (e.g. 'npm run build')"
|
||||
id="build"
|
||||
bind:value={buildCmd} />
|
||||
</FormList>
|
||||
</CollapsibleItem>
|
||||
</Collapsible>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled submit>Update</Button>
|
||||
<Button disabled={!isUpdateButtonEnabled} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -116,3 +209,5 @@
|
||||
{:else}
|
||||
<GitConfigurationModal bind:show={showGit} {installations} />
|
||||
{/if}
|
||||
|
||||
<DisconnectRepo bind:show={showDisconnect} />
|
||||
Reference in new issue
Block a user