mirror of
https://github.com/quay/quay.git
synced 2026-01-26 06:21:37 +03:00
[redhat-3.12] ui: fix for negative integers in image expiry days (PROJQUAY-7442) (#3014)
ui: fix for negative integers in image expiry days (PROJQUAY-7442) Co-authored-by: Sunandadadi <sunanda.3094@gmail.com>
This commit is contained in:
committed by
GitHub
parent
414ea00b6d
commit
3e43a5f50e
@@ -398,4 +398,20 @@ describe('Repository Settings - Notifications', () => {
|
||||
cy.get(`[data-label="status"]`).should('have.text', 'Enabled');
|
||||
});
|
||||
});
|
||||
|
||||
it('Incorrect form for repo image expiry notification', () => {
|
||||
cy.contains('Create notification').click();
|
||||
cy.get('#create-notification-form').within(() => {
|
||||
cy.contains('Select event').click();
|
||||
cy.contains('Image expiry trigger').click();
|
||||
cy.get('#days-to-image-expiry').type('-5');
|
||||
cy.contains('Select method').click();
|
||||
cy.contains('Slack Notification').click();
|
||||
cy.get('#slack-webhook-url-field').type(
|
||||
'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX',
|
||||
);
|
||||
cy.get('#notification-title').type('image expiry notification');
|
||||
cy.contains('button', 'Submit').should('be.disabled');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ export default function CreateNotification(props: CreateNotificationProps) {
|
||||
|
||||
const isValidateConfig = () => {
|
||||
if (event?.type == NotificationEventType.imageExpiry) {
|
||||
return eventConfig?.days != undefined;
|
||||
return eventConfig?.days != undefined && eventConfig?.days > 0;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import {FormGroup, TextInput} from '@patternfly/react-core';
|
||||
import {FormGroup, TextInput, ValidatedOptions} from '@patternfly/react-core';
|
||||
import {NotificationEventConfig} from 'src/hooks/UseEvents';
|
||||
import {useState} from 'react';
|
||||
|
||||
export default function RepoEventExpiry(props: RepoEventExpiryProps) {
|
||||
const [valid, setValid] = useState(ValidatedOptions.default);
|
||||
|
||||
const onChange = (_event, value) => {
|
||||
props.setEventConfig({days: Number(value)});
|
||||
if (value < 1) {
|
||||
setValid(ValidatedOptions.error);
|
||||
} else {
|
||||
setValid(ValidatedOptions.success);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -18,6 +26,7 @@ export default function RepoEventExpiry(props: RepoEventExpiryProps) {
|
||||
type={'number'}
|
||||
id="days-to-image-expiry"
|
||||
required
|
||||
validated={valid}
|
||||
/>
|
||||
</FormGroup>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user