Skip to content

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

chore: update email input with workspace domain (#12474)

boojack3fcae4805553
diff --git a/frontend/src/components/EmailInput.vue b/frontend/src/components/EmailInput.vue
new file mode 100644
index 0000000000..5b35d299fc
--- /dev/null
+++ b/frontend/src/components/EmailInput.vue
@@ -0,0 +1,59 @@
+<template>
+ <NInputGroup v-if="showDomainLabel">
+ <NInput v-model:value="state.shortValue" :readonly="readonly" />
+ <NInputGroupLabel> @{{ domain }} </NInputGroupLabel>
+ </NInputGroup>
+ <NInput v-else v-model:value="state.value" :readonly="readonly" />
+</template>
+
+<script lang="ts" setup>
+import { NInput, NInputGroup, NInputGroupLabel } from "naive-ui";
+import { reactive, watch, ref, onMounted } from "vue";
+
+interface LocalState {
+ // The full email value.
+ value: string;
+ // The short value without the domain.
+ shortValue: string;
+}
+
+const props = withDefaults(
+ defineProps<{
+ domain?: string;
+ value?: string;
+ readonly?: boolean;
+ }>(),
+ {
+ domain: undefined,
+ value: "",
+ readonly: false,
+ }
+);
+
+const emit = defineEmits<{
+ (event: "update:value", value: string): void;
+}>();
+
+const state: LocalState = reactive({
+ value: props.value,
+ shortValue: props.value.split("@")[0],
+});
+const showDomainLabel = ref(false);
+
+onMounted(() => {
+ if (props.domain) {
+ if (!props.value || props.value.endsWith(`@${props.domain}`)) {
+ showDomainLabel.value = true;
+ }
+ }
+});
+
+watch([() => state.value, () => state.shortValue], () => {
+ const email = showDomainLabel.value
+ ? state.shortValue
+ ? `${state.shortValue}@${props.domain}`
+ : ""
+ : state.value;
+ emit("update:value", email);
+});
+</script>
diff --git a/frontend/src/components/GeneralSetting/BrandingSetting.vue b/frontend/src/components/GeneralSetting/BrandingSetting.vue
index 21d018403d..ea3167b136 100644
--- a/frontend/src/components/GeneralSetting/BrandingSetting.vue
+++ b/frontend/src/components/GeneralSetting/BrandingSetting.vue
@@ -24,8 +24,9 @@
<div class="mb-4 flex space-x-2">
<NInput
ref="workspaceIdField"
- :value="workspaceId"
class="mb-4 w-full"
+ readonly
+ :value="workspaceId"
@click="selectWorkspaceId"
/>
<NButton
diff --git a/frontend/src/components/User/Settings/CreateGroupDrawer.vue b/frontend/src/components/User/Settings/CreateGroupDrawer.vue
index 85fdda0379..c36fddf5f2 100644
--- a/frontend/src/components/User/Settings/CreateGroupDrawer.vue
+++ b/frontend/src/components/User/Settings/CreateGroupDrawer.vue
@@ -20,10 +20,10 @@
{{ $t("settings.members.groups.form.email-tips") }}
</span>
</div>
- <NInput
+ <EmailInput
v-model:value="state.group.email"
- :disabled="!isCreating || !allowEdit"
- placeholder="The unique email"
+ :readonly="!isCreating"
+ :domain="workspaceDomain"
/>
</div>
<div class="flex flex-col gap-y-2">
@@ -131,17 +131,19 @@
</template>
<script lang="ts" setup>
-import { cloneDeep, isEqual } from "lodash-es";
+import { cloneDeep, head, isEqual } from "lodash-es";
import { Trash2Icon } from "lucide-vue-next";
import { NButton, NInput, NTooltip } from "naive-ui";
import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
+import EmailInput from "@/components/EmailInput.vue";
import {
extractGroupEmail,
useUserGroupStore,
useCurrentUserV1,
pushNotification,
useUserStore,
+ useSettingV1Store,
} from "@/store";
import { userNamePrefix, userGroupNamePrefix } from "@/store/modules/v1/common";
import { getUserEmailFromIdentifier } from "@/store/modules/v1/common";
@@ -176,6 +178,7 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
+const settingV1Store = useSettingV1Store();
const userStore = useUserStore();
const groupStore = useUserGroupStore();
const currentUserV1 = useCurrentUserV1();
@@ -199,6 +202,10 @@ const state = reactive<LocalState>({
const isCreating = computed(() => !props.group);
+const workspaceDomain = computed(() =>
+ head(settingV1Store.workspaceProfileSetting?.domains)
+);
+
const selfMemberInGroup = computed(() => {
return props.group?.members.find(
(member) =>
diff --git a/frontend/src/components/User/Settings/CreateUserDrawer.vue b/frontend/src/components/User/Settings/CreateUserDrawer.vue
index ddd5c0059f..852549c9b5 100644
--- a/frontend/src/components/User/Settings/CreateUserDrawer.vue
+++ b/frontend/src/components/User/Settings/CreateUserDrawer.vue
@@ -59,11 +59,10 @@
{{ serviceAccountEmailSuffix }}
</span>
</div>
- <NInput
+ <EmailInput
v-else
v-model:value="state.user.email"
- :input-props="{ type: 'email', autocomplete: 'new-password' }"
- placeholder="[email protected]"
+ :domain="workspaceDomain"
/>
</NFormItem>
<NFormItem :label="$t('settings.members.table.roles')" required>
@@ -173,7 +172,7 @@
</template>
<script lang="ts" setup>
-import { cloneDeep, isEmpty } from "lodash-es";
+import { cloneDeep, head, isEmpty } from "lodash-es";
import { ArchiveIcon } from "lucide-vue-next";
import type { SelectGroupOption, SelectOption } from "naive-ui";
import {
@@ -188,10 +187,12 @@ import {
} from "naive-ui";
import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
+import EmailInput from "@/components/EmailInput.vue";
import {
getUpdateMaskFromUsers,
pushNotification,
useRoleStore,
+ useSettingV1Store,
useUserStore,
} from "@/store";
import {
@@ -223,6 +224,7 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
+const settingV1Store = useSettingV1Store();
const userStore = useUserStore();
const state = reactive<LocalState>({
isRequesting: false,
@@ -278,6 +280,13 @@ const hasWorkspaceRole = computed(() => {
return state.user.roles.some((role) => PRESET_WORKSPACE_ROLES.includes(role));
});
+const workspaceDomain = computed(() => {
+ if (!settingV1Store.workspaceProfileSetting?.enforceIdentityDomain) {
+ return undefined;
+ }
+ return head(settingV1Store.workspaceProfileSetting?.domains);
+});
+
const isCreating = computed(() => !props.user);
const passwordMismatch = computed(() => {