Skip to content

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

chore: add copy button to redirect url input (#4532)

boojackc38542e6fd00
diff --git a/frontend/src/components/IdentityProviderCreateForm.vue b/frontend/src/components/IdentityProviderCreateForm.vue
index 62efa9853f..11e90664c8 100644
--- a/frontend/src/components/IdentityProviderCreateForm.vue
+++ b/frontend/src/components/IdentityProviderCreateForm.vue
@@ -35,14 +35,23 @@
>
<template v-if="isCreating">
<p class="textinfolabel !mt-4">
- {{ $t("settings.sso.form.callback-url") }}
+ {{ $t("settings.sso.form.redirect-url") }}
</p>
- <input
- type="text"
- class="textfield mt-1 w-full"
- readonly
- :value="callbackUrl"
- />
+ <div class="w-full relative mt-1">
+ <input
+ type="text"
+ class="textfield w-full"
+ readonly
+ :value="redirectUrl"
+ />
+ <button
+ tabindex="-1"
+ class="absolute right-0 top-1/2 -translate-y-1/2 mr-2 p-1 text-control-light rounded hover:bg-gray-100"
+ @click.prevent="copyRedirectUrl"
+ >
+ <heroicons-outline:clipboard class="w-5 h-5" />
+ </button>
+ </div>
<p class="textinfolabel !mt-4">
{{ $t("settings.sso.form.use-template") }}
</p>
@@ -106,7 +115,7 @@
{{ $t("settings.sso.form.identity-provider-information") }}
</p>
<ShowMoreIcon
- class="inline-block ml-1 textinfolabel"
+ class="inline-block ml-1"
:content="
$t('settings.sso.form.identity-provider-information-description')
"
@@ -212,7 +221,7 @@
{{ $t("settings.sso.form.user-information-mapping") }}
</p>
<ShowMoreIcon
- class="inline-block ml-1 textinfolabel"
+ class="inline-block ml-1"
:content="
$t('settings.sso.form.user-information-mapping-description')
"
@@ -402,6 +411,8 @@
<script lang="ts" setup>
import { cloneDeep, isEqual } from "lodash-es";
import { ClientError } from "nice-grpc-common";
+import { toClipboard } from "@soerenmartius/vue3-clipboard";
+import { useI18n } from "vue-i18n";
import {
computed,
reactive,
@@ -428,9 +439,9 @@ import {
isDev,
openWindowForSSO,
} from "@/utils";
-import ShowMoreIcon from "./ShowMoreIcon.vue";
import { OAuthWindowEventPayload } from "@/types";
import { identityProviderClient } from "@/grpcweb";
+import ShowMoreIcon from "./ShowMoreIcon.vue";
interface LocalState {
type: IdentityProviderType;
@@ -446,6 +457,7 @@ const emit = defineEmits<{
(e: "confirm", identityProvider: IdentityProvider): void;
}>();
+const { t } = useI18n();
const identityProviderStore = useIdentityProviderStore();
const state = reactive<LocalState>({
type: IdentityProviderType.OAUTH2,
@@ -474,7 +486,7 @@ const identityProviderTypeList = computed(() => {
return list;
});
-const callbackUrl = computed(() => {
+const redirectUrl = computed(() => {
return `${
useActuatorStore().serverInfo?.externalUrl || window.origin
}/oauth/callback`;
@@ -652,6 +664,16 @@ const loginWithIdentityProviderEventListener = async (event: Event) => {
});
};
+const copyRedirectUrl = () => {
+ toClipboard(redirectUrl.value).then(() => {
+ pushNotification({
+ module: "bytebase",
+ style: "INFO",
+ title: t("settings.sso.copy-redirect-url"),
+ });
+ });
+};
+
const testConnection = () => {
if (state.type === IdentityProviderType.OAUTH2) {
openWindowForSSO(editedIdentityProvider.value);
diff --git a/frontend/src/components/ShowMoreIcon.vue b/frontend/src/components/ShowMoreIcon.vue
index 087b14f788..93bc26c828 100644
--- a/frontend/src/components/ShowMoreIcon.vue
+++ b/frontend/src/components/ShowMoreIcon.vue
@@ -1,25 +1,19 @@
<template>
- <div class="tooltip-wrapper">
- <span
- v-if="content !== ''"
- class="tooltip whitespace-nowrap"
- :class="`tooltip-${position}`"
- >
- {{ content }}
- </span>
- <heroicons-outline:question-mark-circle class="w-5 h-5" />
- </div>
+ <n-tooltip trigger="hover">
+ <template #trigger>
+ <heroicons-outline:question-mark-circle class="w-5 h-5" />
+ </template>
+ {{ content }}
+ </n-tooltip>
</template>
<script lang="ts" setup>
withDefaults(
defineProps<{
content: string;
- position?: string;
}>(),
{
content: "",
- position: "top",
}
);
</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 136dbdc4de..29199fa278 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -406,7 +406,7 @@
"description": "Single sign-on (SSO) is an authentication method that enables users to sign in to multiple applications and websites with a single set of credentials.",
"deletion": "Delete this SSO",
"form": {
- "callback-url": "Authorization callback url",
+ "redirect-url": "Authorization redirect url",
"use-template": "Use template",
"select-template": "Select template",
"type": "Type",
@@ -428,7 +428,8 @@
"user-information-mapping-description": "Field mapping saves the field names from user info API.",
"identifier": "Identifier",
"display-name": "Display name"
- }
+ },
+ "copy-redirect-url": "Redirect URL copied to clipboard. Paste to the corresponding field on the OAuth application form."
},
"general": {
"workspace": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index da46c8e10b..cddd5cd04a 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -406,7 +406,7 @@
"description": "单点登录(SSO)是一种认证方法,使用户能够通过其他应用程序和网站来进行登录。",
"deletion": "删除这个 SSO",
"form": {
- "callback-url": "回调地址",
+ "redirect-url": "回调地址",
"use-template": "使用模版",
"select-template": "选择模版",
"type": "类型",
@@ -428,7 +428,8 @@
"user-information-mapping-description": "字段映射保存了来自 API 用户信息的字段名。",
"identifier": "唯一标识符",
"display-name": "昵称"
- }
+ },
+ "copy-redirect-url": "Redirect URL 已复制到剪切板,请粘贴至 OAuth 应用的对应字段内。"
},
"general": {
"workspace": {