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
Bug 1867864: restrict multiple selections of a revision in traffic modal #6286
Bug 1867864: restrict multiple selections of a revision in traffic modal #6286
Conversation
/assign @invincibleJai |
/kind bug |
@nemesis09: This pull request references Bugzilla bug 1867864, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@nemesis09: This pull request references Bugzilla bug 1867864, which is valid. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
import { DropdownField } from '@console/shared'; | ||
|
||
type TrafficModalRevisionsDropdownFieldProps = { | ||
revisionItems: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we know type for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an object of type {string(revisionName): string(revisionName)}
Should I define a type for it in utils to use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a type RevisionItems
in utils, got overlooked
updated it with type
5d83c69
to
e10e66f
Compare
@nemesis09 we need to disable add row as well is no revisions left with |
e10e66f
to
a139c87
Compare
done |
/retest |
}) => { | ||
const [field] = useField(name); | ||
const dropdownItems = | ||
!field.value || Object.values(revisionItems).includes(field.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we it as below
!field.value || Object.values(revisionItems).includes(field.value) | |
Object.values(revisionItems).includes(field.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will allow empty value to be shown in dropdown resulting in a field with blank title
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
am not sure m why will that be the case?
}); | ||
|
||
it('should not disable delete row button for more than one values', () => { | ||
const wrapper = shallow(<TrafficSplittingFields {...formProps} />); | ||
it('should not disable delete row button or add row button if number of values if more than one but less than total number of revisions', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo:
it('should not disable delete row button or add row button if number of values if more than one but less than total number of revisions', () => { | |
it('should not disable delete row button or add row button if number of values is more than one but less than total number of revisions', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
values={{ | ||
trafficSplitting: mockTrafficData | ||
.filter((_, index) => index < 2) | ||
.map((trafficElement) => ({ ...trafficElement, percent: 50 })), | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO below will be simpler as it's mock data
values={{ | |
trafficSplitting: mockTrafficData | |
.filter((_, index) => index < 2) | |
.map((trafficElement) => ({ ...trafficElement, percent: 50 })), | |
}} | |
values={[ | |
{ percent: 50, tag: 'tag-1', revisionName: 'overlayimage-fdqsf' }, | |
{ percent: 50, tag: 'tag-2', revisionName: 'overlayimage-tkvz5' }, | |
]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
.find(TrafficModalRevisionsDropdownField) | ||
.first() | ||
.props().revisionItems['overlayimage-fdqsf'], | ||
).toBeFalsy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit : can stick to
).toBeFalsy(); | |
).toBe(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
const dropdownItems = | ||
!field.value || Object.values(revisionItems).includes(field.value) | ||
? revisionItems | ||
: set(cloneDeep(revisionItems), [field.value], field.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we could simply do this and remove lodash imports.
: set(cloneDeep(revisionItems), [field.value], field.value); | |
: {...revisionItems, [field.value] : field.value}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
const selectedRevisions: string[] = values.trafficSplitting.reduce((acc, currentValue) => { | ||
acc.push(currentValue.revisionName); | ||
return acc; | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const selectedRevisions: string[] = values.trafficSplitting.reduce((acc, currentValue) => { | |
acc.push(currentValue.revisionName); | |
return acc; | |
}, []); | |
const selectedRevisions: string[] = values.trafficSplitting.map((traffic) => traffic.revisionName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
a139c87
to
be43e7d
Compare
be43e7d
to
c90ac62
Compare
c90ac62
to
80b1922
Compare
/test e2e-gcp-console |
/lgtm Verified the changes, seems to work as expected |
/retest Please review the full test history for this PR and help us cut down flakes. |
3 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest |
/retest Please review the full test history for this PR and help us cut down flakes. |
19 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@nemesis09: All pull requests linked via external trackers have merged: openshift/console#6286. Bugzilla bug 1867864 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Fixes:
https://issues.redhat.com/browse/ODC-3696
Analysis / Root cause:
a revision can be assigned traffic multiple times in traffic distribution modal
Solution Description:
restrict multiple selection of the same revision in the traffic modal by removing the already selected revisions from dropdown options
Screens:
Test Coverage:
Browser Conformance: