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

fix(control): controls display id instead of label #746

Merged
merged 6 commits into from
Mar 27, 2023

Conversation

kylelaker
Copy link
Contributor

@kylelaker kylelaker commented Mar 24, 2023

Currently, controls are often displayed with their id in uppercase instead of using the label property. This means that the display is not necessarily always what a document author may intend (even if it perhaps is close).

The label is displayed matching the surrounding content. If the ID is used, it falls back to displaying using the ID (in our standard grey color).

This also fixes an issue where, for prose, the label was squished up against the text without a space.

Screenshots - Test Catalog

Before

image

After

image

Screenshots - SP 800-53

Before

image

After

image

Controls would display the `id` field a lot except for the like one
place where we did properly lookup the label. This adds a new generic
way to query for props by name (ignoring value). This retains `id` as a
fallback as a bridge way to move to identifying whether that is better
or if we should instead just not display anything label-like at all. The
latter requires far larger refactoring.
@easy-dynamics-oscal-automation easy-dynamics-oscal-automation bot requested a review from a team March 24, 2023 20:44
@easy-dynamics-oscal-automation easy-dynamics-oscal-automation bot requested a review from a team March 27, 2023 16:59
Copy link
Contributor Author

@kylelaker kylelaker left a comment

Choose a reason for hiding this comment

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

@@ -24,7 +24,7 @@ function testOSCALProfile(parentElementName, renderer) {
jest.setTimeout(6000);
test(`${parentElementName} displays controls`, async () => {
renderer();
const result = await screen.findByText("ac-1", {
const result = await screen.findByText("AC-1", {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This changes because we now properly use the label which does specify the value in uppercase.

@@ -58,7 +74,7 @@ describe("OSCALCatalogGroup", () => {
fireEvent.click(expand2);

const expand3 = screen.getByText(
"CONTROL-ID Access Control Policy and Procedures"
getTextByChildren("control-id Access Control Policy and Procedures")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now lowercase because we make the text uppercase in CSS instead of by calling toUppercase.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, so smart!

@@ -35,6 +35,22 @@ const testGroups = [
},
];

function getTextByChildren(text) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is necessary because we're now potentially pulling text across multiple <span>s.

@@ -488,7 +486,7 @@ export function OSCALReplacedProseWithByComponentParameterValue(props) {
<Link underline="hover" href={`#${props.label}`}>
{props.label}
</Link>
</StyledTooltip>
</StyledTooltip>{" "}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the issue with the label being "squished" up against the actual text. Same for the changes above where {props.label} and {prose} are now on the same line.

Copy link
Contributor

@Bronstrom Bronstrom left a comment

Choose a reason for hiding this comment

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

Nice work @kylelaker!

@@ -58,7 +74,7 @@ describe("OSCALCatalogGroup", () => {
fireEvent.click(expand2);

const expand3 = screen.getByText(
"CONTROL-ID Access Control Policy and Procedures"
getTextByChildren("control-id Access Control Policy and Procedures")
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, so smart!

@Bronstrom Bronstrom merged commit fe66dd7 into develop Mar 27, 2023
@Bronstrom Bronstrom deleted the kyle/control-display-label-not-id branch March 27, 2023 18:37
@kylelaker kylelaker added the bug Something isn't working label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants