-
Notifications
You must be signed in to change notification settings - Fork 236
fix: normalize created proxy rule status in console #3023
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 ''; | ||
|
Comment on lines
+36
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The old Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| } | ||
|
|
||
| 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; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createdstatusThe old code whitelisted only
'verifying'and'unverified'for log viewing. The newnormalizedStatus !== Verifiedpredicate also includescreated(before normalization) and any unrecognized future statuses. Since the PR intentionally treatscreatedas a failure state equivalent tounverified, this is probably correct — but worth confirming that exposing logs on a freshly-created (never-attempted) rule is the desired UX, in case the API returnscreatedfor brand-new rules that have no meaningful logs yet.