mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Update Console to handle specifications for self-hosted (#2685)
Update Console to conditionally call listSpecifications only on Cloud - Modified functions layout loader to check isCloud before calling listSpecifications - Modified sites settings page loader to check isCloud before calling listSpecifications - Updated function create pages to handle empty specifications array safely - Updated updateResourceLimits components to handle empty specifications array safely - On self-hosted, specifications will be empty and not passed to backend, allowing default spec
This commit is contained in:
@@ -3,6 +3,7 @@ import Header from './header.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { isCloud } from '$lib/system';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async ({ depends, params }) => {
|
||||
@@ -13,7 +14,9 @@ export const load: LayoutLoad = async ({ depends, params }) => {
|
||||
sdk
|
||||
.forProject(params.region, params.project)
|
||||
.vcs.listInstallations({ queries: [Query.limit(100)] }),
|
||||
sdk.forProject(params.region, params.project).functions.listSpecifications()
|
||||
isCloud
|
||||
? sdk.forProject(params.region, params.project).functions.listSpecifications()
|
||||
: Promise.resolve({ specifications: [], total: 0 })
|
||||
]);
|
||||
|
||||
return {
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@
|
||||
return { value, label, leadingHtml };
|
||||
});
|
||||
|
||||
const specificationOptions = data.specificationsList.specifications.map((size) => ({
|
||||
const specificationOptions = (data.specificationsList?.specifications ?? []).map((size) => ({
|
||||
label:
|
||||
`${size.cpus} CPU, ${size.memory} MB RAM` +
|
||||
(!size.enabled ? ` (Upgrade to use this)` : ''),
|
||||
@@ -58,7 +58,7 @@
|
||||
let roles: string[] = [];
|
||||
let variables: Partial<Models.Variable>[] = [];
|
||||
let files: FileList;
|
||||
let specification = specificationOptions[0].value;
|
||||
let specification = specificationOptions[0]?.value || '';
|
||||
|
||||
async function create() {
|
||||
try {
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@
|
||||
|
||||
export let data;
|
||||
|
||||
const specificationOptions = data.specificationsList.specifications.map((size) => ({
|
||||
const specificationOptions = (data.specificationsList?.specifications ?? []).map((size) => ({
|
||||
label:
|
||||
`${size.cpus} CPU, ${size.memory} MB RAM` +
|
||||
(!size.enabled ? ` (Upgrade to use this)` : ''),
|
||||
@@ -55,7 +55,7 @@
|
||||
let rootDir = './';
|
||||
let variables: Partial<Models.Variable>[] = [];
|
||||
let silentMode = false;
|
||||
let specification = specificationOptions[0].value;
|
||||
let specification = specificationOptions[0]?.value || '';
|
||||
|
||||
let detectingRuntime = true;
|
||||
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@
|
||||
|
||||
export let data;
|
||||
|
||||
const specificationOptions = data.specificationsList.specifications.map((size) => ({
|
||||
const specificationOptions = (data.specificationsList?.specifications ?? []).map((size) => ({
|
||||
label:
|
||||
`${size.cpus} CPU, ${size.memory} MB RAM` +
|
||||
(!size.enabled ? ` (Upgrade to use this)` : ''),
|
||||
@@ -65,7 +65,7 @@
|
||||
let selectedScopes: string[] = [];
|
||||
let execute = true;
|
||||
let variables: Partial<Models.TemplateVariable>[] = [];
|
||||
let specification = specificationOptions[0].value;
|
||||
let specification = specificationOptions[0]?.value || '';
|
||||
|
||||
onMount(async () => {
|
||||
if (!$installation?.$id) {
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
const options = specs.specifications.map((spec) => ({
|
||||
const options = (specs?.specifications ?? []).map((spec) => ({
|
||||
label: `${spec.cpus} CPU, ${spec.memory} MB RAM`,
|
||||
value: spec.slug,
|
||||
disabled: !spec.enabled
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { isCloud } from '$lib/system';
|
||||
|
||||
export const load = async ({ params, depends, parent }) => {
|
||||
depends(Dependencies.VARIABLES);
|
||||
@@ -14,7 +15,9 @@ export const load = async ({ params, depends, parent }) => {
|
||||
.sites.listVariables({ siteId: params.site }),
|
||||
sdk.forProject(params.region, params.project).sites.listFrameworks(),
|
||||
sdk.forProject(params.region, params.project).vcs.listInstallations(),
|
||||
sdk.forProject(params.region, params.project).sites.listSpecifications()
|
||||
isCloud
|
||||
? sdk.forProject(params.region, params.project).sites.listSpecifications()
|
||||
: Promise.resolve({ specifications: [], total: 0 })
|
||||
]);
|
||||
|
||||
// Conflicting variables first
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
const options = specs.specifications.map((spec) => ({
|
||||
const options = (specs?.specifications ?? []).map((spec) => ({
|
||||
label: `${spec.cpus} CPU, ${spec.memory} MB RAM`,
|
||||
value: spec.slug,
|
||||
disabled: !spec.enabled
|
||||
|
||||
Reference in New Issue
Block a user