Skip to content

Commit

Permalink
Fix notes field breaking table in classifications editor preview (#3055)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcnulty authored Sep 9, 2024
1 parent 4276f5d commit 2883429
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions site/gatsby-site/src/components/taxa/Taxonomy.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,27 @@ const Taxonomy = ({ taxonomy, incidentId, reportNumber, canEdit, initialEditing
${singleColumn ? 'grid-cols-[1fr_3fr]' : 'lg:grid-cols-[repeat(4,_auto)]'}
`}
>
{canEdit && (
<div key={'NOTES'} className="tw-classification-container">
<div className="tw-field">
<Tooltip content={'Admin notes'}>
<p>{'Notes'}</p>
</Tooltip>
</div>
<Markdown>{taxonomy.notes}</Markdown>
</div>
)}
{(showAllClassifications ? taxonomy.classificationsArray : topClassifications)
.filter(
(field) => !(field.renderAs === 'description_toggle' && field.value == 'No')
{['dummy-notes']
.concat(
(showAllClassifications
? taxonomy.classificationsArray
: topClassifications.slice(canEdit ? 1 : 0)

Check warning on line 119 in site/gatsby-site/src/components/taxa/Taxonomy.js

View check run for this annotation

Codecov / codecov/patch

site/gatsby-site/src/components/taxa/Taxonomy.js#L118-L119

Added lines #L118 - L119 were not covered by tests
)
.filter(
(field) => !(field.renderAs === 'description_toggle' && field.value == 'No')
)
.map((field) => {

Check warning on line 124 in site/gatsby-site/src/components/taxa/Taxonomy.js

View check run for this annotation

Codecov / codecov/patch

site/gatsby-site/src/components/taxa/Taxonomy.js#L124

Added line #L124 was not covered by tests
if (field.renderAs === 'description_toggle') {
return { ...field, value: field.longDescription };

Check warning on line 126 in site/gatsby-site/src/components/taxa/Taxonomy.js

View check run for this annotation

Codecov / codecov/patch

site/gatsby-site/src/components/taxa/Taxonomy.js#L126

Added line #L126 was not covered by tests
}

return field;

Check warning on line 129 in site/gatsby-site/src/components/taxa/Taxonomy.js

View check run for this annotation

Codecov / codecov/patch

site/gatsby-site/src/components/taxa/Taxonomy.js#L129

Added line #L129 was not covered by tests
})
)
.map((field) => {
if (field.renderAs === 'description_toggle') {
return { ...field, value: field.longDescription };
}

return field;
})
.filter((field) => canEdit || field !== 'dummy-notes')
.map((field, i) => {
const showNotes = field === 'dummy-notes';

Check warning on line 134 in site/gatsby-site/src/components/taxa/Taxonomy.js

View check run for this annotation

Codecov / codecov/patch

site/gatsby-site/src/components/taxa/Taxonomy.js#L134

Added line #L134 was not covered by tests

const isFirst = singleColumn ? i == 0 : i < 2;

const isLast = singleColumn
Expand All @@ -154,11 +153,15 @@ const Taxonomy = ({ taxonomy, incidentId, reportNumber, canEdit, initialEditing
${isLast ? 'border-b-0' : ''}
`}
>
<Tooltip content={field.shortDescription}>
<p>
{field.name} {field.renderAs}
</p>
</Tooltip>
{showNotes ? (
<p>Notes</p>

Check warning on line 157 in site/gatsby-site/src/components/taxa/Taxonomy.js

View check run for this annotation

Codecov / codecov/patch

site/gatsby-site/src/components/taxa/Taxonomy.js#L157

Added line #L157 was not covered by tests
) : (
<Tooltip content={field.shortDescription}>

Check warning on line 159 in site/gatsby-site/src/components/taxa/Taxonomy.js

View check run for this annotation

Codecov / codecov/patch

site/gatsby-site/src/components/taxa/Taxonomy.js#L159

Added line #L159 was not covered by tests
<p>
{field.name} {field.renderAs}
</p>
</Tooltip>
)}
</div>
<Markdown
className={`
Expand All @@ -172,7 +175,7 @@ const Taxonomy = ({ taxonomy, incidentId, reportNumber, canEdit, initialEditing
${isLast ? 'border-b-0' : ''}
`}
>
{field.value}
{showNotes ? taxonomy.notes : field.value}

Check warning on line 178 in site/gatsby-site/src/components/taxa/Taxonomy.js

View check run for this annotation

Codecov / codecov/patch

site/gatsby-site/src/components/taxa/Taxonomy.js#L178

Added line #L178 was not covered by tests
</Markdown>
</>
);
Expand Down

0 comments on commit 2883429

Please sign in to comment.