From 4b0fc1dbb3f60a485d3ba7ec27d7654a8ea0d382 Mon Sep 17 00:00:00 2001 From: Yoshie Muranaka Date: Mon, 6 Jan 2020 07:36:16 -0800 Subject: Update local user layout and styles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resubmitting after reverted–original commit here https://gerrit.openbmc-project.xyz/c/openbmc/webui-vue/+/28790 - Add BVConfig plugin to modify boostrap component defaults - Add vuelidate - Add package and basic validations to user form - Add all user form validations - Add checks for edit user - Create VuelidateMixin for shared methods - Update Login to use Vuelidate Signed-off-by: Yoshie Muranaka Signed-off-by: Derick Montague Change-Id: Ib50ee4d1fb5f14637c9460e77f0682869a86ac8a --- src/assets/styles/_form-components.scss | 29 +++ src/assets/styles/_modal.scss | 7 + src/assets/styles/_obmc-custom.scss | 6 +- src/assets/styles/_table.scss | 21 ++ src/components/Mixins/VuelidateMixin.js | 10 + src/main.js | 10 + .../modules/Authentication/AuthenticanStore.js | 17 +- .../LocalUserManagement/LocalUserManagement.vue | 51 ++-- .../LocalUserManagement/ModalUser.vue | 272 ++++++++++++++++++--- .../LocalUserManagement/TableRoles.vue | 2 +- src/views/Login/Login.vue | 101 ++++---- 11 files changed, 402 insertions(+), 124 deletions(-) create mode 100644 src/assets/styles/_form-components.scss create mode 100644 src/assets/styles/_modal.scss create mode 100644 src/assets/styles/_table.scss create mode 100644 src/components/Mixins/VuelidateMixin.js (limited to 'src') diff --git a/src/assets/styles/_form-components.scss b/src/assets/styles/_form-components.scss new file mode 100644 index 00000000..41b291b2 --- /dev/null +++ b/src/assets/styles/_form-components.scss @@ -0,0 +1,29 @@ +.form-text { + margin-top: -$spacer / 4; + margin-bottom: $spacer / 2; + color: $gray-800; +} + +.col-form-label { + color: $gray-800; + font-size: 14px; +} + +.form-group { + margin-bottom: $spacer * 2; +} + +.custom-select, +.custom-control-label, +.form-control { + //important needed to override validation colors on radio labels + color: $gray-900!important; + border-color: $gray-400!important; + &::before { + border-color: $primary; + } + &.is-invalid, + &:invalid { + border-bottom: 2px solid $danger!important; + } +} \ No newline at end of file diff --git a/src/assets/styles/_modal.scss b/src/assets/styles/_modal.scss new file mode 100644 index 00000000..b20327e7 --- /dev/null +++ b/src/assets/styles/_modal.scss @@ -0,0 +1,7 @@ +.modal-header { + .close { + font-weight: normal; + color: $gray-900; + opacity: 1; + } +} \ No newline at end of file diff --git a/src/assets/styles/_obmc-custom.scss b/src/assets/styles/_obmc-custom.scss index e87e01bb..d20e64e4 100644 --- a/src/assets/styles/_obmc-custom.scss +++ b/src/assets/styles/_obmc-custom.scss @@ -1,4 +1,5 @@ $enable-rounded: false; +$enable-validation-icons: false; // Required @import "~bootstrap/scss/functions"; @@ -52,4 +53,7 @@ $colors: map-remove($theme-colors, "light", "dark"); @import "~bootstrap-vue/src/index.scss"; -@import "./buttons"; \ No newline at end of file +@import "./buttons"; +@import "./form-components"; +@import "./modal"; +@import "./table"; \ No newline at end of file diff --git a/src/assets/styles/_table.scss b/src/assets/styles/_table.scss new file mode 100644 index 00000000..ff1ed302 --- /dev/null +++ b/src/assets/styles/_table.scss @@ -0,0 +1,21 @@ +.table-light { + td { + border-top: none; + border-bottom: 1px solid $gray-300; + } +} + +.thead-light.thead-light { + th { + border: none; + color: $gray-900; + } +} + +.table-cell__actions { + text-align: right; + .btn { + padding-top: 0; + padding-bottom: 0; + } +} diff --git a/src/components/Mixins/VuelidateMixin.js b/src/components/Mixins/VuelidateMixin.js new file mode 100644 index 00000000..8c617791 --- /dev/null +++ b/src/components/Mixins/VuelidateMixin.js @@ -0,0 +1,10 @@ +const VuelidateMixin = { + methods: { + getValidationState(model) { + const { $dirty, $error } = model; + return $dirty ? !$error : null; + } + } +}; + +export default VuelidateMixin; diff --git a/src/main.js b/src/main.js index b69c6591..e32a56be 100644 --- a/src/main.js +++ b/src/main.js @@ -7,6 +7,7 @@ import { AlertPlugin, BadgePlugin, ButtonPlugin, + BVConfigPlugin, CollapsePlugin, FormPlugin, FormCheckboxPlugin, @@ -22,12 +23,20 @@ import { NavPlugin, TablePlugin } from 'bootstrap-vue'; +import Vuelidate from 'vuelidate'; Vue.filter('date', dateFilter); Vue.use(AlertPlugin); Vue.use(BadgePlugin); Vue.use(ButtonPlugin); +Vue.use(BVConfigPlugin, { + BFormText: { textVariant: 'black' }, + BTable: { + headVariant: 'light', + footVariant: 'light' + } +}); Vue.use(CollapsePlugin); Vue.use(FormPlugin); Vue.use(FormCheckboxPlugin); @@ -43,6 +52,7 @@ Vue.use(ModalPlugin); Vue.use(NavbarPlugin); Vue.use(NavPlugin); Vue.use(TablePlugin); +Vue.use(Vuelidate); new Vue({ router, diff --git a/src/store/modules/Authentication/AuthenticanStore.js b/src/store/modules/Authentication/AuthenticanStore.js index 3a554b6b..8d8898ef 100644 --- a/src/store/modules/Authentication/AuthenticanStore.js +++ b/src/store/modules/Authentication/AuthenticanStore.js @@ -4,35 +4,28 @@ import Cookies from 'js-cookie'; const AuthenticationStore = { namespaced: true, state: { - status: '', + authError: false, cookie: Cookies.get('XSRF-TOKEN') }, getters: { - authStatus: state => state.status, + authError: state => state.authError, isLoggedIn: state => !!state.cookie }, mutations: { - authRequest(state) { - state.status = 'processing'; - }, authSuccess(state) { - state.status = 'authenticated'; + state.authError = false; state.cookie = Cookies.get('XSRF-TOKEN'); }, authError(state) { - state.status = 'error'; - }, - authReset(state) { - state.status = ''; + state.authError = true; }, logout(state) { - state.status = ''; + state.authError = false; Cookies.remove('XSRF-TOKEN'); } }, actions: { login({ commit }, auth) { - commit('authRequest'); return api .post('/login', { data: auth }) .then(() => commit('authSuccess')) diff --git a/src/views/AccessControl/LocalUserManagement/LocalUserManagement.vue b/src/views/AccessControl/LocalUserManagement/LocalUserManagement.vue index 6ca43f32..b81dba67 100644 --- a/src/views/AccessControl/LocalUserManagement/LocalUserManagement.vue +++ b/src/views/AccessControl/LocalUserManagement/LocalUserManagement.vue @@ -2,8 +2,8 @@ - - + + Account policy settings @@ -15,11 +15,11 @@ - - + @@ -63,6 +61,7 @@ import IconTrashcan from '@carbon/icons-vue/es/trash-can/20'; import IconEdit from '@carbon/icons-vue/es/edit/20'; import IconAdd from '@carbon/icons-vue/es/add--alt/20'; import IconSettings from '@carbon/icons-vue/es/settings/20'; +import IconChevron from '@carbon/icons-vue/es/chevron--up/20'; import TableRoles from './TableRoles'; import ModalUser from './ModalUser'; @@ -73,6 +72,7 @@ export default { name: 'local-users', components: { IconAdd, + IconChevron, IconEdit, IconSettings, IconTrashcan, @@ -84,7 +84,17 @@ export default { data() { return { activeUser: null, - settings: null + settings: null, + fields: [ + 'username', + 'privilege', + 'status', + { + key: 'actions', + label: '', + tdClass: 'table-cell__actions' + } + ] }; }, created() { @@ -108,7 +118,8 @@ export default { actions: { edit: true, delete: user.UserName === 'root' ? false : true - } + }, + ...user }; }); } @@ -143,18 +154,15 @@ export default { // fetch settings then show modal } }, - saveUser({ newUser, form }) { - if (newUser) { - this.$store.dispatch('localUsers/createUser', form); + saveUser({ isNewUser, userData }) { + if (isNewUser) { + this.$store.dispatch('localUsers/createUser', userData); } else { - this.$store.dispatch('localUsers/updateUser', form); + this.$store.dispatch('localUsers/updateUser', userData); } }, deleteUser({ username }) { this.$store.dispatch('localUsers/deleteUser', username); - }, - clearActiveUser() { - this.activeUser = null; } } }; @@ -164,4 +172,9 @@ export default { h1 { margin-bottom: 2rem; } +.btn.collapsed { + svg { + transform: rotate(180deg); + } +} diff --git a/src/views/AccessControl/LocalUserManagement/ModalUser.vue b/src/views/AccessControl/LocalUserManagement/ModalUser.vue index 73aa164c..e3ceb7df 100644 --- a/src/views/AccessControl/LocalUserManagement/ModalUser.vue +++ b/src/views/AccessControl/LocalUserManagement/ModalUser.vue @@ -1,9 +1,5 @@