merge: upstream

This commit is contained in:
Marie 2023-12-23 02:09:23 +01:00
commit 5db583a3eb
701 changed files with 50809 additions and 13660 deletions

View file

@ -26,9 +26,9 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkKeyValue>
</FormSplit>
<MkTextarea v-model="valueForEditor" tall class="_monospace">
<MkCodeEditor v-model="valueForEditor" lang="json5">
<template #label>{{ i18n.ts.value }} (JSON)</template>
</MkTextarea>
</MkCodeEditor>
<MkButton primary @click="save"><i class="ph-floppy-disk ph-bold ph-lg"></i> {{ i18n.ts.save }}</MkButton>
@ -45,14 +45,14 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { watch } from 'vue';
import { watch, computed, ref } from 'vue';
import JSON5 from 'json5';
import * as os from '@/os.js';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import MkButton from '@/components/MkButton.vue';
import MkKeyValue from '@/components/MkKeyValue.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import MkCodeEditor from '@/components/MkCodeEditor.vue';
import FormSplit from '@/components/form/split.vue';
import FormInfo from '@/components/MkInfo.vue';
@ -61,26 +61,26 @@ const props = defineProps<{
domain: string;
}>();
const scope = $computed(() => props.path.split('/').slice(0, -1));
const key = $computed(() => props.path.split('/').at(-1));
const scope = computed(() => props.path.split('/').slice(0, -1));
const key = computed(() => props.path.split('/').at(-1));
let value = $ref(null);
let valueForEditor = $ref(null);
const value = ref(null);
const valueForEditor = ref(null);
function fetchValue() {
os.api('i/registry/get-detail', {
scope,
key,
scope: scope.value,
key: key.value,
domain: props.domain === '@' ? null : props.domain,
}).then(res => {
value = res;
valueForEditor = JSON5.stringify(res.value, null, '\t');
value.value = res;
valueForEditor.value = JSON5.stringify(res.value, null, '\t');
});
}
async function save() {
try {
JSON5.parse(valueForEditor);
JSON5.parse(valueForEditor.value);
} catch (err) {
os.alert({
type: 'error',
@ -94,9 +94,9 @@ async function save() {
}).then(({ canceled }) => {
if (canceled) return;
os.apiWithDialog('i/registry/set', {
scope,
key,
value: JSON5.parse(valueForEditor),
scope: scope.value,
key: key.value,
value: JSON5.parse(valueForEditor.value),
domain: props.domain === '@' ? null : props.domain,
});
});
@ -109,8 +109,8 @@ function del() {
}).then(({ canceled }) => {
if (canceled) return;
os.apiWithDialog('i/registry/remove', {
scope,
key,
scope: scope.value,
key: key.value,
domain: props.domain === '@' ? null : props.domain,
});
});
@ -118,9 +118,9 @@ function del() {
watch(() => props.path, fetchValue, { immediate: true });
const headerActions = $computed(() => []);
const headerActions = computed(() => []);
const headerTabs = $computed(() => []);
const headerTabs = computed(() => []);
definePageMetadata({
title: i18n.ts.registry,