Skip to content

Commit

Permalink
Toolbars: TopologyToolbar converted to a React component.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpovolny committed Sep 13, 2019
1 parent 16bd789 commit 14a61df
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 10 deletions.
18 changes: 8 additions & 10 deletions app/javascript/components/dashboard_toolbar.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { useEffect, useReducer } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import { Dropdown, DropdownButton, MenuItem } from 'patternfly-react';

// app/views/dashboard/_widgets_menu.html.haml
import { Dropdown, MenuItem } from 'patternfly-react';

const resetButton = () => (
<button
Expand All @@ -24,7 +22,7 @@ const resetClick = () => {
}

const addMenu = (items, locked) => {
const [ title, cls ] = locked
const [ title, cls ] = locked
? [__("Cannot add a Widget, this Dashboard has been locked by the Administrator"), 'disabled']
: [__("Add a widget"), ''];

Expand All @@ -48,13 +46,13 @@ const addMenu = (items, locked) => {
};

const renderDisabled = () => (
<div className='btn-group.dropdown'>
<div className="btn-group.dropdown">
<button
className='disabled btn btn-default dropdown-toggle'
title={__('No Widgets available to add')}
className="disabled btn btn-default dropdown-toggle"
title={__("No Widgets available to add")}
>
<i className='fa fa-reply fa-lg' />
<span className='caret' />
<i className="fa fa-reply fa-lg" />
<span className="caret" />
</button>
</div>
);
Expand Down
66 changes: 66 additions & 0 deletions app/javascript/components/topology_toolbar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from 'react';

const searchClick = () => {
console.log('searchClick');
sendDataWithRx({ service: 'topologyService', name: 'searchNode' });
};

const refreshClick = () => {
sendDataWithRx({ name: 'refreshTopology' });
};

const resetSearchClick = () => {
console.log('resetSearchClick');
sendDataWithRx({ service: 'topologyService', name: 'resetSearch' });
};
// # this hidden button is a workaround
// # pressing enter in ^input triggers a *click* event on the next button
// # without this, that button is resetSearch, which ..is undesirable :)

// app/views/shared/_topology_header_toolbar.html.haml
const TopologyToolbar = () => (
<div className="toolbar-pf-actions miq-toolbar-actions">
<div className="miq-toolbar-group form-group">
<div className="form-group text">
<label className="topology-checkbox checkbox-inline">
<input id="box_display_names" type="checkbox" />
{__('Display Names')}
</label>
</div>
<div className="form-group">
<button type="button" className="btn btn-default" title={__('Refresh this page')} onClick={refreshClick} >
<i className="fa fa-refresh fa-lg" />
{__('Refresh')}
</button>
</div>
<form
style={{ display: 'inline' }}
className="search-pf topology-search"
onSubmit={searchClick}
>
<div className="form-group has-clear">
<div className="search-pf-input-group">
<label className="sr-only" htmlFor="search">
{__('Search')}
</label>
<input id="search_topology" className="form-control" type="search" placeholder={__('Search')} />
<button type="button" className="hidden" onClick={searchClick} />
<button type="button" className="clear" aria-hidden="true" onClick={resetSearchClick}>
<span className="pficon pficon-close" />
</button>
</div>
</div>
<div className="form-group search-button">
<button type="button" className="btn btn-default search-topology-button" onClick={searchClick}>
<span className="fa fa-search" />
</button>
</div>
</form>
</div>
</div>
);

TopologyToolbar.propTypes = {
};

export default TopologyToolbar;

0 comments on commit 14a61df

Please sign in to comment.