Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ui state when creating repository #1592

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/lib/components/git/newRepository.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
export let installations: Models.InstallationList;
export let repositoryName: string;
export let repositoryPrivate = true;
export let disableFields = false;
</script>

<Layout.Stack gap="l">
{#key selectedInstallationId}
<InputSelect
id="installation"
label="Git organization"
disabled={disableFields}
options={installations.installations.map((entry) => {
return {
label: entry.organization,
Expand All @@ -32,9 +34,11 @@
id="repositoryName"
label="Repository name"
placeholder="my-repository"
disabled={disableFields}
bind:value={repositoryName} />
<InputChoice
id="repositoryPrivate"
label="Keep repository private"
disabled={disableFields}
bind:value={repositoryPrivate} />
</Layout.Stack>
3 changes: 2 additions & 1 deletion src/lib/elements/forms/button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
let classes: string = '';
export { classes as class };
export let submissionLoader = false;
export let showLoaderAnyway = false;
ItzNotABug marked this conversation as resolved.
Show resolved Hide resolved

const isSubmitting = hasContext('form')
? getContext<FormContext>('form').isSubmitting
Expand Down Expand Up @@ -85,7 +86,7 @@
aria-label={ariaLabel}
type={submit ? 'submit' : 'button'}
--button-width={fullWidth ? '100%' : undefined}>
{#if $isSubmitting && submissionLoader}
{#if ($isSubmitting && submissionLoader) || (showLoaderAnyway && submissionLoader)}
<span
class="loader is-small"
style:--p-loader-base-full-color="transparent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
export let data;

let showExitModal = false;
let isCreatingRepository = false;
let hasInstallations = !!data?.installations?.total;

let formComponent: Form;
Expand Down Expand Up @@ -80,6 +81,7 @@

async function createRepository() {
try {
isCreatingRepository = true;
const repo = await sdk.forProject.vcs.createRepository(
$installation.$id,
repositoryName,
Expand All @@ -93,6 +95,8 @@
type: 'error',
message: error.message
});
} finally {
isCreatingRepository = false;
}
}

Expand Down Expand Up @@ -216,12 +220,13 @@
</Layout.Stack>
{#if connectBehaviour === 'now'}
{#if hasInstallations}
<Fieldset legend="Git repositoy">
<Fieldset legend="Git repository">
<Layout.Stack gap="xl">
<RepositoryBehaviour bind:repositoryBehaviour />
{#if repositoryBehaviour === 'new'}
<NewRepository
bind:selectedInstallationId
disableFields={isCreatingRepository}
installations={data.installations}
bind:repositoryName
bind:repositoryPrivate />
Expand All @@ -231,7 +236,11 @@
<Button
size="s"
on:click={createRepository}
disabled={!repositoryName || !$installation?.$id}>
showLoaderAnyway={true}
submissionLoader={isCreatingRepository}
disabled={!repositoryName ||
!$installation?.$id ||
isCreatingRepository}>
Create
</Button>
</Layout.Stack>
Expand Down
Loading