-
Notifications
You must be signed in to change notification settings - Fork 9
PMM-14618 Add disable collectors field to MySQL/PG/RDS/Mongo/ProxySQL #904
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
base: main
Are you sure you want to change the base?
Changes from all commits
8c95c98
04f92d1
da465d8
c5fbb33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { FC } from 'react'; | ||
|
|
||
| import { useStyles2 } from '@grafana/ui'; | ||
| import { TextInputField } from 'app/percona/shared/components/Form/TextInput'; | ||
| import { validators as platformCoreValidators } from 'app/percona/shared/helpers/validatorsForm'; | ||
|
|
||
| import { Messages } from '../FormParts.messages'; | ||
| import { getStyles } from '../FormParts.styles'; | ||
|
|
||
| interface Props { | ||
| name: string; | ||
| } | ||
|
|
||
| const DisableCollectorsField: FC<Props> = ({ name }) => { | ||
| const styles = useStyles2(getStyles); | ||
|
|
||
| return ( | ||
| <div className={styles.fieldWrapper}> | ||
| <TextInputField | ||
| name={name} | ||
| label={ | ||
| <> | ||
| <span>{Messages.form.labels.additionalOptions.disableCollectors}</span> | ||
| <br /> | ||
| <span className={styles.description}>{Messages.form.descriptions.disableCollectors}</span> | ||
| </> | ||
| } | ||
|
matejkubinec marked this conversation as resolved.
|
||
| placeholder={Messages.form.placeholders.additionalOptions.disableCollectors} | ||
| validators={[platformCoreValidators.disableCollectors]} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default DisableCollectorsField; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @catalinaadam when you have time, please take a look at the wording here if it's alright There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @matejkubinec, the label and placeholder look good. I'd suggest updating the description to explain the purpose rather than just the format: Current: Suggested:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { disableCollectors } from './disableCollectors'; | ||
|
|
||
| describe('disableCollectors validator', () => { | ||
| it('passes for empty or undefined value (optional field)', () => { | ||
| expect(disableCollectors('')).toBeUndefined(); | ||
| expect(disableCollectors(undefined)).toBeUndefined(); | ||
| }); | ||
|
matejkubinec marked this conversation as resolved.
|
||
|
|
||
| it('passes for a single valid token', () => { | ||
| expect(disableCollectors('collector_1')).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('passes for a comma-delimited list with arbitrary spacing', () => { | ||
| expect(disableCollectors('collector_1, collector2, collector3')).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('passes for names containing "." and "-"', () => { | ||
| expect(disableCollectors('custom_query.mr, standard-process')).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('fails for a token with a space inside the name', () => { | ||
| expect(disableCollectors('bad name')).toEqual(expect.any(String)); | ||
| }); | ||
|
|
||
| it('fails for a token with an illegal character', () => { | ||
| expect(disableCollectors('collector_1, bad!')).toEqual(expect.any(String)); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { Validator } from './validator.types'; | ||
|
|
||
| const collectorNameRe = /^[a-zA-Z0-9_.-]+$/; | ||
|
|
||
| export const disableCollectors: Validator<string | undefined> = (value) => { | ||
| if (!value) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const tokens = value | ||
| .split(',') | ||
| .map((token) => token.trim()) | ||
| .filter(Boolean); | ||
|
|
||
| return tokens.every((token) => collectorNameRe.test(token)) | ||
| ? undefined | ||
| : 'Each collector name may contain only letters, numbers, "_", ".", "-", separated by commas'; | ||
| }; | ||
|
matejkubinec marked this conversation as resolved.
|
||
Uh oh!
There was an error while loading. Please reload this page.