mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
addressed code rabbit comment
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export type DetectedVariable = {
|
||||
key?: string;
|
||||
name?: string;
|
||||
value?: string;
|
||||
secret?: boolean;
|
||||
};
|
||||
|
||||
export function normalizeDetectedVariables(detected: DetectedVariable[] = []) {
|
||||
const normalized: Partial<Models.Variable>[] = [];
|
||||
detected.forEach((variable) => {
|
||||
const key = variable.key ?? variable.name;
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
normalized.push({
|
||||
key,
|
||||
value: variable.value ?? '',
|
||||
secret: variable.secret ?? false
|
||||
});
|
||||
});
|
||||
return normalized;
|
||||
}
|
||||
|
||||
export function mergeVariables(
|
||||
existing: Partial<Models.Variable>[],
|
||||
detected: Partial<Models.Variable>[]
|
||||
) {
|
||||
const map = new Map(existing.map((variable) => [variable.key, variable]));
|
||||
detected.forEach((variable) => {
|
||||
if (!variable.key) {
|
||||
return;
|
||||
}
|
||||
if (!map.has(variable.key)) {
|
||||
map.set(variable.key, variable);
|
||||
}
|
||||
});
|
||||
return Array.from(map.values());
|
||||
}
|
||||
+1
-39
@@ -22,6 +22,7 @@
|
||||
import RepoCard from './repoCard.svelte';
|
||||
import { getIconFromRuntime } from '$lib/stores/runtimes';
|
||||
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
|
||||
import { normalizeDetectedVariables, mergeVariables } from '$lib/helpers/variables';
|
||||
|
||||
export let data;
|
||||
|
||||
@@ -59,45 +60,6 @@
|
||||
|
||||
let detectingRuntime = true;
|
||||
|
||||
type DetectedVariable = {
|
||||
key?: string;
|
||||
name?: string;
|
||||
value?: string;
|
||||
secret?: boolean;
|
||||
};
|
||||
|
||||
function normalizeDetectedVariables(detected: DetectedVariable[] = []) {
|
||||
const normalized: Partial<Models.Variable>[] = [];
|
||||
detected.forEach((variable) => {
|
||||
const key = variable.key ?? variable.name;
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
normalized.push({
|
||||
key,
|
||||
value: variable.value ?? '',
|
||||
secret: variable.secret ?? false
|
||||
});
|
||||
});
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function mergeVariables(
|
||||
existing: Partial<Models.Variable>[],
|
||||
detected: Partial<Models.Variable>[]
|
||||
) {
|
||||
const map = new Map(existing.map((variable) => [variable.key, variable]));
|
||||
detected.forEach((variable) => {
|
||||
if (!variable.key) {
|
||||
return;
|
||||
}
|
||||
if (!map.has(variable.key)) {
|
||||
map.set(variable.key, variable);
|
||||
}
|
||||
});
|
||||
return Array.from(map.values());
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
installation.set(data.installation);
|
||||
repository.set(data.repository);
|
||||
|
||||
+1
-39
@@ -27,6 +27,7 @@
|
||||
import Configuration from '../../configuration.svelte';
|
||||
import Domain from '../../domain.svelte';
|
||||
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
|
||||
import { normalizeDetectedVariables, mergeVariables } from '$lib/helpers/variables';
|
||||
|
||||
export let data;
|
||||
let showExitModal = false;
|
||||
@@ -49,45 +50,6 @@
|
||||
let domainIsValid = true;
|
||||
let isVariablesLoading = true;
|
||||
|
||||
type DetectedVariable = {
|
||||
key?: string;
|
||||
name?: string;
|
||||
value?: string;
|
||||
secret?: boolean;
|
||||
};
|
||||
|
||||
function normalizeDetectedVariables(detected: DetectedVariable[] = []) {
|
||||
const normalized: Partial<Models.Variable>[] = [];
|
||||
detected.forEach((variable) => {
|
||||
const key = variable.key ?? variable.name;
|
||||
if (!key) {
|
||||
return;
|
||||
}
|
||||
normalized.push({
|
||||
key,
|
||||
value: variable.value ?? '',
|
||||
secret: variable.secret ?? false
|
||||
});
|
||||
});
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function mergeVariables(
|
||||
existing: Partial<Models.Variable>[],
|
||||
detected: Partial<Models.Variable>[]
|
||||
) {
|
||||
const map = new Map(existing.map((variable) => [variable.key, variable]));
|
||||
detected.forEach((variable) => {
|
||||
if (!variable.key) {
|
||||
return;
|
||||
}
|
||||
if (!map.has(variable.key)) {
|
||||
map.set(variable.key, variable);
|
||||
}
|
||||
});
|
||||
return Array.from(map.values());
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
installation.set(data.installation);
|
||||
repository.set(data.repository);
|
||||
|
||||
Reference in New Issue
Block a user