-
Notifications
You must be signed in to change notification settings - Fork 356
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
Convert trees to react #6413
Convert trees to react #6413
Conversation
Todo
|
Catalog tree styling should be fixed in #6511 |
@ZitaNemeckova could you please test this? |
app/assets/javascripts/controllers/catalog/catalog_item_form_controller.js
Outdated
Show resolved
Hide resolved
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 way we are handling the onclick/oncheck for each tree is a disaster. Of course you're not the one who's responsible for it, so I think we can keep it this way until I come up with something better. But there are a few nitpicks.
Checked commits https://github.com/brumik/manageiq-ui-classic/compare/da20191813c2fc084a1fa0d82c131a270a4f76b6~...73ee7e1ce170f62f0b981593d4610d41361248c4 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint app/views/miq_policy/_alert_profile_assign.html.haml
app/views/shared/_tree.html.haml
|
Merging, everything seems to work, no major issues :) @brumik I do see 2 very minor issues, but we can solve those in a separate PR: Group edit - assigned filters:
The same happens when adding an ansible playbook catalog item: VM Snapshot - clicking an active item deactivates it: on master, there's no deactivation (and no request when already active). |
So, the indent issue: from => the expand chevron total width would have to be But also react-ui-components wooden-tree css overrides the icon, setting @brumik should we try to keep the spacing upstream? If so, it needs to set a specific width for the chevron icon (not necesarily the other icons), and use that width+margin in the computation, something like... diff --git a/src/components/Tree.tsx b/src/components/Tree.tsx
index 474500f..d977bd3 100644
--- react-wooden-tree/src/components/Tree.tsx
+++ react-wooden-tree/src/components/Tree.tsx
@@ -333,11 +333,18 @@ export class Tree extends React.PureComponent<TreeProps, {}> {
*/
private static generateIndentCSS(depth: number): string {
let cssRules: string = '';
- let indentSize = 1;
+ let indentSize = '1em';
+ let chevronSize = '1em + 7px';
+
for (let i = 0; i < depth; i++) {
cssRules += `
- .react-tree-view .indent-${i}{padding-left:${indentSize * i}em}
- .react-tree-view .indent-${i}.no-open-button{padding-left:calc(${indentSize * i + indentSize}em + 4px)}`;
+ .react-tree-view .indent-${i} {
+ padding-left: calc(${indentSize} * ${i});
+ }
+ .react-tree-view .indent-${i}.no-open-button {
+ padding-left: calc(${indentSize} * ${i} + ${chevronSize});
+ }
+ `;
}
return cssRules;
} (Well, or just Or, if not, there should probably be a way to disable the indent css generation, diff --git a/src/wooden-tree/index.scss b/src/wooden-tree/index.scss
index 7a364ea..b26be41 100644
--- react-ui-components/src/wooden-tree/index.scss
+++ react-ui-components/src/wooden-tree/index.scss
@@ -3,13 +3,12 @@
padding-left: 0;
}
- li :first-child {
+ li > :first-child {
display: inline-block;
}
i.icon {
- width: 1em;
- box-sizing: content-box;
+ width: calc(1em + 3px);
padding: 2px;
padding-right: 1px;
margin-right: 4px;
@@ -23,4 +22,15 @@
background-color: #349ad3;
color: #FFFFFF;
}
+
+ $indentSize: "1em";
+ $chevronSize: "1em + 7px";
+ @for $i from 0 through 5 {
+ .indent-#{$i} {
+ padding-left: calc(#{$indentSize} * #{$i}) !important;
+ &.no-open-button {
+ padding-left: calc(#{$indentSize} * #{$i} + #{$chevronSize}) !important;
+ }
+ }
+ }
} ( With the react-ui-components fix: |
I am willing to make these changes to the component itself - it looks like the more reasonable solution. Also if you can propose a better CSS behaviour I am open: I know that generating and injecting CSS right under the tree (multiple times if there are multiple trees) is not perfect, but it was the best solution I could find. |
Aah, great, agreed .. should I open a PR or do you want to do this? :) As for the injection.. well, one possibility is to use invisible padder elements that can be naturally stacked, like having a But I'm not really against the injection that much, if it can be relied upon. But maybe adding optional |
I didn't want a stacker as it slows down the component by a huge margin and it was built for performance. If you can do it easily please create a PR there (don't have it locally since the reinstall). I think it uses schematic release it is just not documented yet ( |
OK, step 1: brumik/react-wooden-tree#50 (released in react-wooden-tree 2.1.5) |
Editing Role - the rbac tree no longer sends any miq_observe notifications - so form buttons no longer work. (found by @h-kataria) |
^ caused by 87f53cc
|
Just asked @brumik, he'll have a few hours to look at it tomorrow. It'll be a nice recharge 😉 |
The problem is that the tree name in edit and non-edit mode is the same, so first the tree is initialized without a reducer for oncheck and then re-rendered and not initialized with the right oncheck reducer. I guess the safest solution is to rename the non-edit tree as it has less moving parts. |
Tree updates
Converts the trees to the new react tree, adding all the required functionality:
Affected trees (at least) by screens
------------------------------------------------------------------------------------------------------------------------------------
@miq-bot add_reviewer @skateman
@miq-bot add_reviewer @Hyperkid123
@miq-bot add_reviewer @himdel
@martinpovolny
@miq-bot add_label hammer/no
@miq-bot add_label react
@miq-bot add_label trees