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

[release-4.4] Bug 1807657: Alertmanager receiver creation page should mark Routing Labels field by red-star mark #4633

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/integration-tests/tests/monitoring.scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ describe('Alertmanager: Configuration', () => {
// pagerduty subform should still be invalid at this point, thus save button should be disabled
expect(monitoringView.saveButton.isEnabled()).toBe(false);
await firstElementByTestID('integration-key').sendKeys('<integration_key>');
expect(monitoringView.saveButton.isEnabled()).toBe(true); // subform valid, save should be enabled at this point

// labels
expect(firstElementByTestID('invalid-label-name-error').isPresent()).toBe(false);
Expand All @@ -306,6 +305,7 @@ describe('Alertmanager: Configuration', () => {
await firstElementByTestID('remove-routing-label').click();
expect(firstElementByTestID('duplicate-label-name-error').isPresent()).toBe(false);

expect(monitoringView.saveButton.isEnabled()).toBe(true); // subform valid & labels provided, save should be enabled at this point
await monitoringView.saveButton.click();
await crudView.isLoaded();
monitoringView.getFirstRowAsText().then((text) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ const ReceiverBaseForm: React.FC<ReceiverBaseFormProps> = ({
!formValues.receiverType ||
SubForm.isFormInvalid(formValues) ||
!_.isEmpty(formValues.routeLabelFieldErrors) ||
formValues.routeLabelDuplicateNamesError;
formValues.routeLabelDuplicateNamesError ||
(!isDefaultReceiver &&
formValues.routeLabels.length === 1 &&
(formValues.routeLabels[0].name === '' || formValues.routeLabels[0].value === ''));

const save = (e) => {
e.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const RoutingLabelEditor = ({ formValues, dispatchFormChange, isDefaultRe

return (
<div data-test-id="receiver-routing-labels-editor" className="form-group">
<SectionHeading text="Routing Labels" />
<SectionHeading text="Routing Labels" required={!isDefaultReceiver} />
<p className="co-help-text">
Firing alerts with labels that match all of these selectors will be sent to this receiver.
Label values can be matched exactly or with a &nbsp;
Expand Down
16 changes: 14 additions & 2 deletions frontend/public/components/utils/headings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,20 @@ export const PageHeading = connectToModel((props: PageHeadingProps) => {
);
});

export const SectionHeading: React.SFC<SectionHeadingProps> = ({ text, children, style }) => (
export const SectionHeading: React.SFC<SectionHeadingProps> = ({
text,
children,
style,
required,
}) => (
<h2 className="co-section-heading" style={style} data-test-section-heading={text}>
{text}
<span
className={classNames({
'co-required': required,
})}
>
{text}
</span>
{children}
</h2>
);
Expand Down Expand Up @@ -264,6 +275,7 @@ export type SectionHeadingProps = {
children?: any;
style?: any;
text: string;
required?: boolean;
};

export type SidebarSectionHeadingProps = {
Expand Down