From 812932abb36dc65cdc767dc2a9ca47ec315bc7b2 Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Tue, 21 Jan 2020 16:19:46 +0700 Subject: [PATCH] iam: Add LDAP Account Form (#116) Add LDAP account feature Signed-off-by: Rohit Yadav Co-authored-by: Rohit Yadav --- ui/src/components/view/ActionButton.vue | 4 +- ui/src/components/widgets/OsLogo.vue | 2 +- ui/src/config/section/iam.js | 11 + ui/src/config/section/image.js | 2 +- ui/src/config/section/project.js | 2 +- ui/src/store/getters.js | 3 +- ui/src/store/modules/user.js | 13 +- ui/src/views/iam/AddLdapAccount.vue | 412 ++++++++++++++++++++++++ 8 files changed, 442 insertions(+), 7 deletions(-) create mode 100644 ui/src/views/iam/AddLdapAccount.vue diff --git a/ui/src/components/view/ActionButton.vue b/ui/src/components/view/ActionButton.vue index fbd842a9d87..0146ec6edbc 100644 --- a/ui/src/components/view/ActionButton.vue +++ b/ui/src/components/view/ActionButton.vue @@ -32,7 +32,7 @@ v-if="action.api in $store.getters.apis && action.showBadge && ((!dataView && (action.listView || action.groupAction && selectedRowKeys.length > 0)) || (dataView && action.dataView)) && - ('show' in action ? action.show(resource, $store.getters.userInfo) : true)"> + ('show' in action ? action.show(resource, $store.getters) : true)"> { + return store.isLdapEnabled + }, + component: () => import('@/views/iam/AddLdapAccount.vue') + }, { api: 'updateAccount', icon: 'edit', diff --git a/ui/src/config/section/image.js b/ui/src/config/section/image.js index 93e94821fd3..b8d837d6765 100644 --- a/ui/src/config/section/image.js +++ b/ui/src/config/section/image.js @@ -91,7 +91,7 @@ export default { label: 'Update template permissions', dataView: true, popup: true, - show: (record, user) => { return (['Admin', 'DomainAdmin'].includes(user.roletype) && (record.domainid === user.domainid && record.account === user.account) || record.templatetype !== 'BUILTIN') }, + show: (record, store) => { return (['Admin', 'DomainAdmin'].includes(store.userInfo.roletype) && (record.domainid === store.userInfo.domainid && record.account === store.userInfo.account) || record.templatetype !== 'BUILTIN') }, component: () => import('@/views/image/UpdateTemplatePermissions') }, { diff --git a/ui/src/config/section/project.js b/ui/src/config/section/project.js index d9d4059ab1a..3993fbe93e0 100644 --- a/ui/src/config/section/project.js +++ b/ui/src/config/section/project.js @@ -95,7 +95,7 @@ export default { label: 'Add Account to Project', dataView: true, args: ['projectid', 'account', 'email'], - show: (record, user) => { return record.account === user.account || ['Admin', 'DomainAdmin'].includes(user.roletype) }, + show: (record, store) => { return record.account === store.userInfo.account || ['Admin', 'DomainAdmin'].includes(store.userInfo.roletype) }, mapping: { projectid: { value: (record) => { return record.id } diff --git a/ui/src/store/getters.js b/ui/src/store/getters.js index 05c923c9763..13cd2b75582 100644 --- a/ui/src/store/getters.js +++ b/ui/src/store/getters.js @@ -29,7 +29,8 @@ const getters = { userInfo: state => state.user.info, addRouters: state => state.permission.addRouters, multiTab: state => state.app.multiTab, - asyncJobIds: state => state.user.asyncJobIds + asyncJobIds: state => state.user.asyncJobIds, + isLdapEnabled: state => state.user.isLdapEnabled } export default getters diff --git a/ui/src/store/modules/user.js b/ui/src/store/modules/user.js index a61e49ad8cc..43426cc5e6c 100644 --- a/ui/src/store/modules/user.js +++ b/ui/src/store/modules/user.js @@ -31,7 +31,8 @@ const user = { apis: {}, features: {}, project: {}, - asyncJobIds: [] + asyncJobIds: [], + isLdapEnabled: false }, mutations: { @@ -62,6 +63,9 @@ const user = { Vue.ls.set(ASYNC_JOB_IDS, jobsJsonArray) state.asyncJobIds = jobsJsonArray }, + SET_LDAP: (state, isLdapEnabled) => { + state.isLdapEnabled = isLdapEnabled + }, RESET_THEME: (state) => { Vue.ls.set(DEFAULT_THEME, 'light') } @@ -126,6 +130,13 @@ const user = { }).catch(error => { reject(error) }) + + api('listLdapConfigurations').then(response => { + const ldapEnable = (response.ldapconfigurationresponse.count > 0) + commit('SET_LDAP', ldapEnable) + }).catch(error => { + reject(error) + }) }) }, Logout ({ commit, state }) { diff --git a/ui/src/views/iam/AddLdapAccount.vue b/ui/src/views/iam/AddLdapAccount.vue new file mode 100644 index 00000000000..59dff86451d --- /dev/null +++ b/ui/src/views/iam/AddLdapAccount.vue @@ -0,0 +1,412 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + + + + + +