mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #1355 from appwrite/fix-page-breaks-on-redirection
fix: page breaks on redirection
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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',
|
||||
|
||||
+3
-4
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user