Skip to content

Commit 4b0fc1d

Browse files
Update local user layout and styles
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 <[email protected]> Signed-off-by: Derick Montague <[email protected]> Change-Id: Ib50ee4d1fb5f14637c9460e77f0682869a86ac8a
1 parent 6109113 commit 4b0fc1d

File tree

13 files changed

+540
-190
lines changed

13 files changed

+540
-190
lines changed

package-lock.json

+137-66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"vue": "2.6.10",
2020
"vue-date-fns": "^1.1.0",
2121
"vue-router": "3.1.3",
22+
"vuelidate": "^0.7.4",
2223
"vuex": "3.0.1"
2324
},
2425
"devDependencies": {
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.form-text {
2+
margin-top: -$spacer / 4;
3+
margin-bottom: $spacer / 2;
4+
color: $gray-800;
5+
}
6+
7+
.col-form-label {
8+
color: $gray-800;
9+
font-size: 14px;
10+
}
11+
12+
.form-group {
13+
margin-bottom: $spacer * 2;
14+
}
15+
16+
.custom-select,
17+
.custom-control-label,
18+
.form-control {
19+
//important needed to override validation colors on radio labels
20+
color: $gray-900!important;
21+
border-color: $gray-400!important;
22+
&::before {
23+
border-color: $primary;
24+
}
25+
&.is-invalid,
26+
&:invalid {
27+
border-bottom: 2px solid $danger!important;
28+
}
29+
}

src/assets/styles/_modal.scss

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.modal-header {
2+
.close {
3+
font-weight: normal;
4+
color: $gray-900;
5+
opacity: 1;
6+
}
7+
}

src/assets/styles/_obmc-custom.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
$enable-rounded: false;
2+
$enable-validation-icons: false;
23

34
// Required
45
@import "~bootstrap/scss/functions";
@@ -52,4 +53,7 @@ $colors: map-remove($theme-colors, "light", "dark");
5253

5354
@import "~bootstrap-vue/src/index.scss";
5455

55-
@import "./buttons";
56+
@import "./buttons";
57+
@import "./form-components";
58+
@import "./modal";
59+
@import "./table";

src/assets/styles/_table.scss

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.table-light {
2+
td {
3+
border-top: none;
4+
border-bottom: 1px solid $gray-300;
5+
}
6+
}
7+
8+
.thead-light.thead-light {
9+
th {
10+
border: none;
11+
color: $gray-900;
12+
}
13+
}
14+
15+
.table-cell__actions {
16+
text-align: right;
17+
.btn {
18+
padding-top: 0;
19+
padding-bottom: 0;
20+
}
21+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const VuelidateMixin = {
2+
methods: {
3+
getValidationState(model) {
4+
const { $dirty, $error } = model;
5+
return $dirty ? !$error : null;
6+
}
7+
}
8+
};
9+
10+
export default VuelidateMixin;

src/main.js

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
AlertPlugin,
88
BadgePlugin,
99
ButtonPlugin,
10+
BVConfigPlugin,
1011
CollapsePlugin,
1112
FormPlugin,
1213
FormCheckboxPlugin,
@@ -22,12 +23,20 @@ import {
2223
NavPlugin,
2324
TablePlugin
2425
} from 'bootstrap-vue';
26+
import Vuelidate from 'vuelidate';
2527

2628
Vue.filter('date', dateFilter);
2729

2830
Vue.use(AlertPlugin);
2931
Vue.use(BadgePlugin);
3032
Vue.use(ButtonPlugin);
33+
Vue.use(BVConfigPlugin, {
34+
BFormText: { textVariant: 'black' },
35+
BTable: {
36+
headVariant: 'light',
37+
footVariant: 'light'
38+
}
39+
});
3140
Vue.use(CollapsePlugin);
3241
Vue.use(FormPlugin);
3342
Vue.use(FormCheckboxPlugin);
@@ -43,6 +52,7 @@ Vue.use(ModalPlugin);
4352
Vue.use(NavbarPlugin);
4453
Vue.use(NavPlugin);
4554
Vue.use(TablePlugin);
55+
Vue.use(Vuelidate);
4656

4757
new Vue({
4858
router,

src/store/modules/Authentication/AuthenticanStore.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,28 @@ import Cookies from 'js-cookie';
44
const AuthenticationStore = {
55
namespaced: true,
66
state: {
7-
status: '',
7+
authError: false,
88
cookie: Cookies.get('XSRF-TOKEN')
99
},
1010
getters: {
11-
authStatus: state => state.status,
11+
authError: state => state.authError,
1212
isLoggedIn: state => !!state.cookie
1313
},
1414
mutations: {
15-
authRequest(state) {
16-
state.status = 'processing';
17-
},
1815
authSuccess(state) {
19-
state.status = 'authenticated';
16+
state.authError = false;
2017
state.cookie = Cookies.get('XSRF-TOKEN');
2118
},
2219
authError(state) {
23-
state.status = 'error';
24-
},
25-
authReset(state) {
26-
state.status = '';
20+
state.authError = true;
2721
},
2822
logout(state) {
29-
state.status = '';
23+
state.authError = false;
3024
Cookies.remove('XSRF-TOKEN');
3125
}
3226
},
3327
actions: {
3428
login({ commit }, auth) {
35-
commit('authRequest');
3629
return api
3730
.post('/login', { data: auth })
3831
.then(() => commit('authSuccess'))

src/views/AccessControl/LocalUserManagement/LocalUserManagement.vue

+32-19
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<b-container class="ml-0">
33
<PageTitle />
44
<b-row>
5-
<b-col lg="10">
6-
<b-button @click="initModalSettings" variant="link">
5+
<b-col lg="10" class="text-right">
6+
<b-button variant="link" @click="initModalSettings">
77
Account policy settings
88
<icon-settings />
99
</b-button>
@@ -15,11 +15,11 @@
1515
</b-row>
1616
<b-row>
1717
<b-col lg="10">
18-
<b-table bordered show-empty head-variant="dark" :items="tableItems">
19-
<template v-slot:head(actions)="data"></template>
18+
<b-table show-empty :fields="fields" :items="tableItems">
2019
<template v-slot:cell(actions)="data">
2120
<b-button
2221
aria-label="Edit user"
22+
title="Edit user"
2323
variant="link"
2424
:disabled="!data.value.edit"
2525
@click="initModalUser(data.item)"
@@ -28,6 +28,7 @@
2828
</b-button>
2929
<b-button
3030
aria-label="Delete user"
31+
title="Delete user"
3132
variant="link"
3233
:disabled="!data.value.delete"
3334
@click="initModalDelete(data.item)"
@@ -42,19 +43,16 @@
4243
<b-col lg="8">
4344
<b-button v-b-toggle.collapse-role-table variant="link" class="mt-3">
4445
View privilege role descriptions
46+
<icon-chevron />
4547
</b-button>
4648
<b-collapse id="collapse-role-table" class="mt-3">
4749
<table-roles />
4850
</b-collapse>
4951
</b-col>
5052
</b-row>
5153
<!-- Modals -->
52-
<modal-settings v-bind:settings="settings"></modal-settings>
53-
<modal-user
54-
v-bind:user="activeUser"
55-
@ok="saveUser"
56-
@hidden="clearActiveUser"
57-
></modal-user>
54+
<modal-settings :settings="settings"></modal-settings>
55+
<modal-user :user="activeUser" @ok="saveUser"></modal-user>
5856
</b-container>
5957
</template>
6058

@@ -63,6 +61,7 @@ import IconTrashcan from '@carbon/icons-vue/es/trash-can/20';
6361
import IconEdit from '@carbon/icons-vue/es/edit/20';
6462
import IconAdd from '@carbon/icons-vue/es/add--alt/20';
6563
import IconSettings from '@carbon/icons-vue/es/settings/20';
64+
import IconChevron from '@carbon/icons-vue/es/chevron--up/20';
6665
6766
import TableRoles from './TableRoles';
6867
import ModalUser from './ModalUser';
@@ -73,6 +72,7 @@ export default {
7372
name: 'local-users',
7473
components: {
7574
IconAdd,
75+
IconChevron,
7676
IconEdit,
7777
IconSettings,
7878
IconTrashcan,
@@ -84,7 +84,17 @@ export default {
8484
data() {
8585
return {
8686
activeUser: null,
87-
settings: null
87+
settings: null,
88+
fields: [
89+
'username',
90+
'privilege',
91+
'status',
92+
{
93+
key: 'actions',
94+
label: '',
95+
tdClass: 'table-cell__actions'
96+
}
97+
]
8898
};
8999
},
90100
created() {
@@ -108,7 +118,8 @@ export default {
108118
actions: {
109119
edit: true,
110120
delete: user.UserName === 'root' ? false : true
111-
}
121+
},
122+
...user
112123
};
113124
});
114125
}
@@ -143,18 +154,15 @@ export default {
143154
// fetch settings then show modal
144155
}
145156
},
146-
saveUser({ newUser, form }) {
147-
if (newUser) {
148-
this.$store.dispatch('localUsers/createUser', form);
157+
saveUser({ isNewUser, userData }) {
158+
if (isNewUser) {
159+
this.$store.dispatch('localUsers/createUser', userData);
149160
} else {
150-
this.$store.dispatch('localUsers/updateUser', form);
161+
this.$store.dispatch('localUsers/updateUser', userData);
151162
}
152163
},
153164
deleteUser({ username }) {
154165
this.$store.dispatch('localUsers/deleteUser', username);
155-
},
156-
clearActiveUser() {
157-
this.activeUser = null;
158166
}
159167
}
160168
};
@@ -164,4 +172,9 @@ export default {
164172
h1 {
165173
margin-bottom: 2rem;
166174
}
175+
.btn.collapsed {
176+
svg {
177+
transform: rotate(180deg);
178+
}
179+
}
167180
</style>

0 commit comments

Comments
 (0)