Skip to content

Commit

Permalink
Merge pull request #2485 from NationalSecurityAgency/t#2474/add-name-…
Browse files Browse the repository at this point in the history
…columns

T#2474/add name columns
  • Loading branch information
sudo-may authored Dec 6, 2023
2 parents 58340c8 + b8f2232 commit 509df30
Show file tree
Hide file tree
Showing 25 changed files with 292 additions and 74 deletions.
26 changes: 15 additions & 11 deletions dashboard/src/components/access/RevokeUserAccess.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ limitations under the License.
<b-card body-class="p-0">
<div class="row px-3 pt-3">
<div class="col-12">
<b-form-group label="User Id Filter" label-class="text-muted">
<b-input v-model="filters.userId" v-on:keydown.enter="applyFilters" data-cy="privateProjectUsers-userIdFilter" aria-label="user id filter"/>
<b-form-group label="User Filter" label-class="text-muted">
<b-input v-model="filters.user" v-on:keydown.enter="applyFilters" data-cy="privateProjectUsers-userIdFilter" aria-label="user filter"/>
</b-form-group>
</div>
<div class="col-md">
Expand All @@ -40,7 +40,7 @@ limitations under the License.
tableStoredStateId="privateProjectUsersTable"
data-cy="privateProjectUsersTable">
<template v-slot:cell(userId)="data">
{{ getUserDisplay(data.item) }}
{{ getUserDisplay(data.item, true) }}

<b-button-group class="float-right">
<b-button @click="revokeAccess(data.value, getUserDisplay(data.item))"
Expand Down Expand Up @@ -70,7 +70,7 @@ limitations under the License.
data() {
return {
filters: {
userId: '',
user: '',
},
table: {
items: [],
Expand All @@ -84,7 +84,7 @@ limitations under the License.
fields: [
{
key: 'userId',
label: 'User Id',
label: 'User',
sortable: true,
},
],
Expand Down Expand Up @@ -123,11 +123,11 @@ limitations under the License.
applyFilters() {
this.table.options.pagination.currentPage = 1;
this.loadData().then(() => {
this.$nextTick(() => this.$announcer.polite(`Revoke user access table has been filtered by ${this.filters.userId}`));
this.$nextTick(() => this.$announcer.polite(`Revoke user access table has been filtered by ${this.filters.user}`));
});
},
reset() {
this.filters.userId = '';
this.filters.user = '';
this.table.options.pagination.currentPage = 1;
this.loadData().then(() => {
this.$nextTick(() => this.$announcer.polite('Revoke user access table filters have been removed'));
Expand All @@ -136,7 +136,7 @@ limitations under the License.
loadData() {
this.table.options.busy = true;
const pageParams = {
query: this.filters.userId,
query: this.filters.user,
limit: this.table.options.pagination.pageSize,
ascending: !this.table.options.sortDesc,
page: this.table.options.pagination.currentPage,
Expand Down Expand Up @@ -166,19 +166,23 @@ limitations under the License.
}
});
},
getUserDisplay(props) {
getUserDisplay(props, fullName = false) {
const userDisplay = props.userIdForDisplay ? props.userIdForDisplay : props.userId;
const { oAuthProviders } = this.$store.getters.config;
let userName = '';
if (fullName && props.firstName && props.lastName) {
userName = ` (${props.lastName}, ${props.firstName})`;
}
if (oAuthProviders) {
const indexOfDash = userDisplay.lastIndexOf('-');
if (indexOfDash > 0) {
const provider = userDisplay.substr(indexOfDash + 1);
if (oAuthProviders.includes(provider)) {
return userDisplay.substr(0, indexOfDash);
return `${userDisplay.substr(0, indexOfDash)}${userName}`;
}
}
}
return userDisplay;
return `${userDisplay}${userName}`;
},
},
};
Expand Down
4 changes: 3 additions & 1 deletion dashboard/src/components/expiration/ExpirationHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ limitations under the License.
<span class="text-primary"><i class="fas fa-clock text-warning" aria-hidden="true"></i> {{ data.label }}</span>
</template>
<template v-slot:cell(userIdForDisplay)="data">
{{ data.value }}
{{ getUserDisplay(data.item, true) }}

<b-button-group class="float-right">
<b-button :to="calculateClientDisplayRoute(data)"
Expand Down Expand Up @@ -82,9 +82,11 @@ limitations under the License.
import SkillsBTable from '@/components/utils/table/SkillsBTable';
import ExpirationService from '@/components/expiration/ExpirationService';
import DateCell from '../utils/table/DateCell';
import UserIdForDisplayMixin from '../users/UserIdForDisplayMixin';
export default {
name: 'ExpirationHistory',
mixins: [UserIdForDisplayMixin],
components: {
SubPageHeader,
SkillsBTable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ limitations under the License.
@page-size-changed="pageSizeChanged"
@sort-changed="sortTable">
<template v-slot:cell(userId)="data">
{{ getUserDisplay(data.item) }}
{{ getUserDisplay(data.item, true) }}

<b-button-group class="float-right">
<b-button :to="calculateClientDisplayRoute(data.item)"
Expand Down
4 changes: 3 additions & 1 deletion dashboard/src/components/quiz/access/QuizAccessPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ limitations under the License.
<template v-slot:cell(userIdForDisplay)="data">
<div class="row" :data-cy="`quizAdmin_${data.item.userId}`">
<div class="col">
{{ data.value }}
{{ getUserDisplay(data.item, true) }}
</div>
<div class="col-auto">
<b-tooltip target="warningIconForSelfRemoval" triggers="hover">
Expand Down Expand Up @@ -100,9 +100,11 @@ limitations under the License.
import SkillsBTable from '@/components/utils/table/SkillsBTable';
import ExistingUserInput from '@/components/utils/ExistingUserInput';
import RemovalValidation from '@/components/utils/modal/RemovalValidation';
import UserIdForDisplayMixin from '../../users/UserIdForDisplayMixin';
export default {
name: 'QuizAccessPage',
mixins: [UserIdForDisplayMixin],
components: {
ExistingUserInput,
SubPageHeader,
Expand Down
5 changes: 3 additions & 2 deletions dashboard/src/components/quiz/metrics/QuizAnswerHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ limitations under the License.
<template v-slot:cell(userIdForDisplay)="data">
<div class="row" style="min-width: 15rem;" :data-cy="`row${data.index}-colUserId`">
<div class="col mb-2">
{{ data.value }}
{{ getUserDisplay(data.item, true) }}
</div>
<div class="col-auto mb-2">
<b-button size="sm" variant="outline-info"
Expand Down Expand Up @@ -80,10 +80,11 @@ limitations under the License.
import SkillsBTable from '@/components/utils/table/SkillsBTable';
import DateCell from '@/components/utils/table/DateCell';
import UserTagsConfigMixin from '@/components/users/UserTagsConfigMixin';
import UserIdForDisplayMixin from '../../users/UserIdForDisplayMixin';
export default {
name: 'QuizAnswerHistory',
mixins: [UserTagsConfigMixin],
mixins: [UserTagsConfigMixin, UserIdForDisplayMixin],
components: { DateCell, SkillsBTable },
props: {
answerDefId: Number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ limitations under the License.
<template v-slot:cell(userIdForDisplay)="data">
<div class="row" :data-cy="`row${data.index}-userCell`">
<div class="col">
<span v-if="data.item.userIdForDisplayHtml" v-html="data.item.userIdForDisplayHtml"></span><span v-else>{{ data.item.userIdForDisplay }}</span>
<span v-if="data.item.userIdForDisplayHtml" v-html="data.item.userIdForDisplayHtml"></span>
<span v-else>
{{ getUserDisplay(data.item, true) }}
</span>
</div>
<div class="col-auto">
<b-button variant="outline-info" size="sm" :data-cy="`row${data.index}-viewRun`"
Expand Down Expand Up @@ -142,12 +145,13 @@ limitations under the License.
import UserTagsConfigMixin from '@/components/users/UserTagsConfigMixin';
import QuizUserTagsChart from '@/components/quiz/metrics/QuizUserTagsChart';
import QuizAttemptsTimeChart from '@/components/quiz/metrics/QuizAttemptsTimeChart';
import UserIdForDisplayMixin from '../../users/UserIdForDisplayMixin';
const { mapActions } = createNamespacedHelpers('quiz');
export default {
name: 'QuizRunsHistoryPage',
mixins: [UserTagsConfigMixin],
mixins: [UserTagsConfigMixin, UserIdForDisplayMixin],
components: {
QuizRunStatus,
DateCell,
Expand Down Expand Up @@ -247,7 +251,7 @@ limitations under the License.
let items = res.data;
if (this.filters.userId && this.filters.userId.trim().length > 0) {
items = items.map((item) => {
const userIdForDisplayHtml = StringHighlighter.highlight(item.userIdForDisplay, this.filters.userId);
const userIdForDisplayHtml = StringHighlighter.highlight(this.getUserDisplay(item, true), this.filters.userId);
return { userIdForDisplayHtml, ...item };
});
}
Expand Down
4 changes: 3 additions & 1 deletion dashboard/src/components/userActions/UserActionsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ limitations under the License.
</template>

<template v-slot:cell(userIdForDisplay)="data">
<span :data-cy="`row${data.index}-userId`">{{ data.value }}</span>
<span :data-cy="`row${data.index}-userId`">{{ getUserDisplay(data.item, true) }}</span>
</template>

<template v-slot:cell(action)="data">
Expand Down Expand Up @@ -178,9 +178,11 @@ limitations under the License.
import DateCell from '@/components/utils/table/DateCell';
import SingleUserAction from '@/components/userActions/SingleUserAction';
import StartRecordingUserActionsDateWarning from '@/components/userActions/StartRecordingUserActionsDateWarning';
import UserIdForDisplayMixin from '../users/UserIdForDisplayMixin';
export default {
name: 'UserActionsPage',
mixins: [UserIdForDisplayMixin],
components: {
StartRecordingUserActionsDateWarning,
SingleUserAction,
Expand Down
10 changes: 7 additions & 3 deletions dashboard/src/components/users/UserIdForDisplayMixin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,23 @@ limitations under the License.
export default {
name: 'UserIdForDisplayMixin',
methods: {
getUserDisplay(props) {
getUserDisplay(props, fullName = false) {
const userDisplay = props.userIdForDisplay ? props.userIdForDisplay : props.userId;
const { oAuthProviders } = this.$store.getters.config;
let userName = '';
if (fullName && props.firstName && props.lastName) {
userName = ` (${props.lastName}, ${props.firstName})`;
}
if (oAuthProviders) {
const indexOfDash = userDisplay.lastIndexOf('-');
if (indexOfDash > 0) {
const provider = userDisplay.substr(indexOfDash + 1);
if (oAuthProviders.includes(provider)) {
return userDisplay.substr(0, indexOfDash);
return `${userDisplay.substr(0, indexOfDash)}${userName}`;
}
}
}
return userDisplay;
return `${userDisplay}${userName}`;
},
},
};
Expand Down
17 changes: 6 additions & 11 deletions dashboard/src/components/users/UserPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,12 @@ limitations under the License.
});
}
if (this.$store.getters.isPkiAuthenticated) {
UsersService.getUserInfo(this.$route.params.projectId, this.$route.params.userId)
.then((result) => {
this.userIdForDisplay = result.userIdForDisplay;
this.userTitle = result.first && result.last ? `${result.first} ${result.last}` : result.userIdForDisplay;
userDetails = this.loadUserDetails();
});
} else {
userDetails = this.loadUserDetails();
}
userDetails = this.loadUserDetails();
UsersService.getUserInfo(this.$route.params.projectId, this.$route.params.userId)
.then((result) => {
this.userIdForDisplay = result.userIdForDisplay;
this.userTitle = result.first && result.last ? `${result.first} ${result.last}` : result.userIdForDisplay;
userDetails = this.loadUserDetails();
});
Promise.all([userTags, userDetails]).finally(() => {
this.isLoading = false;
Expand Down
22 changes: 11 additions & 11 deletions dashboard/src/components/users/UsersTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License.
<div>
<div class="row px-3 pt-3">
<div class="col-md-6">
<b-form-group label="User Id Filter" label-class="text-muted">
<b-input v-model="filters.userId" v-on:keydown.enter="applyFilters" data-cy="users-skillIdFilter" aria-label="user id filter"/>
<b-form-group label="User Filter" label-class="text-muted">
<b-input v-model="filters.user" v-on:keydown.enter="applyFilters" data-cy="users-skillIdFilter" aria-label="user filter"/>
</b-form-group>
</div>
<div class="col-md-6">
Expand Down Expand Up @@ -63,13 +63,13 @@ limitations under the License.
</template>

<template v-slot:cell(userId)="data">
{{ getUserDisplay(data.item) }}
{{ getUserDisplay(data.item, true) }}

<b-button-group class="float-right">
<b-button :to="calculateClientDisplayRoute(data.item)"
variant="outline-info" size="sm" class="text-secondary"
v-b-tooltip.hover="'View User Details'"
:aria-label="`View details for user ${getUserDisplay(data.item)}`"
:aria-label="`View details for user ${getUserDisplay(data.item, true)}`"
data-cy="usersTable_viewDetailsBtn"><i class="fa fa-user-alt" aria-hidden="true"/><span class="sr-only">view user details</span>
</b-button>
</b-button-group>
Expand Down Expand Up @@ -138,7 +138,7 @@ limitations under the License.
inviteOnlyProject: false,
data: [],
filters: {
userId: '',
user: '',
progress: 0,
minimumPoints: 0,
},
Expand All @@ -156,7 +156,7 @@ limitations under the License.
fields: [
{
key: 'userId',
label: 'User Id',
label: 'User',
sortable: true,
},
{
Expand Down Expand Up @@ -236,17 +236,17 @@ limitations under the License.
this.filters.minimumPoints = Math.floor(this.totalPoints * (this.filters.progress / 100));
this.loadData().then(() => {
let filterMessage = 'Users table has been filtered by';
if (this.filters.userId) {
filterMessage += ` ${this.filters.userId}`;
if (this.filters.user) {
filterMessage += ` ${this.filters.user}`;
}
if (this.filters.minimumPoints > 0) {
filterMessage += `${this.filters.userId ? ' and' : ''} users with at least ${this.filters.minimumPoints} points`;
filterMessage += `${this.filters.user ? ' and' : ''} users with at least ${this.filters.minimumPoints} points`;
}
this.$nextTick(() => this.$announcer.polite(filterMessage));
});
},
reset() {
this.filters.userId = '';
this.filters.user = '';
this.filters.minimumPoints = 0;
this.filters.progress = 0;
this.table.options.pagination.currentPage = 1;
Expand All @@ -258,7 +258,7 @@ limitations under the License.
this.table.options.busy = true;
const url = this.getUrl();
return UsersService.ajaxCall(url, {
query: this.filters.userId,
query: this.filters.user,
limit: this.table.options.pagination.pageSize,
ascending: !this.table.options.sortDesc,
page: this.table.options.pagination.currentPage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ describe('Metrics Tests - Achievements', () => {

const m = moment.utc('2020-09-12 11', 'YYYY-MM-DD HH');
cy.request('POST', `/api/projects/proj1/skills/skill1`, {
userId: 'user0Good@skills.org',
userId: 'user0good@skills.org',
timestamp: m.clone()
.subtract(1, 'day')
.format('x')
});
cy.request('POST', `/api/projects/proj1/skills/skill2`, {
userId: 'user0Good@skills.org',
userId: 'user0good@skills.org',
timestamp: m.clone()
.subtract(4, 'day')
.format('x')
Expand All @@ -223,7 +223,7 @@ describe('Metrics Tests - Achievements', () => {
cy.validateTable(tableSelector, [
[{
colIndex: 0,
value: 'user0Good@skills.org'
value: 'user0good@skills.org'
}, {
colIndex: 1,
value: 'Skill'
Expand All @@ -239,7 +239,7 @@ describe('Metrics Tests - Achievements', () => {
}],
[{
colIndex: 0,
value: 'user0Good@skills.org'
value: 'user0good@skills.org'
}, {
colIndex: 1,
value: 'Skill'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ describe('Metrics Using User Tags Tests', () => {
.contains('Level 1: 0 users');

cy.intercept('/admin/projects/proj1/userTags/manyValues/tag0/users*').as('getUsers');
cy.get(`${usersTableSelector}`).contains('User Id').click();
cy.get(`${usersTableSelector}`).contains('User').click();
cy.wait('@getUsers')

cy.get('[data-cy="levelsChart"] [data-cy="metricsCard-header"]').contains('Overall Levels for Best Label: tag0')
Expand Down
Loading

0 comments on commit 509df30

Please sign in to comment.