Skip to content

Commit

Permalink
Updated CSR Modal & Service login Certificate Modal (#59)
Browse files Browse the repository at this point in the history
* Updated CSR Modal

- Removed the certificate type option from the modal
- Only admin can upload Service login Certificate

Signed-off-by: Kenneth Fullbright <[email protected]>
  • Loading branch information
Kenneth Fullbright authored and rfrandse committed Jun 30, 2022
1 parent b787ab4 commit fe8a5a4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/components/Mixins/CurrentUserMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const CurrentUserMixin = {
computed: {
currentUser() {
const value = this.$store.getters['userManagement/allUsers'].filter(
(user) => user.Id === this.$store.getters['global/username']
)[0];
return value;
},
},
};

export default CurrentUserMixin;
17 changes: 14 additions & 3 deletions src/views/SecurityAndAccess/Certificates/Certificates.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@
</b-col>
</b-row>
<!-- Modals -->
<modal-upload-certificate :certificate="modalCertificate" @ok="onModalOk" />
<modal-upload-certificate
:certificate="modalCertificate"
:user-role-id="userRoleId"
@ok="onModalOk"
/>
<modal-generate-csr />
</b-container>
</template>
Expand All @@ -106,6 +110,7 @@ import TableRowAction from '@/components/Global/TableRowAction';
import StatusIcon from '@/components/Global/StatusIcon';
import Alert from '@/components/Global/Alert';
import BVToastMixin from '@/components/Mixins/BVToastMixin';
import CurrentUserMixin from '@/components/Mixins/CurrentUserMixin';
import LoadingBarMixin from '@/components/Mixins/LoadingBarMixin';
export default {
name: 'Certificates',
Expand All @@ -120,13 +125,14 @@ export default {
StatusIcon,
TableRowAction,
},
mixins: [BVToastMixin, LoadingBarMixin],
mixins: [BVToastMixin, CurrentUserMixin, LoadingBarMixin],
beforeRouteLeave(to, from, next) {
this.hideLoader();
next();
},
data() {
return {
userRoleId: null,
isBusy: true,
modalCertificate: null,
fields: [
Expand Down Expand Up @@ -215,7 +221,12 @@ export default {
this.$store.dispatch('global/getBmcTime'),
this.$store.dispatch('certificates/getAcfCertificate'),
this.$store.dispatch('certificates/getCertificates'),
]).finally(() => this.endLoader());
this.$store.dispatch('userManagement/getUsers'),
]).finally(() => {
this.endLoader();
this.isBusy = false;
this.userRoleId = this.currentUser.RoleId;
});
},
methods: {
onTableRowAction(event, rowItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ export default {
keyBitLength: null,
},
certificateOptions: CERTIFICATE_TYPES.reduce((arr, cert) => {
if (cert.type === 'TrustStore Certificate') return arr;
if (
cert.type === 'TrustStore Certificate' ||
cert.type === 'ServiceLogin Certificate'
)
return arr;
arr.push({
text: cert.label,
value: cert.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ export default {
);
},
},
userRoleId: {
type: String,
default: null,
},
},
data() {
return {
Expand All @@ -119,12 +123,25 @@ export default {
return this.$store.getters['certificates/availableUploadTypes'];
},
certificateOptions() {
return this.certificateTypes.map(({ type, label }) => {
return {
text: label,
value: type,
};
});
return this.certificateTypes
.filter((certificate) => {
if (
certificate.type === 'ServiceLogin Certificate' &&
this.isNotAdmin
) {
return certificate.type !== 'ServiceLogin Certificate';
}
return certificate === certificate;
})
.map(({ type, label }) => {
return {
text: label,
value: type,
};
});
},
isNotAdmin() {
return this.userRoleId !== 'Administrator';
},
},
watch: {
Expand Down

0 comments on commit fe8a5a4

Please sign in to comment.