mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix: separate site build and runtime specs
This commit is contained in:
1 parent
9d38b9dd6e
commit
66dc7d1aac
3 files changed
+61
-24
No files matched your search
+15
-6
@@ -1,9 +1,10 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
|
||||
import { isCloud } from '$lib/system';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { Query, type Models } from '@appwrite.io/console';
|
||||
|
||||
const VARIABLES_LIMIT = 100;
|
||||
type SiteSpecification = Models.Specification & { buildEnabled: boolean; runtimeEnabled: boolean };
|
||||
|
||||
export const load = async ({ params, depends, parent }) => {
|
||||
depends(Dependencies.VARIABLES);
|
||||
@@ -46,12 +47,20 @@ export const load = async ({ params, depends, parent }) => {
|
||||
}
|
||||
});
|
||||
|
||||
const enabledSpecs = specificationsList?.specifications?.filter((s) => s.enabled) ?? [];
|
||||
if (!enabledSpecs.some((s) => s.slug === site.buildSpecification)) {
|
||||
site.buildSpecification = enabledSpecs[0]?.slug;
|
||||
const specifications = (specificationsList?.specifications ?? []) as SiteSpecification[];
|
||||
const buildEnabledSpecs = specifications.filter((s) => s.buildEnabled);
|
||||
const runtimeEnabledSpecs = specifications.filter((s) => s.runtimeEnabled);
|
||||
if (
|
||||
buildEnabledSpecs.length &&
|
||||
!buildEnabledSpecs.some((s) => s.slug === site.buildSpecification)
|
||||
) {
|
||||
site.buildSpecification = buildEnabledSpecs[0]?.slug;
|
||||
}
|
||||
if (!enabledSpecs.some((s) => s.slug === site.runtimeSpecification)) {
|
||||
site.runtimeSpecification = enabledSpecs[0]?.slug;
|
||||
if (
|
||||
runtimeEnabledSpecs.length &&
|
||||
!runtimeEnabledSpecs.some((s) => s.slug === site.runtimeSpecification)
|
||||
) {
|
||||
site.runtimeSpecification = runtimeEnabledSpecs[0]?.slug;
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
+27
-12
@@ -25,6 +25,11 @@
|
||||
specs: Models.SpecificationList;
|
||||
} = $props();
|
||||
|
||||
type SiteSpecification = Models.Specification & {
|
||||
buildEnabled: boolean;
|
||||
runtimeEnabled: boolean;
|
||||
};
|
||||
|
||||
let frameworkKey = $state(site.framework);
|
||||
let installCommand = $state(site?.installCommand);
|
||||
let buildCommand = $state(site?.buildCommand);
|
||||
@@ -125,13 +130,20 @@
|
||||
site.adapter = adapter;
|
||||
}
|
||||
if (specs && specs.specifications?.length) {
|
||||
const enabledSpecs = specs.specifications.filter((s) => s.enabled);
|
||||
const fallbackSlug = enabledSpecs[0]?.slug ?? specs.specifications[0]?.slug;
|
||||
if (!enabledSpecs.some((s) => s.slug === site.buildSpecification)) {
|
||||
site.buildSpecification = fallbackSlug;
|
||||
const specifications = specs.specifications as SiteSpecification[];
|
||||
const buildEnabledSpecs = specifications.filter((s) => s.buildEnabled);
|
||||
const runtimeEnabledSpecs = specifications.filter((s) => s.runtimeEnabled);
|
||||
if (
|
||||
buildEnabledSpecs.length &&
|
||||
!buildEnabledSpecs.some((s) => s.slug === site.buildSpecification)
|
||||
) {
|
||||
site.buildSpecification = buildEnabledSpecs[0]?.slug;
|
||||
}
|
||||
if (!enabledSpecs.some((s) => s.slug === site.runtimeSpecification)) {
|
||||
site.runtimeSpecification = fallbackSlug;
|
||||
if (
|
||||
runtimeEnabledSpecs.length &&
|
||||
!runtimeEnabledSpecs.some((s) => s.slug === site.runtimeSpecification)
|
||||
) {
|
||||
site.runtimeSpecification = runtimeEnabledSpecs[0]?.slug;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,14 +156,17 @@
|
||||
adptr = selectedFramework.adapters[0];
|
||||
site.adapter = adapter;
|
||||
}
|
||||
// only allow enabled specsification for it
|
||||
const enabledSpecs = specs?.specifications?.filter((s) => s.enabled) ?? [];
|
||||
const specToSend = enabledSpecs.some((s) => s.slug === site.buildSpecification)
|
||||
const specifications = (specs?.specifications ?? []) as SiteSpecification[];
|
||||
const buildEnabledSpecs = specifications.filter((s) => s.buildEnabled);
|
||||
const runtimeEnabledSpecs = specifications.filter((s) => s.runtimeEnabled);
|
||||
const specToSend = buildEnabledSpecs.some((s) => s.slug === site.buildSpecification)
|
||||
? site.buildSpecification
|
||||
: enabledSpecs[0]?.slug;
|
||||
const runtimeSpecToSend = enabledSpecs.some((s) => s.slug === site.runtimeSpecification)
|
||||
: (buildEnabledSpecs[0]?.slug ?? site.buildSpecification);
|
||||
const runtimeSpecToSend = runtimeEnabledSpecs.some(
|
||||
(s) => s.slug === site.runtimeSpecification
|
||||
)
|
||||
? site.runtimeSpecification
|
||||
: enabledSpecs[0]?.slug;
|
||||
: (runtimeEnabledSpecs[0]?.slug ?? site.runtimeSpecification);
|
||||
try {
|
||||
await sdk.forProject(page.params.region, page.params.project).sites.update({
|
||||
siteId: site.$id,
|
||||
|
||||
+19
-6
@@ -18,6 +18,11 @@
|
||||
export let site: Models.Site;
|
||||
export let specs: Models.SpecificationList;
|
||||
|
||||
type SiteSpecification = Models.Specification & {
|
||||
buildEnabled: boolean;
|
||||
runtimeEnabled: boolean;
|
||||
};
|
||||
|
||||
let buildSpecification = site.buildSpecification;
|
||||
let runtimeSpecification = site.runtimeSpecification;
|
||||
let originalBuild = site.buildSpecification;
|
||||
@@ -75,10 +80,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
const options = (specs?.specifications ?? []).map((spec) => ({
|
||||
const specifications = (specs?.specifications ?? []) as SiteSpecification[];
|
||||
const buildEnabledSpecs = specifications.filter((spec) => spec.buildEnabled);
|
||||
const runtimeEnabledSpecs = specifications.filter((spec) => spec.runtimeEnabled);
|
||||
const buildOptions = specifications.map((spec) => ({
|
||||
label: `${spec.cpus} CPU, ${spec.memory} MB RAM`,
|
||||
value: spec.slug,
|
||||
disabled: !spec.enabled
|
||||
disabled: !spec.buildEnabled
|
||||
}));
|
||||
const runtimeOptions = specifications.map((spec) => ({
|
||||
label: `${spec.cpus} CPU, ${spec.memory} MB RAM`,
|
||||
value: spec.slug,
|
||||
disabled: !spec.runtimeEnabled
|
||||
}));
|
||||
</script>
|
||||
|
||||
@@ -94,9 +107,9 @@
|
||||
label="Build specification"
|
||||
id="build-specification"
|
||||
required
|
||||
disabled={options.length < 1}
|
||||
disabled={buildEnabledSpecs.length < 1}
|
||||
bind:value={buildSpecification}
|
||||
{options}>
|
||||
options={buildOptions}>
|
||||
<Tooltip slot="info">
|
||||
<Icon icon={IconInfo} size="s" />
|
||||
<span slot="tooltip">
|
||||
@@ -109,9 +122,9 @@
|
||||
label="Runtime specification"
|
||||
id="runtime-specification"
|
||||
required
|
||||
disabled={options.length < 1}
|
||||
disabled={runtimeEnabledSpecs.length < 1}
|
||||
bind:value={runtimeSpecification}
|
||||
{options}>
|
||||
options={runtimeOptions}>
|
||||
<Tooltip slot="info">
|
||||
<Icon icon={IconInfo} size="s" />
|
||||
<span slot="tooltip">
|
||||
|
||||
Reference in new issue
Block a user