Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 支持环境变量开启新建租户功能 #1872

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/bk-login/pages/src/views/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ const handleTenantChange = async (id: string) => {
inputTenant.value = null;
return;
}
let selected = allTenantList.value.find(item => item.id === id);
let selected = allTenantList.value.find(item => item.id === id) || inputTenant.value?.find(item => item.id === id);
if (!selected) {
const res = await getTenantList({
tenant_ids: id,
Expand Down Expand Up @@ -441,9 +441,7 @@ const getUserGroupName = (tenant: Tenant) => {
if (userGroupId === tenant.id) {
return '本租户';
}
const list = tenant.collaboration_tenants || [];
const current = list.find(item => item.id === userGroup.value);
return current?.name || '';
return userGroupId
};

/**
Expand Down
4 changes: 3 additions & 1 deletion src/pages/.bk.development.env
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ BK_ENABLE_BK_NOTICE = ''

BK_SHARED_RES_URL = ''

BK_ENABLE_VIRTUAL_USER = ''
BK_ENABLE_VIRTUAL_USER = ''

BK_ENABLE_CREATE_TENANT = ''
2 changes: 2 additions & 0 deletions src/pages/.bk.production.env
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ BK_ENABLE_BK_NOTICE = '{{ ENABLE_BK_NOTICE }}'
BK_SHARED_RES_URL = '{{ BK_SHARED_RES_URL }}'

BK_ENABLE_VIRTUAL_USER = '{{ ENABLE_VIRTUAL_USER }}'

BK_ENABLE_CREATE_TENANT = '{{ ENABLE_CREATE_TENANT }}'
2 changes: 1 addition & 1 deletion src/pages/src/http/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const handleResponse = <T>({

const handleReject = (error: AxiosError, config: Record<string, any>) => {
const { status } = error.response;
const { message, data, code, details } = error.response.data.error;
const { message = '', data = {}, code = '', details = [] } = error.response.data.error;

if (status === 401) {
if (error.config.url === '/api/v1/web/basic/current-user/') {
Expand Down
4 changes: 3 additions & 1 deletion src/pages/src/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -536,5 +536,7 @@
"回调地址为:": "The callback address is: ",
"确认要关闭企业微信登录吗?": "Are you sure you want to disable WeChat Work login?",
"关闭后用户将无法通过企业微信登录": "After deactivation, users will not be able to log in via WeChat Work",
"请将以下回调地址填写到企业微信配置内:": "Please enter the following callback address in the enterprise wechat configuration:"
"请将以下回调地址填写到企业微信配置内:": "Please enter the following callback address in the enterprise wechat configuration:",
"至": "to ",
"成功 ": " Success"
}
4 changes: 3 additions & 1 deletion src/pages/src/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -536,5 +536,7 @@
"回调地址为:": "回调地址为:",
"确认要关闭企业微信登录吗?": "确认要关闭企业微信登录吗?",
"关闭后用户将无法通过企业微信登录": "关闭后用户将无法通过企业微信登录",
"请将以下回调地址填写到企业微信配置内:": "请将以下回调地址填写到企业微信配置内:"
"请将以下回调地址填写到企业微信配置内:": "请将以下回调地址填写到企业微信配置内:",
"至": "至",
"成功 ": "成功"
}
2 changes: 1 addition & 1 deletion src/pages/src/views/organization/details/ViewUser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const dateOptions = computed(() => {
];
const options = expirationTimes.map(({ num, unit, label }) => {
const date = defineDateTime(num, unit);
return { id: `${date} 00:00:00`, name: `${label} (${date})` };
return { id: `${date} 00:00:00`, name: `${label} (${t('至')}${date})` };
});
options.push(
{ id: '2100-1-1T00:00:00', name: t('永久') },
Expand Down
2 changes: 1 addition & 1 deletion src/pages/src/views/setting/data-source/NewDataSource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const handleCollapse = () => {
const successText = ref('新建企业微信数据源成功');
const isSuccess = ref(false);
const updateSuccess = (value: string) => {
successText.value = `${value}${currentPlugins.value[0].name}成功`;
successText.value = `${value}${currentPlugins.value[0].name}${t('成功 ')}`;
isSuccess.value = true;
};

Expand Down
63 changes: 32 additions & 31 deletions src/pages/src/views/tenant/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="main-content">
<div class="content-search">
<div class="content-search-left">
<bk-button class="mr-[24px]" theme="primary" @click="handleClick('add')">
<bk-button v-if="isCreateTenant" class="mr-[24px]" theme="primary" @click="handleClick('add')">
<i class="user-icon icon-add-2 mr8" />
{{ $t('新建租户') }}
</bk-button>
Expand Down Expand Up @@ -203,27 +203,27 @@
<div class="mb-[18px]">
<bk-checkbox v-model="smsValue" @change="changeSms">{{ $t('短信') }}</bk-checkbox>
<PhoneInput
:form-data="adminPasswordData"
:tel-error="telError"
:required="smsValue"
@change-country-code="changeCountryCode"
@change-tel-error="changeTelError" />
:form-data="adminPasswordData"
:tel-error="telError"
:required="smsValue"
@change-country-code="changeCountryCode"
@change-tel-error="changeTelError" />
</div>
<div>
<bk-checkbox v-model="emailValue" @change="changeEmail">{{ $t('邮箱') }}</bk-checkbox>
<div>
<bk-input
:class="{ 'input-error': emailError }"
v-model="adminPasswordData.email"
@blur="emailBlur"
@input="handleInput" />
<p class="error" v-show="emailError">{{ $t('请输入正确的邮箱地址') }}</p>
</div>
<bk-input
:class="{ 'input-error': emailError }"
v-model="adminPasswordData.email"
@blur="emailBlur"
@input="handleInput" />
<p class="error" v-show="emailError">{{ $t('请输入正确的邮箱地址') }}</p>
</div>
</div>
</bk-form-item>
</bk-form>
</bk-dialog>
<!-- 创建租户成功弹窗 -->
<!-- 创建租户成功弹窗 -->
<bk-dialog
class="tenant-success"
v-model:is-show="isShowDialog"
Expand Down Expand Up @@ -288,6 +288,7 @@ import OperationDetails from './OperationDetails.vue';
import ViewDetails from './ViewDetails.vue';

import Empty from '@/components/Empty.vue';
import LabelContent from '@/components/layouts/LabelContent.vue';
import passwordInput from '@/components/passwordInput.vue';
import PhoneInput from '@/components/phoneInput.vue';
import { useAdminPassword, useInfoBoxContent, useTableMaxHeight, useValidate } from '@/hooks';
Expand All @@ -303,16 +304,16 @@ import {
} from '@/http';
import { t } from '@/language/index';
import router from '@/router';
import { useMainViewStore, useUser, platformConfig} from '@/store';
import { LOGO_COLOR, logoConvert, tenantStatus, copy} from '@/utils';
import LabelContent from '@/components/layouts/LabelContent.vue';
import { platformConfig, useMainViewStore, useUser } from '@/store';
import { copy, LOGO_COLOR, logoConvert, tenantStatus } from '@/utils';

const userStore = useUser();
const store = useMainViewStore();
const platformConfigData = platformConfig()
const platformConfigData = platformConfig();
const contact = computed(() => platformConfigData.i18n.footerInfoHTML);
const copyright = computed(() => platformConfigData.footerCopyrightContent);
store.customBreadcrumbs = false;
const isCreateTenant = window.ENABLE_CREATE_TENANT !== 'False';

const validate = useValidate();
const tableMaxHeight = useTableMaxHeight(202);
Expand Down Expand Up @@ -507,21 +508,21 @@ const updateTenantsList = (type: string, formData: any) => {
isCreated.value = type === 'add';
newId.value = formData?.id;
fetchTenantsList();
if(isCreated.value) {
if (isCreated.value) {
Object.assign(dialogData.value, {
...formData,
isShowItem: formData.notification_methods?.length === 0,
emailNotification: formData.notification_methods?.includes('email') ? t('邮箱') : '',
smsNotification: formData.notification_methods?.includes('sms') ? t('短信') : '',
accessUrl: location.origin
})
isShowDialog.value = true
...formData,
isShowItem: formData.notification_methods?.length === 0,
emailNotification: formData.notification_methods?.includes('email') ? t('邮箱') : '',
smsNotification: formData.notification_methods?.includes('sms') ? t('短信') : '',
accessUrl: location.origin,
});
isShowDialog.value = true;
} else {
Message({
theme: 'success',
message: t('租户更新成功'),
});
}
theme: 'success',
message: t('租户更新成功'),
});
}
};

const dialogRef = ref();
Expand All @@ -535,7 +536,7 @@ const getDialogContentText = () => {
const copyContent = () => {
const container = getDialogContentText();
copy(container);
isShowDialog.value = false
isShowDialog.value = false;
};

const handleBeforeClose = async () => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ declare interface Window {
ENABLE_BK_NOTICE: string
BK_SHARED_RES_URL: string
ENABLE_VIRTUAL_USER: string
ENABLE_CREATE_TENANT:string
}
Loading