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

ERM-3119 Add Organisation status to organisation card display #655

Merged
merged 5 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion lib/OrganizationsFieldArray/EditOrganizationCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const EditOrganizationCard = ({
setDuplicateWarning(true);
setNOONL(o.name);
} else {
const org = { name: o.name, orgsUuid: o.id };
const org = { name: o.name, orgsUuid: o.id, status: o.status };
onUpdate(i, { org });
}
};
Expand Down
74 changes: 42 additions & 32 deletions lib/ViewOrganizationCard/ViewOrganizationCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,22 @@ const ViewOrganizationCard = ({
})
);

const renderOrganizationName = (name) => (
<KeyValue label={<FormattedMessage id="stripes-erm-components.viewOrg.name" />}>
<span
data-test-org-name
id={`${id}-name`}
>
{name}
</span>
</KeyValue>
);
const renderOrganizationName = (name) => {
const orgStatus = org.orgsUuid_object?.status ? org.orgsUuid_object.status :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CalamityC For brevity, in future this can be written org.orgsUuid_object?.status ?? org?.status. Not going to block this merge for that though, it can be tweaked later if we want.

(org?.status ? org.status : null);
return (
<KeyValue label={<FormattedMessage id="stripes-erm-components.viewOrg.name" />}>
<span
data-test-org-name
id={`${id}-name`}
>
{name}
{orgStatus ? ' · ' : null}
{orgStatus ? <FormattedMessage id={`ui-organizations.organizationStatus.${orgStatus.toLowerCase()}`} /> : null}
</span>
</KeyValue>
);
};

const renderError = (error) => (
<Layout className={`textCentered ${css.error}`}>
Expand All @@ -180,16 +186,16 @@ const ViewOrganizationCard = ({
<Layout className="textCentered">
<FormattedMessage id="stripes-erm-components.organizations.linkOrganizationToStart" />
</Layout>
{ duplicateWarning &&
<Layout className="padding-top-gutter">
<MessageBanner
dismissable
onExited={() => setDuplicateWarning(false)}
type="error"
>
{duplicateMessage}
</MessageBanner>
</Layout> }
{duplicateWarning &&
<Layout className="padding-top-gutter">
<MessageBanner
dismissable
onExited={() => setDuplicateWarning(false)}
type="error"
>
{duplicateMessage}
</MessageBanner>
</Layout>}
</div>
{meta && meta.error && meta.touched ? renderError(meta.error) : null}
</>
Expand All @@ -205,7 +211,11 @@ const ViewOrganizationCard = ({
}

if (hasOrgData) {
return renderOrganizationName(org.name);
return (
<>
{renderOrganizationName(org.name)}
</>
);
}

return renderEmpty();
Expand All @@ -220,17 +230,17 @@ const ViewOrganizationCard = ({
headerStart={headerStart}
roundedBorder
>
{ roles?.length && <KeyValue label={<FormattedMessage id="stripes-erm-components.organizations.roles" />}>{renderRoles()}</KeyValue> }
{ note &&
<KeyValue label={<FormattedMessage id="stripes-erm-components.organizations.note" />}>
<div
data-test-org-note
id={`${id}-note`}
>
{note}
</div>
</KeyValue>
}
{roles?.length && <KeyValue label={<FormattedMessage id="stripes-erm-components.organizations.roles" />}>{renderRoles()}</KeyValue>}
{note &&
<KeyValue label={<FormattedMessage id="stripes-erm-components.organizations.note" />}>
<div
data-test-org-note
id={`${id}-note`}
>
{note}
</div>
</KeyValue>
}
{renderCard()}
</Card>
</div>
Expand Down
Loading