Merge branch 'main' into fix-PRO-1094-alignment-fixes

# Conflicts:
#	src/routes/(console)/account/payments/paymentMethods.svelte
This commit is contained in:
ernstmul committed 2024-10-01 13:28:47 +02:00
commit 4b5123e1d8
32 files changed
+502 -99

No files matched your search

+3 -1
View File
@@ -321,5 +321,7 @@ export enum Submit {
MessagingTopicUpdatePermissions = 'submit_messaging_topic_update_permissions',
MessagingTopicSubscriberAdd = 'submit_messaging_topic_subscriber_add',
MessagingTopicSubscriberDelete = 'submit_messaging_topic_subscriber_delete',
ApplyQuickFilter = 'submit_apply_quick_filter'
ApplyQuickFilter = 'submit_apply_quick_filter',
RequestBAA = 'submit_request_baa',
RequestSoc2 = 'submit_request_soc2'
}
+1 -1
View File
@@ -52,7 +52,7 @@
function handleClose() {
const modalAlert = currentModalAlert;
dismissBottomModalAlert(modalAlert.id);
hideNotification(modalAlert.id);
hideNotification(modalAlert.id, { coolOffPeriod: 24 * 365 });
if (modalAlert.closed) modalAlert.closed();
if (currentIndex === filteredModalAlerts.length - 1 && filteredModalAlerts.length > 1) {
+1 -1
View File
@@ -26,7 +26,7 @@
<p class="body-text-2">
{maxValue}
{maxUnit && maxUnit}
{maxUnit ? maxUnit : ''}
</p>
</div>
{/if}
+1
View File
@@ -14,6 +14,7 @@ export function calculateSize(bytes: number, decimals = 1, base: 1000 | 1024 = 1
}
export function sizeToBytes(value: number, unit: Size, base = 1000) {
if (typeof value !== 'number') return 0;
const index = sizes.indexOf(unit);
return value * Math.pow(base, index);
}
+1 -1
View File
@@ -70,7 +70,7 @@ export function createTimeUnitPair(initialValue = 0) {
{ name: 'Minutes', value: 60 },
{ name: 'Seconds', value: 1 }
];
return { ...createValueUnitPair(initialValue, units), units };
return { ...createValueUnitPair(initialValue || 0, units), units };
}
export function createByteUnitPair(initialValue = 0, base: 1000 | 1024 = 1000) {
@@ -10,7 +10,6 @@ export const load: PageLoad = async ({ depends }) => {
sdk.forConsole.billing.listPaymentMethods(),
sdk.forConsole.billing.listAddresses()
]);
return {
paymentMethods,
addressList
@@ -18,7 +18,6 @@
import EditAddressModal from './editAddressModal.svelte';
import type { Address } from '$lib/sdk/billing';
import { organizationList, type Organization } from '$lib/stores/organization';
import { tooltip } from '$lib/actions/tooltip';
import { base } from '$app/paths';
import { Pill } from '$lib/elements';
@@ -29,6 +28,7 @@
let showDelete = false;
let showDropdown = [];
let countryList: Models.CountryList;
let showLinked = [];
onMount(async () => {
countryList = await sdk.forProject.locale.listCountries();
@@ -76,26 +76,28 @@
</TableCell>
<TableCell style="vertical-align: top;">
{#if linkedOrgs?.length > 0}
<div
use:tooltip={{
interactive: true,
allowHTML: true,
trigger: 'click',
content: `
<div class="u-flex u-flex-vertical u-gap-8">
<p class="text">This billing address is linked to the following organizations:</p>
${linkedOrgs
.map(
(org) =>
`<a href="${base}/organization-${org.$id}/billing" class="link">${org.name}</a>`
)
.join('')}
</div>`
}}>
<Pill button>
<DropList bind:show={showLinked[i]} width="20" scrollable>
<Pill
button
on:click={() => (showLinked[i] = !showLinked[i])}>
<span class="icon-info" /> linked to organization
</Pill>
</div>
<svelte:fragment slot="list">
<p class="u-break-word">
This billing address is linked to the following
organizations:
</p>
<div class="u-flex u-flex-vertical u-gap-4">
{#each linkedOrgs as org}
<a
class="u-underline u-trim"
href={`${base}/console/organization-${org.$id}/billing`}>
{org.name}
</a>
{/each}
</div>
</svelte:fragment>
</DropList>
{/if}
</TableCell>
<TableCell style="vertical-align: top;">
@@ -20,7 +20,6 @@
import { paymentMethods } from '$lib/stores/billing';
import type { PaymentMethodData } from '$lib/sdk/billing';
import { organizationList, type Organization } from '$lib/stores/organization';
import { tooltip } from '$lib/actions/tooltip';
import { base } from '$app/paths';
import EditPaymentModal from './editPaymentModal.svelte';
import DeletePaymentModal from './deletePaymentModal.svelte';
@@ -34,6 +33,7 @@
let showDelete = false;
let showEdit = false;
let isLinked = false;
let showLinked = [];
$: orgList = $organizationList.teams as unknown as Organization[];
@@ -68,27 +68,34 @@
<CreditCardInfo {paymentMethod}>
<div class="u-flex u-gap-16 u-cross-center">
{#if linkedOrgs?.length > 0}
<div
use:tooltip={{
interactive: true,
allowHTML: true,
trigger: 'click',
content: `
<div class="u-flex u-flex-vertical u-gap-4">
<p class="text">This payment method is linked to the following organizations:</p>
${linkedOrgs
.map(
(org) =>
`<a href="${base}/organization-${org.$id}/billing" class="link">${org.name}</a>`
)
.join('')}
</div>`
}}>
<Pill button>
<DropList
bind:show={showLinked[i]}
width="20"
scrollable>
<Pill
button
on:click={() =>
(showLinked[i] = !showLinked[i])}>
<span class="icon-info" /> linked to organization
</Pill>
</div>
<svelte:fragment slot="list">
<p class="u-break-word">
This payment method is linked to the
following organizations:
</p>
<div class="u-flex u-flex-vertical u-gap-4">
{#each linkedOrgs as org}
<a
class="u-underline u-trim"
href={`${base}/console/organization-${org.$id}/billing`}>
{org.name}
</a>
{/each}
</div>
</svelte:fragment>
</DropList>
{/if}
<DropList
bind:show={showDropdown[i]}
placement="bottom-start"
@@ -10,6 +10,7 @@
import { addNotification } from '$lib/stores/notifications';
import { organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import RemoveAddress from './removeAddress.svelte';
import { user } from '$lib/stores/user';
import AddressModal from '$routes/(console)/account/payments/addressModal.svelte';
import EditAddressModal from '$routes/(console)/account/payments/editAddressModal.svelte';
@@ -22,6 +23,7 @@
let showCreate = false;
let showEdit = false;
let showReplace = false;
let showRemove = false;
async function addAddress(addressId: string) {
try {
@@ -100,6 +102,14 @@
}}>
Replace
</DropListItem>
<DropListItem
icon="trash"
on:click={() => {
showRemove = true;
showBillingAddressDropdown = false;
}}>
Remove
</DropListItem>
</svelte:fragment>
</DropList>
</div>
@@ -166,3 +176,6 @@
{#if showReplace}
<ReplaceAddress bind:show={showReplace} />
{/if}
{#if showRemove}
<RemoveAddress bind:show={showRemove} />
{/if}
@@ -6,17 +6,17 @@
import { sdk } from '$lib/stores/sdk';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { organization } from '$lib/stores/organization';
import { Dependencies } from '$lib/constants';
import { BillingPlan, Dependencies } from '$lib/constants';
export let showDelete = false;
export let isBackup = false;
export let disabled = false;
export let hasOtherMethod = false;
let error: string;
async function removeDefaultMethod() {
if (!$organization.paymentMethodId || !$organization.backupPaymentMethodId) return;
showDelete = false;
if ($organization?.billingPlan !== BillingPlan.FREE && !hasOtherMethod) return;
try {
await sdk.forConsole.billing.removeOrganizationPaymentMethod($organization.$id);
@@ -26,13 +26,16 @@
});
trackEvent(Submit.OrganizationPaymentDelete);
invalidate(Dependencies.ORGANIZATION);
showDelete = false;
} catch (e) {
error = e.message;
trackError(e, Submit.OrganizationPaymentDelete);
} finally {
showDelete = false;
}
}
async function removeBackuptMethod() {
if (!$organization.paymentMethodId || !$organization.backupPaymentMethodId) return;
if ($organization?.billingPlan !== BillingPlan.FREE && !hasOtherMethod) return;
showDelete = false;
try {
@@ -43,6 +46,7 @@
});
trackEvent(Submit.OrganizationBackupPaymentDelete);
invalidate(Dependencies.ORGANIZATION);
showDelete = false;
} catch (e) {
error = e.message;
trackError(e, Submit.OrganizationBackupPaymentDelete);
@@ -10,7 +10,7 @@
DropListItem,
Heading
} from '$lib/components';
import { Dependencies } from '$lib/constants';
import { BillingPlan, Dependencies } from '$lib/constants';
import { addNotification } from '$lib/stores/notifications';
import { organization } from '$lib/stores/organization';
import { Button } from '$lib/elements/forms';
@@ -325,10 +325,12 @@
<ReplaceCard bind:show={showReplace} isBackup={isSelectedBackup} />
{/if}
{#if showDelete && isCloud && hasStripePublicKey}
{@const hasOtherMethod = isSelectedBackup
? !!$organization?.paymentMethodId
: !!$organization?.backupPaymentMethodId}
<DeleteOrgPayment
bind:showDelete
{hasOtherMethod}
isBackup={isSelectedBackup}
disabled={isSelectedBackup
? !$organization?.paymentMethodId
: !$organization?.backupPaymentMethodId} />
disabled={$organization?.billingPlan !== BillingPlan.FREE && !hasOtherMethod} />
{/if}
@@ -0,0 +1,47 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { Modal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdk } from '$lib/stores/sdk';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { organization } from '$lib/stores/organization';
import { Dependencies } from '$lib/constants';
export let show = false;
let error: string;
async function removeAddress() {
try {
await sdk.forConsole.billing.removeBillingAddress($organization.$id);
addNotification({
type: 'success',
message: `The billing address has been removed from ${$organization.name}`
});
trackEvent(Submit.OrganizationBillingAddressDelete);
invalidate(Dependencies.ORGANIZATION);
show = false;
} catch (e) {
error = e.message;
trackError(e, Submit.OrganizationBillingAddressDelete);
}
}
</script>
<Modal
bind:show
bind:error
onSubmit={removeAddress}
icon="exclamation"
state="warning"
headerDivider={false}
title="Remove billing address">
<p data-private>
Are you sure you want to remove the billing address from <b>{$organization?.name}</b>?
</p>
<svelte:fragment slot="footer">
<Button text on:click={() => (show = false)}>Cancel</Button>
<Button secondary submit>Remove</Button>
</svelte:fragment>
</Modal>
@@ -12,6 +12,8 @@
import DownloadDPA from './downloadDPA.svelte';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import { isCloud } from '$lib/system';
import Baa from './BAA.svelte';
import Soc2 from './Soc2.svelte';
export let data;
let name: string;
@@ -67,6 +69,8 @@
{#if isCloud}
<DownloadDPA />
<Baa />
<Soc2 />
{/if}
<CardGrid danger>
@@ -0,0 +1,36 @@
<script lang="ts">
import { Box, CardGrid, Heading } from '$lib/components';
import { Button } from '$lib/elements/forms';
import BaaModal from './BAAModal.svelte';
let show = false;
</script>
<CardGrid>
<div>
<Heading tag="h6" size="7">BAA</Heading>
</div>
<p class="text">After requesting a BAA, we will contact you via email for the next steps.</p>
<svelte:fragment slot="aside">
<Box>
<h6>
<b>Business Associate Agreement (BAA)</b>
</h6>
<p class="text u-margin-block-start-8">
A Business Associate Agreement (BAA) is a HIPAA-required document ensuring outside
services handling patient information for a healthcare organization follow privacy
rules.
</p>
<Button
secondary
external
class="u-margin-block-start-16"
on:click={() => (show = true)}
event="request_baa">
<span class="text">Request BAA</span>
</Button>
</Box>
</svelte:fragment>
</CardGrid>
<BaaModal bind:show />
@@ -0,0 +1,130 @@
<script lang="ts">
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import { Button, FormList, InputEmail, InputSelect, InputText } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { user } from '$lib/stores/user';
import { VARS } from '$lib/system';
import { onMount } from 'svelte';
export let show = false;
let email = '';
let employees: string = null;
let employeesOptions = [
{
value: '1-5',
label: '1-5'
},
{
value: '6-10',
label: '6-10'
},
{
value: '11-50',
label: '11-50'
},
{
value: '50+',
label: '50+'
}
];
let country = '';
let countryOptions = [];
let role = '';
let error: string;
onMount(async () => {
const countryList = await sdk.forProject.locale.listCountries();
const locale = await sdk.forProject.locale.get();
if (locale.countryCode) {
country = locale.countryCode;
}
countryOptions = countryList.countries.map((country) => {
return {
value: country.code,
label: country.name
};
});
email = $user.email;
});
async function handleSubmit() {
const response = await fetch(`${VARS.GROWTH_ENDPOINT}/support`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
subject: 'support',
email: email,
firstName: $user?.name ?? '',
message: 'BAA',
tags: ['cloud'],
customFields: [
{ id: '41612', value: 'BAA' },
{ id: '48493', value: $user?.name ?? '' },
{ id: '48492', value: $organization?.$id ?? '' },
{ id: '48490', value: $user?.$id ?? '' }
],
metaFields: {
employees: employees,
country: country,
role: role
}
})
});
trackEvent(Submit.RequestBAA);
if (response.status !== 200) {
trackError(new Error(response.status.toString()), Submit.RequestBAA);
error = 'There was an error submitting your request. Please try again later.';
} else {
show = false;
addNotification({
message: `Your request was sent, we will get in contact with you at ${email} in a few working days`,
type: 'success'
});
}
}
</script>
<Modal
bind:error
bind:show
onSubmit={handleSubmit}
size="big"
title="Request BAA"
headerDivider={false}>
<FormList>
<InputEmail label="Email" placeholder="Enter email" id="email" bind:value={email} />
<InputSelect
label="Number of employees"
id="employees"
placeholder="Select number of employees"
required
options={employeesOptions}
bind:value={employees} />
<InputSelect
label="Country"
id="country"
options={countryOptions}
placeholder="Select country"
required
bind:value={country} />
<InputText
label="Your role"
placeholder="Enter your role"
id="role"
bind:value={role}
required />
<InputText label="Website" placeholder="Enter website" id="website" />
</FormList>
<svelte:fragment slot="footer">
<Button submit>
<span class="text">Send request</span>
</Button>
</svelte:fragment>
</Modal>
@@ -0,0 +1,36 @@
<script lang="ts">
import { Box, CardGrid, Heading } from '$lib/components';
import { Button } from '$lib/elements/forms';
import Soc2Modal from './Soc2Modal.svelte';
let show = false;
</script>
<CardGrid>
<div>
<Heading tag="h6" size="7">Soc-2</Heading>
</div>
<p class="text">After requesting Soc-2, we will contact you via email for the next steps.</p>
<svelte:fragment slot="aside">
<Box>
<h6>
<b>Service Organization Control Type 2 (Soc-2)</b>
</h6>
<p class="text u-margin-block-start-8">
Soc-2 is a framework for managing and protecting sensitive information, ensuring
compliance with trust service criteria such as security, availability, processing
integrity, confidentiality, and privacy.
</p>
<Button
secondary
external
class="u-margin-block-start-16"
on:click={() => (show = true)}
event="request_soc-2">
<span class="text">Request Soc-2</span>
</Button>
</Box>
</svelte:fragment>
</CardGrid>
<Soc2Modal bind:show />
@@ -0,0 +1,132 @@
<script lang="ts">
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Modal } from '$lib/components';
import { FormList, InputEmail, InputSelect, InputText } from '$lib/elements/forms';
import Button from '$lib/elements/forms/button.svelte';
import { addNotification } from '$lib/stores/notifications';
import { organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
import { user } from '$lib/stores/user';
import { VARS } from '$lib/system';
import { onMount } from 'svelte';
export let show = false;
let email = '';
let employees: string = null;
let employeesOptions = [
{
value: '1-5',
label: '1-5'
},
{
value: '6-10',
label: '6-10'
},
{
value: '11-50',
label: '11-50'
},
{
value: '50+',
label: '50+'
}
];
let country = '';
let countryOptions = [];
let role = '';
let error: string;
onMount(async () => {
const countryList = await sdk.forProject.locale.listCountries();
const locale = await sdk.forProject.locale.get();
if (locale.countryCode) {
country = locale.countryCode;
}
countryOptions = countryList.countries.map((country) => {
return {
value: country.code,
label: country.name
};
});
email = $user.email;
});
async function handleSubmit() {
const response = await fetch(`${VARS.GROWTH_ENDPOINT}/support`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
subject: 'support',
email: email,
firstName: $user?.name ?? '',
message: 'Soc-2',
tags: ['cloud'],
customFields: [
{ id: '41612', value: 'Soc-2' },
{ id: '48493', value: $user?.name ?? '' },
{ id: '48492', value: $organization?.$id ?? '' },
{ id: '48490', value: $user?.$id ?? '' }
],
metaFields: {
employees: employees,
country: country,
role: role
}
})
});
trackEvent(Submit.RequestSoc2);
if (response.status !== 200) {
trackError(new Error(response.status.toString()), Submit.RequestSoc2);
error = 'There was an error submitting your request. Please try again later.';
} else {
show = false;
addNotification({
message: `Your request was sent, we will get in contact with you at ${email} in a few working days`,
type: 'success'
});
}
}
</script>
<Modal
bind:error
bind:show
onSubmit={handleSubmit}
size="big"
headerDivider={false}
title="Request Soc-2">
<FormList>
<InputEmail label="Email" placeholder="Enter email" id="email" bind:value={email} />
<InputSelect
label="Number of employees"
id="employees"
placeholder="Select number of employees"
required
options={employeesOptions}
bind:value={employees} />
<InputSelect
label="Country"
id="country"
options={countryOptions}
placeholder="Select country"
required
bind:value={country} />
<InputText
label="Your role"
placeholder="Enter your role"
id="role"
bind:value={role}
required />
<InputText label="Website" placeholder="Enter website" id="website" />
</FormList>
<svelte:fragment slot="footer">
<Button submit>
<span class="text">Send request</span>
</Button>
</svelte:fragment>
</Modal>
@@ -237,7 +237,7 @@
<ProgressBarBig
currentUnit="Executions"
currentValue={formatNum(current)}
maxValue={`of ${formatNum(max)} Executions used`}
maxValue={`of ${formatNum(max)} executions used`}
progressValue={current}
progressMax={max}
showBar={false} />
@@ -59,7 +59,7 @@
<svelte:fragment slot="title">Project breakdown</svelte:fragment>
<TableScroll noMargin>
<TableHeader>
<TableCellHead width={185}>Project</TableCellHead>
<TableCellHead width={185} style="padding-left: 0;">Project</TableCellHead>
<TableCellHead width={100}>Usage</TableCellHead>
{#if $canSeeProjects}
<TableCellHead width={140} />
@@ -68,7 +68,7 @@
<TableBody>
{#each groupByProject(metric).sort((a, b) => b.usage - a.usage) as project}
<TableRow>
<TableCellText title="Project">
<TableCellText title="Project" style="padding-left: 0;">
{getProjectName(project.projectId)}
</TableCellText>
<TableCellText title="Usage">{format(project.usage)}</TableCellText>
@@ -22,7 +22,6 @@
let numbers: Models.MockNumber[] = $project?.authMockNumbers ?? [];
let initialNumbers = [];
let projectId: string = $project.$id;
$: initialNumbers = $project?.authMockNumbers?.map((num) => ({ ...num })) ?? [];
$: isSubmitDisabled = JSON.stringify(numbers) === JSON.stringify(initialNumbers);
@@ -39,7 +38,7 @@
async function updateMockNumbers() {
try {
await sdk.forConsole.projects.updateMockNumbers(projectId, numbers);
await sdk.forConsole.projects.updateMockNumbers($project.$id, numbers);
await invalidate(Dependencies.PROJECT);
addNotification({
type: 'success',
@@ -8,13 +8,12 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
const projectId = $project.$id;
let passwordDictionary = $project.authPasswordDictionary ?? false;
let passwordDictionary = $project?.authPasswordDictionary ?? false;
async function updatePasswordDictionary() {
try {
await sdk.forConsole.projects.updateAuthPasswordDictionary(
projectId,
$project.$id,
passwordDictionary
);
await invalidate(Dependencies.PROJECT);
@@ -56,7 +55,7 @@
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={passwordDictionary === $project.authPasswordDictionary} submit
<Button disabled={passwordDictionary === $project?.authPasswordDictionary} submit
>Update</Button>
</svelte:fragment>
</CardGrid>
@@ -9,15 +9,14 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
const projectId = $project.$id;
let passwordHistory = $project.authPasswordHistory < 1 ? 5 : $project.authPasswordHistory;
let passwordHistoryEnabled = ($project.authPasswordHistory ?? 0) != 0;
let passwordHistory = $project?.authPasswordHistory < 1 ? 5 : $project?.authPasswordHistory;
let passwordHistoryEnabled = ($project?.authPasswordHistory ?? 0) !== 0;
let initialPasswordHistoryEnabled = passwordHistoryEnabled;
async function updatePasswordHistoryLimit() {
try {
await sdk.forConsole.projects.updateAuthPasswordHistory(
projectId,
$project.$id,
passwordHistoryEnabled ? passwordHistory : 0
);
await invalidate(Dependencies.PROJECT);
@@ -67,8 +66,8 @@
<svelte:fragment slot="actions">
<Button
disabled={(passwordHistory === $project.authPasswordHistory ||
$project.authPasswordHistory === 0) &&
disabled={(passwordHistory === $project?.authPasswordHistory ||
$project?.authPasswordHistory === 0) &&
initialPasswordHistoryEnabled === passwordHistoryEnabled}
submit>Update</Button>
</svelte:fragment>
@@ -9,7 +9,7 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
let authPersonalDataCheck = $project.authPersonalDataCheck ?? false;
let authPersonalDataCheck = $project?.authPersonalDataCheck ?? false;
async function updatePersonalDataCheck() {
try {
@@ -50,7 +50,7 @@
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={authPersonalDataCheck === $project.authPersonalDataCheck} submit
<Button disabled={authPersonalDataCheck === $project?.authPersonalDataCheck} submit
>Update</Button>
</svelte:fragment>
</CardGrid>
@@ -9,7 +9,7 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
let authSessionAlerts = $project.authSessionAlerts ?? false;
let authSessionAlerts = $project?.authSessionAlerts ?? false;
async function updateSessionAlerts() {
try {
@@ -46,7 +46,7 @@
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={authSessionAlerts === $project.authSessionAlerts} submit>
<Button disabled={authSessionAlerts === $project?.authSessionAlerts} submit>
Update
</Button>
</svelte:fragment>
@@ -9,13 +9,12 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
const projectId = $project.$id;
const { value, unit, baseValue, units } = createTimeUnitPair($project.authDuration);
const { value, unit, baseValue, units } = createTimeUnitPair($project?.authDuration);
const options = units.map((v) => ({ label: v.name, value: v.name }));
async function updateSessionLength() {
try {
await sdk.forConsole.projects.updateAuthDuration(projectId, $baseValue);
await sdk.forConsole.projects.updateAuthDuration($project.$id, $baseValue);
await invalidate(Dependencies.PROJECT);
addNotification({
@@ -8,13 +8,11 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
const projectId = $project.$id;
let maxSessions = $project.authSessionsLimit;
let maxSessions = $project?.authSessionsLimit;
async function updateSessionsLimit() {
try {
await sdk.forConsole.projects.updateAuthSessionsLimit(projectId, maxSessions);
await sdk.forConsole.projects.updateAuthSessionsLimit($project.$id, maxSessions);
await invalidate(Dependencies.PROJECT);
addNotification({
@@ -43,7 +41,7 @@
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={maxSessions === $project.authSessionsLimit} submit>Update</Button>
<Button disabled={maxSessions === $project?.authSessionsLimit} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -10,15 +10,13 @@
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
const projectId = $project.$id;
let isLimited = $project.authLimit !== 0;
let newLimit = isLimited ? $project.authLimit : 100;
let isLimited = $project?.authLimit !== 0;
let newLimit = isLimited ? $project?.authLimit : 100;
$: btnDisabled = (function isBtnDisabled() {
if (
(!isLimited && $project.authLimit === 0) ||
(isLimited && $project.authLimit === newLimit)
(!isLimited && $project?.authLimit === 0) ||
(isLimited && $project?.authLimit === newLimit)
) {
return true;
}
@@ -28,7 +26,7 @@
async function updateLimit() {
try {
await sdk.forConsole.projects.updateAuthLimit(projectId, isLimited ? newLimit : 0);
await sdk.forConsole.projects.updateAuthLimit($project?.$id, isLimited ? newLimit : 0);
await invalidate(Dependencies.PROJECT);
addNotification({
type: 'success',
@@ -33,11 +33,9 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { Alert, CardGrid, Collapsible, CollapsibleItem, Heading } from '$lib/components';
import { Container } from '$lib/layout';
import { sdk } from '$lib/stores/sdk';
import { project } from '../../store';
import { addNotification } from '$lib/stores/notifications';
import { onMount } from 'svelte';
import EmailVerificationTemplate from './emailVerificationTemplate.svelte';
@@ -63,7 +61,7 @@
EmailTemplateLocale
} from '@appwrite.io/console';
const projectId = $page.params.project;
export let data;
let emailOpen = 'verification';
$: emailVerificationOpen = emailOpen === 'verification';
@@ -86,7 +84,7 @@
async function openEmail(type: string) {
type === emailOpen ? (emailOpen = null) : (emailOpen = type);
$emailTemplate = await loadEmailTemplate(projectId, type, 'en');
$emailTemplate = await loadEmailTemplate(data.project.$id, type, 'en');
$baseEmailTemplate = { ...$emailTemplate };
}
@@ -105,7 +103,7 @@
</div>
</div>
{#if !$project.smtpEnabled}
{#if !data.project.smtpEnabled}
<div class="u-margin-block-start-24">
<Alert
isStandalone
@@ -114,7 +112,7 @@
buttons={[
{
slot: 'SMTP settings',
href: `${base}/project-${$project.$id}/settings/smtp`
href: `${base}/project-${data.project.$id}/settings/smtp`
}
]}>
<svelte:fragment slot="title">
@@ -216,7 +214,7 @@
</Collapsible>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button href={`${base}/project-${$project.$id}/settings/smtp`} secondary>
<Button href={`${base}/project-${data.project.$id}/settings/smtp`} secondary>
SMTP settings
</Button>
</svelte:fragment>
@@ -1,7 +1,6 @@
import { sdk } from '$lib/stores/sdk';
import type { PageLoad } from './$types';
export const load: PageLoad = async () => {
export const load = async () => {
const codes = await sdk.forProject.locale.listCodes();
return {
localeCodes: codes.localeCodes
@@ -87,7 +87,7 @@
$: isButtonDisabled = deepEqual($emailTemplate, $baseEmailTemplate);
$: isSmtpEnabled = $project.smtpEnabled;
$: isSmtpEnabled = $project?.smtpEnabled;
</script>
<Box class="u-position-relative">
@@ -16,7 +16,6 @@
import Create from './create.svelte';
import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system';
import { readOnly } from '$lib/stores/billing';
import { project } from '../../store';
import { writable } from 'svelte/store';
import type { Column } from '$lib/helpers/types';
import Table from './table.svelte';
@@ -199,7 +198,7 @@
{/if}
<Button
secondary
href={`${base}/project-${$project.$id}/functions/function-${$func.$id}/executions/execute-function`}
href={`${base}/project-${$page.params.project}/functions/function-${$func.$id}/executions/execute-function`}
disabled={isCloud && $readOnly && !GRACE_PERIOD_OVERRIDE}>
Execute
</Button>
@@ -16,12 +16,12 @@
} from '$lib/elements/table';
import { addNotification } from '$lib/stores/notifications';
import type { PageData } from './$types';
import { project } from '$routes/(console)/project-[project]/store';
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { sdk } from '$lib/stores/sdk';
import { toLocaleDateTime } from '$lib/helpers/date';
import type { Column } from '$lib/helpers/types';
import { page } from '$app/stores';
import { canWriteTopics } from '$lib/stores/roles';
export let columns: Column[];
@@ -75,7 +75,7 @@
<TableBody>
{#each data.topics.topics as topic (topic.$id)}
<TableRowLink
href={`${base}/project-${$project.$id}/messaging/topics/topic-${topic.$id}`}>
href={`${base}/project-${$page.params.project}/messaging/topics/topic-${topic.$id}`}>
{#if $canWriteTopics}
<TableCellCheck bind:selectedIds id={topic.$id} />
{/if}