Chore: Remove Form usage from SharedPreferences.tsx (#81468)

* Chore: Remove Form usage from SharedPreferences.tsx

* Update betterer

* Update betterer
This commit is contained in:
Alex Khomenko 2024-01-31 18:33:17 +01:00 committed by GitHub
parent c310a20966
commit 1749ec9d5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 83 additions and 92 deletions

View File

@ -1050,9 +1050,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"],
[0, 0, 0, "Styles should be written using objects.", "1"]
],
"public/app/core/components/SharedPreferences/SharedPreferences.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"]
],
"public/app/core/components/TagFilter/TagFilter.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],

View File

@ -9,7 +9,6 @@ import {
Button,
Field,
FieldSet,
Form,
Label,
Select,
stylesFactory,
@ -87,7 +86,8 @@ export class SharedPreferences extends PureComponent<Props, State> {
});
}
onSubmitForm = async () => {
onSubmitForm = async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
const confirmationResult = this.props.onConfirm ? await this.props.onConfirm() : true;
if (confirmationResult) {
@ -137,10 +137,7 @@ export class SharedPreferences extends PureComponent<Props, State> {
const currentThemeOption = this.themeOptions.find((x) => x.value === theme) ?? this.themeOptions[0];
return (
<Form onSubmit={this.onSubmitForm}>
{() => {
return (
<>
<form onSubmit={this.onSubmitForm} className={styles.form}>
<FieldSet label={<Trans i18nKey="shared-preferences.title">Preferences</Trans>} disabled={disabled}>
<Field label={t('shared-preferences.fields.theme-label', 'Interface theme')}>
<Select
@ -214,17 +211,10 @@ export class SharedPreferences extends PureComponent<Props, State> {
/>
</Field>
</FieldSet>
<Button
type="submit"
variant="primary"
data-testid={selectors.components.UserProfile.preferencesSaveButton}
>
<Button type="submit" variant="primary" data-testid={selectors.components.UserProfile.preferencesSaveButton}>
<Trans i18nKey="common.save">Save</Trans>
</Button>
</>
);
}}
</Form>
</form>
);
}
}
@ -233,9 +223,13 @@ export default SharedPreferences;
const getStyles = stylesFactory(() => {
return {
labelText: css`
margin-right: 6px;
`,
labelText: css({
marginRight: '6px',
}),
form: css({
width: '100%',
maxWidth: '600px',
}),
};
});