From 925f1a8500211cfdba7555c73b40ca82168877b1 Mon Sep 17 00:00:00 2001
From: karolina-siemieniuk-morawska
<55505399+karolina-siemieniuk-morawska@users.noreply.github.com>
Date: Mon, 26 Aug 2024 11:58:25 +0200
Subject: [PATCH] ui: display decision on completed workflows in new holdingpen
* ref: cern-sis/issues-inspire#518
---
ui/src/holdingpen-new/components/Links.tsx | 18 ++-
.../ResultItem/AuthorResultItem.tsx | 17 +--
.../__tests__/AuthorResultItem.test.tsx | 6 +-
.../AuthorDetailPageContainer.tsx | 127 ++++++++++--------
.../AuthorDetailPageContainer.test.tsx.snap | 4 +-
ui/src/holdingpen-new/utils/utils.tsx | 15 +++
6 files changed, 113 insertions(+), 74 deletions(-)
diff --git a/ui/src/holdingpen-new/components/Links.tsx b/ui/src/holdingpen-new/components/Links.tsx
index 2506d2248..7de6d70d5 100644
--- a/ui/src/holdingpen-new/components/Links.tsx
+++ b/ui/src/holdingpen-new/components/Links.tsx
@@ -18,22 +18,30 @@ function getLinkData(schema: string, value: string) {
case 'LINKEDIN':
return {
href: `https://www.linkedin.com/in/${value}`,
- icon: ,
+ icon: ,
};
case 'TWITTER':
return {
href: `https://twitter.com/${value}`,
- icon: ,
+ icon: ,
};
case 'ORCID':
return {
href: `https://orcid.org/my-orcid?orcid=${value}`,
- icon: ,
+ icon: (
+
+ ),
};
default:
return {
href: value,
- icon: ,
+ icon: ,
};
}
}
@@ -47,7 +55,7 @@ export const Ids: React.FC<{ ids: Map; noIcon?: boolean }> = ({
{!noIcon && getLinkData(link?.get('schema'), link?.get('value'))?.icon}
{link?.get('schema') && (
- {link?.get('schema').toLowerCase()}:
+ {link?.get('schema').toLowerCase()}:
)}{' '}
{
- const decisions: { [key: string]: { bg: string; text: string } } = {
- accept: { bg: 'bg-halted ml1', text: 'Accept' },
- accept_curate: { bg: 'bg-halted ml1', text: 'Accept Curate' },
- reject: { bg: 'bg-error font-white', text: 'Reject' },
- };
- return decisions[decision] || null;
-};
+import { resolveDecision } from '../../utils/utils';
const renderWorkflowStatus = (status: string) => {
const statuses: {
@@ -65,6 +57,7 @@ const renderWorkflowStatus = (status: string) => {
const AuthorResultItem = ({ item }: { item: any }) => {
const data = item?.get('data');
+ const decision = item?.get('decisions')?.first();
return (
@@ -93,13 +86,13 @@ const AuthorResultItem = ({ item }: { item: any }) => {
Update
>
)}
- {item?.get('user_action') && (
+ {decision && (
- {resolveDecision(item?.get('user_action'))?.text}
+ {resolveDecision(decision?.get('action'))?.text}
)}
diff --git a/ui/src/holdingpen-new/components/ResultItem/__tests__/AuthorResultItem.test.tsx b/ui/src/holdingpen-new/components/ResultItem/__tests__/AuthorResultItem.test.tsx
index e777c2306..328ecfd99 100644
--- a/ui/src/holdingpen-new/components/ResultItem/__tests__/AuthorResultItem.test.tsx
+++ b/ui/src/holdingpen-new/components/ResultItem/__tests__/AuthorResultItem.test.tsx
@@ -13,8 +13,12 @@ describe('AuthorResultItem component', () => {
const item = fromJS({
id: '123',
workflow_type: 'AUTHOR_UPDATE',
- user_action: 'accept',
status: 'completed',
+ decisions: fromJS([
+ {
+ action: 'accept',
+ },
+ ]),
data: fromJS({
name: fromJS({
value: 'Doe, John',
diff --git a/ui/src/holdingpen-new/containers/DetailPageContainer/AuthorDetailPageContainer.tsx b/ui/src/holdingpen-new/containers/DetailPageContainer/AuthorDetailPageContainer.tsx
index 321a5a64f..6cb81475e 100644
--- a/ui/src/holdingpen-new/containers/DetailPageContainer/AuthorDetailPageContainer.tsx
+++ b/ui/src/holdingpen-new/containers/DetailPageContainer/AuthorDetailPageContainer.tsx
@@ -26,6 +26,7 @@ import {
columnsAdvisors,
} from './columnData';
import { getConfigFor } from '../../../common/config';
+import { resolveDecision } from '../../utils/utils';
interface AuthorDetailPageContainerProps {
dispatch: ActionCreator;
@@ -48,6 +49,8 @@ const AuthorDetailPageContainer: React.FC = ({
const data = author?.get('data') as Map;
const tickets = author?.get('tickets') as Map;
+ const decision = author?.get('decisions')?.first();
+
const ERRORS_URL = getConfigFor('INSPIRE_WORKFLOWS_DAGS_URL');
const OPEN_SECTIONS = [
@@ -99,21 +102,23 @@ const AuthorDetailPageContainer: React.FC = ({
)}
{data?.get('status') && (
-
+
Status: {data?.get('status')}
)}
{(data?.get('ids') as any[])?.find(
(id: any) => id?.get('schema') === 'ORCID'
) && (
- id?.get('schema') === 'ORCID'
- ) as unknown as Map
- }
- noIcon
- />
+
+ id?.get('schema') === 'ORCID'
+ ) as unknown as Map
+ }
+ noIcon
+ />
+
)}
@@ -197,56 +202,68 @@ const AuthorDetailPageContainer: React.FC = ({
{author?.get('status') &&
- author?.get('status') === 'approval' && (
+ author?.get('status') !== 'error' &&
+ author?.get('status') !== 'running' && (
-
-
-
-
-
+ {author?.get('status') === 'approval' ? (
+
+
+
+
+
+ ) : (
+
+ This workflow is{' '}
+
+ {resolveDecision(decision?.get('action'))
+ ?.decision || 'completed'}
+
+ .
+
+ )}
)}
= ({
target="_blank"
>
{' '}
- #{tickets?.first().get('ticket_id')}
+ #{tickets?.first()?.get('ticket_id')}
)}
diff --git a/ui/src/holdingpen-new/containers/DetailPageContainer/__tests__/__snapshots__/AuthorDetailPageContainer.test.tsx.snap b/ui/src/holdingpen-new/containers/DetailPageContainer/__tests__/__snapshots__/AuthorDetailPageContainer.test.tsx.snap
index 4ecc942c5..b494b62b7 100644
--- a/ui/src/holdingpen-new/containers/DetailPageContainer/__tests__/__snapshots__/AuthorDetailPageContainer.test.tsx.snap
+++ b/ui/src/holdingpen-new/containers/DetailPageContainer/__tests__/__snapshots__/AuthorDetailPageContainer.test.tsx.snap
@@ -196,7 +196,9 @@ exports[`AuthorDetailPageContainer should render the AuthorDetailPageContainer 1
Johnny
-
+
Status:
diff --git a/ui/src/holdingpen-new/utils/utils.tsx b/ui/src/holdingpen-new/utils/utils.tsx
index 7291317f0..fb9423a79 100644
--- a/ui/src/holdingpen-new/utils/utils.tsx
+++ b/ui/src/holdingpen-new/utils/utils.tsx
@@ -55,3 +55,18 @@ export const refreshToken = async () => {
return null;
};
+
+export const resolveDecision = (decision: string | number) => {
+ const decisions: {
+ [key: string]: { bg: string; text: string; decision: string };
+ } = {
+ accept: { bg: 'bg-halted ml1', text: 'Accept', decision: 'accepted' },
+ accept_curate: {
+ bg: 'bg-halted ml1',
+ text: 'Accept Curate',
+ decision: 'accepted with curation',
+ },
+ reject: { bg: 'bg-error font-white', text: 'Reject', decision: 'rejected' },
+ };
+ return decisions[decision] || null;
+};