Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update gh-ost params UI (#9174)
Liu Ji9cb95a7482fd
diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/BoolFlag.vue b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/BoolFlag.vuenew file mode 100644index 0000000000..b11dd3f819--- /dev/null+++ b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/BoolFlag.vue@@ -0,0 +1,34 @@+<template>+ <NRadioGroup+ :value="value"+ @update:value="$emit('update:value', $event as boolean)"+ >+ <NRadio :value="false">{{ getLabel(false) }}</NRadio>+ <NRadio :value="true">{{ getLabel(true) }}</NRadio>+ </NRadioGroup>+</template>++<script setup lang="ts">+import { NRadio, NRadioGroup } from "naive-ui";+import { useI18n } from "vue-i18n";++const props = defineProps<{+ value: boolean;+ defaults: boolean;+ readonly: boolean;+}>();++defineEmits<{+ (event: "update:value", on: boolean): void;+}>();++const { t } = useI18n();++const getLabel = (value: boolean) => {+ const label = value ? "true" : "false";+ if (value === props.defaults) {+ return `(${t("common.default")}) ${label}`;+ }+ return label;+};+</script>diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/DefaultParams.vue b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/DefaultParams.vuedeleted file mode 100644index 4ebb49f0ed..0000000000--- a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/DefaultParams.vue+++ /dev/null@@ -1,43 +0,0 @@-<template>- <div class="flex items-center">- <NButton size="small" @click="expanded = !expanded">- <template v-if="expanded">- {{ $t("task.online-migration.hide-default-parameters") }}- </template>- <template v-else>- {{ $t("task.online-migration.show-default-parameters") }}- </template>- </NButton>- </div>- <div- v-if="expanded"- class="grid gap-y-4 gap-x-4 items-center text-sm"- style="grid-template-columns: auto 1fr"- >- <div- v-for="param in DefaultGhostParameters"- :key="param.key"- class="contents"- >- <div class="font-medium text-control">{{ param.key }}</div>- <div class="textinfolabel break-all">- <NCheckbox- v-if="param.type === 'bool'"- :checked="param.value === 'true'"- :disabled="true"- />- <span v-else>- {{ param.value }}- </span>- </div>- </div>- </div>-</template>--<script lang="ts" setup>-import { NCheckbox } from "naive-ui";-import { ref } from "vue";-import { DefaultGhostParameters } from "./constants";--const expanded = ref(false);-</script>diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/FlagsForm.vue b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/FlagsForm.vueindex 875c313258..413b9165f1 100644--- a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/FlagsForm.vue+++ b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/FlagsForm.vue@@ -13,23 +13,34 @@<NInputv-if="param.type === 'int'"size="small"- :value="getIntValue(param.key)"+ :value="getIntValue(param)":allow-input="onlyAllowNumber":disabled="readonly"- @update:value="setIntValue(param.key, parseInt($event, 10))"+ :placeholder="param.defaults"+ @update:value="setIntValue(param, parseInt($event, 10))"/>- <NCheckbox- v-if="param.type === 'bool'"- :checked="getBoolValue(param.key)"+ <NInput+ v-if="param.type === 'float'"+ size="small"+ :value="getFloatValue(param)":disabled="readonly"- @update:checked="setBoolValue(param.key, $event)"+ :placeholder="param.defaults"+ @update:value="setFloatValue(param, $event)"+ />+ <BoolFlag+ v-if="param.type === 'bool'"+ :value="getBoolValue(param)"+ :defaults="param.defaults === 'true'"+ :readonly="readonly"+ @update:value="setBoolValue(param, $event)"/><NInputv-if="param.type === 'string'"size="small"- :value="getStringValue(param.key)"+ :value="getStringValue(param)":disabled="readonly"- @update:value="setStringValue(param.key, $event)"+ :placeholder="param.defaults"+ @update:value="setStringValue(param, $event)"/></div></div>@@ -37,9 +48,10 @@</template><script lang="ts" setup>-import { NCheckbox, NInput } from "naive-ui";+import { NInput } from "naive-ui";import { onlyAllowNumber } from "@/utils";-import { SupportedGhostParameters } from "./constants";+import BoolFlag from "./BoolFlag.vue";+import { GhostParameter, SupportedGhostParameters } from "./constants";const props = defineProps<{flags: Record<string, string>;@@ -49,29 +61,36 @@ const emit = defineEmits<{(event: "update:flags", flags: Record<string, string>): void;}>();-const getBoolValue = (key: string) => {- return props.flags[key] === "true";+const getBoolValue = (param: GhostParameter<"bool">) => {+ const { key, defaults: value } = param;+ if (props.flags[key] === "true") return true;+ if (props.flags[key] === "false") return false;+ return value === "true";};-const getStringValue = (key: string) => {- return props.flags[key] ?? "";+const getStringValue = (param: GhostParameter<"string">) => {+ return props.flags[param.key] ?? "";};-const getIntValue = (key: string) => {- const intVal = parseInt(props.flags[key], 10);+const getIntValue = (param: GhostParameter<"int">) => {+ const intVal = parseInt(props.flags[param.key], 10);if (Number.isNaN(intVal)) return undefined;return String(intVal);};+const getFloatValue = (param: GhostParameter<"float">) => {+ return props.flags[param.key];+};-const setBoolValue = (key: string, value: boolean) => {+const setBoolValue = (param: GhostParameter, value: boolean) => {+ const { key } = param;const updated = { ...props.flags };- if (value) {- updated[key] = "true";- } else {+ updated[key] = value ? "true" : "false";+ if (updated[key] === param.defaults) {delete updated[key];}emit("update:flags", updated);};-const setStringValue = (key: string, value: string) => {+const setStringValue = (param: GhostParameter<"string">, value: string) => {const updated = { ...props.flags };+ const { key } = param;value = value.trim();if (value) {updated[key] = value;@@ -80,9 +99,9 @@ const setStringValue = (key: string, value: string) => {}emit("update:flags", updated);};-const setIntValue = (key: string, value: number) => {+const setIntValue = (param: GhostParameter<"int">, value: number) => {const updated = { ...props.flags };-+ const { key } = param;if (!Number.isNaN(value)) {updated[key] = value.toString();} else {@@ -90,4 +109,15 @@ const setIntValue = (key: string, value: number) => {}emit("update:flags", updated);};+const setFloatValue = (param: GhostParameter<"float">, value: string) => {+ const updated = { ...props.flags };+ const { key } = param;+ value = value.trim();+ if (value !== "") {+ updated[key] = value;+ } else {+ delete updated[key];+ }+ emit("update:flags", updated);+};</script>diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/constants.ts b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/constants.tsindex e8c2f3f273..9c8b0fac39 100644--- a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/constants.ts+++ b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/constants.ts@@ -3,88 +3,22 @@ export type GhostParameterType = "bool" | "int" | "float" | "string";export type GhostParameter<T extends GhostParameterType = any> = {key: string;type: T;+ defaults: string;};-export type GhostParameterWithValue<T extends GhostParameterType = any> =- GhostParameter<T> & {- value: string;- };-export const SupportedGhostParameters: GhostParameter[] = [- { key: "max-load", type: "string" },- { key: "chunk-size", type: "int" },- { key: "initially-drop-ghost-table", type: "bool" },- { key: "max-lag-millis", type: "int" },- { key: "allow-on-master", type: "bool" },- { key: "switch-to-rbr", type: "bool" },-];--export const DefaultGhostParameters: GhostParameterWithValue[] = [- {- key: "allow-on-master",- type: "bool",- value: "true",- },- {- key: "concurrent-rowcount",- type: "bool",- value: "true",- },- {- key: "hooks-status-interval",- type: "int",- value: "60",- },- {- key: "heartbeat-interval-millis",- type: "int",- value: "100",- },- {- key: "nice-ratio",- type: "float",- value: "0",- },- {- key: "chunk-size",- type: "int",- value: "1000",- },- {- key: "dml-batch-size",- type: "int",- value: "10",- },- {- key: "max-lag-millis",- type: "int",- value: "1500",- },- {- key: "default-retries",- type: "int",- value: "60",- },- {- key: "cut-over-lock-timeout-seconds",- type: "int",- value: "60",- },- {- key: "exponential-backoff-max-interval",- type: "int",- value: "64",- },- {- key: "throttle-http-interval-millis",- type: "int",- value: "100",- },- {- key: "throttle-http-timeout-millis",- type: "int",- value: "1000",- },+ { key: "max-load", type: "string", defaults: "" },+ { key: "chunk-size", type: "int", defaults: "1000" },+ { key: "dml-batch-size", type: "int", defaults: "10" },+ { key: "default-retries", type: "int", defaults: "60" },+ { key: "cut-over-lock-timeout-seconds", type: "int", defaults: "60" },+ { key: "exponential-backoff-max-interval", type: "int", defaults: "64" },+ { key: "max-lag-millis", type: "int", defaults: "1500" },+ { key: "allow-on-master", type: "bool", defaults: "true" },+ { key: "switch-to-rbr", type: "bool", defaults: "false" },+ { key: "assume-rbr", type: "bool", defaults: "false" },+ { key: "heart-beat-interval-millis", type: "int", defaults: "100" },+ { key: "nice-ratio", type: "float", defaults: "0" },];export const isBoolParameter = (@@ -104,3 +38,9 @@ export const isStringParameter = (): param is GhostParameter<"string"> => {return param.type === "string";};++export const isFloatParameter = (+ param: GhostParameter+): param is GhostParameter<"float"> => {+ return param.type === "float";+};diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/index.ts b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/index.tsindex 9d6f915b7b..4347eddcde 100644--- a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/index.ts+++ b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/FlagsForm/index.ts@@ -1,5 +1,3 @@-import DefaultParams from "./DefaultParams.vue";import FlagsForm from "./FlagsForm.vue";export default FlagsForm;-export { FlagsForm, DefaultParams };diff --git a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostFlagsPanel.vue b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostFlagsPanel.vueindex 5cfeb7ced0..cdbfa910bc 100644--- a/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostFlagsPanel.vue+++ b/frontend/src/components/IssueV1/components/StageSection/Actions/GhostSection/GhostFlagsPanel.vue@@ -37,10 +37,14 @@</div><p class="font-medium text-control">- {{ $t("task.online-migration.ghost-parameters") }}+ {{ $t("task.online-migration.gho\st-parameters") }}++ <LearnMoreLink+ class="text-sm ml-1"+ url="https://github.com/github/gh-ost/blob/master/doc/command-line-flags.md"+ /></p><FlagsForm v-model:flags="flags" :readonly="readonly" />- <DefaultParams /></div></template><template #footer>@@ -81,12 +85,13 @@ import {stageForTask,useIssueContext,} from "@/components/IssueV1/logic";+import LearnMoreLink from "@/components/LearnMoreLink.vue";import ErrorList from "@/components/misc/ErrorList.vue";import { Drawer, DrawerContent, RichDatabaseName } from "@/components/v2";import { rolloutServiceClient } from "@/grpcweb";import { pushNotification } from "@/store";import { Plan_Spec, Task_Type } from "@/types/proto/v1/rollout_service";-import { FlagsForm, DefaultParams } from "./FlagsForm";+import FlagsForm from "./FlagsForm";import { allowChangeTaskGhostFlags, useIssueGhostContext } from "./common";const { t } = useI18n();