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

Bug 1867864: restrict multiple selections of a revision in traffic modal #6286

Conversation

nemesis09
Copy link
Contributor

@nemesis09 nemesis09 commented Aug 11, 2020

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:
application-dropdown
Screenshot from 2020-08-11 08-24-51

Test Coverage:
Screenshot from 2020-08-11 09-39-23

Browser Conformance:

  • Firefox
  • Chrome
  • Safari
  • Edge

@nemesis09
Copy link
Contributor Author

/assign @invincibleJai

@nemesis09
Copy link
Contributor Author

/kind bug

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 11, 2020
@nemesis09 nemesis09 changed the title restrict multiple selections of a revision in traffic modal Bug 1867864: restrict multiple selections of a revision in traffic modal Aug 11, 2020
@openshift-ci-robot openshift-ci-robot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Aug 11, 2020
@openshift-ci-robot
Copy link
Contributor

@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
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1867864: restrict multiple selections of a revision in traffic modal

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.

@openshift-ci-robot
Copy link
Contributor

@nemesis09: This pull request references Bugzilla bug 1867864, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1867864: restrict multiple selections of a revision in traffic modal

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;
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

@nemesis09 nemesis09 force-pushed the fix-traffic-modal-revisions-duplicate branch from 5d83c69 to e10e66f Compare August 11, 2020 12:26
@invincibleJai
Copy link
Member

@nemesis09 we need to disable add row as well is no revisions left with disableAddRow

image

@nemesis09 nemesis09 force-pushed the fix-traffic-modal-revisions-duplicate branch from e10e66f to a139c87 Compare August 11, 2020 13:10
@nemesis09
Copy link
Contributor Author

@nemesis09 we need to disable add row as well is no revisions left with disableAddRow

image

done

@nemesis09
Copy link
Contributor Author

/retest

@invincibleJai
Copy link
Member

it works fine , just one if same revision added traffic twice via cli then in modal i can see add enabled and dropdown is empty

image

}) => {
const [field] = useField(name);
const dropdownItems =
!field.value || Object.values(revisionItems).includes(field.value)
Copy link
Member

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

Suggested change
!field.value || Object.values(revisionItems).includes(field.value)
Object.values(revisionItems).includes(field.value)

Copy link
Contributor Author

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

Copy link
Member

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', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo:

Suggested change
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', () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 45 to 50
values={{
trafficSplitting: mockTrafficData
.filter((_, index) => index < 2)
.map((trafficElement) => ({ ...trafficElement, percent: 50 })),
}}
Copy link
Member

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

Suggested change
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' },
]}

Copy link
Contributor Author

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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit : can stick to

Suggested change
).toBeFalsy();
).toBe(false);

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Suggested change
: set(cloneDeep(revisionItems), [field.value], field.value);
: {...revisionItems, [field.value] : field.value};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 16 to 19
const selectedRevisions: string[] = values.trafficSplitting.reduce((acc, currentValue) => {
acc.push(currentValue.revisionName);
return acc;
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const selectedRevisions: string[] = values.trafficSplitting.reduce((acc, currentValue) => {
acc.push(currentValue.revisionName);
return acc;
}, []);
const selectedRevisions: string[] = values.trafficSplitting.map((traffic) => traffic.revisionName);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@nemesis09 nemesis09 force-pushed the fix-traffic-modal-revisions-duplicate branch from a139c87 to be43e7d Compare August 13, 2020 02:30
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 13, 2020
@nemesis09
Copy link
Contributor Author

it works fine , just one if same revision added traffic twice via cli then in modal i can see add enabled and dropdown is empty

image

fixed

@nemesis09 nemesis09 force-pushed the fix-traffic-modal-revisions-duplicate branch from be43e7d to c90ac62 Compare August 13, 2020 02:41
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 13, 2020
@nemesis09 nemesis09 force-pushed the fix-traffic-modal-revisions-duplicate branch from c90ac62 to 80b1922 Compare August 13, 2020 02:41
@nemesis09
Copy link
Contributor Author

/test e2e-gcp-console

@invincibleJai
Copy link
Member

/lgtm
/approve

Verified the changes, seems to work as expected

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

3 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@invincibleJai
Copy link
Member

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@invincibleJai
Copy link
Member

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

19 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 5262894 into openshift:master Aug 20, 2020
@openshift-ci-robot
Copy link
Contributor

@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:

Bug 1867864: restrict multiple selections of a revision in traffic modal

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.

@spadgett spadgett added this to the v4.6 milestone Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/knative Related to knative-plugin kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants