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

[To Main] DESENG-655: Add existing engagement fields to engagement wizard #2555

Merged

Conversation

NatSquared
Copy link
Contributor

Issue #: 🎟️ DESENG-655
Description of changes:

  • Feature Add the existing engagement form fields to the engagement authoring wizard
    • Added fields for the existing data (engagement title, dates, internal/external, public slug)
    • Create button is now enabled when all required fields are filled
    • Users are redirected to the old form after creating a new engagement
      • (clicking "edit" on an existing engagement also brings you to the old form, as usual)
  • Some extracurricular work:
    • Created a reusable component to warn users when they're about to navigate away from the page while editing content
    • Adjusted theming throughout the app to reduce the number of places where colors are defined
    • Updated to the latest version of @mui/x-date-pickers and adjust existing components where necessary

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the met-public license (Apache 2.0).

@codecov-commenter
Copy link

codecov-commenter commented Jul 13, 2024

Codecov Report

Attention: Patch coverage is 82.60870% with 4 lines in your changes missing coverage. Please review.

Project coverage is 75.96%. Comparing base (55f54ff) to head (cd93814).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2555      +/-   ##
==========================================
+ Coverage   75.95%   75.96%   +0.01%     
==========================================
  Files         607      609       +2     
  Lines       21943    21959      +16     
  Branches     1707     1711       +4     
==========================================
+ Hits        16666    16681      +15     
- Misses       5014     5015       +1     
  Partials      263      263              
Flag Coverage Δ
metweb 64.72% <82.60%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
met-web/src/components/common/Input/Button.tsx 95.45% <ø> (+1.13%) ⬆️
met-web/src/components/common/Layout/index.tsx 88.88% <ø> (ø)
met-web/src/components/common/Navigation/Link.tsx 100.00% <ø> (ø)
...ents/common/Navigation/UnsavedWorkConfirmation.tsx 100.00% <100.00%> (ø)
...components/engagement/view/ScheduleModal/index.tsx 60.78% <100.00%> (-1.48%) ⬇️
met-web/src/components/layout/SideNav/SideNav.tsx 90.90% <100.00%> (ø)
...web/src/components/layout/SideNav/UserGuideNav.tsx 45.16% <ø> (-1.72%) ⬇️
...ublicDashboard/SubmissionTrend/SubmissionTrend.tsx 78.82% <100.00%> (-0.49%) ⬇️
...web/src/components/tenantManagement/TenantForm.tsx 77.38% <100.00%> (-1.51%) ⬇️
met-web/src/styles/Theme.ts 100.00% <ø> (ø)
... and 1 more

... and 1 file with indirect coverage changes

@NatSquared NatSquared marked this pull request as ready for review July 13, 2024 00:29
@NatSquared NatSquared changed the title DESENG-655: Add existing engagement fields to engagement wizard [To Main] DESENG-655: Add existing engagement fields to engagement wizard Jul 13, 2024
Copy link
Collaborator

@Baelx Baelx left a comment

Choose a reason for hiding this comment

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

Thanks Nat! Lots of great work here. Could I ask for a couple of things:

  • ensure textfields and other inputs have labels wherever possible
  • remove commented-out code

Also another gentle reminder to just keep an eye on the file count when working on code :) If you're getting to 15-ish files and there's still work left, it could be a good time to submit a PR

@@ -0,0 +1,237 @@
import React, { useEffect } from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was the existing date calculation not working? Or did the designs include a day calculator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The designs included a day calculation - though "DatesPicker" would probably have been a better name for this component

color: colors.type.inverted.primary,
borderRadius: '0 50% 50% 0',
border: `1px solid ${colors.surface.blue[80]}`,
borderLeft: 'none',
Copy link
Collaborator

Choose a reason for hiding this comment

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

A lot of this styling is repeated from above. You could make things more compact by just having a buttonRadius variable set based on the condition fired. Also, is it possible to merge/reduce some of the conditions in this function?

};

return (
<Grid container mt={2} direction="column" spacing={2}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this component a date picker too? If so, we could make that more explicit by naming it DatePickerWithDateCaclulation or something like that

<Grid item container direction="row">
<Grid item>
<BodyText bold>Start Date</BodyText>
<Controller
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we're building this component from scratch again, how does it fare with keyboards only? What about with a screen reader?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After testing, I believe this is on par with the existing calendar picker - MUI has excellent screen reader info built into the component, and the alternative is to assume that the user's browser has a calendar picker.

</Grid>
<Grid item>
<BodyText thin display="inline">
(12:01 AM)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this static text used for?

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 was part of the design - It clarifies the exact time that engagements will go live

)}
/>
</FormControl>
<When condition={isInternal !== undefined}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm trying to understand this condition, so when isInternal is true or false it'll show the Grid, but when it's undefined it won't? Is undefined the default value it gets and it would be complicated to make it false from the get-go? If so, maybe add a comment to explain

slug: formData.get('slug') as string,
});
} catch (e) {
console.error(e);
Copy link
Collaborator

Choose a reason for hiding this comment

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

A context message could be helpful in case we need to go and track down this error message

Suggested change
console.error(e);
console.error('Error updating engagement slug', e);

maxLength={50}
title="1. What is the title of your Engagement?"
instructions="Titles should succinctly describe what your engagement is about in 60 characters or less."
placeholder="Engagement title"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Many screen readers do not read placeholders and some may not properly interpret the title attribute on a form field. We should make sure to include a label so the field is properly identified by them.

Suggested change
placeholder="Engagement title"
placeholder="Engagement title"
label="Engagement title"

<TextField
value={currentSlug}
onChange={setCurrentSlug}
title="Engagement URL"
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems like maybe there's a precedent in this app for using the title attribute instead of having form labels? WCAG guidelines say we should go for labels whenever possible. Titles are somewhat acceptable but may be unreliable in terms of conveying field info to screen readers: https://www.w3.org/WAI/tutorials/forms/labels/#using-the-title-attribute

Suggested change
title="Engagement URL"
label="Engagement URL"

@@ -148,18 +148,18 @@ const ScheduleModal = ({ reschedule, open, updateModal }: ScheduleModalProps) =>
<Grid data-testid={'desktop-datepicker'} item xs={6}>
<MetLabel>Date</MetLabel>
<DesktopDatePicker
inputFormat="MM/DD/YYYY"
// inputFormat="MM/DD/YYYY"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these commented-out fields needed for later?

Copy link

sonarcloud bot commented Jul 16, 2024

@@ -66,8 +67,9 @@ const EngagementVisibilityControl = () => {
)}
/>
</FormControl>
<When condition={isInternal !== undefined}>
<When condition={!isEditing}>
{/* Hide the URL settings until the user has selected a visibility option */}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks!

@NatSquared NatSquared merged commit a5d65be into main Jul 16, 2024
8 checks passed
@NatSquared NatSquared deleted the feature/DESENG-655-add-existing-fields-to-engagement-wizard branch August 28, 2024 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants