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

Migrate Query and config editors to new form styling under feature toggle #255

Merged
merged 13 commits into from Oct 31, 2023

Conversation

idastambuk
Copy link
Contributor

@idastambuk idastambuk commented Oct 8, 2023

Migrating Redshift Config Editor to the new design system form components, as well as the query editor to use EditorField components from grafana/experimental.
The new components are under a Grafana feature flag.

Config Editor

What was done

  • Replaced InlineFields with grafana/ui's Fields
  • included aws-sdk's restyled ConnectionConfig
  • set width of the container to width-30. This was true before, but the width was set in aws-sdk's connection config and not in Redshift
  • added htmlFor and ids, tested all with Voice Over Utility to make sure the labels are read out
  • added allowCustomValue for managed secret, which should fix Data source configuration UI does not accept custom string for Managed Secret #212 too
    Before & After
Screenshot 2023-10-03 at 6 06 16 PM

ezgif-5-46bda79280

Query Editor

What was done:

  • wrapped aws-sdk's resource selector in EditorRowGroup and EditorFields
  • The sql editor field is now vertical
  • added htmlFor and ids, tested all with Voice Over Utility to make sure the labels are read ou
  • Moved Format as section in a Collapse as a temporary solution. Added a ticket here to mimic what we have in Prometheus and Loki, so when that gets picked up I will update here.
  • fixed a test that I think was set up wrong (see comment in the diff)

Before & After
Screenshot 2023-10-03 at 6 15 44 PM

Screenshot 2023-10-24 at 1 28 13 PM

Note: I also had to update plugin tools in the last commit, as after the dependency upgrades the plugin had some errors.

/>
);

const selectEl = screen.getByRole('combobox', { name: selectors.components.ConfigEditor.ClusterID.input });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the old test was selecting the wrong Cluster identifier input. As it was set up, cluser Id Select shouldn't have been shown, instead the cluster disabled autofilled field should have.
I added a prop to get it to show, and a selector for the combobox in particular (not the input).
I could be getting this wrong, but I think it should be ok now. I double checked #228 to verify the logic.

<EditorField
width={15}
label={selectors.components.ConfigEditor.schema.input}
tooltip="Use the selected schema with the $__schema macro"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, description prop in EditorField doesn't show up so Im leaving tooltips for now until we can investigate.
grafana/grafana-experimental#89

Copy link
Contributor

Choose a reason for hiding this comment

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

the underlying field component in @grafana/ui renders the description in the label only if the label is a string
https://github.com/grafana/grafana/blob/bf8af608a7bda9a287071a3f4bdbc96d9d3d335f/packages/grafana-ui/src/components/Forms/Field.tsx#L95-L102

but the editor field component passes in a label element so the description doesn't show up.

https://github.com/grafana/grafana-experimental/blob/ace60c4015b0968813fa055593d8aceadef72e11/src/QueryEditor/EditorField.tsx#L26-L39

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, thanks for getting to the bottom of this @kevinwcyu! Added this to the ticket :)

/>
</Label>
);
}

const getStyles = (theme: GrafanaTheme2) => ({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These adjustments don't change the old form, only the new form with width adjustments.

@idastambuk idastambuk marked this pull request as ready for review October 24, 2023 11:39
@idastambuk idastambuk requested a review from a team as a code owner October 24, 2023 11:39
});
}
run('ConfigEditor with new form styling disabled');
config.featureToggles.awsDatasourcesNewFormStyling = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

in line 57 this toggle is already set to true. also not sure whether this will have an effect since @grafana/runtime is mocked above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok so there indeed is a problem with these tests, and TIL about Jest's setup and teardown lifecycle 👩🏻‍🎓
Since jest "executes all describe handlers in a test file before it executes any of the actual tests", the value of the feature toggle will always be true (or whatever value we put last), since we overwrite it globally.
The only way I found to circumvent this is to separate "toggle disabled" and "toggle enabled" describe blocks and add

beforeAll(() => {
        valueOfTheToggle = whatever
})

inside each block. Maybe there's a better way that I can't see right now (or just copying the tests lol)🤔

<EditorField
width={15}
label={selectors.components.ConfigEditor.schema.input}
tooltip="Use the selected schema with the $__schema macro"
Copy link
Contributor

Choose a reason for hiding this comment

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

the underlying field component in @grafana/ui renders the description in the label only if the label is a string
https://github.com/grafana/grafana/blob/bf8af608a7bda9a287071a3f4bdbc96d9d3d335f/packages/grafana-ui/src/components/Forms/Field.tsx#L95-L102

but the editor field component passes in a label element so the description doesn't show up.

https://github.com/grafana/grafana-experimental/blob/ace60c4015b0968813fa055593d8aceadef72e11/src/QueryEditor/EditorField.tsx#L26-L39

@idastambuk idastambuk changed the title Query and config editors with feature toggle Migrate Query and config editors to new form styling under feature toggle Oct 27, 2023
@idastambuk idastambuk force-pushed the 287-redshift-queryeditor-and-config-editor-migration branch from d07e03f to 2bd4123 Compare October 31, 2023 13:15
@idastambuk idastambuk merged commit afca4dc into main Oct 31, 2023
4 checks passed
@idastambuk idastambuk deleted the 287-redshift-queryeditor-and-config-editor-migration branch October 31, 2023 14:35
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.

Data source configuration UI does not accept custom string for Managed Secret
2 participants