-
Notifications
You must be signed in to change notification settings - Fork 253
Expand file tree
/
Copy pathfunctionConfiguration.svelte
More file actions
118 lines (109 loc) 路 3.81 KB
/
Copy pathfunctionConfiguration.svelte
File metadata and controls
118 lines (109 loc) 路 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<script lang="ts">
import { Collapsible, CollapsibleItem, CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { FormList, InputSelect, InputText } from '$lib/elements/forms';
import InputTextarea from '$lib/elements/forms/inputTextarea.svelte';
import { WizardStep } from '$lib/layout';
import { onMount } from 'svelte';
import { sdk } from '$lib/stores/sdk';
import { choices, createFunction, installation, repository } from '../store';
import { runtimesList } from '$routes/console/project-[project]/functions/store';
let showCustomId = false;
let detectingRuntime = true;
async function loadDetection(
installationId: string,
repositoryId: string,
rootDirectory: string
) {
const detection = await sdk.forProject.vcs.createRepositoryDetection(
installationId,
repositoryId,
rootDirectory
);
return detection;
}
let options = [];
onMount(async () => {
options = (await $runtimesList).runtimes.map((runtime) => ({
label: `${runtime.name} - ${runtime.version}`,
value: runtime.$id
}));
try {
const detection = await loadDetection(
$installation.$id,
$repository.id,
$choices.rootDir
);
$createFunction.runtime = detection.runtime;
} catch (err) {
console.error(err);
} finally {
detectingRuntime = false;
}
});
</script>
<WizardStep>
<svelte:fragment slot="title">Configuration</svelte:fragment>
<svelte:fragment slot="subtitle">
Set your deployment configuration and any build commands here.
</svelte:fragment>
<FormList>
<InputText
label="Name"
id="name"
placeholder="Function name"
bind:value={$createFunction.name}
required />
{#if !showCustomId}
<div>
<Pill button on:click={() => (showCustomId = !showCustomId)}>
<span class="icon-pencil" aria-hidden="true" />
<span class="text">Function ID </span>
</Pill>
</div>
{:else}
<CustomId
bind:show={showCustomId}
name="Function"
bind:id={$createFunction.$id}
fullWidth />
{/if}
{#if detectingRuntime}
<InputSelect
disabled
label="Runtime"
id="runtime"
placeholder="Detecting runtime"
value={null}
options={[]} />
{:else}
<InputSelect
label="Runtime"
id="runtime"
placeholder="Select runtime"
bind:value={$createFunction.runtime}
{options}
required />
{/if}
<InputText
label="Entrypoint"
id="entrypoint"
placeholder="Entrypoint"
bind:value={$createFunction.entrypoint}
required />
<Collapsible>
<CollapsibleItem>
<svelte:fragment slot="title">Build commands</svelte:fragment>
<svelte:fragment slot="subtitle">(optional)</svelte:fragment>
<FormList>
<InputTextarea
label="Commands"
placeholder="Enter a build commad (e.g. 'npm install')"
id="build"
tooltip="Enter a single command or chain multiple commands with the && operator"
bind:value={$createFunction.commands} />
</FormList>
</CollapsibleItem>
</Collapsible>
</FormList>
</WizardStep>