-
Notifications
You must be signed in to change notification settings - Fork 1
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
268 migrate aws sdk react components to the new form styling #62
268 migrate aws sdk react components to the new form styling #62
Conversation
97d41b3
to
6e22d34
Compare
Phenomenal work @idastambuk! Well done for getting everything in, I think it looks like a massive improvement 😊 |
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.
LGTM! Up to you, but it's a big change so it may make sense to wait for someone besides me to also review it.
|
||
export interface ConfigSelectProps | ||
extends DataSourcePluginOptionsEditorProps<AwsAuthDataSourceJsonData, AwsAuthDataSourceSecureJsonData> { | ||
value: string; | ||
// input id and aria-label necessary for accessibility attributes | ||
id: string; | ||
['aria-label']: string; |
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.
Why is aria-label
in brackets?
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.
It's a way to define html element props that aren't camel case, like aria-label and data-testid so that typescript linter doesn't complain. I could have made the ariaLabel an 'official' component prop as well, of course. However, I replaced it in the final version with just label
props.
const label = 'foo-id'; | ||
render(<ConfigSelect {...props} disabled={true} label={label} />); | ||
const selectEl = screen.getByLabelText(label); | ||
render(<ConfigSelect {...props} disabled={true} aria-label={props['aria-label']} />); |
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.
does the aria-label need to be set separately here or is it set by the props
field already?
src/components/Divider.tsx
Outdated
@@ -0,0 +1,19 @@ | |||
// copied from Azure Data Explorer plugin since there is not Divider component in G<10.1 | |||
import React from 'react'; | |||
// import { Divider as GrafanaDivider} from '@grafana/ui'; |
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.
wouldn't this throw an error if we are running the plugin in grafana < 10.1? my understanding is that the plugins rely on the runtime for the @grafana/ui
import so if we run in grafana < 10.1 it would not find the Divider
component.
also, i think it'd be good to remove the commented out code for now and leave it in a draft branch and then link it to the github issue for enabling this.
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.
FWIW I tested this when I implemented and it didn't throw in G<10.1 but maybe worth someone else checking too 😊
src/components/utils/version.ts
Outdated
@@ -0,0 +1,53 @@ | |||
// copied from Azure Data Explorer plugin |
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.
it doesn't look like these are exported except for use by the divider component. can this file also be moved to a draft branch and then linked to the github issue for enabling the divider component?
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.
Good point, removed!
> | ||
<Select | ||
id="authProvider" | ||
aria-label="Authentication Provider" |
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'm curious is the aria-label here necessary/recommended by our accessibility folks? I would guess that the label + htmlFor would do the job of labeling this component but I could be wrong, I know these Select components are very tricky sometimes
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.
Ok so I tested the aria-labels with a screen reader and it looks like we need them on Select components, but not on the new Inputs. I would expect the aria labels be applied if we have an htmlFor and id, but they aren't getting. I will open a bug ticket for this in main grafana, but in the meantime I removed new Input aria-labels but keeping the Select ones. I didn't touch the old ones, since they will be removed later anyway. Good catch!
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.
Overall looks pretty cool!
A few ideas come to mind, feel free to think about them and do what you think is best!
- it looks like a lot of changes and I don't think it would be too crazy to try using a feature flag, but I also respect the choice not to! There's a cost to everything, etc, etc.
- I see we're adding a lot of aria-labels here primarily for testing purposes, but I think one of the benefits of these new components is that you don't need to use aria-labels (as long as we have a label and say what component that label is for) You can read more about some of the negatives of putting aria-labels on things that don't need aria-labels here if you'd like: https://github.com/grafana/grafana/blob/main/contribute/style-guides/e2e.md#aria-labels-vs-data-testid Or at least that's my understanding, I'm not an a11y expert, so I defer to whatever our a11y working group recommends!
Thanks for doing this very exciting!
src/sql/ResourceSelector.test.tsx
Outdated
} | ||
const selectEl = screen.getByLabelText(props.label); | ||
const selectEl = screen.getByLabelText(props['aria-label']); |
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.
Imo it's a bit easier to understand what's happening in a test here to say:
const selectEl = screen.getByLabelText("the actual label");
but a bit nitpicky of me!
return ( | ||
<> | ||
{props.newFormStylingEnabled ? ( | ||
<NewConnectionConfig |
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'm getting into extremely nitpicky territory here so please don't feel the need to change the code, but it's been something I've been thinking about with my own code so I thought maybe I'd share:
It can sometimes be nice to think about adding changes in such a way that we are minimizing future changes, so as to feel more confidence when we make them and reduce cleanup.
For example whenever we end up removing this feature flag we're going to have lingering references to an unused prop newFormStylingEnabled
and we're going to have a component that does nothing except render a component (so we'll probably have to remove the NewConnectionConfig file and put it back in here).
Another alternative could be to:
- directly import the feature flag here (then you don't need to pass the feature flag prop at all)
- Keep the new ConnectionConfig in the file called ConnectionConfig, and put all the old stuff in a new file OldConnectionConfig, so that eventually you just delete that file.
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 agree! I tried to do that in the rest of the files that I hadn't done yet, but I kept this one, as the change to move to OldConnectionConfig now, will take more than putting things from NewConnectionConfig back. I don't think it's super worth it for this specific one right now
assumeRoleInstructionsStyle, | ||
...props | ||
}: NewConnectionConfigProps) => { | ||
const options = props.options; |
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.
just curious why we pull options here rather than use the spread up above?
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.
We're passing props to the handlers, but we need options in there too. In a few other places in the file we just need options, so I don't necessarily need the spread and can use props.options but decided to leave the shorthand
This is a part of migration to the new saga design system, namely using components from grafana/ui or the experimental components from /experimental. There are two parts to this, migrating query editor components and migrating config editor components, let me know if you'd rather have them split into two. Resource Selector cannot be split in the way I chose to do it, so I'm submitting a PR for both.
Thank you @aangelisc for all the support on this one!
Config Editor migration:
Before & After
(in Redshift Config editor)
What was done:
Connection Config:
Authentication
,Assume Role
andAdditional Setting
s to break the form up a little bit. It made it look a bit busier, so if anyone feels strongly about removing this, I'd be happy to.Query Editor components
(ResourceSelector, FillValueSelect, FormatSelect)
This is what the query editor looks like in Redshift now. The changes from this PR are only with regards to the fields, not the layout. The layout changes are Redshift-specific.