Skip to content

Commit

Permalink
ui: display decision on completed workflows in new holdingpen
Browse files Browse the repository at this point in the history
  • Loading branch information
karolina-siemieniuk-morawska committed Aug 26, 2024
1 parent dc1a945 commit 925f1a8
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 74 deletions.
18 changes: 13 additions & 5 deletions ui/src/holdingpen-new/components/Links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,30 @@ function getLinkData(schema: string, value: string) {
case 'LINKEDIN':
return {
href: `https://www.linkedin.com/in/${value}`,
icon: <LinkedinOutlined />,
icon: <LinkedinOutlined className="mr1" />,
};
case 'TWITTER':
return {
href: `https://twitter.com/${value}`,
icon: <TwitterOutlined />,
icon: <TwitterOutlined className="mr1" />,
};
case 'ORCID':
return {
href: `https://orcid.org/my-orcid?orcid=${value}`,
icon: <img src={orcidLogo} alt="ORCID" width={16} height={16} />,
icon: (
<img
src={orcidLogo}
alt="ORCID"
width={16}
height={16}
className="mr1"
/>
),
};
default:
return {
href: value,
icon: <LinkOutlined />,
icon: <LinkOutlined className="mr1" />,
};
}
}
Expand All @@ -47,7 +55,7 @@ export const Ids: React.FC<{ ids: Map<string, any>; noIcon?: boolean }> = ({
<p key={link?.get('value')} className={noIcon ? 'mb0' : ''}>
{!noIcon && getLinkData(link?.get('schema'), link?.get('value'))?.icon}
{link?.get('schema') && (
<b className="dib ml1 ttc">{link?.get('schema').toLowerCase()}:</b>
<b className="dib ttc">{link?.get('schema').toLowerCase()}:</b>
)}{' '}
<a
href={getLinkData(link?.get('schema'), link?.get('value'))?.href}
Expand Down
17 changes: 5 additions & 12 deletions ui/src/holdingpen-new/components/ResultItem/AuthorResultItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ import PublicationSelectContainer from '../../../authors/containers/PublicationS
import ResultItem from '../../../common/components/ResultItem';
import UnclickableTag from '../../../common/components/UnclickableTag';
import { HOLDINGPEN_NEW } from '../../../common/routes';

const resolveDecision = (decision: string | number) => {
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: {
Expand Down Expand Up @@ -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 (
<div className="result-item result-item-action mv2">
Expand Down Expand Up @@ -93,13 +86,13 @@ const AuthorResultItem = ({ item }: { item: any }) => {
<UnclickableTag color="processing">Update</UnclickableTag>
</>
)}
{item?.get('user_action') && (
{decision && (
<UnclickableTag
className={`decission-pill ${resolveDecision(
item?.get('user_action')
decision?.get('action')
)?.bg}`}
>
{resolveDecision(item?.get('user_action'))?.text}
{resolveDecision(decision?.get('action'))?.text}
</UnclickableTag>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
columnsAdvisors,
} from './columnData';
import { getConfigFor } from '../../../common/config';
import { resolveDecision } from '../../utils/utils';

interface AuthorDetailPageContainerProps {
dispatch: ActionCreator<Action>;
Expand All @@ -48,6 +49,8 @@ const AuthorDetailPageContainer: React.FC<AuthorDetailPageContainerProps> = ({

const data = author?.get('data') as Map<any, any>;
const tickets = author?.get('tickets') as Map<any, any>;
const decision = author?.get('decisions')?.first();

const ERRORS_URL = getConfigFor('INSPIRE_WORKFLOWS_DAGS_URL');

const OPEN_SECTIONS = [
Expand Down Expand Up @@ -99,21 +102,23 @@ const AuthorDetailPageContainer: React.FC<AuthorDetailPageContainerProps> = ({
</p>
)}
{data?.get('status') && (
<p>
<p className="mb0">
<b>Status:</b> {data?.get('status')}
</p>
)}
{(data?.get('ids') as any[])?.find(
(id: any) => id?.get('schema') === 'ORCID'
) && (
<Ids
ids={
(data?.get('ids') as any[])?.filter(
(id: any) => id?.get('schema') === 'ORCID'
) as unknown as Map<string, any>
}
noIcon
/>
<p className="mt3 mb0">
<Ids
ids={
(data?.get('ids') as any[])?.filter(
(id: any) => id?.get('schema') === 'ORCID'
) as unknown as Map<string, any>
}
noIcon
/>
</p>
)}
</ContentBox>
<CollapsableForm openSections={OPEN_SECTIONS}>
Expand Down Expand Up @@ -197,56 +202,68 @@ const AuthorDetailPageContainer: React.FC<AuthorDetailPageContainerProps> = ({
</Col>
<Col xs={24} lg={8}>
{author?.get('status') &&
author?.get('status') === 'approval' && (
author?.get('status') !== 'error' &&
author?.get('status') !== 'running' && (
<ContentBox
className="mb3"
fullHeight={false}
subTitle="Decision"
>
<div className="w-100 flex flex-column items-center">
<Button
className="font-white bg-completed w-75 mb2"
onClick={() =>
dispatch(
resolveAction(id, 'resolve', {
value: 'accept',
create_ticket: false,
})
)
}
loading={actionInProgress === 'resolve'}
>
Accept
</Button>
<Button
className="font-white bg-halted w-75 mb2"
onClick={() =>
dispatch(
resolveAction(id, 'resolve', {
value: 'accept_curate',
create_ticket: false,
})
)
}
loading={actionInProgress === 'resolve'}
>
Accept + Curation
</Button>
<Button
className="font-white bg-error w-75"
onClick={() =>
dispatch(
resolveAction(id, 'resolve', {
value: 'reject',
create_ticket: false,
})
)
}
loading={actionInProgress === 'resolve'}
>
Reject
</Button>
</div>
{author?.get('status') === 'approval' ? (
<div className="w-100 flex flex-column items-center">
<Button
className="font-white bg-completed w-75 mb2"
onClick={() =>
dispatch(
resolveAction(id, 'resolve', {
value: 'accept',
create_ticket: false,
})
)
}
loading={actionInProgress === 'resolve'}
>
Accept
</Button>
<Button
className="font-white bg-halted w-75 mb2"
onClick={() =>
dispatch(
resolveAction(id, 'resolve', {
value: 'accept_curate',
create_ticket: false,
})
)
}
loading={actionInProgress === 'resolve'}
>
Accept + Curation
</Button>
<Button
className="font-white bg-error w-75"
onClick={() =>
dispatch(
resolveAction(id, 'resolve', {
value: 'reject',
create_ticket: false,
})
)
}
loading={actionInProgress === 'resolve'}
>
Reject
</Button>
</div>
) : (
<p className="mb0">
This workflow is{' '}
<b>
{resolveDecision(decision?.get('action'))
?.decision || 'completed'}
</b>
.
</p>
)}
</ContentBox>
)}
<ContentBox
Expand Down Expand Up @@ -291,7 +308,7 @@ const AuthorDetailPageContainer: React.FC<AuthorDetailPageContainerProps> = ({
target="_blank"
>
{' '}
#{tickets?.first().get('ticket_id')}
#{tickets?.first()?.get('ticket_id')}
</a>
</p>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ exports[`AuthorDetailPageContainer should render the AuthorDetailPageContainer 1
</b>
Johnny
</p>
<p>
<p
class="mb0"
>
<b>
Status:
</b>
Expand Down
15 changes: 15 additions & 0 deletions ui/src/holdingpen-new/utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 925f1a8

Please sign in to comment.