Skip to content

Commit

Permalink
Returning null earlier. Reducing code.
Browse files Browse the repository at this point in the history
  • Loading branch information
erinesullivan committed Aug 22, 2023
1 parent 1d48ef1 commit 59bf075
Showing 1 changed file with 31 additions and 39 deletions.
70 changes: 31 additions & 39 deletions src/modules/records/components/RecordPreview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,55 +68,47 @@ Header.propTypes = {
};

const Footer = ({ record, datastoreUid }) => {
// No access/holding options for Mirlyn for preview records.
if (datastoreUid === 'mirlyn' || datastoreUid === 'website') {
// No access/holding options or are Catalog or Guides and More datastores.
if (['mirlyn', 'website'].includes(datastoreUid) || !(record.resourceAccess && record.resourceAccess[0])) {
return null;
}

const outage = getFieldValue(getField(record.fields, 'outage'))[0];

if (record.resourceAccess && record.resourceAccess[0]) {
return (
<>
{outage && (
return (
<>
{outage && (
<p
style={{
color: INTENT_COLORS.error,
marginBottom: '0',
marginTop: '0.5rem'
}}
>
<Icon icon='warning' /> {outage}
</p>
)}
{record.resourceAccess[0].rows.map((row, index) => {
const accessCell = row[0];
if (!accessCell?.previewEligible) {
return null;
}
return (
<p
className='record-preview-link'
style={{
color: INTENT_COLORS.error,
marginBottom: '0',
marginTop: '0.5rem'
marginBottom: '0'
}}
key={record.uid + '-resource-' + index}
>
<Icon icon='warning' /> {outage}
<a href={accessCell.href}>
{accessCell.text}
</a>
</p>
)}
{record.resourceAccess[0].rows.map((row) => {
const accessCell = row[0];
if (accessCell && accessCell.previewEligible) {
return (
<p
className='record-preview-link'
style={{
marginBottom: '0'
}}
key={accessCell.href}
>
<a href={accessCell.href}>
{accessCell.text}
</a>
</p>
);
} else {
return null;
}
})}
</>
);
}

// TODO
// Add "Go to <thing>" here with resource access component.

return null;
);
})}
</>
);
};

Footer.propTypes = {
Expand Down

0 comments on commit 59bf075

Please sign in to comment.