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

#2213 Table toolbar should not be shown for single select tables #2214

Merged
merged 40 commits into from
Nov 13, 2024

Conversation

mikieyx
Copy link
Contributor

@mikieyx mikieyx commented Oct 17, 2024

Fixes: #2213

Developer's Certificate of Origin 1.1

   By making a contribution to this project, I certify that:

   (a) The contribution was created in whole or in part by me and I
       have the right to submit it under the Apache License 2.0; or

   (b) The contribution is based upon previous work that, to the best
       of my knowledge, is covered under an appropriate open source
       license and I have the right under that license to submit that
       work with modifications, whether created in whole or in part
       by me, under the same open source license (unless I am
       permitted to submit under a different license), as indicated
       in the file; or

   (c) The contribution was provided directly to me by some other
       person who certified (a), (b) or (c) and I have not modified
       it.

   (d) I understand and agree that this project and the contribution
       are public and that a record of the contribution (including all
       personal information I submit with it, including my sign-off) is
       maintained indefinitely and may be redistributed consistent with
       this project or the open source license(s) involved.

Michael Pavlik and others added 20 commits August 27, 2024 09:55
Signed-off-by: Michael Pavlik <[email protected]>
Signed-off-by: Michael Pavlik <[email protected]>
Signed-off-by: Michael Pavlik <[email protected]>
Signed-off-by: Michael Pavlik <[email protected]>
Signed-off-by: Michael Pavlik <[email protected]>
Signed-off-by: Michael Pavlik <[email protected]>
Signed-off-by: Michael Pavlik <[email protected]>
@@ -39,6 +39,11 @@ $row-left-padding: $spacing-02;
height: $spacing-07;
}

.single-table {
Copy link
Member

Choose a reason for hiding this comment

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

This class isn't used anywhere other than this file

Copy link
Contributor Author

@mikieyx mikieyx Oct 30, 2024

Choose a reason for hiding this comment

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

I removed it on accident when merging. I used it to resolve the bug where the add value button would switch location depending on if the table was in focus

Copy link
Member

Choose a reason for hiding this comment

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

Rename to single-row-selection-table

className="delete-button"
hasIconOnly
onClick={this.props.deleteRow}
renderIcon={TrashCan}
Copy link
Member

Choose a reason for hiding this comment

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

Please add iconDescription for delete button

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey Neha, I removed iconDescription because it would fail tests due to the fact that the icon description is considered to be part of the text. Let me know if I should just remove icon description or to modify the test cases.

image

Copy link
Member

Choose a reason for hiding this comment

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

@mikieyx You should add iconDescription and modify test cases.

@@ -414,6 +415,18 @@ class VirtualizedTable extends React.Component {
readOnly={this.props.readOnly}
/>
</div>);
} else {
trashOption = (
Copy link
Member

Choose a reason for hiding this comment

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

Rename this to deleteOption

cy.toggleCommonPropertiesSidePanel();
cy.openPropertyDefinition("summaryPanel_paramDef.json");
});
// describe("Test if tips show up for the summary table values", function() {
Copy link
Member

Choose a reason for hiding this comment

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

Enable all commented tests in this file

@@ -1216,7 +1216,7 @@
},
{
"complex_type_ref": "inlineEditingTableError",
"row_selection": "single",
"row_selection": "multiple-edit",
Copy link
Member

Choose a reason for hiding this comment

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

This change is not needed. You can revert this to "single". Table looks odd because there is no header for column which has delete icons.
Screenshot 2024-10-30 at 5 32 22 PM

Take a look at how the header is added for subpanel column here - https://github.com/elyra-ai/canvas/blob/main/canvas_modules/common-canvas/src/common-properties/controls/abstract-table.jsx#L705
Screenshot 2024-10-30 at 5 34 31 PM

You should add a similar header for single select tables which will have a delete rows column.

Copy link
Contributor Author

@mikieyx mikieyx Oct 31, 2024

Choose a reason for hiding this comment

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

I switched from single to multi select because single tables no longer have the toolbar which means that single tables can no longer move rows. The table has moveable rows set to true. I discussed this with Matt and Jesus, and they mentioned to switch it to multi select to ensure test coverage.

@@ -1216,7 +1216,7 @@
},
{
"complex_type_ref": "inlineEditingTableError",
"row_selection": "single",
"row_selection": "multiple-edit",
Copy link
Member

Choose a reason for hiding this comment

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

This change is not needed. You can revert this to "single".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I switched from single to multi select because single tables no longer have the toolbar which means that single tables can no longer move rows. The table has moveable rows set to true. I discussed this with Matt and Jesus, and they mentioned to switch it to multi select to ensure test coverage.

@@ -523,7 +523,8 @@ class FlexibleTable extends React.Component {

const containerClass = this.props.showHeader ? "properties-ft-container-absolute " : "properties-ft-container-absolute-noheader ";
const messageClass = (!this.props.messageInfo) ? containerClass + STATES.INFO : containerClass;
const ftHeaderClassname = "properties-ft-table-header";
const ftHeaderClassname = classNames("properties-ft-table-header",
{ "single-table": this.props.rowSelection === ROW_SELECTION.SINGLE });
Copy link
Member

Choose a reason for hiding this comment

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

Rename to single-row-selection-table

@@ -39,6 +39,11 @@ $row-left-padding: $spacing-02;
height: $spacing-07;
}

.single-table {
Copy link
Member

Choose a reason for hiding this comment

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

Rename to single-row-selection-table

@nmgokhale
Copy link
Member

When I click on Delete icon, row gets selected and it shows the inline editable fields briefly before deleting the row -

Screen.Recording.2024-10-30.at.5.42.59.PM.mov

Is it possible to not select the row when delete icon is clicked?

@mikieyx
Copy link
Contributor Author

mikieyx commented Oct 31, 2024

When I click on Delete icon, row gets selected and it shows the inline editable fields briefly before deleting the row -

Screen.Recording.2024-10-30.at.5.42.59.PM.mov

Is it possible to not select the row when delete icon is clicked?

When you click on the delete icon, it selects the row and it triggers the removeSelected() which removes the selected row. In this situation it first detects that the row is selected which pops open the inline editable fields before deleting. I'll try to take a closer look.

Signed-off-by: Michael Pavlik <[email protected]>
@@ -703,6 +706,8 @@ export default class AbstractTable extends React.Component {
if (this.props.control.childItem && !this.isReadonlyTable()) {
// set to specific size. Exclude this column from resizing.
headers.push({ "key": "subpanel", "label": "", "width": TABLE_SUBPANEL_BUTTON_WIDTH, "staticWidth": true });
} else if (this.props.control.rowSelection === ROW_SELECTION.SINGLE) {
Copy link
Member

Choose a reason for hiding this comment

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

Remove else and just add if condition.
This code fails if the table has edit icon and delete icon both, there's only 1 table header.
To test this case, add "row_selection": "single", here - https://github.com/elyra-ai/canvas/blob/main/canvas_modules/harness/test_resources/parameterDefs/structurelisteditor_paramDef.json#L973

There are 7 columns but only 6 headers in the table.
Screenshot 2024-11-04 at 3 08 00 PM

Michael Pavlik added 2 commits November 5, 2024 09:31
@nmgokhale
Copy link
Member

In expression builder table, there's no header for delete column -
Screenshot 2024-11-05 at 11 31 35 AM

@mikieyx
Copy link
Contributor Author

mikieyx commented Nov 6, 2024

In expression builder table, there's no header for delete column - Screenshot 2024-11-05 at 11 31 35 AM

I implemented the logic to add a column for the in abstract table. Abstract table uses flexible table and the expression builder also uses flexible table. I'll try to add the a column for the delete button in flexible table or even virtualized table (flexible table uses virtualized table)

@matthoward366
Copy link
Member

@mikieyx The problem is in the expression builder there should be no delete column.

@nmgokhale do you remember how we controlled this with single select before?

@mikieyx
Copy link
Contributor Author

mikieyx commented Nov 6, 2024

@mikieyx The problem is in the expression builder there should be no delete column.

@nmgokhale do you remember how we controlled this with single select before?

image image

I can add a condition that only adds the delete icon if it's a read only table and then pass in the readOnly prop as true into the flexible table in expression-select-field-function.jsx

@nmgokhale
Copy link
Member

nmgokhale commented Nov 6, 2024

@nmgokhale do you remember how we controlled this with single select before?

createTable() in abstract-table adds a table toolbar on a table. For expression field and functions tables, it never called createTable() method. So there was no table toolbar for expression tables.
With the addition of single select check in virtualized-table, delete icon started showing up in expression tables.

I can add a condition that only adds the delete icon if it's a read only table and then pass in the readOnly prop as true into the flexible table in expression-select-field-function.jsx

@mikieyx readOnly prop is not meant to show/hide delete icon in the table.
How about we check for tableLabel and if its fieldsTableLabel, valuesTableLabel or functionsTableLabel, don't show delete icon?

} else if (this.props.rowSelection === ROW_SELECTION.SINGLE && !(this.props.tableLabel === fieldsTableLabel ||
this.props.tableLabel === valuesTableLabel || this.props.tableLabel === functionsTableLabel
)) {
const toolTip = "Delete";
Copy link
Member

Choose a reason for hiding this comment

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

This tooltip should be translated

className="delete-button"
hasIconOnly
onClick={this.props.deleteRow}
renderIcon={TrashCan}
Copy link
Member

Choose a reason for hiding this comment

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

Add iconDescription here

@@ -414,6 +418,29 @@ class VirtualizedTable extends React.Component {
readOnly={this.props.readOnly}
/>
</div>);
} else if (this.props.rowSelection === ROW_SELECTION.SINGLE && !(this.props.tableLabel === fieldsTableLabel ||
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment here -
"Don't show delete icon for tables in expression builder"

@nmgokhale
Copy link
Member

@mikieyx I am seeing extra width for Delete column -
Edit column and Delete column should have same width.
Screenshot 2024-11-07 at 11 13 57 AM

Wondering if this is because tooltip-container is outside the parent <div> for delete column.

@mikieyx
Copy link
Contributor Author

mikieyx commented Nov 7, 2024

@nmgokhale I dug into it, and it seems like the delete icons are not being connected to the right column. The headers are add in abstract table, while the delete icon is created in virtualized table. Abstract tables uses flexible table which uses virtualized table.

@@ -414,6 +413,7 @@ class VirtualizedTable extends React.Component {
readOnly={this.props.readOnly}
/>
</div>);
// Don't show delete icon for tables in expression builder
Copy link
Member

Choose a reason for hiding this comment

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

remove this comment. This is no longer applicable now after adding delete icon in abstract-table

@@ -112,5 +112,6 @@
"label.indicator.optional": "[Esperanto~(optional)~~~~~~eo]",
"slider.numberInput.label": "[Esperanto~Slider number input~~~~~eo]",
"editorForm.tabList.label": "[Esperanto~Primary Tabs~~~~eo]",
"subTabs.tabList.label": "[Esperanto~Tab List~~~~eo]"
"subTabs.tabList.label": "[Esperanto~Tab List~~~~eo]",
"table.deleteiIcon.tooltip": "[Esperanto~Delete~~~~eo]"
Copy link
Member

Choose a reason for hiding this comment

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

Typo in deleteiIcon

let deleteButton = tableToolbar.find("button.properties-action-delete");
expect(deleteButton).to.have.length(1);
deleteButton.simulate("click");
// let tableToolbar = tableWrapper.find("div.properties-table-toolbar");
Copy link
Member

Choose a reason for hiding this comment

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

Remove this comment

@@ -543,6 +543,7 @@ VirtualizedTable.propTypes = {
PropTypes.number.isRequired
]),
onRowDoubleClick: PropTypes.func,
deleteRow: PropTypes.func,
Copy link
Member

Choose a reason for hiding this comment

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

This isn't used anywhere

Signed-off-by: Michael Pavlik <[email protected]>
Copy link
Member

@nmgokhale nmgokhale left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@nmgokhale nmgokhale merged commit 3bebb81 into elyra-ai:main Nov 13, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table toolbar should not be shown for single select tables
3 participants