Skip to content

Commit

Permalink
fix: consolevariabels check
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmanNik committed Aug 28, 2023
1 parent 26d4057 commit 34aa86c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/stores/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import type { Models } from '@appwrite.io/console';

export const consoleVariables = derived(
page,
($page) => $page.data.account as Models.ConsoleVariables
($page) => $page.data.consoleVariables as Models.ConsoleVariables
);
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { Query } from '@appwrite.io/console';
import { Query, type Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
import { isSelfHosted } from '$lib/system';

export const load: PageLoad = async ({ params, depends, url, route, parent }) => {
await parent();
depends(Dependencies.DEPLOYMENTS);
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
let consoleVariables: Models.ConsoleVariables = null;
if (isSelfHosted) {
consoleVariables = await sdk.forConsole.console.variables();
}

return {
offset,
Expand All @@ -19,6 +24,6 @@ export const load: PageLoad = async ({ params, depends, url, route, parent }) =>
Query.offset(offset),
Query.orderDesc('')
]),
consoleVariables: sdk.forConsole.console.variables()
consoleVariables
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@
selectedDir !== $func?.providerRootDirectory;
$: isVcsEnabled = $consoleVariables?._APP_VCS_ENABLED === true;
$: console.log($consoleVariables);
</script>

<Form onSubmit={updateConfiguration}>
Expand Down
9 changes: 7 additions & 2 deletions src/routes/console/project-[project]/settings/+page.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import { sdk } from '$lib/stores/sdk';
import { Query } from '@appwrite.io/console';
import { Query, type Models } from '@appwrite.io/console';
import type { PageLoad } from './$types';
import { isSelfHosted } from '$lib/system';

export const load: PageLoad = async ({ depends, url }) => {
depends(Dependencies.PROJECT_VARIABLES);
depends(Dependencies.PROJECT_INSTALLATIONS);
const limit = PAGE_LIMIT;
const offset = Number(url.searchParams.get('offset') ?? 0);
let consoleVariables: Models.ConsoleVariables = null;
if (isSelfHosted) {
consoleVariables = await sdk.forConsole.console.variables();
}

return {
limit,
Expand All @@ -17,6 +22,6 @@ export const load: PageLoad = async ({ depends, url }) => {
Query.limit(limit),
Query.offset(offset)
]),
consoleVariables: sdk.forConsole.console.variables()
consoleVariables
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
}
$: isVcsEnabled = $consoleVariables?._APP_VCS_ENABLED === true;
$: console.log($consoleVariables, isVcsEnabled);
</script>

<CardGrid>
Expand Down

0 comments on commit 34aa86c

Please sign in to comment.