Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: use NRadio (#10116)

ecmadao928fa7a95ca1
diff --git a/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue b/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue
index 464f79cff2..6669a2b8e3 100644
--- a/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue
+++ b/frontend/src/components/DatabaseBackup/DatabaseBackupSettingForm.vue
@@ -14,24 +14,16 @@
>
<template #trigger>
<div class="flex items-center gap-x-2 text-sm">
- <label
+ <NRadio
v-for="schedule in PLAN_SCHEDULES"
:key="schedule"
- class="flex items-center gap-x-2"
- :class="
- !isAllowedScheduleByPolicy(schedule) &&
- 'opacity-50 cursor-not-allowed'
- "
- @click="setSchedule(schedule)"
+ :value="schedule"
+ :checked="schedule === checkedSchedule"
+ :disabled="!isAllowedScheduleByPolicy(schedule)"
+ @change="setSchedule(schedule)"
>
- <input
- type="radio"
- :value="schedule"
- :checked="schedule === checkedSchedule"
- :disabled="!isAllowedScheduleByPolicy(schedule)"
- />
- <span>{{ nameOfSchedule(schedule) }}</span>
- </label>
+ {{ nameOfSchedule(schedule) }}
+ </NRadio>
</div>
</template>
@@ -150,7 +142,7 @@
</template>
<script lang="ts" setup>
-import { NPopover, NSelect, NInputNumber } from "naive-ui";
+import { NPopover, NSelect, NInputNumber, NRadio } from "naive-ui";
import { computed, PropType, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
import { DrawerContent } from "@/components/v2";
diff --git a/frontend/src/components/IdentityProviderCreateForm.vue b/frontend/src/components/IdentityProviderCreateForm.vue
index 48ff392302..807f4ffa81 100644
--- a/frontend/src/components/IdentityProviderCreateForm.vue
+++ b/frontend/src/components/IdentityProviderCreateForm.vue
@@ -19,22 +19,15 @@
</a>
</div>
<div class="w-full flex flex-row justify-start items-start space-x-2">
- <label
+ <NRadioGroup
v-for="item in identityProviderTypeList"
:key="item"
- class="flex flex-row justify-center items-center cursor-pointer mr-2"
- :for="`radio-${item}`"
+ v-model:value="state.type"
>
- <input
- :id="`radio-${item}`"
- v-model="state.type"
- type="radio"
- class="btn mr-2"
- :value="item"
- :checked="state.type === item"
- />
- <span>{{ identityProviderTypeToString(item) }}</span>
- </label>
+ <NRadio :value="item">
+ {{ identityProviderTypeToString(item) }}
+ </NRadio>
+ </NRadioGroup>
</div>
</div>
@@ -47,21 +40,22 @@
{{ $t("settings.sso.form.use-template") }}
</p>
<div class="w-full flex flex-row justify-start items-start space-x-2">
- <label
+ <NRadioGroup
v-for="template in templateList"
:key="template.title"
- class="w-24 h-24 border rounded-md flex flex-col justify-center items-center cursor-pointer hover:bg-gray-100"
- :for="`radio-${template.title}`"
- @click="handleTemplateSelect(template)"
+ :value="selectedTemplate?.title"
>
- <span>{{ template.title }}</span>
- <input
- :id="`radio-${template.title}`"
- type="radio"
- class="btn mt-4"
- :checked="selectedTemplate?.title === template.title"
- />
- </label>
+ <div
+ class="w-24 h-12 border rounded-md flex items-center justify-center"
+ >
+ <NRadio
+ :value="template.title"
+ @change="handleTemplateSelect(template)"
+ >
+ {{ template.title }}
+ </NRadio>
+ </div>
+ </NRadioGroup>
</div>
</div>
diff --git a/frontend/src/components/Project/ProjectCreatePanel.vue b/frontend/src/components/Project/ProjectCreatePanel.vue
index 3dca41a6d9..7c97e16984 100644
--- a/frontend/src/components/Project/ProjectCreatePanel.vue
+++ b/frontend/src/components/Project/ProjectCreatePanel.vue
@@ -53,32 +53,7 @@
<span class="text-red-600">*</span>
</div>
<div class="mt-2 textlabel">
- <div class="radio-set-row">
- <div class="radio">
- <input
- v-model="state.project.tenantMode"
- tabindex="-1"
- type="radio"
- class="btn"
- :value="TenantMode.TENANT_MODE_DISABLED"
- />
- <label class="label">{{ $t("project.mode.standard") }}</label>
- </div>
- <div class="radio space-x-1">
- <input
- v-model="state.project.tenantMode"
- tabindex="-1"
- type="radio"
- class="btn"
- :value="TenantMode.TENANT_MODE_ENABLED"
- />
- <label class="label">{{ $t("project.mode.batch") }}</label>
- <LearnMoreLink
- url="https://www.bytebase.com/docs/change-database/batch-change/?source=console"
- />
- <FeatureBadge feature="bb.feature.multi-tenancy" />
- </div>
- </div>
+ <ProjectModeRadioGroup v-model:value="state.project.tenantMode" />
</div>
</div>
</div>
diff --git a/frontend/src/components/Project/ProjectGeneralSettingPanel.vue b/frontend/src/components/Project/ProjectGeneralSettingPanel.vue
index 02292d7000..7dabc473ab 100644
--- a/frontend/src/components/Project/ProjectGeneralSettingPanel.vue
+++ b/frontend/src/components/Project/ProjectGeneralSettingPanel.vue
@@ -54,34 +54,10 @@
<span class="text-red-600">*</span>
</div>
<div class="mt-2 textlabel">
- <div class="radio-set-row">
- <label class="radio">
- <input
- v-model="state.tenantMode"
- :disabled="!allowEdit"
- tabindex="-1"
- type="radio"
- class="btn disabled:opacity-50 disabled:cursor-not-allowed"
- :value="TenantMode.TENANT_MODE_DISABLED"
- />
- <span class="label">{{ $t("project.mode.standard") }}</span>
- </label>
- <label class="radio space-x-1">
- <input
- v-model="state.tenantMode"
- :disabled="!allowEdit"
- tabindex="-1"
- type="radio"
- class="btn disabled:opacity-50 disabled:cursor-not-allowed"
- :value="TenantMode.TENANT_MODE_ENABLED"
- />
- <span class="label">{{ $t("project.mode.batch") }}</span>
- <LearnMoreLink
- url="https://www.bytebase.com/docs/change-database/batch-change/?source=console"
- />
- <FeatureBadge feature="bb.feature.multi-tenancy" />
- </label>
- </div>
+ <ProjectModeRadioGroup
+ v-model:value="state.tenantMode"
+ :disabled="!allowEdit"
+ />
</div>
</div>
diff --git a/frontend/src/components/Project/ProjectModeRadioGroup.vue b/frontend/src/components/Project/ProjectModeRadioGroup.vue
new file mode 100644
index 0000000000..fb4569f554
--- /dev/null
+++ b/frontend/src/components/Project/ProjectModeRadioGroup.vue
@@ -0,0 +1,43 @@
+<template>
+ <div class="radio-set-row">
+ <NRadioGroup
+ :disabled="disabled"
+ :value="value"
+ @update:value="$emit('update:value', $event)"
+ >
+ <NRadio :value="TenantMode.TENANT_MODE_DISABLED">
+ {{ $t("project.mode.standard") }}
+ </NRadio>
+ <NRadio :value="TenantMode.TENANT_MODE_ENABLED">
+ <div class="flex space-x-1">
+ <span>
+ {{ $t("project.mode.batch") }}
+ </span>
+ <LearnMoreLink
+ url="https://www.bytebase.com/docs/change-database/batch-change/?source=console"
+ />
+ <FeatureBadge feature="bb.feature.multi-tenancy" />
+ </div>
+ </NRadio>
+ </NRadioGroup>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { NRadio, NRadioGroup } from "naive-ui";
+import { TenantMode } from "@/types/proto/v1/project_service";
+
+withDefaults(
+ defineProps<{
+ value: TenantMode;
+ disabled?: boolean;
+ }>(),
+ {
+ disabled: false,
+ }
+);
+
+defineEmits<{
+ (event: "update:value", value: TenantMode): void;
+}>();
+</script>
diff --git a/frontend/src/components/ProjectVersionControlPanel.vue b/frontend/src/components/ProjectVersionControlPanel.vue
index 9d07c2aad9..2f6fbf9af2 100644
--- a/frontend/src/components/ProjectVersionControlPanel.vue
+++ b/frontend/src/components/ProjectVersionControlPanel.vue
@@ -17,47 +17,27 @@
<div class="text-lg leading-6 font-medium text-main">
{{ $t("workflow.current-workflow") }}
</div>
- <div class="mt-6 flex flex-col space-y-4">
- <div class="flex space-x-4">
- <input
- id="workflow-ui"
- v-model="state.workflowType"
- name="UI workflow"
- tabindex="-1"
- type="radio"
- class="text-accent disabled:text-accent-disabled focus:ring-accent"
- :value="Workflow.UI"
- :disabled="!allowEdit"
- />
- <div class="-mt-1">
- <label for="workflow-ui" class="textlabel">{{
- $t("workflow.ui-workflow")
- }}</label>
- <div class="mt-1 textinfolabel">
- {{ $t("workflow.ui-workflow-description") }}
+ <div class="mt-6">
+ <NRadioGroup
+ v-model:value="state.workflowType"
+ :disabled="!allowEdit"
+ class="flex flex-col space-y-4"
+ >
+ <NRadio
+ v-for="workflow in workflowList"
+ :key="workflow.value"
+ :value="workflow.value"
+ >
+ <div>
+ <span class="textlabel">
+ {{ workflow.title }}
+ </span>
+ <div class="mt-1 textinfolabel">
+ {{ workflow.description }}
+ </div>
</div>
- </div>
- </div>
- <div class="flex space-x-4">
- <input
- id="workflow-gitops"
- v-model="state.workflowType"
- name="GitOps workflow"
- tabindex="-1"
- type="radio"
- class="text-accent disabled:text-accent-disabled focus:ring-accent"
- :value="Workflow.VCS"
- :disabled="!allowEdit"
- />
- <div class="-mt-1">
- <label for="workflow-gitops" class="textlabel">{{
- $t("workflow.gitops-workflow")
- }}</label>
- <div class="mt-1 textinfolabel">
- {{ $t("workflow.gitops-workflow-description") }}
- </div>
- </div>
- </div>
+ </NRadio>
+ </NRadioGroup>
</div>
<template v-if="allowEdit && state.workflowType == Workflow.VCS">
<div class="mt-4 flex items-center justify-end">
@@ -85,6 +65,7 @@
</template>
<script lang="ts" setup>
+import { NRadio, NRadioGroup } from "naive-ui";
import { reactive, watch } from "vue";
import { computed, PropType } from "vue";
import { useI18n } from "vue-i18n";
@@ -120,6 +101,19 @@ const state = reactive<LocalState>({
showWizardForChange: false,
});
+const workflowList = computed(() => [
+ {
+ value: Workflow.UI,
+ title: t("workflow.ui-workflow"),
+ description: t("workflow.ui-workflow-description"),
+ },
+ {
+ value: Workflow.VCS,
+ title: t("workflow.gitops-workflow"),
+ description: t("workflow.gitops-workflow-description"),
+ },
+]);
+
watch(
() => [props.project.name],
async () => {
diff --git a/frontend/src/components/ProjectWebhookForm.vue b/frontend/src/components/ProjectWebhookForm.vue
index 7eecd34aed..4839309396 100644
--- a/frontend/src/components/ProjectWebhookForm.vue
+++ b/frontend/src/components/ProjectWebhookForm.vue
@@ -1,56 +1,61 @@
<template>
<div class="space-y-4">
<div v-if="create">
- <label class="textlabel">
- {{ $t("project.webhook.destination") }}
- </label>
- <div class="mt-1 grid grid-cols-1 gap-4 sm:grid-cols-7">
- <template
- v-for="(item, index) in projectWebhookV1TypeItemList()"
- :key="index"
- >
- <div
- class="flex justify-center px-2 py-4 border border-control-border hover:bg-control-bg-hover cursor-pointer"
- @click.capture="state.webhook.type = item.type"
+ <div>
+ <label for="name" class="textlabel">
+ {{ $t("project.webhook.destination") }}
+ <span class="text-red-600">*</span>
+ </label>
+ </div>
+ <NRadioGroup class="w-full mt-1" :value="state.webhook.type">
+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-7">
+ <template
+ v-for="(item, index) in projectWebhookV1TypeItemList()"
+ :key="index"
>
- <div class="flex flex-col items-center">
- <!-- This awkward code is author couldn't figure out proper way to use dynamic src under vite
+ <div
+ class="flex justify-center px-2 py-4 rounded border border-control-border hover:bg-control-bg-hover cursor-pointer"
+ @click.capture="state.webhook.type = item.type"
+ >
+ <div class="flex flex-col items-center">
+ <!-- This awkward code is author couldn't figure out proper way to use dynamic src under vite
https://github.com/vitejs/vite/issues/1265 -->
- <template v-if="item.type === Webhook_Type.TYPE_SLACK">
- <img class="h-10 w-10" src="../assets/slack-logo.png" alt="" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_DISCORD">
- <img class="h-10 w-10" src="../assets/discord-logo.svg" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_TEAMS">
- <img class="h-10 w-10" src="../assets/teams-logo.svg" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_DINGTALK">
- <img class="h-10 w-10" src="../assets/dingtalk-logo.png" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_FEISHU">
- <img class="h-10 w-10" src="../assets/feishu-logo.webp" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_WECOM">
- <img class="h-10 w-10" src="../assets/wecom-logo.png" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_CUSTOM">
- <heroicons-outline:puzzle class="w-10 h-10" />
- </template>
- <p class="mt-1 text-center textlabel">
- {{ item.name }}
- </p>
- <div class="mt-3 radio text-sm">
- <input
- type="radio"
- class="btn"
- :checked="state.webhook.type == item.type"
- />
+ <template v-if="item.type === Webhook_Type.TYPE_SLACK">
+ <img
+ class="h-10 w-10"
+ src="../assets/slack-logo.png"
+ alt=""
+ />
+ </template>
+ <template v-else-if="item.type === Webhook_Type.TYPE_DISCORD">
+ <img class="h-10 w-10" src="../assets/discord-logo.svg" />
+ </template>
+ <template v-else-if="item.type === Webhook_Type.TYPE_TEAMS">
+ <img class="h-10 w-10" src="../assets/teams-logo.svg" />
+ </template>
+ <template v-else-if="item.type === Webhook_Type.TYPE_DINGTALK">
+ <img class="h-10 w-10" src="../assets/dingtalk-logo.png" />
+ </template>
+ <template v-else-if="item.type === Webhook_Type.TYPE_FEISHU">
+ <img class="h-10 w-10" src="../assets/feishu-logo.webp" />
+ </template>
+ <template v-else-if="item.type === Webhook_Type.TYPE_WECOM">
+ <img class="h-10 w-10" src="../assets/wecom-logo.png" />
+ </template>
+ <template v-else-if="item.type === Webhook_Type.TYPE_CUSTOM">
+ <heroicons-outline:puzzle class="w-10 h-10" />
+ </template>
+ <p class="mt-1 text-center textlabel">
+ {{ item.name }}
+ </p>
+ <div class="mt-3 radio text-sm">
+ <NRadio :value="item.type" />
+ </div>
</div>
</div>
- </div>
- </template>
- </div>
+ </template>
+ </div>
+ </NRadioGroup>
</div>
<div>
<label for="name" class="textlabel">
@@ -279,7 +284,7 @@
<script lang="ts" setup>
import { cloneDeep, isEmpty, isEqual } from "lodash-es";
-import { NCheckbox } from "naive-ui";
+import { NCheckbox, NRadio, NRadioGroup } from "naive-ui";
import { reactive, computed, PropType, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
diff --git a/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue b/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue
index 424a66d806..3b08ae319b 100644
--- a/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue
+++ b/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue
@@ -1,35 +1,20 @@
<template>
<div class="textlabel">
<div class="flex items-center justify-between">
- <div class="radio-set-row">
- <template v-if="project.name !== DEFAULT_PROJECT_V1_NAME">
- <label class="radio">
- <input
- v-model="state.transferSource"
- tabindex="-1"
- type="radio"
- class="btn"
- value="DEFAULT"
- />
- <span class="label">
- {{ $t("quick-action.from-unassigned-databases") }}
- </span>
- </label>
- <label class="radio">
- <input
- v-model="state.transferSource"
- tabindex="-1"
- type="radio"
- class="btn"
- value="OTHER"
- />
- <span class="label">
- {{ $t("quick-action.from-projects") }}
- </span>
- </label>
- </template>
+ <div
+ v-if="project.name !== DEFAULT_PROJECT_V1_NAME"
+ class="radio-set-row"
+ >
+ <NRadioGroup v-model:value="state.transferSource">
+ <NRadio :value="'DEFAULT'">
+ {{ $t("quick-action.from-unassigned-databases") }}
+ </NRadio>
+ <NRadio :value="'OTHER'">
+ {{ $t("quick-action.from-projects") }}
+ </NRadio>
+ </NRadioGroup>
</div>
- <NInputGroup style="width: auto">
+ <NInputGroup style="width: auto; margin-left: auto">
<InstanceSelect
v-if="state.transferSource == 'DEFAULT'"
class="!w-48"
@@ -60,7 +45,7 @@
</template>
<script lang="ts" setup>
-import { NInputGroup } from "naive-ui";
+import { NInputGroup, NRadio, NRadioGroup } from "naive-ui";
import { type PropType, computed, reactive, watch } from "vue";
import { InstanceSelect, ProjectSelect, SearchBox } from "@/components/v2";
import { useInstanceV1Store, useProjectV1Store } from "@/store";
diff --git a/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue b/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue
index 1aea7f784f..ee2ec5b810 100644
--- a/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue
+++ b/frontend/src/components/VCS/VCSProviderBasicInfoPanel.vue
@@ -5,25 +5,21 @@
<span class="text-red-600">*</span>
</div>
<div class="flex flex-wrap pt-4 radio-set-row gap-4">
- <label
- v-for="vcsWithUIType in vcsListByUIType"
- :key="vcsWithUIType.uiType"
- class="radio space-x-2"
- >
- <input
- v-model="config.uiType"
- :name="vcsWithUIType.title"
- tabindex="-1"
- type="radio"
- class="btn"
+ <NRadioGroup v-model:value="config.uiType">
+ <NRadio
+ v-for="vcsWithUIType in vcsListByUIType"
+ :key="vcsWithUIType.uiType"
:value="vcsWithUIType.uiType"
@change="changeUIType()"
- />
- <VCSIcon custom-class="h-6" :type="vcsWithUIType.type" />
- <span class="whitespace-nowrap">
- {{ vcsWithUIType.title }}
- </span>
- </label>
+ >
+ <div class="flex space-x-1">
+ <VCSIcon custom-class="h-6" :type="vcsWithUIType.type" />
+ <span class="whitespace-nowrap">
+ {{ vcsWithUIType.title }}
+ </span>
+ </div>
+ </NRadio>
+ </NRadioGroup>
</div>
<div class="mt-6 pt-6 border-t border-block-border textlabel">
{{ instanceUrlLabel }} <span class="text-red-600">*</span>
@@ -58,6 +54,7 @@
<script lang="ts" setup>
import isEmpty from "lodash-es/isEmpty";
+import { NRadio, NRadioGroup } from "naive-ui";
import { computed, onUnmounted, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { TEXT_VALIDATION_DELAY, VCSConfig } from "@/types";