-
Notifications
You must be signed in to change notification settings - Fork 51
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
refactor(ui): update machine header to support tag forms #3661
Conversation
@@ -0,0 +1,245 @@ | |||
import { mount } from "enzyme"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file hasn't changed, just renamed from ui/src/app/pools/views/Pools.test.tsx
@@ -0,0 +1,207 @@ | |||
import { useEffect, useState } from "react"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file hasn't been modified, just renamed from "ui/src/app/pools/views/Pools.tsx"
QA notesNow the subheader (number of machines) disappears if you go to a different tab. This breaks the view hierarchy which is confusing (switching to a different tab should ideally only modify content that's within that tab). This is also not consistent with how we handle this pattern in other views (e.g. KVM). This PRBeforeKVM |
@@ -0,0 +1,72 @@ | |||
import { mount } from "enzyme"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use the testing library please 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should probably have a rule that if you're touching a file you shouldn't have to update to RTL otherwise a lot of PRs are going to get very large.
</MemoryRouter> | ||
</Provider> | ||
); | ||
expect(screen.getByText("Add tag form")).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(screen.getByText("Add tag form")).toBeInTheDocument(); | |
expect(screen.getByRole("form", { name: "Add tag" })).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use the appropriate role. This can easily get missed when you open another PR with the full form implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's OK, that text isn't going to stay...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a todo here.
<> | ||
Add tag form{" "} | ||
<Button onClick={() => setHeaderContent(null)}>Close</Button> | ||
</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<> | |
Add tag form{" "} | |
<Button onClick={() => setHeaderContent(null)}>Close</Button> | |
</> | |
<form aria-label="Add tag"> | |
<Button onClick={() => setHeaderContent(null)}>Close</Button> | |
</form> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above.
setHeaderContent={jest.fn()} | ||
/> | ||
); | ||
expect(screen.getByText("Add tag form")).toBeInTheDocument(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use the form
role instead of simple text matching please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a placeholder until the form is implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a todo here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
export const TagsHeader = ({ | ||
headerContent, | ||
setHeaderContent, | ||
}: Props): JSX.Element => { | ||
return ( | ||
<MachinesHeader | ||
buttons={[ | ||
<Button | ||
appearance="positive" | ||
onClick={() => setHeaderContent({ view: TagHeaderViews.AddTag })} | ||
> | ||
Create new tag | ||
</Button>, | ||
]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relates to my other comment about view hierarchy.
I think that instead of importing a parent element into a child it would make more sense to keep MachineHeader above and in a single place (views/Machines
), like it was before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem we have is that other than the title and the tabs we treat the machines/tags/pools as isolated parts of the site (there's no shared state etc.) so we're having to work around that by watching for URL changes and resetting things like the filter states.
As we're now adding forms for the tags we're now conflating things further. The aim of this PR is separating the concerns of each view (machines/tags/pools) so that they no longer have a single header and form state so each section can implement things like forms in isolation.
Oh yeah that's to match the design: |
Separate the main machine/pool/tag view and header so that it can support tag header forms. Fixes: canonical/app-tribe#741.
9f43666
to
9742e22
Compare
Done
QA
MAAS deployment
To run this branch you will need access to one of the following MAAS deployments:
Running the branch
You can run this branch by:
QA steps
Fixes
Fixes: canonical-web-and-design/app-tribe#741.