Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
chore: user provider advanced options
Browse files Browse the repository at this point in the history
  • Loading branch information
hibig committed Apr 20, 2024
1 parent bad3ff4 commit 5919bf5
Show file tree
Hide file tree
Showing 18 changed files with 128 additions and 20 deletions.
1 change: 1 addition & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare module 'vue' {
ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb'];
ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem'];
AButton: typeof import('@arco-design/web-vue')['Button'];
AButtton: typeof import('@arco-design/web-vue')['Buttton'];
ACard: typeof import('@arco-design/web-vue')['Card'];
ACascader: typeof import('@arco-design/web-vue')['Cascader'];
ACheckbox: typeof import('@arco-design/web-vue')['Checkbox'];
Expand Down
3 changes: 2 additions & 1 deletion src/locale/en-US/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,6 @@ export default {
'common.code.hide.tips': '... Hide {rows} lines, click to expand ...',
'common.nodata.created': 'No {type} has been created yet',
'common.nodata.added': 'No {type} has been added yet',
'common.status.edited': 'Edited'
'common.status.edited': 'Edited',
'common.table.user': '用户'
};
1 change: 1 addition & 0 deletions src/locale/en-US/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default {
'10 gradient colors generated according to the theme color',
'settings.user.nickName': 'Nickname',
'settings.user.email': 'Email',
'settings.user.group': 'Group',
'settings.user.avatar': 'Avatar',
'settings.user.setting': 'User Settings'
};
3 changes: 2 additions & 1 deletion src/locale/zh-CN/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,6 @@ export default {
'common.code.hide.tips': '... 隐藏 {rows} 行,点击展开 ...',
'common.nodata.created': '尚未创建{type}',
'common.nodata.added': '尚未添加{type}',
'common.status.edited': '已编辑'
'common.status.edited': '已编辑',
'common.table.user': '用户'
};
1 change: 1 addition & 0 deletions src/locale/zh-CN/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default {
'根据主题颜色生成的 10 个梯度色(将配置复制到项目中,主题色才能对亮色 / 暗黑模式同时生效)',
'settings.user.nickName': '昵称',
'settings.user.email': '邮箱',
'settings.user.group': '分组',
'settings.user.avatar': '头像',
'settings.user.setting': '用户设置'
};
2 changes: 1 addition & 1 deletion src/views/exception/403/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<a-result
class="result"
status="403"
:subtitle="$t('exception.result.403.description')"
:subtitle="route.err || $t('exception.result.403.description')"
/>
<div class="operation-row">
<a-button key="back" type="primary" @click="handleBack">
Expand Down
2 changes: 1 addition & 1 deletion src/views/exception/404/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<a-result
class="result"
status="404"
:subtitle="$t('exception.result.404.description')"
:subtitle="route.err || $t('exception.result.404.description')"
>
</a-result>
<div class="operation-row">
Expand Down
4 changes: 2 additions & 2 deletions src/views/exception/500/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<a-result
class="result"
status="500"
:subtitle="$t('exception.result.500.description')"
:subtitle="route.err || $t('exception.result.500.description')"
/>
<a-button key="back" type="primary" @click="handleBack">
{{ $t('exception.result.500.back') }}
Expand All @@ -18,7 +18,7 @@
import useCallCommon from '@/hooks/use-call-common';
const { router, route } = useCallCommon();
console.log('router-------', route.query);
const handleBack = () => {
if (route.query.back) {
router.replace({ name: route.query.back as string });
Expand Down
3 changes: 2 additions & 1 deletion src/views/exception/redirect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
const { router } = useCallCommon();
const redirectPage = () => {
const query = router.currentRoute.value;
const { code, ...othersQuery } = router.currentRoute.value.params;
const { code, ...othersQuery } = query;
const toPage = code ? `Page${code}` : 'Page500';
console.log('query========', query, othersQuery, code);
router.replace({
name: toPage,
query: {
Expand Down
2 changes: 1 addition & 1 deletion src/views/login/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface LoginData {
}

interface SetPassword {
oldPassword: string;
originalPassword: string;
password: string;
name?: string;
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/login/components/modify-password.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
const userStore = useUserStore();
const emits = defineEmits(['updatePassword']);
const props = defineProps({
oldPassword: {
originalPassword: {
type: String,
default() {
return '';
Expand All @@ -152,7 +152,7 @@
}
});
const formData = reactive({
'oldPassword': props.oldPassword,
'originalPassword': props.originalPassword,
'newPassword': '',
'confirmPassword': '',
'serve-url': window.location.origin,
Expand Down Expand Up @@ -193,7 +193,7 @@
const handleSubmit = async ({ errors }) => {
if (!errors) {
const data = {
oldPassword: props.oldPassword,
originalPassword: props.originalPassword,
password: formData.newPassword,
name: props.userName
};
Expand Down
2 changes: 1 addition & 1 deletion src/views/login/components/password-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<!-- modify password box -->
<modifyPassword
v-show="showModify"
:old-password="userInfo.password || tempPassword"
:original-password="userInfo.password || tempPassword"
:user-name="userInfo.username"
:settings-info="settingsInfo"
@updatePassword="handleModifyDefaultPassword"
Expand Down
1 change: 1 addition & 0 deletions src/views/login/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
// small window: fullscreen=no,scrollbars=yes,left=300,top=0,toolbar=no,height=800, width=700
window.open(ssoLogin(params), '_self');
loading.value = true;
} catch (error) {
// ignore
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/profile/pages/modify-password.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@
<a-form-item
hide-asterisk
hide-label
field="oldPassword"
field="originalPassword"
:trigger="['change', 'blur']"
:rules="[
{ required: true, message: $t('user.password.rules.oldpassword') }
]"
>
<seal-input-password
v-model="formData.oldPassword"
v-model="formData.originalPassword"
:style="{ width: `${InputWidth.LARGE}px` }"
:required="true"
allow-clear
Expand Down Expand Up @@ -147,7 +147,7 @@
displayName: '',
email: '',
password: '',
oldPassword: '',
originalPassword: '',
confirmPassword: ''
});
const handleCancel = () => {
Expand Down
56 changes: 52 additions & 4 deletions src/views/subject-providers/components/create-subject-provider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import SealInputPassword from '@/components/seal-form/components/seal-input-password.vue';
import SealInput from '@/components/seal-form/components/seal-input.vue';
import SealSwitch from '@/components/seal-form/components/seal-switch.vue';
import ModuleWrapper from '@/components/module-wrapper/index.vue';
import {
GlobalNamespace,
createSubjectProvider,
Expand Down Expand Up @@ -55,6 +56,8 @@
const { t } = i18n.global;
const submitLoading = ref(false);
const formref = ref();
const showAdavanced = ref(false);
const configOptions = ref([]);
const formData = ref<FormData>({
apiVersion,
kind: ResourceKinds.SubjectProvider,
Expand Down Expand Up @@ -202,10 +205,11 @@
);
};
const renderProviderConfig = () => {
const configList =
ProviderSpecConfig[formData.value.spec.type || 'GitHub'];
return _.map(configList, (item, index) => {
const renderOptions = (options) => {
if (!options || options.length === 0) {
return null;
}
return _.map(options, (item, index) => {
let Component: any = null;
if (item.type === FieldType.boolean) {
Component = SealSwitch;
Expand Down Expand Up @@ -266,6 +270,49 @@
);
});
};
const renderAdvancedOptions = () => {
const advancedOptions = _.filter(configOptions.value, (item) => {
return item.key === 'AdvancedOptions';
});
return (
<>
{advancedOptions.length > 0 && (
<div title="Advanced Options">
<a-button
class="size-14"
type="text"
style={{
padding: '0 2px',
marginBottom: '12px',
fontSize: 'var(--font-size-large)'
}}
onClick={() => {
showAdavanced.value = !showAdavanced.value;
}}
v-slots={{
icon: () => {
return <icon-settings />;
}
}}
>
Advanced Options
</a-button>
{showAdavanced.value &&
renderOptions(advancedOptions?.[0]?.options)}
</div>
)}
</>
);
};
const renderProviderConfig = () => {
configOptions.value =
ProviderSpecConfig[formData.value.spec.type || 'GitHub'];
const basicOptions = _.filter(configOptions.value, (item) => {
return item.key !== 'AdvancedOptions';
});
return <>{renderOptions(basicOptions)}</>;
};
return () => (
<a-modal
top="5%"
Expand Down Expand Up @@ -389,6 +436,7 @@
</seal-select>
</a-form-item>
{renderProviderConfig()}
{renderAdvancedOptions()}
<a-form-item label={t('common.table.description')} hide-label>
<seal-textarea
v-model={formData.value.spec.description}
Expand Down
3 changes: 2 additions & 1 deletion src/views/subject-providers/components/providers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
tooltip
:cell-style="{ minWidth: '40px' }"
data-index="metadata.name"
:title="$t('profile.account.type.user')"
:title="$t('common.table.user')"
>
</a-table-column>
<a-table-column
Expand All @@ -78,6 +78,7 @@
:title="$t('settings.user.nickName')"
>
</a-table-column>

<a-table-column
ellipsis
tooltip
Expand Down
36 changes: 36 additions & 0 deletions src/views/subject-providers/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,37 @@ const specConfig_1 = [
default: ''
}
];

const AdvancedOptions = [
{
key: 'claimMapping.nameKey',
label: 'Name',
required: false,
type: FieldType.string,
default: 'Name'
},
{
key: 'claimMapping.displayNameKey',
label: 'Nickname',
required: false,
type: FieldType.string,
default: ''
},
{
key: 'claimMapping.emailKey',
label: 'Email',
required: false,
type: FieldType.string,
default: ''
},
{
key: 'claimMapping.groupsKey',
label: 'Groups',
required: false,
type: FieldType.string,
default: ''
}
];
const specConfig_2 = [
{
key: 'issuer',
Expand Down Expand Up @@ -85,6 +116,11 @@ const specConfig_2 = [
required: true,
type: FieldType.password,
default: ''
},
{
key: 'AdvancedOptions',
label: 'Claim Mapping',
options: AdvancedOptions
}
];
export const ProviderSpecConfig = {
Expand Down
16 changes: 16 additions & 0 deletions src/views/system/pages/users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@
:title="$t('settings.user.nickName')"
>
</a-table-column>
<a-table-column
ellipsis
tooltip
:cell-style="{ minWidth: '40px' }"
data-index="spec.email"
:title="$t('settings.user.email')"
>
</a-table-column>
<!-- <a-table-column
ellipsis
tooltip
:cell-style="{ minWidth: '40px' }"
data-index="spec.role"
:title="$t('settings.user.group')"
>
</a-table-column> -->
<a-table-column
ellipsis
tooltip
Expand Down

0 comments on commit 5919bf5

Please sign in to comment.