Skip to content
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

Update create function cover for case where VCS is not enabled #544

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions src/lib/pages/domains/wizard/step1.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,12 @@
import { sdk } from '$lib/stores/sdk';
import { isSelfHosted } from '$lib/system';
import { func } from '$routes/console/project-[project]/functions/function-[function]/store';
import { onMount } from 'svelte';
import { ProxyTypes } from '../index.svelte';
import { domain, typeStore } from './store';
import { consoleVariables } from '$routes/console/store';

let error = null;
let isDomainsEnabled = false;

onMount(async () => {
if (!isSelfHosted) {
return;
}

isDomainsEnabled = (await $consoleVariables)?._APP_DOMAIN_ENABLED === true;
});
const isDomainsEnabled = $consoleVariables?._APP_DOMAIN_ENABLED === true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$consoleVariables might need to be awaited since we are not doing it in the layout


async function createDomain() {
try {
Expand Down
331 changes: 199 additions & 132 deletions src/lib/wizards/functions/cover.svelte

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions src/routes/console/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@
.join(' ');
}

let isAssistantEnabled = false;
onMount(async () => {
isAssistantEnabled = (await $consoleVariables)?._APP_ASSISTANT_ENABLED === true;
});
const isAssistantEnabled = $consoleVariables?._APP_ASSISTANT_ENABLED === true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to be awaited too 🤔


$: isOnSettingsLayout = $project?.$id
? $page.url.pathname.includes(`project-${$project.$id}/settings`)
Expand Down
11 changes: 7 additions & 4 deletions src/routes/console/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ export const load: LayoutLoad = async ({ fetch, depends }) => {
depends(Dependencies.CONSOLE_VARIABLES);

const { endpoint, project } = sdk.forConsole.client.config;
const response = await fetch(`${endpoint}/health/version`, {
const versionPromise = fetch(`${endpoint}/health/version`, {
headers: {
'X-Appwrite-Project': project
}
});
const data = await response.json();
}).then((response) => response.json() as { version?: string });

const variablesPromise = sdk.forConsole.console.variables();

const [data, variables] = await Promise.all([versionPromise, variablesPromise]);

return {
consoleVariables: sdk.forConsole.console.variables(),
consoleVariables: variables,
version: data?.version ?? null
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@
import InputSelectSearch from '$lib/elements/forms/inputSelectSearch.svelte';
import { installations } from '$lib/wizards/functions/store';
import { isSelfHosted } from '$lib/system';
import { consoleVariables, isVcsEnabled } from '$routes/console/store';
import { consoleVariables } from '$routes/console/store';

const functionId = $page.params.function;
const isVcsEnabled = $consoleVariables?._APP_VCS_ENABLED === true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await 👍


let entrypoint: string;
let commands: string;
Expand Down Expand Up @@ -271,7 +272,7 @@
</div>
</Box>
{:else}
{#if isSelfHosted && !isVcsEnabled($consoleVariables)}
{#if isSelfHosted && !isVcsEnabled}
<Alert class="common-section" type="info">
<svelte:fragment slot="title">
Installing Git to a self-hosted instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import { Container } from '$lib/layout';
import { isSelfHosted } from '$lib/system';
import { connectTemplate } from '$lib/wizards/functions/cover.svelte';
import { consoleVariables, isVcsEnabled } from '$routes/console/store';
import { consoleVariables } from '$routes/console/store';
import { template } from './store';

const isVcsEnabled = $consoleVariables?._APP_VCS_ENABLED === true;
</script>

<Container>
Expand Down Expand Up @@ -60,7 +62,7 @@
</span>
</Heading>
<p class="u-margin-block-start-24">{$template.tagline}</p>
{#if isSelfHosted && !isVcsEnabled($consoleVariables)}
{#if isSelfHosted && !isVcsEnabled}
<Alert class="u-margin-block-start-24" type="info">
<svelte:fragment slot="title">
Cloning templates to a self-hosted instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import GitDisconnectModal from './GitDisconnectModal.svelte';
import dayjs from 'dayjs';
import { isSelfHosted } from '$lib/system';
import { consoleVariables, isVcsEnabled } from '$routes/console/store';
import { consoleVariables } from '$routes/console/store';

export let total: number;
export let limit: number;
Expand All @@ -40,6 +40,7 @@
let showGitDisconnect = false;
let showInstallationDropdown: boolean[] = [];
let selectedInstallation: Models.Installation;
const isVcsEnabled = $consoleVariables?._APP_VCS_ENABLED === true;

function getInstallationLink(installation: Models.Installation) {
switch (installation.provider) {
Expand Down Expand Up @@ -180,7 +181,7 @@
bind:offset />
</div>
{:else}
{#if isSelfHosted && !isVcsEnabled($consoleVariables)}
{#if isSelfHosted && !isVcsEnabled}
<Alert type="info">
<svelte:fragment slot="title">
Installing Git to a self-hosted instance
Expand All @@ -203,7 +204,7 @@
<div class="avatar"><SvgIcon name="appwrite" type="color" size={80} /></div>
</div>
<Button
disabled={isSelfHosted && !isVcsEnabled($consoleVariables)}
disabled={isSelfHosted && !isVcsEnabled}
on:click={() => (showGitIstall = true)}
secondary>
<span class="text">Add Installation</span>
Expand Down
5 changes: 1 addition & 4 deletions src/routes/console/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ import { derived } from 'svelte/store';
export const version = derived(page, ($page) => $page.data.version as string | null);
export const consoleVariables = derived(
page,
async ($page) => (await $page.data.consoleVariables) as Models.ConsoleVariables
($page) => $page.data.consoleVariables as Models.ConsoleVariables
);
export async function isVcsEnabled(store: Promise<Models.ConsoleVariables>) {
return (await store)?._APP_VCS_ENABLED === true;
}