From 59df33ffbffd951c53500d13d775c7d425cff048 Mon Sep 17 00:00:00 2001 From: Martin Povolny Date: Wed, 18 Sep 2019 21:11:24 +0200 Subject: [PATCH] Toolbars: final touches in Dashboard and Topology toolbars. --- .../components/dashboard_toolbar.jsx | 68 ++++++++++--------- .../components/topology_toolbar.jsx | 16 ++--- app/views/dashboard/_widgets_menu.html.haml | 32 --------- .../shared/_topology_header_toolbar.html.haml | 39 ----------- 4 files changed, 41 insertions(+), 114 deletions(-) delete mode 100644 app/views/dashboard/_widgets_menu.html.haml delete mode 100644 app/views/shared/_topology_header_toolbar.html.haml diff --git a/app/javascript/components/dashboard_toolbar.jsx b/app/javascript/components/dashboard_toolbar.jsx index f9a09b272eb..31327036c1d 100644 --- a/app/javascript/components/dashboard_toolbar.jsx +++ b/app/javascript/components/dashboard_toolbar.jsx @@ -2,44 +2,47 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Dropdown, MenuItem } from 'patternfly-react'; +const addClick = item => + window.miqJqueryRequest(`widget_add?widget=${item.id}`, { beforeSend: true, complete: true }); + +const resetClick = () => { + /* eslint no-alert: off */ + if (window.confirm(__("Are you sure you want to reset this Dashboard's Widgets to the defaults?"))) { + window.miqJqueryRequest('reset_widgets', { beforeSend: true }); + } +}; + const resetButton = () => ( -) - -const addClick = (item) => - miqJqueryRequest(`widget_add?widget=${item.id}`, { beforeSend: true, complete: true }); - -const resetClick = () => { - if (confirm(__("Are you sure you want to reset this Dashboard's Widgets to the defaults?"))) { - miqJqueryRequest('reset_widgets', { beforeSend: true }); - } -} +); const addMenu = (items, locked) => { - const [ title, cls ] = locked - ? [__("Cannot add a Widget, this Dashboard has been locked by the Administrator"), 'disabled'] - : [__("Add a widget"), '']; + const title = locked + ? __('Cannot add a Widget, this Dashboard has been locked by the Administrator') + : __('Add a widget'); return ( - - @@ -42,11 +35,10 @@ const TopologyToolbar = () => ( >
-
diff --git a/app/views/dashboard/_widgets_menu.html.haml b/app/views/dashboard/_widgets_menu.html.haml deleted file mode 100644 index 22b88f85948..00000000000 --- a/app/views/dashboard/_widgets_menu.html.haml +++ /dev/null @@ -1,32 +0,0 @@ -.form-group - .btn-group.dropdown - - if @widgets_menu[:blank] - %button.disabled.btn.btn-default.dropdown-toggle{'data-toggle' => 'dropdown', :title => _('No Widgets available to add'), 'data-click' => 'add_widget'} - %i.fa.fa-reply.fa-lg - %span.caret - - else - - if @widgets_menu[:allow_add] - - if @widgets_menu[:locked] - - title = _("Cannot add a Widget, this Dashboard has been locked by the Administrator") - - enabled = false - - else - - title = _("Add a widget") - - enabled = true - - cls = enabled ? '' : 'disabled ' - %button{'data-toggle' => 'dropdown', :class => "#{cls}btn btn-default dropdown-toggle", :title => title} - %i.fa.fa-plus.fa-lg - %span.caret - - %ul.dropdown-menu.scrollable-menu - - @widgets_menu[:items].each do |item| - %li - - if item[:type] == :separator - .divider{:role => 'presentation'} - - else - %a{:href => '#', :title => item[:title], 'data-click' => item[:id]} - %i{:class => item[:image]} - = item[:text] - - - if @widgets_menu[:allow_reset] - %button.btn.btn-default{:title => _('Reset Dashboard Widgets to the defaults'), 'data-click' => 'reset'} - %i.fa.fa-reply.fa-lg diff --git a/app/views/shared/_topology_header_toolbar.html.haml b/app/views/shared/_topology_header_toolbar.html.haml deleted file mode 100644 index 459af802ae1..00000000000 --- a/app/views/shared/_topology_header_toolbar.html.haml +++ /dev/null @@ -1,39 +0,0 @@ -.form-group.text - %label.topology-checkbox.checkbox-inline - %input#box_display_names{:type => 'checkbox'} - = _("Display Names") - -.form-group - %button.btn.btn-default{:title => _('Refresh this page'), - 'data-function' => 'sendDataWithRx', - 'data-function-data' => {:name => 'refreshTopology'}.to_json} - %i.fa.fa-refresh.fa-lg - = _("Refresh") -%form.search-pf.topology-search{:role => 'form', - :onsubmit => 'sendDataWithRx({service: "topologyService", name: "searchNode", args: [] }); return false'} - .form-group.has-clear - .search-pf-input-group - %label.sr-only{:for => 'search'} - = _("Search") - - %input#search_topology.form-control{:type => 'search', - 'placeholder' => _("Search")} - - -# 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 :) - %button.hidden{'data-function' => 'sendDataWithRx', - 'data-function-data' => {:service => 'topologyService', - :name => 'searchNode'}.to_json} - - %button.clear{'aria-hidden' => 'true', - 'data-function' => 'sendDataWithRx', - 'data-function-data' => {:service => 'topologyService', - :name => 'resetSearch'}.to_json} - %span.pficon.pficon-close - - .form-group.search-button - %button.btn.btn-default.search-topology-button{'data-function' => 'sendDataWithRx', - 'data-function-data' => {:service => 'topologyService', - :name => 'searchNode'}.to_json} - %span.fa.fa-search