mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
code rabbit clean suggestions
This commit is contained in:
@@ -16,9 +16,8 @@ export function isBuildTimedOut(
|
||||
return false;
|
||||
}
|
||||
|
||||
const now = new Date();
|
||||
const created = new Date(createdAt);
|
||||
const elapsedSeconds = Math.floor((now.getTime() - created.getTime()) / 1000);
|
||||
const elapsedSeconds = Math.floor((Date.now() - created.getTime()) / 1000);
|
||||
|
||||
return elapsedSeconds > timeoutSeconds;
|
||||
}
|
||||
|
||||
+4
-4
@@ -61,7 +61,7 @@
|
||||
`functions.${page.params.function}.deployments.${page.params.deployment}.update`
|
||||
)
|
||||
) {
|
||||
if (message.payload.status === 'ready') {
|
||||
if (['ready', 'failed'].includes(message.payload.status)) {
|
||||
invalidate(Dependencies.DEPLOYMENT);
|
||||
}
|
||||
}
|
||||
@@ -155,9 +155,9 @@
|
||||
<Card.Base padding="s">
|
||||
<Accordion
|
||||
title="Deployment logs"
|
||||
badge={capitalize(data.deployment.status)}
|
||||
badge={capitalize(effectiveStatus)}
|
||||
open
|
||||
badgeType={badgeTypeDeployment(data.deployment.status)}
|
||||
badgeType={badgeTypeDeployment(effectiveStatus)}
|
||||
hideDivider>
|
||||
<Layout.Stack gap="xl">
|
||||
{#key data.deployment.buildLogs}
|
||||
@@ -170,7 +170,7 @@
|
||||
|
||||
<svelte:fragment slot="end">
|
||||
<Layout.Stack direction="row" alignItems="center" inline>
|
||||
{#if ['processing', 'building'].includes(data.deployment.status)}
|
||||
{#if ['processing', 'building'].includes(effectiveStatus)}
|
||||
<Typography.Code color="--fgcolor-neutral-secondary">
|
||||
<Layout.Stack direction="row" alignItems="center" inline>
|
||||
<p use:timer={{ start: data.deployment.$createdAt }}></p>
|
||||
|
||||
+8
-8
@@ -53,6 +53,11 @@
|
||||
</Button>
|
||||
<svelte:fragment slot="menu" let:toggle>
|
||||
<ActionMenu.Root>
|
||||
{@const effectiveStatus = getEffectiveBuildStatus(
|
||||
deployment.status,
|
||||
deployment.$createdAt,
|
||||
getBuildTimeoutSeconds($regionalConsoleVariables)
|
||||
)}
|
||||
{#if !inCard}
|
||||
<Tooltip disabled={selectedDeployment?.sourceSize !== 0} placement={'bottom'}>
|
||||
<div>
|
||||
@@ -72,7 +77,7 @@
|
||||
<div slot="tooltip">Source is empty</div>
|
||||
</Tooltip>
|
||||
{/if}
|
||||
{#if deployment?.status === 'ready' && deployment?.$id !== activeDeployment}
|
||||
{#if effectiveStatus === 'ready' && deployment?.$id !== activeDeployment}
|
||||
<ActionMenu.Item.Button
|
||||
leadingIcon={IconLightningBolt}
|
||||
on:click={(e) => {
|
||||
@@ -84,7 +89,7 @@
|
||||
Activate
|
||||
</ActionMenu.Item.Button>
|
||||
{/if}
|
||||
{#if deployment?.status === 'ready' || deployment?.status === 'failed' || deployment?.status === 'building'}
|
||||
{#if effectiveStatus === 'ready' || effectiveStatus === 'failed' || effectiveStatus === 'building'}
|
||||
<SubMenu>
|
||||
<ActionMenu.Root noPadding>
|
||||
<ActionMenu.Item.Button
|
||||
@@ -103,7 +108,7 @@
|
||||
</ActionMenu.Item.Anchor>
|
||||
|
||||
<ActionMenu.Item.Anchor
|
||||
disabled={deployment?.status !== 'ready'}
|
||||
disabled={effectiveStatus !== 'ready'}
|
||||
on:click={toggle}
|
||||
href={getOutputDownload(deployment.$id)}
|
||||
external>
|
||||
@@ -114,11 +119,6 @@
|
||||
</SubMenu>
|
||||
{/if}
|
||||
|
||||
{@const effectiveStatus = getEffectiveBuildStatus(
|
||||
deployment.status,
|
||||
deployment.$createdAt,
|
||||
getBuildTimeoutSeconds($regionalConsoleVariables)
|
||||
)}
|
||||
{#if effectiveStatus === 'processing' || effectiveStatus === 'building' || effectiveStatus === 'waiting'}
|
||||
<ActionMenu.Item.Button
|
||||
leadingIcon={IconXCircle}
|
||||
|
||||
@@ -9,12 +9,10 @@
|
||||
|
||||
let { status, deployment }: { status: string; deployment: Models.Deployment } = $props();
|
||||
|
||||
// mmoize timeout value to avoid recalculating on every render
|
||||
let timeoutSeconds = $derived(getBuildTimeoutSeconds($regionalConsoleVariables));
|
||||
let effectiveStatus = $derived(
|
||||
getEffectiveBuildStatus(
|
||||
status,
|
||||
deployment.$createdAt,
|
||||
getBuildTimeoutSeconds($regionalConsoleVariables)
|
||||
)
|
||||
getEffectiveBuildStatus(status, deployment.$createdAt, timeoutSeconds)
|
||||
);
|
||||
</script>
|
||||
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@
|
||||
<Container>
|
||||
<SiteCard {deployment} proxyRuleList={data.proxyRuleList}>
|
||||
{#snippet footer()}
|
||||
{#if deployment?.status === 'ready' && data.proxyRuleList?.total}
|
||||
{#if effectiveStatus === 'ready' && data.proxyRuleList?.total}
|
||||
<Button
|
||||
external
|
||||
href={`${$regionalProtocol}${data.proxyRuleList.rules[0]?.domain}`}>
|
||||
|
||||
Reference in New Issue
Block a user