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: frontend optimize (#11533)
ecmadaodaa0180f450d
diff --git a/backend/api/v1/vcs_connector_service.go b/backend/api/v1/vcs_connector_service.goindex 2e1dc4830f..81752df291 100644--- a/backend/api/v1/vcs_connector_service.go+++ b/backend/api/v1/vcs_connector_service.go@@ -268,7 +268,7 @@ func (s *VCSConnectorService) UpdateVCSConnector(ctx context.Context, request *vreturn nil, status.Errorf(codes.Internal, "failed to find vcs: %s", err.Error())}if vcsProvider == nil {- return nil, status.Errorf(codes.NotFound, "vcs %s not found", vcsConnector.VCSResourceID)+ return nil, status.Errorf(codes.NotFound, "vcs provider %s not found", vcsConnector.VCSResourceID)}user, ok := ctx.Value(common.UserContextKey).(*store.UserMessage)@@ -357,7 +357,7 @@ func (s *VCSConnectorService) DeleteVCSConnector(ctx context.Context, request *vreturn nil, status.Errorf(codes.Internal, "failed to find vcs: %s", err.Error())}if vcsProvider == nil {- return nil, status.Errorf(codes.NotFound, "vcs %d not found", vcsConnector.UID)+ return nil, status.Errorf(codes.NotFound, "vcs provider %d not found", vcsConnector.UID)}if err := s.store.DeleteVCSConnector(ctx, project.ResourceID, vcsConnectorID); err != nil {diff --git a/backend/api/v1/vcs_provider_service.go b/backend/api/v1/vcs_provider_service.goindex 6f8c2f5c08..c635e87300 100644--- a/backend/api/v1/vcs_provider_service.go+++ b/backend/api/v1/vcs_provider_service.go@@ -196,7 +196,7 @@ func (s *VCSProviderService) getVCS(ctx context.Context, name string) (*store.VCreturn nil, status.Errorf(codes.Internal, "Failed to retrieve vcs provider: %v", err)}if vcsProvider == nil {- return nil, status.Errorf(codes.NotFound, "vcs provider not found: %v", err)+ return nil, status.Errorf(codes.NotFound, "vcs provider %s not found", name)}return vcsProvider, nil}diff --git a/frontend/src/components/IssueV1/components/Sidebar/VCSInfo.vue b/frontend/src/components/IssueV1/components/Sidebar/VCSInfo.vueindex 7fdda258ea..84bd9dbf48 100644--- a/frontend/src/components/IssueV1/components/Sidebar/VCSInfo.vue+++ b/frontend/src/components/IssueV1/components/Sidebar/VCSInfo.vue@@ -47,28 +47,38 @@ const currentUser = useCurrentUserV1();const vcsConnectorStore = useVCSConnectorStore();const vcsProviderStore = useVCSProviderStore();+const hasGetVCSConnectorPermission = computed(() =>+ hasProjectPermissionV2(+ issue.value.projectEntity,+ currentUser.value,+ "bb.vcsConnectors.get"+ )+);++const hasGetVCSProviderPermission = computed(() =>+ hasWorkspacePermissionV2(currentUser.value, "bb.vcsProviders.get")+);+watchEffect(async () => {if (!issue.value.planEntity?.vcsSource?.vcsConnector) {return;}- const connector = await vcsConnectorStore.getOrFetchConnectorByName(- issue.value.planEntity?.vcsSource?.vcsConnector- );- await vcsProviderStore.getOrFetchVCSByName(connector.vcsProvider);+ if (hasGetVCSConnectorPermission.value) {+ const connector = await vcsConnectorStore.getOrFetchConnectorByName(+ issue.value.planEntity?.vcsSource?.vcsConnector+ );+ if (hasGetVCSProviderPermission.value) {+ await vcsProviderStore.getOrFetchVCSByName(connector.vcsProvider);+ }+ }});const vcsConnector = computed(() => {if (!issue.value.planEntity?.vcsSource?.vcsConnector) {return;}- if (- !hasProjectPermissionV2(- issue.value.projectEntity,- currentUser.value,- "bb.vcsConnectors.get"- )- ) {+ if (!hasGetVCSConnectorPermission.value) {return;}return vcsConnectorStore.getConnectorByName(@@ -80,9 +90,7 @@ const vcsProvider = computed(() => {if (!vcsConnector.value) {return;}- if (- !hasWorkspacePermissionV2(currentUser.value, "bb.identityProviders.get")- ) {+ if (!hasGetVCSProviderPermission.value) {return;}return vcsProviderStore.getVCSByName(vcsConnector.value.vcsProvider);diff --git a/frontend/src/components/IdentityProviderCreateForm.vue b/frontend/src/components/SSO/IdentityProviderCreateForm.vuesimilarity index 91%rename from frontend/src/components/IdentityProviderCreateForm.vuerename to frontend/src/components/SSO/IdentityProviderCreateForm.vueindex f61673874a..11386bd91d 100644--- a/frontend/src/components/IdentityProviderCreateForm.vue+++ b/frontend/src/components/SSO/IdentityProviderCreateForm.vue@@ -31,7 +31,11 @@</div><BBAttention- v-if="!externalUrl && redirectUrl"+ v-if="+ !externalUrl &&+ (state.type === IdentityProviderType.OAUTH2 ||+ state.type === IdentityProviderType.OIDC)+ "class="mt-4 w-full border-none"type="error":title="$t('banner.external-url')"@@ -130,35 +134,7 @@}}</p></div>- <div- v-if="isCreating"- class="w-auto max-w-full p-4 rounded flex flex-col justify-start items-start border"- >- <p class="textinfolabel flex flex-row justify-start items-center mb-2">- {{ $t("settings.sso.form.identity-provider-needed-information") }}- <ShowMoreIcon- class="ml-1 mr-2"- :content="$t('settings.sso.form.redirect-url-description')"- />- </p>- <div class="w-128 flex flex-row justify-start items-center space-x-4">- <p class="textlabel my-auto text-right whitespace-nowrap">- {{ $t("settings.sso.form.redirect-url") }}- </p>- <div class="w-full relative break-all pr-8 text-sm">- <div class="bg-gray-100 p-1 border border-gray-300 rounded">- {{ redirectUrl }}- </div>- <button- tabindex="-1"- class="absolute right-0 top-1/2 -translate-y-1/2 p-1 text-control-light rounded hover:bg-gray-100"- @click.prevent="copyRedirectUrl"- >- <heroicons-outline:clipboard class="w-5 h-5" />- </button>- </div>- </div>- </div>+ <IdentityProviderExternalURL v-if="isCreating" :type="state.type" /><div class="w-full flex flex-col justify-start items-start"><p class="textlabel">Client ID@@ -300,35 +276,7 @@}}</p></div>- <div- v-if="isCreating"- class="w-auto max-w-full p-4 rounded flex flex-col justify-start items-start border"- >- <p class="textinfolabel flex flex-row justify-start items-center mb-2">- {{ $t("settings.sso.form.identity-provider-needed-information") }}- <ShowMoreIcon- class="ml-1 mr-2"- :content="$t('settings.sso.form.redirect-url-description')"- />- </p>- <div class="w-128 flex flex-row justify-start items-center space-x-4">- <p class="textlabel my-auto text-right whitespace-nowrap">- {{ $t("settings.sso.form.redirect-url") }}- </p>- <div class="w-full relative break-all pr-8 text-sm">- <div class="bg-gray-100 p-1 border border-gray-300 rounded">- {{ redirectUrl }}- </div>- <button- tabindex="-1"- class="absolute right-0 top-1/2 -translate-y-1/2 p-1 text-control-light rounded hover:bg-gray-100"- @click.prevent="copyRedirectUrl"- >- <heroicons-outline:clipboard class="w-5 h-5" />- </button>- </div>- </div>- </div>+ <IdentityProviderExternalURL v-if="isCreating" :type="state.type" /><div class="w-full flex flex-col justify-start items-start"><p class="textlabel">Issuer@@ -651,10 +599,7 @@</NButton></template><template v-else>- <NButton- :disabled="!allowUpdate"- @click="handleDiscardChangesButtonClick"- >+ <NButton v-if="allowUpdate" @click="handleDiscardChangesButtonClick">{{ $t("common.discard-changes") }}</NButton><NButton@@ -720,7 +665,6 @@ import {identityProviderTemplateList,identityProviderTypeToString,openWindowForSSO,- toClipboard,} from "@/utils";import { getErrorCode } from "@/utils/grpcweb";@@ -786,18 +730,6 @@ const externalUrl = computed(() => useActuatorV1Store().serverInfo?.externalUrl ?? "");-const redirectUrl = computed(() => {- const url = externalUrl.value || window.origin;- switch (state.type) {- case IdentityProviderType.OAUTH2:- return `${url}/oauth/callback`;- case IdentityProviderType.OIDC:- return `${url}/oidc/callback`;- default:- return "";- }-});-const isCreating = computed(() => {return currentIdentityProvider.value === undefined;});@@ -1001,16 +933,6 @@ const loginWithIdentityProviderEventListener = async (event: Event) => {});};-const copyRedirectUrl = () => {- toClipboard(redirectUrl.value).then(() => {- pushNotification({- module: "bytebase",- style: "INFO",- title: t("settings.sso.copy-redirect-url"),- });- });-};-const validateResourceId = async (resourceId: ResourceId): Promise<ValidatedMessage[]> => {diff --git a/frontend/src/components/SSO/IdentityProviderExternalURL.vue b/frontend/src/components/SSO/IdentityProviderExternalURL.vuenew file mode 100644index 0000000000..2af2f53b03--- /dev/null+++ b/frontend/src/components/SSO/IdentityProviderExternalURL.vue@@ -0,0 +1,70 @@+<template>+ <div+ class="w-auto max-w-full p-4 rounded flex flex-col justify-start items-start border"+ >+ <p class="textinfolabel flex flex-row justify-start items-center mb-2">+ {{ $t("settings.sso.form.identity-provider-needed-information") }}+ <ShowMoreIcon+ class="ml-1 mr-2"+ :content="$t('settings.sso.form.redirect-url-description')"+ />+ </p>+ <div class="flex flex-row justify-start items-center space-x-4">+ <p class="textlabel my-auto text-right whitespace-nowrap">+ {{ $t("settings.sso.form.redirect-url") }}+ </p>+ <div class="w-full relative break-all pr-8 text-sm">+ <div class="bg-gray-100 p-1 border border-gray-300 rounded">+ {{ redirectUrl }}+ </div>+ <button+ tabindex="-1"+ class="absolute right-0 top-1/2 -translate-y-1/2 p-1 text-control-light rounded hover:bg-gray-100"+ @click.prevent="copyRedirectUrl"+ >+ <heroicons-outline:clipboard class="w-5 h-5" />+ </button>+ </div>+ </div>+ </div>+</template>++<script setup lang="ts">+import { computed } from "vue";+import { useI18n } from "vue-i18n";+import { pushNotification, useActuatorV1Store } from "@/store";+import { IdentityProviderType } from "@/types/proto/v1/idp_service";+import { toClipboard } from "@/utils";++const props = defineProps<{+ type: IdentityProviderType;+}>();++const { t } = useI18n();++const externalUrl = computed(+ () => useActuatorV1Store().serverInfo?.externalUrl ?? ""+);++const redirectUrl = computed(() => {+ const url = externalUrl.value || window.origin;+ switch (props.type) {+ case IdentityProviderType.OAUTH2:+ return `${url}/oauth/callback`;+ case IdentityProviderType.OIDC:+ return `${url}/oidc/callback`;+ default:+ return "";+ }+});++const copyRedirectUrl = () => {+ toClipboard(redirectUrl.value).then(() => {+ pushNotification({+ module: "bytebase",+ style: "INFO",+ title: t("settings.sso.copy-redirect-url"),+ });+ });+};+</script>diff --git a/frontend/src/components/IdentityProviderTable.vue b/frontend/src/components/SSO/IdentityProviderTable.vuesimilarity index 100%rename from frontend/src/components/IdentityProviderTable.vuerename to frontend/src/components/SSO/IdentityProviderTable.vuediff --git a/frontend/src/components/VCS/VCSSetupWizard.vue b/frontend/src/components/VCS/VCSSetupWizard.vueindex 4ac23a255f..600eb225e0 100644--- a/frontend/src/components/VCS/VCSSetupWizard.vue+++ b/frontend/src/components/VCS/VCSSetupWizard.vue@@ -30,7 +30,6 @@ import type { VCSConfig } from "@/types";import { VCSType } from "@/types/proto/v1/common";import type { VCSProvider } from "@/types/proto/v1/vcs_provider_service";import { hasWorkspacePermissionV2 } from "@/utils";-import VCSProviderBasicInfoPanel from "./VCSProviderBasicInfoPanel.vue";withDefaults(defineProps<{diff --git a/frontend/src/store/modules/v1/vcs_provider.ts b/frontend/src/store/modules/v1/vcs_provider.tsindex fd96ea2e7d..09c17301ef 100644--- a/frontend/src/store/modules/v1/vcs_provider.ts+++ b/frontend/src/store/modules/v1/vcs_provider.ts@@ -62,9 +62,7 @@ export const useVCSProviderStore = defineStore("vcs_provider", () => {return entity;}- const vcs = await vcsProviderServiceClient.getVCSProvider({- name,- });+ const vcs = await fetchVCSByName(name);cacheByName.setEntity([vcs.name], vcs);return vcs;};diff --git a/frontend/src/views/Archive.vue b/frontend/src/views/Archive.vueindex 6260ca4e19..f2e9ee37c2 100644--- a/frontend/src/views/Archive.vue+++ b/frontend/src/views/Archive.vue@@ -36,7 +36,7 @@<script lang="ts" setup>import { computed, reactive, watchEffect } from "vue";import { useI18n } from "vue-i18n";-import IdentityProviderTable from "@/components/IdentityProviderTable.vue";+import IdentityProviderTable from "@/components/SSO/IdentityProviderTable.vue";import {EnvironmentV1Table,InstanceV1Table,diff --git a/frontend/src/views/SettingWorkspaceMailDelivery.vue b/frontend/src/views/SettingWorkspaceMailDelivery.vueindex 5221f42e4d..fcd214c4bd 100644--- a/frontend/src/views/SettingWorkspaceMailDelivery.vue+++ b/frontend/src/views/SettingWorkspaceMailDelivery.vue@@ -160,7 +160,16 @@</div></div></div>- <div class="flex border-t pt-4 flex-row w-full justify-end">+ <div class="flex border-t pt-4 flex-row w-full justify-end space-x-3">+ <NButton+ v-if="+ !isCreating &&+ !isEqual(state.mailDeliverySetting, state.originMailDeliverySetting)+ "+ @click="discardChanges"+ >+ {{ $t("common.discard-changes") }}+ </NButton><NButtontype="primary":disabled="!allowMailDeliveryActionButton || state.isSendLoading"@@ -175,7 +184,7 @@</template><script lang="ts" setup>-import { cloneDeep } from "lodash-es";+import { cloneDeep, isEqual } from "lodash-es";import type { SelectOption } from "naive-ui";import { NCheckbox } from "naive-ui";import type { ClientError } from "nice-grpc-web";@@ -232,6 +241,14 @@ const isCreating = computed(() => state.originMailDeliverySetting === undefined);+const discardChanges = () => {+ const setting = store.mailDeliverySetting;+ state.originMailDeliverySetting = cloneDeep(setting);+ if (state.originMailDeliverySetting) {+ state.mailDeliverySetting = cloneDeep(state.originMailDeliverySetting!);+ }+};+const mailDeliverySettingButtonText = computed(() => {return isCreating.value ? t("common.create") : t("common.update");});@@ -265,11 +282,7 @@ const allowMailDeliveryActionButton = computed(() => {onMounted(async () => {await store.fetchMailDeliverySetting();- const setting = store.mailDeliverySetting;- state.originMailDeliverySetting = cloneDeep(setting);- if (state.originMailDeliverySetting) {- state.mailDeliverySetting = cloneDeep(state.originMailDeliverySetting!);- }+ discardChanges();});const updateMailDeliverySetting = async () => {diff --git a/frontend/src/views/SettingWorkspaceSSODetail.vue b/frontend/src/views/SettingWorkspaceSSODetail.vueindex 5f66138e3f..0937c01b7c 100644--- a/frontend/src/views/SettingWorkspaceSSODetail.vue+++ b/frontend/src/views/SettingWorkspaceSSODetail.vue@@ -34,7 +34,7 @@<script lang="ts" setup>import { computed, reactive, ref, watchEffect } from "vue";-import IdentityProviderCreateForm from "@/components/IdentityProviderCreateForm.vue";+import IdentityProviderCreateForm from "@/components/SSO/IdentityProviderCreateForm.vue";import { useIdentityProviderStore } from "@/store/modules/idp";import { ssoNamePrefix } from "@/store/modules/v1/common";import { State } from "@/types/proto/v1/common";diff --git a/frontend/src/views/SettingWorkspaceVCS.vue b/frontend/src/views/SettingWorkspaceVCS.vueindex ff0495107a..136ab4cfe9 100644--- a/frontend/src/views/SettingWorkspaceVCS.vue+++ b/frontend/src/views/SettingWorkspaceVCS.vue@@ -15,7 +15,7 @@</div><NDataTable- v-if="vcsList.length > 0"+ v-if="vcsList.length > 0 || loading":data="vcsList":columns="columnList":striped="true"@@ -28,7 +28,7 @@<script lang="ts" setup>import { NButton, NDataTable } from "naive-ui";import type { DataTableColumn } from "naive-ui";-import { computed, watchEffect, h } from "vue";+import { computed, watchEffect, h, ref } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import VCSIcon from "@/components/VCS/VCSIcon.vue";@@ -46,13 +46,15 @@ const currentUser = useCurrentUserV1();const vcsV1Store = useVCSProviderStore();const router = useRouter();const { t } = useI18n();+const loading = ref<boolean>(true);const hasCreateVCSPermission = computed(() => {return hasWorkspacePermissionV2(currentUser.value, "bb.vcsProviders.create");});-const prepareVCSList = () => {- vcsV1Store.getOrFetchVCSList();+const prepareVCSList = async () => {+ await vcsV1Store.getOrFetchVCSList();+ loading.value = false;};watchEffect(prepareVCSList);@@ -74,7 +76,7 @@ const columnList = computed((): DataTableColumn<VCSProvider>[] => {title: t("common.name"),render: (vcs) =>h("div", { class: "flex items-center gap-x-2" }, [- h(VCSIcon, { type: vcs.type, customClass: "h-6" }),+ h(VCSIcon, { type: vcs.type, customClass: "h-5" }),vcs.title,]),},diff --git a/frontend/src/views/project/ProjectVersionControlPanel.vue b/frontend/src/views/project/ProjectVersionControlPanel.vueindex 17cc45d6f5..46398fb849 100644--- a/frontend/src/views/project/ProjectVersionControlPanel.vue+++ b/frontend/src/views/project/ProjectVersionControlPanel.vue@@ -90,7 +90,7 @@ const columnList = computed((): DataTableColumn<VCSConnector>[] => {return h("div", { class: "flex items-center gap-x-2" }, [h(VCSIcon, {type: vcs?.type ?? VCSType.VCS_TYPE_UNSPECIFIED,- customClass: "h-4",+ customClass: "h-5",}),vcs?.title ?? "",]);