Skip to content

Commit

Permalink
[ui] Mark individuals as reviewed
Browse files Browse the repository at this point in the history
Adds a button on the individuals view to mark it as reviewed.
The button shows the review date if it has been reviewed and
a warning icon if there have been any changes since the last
review.

Signed-off-by: Eva Millán <[email protected]>
  • Loading branch information
evamillan committed Sep 5, 2024
1 parent 7400e9b commit 2f2974b
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 17 deletions.
2 changes: 2 additions & 0 deletions ui/src/apollo/fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const FULL_INDIVIDUAL = gql`
fragment individual on IndividualType {
mk
isLocked
lastReviewed
lastModified
...profile
...identities
...enrollments
Expand Down
32 changes: 32 additions & 0 deletions ui/src/apollo/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ const UPDATE_PROFILE = gql`
uuid
individual {
...individual
matchRecommendationSet {
id
individual {
...individual
}
}
}
}
}
Expand Down Expand Up @@ -458,6 +464,24 @@ const DELETE_MERGE_RECOMMENDATIONS = gql`
}
`;

const REVIEW_INDIVIDUAL = gql`
mutation reviewIndidivual($uuid: String!) {
review(uuid: $uuid) {
uuid
individual {
...individual
matchRecommendationSet {
id
individual {
...individual
}
}
}
}
}
${FULL_INDIVIDUAL}
`;

const tokenAuth = (apollo, username, password) => {
const response = apollo.mutate({
mutation: TOKEN_AUTH,
Expand Down Expand Up @@ -877,6 +901,13 @@ const deleteMergeRecommendations = (apollo) => {
});
};

const reviewIndidivual = (apollo, uuid) => {
return apollo.mutate({
mutation: REVIEW_INDIVIDUAL,
variables: { uuid },
});
};

export {
tokenAuth,
lockIndividual,
Expand Down Expand Up @@ -912,4 +943,5 @@ export {
deleteAlias,
addLinkedinProfile,
deleteMergeRecommendations,
reviewIndidivual,
};
2 changes: 2 additions & 0 deletions ui/src/utils/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ const formatIndividual = (individual) => {
country: individual.profile.country,
isLocked: individual.isLocked,
isBot: individual.profile.isBot,
lastReviewed: individual.lastReviewed,
lastModified: individual.lastModified,
};

if (individual.enrollments && individual.enrollments.length > 0) {
Expand Down
60 changes: 60 additions & 0 deletions ui/src/views/Individual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,24 @@
</v-col>

<v-col cols="2" class="d-flex justify-end align-start mr-1">
<v-tooltip location="bottom" max-width="200">
<template v-slot:activator="{ props }">
<v-btn
:disabled="individual.isLocked"
:aria-label="reviewButton.tooltip"
:icon="reviewButton.icon"
v-bind="props"
class="mr-1"
data-testid="review-btn"
variant="text"
@click="review(this.mk)"
>
</v-btn>
</template>
<span>
{{ reviewButton.tooltip }}
</span>
</v-tooltip>
<v-tooltip location="bottom">
<template v-slot:activator="{ props }">
<v-btn
Expand Down Expand Up @@ -400,6 +418,7 @@
</template>

<script>
import dayjs from "dayjs";
import {
getCountries,
findOrganization,
Expand All @@ -417,6 +436,7 @@ import {
updateProfile,
withdraw,
recommendMatches,
reviewIndidivual,
} from "../apollo/mutations";
import { formatIndividual } from "../utils/actions";
import { enrollMixin } from "../mixins/enroll";
Expand Down Expand Up @@ -505,6 +525,32 @@ export default {
(profile) => profile.source === "linkedin"
);
},
reviewButton() {
const reviewDate = this.$formatDate(
this.individual.lastReviewed,
"YYYY-MM-DD"
);
const unreviewedChanges = dayjs(this.individual.lastModified).isAfter(
this.individual.lastReviewed,
"second"
);
if (!reviewDate) {
return {
icon: "mdi-check-decagram-outline",
tooltip: "Mark as reviewed",
};
} else if (unreviewedChanges) {
return {
icon: "mdi-alert-decagram",
tooltip: `Changes since last review on ${reviewDate}`,
};
} else {
return {
icon: "mdi-check-decagram",
tooltip: `Last reviewed ${reviewDate}`,
};
}
},
},
methods: {
async updateProfile(data) {
Expand Down Expand Up @@ -793,6 +839,20 @@ export default {
action: this.removeLinkedInProfile,
};
},
async review(uuid) {
try {
const response = await reviewIndidivual(this.$apollo, uuid);
this.updateIndividual(response.data.review.individual);
this.$logger.debug(`Marked individual ${this.mk} as reviewed`);
} catch (error) {
this.dialog = {
open: true,
title: "Error reviewing individual",
errorMessage: this.$getErrorMessage(error),
};
this.$logger.error(`Error reviewing individual: ${error}`);
}
},
},
};
</script>
Expand Down
67 changes: 51 additions & 16 deletions ui/tests/unit/__snapshots__/individual.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,41 @@ exports[`Individual Matches snapshot 1`] = `
<button
aria-describedby="v-tooltip-2"
aria-label="Mark as reviewed"
class="v-btn v-btn--icon v-theme--light v-btn--density-default v-btn--size-small v-btn--variant-text mr-1"
data-testid="review-btn"
targetref="[object Object]"
type="button"
>
<span
class="v-btn__overlay"
/>
<span
class="v-btn__underlay"
/>
<!---->
<span
class="v-btn__content"
data-no-activator=""
>
<i
aria-hidden="true"
class="mdi-check-decagram-outline mdi v-icon notranslate v-theme--light v-icon--size-default"
/>
</span>
<!---->
<!---->
</button>
<!--teleport start-->
<!--teleport end-->
<button
aria-describedby="v-tooltip-4"
aria-label="Mark as bot"
class="v-btn v-btn--icon v-theme--light v-btn--density-default v-btn--size-small v-btn--variant-text mr-1"
targetref="[object Object]"
Expand Down Expand Up @@ -175,7 +210,7 @@ exports[`Individual Matches snapshot 1`] = `
<button
aria-describedby="v-tooltip-4"
aria-describedby="v-tooltip-6"
aria-label="Add to workspace"
class="v-btn v-btn--icon v-theme--light v-btn--density-default v-btn--size-small v-btn--variant-text mr-1"
targetref="[object Object]"
Expand Down Expand Up @@ -209,7 +244,7 @@ exports[`Individual Matches snapshot 1`] = `
<button
aria-describedby="v-tooltip-6"
aria-describedby="v-tooltip-8"
aria-label="Lock"
class="v-btn v-btn--icon v-theme--light v-btn--density-default v-btn--size-small v-btn--variant-text mr-1"
targetref="[object Object]"
Expand Down Expand Up @@ -246,7 +281,7 @@ exports[`Individual Matches snapshot 1`] = `
aria-expanded="false"
aria-haspopup="menu"
aria-label="See more actions"
aria-owns="v-menu-8"
aria-owns="v-menu-10"
class="v-btn v-btn--icon v-theme--light v-btn--density-default v-btn--size-small v-btn--variant-text"
targetref="[object Object]"
type="button"
Expand Down Expand Up @@ -310,7 +345,7 @@ exports[`Individual Matches snapshot 1`] = `
<button
aria-expanded="false"
aria-haspopup="menu"
aria-owns="v-menu-10"
aria-owns="v-menu-12"
class="hide-icon"
targetref="[object Object]"
>
Expand Down Expand Up @@ -346,7 +381,7 @@ exports[`Individual Matches snapshot 1`] = `
<button
aria-expanded="false"
aria-haspopup="menu"
aria-owns="v-menu-11"
aria-owns="v-menu-13"
class="hide-icon"
targetref="[object Object]"
>
Expand Down Expand Up @@ -382,7 +417,7 @@ exports[`Individual Matches snapshot 1`] = `
<button
aria-expanded="false"
aria-haspopup="menu"
aria-owns="v-menu-12"
aria-owns="v-menu-14"
class="hide-icon"
targetref="[object Object]"
>
Expand Down Expand Up @@ -503,7 +538,7 @@ exports[`Individual Matches snapshot 1`] = `
<i
aria-describedby="v-tooltip-15"
aria-describedby="v-tooltip-17"
aria-hidden="true"
class="mdi-git mdi v-icon notranslate v-theme--light v-icon--size-default"
targetref="[object Object]"
Expand Down Expand Up @@ -534,7 +569,7 @@ exports[`Individual Matches snapshot 1`] = `
<span
aria-describedby="v-tooltip-16"
aria-describedby="v-tooltip-18"
class="v-chip v-chip--link v-theme--light v-chip--density-default v-chip--size-default v-chip--variant-outlined text-center mr-6"
draggable="false"
tabindex="0"
Expand Down Expand Up @@ -614,7 +649,7 @@ exports[`Individual Matches snapshot 1`] = `
<button
aria-describedby="v-tooltip-18"
aria-describedby="v-tooltip-20"
class="v-btn v-btn--icon v-theme--light v-btn--density-default v-btn--size-small v-btn--variant-text"
targetref="[object Object]"
type="button"
Expand Down Expand Up @@ -687,7 +722,7 @@ exports[`Individual Matches snapshot 1`] = `
<i
aria-describedby="v-tooltip-22"
aria-describedby="v-tooltip-24"
aria-hidden="true"
class="mdi-github mdi v-icon notranslate v-theme--light v-icon--size-default"
targetref="[object Object]"
Expand Down Expand Up @@ -718,7 +753,7 @@ exports[`Individual Matches snapshot 1`] = `
<span
aria-describedby="v-tooltip-23"
aria-describedby="v-tooltip-25"
class="v-chip v-chip--link v-theme--light v-chip--density-default v-chip--size-default v-chip--variant-outlined text-center mr-6"
draggable="false"
tabindex="0"
Expand Down Expand Up @@ -808,7 +843,7 @@ exports[`Individual Matches snapshot 1`] = `
<button
aria-describedby="v-tooltip-25"
aria-describedby="v-tooltip-27"
class="v-btn v-btn--icon v-theme--light v-btn--density-default v-btn--size-small v-btn--variant-text"
targetref="[object Object]"
type="button"
Expand Down Expand Up @@ -896,7 +931,7 @@ exports[`Individual Matches snapshot 1`] = `
<span
aria-describedby="v-tooltip-30"
aria-describedby="v-tooltip-32"
class="v-chip v-chip--link v-theme--light v-chip--density-default v-chip--size-default v-chip--variant-outlined text-center mr-6"
draggable="false"
tabindex="0"
Expand Down Expand Up @@ -982,7 +1017,7 @@ exports[`Individual Matches snapshot 1`] = `
<button
aria-describedby="v-tooltip-32"
aria-describedby="v-tooltip-34"
class="v-btn v-btn--icon v-theme--light v-btn--density-default v-btn--size-small v-btn--variant-text"
targetref="[object Object]"
type="button"
Expand Down Expand Up @@ -1070,7 +1105,7 @@ exports[`Individual Matches snapshot 1`] = `
<span
aria-describedby="v-tooltip-37"
aria-describedby="v-tooltip-39"
class="v-chip v-chip--link v-theme--light v-chip--density-default v-chip--size-default v-chip--variant-outlined text-center mr-6"
draggable="false"
tabindex="0"
Expand Down Expand Up @@ -1158,7 +1193,7 @@ exports[`Individual Matches snapshot 1`] = `
<button
aria-describedby="v-tooltip-39"
aria-describedby="v-tooltip-41"
class="v-btn v-btn--icon v-theme--light v-btn--density-default v-btn--size-small v-btn--variant-text"
targetref="[object Object]"
type="button"
Expand Down
Loading

0 comments on commit 2f2974b

Please sign in to comment.