Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Toolbar implementation in React #115

Merged
merged 18 commits into from
Sep 24, 2019
Merged

Conversation

martinpovolny
Copy link
Member

@martinpovolny martinpovolny commented May 15, 2019

toolbars-2019-05-15_14-23

Depends on patternfly/patternfly-react#2041 (merged)
patternfly/patternfly-react#2984 (merged)

TODO:

  • make the bundle size smaller
  • remove the data- tags (done)

name={props.name}
title={props.title}
className={classNames('btn btn-default', { active: props.selected, disabled: !props.enabled })}
data-explorer={props.explorer}
Copy link
Contributor

Choose a reason for hiding this comment

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

could you get rid of these explicit keys in favor of generic data?

No part of toolbar code (except for miqToolbarOnClick) should be aware that data-function and data-function-data and data-click even exist.. (and all the others).

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess yes. Just I'd love to get a functional parity with the current implementation first and then improve.

But right, using generic data should be fine as long as we do not handle some data- key in some special way in the current implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will be removing all the data- tags because the onClick handler now uses props directly. So this will go away.

@martinpovolny
Copy link
Member Author

ping @himdel, @rvsia


import CountContext from './ToolbarContext';

// const classNames = require('classnames');
Copy link

Choose a reason for hiding this comment

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

comment here

const toolbarGroupHasContent = group =>
group &&
group.filter(item => item &&
(isButtonOrSelect(item))).length !== 0;
Copy link

Choose a reason for hiding this comment

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

unnecessary parenthesis around isButtonOrSelect


const classNames = require('classnames');

const ButtonIcon = (props) => {
Copy link

Choose a reason for hiding this comment

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

({ img_url: imgUrl, icon, color, enabled })

enabled: PropTypes.bool,
};

/* FIXME
Copy link

Choose a reason for hiding this comment

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

What about these comments? Are they still valid?

data: PropTypes.any,
selected: PropTypes.bool,
enabled: PropTypes.bool,
// hidden: PropTypes.bool,
Copy link

Choose a reason for hiding this comment

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

commented prop

.kebab .btn-group.open .dropdown-toggle {
box-shadow: none;
}

Copy link

Choose a reason for hiding this comment

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

empty line


describe('Toolbar', () => {
it('Well it works ;-)', () => {
const t = shallow(<Toolbar
Copy link

Choose a reason for hiding this comment

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

I would rename t to something more meaningful

Copy link
Member Author

Choose a reason for hiding this comment

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

well I like the 't' as toolbar, or the test subject

I think that the short name does not negatively affect readability in this context

@@ -0,0 +1,97 @@
import React from 'react';
import toJson from 'enzyme-to-json';
Copy link

Choose a reason for hiding this comment

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

You don't use it here

id: PropTypes.string,
name: PropTypes.string,
url: PropTypes.string,
url_parms: PropTypes.any,
Copy link

Choose a reason for hiding this comment

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

This triggers Prop type any is forbidden eslint(react/forbid-prop-types)

import { ToolbarList } from '../ToolbarList';
import { ToolbarView } from '../ToolbarView';

const toolbarData = require('../data/toolbar-big.json');
Copy link

Choose a reason for hiding this comment

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

you can use import here

@rvsia
Copy link

rvsia commented Sep 20, 2019

Looks solid and works well in the storybook! 👍 I found only small nitpicks.

@rvsia
Copy link

rvsia commented Sep 20, 2019

Actually missed few UX issues:

  1. Disabled buttons are white, when you make them active (click and hold it)

image

  1. You can open one item by clicking and you can open the other items by hovering at the same time

image

  1. Buttons will expand the page, when they don't have space

toolbarbug

@@ -0,0 +1,78 @@
import React from 'react';
import PropTypes from 'prop-types';
import { DropdownButton, MenuItem } from 'patternfly-react';
Copy link

Choose a reason for hiding this comment

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

Put HorizontalNavMenuItem here

@martinpovolny
Copy link
Member Author

martinpovolny commented Sep 23, 2019

@rvsia: used your code to fix the multi-open issue (2.), made a small PR to PF3 to fix the console error: patternfly/patternfly-react#2984

@martinpovolny
Copy link
Member Author

Fixed UX issue (1.)

I think that the 3rd issue is PF issue and I'd prefer to work on that separately if needed (if it's relevant for ManageIQ where the custom buttons buttons should not be rightmost, I belive).


return (
<div className="kebab">
<DropdownButton id="menu_kebab" title={<span className="fa fa-ellipsis-v" />}>
Copy link

Choose a reason for hiding this comment

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

Please provide here onClick={() => setIsOpenId(undefined)} to reset the openId when user closes/opens the kebab

}

if (item.type === 'buttonSelect') {
return <ToolbarSubmenu key={item.id} {...item} onClick={onClick} onSelect={console.log} openId={openId} setIsOpenId={setIsOpenId} />;
Copy link

Choose a reason for hiding this comment

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

console.log here

@rvsia
Copy link

rvsia commented Sep 24, 2019

I still see the first issue

issue1

Ad issue 3) If it's not relevant now, I am fine with skipping it.

@miq-bot
Copy link
Member

miq-bot commented Sep 24, 2019

Checked commits martinpovolny/react-ui-components@cd4de67~...570de8a with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
0 files checked, 0 offenses detected
Everything looks fine. ⭐

@martinpovolny
Copy link
Member Author

martinpovolny commented Sep 24, 2019

I cannot tell why the issue got back, was pretty sure I got it right yesterday. However I have redone the rule to be more specific and added important! as the offending rule has that :-(

Now it looks good to me.

Thx!

Copy link

@rvsia rvsia left a comment

Choose a reason for hiding this comment

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

🏆

@himdel himdel merged commit 48af602 into ManageIQ:master Sep 24, 2019
@himdel himdel self-assigned this Sep 24, 2019
@karelhala
Copy link
Contributor

🎉 This PR is included in version 0.11.47 🎉

The release is available on:

Your semantic-release bot 📦🚀

@himdel
Copy link
Contributor

himdel commented Sep 24, 2019

@martinpovolny One more issue I'm seeing in the screenshots - mixing buttons with and without icon in the dropdown causes surprising alignment.

I think we should have 2 cases - no icons in the dropdown would render as is,
but if there's at least one icon, we should align labels under labels, even when there is no icon for that particular label

(I think an empty icon div with .fa-fw (fixed width) should help)

@martinpovolny
Copy link
Member Author

Let me take a look into that in a follow-up PR.

@h-kataria h-kataria added the enhancement New feature or request label Oct 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants