Skip to content

Commit

Permalink
update: expirations for different key types.
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzNotABug committed Nov 29, 2024
1 parent 7fed9c0 commit d37192c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@
single
allowCreate={$canWriteKeys}
href="https://appwrite.io/docs/advanced/platform/api-keys"
target={$isStandardApiKey ? 'API key' : 'Dev key'}
target="{$isStandardApiKey ? 'API' : 'Dev'} key"
on:click={createApiKey} />
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
return date.toISOString();
}
const options = [
const defaultOptions = [
{
label: 'Never',
value: null
Expand All @@ -46,10 +46,31 @@
}
];
const limitedOptions = [
{
label: '1 Day',
value: incrementToday(1, 'day')
},
{
label: '7 Days',
value: incrementToday(7, 'day')
},
{
label: '30 days',
value: incrementToday(30, 'day')
}
];
export let value: string | null = null;
export let isStandardApiKey: boolean = false;
const options = isStandardApiKey ? defaultOptions : limitedOptions;
function initExpirationSelect() {
if (value === null || !isValidDate(value)) return null;
if (value === null || !isValidDate(value)) {
return options[0]?.value ?? null;
}
let result = 'custom';
for (const option of options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@
import ExpirationInput from '../expirationInput.svelte';
import { key } from './store';
import { isStandardApiKey } from '../../store';
const keyTypeName = $isStandardApiKey ? 'API' : 'Dev';
</script>

<WizardStep>
<svelte:fragment slot="title">{$isStandardApiKey ? 'API' : 'Dev'} key</svelte:fragment>
<svelte:fragment slot="title">{keyTypeName} key</svelte:fragment>
<svelte:fragment slot="subtitle">
{#if $isStandardApiKey}
Generate API keys to authenticate your application.
Generate API keys to authenticate your application. While still in development, use Dev
keys instead, as they're better suited for debugging.
{:else}
Generate Dev keys for improved debugging while still developing.
Test your app without rate limits and more detailed error messages.
{/if}
</svelte:fragment>
<FormList>
<InputText
id="name"
label="Name"
placeholder="{$isStandardApiKey ? 'API' : 'Dev'} key name"
placeholder="{keyTypeName} key name"
required
bind:value={$key.name} />
<ExpirationInput bind:value={$key.expire} />
<ExpirationInput bind:value={$key.expire} isStandardApiKey={$isStandardApiKey} />
</FormList>
</WizardStep>

0 comments on commit d37192c

Please sign in to comment.