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

Fixes #27605 - Adding generic first row for grouped subs #8336

Merged
merged 1 commit into from Oct 11, 2019

Conversation

sseelam2
Copy link
Member

@sseelam2 sseelam2 commented Sep 6, 2019

This PR is still a work in progess. I would appreciate suggestions.
This PR is changing the view of the subscriptions with multiple entitlements.

To test this PR -

  • Create a manifest with a subscription having multiple entitlements in the Red Hat customer portal.
  • Click on manage manifest and import this manifest under the Subscriptions tab.
  • When this is viewed in the UI (Content -> Subscriptions), the first row for this subscription must be collapsible having the subscription name and product ID and everything else set to NA. When '>' is clicked it should show all the subscriptions under the generic row with the same product ID.

@theforeman-bot
Copy link

Issues: #27605

@jturel
Copy link
Member

jturel commented Sep 9, 2019

@sseelam2 I saw this was in ready for review but it appears to be a work in progress. Was there something specific you're looking for feedback on?

@sseelam2
Copy link
Member Author

sseelam2 commented Sep 9, 2019

@jturel Sorry I forgot to mention that. I still have not figured out how to make the entitlements column NA for the generic row. And also I'm not sure why '>' this symbol comes up in the first two rows when it should be present only on the first row.

@jturel
Copy link
Member

jturel commented Sep 9, 2019

@sseelam2 that's OK. I am also curious if you talked with anyone from the UX side on this. Maybe it's better to not collapse/group the subscriptions, but instead list them individually. That makes it easier from our side but I think I can also see why we have the grouping.

@jturel jturel self-assigned this Sep 9, 2019
@sseelam2
Copy link
Member Author

sseelam2 commented Sep 9, 2019

@jturel I discussed with Roxanne about this. She went through the description of the bug and mentioned that she had seen something just like this earlier and asked me to go ahead with this solution.

@sseelam2 sseelam2 force-pushed the manifest_bug branch 2 times, most recently from 3c8ce1a to cd7633f Compare September 10, 2019 15:05
@sseelam2 sseelam2 force-pushed the manifest_bug branch 2 times, most recently from ca16699 to b0d0ce4 Compare September 10, 2019 17:43
@jlsherrill
Copy link
Member

Can we make the commit message a little more descriptive?

@sseelam2
Copy link
Member Author

@jlsherrill We are not sure how we should be displaying the subscriptions yet. @jturel and I have a meeting with Roxanne this friday to figure out a better way of displaying the subscriptions.

@jturel jturel changed the title Fixes #27605 - Mainfest Issue [WIP] Fixes #27605 - Mainfest Issue Sep 19, 2019
@sseelam2
Copy link
Member Author

Can we make the commit message a little more descriptive?

I have edited the commit message. Is there anything else that I need to be adding? @jlsherrill

@@ -27,7 +27,7 @@ const Table = ({
const groupingController = {
isCollapseable: ({ rowData }) =>
// it is the first subscription in the group
rowData.id === groupedSubscriptions[rowData.product_id].subscriptions[0].id &&
rowData.id === 0 &&
Copy link
Member

Choose a reason for hiding this comment

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

How is checking the id is 0 significant?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I think it's so we don't get the '>' on the expanded rows also?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jturel yes that's exactly why.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there's some other distinguishing characteristic about the row (maybe something else we can add) to identify when we should collapse rather than id === 0. What if we had an Id later? That would break the functionality because it's not obvious that ID is significant in that way.

Copy link
Member

Choose a reason for hiding this comment

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

What about putting a 'collapsible' field on the custom row we are building?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jturel Subscriptions already have an id field which starts from 1. So I just used id=0 to represent a generic row. But using a collapsible field sounds good to me.

@sseelam2 sseelam2 force-pushed the manifest_bug branch 6 times, most recently from a87d2fe to 31b7961 Compare September 26, 2019 15:32
@sseelam2 sseelam2 changed the title [WIP] Fixes #27605 - Mainfest Issue Fixes #27605 - Mainfest Issue Sep 26, 2019
@sseelam2 sseelam2 force-pushed the manifest_bug branch 12 times, most recently from 25a7600 to 8edc4ba Compare October 4, 2019 21:54
@jturel
Copy link
Member

jturel commented Oct 7, 2019

@sseelam2 looks like the build is green now. is this ready for re-review? just checking in case you were planning any more changes

@sseelam2
Copy link
Member Author

sseelam2 commented Oct 7, 2019

@sseelam2 looks like the build is green now. is this ready for re-review? just checking in case you were planning any more changes

Yes, It is ready for re-review. 👍

@jturel
Copy link
Member

jturel commented Oct 7, 2019

@jeremylenz hey! I'll take care of the end-to-end testing of the PR. Would you mind looking at it from the JS perspective and make sure that what we came up with isn't breaking any rules?

Copy link
Member

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

Thanks @sseelam2, looking good!

Left a few code comments below.

}) => (
<Table.SelectionCell>
{before}
<Table.Checkbox
{!hide && <Table.Checkbox
Copy link
Member

Choose a reason for hiding this comment

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

My favorite way to conditionally render :)

I think it's more readable if <Table.Checkbox is on the next line.

Copy link
Member Author

Choose a reason for hiding this comment

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

alright. thanks for the feedback. will move it to the next line. 👍

@@ -4,8 +4,10 @@ import CollapseSubscriptionGroupButton from '../components/CollapseSubscriptionG

export default (collapseableController, selectionController, additionalData) => {
const shouldShowCollapseButton = collapseableController.isCollapseable(additionalData);
const isGenericRow = additionalData.rowData.collapsible;
Copy link
Member

Choose a reason for hiding this comment

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

If additionalData.rowData is ever undefined, this will throw an error. You can leave as-is if you're confident that rowData will always be defined, but it's something to keep in mind..

Copy link
Member Author

Choose a reason for hiding this comment

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

The table rows are built only if there are any subscriptions and these rows are passed in as additional data to collapseableAndSelectionCellFormatter.js . So I don't think addtionalData can be empty. Correct me if I'm wrong @jturel.

Copy link
Member

Choose a reason for hiding this comment

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

@sseelam2 rowData is the one at issue. If additionalData is defined but additionalData.rowData isn't, it will error.

Copy link
Member Author

Choose a reason for hiding this comment

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

additonalData doesn't get created if there is no rowData. additonalData contains additional info about the row. So I don't think we'll end up in that situation. But I would like @jturel to confirm. Just to be extra sure about this.

Copy link
Member

Choose a reason for hiding this comment

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

That sounds correct :)

const first = subscriptionGroup.subscriptions[0];
const heading = {};

heading.id = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Unless there's a specific reason for assigning all the properties using =, I think an object literal is more readable:

const heading = {
  id: 0,
  collapsible: true,
  ...

Copy link
Member Author

Choose a reason for hiding this comment

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

This makes sense. Thanks 👍

Comment on lines 43 to 49
heading.contract_number = 'NA';
heading.start_date = 'NA';
heading.end_date = 'NA';
heading.consumed = 'NA';
heading.product_id = first.product_id;
heading.name = first.name;
heading.virt_only = first.virt_only;
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to use camelCase for all these instead of snake_case?

if (subscriptions.length > 1) {
rows.push(buildTableCollapseRow(subscriptionGroup));
if (open) {
return rows.concat(subscriptions.map(sub =>
Copy link
Member

Choose a reason for hiding this comment

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

What about, instead of return rows.concat if we were to use subscriptions.forEach(sub => rows.push(... ?

That way, on line 65 you're just returning rows no matter what, and it's a little easier to see what's happening.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch. Thanks for your feedback @jeremylenz .

@sseelam2 sseelam2 force-pushed the manifest_bug branch 2 times, most recently from 9394735 to eeb2abd Compare October 9, 2019 18:02
@sseelam2 sseelam2 changed the title Fixes #27605 - Mainfest Issue Fixes #27605 - Adding generic first row for grouped subs Oct 9, 2019
@sseelam2
Copy link
Member Author

sseelam2 commented Oct 9, 2019

@jturel PR is ready for testing :)

@@ -6,11 +6,17 @@ import { validateQuantity } from '../../../../../scenes/Subscriptions/Subscripti

const renderValue = (value, additionalData, onActivate) => {
const { available, upstream_pool_id: upstreamPoolId } = additionalData.rowData;
if (available < 0 || !upstreamPoolId) {

if (additionalData.rowData.collapsible) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we pull out collapsible via destructuring on line 8? What's here works fine, but that would be more consistent with the surrounding code

const buildTableRowsFromGroup = (subscriptionGroup, availableQuantities, updatedQuantity) => {
const { open, subscriptions } = subscriptionGroup;
const rows = [];
Copy link
Member

Choose a reason for hiding this comment

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

I think rows can be initialized inside the below if statement, so that we don't initialize it unnecessarily

Copy link
Member

@jturel jturel left a comment

Choose a reason for hiding this comment

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

Left 2 small comments, but it works exactly how I imagined it should!

@sseelam2
Copy link
Member Author

Thanks @jturel and @jeremylenz for the feedback! 😄

Copy link
Member

@jturel jturel left a comment

Choose a reason for hiding this comment

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

ACK!

Thanks @sseelam2 and @jeremylenz for the review

@jturel jturel merged commit 91c3240 into Katello:master Oct 11, 2019
@sseelam2 sseelam2 deleted the manifest_bug branch October 11, 2019 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants