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: Added Rebuild button for function view when build fails during deployment #376

Merged
Show file tree
Hide file tree
Changes from 5 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import type { PageData } from './$types';
import Delete from './delete.svelte';
import Create from './create.svelte';
import Rebuild from './rebuild.svelte';
import Activate from './activate.svelte';
import { browser } from '$app/environment';
import { sdk } from '$lib/stores/sdk';
Expand All @@ -44,13 +45,18 @@
let showDropdown = [];
let showDelete = false;
let showActivate = false;
let showRebuild = false;

let selectedDeployment: Models.Deployment = null;

function handleActivate() {
invalidate(Dependencies.DEPLOYMENTS);
}

function handleRebuild() {
invalidate(Dependencies.DEPLOYMENTS);
}

$: activeDeployment = data.deployments.deployments.find((d) => d.$id === $func?.deployment);

if (browser) {
Expand Down Expand Up @@ -215,6 +221,17 @@
}}>
Activate
</DropListItem>
{#if 'failed' === deployment.status}
<DropListItem
icon="refresh"
on:click={() => {
selectedDeployment = deployment;
showRebuild = true;
showDropdown = [];
}}>
Retry Build
</DropListItem>
{/if}
<DropListItem
icon="terminal"
on:click={() => {
Expand Down Expand Up @@ -281,4 +298,5 @@
{#if selectedDeployment}
<Delete {selectedDeployment} bind:showDelete />
<Activate {selectedDeployment} bind:showActivate on:activated={handleActivate} />
<Rebuild {selectedDeployment} bind:showRebuild on:rebuild={handleRebuild} />
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<script lang="ts">
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@appwrite.io/console';
import { createEventDispatcher } from 'svelte';

export let showRebuild = false;
export let selectedDeployment: Models.Deployment = null;

const dispatch = createEventDispatcher();

const handleSubmit = async () => {
try {
await sdk.forProject.functions.createBuild(
selectedDeployment.resourceId,
selectedDeployment.$id,
selectedDeployment.buildId
);
showRebuild = false;
addNotification({
type: 'success',
message: `Retrying build`
});
dispatch('rebuild');
trackEvent(Submit.DeploymentUpdate);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
trackError(error, Submit.DeploymentUpdate);
}
};
</script>

<Modal bind:show={showRebuild} onSubmit={handleSubmit}>
<svelte:fragment slot="header">Retry build</svelte:fragment>
<p>Are you sure you want to retry building this deployment?</p>
<svelte:fragment slot="footer">
<Button text on:click={() => (showRebuild = false)}>Cancel</Button>
<Button secondary submit>Retry build</Button>
</svelte:fragment>
</Modal>