Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display status in actiondashboard phase tooltip #179

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions common/__generated__/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions components/dashboard/ActionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ const actionFragment = gql`
}
statusSummary {
identifier
label
color
}
timeliness {
identifier
Expand Down
106 changes: 65 additions & 41 deletions components/dashboard/ActionTableTooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import dayjs from 'common/dayjs';
import { getActionTaskTermContext, getActionTermContext } from 'common/i18n';
import Icon from 'components/common/Icon';

const TooltipTitle = styled.p`
font-weight: ${(props) => props.theme.fontWeightBold};
margin-bottom: ${(props) => props.theme.spaces.s025};
`;

const ResponsibleTooltipList = styled.ul`
margin: 0;
padding: 0;
Expand All @@ -24,9 +29,28 @@ const PhasesTooltipListItem = styled.li`

const TaskTooltip = styled.div``;

const StatusLabel = styled.div`
&:before {
content: '';
display: inline-block;
width: 1em;
height: 1em;
margin-right: 0.5em;
margin-bottom: -0.1em;
border-radius: 50%;
background-color: ${(props) => props.theme.graphColors[props.color]};
color: ${(props) => props.theme.graphColors[props.color]};
}
`;

const Divider = styled.div`
margin: ${(props) => props.theme.spaces.s025} 0;
border-bottom: 1px solid ${(props) => props.theme.graphColors.grey030};
`;

export const primaryOrgTooltipContent = (t, primaryOrg) => (
<div>
<h5>{t('common:primary-organization')}</h5>
<TooltipTitle>{t('common:primary-organization')}</TooltipTitle>
{primaryOrg}
</div>
);
Expand All @@ -35,12 +59,16 @@ export const tasksTooltipContent = (plan, t, taskCounts) => {
if (taskCounts.total < 1)
return (
<div>
<h5>{t('actions:action-no-tasks', getActionTaskTermContext(plan))}</h5>
<TooltipTitle>
{t('actions:action-no-tasks', getActionTaskTermContext(plan))}
</TooltipTitle>
</div>
);
return (
<TaskTooltip>
<h5>{t('actions:action-tasks', getActionTaskTermContext(plan))} </h5>
<TooltipTitle>
{t('actions:action-tasks', getActionTaskTermContext(plan))}{' '}
</TooltipTitle>
<table>
<tbody>
{taskCounts.completed > 0 && (
Expand Down Expand Up @@ -80,40 +108,41 @@ export const phasesTooltipContent = (
plan
) => {
const getMergedName = (mergedWith, planId) => {
if (mergedWith.plan.id !== planId)
if (mergedWith.plan.id !== planId) {
return `${mergedWith.plan.shortName} ${mergedWith.identifier}`;
else return mergedWith.identifier;
} else {
return mergedWith.identifier;
}
};

if (merged)
return (
<div>
<h5>
{` ${t(
'actions:action-status-merged',
getActionTermContext(plan)
)}: ${getMergedName(merged, plan.id)}.`}
</h5>
</div>
);
if (!activePhase)
return (
<div>
{!status?.name && (
<h5>{t('actions:action-implementation-phase-unknown')}</h5>
)}
{status?.name}
</div>
);
if (status?.identifier === 'cancelled')
const statusDisplay = (
<StatusLabel color={status?.color}>{status.label}</StatusLabel>
);
// If action is merged, display merged status
if (merged) {
return (
<div>
<h5>{status.name}</h5>
</div>
<TooltipTitle>
{` ${t(
'actions:action-status-merged',
getActionTermContext(plan)
)}: ${getMergedName(merged, plan.id)}.`}
</TooltipTitle>
);
return hasImplementationPhases ? (
}
// If action has no active phase or it's cancelled, or plan has no implementation phases : display only status
if (
!activePhase ||
status?.identifier === 'cancelled' ||
terotik marked this conversation as resolved.
Show resolved Hide resolved
!hasImplementationPhases
) {
return statusDisplay;
terotik marked this conversation as resolved.
Show resolved Hide resolved
}

return (
<div>
<h5>{t('actions:action-implementation-phase')}</h5>
{statusDisplay}
<Divider />
<TooltipTitle>{t('actions:action-implementation-phase')}:</TooltipTitle>
<PhasesTooltipList>
{plan.actionImplementationPhases.map((phase) => (
<PhasesTooltipListItem
Expand All @@ -128,24 +157,19 @@ export const phasesTooltipContent = (
))}
</PhasesTooltipList>
</div>
) : (
<div>
<h5>Status</h5>
{status.name}
</div>
);
};

export const responsiblesTooltipContent = (t, theme, parties) => {
if (parties.length < 1)
return (
<div>
<h5>{t('common:responsible-parties')}</h5>
<TooltipTitle>{t('common:responsible-parties')}</TooltipTitle>
</div>
);
return (
<div>
<h5>{t('common:responsible-parties')}</h5>
<TooltipTitle>{t('common:responsible-parties')}</TooltipTitle>
{parties.find((party) => party.hasContactPerson) && (
<strong>{t('common:with-contact-persons')}:</strong>
)}
Expand Down Expand Up @@ -193,7 +217,7 @@ export const indicatorsTooltipContent = (t, theme, relatedIndicators) => {
);
return (
<div>
<h5>{t('common:indicators')}</h5>
<TooltipTitle>{t('common:indicators')}</TooltipTitle>
<Icon
name="tachometer"
color={
Expand Down Expand Up @@ -224,7 +248,7 @@ export const indicatorsTooltipContent = (t, theme, relatedIndicators) => {

export const lastUpdatedTooltipContent = (t, updateDate) => (
<div>
<h5>{t('common:latest-update')}</h5>
<TooltipTitle>{t('common:latest-update')}</TooltipTitle>
{dayjs(updateDate).format('L')}
</div>
);
Expand All @@ -234,7 +258,7 @@ export const impactTooltipContent = (t, impact, impacts) => {
const activeImpact = impacts.find((item) => item.id === impact.id);
return (
<div>
<h5>{t('common:impact')}</h5>
<TooltipTitle>{t('common:impact')}</TooltipTitle>
{activeImpact.identifier !== '0' && (
<div>
{activeImpact.identifier}/{impacts.length - 1}
Expand Down