This commit is contained in:
Andras Bacsai 2022-11-04 14:41:52 +01:00
parent d24e4c6518
commit 80d15e782b
8 changed files with 163 additions and 80 deletions

View File

@ -92,27 +92,9 @@
label: branch.name label: branch.name
})); }));
} }
async function isBranchAlreadyUsed(event: any) { async function selectBranch(event: any) {
selected.branch = event.detail.value; selected.branch = event.detail.value;
try {
// const data = await get(
// `/applications/${id}/configuration/repository?repository=${selected.repository}&branch=${selected.branch}`
// );
// if (data.used) {
// const sure = confirm($t('application.configuration.branch_already_in_use'));
// if (sure) {
// selected.autodeploy = false;
// showSave = true;
// return true;
// }
// showSave = false;
// return true;
// }
showSave = true; showSave = true;
} catch (error) {
showSave = false;
return errorNotification(error);
}
} }
onMount(async () => { onMount(async () => {
@ -178,7 +160,7 @@
isWaiting={loading.branches} isWaiting={loading.branches}
showIndicator={selected.repository && !loading.branches} showIndicator={selected.repository && !loading.branches}
id="branches" id="branches"
on:select={isBranchAlreadyUsed} on:select={selectBranch}
items={branchSelectOptions} items={branchSelectOptions}
isDisabled={loading.branches || !selected.repository} isDisabled={loading.branches || !selected.repository}
isClearable={false} isClearable={false}
@ -186,10 +168,9 @@
</div></div> </div></div>
<div class="pt-5 flex-col flex justify-center items-center space-y-4"> <div class="pt-5 flex-col flex justify-center items-center space-y-4">
<button <button
class="btn btn-wide" class="btn btn-wide btn-primary"
type="submit" type="submit"
disabled={!showSave} disabled={!showSave}
class:bg-applications={showSave}
>{$t('forms.save')}</button >{$t('forms.save')}</button
> >
</div> </div>

View File

@ -195,27 +195,11 @@
} }
} }
async function isBranchAlreadyUsed(event) { async function selectBranch(event: any) {
selected.branch = event.detail; selected.branch = event.detail;
try {
// const data = await get(
// `/applications/${id}/configuration/repository?repository=${selected.project.path_with_namespace}&branch=${selected.branch.name}`
// );
// if (data.used) {
// const sure = confirm($t('application.configuration.branch_already_in_use'));
// if (sure) {
// autodeploy = false;
// showSave = true;
// return true;
// }
// showSave = false;
// return true;
// }
showSave = true; showSave = true;
} catch (error) {
return errorNotification(error);
}
} }
async function checkSSHKey(sshkeyUrl: any) { async function checkSSHKey(sshkeyUrl: any) {
try { try {
return await post(sshkeyUrl, {}); return await post(sshkeyUrl, {});
@ -394,7 +378,7 @@
showIndicator={!loading.branches} showIndicator={!loading.branches}
isWaiting={loading.branches} isWaiting={loading.branches}
isDisabled={loading.branches || !selected.project} isDisabled={loading.branches || !selected.project}
on:select={isBranchAlreadyUsed} on:select={selectBranch}
on:clear={() => { on:clear={() => {
showSave = false; showSave = false;
selected.branch = null; selected.branch = null;
@ -414,7 +398,6 @@
class="btn btn-wide" class="btn btn-wide"
type="submit" type="submit"
disabled={!showSave || loading.save} disabled={!showSave || loading.save}
class:bg-applications={showSave && !loading.save}
>{loading.save ? $t('forms.saving') : $t('forms.save')}</button >{loading.save ? $t('forms.saving') : $t('forms.save')}</button
> >
{#if tryAgain} {#if tryAgain}
@ -423,7 +406,7 @@
configuration <a href={`/sources/${application.gitSource.id}`}>here.</a> configuration <a href={`/sources/${application.gitSource.id}`}>here.</a>
</div> </div>
<button <button
class="btn btn-sm w-40 bg-green-600" class="btn btn-sm w-40 btn-primary"
on:click|stopPropagation|preventDefault={() => window.location.reload()} on:click|stopPropagation|preventDefault={() => window.location.reload()}
> >
Try again Try again

View File

@ -171,7 +171,7 @@
placeholder="eg: https://github.com/coollabsio/nodejs-example/tree/main" placeholder="eg: https://github.com/coollabsio/nodejs-example/tree/main"
bind:value={publicRepositoryLink} bind:value={publicRepositoryLink}
/> />
<button class="btn bg-orange-600" disabled={loading.branches} type="submit" class:loading={loading.branches}> <button class="btn btn-primary" disabled={loading.branches} type="submit" class:loading={loading.branches}>
Load Repository Load Repository
</button> </button>
</div> </div>

View File

@ -88,31 +88,111 @@
</div> </div>
</div> </div>
{:else} {:else}
<div class="flex flex-col flex-wrap justify-center px-2 md:flex-row mx-auto"> <div class="flex flex-col flex-wrap justify-center px-2 md:flex-row mx-auto gap-4">
{#each ownDestinations as destination} {#each ownDestinations as destination}
<div class="p-2"> <button
<form on:submit|preventDefault={() => handleSubmit(destination.id)}> on:click={() => handleSubmit(destination.id)}
<button type="submit" class="box-selection hover:bg-sky-700 font-bold"> class="box-selection hover:bg-primary font-bold relative"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="absolute top-0 left-0 -m-4 h-12 w-12 text-sky-500"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path
d="M22 12.54c-1.804 -.345 -2.701 -1.08 -3.523 -2.94c-.487 .696 -1.102 1.568 -.92 2.4c.028 .238 -.32 1.002 -.557 1h-14c0 5.208 3.164 7 6.196 7c4.124 .022 7.828 -1.376 9.854 -5c1.146 -.101 2.296 -1.505 2.95 -2.46z"
/>
<path d="M5 10h3v3h-3z" />
<path d="M8 10h3v3h-3z" />
<path d="M11 10h3v3h-3z" />
<path d="M8 7h3v3h-3z" />
<path d="M11 7h3v3h-3z" />
<path d="M11 4h3v3h-3z" />
<path d="M4.571 18c1.5 0 2.047 -.074 2.958 -.78" />
<line x1="10" y1="16" x2="10" y2="16.01" />
</svg>
{#if destination.remoteEngine}
<svg
xmlns="http://www.w3.org/2000/svg"
class="absolute top-0 left-9 -m-2 h-6 w-6 text-sky-500 rotate-45"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<line x1="12" y1="18" x2="12.01" y2="18" />
<path d="M9.172 15.172a4 4 0 0 1 5.656 0" />
<path d="M6.343 12.343a8 8 0 0 1 11.314 0" />
<path d="M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0" />
</svg>
{/if}
<div class="font-bold text-xl text-center truncate">{destination.name}</div> <div class="font-bold text-xl text-center truncate">{destination.name}</div>
<div class="text-center truncate">{destination.network}</div> <div class="text-center truncate">{destination.network}</div>
</button> </button>
</form>
</div>
{/each} {/each}
</div> </div>
{#if otherDestinations.length > 0 && $appSession.teamId === '0'} {#if otherDestinations.length > 0 && $appSession.teamId === '0'}
<div class="px-6 pb-5 pt-10 title">Other Destinations</div> <div class="px-6 pb-5 pt-10 title">Other Destinations</div>
{/if} {/if}
<div class="flex flex-col flex-wrap justify-center px-2 md:flex-row mx-auto"> <div class="flex flex-col flex-wrap justify-center px-2 md:flex-row mx-auto gap-4">
{#each otherDestinations as destination} {#each otherDestinations as destination}
<div class="p-2"> <button
<form on:submit|preventDefault={() => handleSubmit(destination.id)}> class="box-selection hover:bg-sky-700 font-bold relative"
<button type="submit" class="box-selection hover:bg-sky-700 font-bold"> on:click={() => handleSubmit(destination.id)}
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="absolute top-0 left-0 -m-4 h-12 w-12 text-sky-500"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path
d="M22 12.54c-1.804 -.345 -2.701 -1.08 -3.523 -2.94c-.487 .696 -1.102 1.568 -.92 2.4c.028 .238 -.32 1.002 -.557 1h-14c0 5.208 3.164 7 6.196 7c4.124 .022 7.828 -1.376 9.854 -5c1.146 -.101 2.296 -1.505 2.95 -2.46z"
/>
<path d="M5 10h3v3h-3z" />
<path d="M8 10h3v3h-3z" />
<path d="M11 10h3v3h-3z" />
<path d="M8 7h3v3h-3z" />
<path d="M11 7h3v3h-3z" />
<path d="M11 4h3v3h-3z" />
<path d="M4.571 18c1.5 0 2.047 -.074 2.958 -.78" />
<line x1="10" y1="16" x2="10" y2="16.01" />
</svg>
{#if destination.remoteEngine}
<svg
xmlns="http://www.w3.org/2000/svg"
class="absolute top-0 left-9 -m-2 h-6 w-6 text-sky-500 rotate-45"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<line x1="12" y1="18" x2="12.01" y2="18" />
<path d="M9.172 15.172a4 4 0 0 1 5.656 0" />
<path d="M6.343 12.343a8 8 0 0 1 11.314 0" />
<path d="M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0" />
</svg>
{/if}
<div class="font-bold text-xl text-center truncate">{destination.name}</div> <div class="font-bold text-xl text-center truncate">{destination.name}</div>
<div class="text-center truncate">{destination.network}</div> <div class="text-center truncate">{destination.network}</div>
</button> </button>
</form>
</div>
{/each} {/each}
</div> </div>
{/if} {/if}

View File

@ -78,10 +78,7 @@
{$t('application.configuration.no_configurable_git')} {$t('application.configuration.no_configurable_git')}
</div> </div>
<div class="flex justify-center"> <div class="flex justify-center">
<a <a href="/sources/new?from={$page.url.pathname}" class="add-icon">
href="/sources/new?from={$page.url.pathname}"
class="add-icon bg-orange-600 hover:bg-orange-500"
>
<svg <svg
class="w-6" class="w-6"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@ -143,7 +140,7 @@
<button <button
disabled={source.gitlabApp && !source.gitlabAppId} disabled={source.gitlabApp && !source.gitlabAppId}
type="submit" type="submit"
class="disabled:opacity-95 bg-coolgray-200 disabled:text-white box-selection hover:bg-orange-700 group w-full lg:w-96" class="disabled:opacity-95 disabled:text-white box-selection hover:btn-primary group w-full lg:w-96"
class:border-red-500={source.gitlabApp && !source.gitlabAppId} class:border-red-500={source.gitlabApp && !source.gitlabAppId}
class:border-0={source.gitlabApp && !source.gitlabAppId} class:border-0={source.gitlabApp && !source.gitlabAppId}
class:border-l-4={source.gitlabApp && !source.gitlabAppId} class:border-l-4={source.gitlabApp && !source.gitlabAppId}

View File

@ -73,6 +73,7 @@
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import Menu from './_Menu.svelte'; import Menu from './_Menu.svelte';
import { saveForm } from './utils'; import { saveForm } from './utils';
import { dev } from '$app/env';
const { id } = $page.params; const { id } = $page.params;
$isDeploymentEnabled = checkIfDeploymentEnabledServices($appSession.isAdmin, service); $isDeploymentEnabled = checkIfDeploymentEnabledServices($appSession.isAdmin, service);
@ -254,7 +255,7 @@
Delete Service Delete Service
</button> </button>
{/if} {/if}
{#if $page.url.pathname === `/services/${id}/configuration/type`} {#if $page.url.pathname === `/services/${id}/configuration/type` && dev}
<button <button
disabled={loading.refreshTemplates} disabled={loading.refreshTemplates}
class:loading={loading.refreshTemplates} class:loading={loading.refreshTemplates}

View File

@ -77,16 +77,57 @@
</div> </div>
</div> </div>
{:else} {:else}
<div class="flex flex-wrap justify-center"> <div class="flex flex-wrap justify-center gap-4">
{#each destinations as destination} {#each destinations as destination}
<div class="p-2"> <button
<form on:submit|preventDefault={() => handleSubmit(destination.id)}> type="submit"
<button type="submit" class="box-selection hover:bg-primary font-bold"> class="box-selection hover:bg-primary font-bold relative"
on:click={() => handleSubmit(destination.id)}
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="absolute top-0 left-0 -m-4 h-12 w-12 text-sky-500"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<path
d="M22 12.54c-1.804 -.345 -2.701 -1.08 -3.523 -2.94c-.487 .696 -1.102 1.568 -.92 2.4c.028 .238 -.32 1.002 -.557 1h-14c0 5.208 3.164 7 6.196 7c4.124 .022 7.828 -1.376 9.854 -5c1.146 -.101 2.296 -1.505 2.95 -2.46z"
/>
<path d="M5 10h3v3h-3z" />
<path d="M8 10h3v3h-3z" />
<path d="M11 10h3v3h-3z" />
<path d="M8 7h3v3h-3z" />
<path d="M11 7h3v3h-3z" />
<path d="M11 4h3v3h-3z" />
<path d="M4.571 18c1.5 0 2.047 -.074 2.958 -.78" />
<line x1="10" y1="16" x2="10" y2="16.01" />
</svg>
{#if destination.remoteEngine}
<svg
xmlns="http://www.w3.org/2000/svg"
class="absolute top-0 left-9 -m-2 h-6 w-6 text-sky-500 rotate-45"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
>
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<line x1="12" y1="18" x2="12.01" y2="18" />
<path d="M9.172 15.172a4 4 0 0 1 5.656 0" />
<path d="M6.343 12.343a8 8 0 0 1 11.314 0" />
<path d="M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0" />
</svg>
{/if}
<div class="font-bold text-xl text-center truncate">{destination.name}</div> <div class="font-bold text-xl text-center truncate">{destination.name}</div>
<div class="text-center truncate">{destination.network}</div> <div class="text-center truncate">{destination.network}</div>
</button> </button>
</form>
</div>
{/each} {/each}
</div> </div>
{/if} {/if}

View File

@ -156,7 +156,7 @@ .border-gradient-full {
} }
.box-selection { .box-selection {
@apply justify-center rounded border-transparent bg-coolgray-200 p-6 hover:border-transparent hover:bg-coolgray-400; @apply min-w-[16rem] justify-center rounded border-transparent bg-coolgray-200 p-6 hover:border-transparent hover:bg-coolgray-400;
} }
.lds-heart { .lds-heart {