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
Conversation
Issues: #27605 |
f0c4822
to
e40f9dc
Compare
@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? |
@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. |
@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 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. |
webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableHelpers.js
Outdated
Show resolved
Hide resolved
3c8ce1a
to
cd7633f
Compare
webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableHelpers.js
Outdated
Show resolved
Hide resolved
ca16699
to
b0d0ce4
Compare
webpack/scenes/Subscriptions/components/SubscriptionsTable/SubscriptionsTableHelpers.js
Outdated
Show resolved
Hide resolved
Can we make the commit message a little more descriptive? |
@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. |
I have edited the commit message. Is there anything else that I need to be adding? @jlsherrill |
b0d0ce4
to
98caf3d
Compare
@@ -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 && |
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.
How is checking the id is 0 significant?
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.
Oh, I think it's so we don't get the '>' on the expanded rows also?
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.
@jturel yes that's exactly why.
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.
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.
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.
What about putting a 'collapsible' field on the custom row we are building?
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.
@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.
a87d2fe
to
31b7961
Compare
webpack/scenes/Subscriptions/components/SubscriptionsTable/components/Table.js
Outdated
Show resolved
Hide resolved
25a7600
to
8edc4ba
Compare
@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. 👍 |
@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? |
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.
Thanks @sseelam2, looking good!
Left a few code comments below.
}) => ( | ||
<Table.SelectionCell> | ||
{before} | ||
<Table.Checkbox | ||
{!hide && <Table.Checkbox |
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.
My favorite way to conditionally render :)
I think it's more readable if <Table.Checkbox
is on the next line.
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.
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; |
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.
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..
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.
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.
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.
@sseelam2 rowData
is the one at issue. If additionalData
is defined but additionalData.rowData
isn't, it will error.
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.
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.
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.
That sounds correct :)
const first = subscriptionGroup.subscriptions[0]; | ||
const heading = {}; | ||
|
||
heading.id = 0; |
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.
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,
...
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 makes sense. Thanks 👍
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; |
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.
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 => |
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.
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.
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.
Nice catch. Thanks for your feedback @jeremylenz .
9394735
to
eeb2abd
Compare
@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) { |
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.
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 = []; |
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.
I think rows can be initialized inside the below if statement, so that we don't initialize it unnecessarily
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.
Left 2 small comments, but it works exactly how I imagined it should!
eeb2abd
to
13654d3
Compare
13654d3
to
a17056b
Compare
Thanks @jturel and @jeremylenz for the feedback! 😄 |
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.
ACK!
Thanks @sseelam2 and @jeremylenz for the review
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 -