mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #3023 from appwrite/fix-rule-status-created-ui
fix: normalize created proxy rule status in console
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
|
||||
import { getProxyRuleStatusBadge } from './status';
|
||||
|
||||
import { Badge, Layout, Typography, Table, InteractiveText } from '@appwrite.io/pink-svelte';
|
||||
|
||||
@@ -24,16 +25,13 @@
|
||||
{domain}
|
||||
</Typography.Text>
|
||||
{#if verified !== undefined}
|
||||
{#if ruleStatus === 'created'}
|
||||
<Badge variant="secondary" type="error" size="xs" content="Verification failed" />
|
||||
{:else if ruleStatus === 'verifying'}
|
||||
<Badge variant="secondary" size="xs" content="Generating certificate" />
|
||||
{:else if ruleStatus === 'unverified'}
|
||||
{@const statusBadge = getProxyRuleStatusBadge(ruleStatus)}
|
||||
{#if statusBadge}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
type="error"
|
||||
type={statusBadge.type}
|
||||
size="xs"
|
||||
content="Certificate generation failed" />
|
||||
content={statusBadge.content} />
|
||||
{:else if verified === true}
|
||||
<Badge variant="secondary" type="success" size="xs" content="Verified" />
|
||||
{/if}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
|
||||
import { getSubdomain } from '$lib/helpers/tlds';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { getProxyRuleStatusBadge } from './status';
|
||||
|
||||
let {
|
||||
domain,
|
||||
@@ -72,20 +73,13 @@
|
||||
{domain}
|
||||
</Typography.Text>
|
||||
{#if verified !== undefined}
|
||||
{#if ruleStatus === 'created'}
|
||||
{@const statusBadge = getProxyRuleStatusBadge(ruleStatus)}
|
||||
{#if statusBadge}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
type="error"
|
||||
type={statusBadge.type}
|
||||
size="xs"
|
||||
content="Verification failed" />
|
||||
{:else if ruleStatus === 'verifying'}
|
||||
<Badge variant="secondary" size="xs" content="Generating certificate" />
|
||||
{:else if ruleStatus === 'unverified'}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
type="error"
|
||||
size="xs"
|
||||
content="Certificate generation failed" />
|
||||
content={statusBadge.content} />
|
||||
{:else if verified === true}
|
||||
<Badge variant="secondary" type="success" size="xs" content="Verified" />
|
||||
{/if}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import { ProxyRuleStatus, type Models } from '@appwrite.io/console';
|
||||
|
||||
export type ProxyRuleStatusValue =
|
||||
| 'created'
|
||||
| 'verified'
|
||||
| 'verifying'
|
||||
| 'unverified'
|
||||
| ProxyRuleStatus
|
||||
| undefined;
|
||||
|
||||
export function isProxyRuleVerified(status: ProxyRuleStatusValue): boolean {
|
||||
return status === ProxyRuleStatus.Verified;
|
||||
}
|
||||
|
||||
export function normalizeProxyRuleStatus(status: ProxyRuleStatusValue): ProxyRuleStatusValue {
|
||||
if (status === ProxyRuleStatus.Created) {
|
||||
return ProxyRuleStatus.Unverified;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
export function isProxyRuleRetryable(status: ProxyRuleStatusValue): boolean {
|
||||
const normalizedStatus = normalizeProxyRuleStatus(status);
|
||||
|
||||
return normalizedStatus === ProxyRuleStatus.Unverified;
|
||||
}
|
||||
|
||||
export function isProxyRuleLogsViewable(proxyRule: Models.ProxyRule): boolean {
|
||||
return (
|
||||
Boolean(proxyRule.logs?.length) &&
|
||||
normalizeProxyRuleStatus(proxyRule.status) !== ProxyRuleStatus.Verified
|
||||
);
|
||||
}
|
||||
|
||||
export function getProxyRuleUpdatedPrefix(status: ProxyRuleStatusValue): string {
|
||||
const normalizedStatus = normalizeProxyRuleStatus(status);
|
||||
|
||||
if (normalizedStatus === ProxyRuleStatus.Verifying) {
|
||||
return 'Updated';
|
||||
}
|
||||
|
||||
if (normalizedStatus === ProxyRuleStatus.Unverified) {
|
||||
return 'Failed';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
export function getProxyRuleStatusBadge(status: ProxyRuleStatusValue): {
|
||||
content: string;
|
||||
type?: 'error';
|
||||
} | null {
|
||||
const normalizedStatus = normalizeProxyRuleStatus(status);
|
||||
|
||||
if (normalizedStatus === ProxyRuleStatus.Verifying) {
|
||||
return {
|
||||
content: 'Generating certificate'
|
||||
};
|
||||
}
|
||||
|
||||
if (normalizedStatus === ProxyRuleStatus.Unverified) {
|
||||
return {
|
||||
content: 'Certificate generation failed',
|
||||
type: 'error'
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
+2
-1
@@ -25,6 +25,7 @@
|
||||
import { isCloud } from '$lib/system';
|
||||
import { getApexDomain } from '$lib/helpers/tlds';
|
||||
import { resolveRoute } from '$lib/stores/navigation';
|
||||
import { isProxyRuleVerified } from '$lib/components/domains/status';
|
||||
|
||||
let { data } = $props();
|
||||
|
||||
@@ -108,7 +109,7 @@
|
||||
|
||||
await invalidate(Dependencies.FUNCTION_DOMAINS);
|
||||
|
||||
const verified = rule?.status !== 'created';
|
||||
const verified = isProxyRuleVerified(rule?.status);
|
||||
if (verified) {
|
||||
addNotification({
|
||||
type: 'success',
|
||||
|
||||
+16
-23
@@ -24,6 +24,13 @@
|
||||
import { columns } from './store';
|
||||
import { regionalProtocol } from '$routes/(console)/project-[region]-[project]/store';
|
||||
import DnsRecordsAction from '$lib/components/domains/dnsRecordsAction.svelte';
|
||||
import {
|
||||
getProxyRuleStatusBadge,
|
||||
getProxyRuleUpdatedPrefix,
|
||||
isProxyRuleLogsViewable,
|
||||
isProxyRuleRetryable,
|
||||
isProxyRuleVerified
|
||||
} from '$lib/components/domains/status';
|
||||
import ViewLogsModal from '$lib/components/domains/viewLogsModal.svelte';
|
||||
import { timeFromNowShort } from '$lib/helpers/date';
|
||||
|
||||
@@ -49,7 +56,7 @@
|
||||
};
|
||||
|
||||
function updatedLabel(proxyRule: Models.ProxyRule): string {
|
||||
if (proxyRule.status === 'verified') {
|
||||
if (isProxyRuleVerified(proxyRule.status)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -58,14 +65,7 @@
|
||||
return '';
|
||||
}
|
||||
|
||||
const prefix =
|
||||
proxyRule.status === 'created'
|
||||
? 'Checked'
|
||||
: proxyRule.status === 'verifying'
|
||||
? 'Updated'
|
||||
: proxyRule.status === 'unverified'
|
||||
? 'Failed'
|
||||
: '';
|
||||
const prefix = getProxyRuleUpdatedPrefix(proxyRule.status);
|
||||
|
||||
return prefix + ' ' + timeStr;
|
||||
}
|
||||
@@ -81,10 +81,9 @@
|
||||
<Table.Header.Cell column="actions" {root} />
|
||||
</svelte:fragment>
|
||||
{#each proxyRules.rules as proxyRule (proxyRule.$id)}
|
||||
{@const isRetryable = proxyRule.status === 'created' || proxyRule.status === 'unverified'}
|
||||
{@const isLogsViewable =
|
||||
proxyRule.logs?.length > 0 &&
|
||||
(proxyRule.status === 'verifying' || proxyRule.status === 'unverified')}
|
||||
{@const isRetryable = isProxyRuleRetryable(proxyRule.status)}
|
||||
{@const isLogsViewable = isProxyRuleLogsViewable(proxyRule)}
|
||||
{@const statusBadge = getProxyRuleStatusBadge(proxyRule.status)}
|
||||
<Table.Row.Base {root}>
|
||||
{#each $columns as column}
|
||||
<Table.Cell column={column.id} {root}>
|
||||
@@ -99,17 +98,11 @@
|
||||
</Typography.Text>
|
||||
</Link>
|
||||
<Layout.Stack direction="row" gap="s" alignItems="center">
|
||||
{#if proxyRule.status !== 'verified'}
|
||||
{#if statusBadge}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
type={proxyRule.status === 'verifying'
|
||||
? undefined
|
||||
: 'error'}
|
||||
content={proxyRule.status === 'created'
|
||||
? 'Verification failed'
|
||||
: proxyRule.status === 'verifying'
|
||||
? 'Generating certificate'
|
||||
: 'Certificate generation failed'}
|
||||
type={statusBadge.type}
|
||||
content={statusBadge.content}
|
||||
size="xs" />
|
||||
{/if}
|
||||
{#if isRetryable}
|
||||
@@ -140,7 +133,7 @@
|
||||
</Layout.Stack>
|
||||
{:else if column.id === 'target'}
|
||||
{proxyTarget(proxyRule)}
|
||||
{:else if column.id === 'updated' && proxyRule.status !== 'verified'}
|
||||
{:else if column.id === 'updated' && !isProxyRuleVerified(proxyRule.status)}
|
||||
<Layout.Stack direction="row" justifyContent="flex-end">
|
||||
<Typography.Text
|
||||
variant="m-400"
|
||||
|
||||
+2
-1
@@ -13,6 +13,7 @@
|
||||
import { project } from '$routes/(console)/project-[region]-[project]/store';
|
||||
import { getApexDomain } from '$lib/helpers/tlds';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { isProxyRuleVerified } from '$lib/components/domains/status';
|
||||
|
||||
const routeBase = `${base}/project-${page.params.region}-${page.params.project}/settings/domains`;
|
||||
|
||||
@@ -58,7 +59,7 @@
|
||||
|
||||
await invalidate(Dependencies.DOMAINS);
|
||||
|
||||
const verified = rule?.status !== 'created';
|
||||
const verified = isProxyRuleVerified(rule?.status);
|
||||
if (verified) {
|
||||
addNotification({
|
||||
type: 'success',
|
||||
|
||||
@@ -23,6 +23,13 @@
|
||||
import RetryDomainModal from './retryDomainModal.svelte';
|
||||
import { regionalProtocol } from '../../store';
|
||||
import DnsRecordsAction from '$lib/components/domains/dnsRecordsAction.svelte';
|
||||
import {
|
||||
getProxyRuleStatusBadge,
|
||||
getProxyRuleUpdatedPrefix,
|
||||
isProxyRuleLogsViewable,
|
||||
isProxyRuleRetryable,
|
||||
isProxyRuleVerified
|
||||
} from '$lib/components/domains/status';
|
||||
import ViewLogsModal from '$lib/components/domains/viewLogsModal.svelte';
|
||||
import { timeFromNowShort } from '$lib/helpers/date';
|
||||
|
||||
@@ -56,7 +63,7 @@
|
||||
];
|
||||
|
||||
function updatedLabel(proxyRule: Models.ProxyRule): string {
|
||||
if (proxyRule.status === 'verified') {
|
||||
if (isProxyRuleVerified(proxyRule.status)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -65,14 +72,7 @@
|
||||
return '';
|
||||
}
|
||||
|
||||
const prefix =
|
||||
proxyRule.status === 'created'
|
||||
? 'Checked'
|
||||
: proxyRule.status === 'verifying'
|
||||
? 'Updated'
|
||||
: proxyRule.status === 'unverified'
|
||||
? 'Failed'
|
||||
: '';
|
||||
const prefix = getProxyRuleUpdatedPrefix(proxyRule.status);
|
||||
|
||||
return prefix + ' ' + timeStr;
|
||||
}
|
||||
@@ -88,10 +88,9 @@
|
||||
<Table.Header.Cell column="actions" {root} />
|
||||
</svelte:fragment>
|
||||
{#each domains.rules as proxyRule (proxyRule.$id)}
|
||||
{@const isRetryable = proxyRule.status === 'created' || proxyRule.status === 'unverified'}
|
||||
{@const isLogsViewable =
|
||||
proxyRule.logs?.length > 0 &&
|
||||
(proxyRule.status === 'verifying' || proxyRule.status === 'unverified')}
|
||||
{@const isRetryable = isProxyRuleRetryable(proxyRule.status)}
|
||||
{@const isLogsViewable = isProxyRuleLogsViewable(proxyRule)}
|
||||
{@const statusBadge = getProxyRuleStatusBadge(proxyRule.status)}
|
||||
<Table.Row.Base {root}>
|
||||
{#each columns as column}
|
||||
<Table.Cell column={column.id} {root}>
|
||||
@@ -106,17 +105,11 @@
|
||||
</Typography.Text>
|
||||
</Link>
|
||||
<Layout.Stack direction="row" gap="s" alignItems="center">
|
||||
{#if proxyRule.status !== 'verified'}
|
||||
{#if statusBadge}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
type={proxyRule.status === 'verifying'
|
||||
? undefined
|
||||
: 'error'}
|
||||
content={proxyRule.status === 'created'
|
||||
? 'Verification failed'
|
||||
: proxyRule.status === 'verifying'
|
||||
? 'Generating certificate'
|
||||
: 'Certificate generation failed'}
|
||||
type={statusBadge.type}
|
||||
content={statusBadge.content}
|
||||
size="xs" />
|
||||
{/if}
|
||||
{#if isRetryable}
|
||||
@@ -145,7 +138,7 @@
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
{:else if column.id === 'updated' && proxyRule.status !== 'verified'}
|
||||
{:else if column.id === 'updated' && !isProxyRuleVerified(proxyRule.status)}
|
||||
<Layout.Stack direction="row" justifyContent="flex-end">
|
||||
<Typography.Text
|
||||
variant="m-400"
|
||||
|
||||
+2
-1
@@ -29,6 +29,7 @@
|
||||
} from '$routes/(console)/project-[region]-[project]/store';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { getApexDomain } from '$lib/helpers/tlds';
|
||||
import { isProxyRuleVerified } from '$lib/components/domains/status';
|
||||
|
||||
const routeBase = `${base}/project-${page.params.region}-${page.params.project}/sites/site-${page.params.site}/domains`;
|
||||
|
||||
@@ -110,7 +111,7 @@
|
||||
|
||||
await invalidate(Dependencies.SITES_DOMAINS);
|
||||
|
||||
const verified = rule?.status !== 'created';
|
||||
const verified = isProxyRuleVerified(rule?.status);
|
||||
if (verified) {
|
||||
addNotification({
|
||||
type: 'success',
|
||||
|
||||
+16
-23
@@ -24,6 +24,13 @@
|
||||
import { columns } from './store';
|
||||
import { regionalProtocol } from '$routes/(console)/project-[region]-[project]/store';
|
||||
import DnsRecordsAction from '$lib/components/domains/dnsRecordsAction.svelte';
|
||||
import {
|
||||
getProxyRuleStatusBadge,
|
||||
getProxyRuleUpdatedPrefix,
|
||||
isProxyRuleLogsViewable,
|
||||
isProxyRuleRetryable,
|
||||
isProxyRuleVerified
|
||||
} from '$lib/components/domains/status';
|
||||
import ViewLogsModal from '$lib/components/domains/viewLogsModal.svelte';
|
||||
import { timeFromNowShort } from '$lib/helpers/date';
|
||||
|
||||
@@ -49,7 +56,7 @@
|
||||
};
|
||||
|
||||
function updatedLabel(proxyRule: Models.ProxyRule): string {
|
||||
if (proxyRule.status === 'verified') {
|
||||
if (isProxyRuleVerified(proxyRule.status)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -58,14 +65,7 @@
|
||||
return '';
|
||||
}
|
||||
|
||||
const prefix =
|
||||
proxyRule.status === 'created'
|
||||
? 'Checked'
|
||||
: proxyRule.status === 'verifying'
|
||||
? 'Updated'
|
||||
: proxyRule.status === 'unverified'
|
||||
? 'Failed'
|
||||
: '';
|
||||
const prefix = getProxyRuleUpdatedPrefix(proxyRule.status);
|
||||
|
||||
return prefix + ' ' + timeStr;
|
||||
}
|
||||
@@ -81,10 +81,9 @@
|
||||
<Table.Header.Cell column="actions" {root} />
|
||||
</svelte:fragment>
|
||||
{#each proxyRules.rules as proxyRule (proxyRule.$id)}
|
||||
{@const isRetryable = proxyRule.status === 'created' || proxyRule.status === 'unverified'}
|
||||
{@const isLogsViewable =
|
||||
proxyRule.logs?.length > 0 &&
|
||||
(proxyRule.status === 'verifying' || proxyRule.status === 'unverified')}
|
||||
{@const isRetryable = isProxyRuleRetryable(proxyRule.status)}
|
||||
{@const isLogsViewable = isProxyRuleLogsViewable(proxyRule)}
|
||||
{@const statusBadge = getProxyRuleStatusBadge(proxyRule.status)}
|
||||
<Table.Row.Base {root}>
|
||||
{#each $columns as column}
|
||||
<Table.Cell column={column.id} {root}>
|
||||
@@ -99,17 +98,11 @@
|
||||
</Typography.Text>
|
||||
</Link>
|
||||
<Layout.Stack direction="row" gap="s" alignItems="center">
|
||||
{#if proxyRule.status !== 'verified'}
|
||||
{#if statusBadge}
|
||||
<Badge
|
||||
variant="secondary"
|
||||
type={proxyRule.status === 'verifying'
|
||||
? undefined
|
||||
: 'error'}
|
||||
content={proxyRule.status === 'created'
|
||||
? 'Verification failed'
|
||||
: proxyRule.status === 'verifying'
|
||||
? 'Generating certificate'
|
||||
: 'Certificate generation failed'}
|
||||
type={statusBadge.type}
|
||||
content={statusBadge.content}
|
||||
size="xs" />
|
||||
{/if}
|
||||
{#if isRetryable}
|
||||
@@ -140,7 +133,7 @@
|
||||
</Layout.Stack>
|
||||
{:else if column.id === 'target'}
|
||||
{proxyTarget(proxyRule)}
|
||||
{:else if column.id === 'updated' && proxyRule.status !== 'verified'}
|
||||
{:else if column.id === 'updated' && !isProxyRuleVerified(proxyRule.status)}
|
||||
<Layout.Stack direction="row" justifyContent="flex-end">
|
||||
<Typography.Text
|
||||
variant="m-400"
|
||||
|
||||
Reference in New Issue
Block a user