Skip to content

Commit

Permalink
Merge pull request #1592 from appwrite/fix-create-repo-responsiveness
Browse files Browse the repository at this point in the history
Fix ui state when creating repository
  • Loading branch information
ernstmul authored Jan 2, 2025
2 parents b4c2187 + 819a829 commit 10d53b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
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 forceShowLoader = false;
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) || (forceShowLoader && 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 @@ -220,12 +224,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 @@ -235,7 +240,11 @@
<Button
size="s"
on:click={createRepository}
disabled={!repositoryName || !$installation?.$id}>
forceShowLoader
submissionLoader={isCreatingRepository}
disabled={!repositoryName ||
!$installation?.$id ||
isCreatingRepository}>
Create
</Button>
</Layout.Stack>
Expand Down

0 comments on commit 10d53b1

Please sign in to comment.