Skip to content

Commit

Permalink
[Graph] Replace Fontawesome with EUI + Maki icons (#162048)
Browse files Browse the repository at this point in the history
## Summary

Fixes #160232

This PR removes completely FontAwesome from the Graph plugin and replace
its usage with mostly EUI + few Maki icons.
As for the Google icon, @MichaelMarcialis do you think we should just
have a custom SVG icon within the Graph app?

Here's a list of the replaced icons, but if I forgot anything let me
know:

* [x] Created generic `IconRenderer` component to abstract away the
package type from the rendering
  * [x] Add logic for color switch based on background color
* Replace icons in graph visualization
  * [x] Replace with EUI icons
  * [x] Replace with Maki icons
  * [x] Add `prevName` to recover old saved graph SO
  * [x] Fix selection preview icon
* For the `at` and `key` icons it needs to wait for a new EUI release
with elastic/eui#6934
* Replace drill down icons 
  * [x] Replace with EUI icons
  * [x] Replace with Maki icons
  * [x] Find a substitute for Google icon
  * [x] Add `prevName` to recover old saved graph SO
* App toolbars
  * [x] Replace app toolbar icons with EUI icons
    * [x] Changed blocked list icon from `ban` to `filterIgnore`
  * [x] Replace styling icon + color swatches
    * The EUI `dot` icon was too small, so switches to rect icons 
  * [x] Replace merge icons on link selection
  * [x] Replace group/ungroup icons with `fold/unfold`
  * [x] Custom drilldowns
* [x] Removed `LegacyIcon`
  * Replaced usage in various places

New icons within field configuration + graph visualization

<img width="1061" alt="Screenshot 2023-07-17 at 11 00 35"
src="https://github.com/elastic/kibana/assets/924948/59f981e7-64b7-4ce5-b3ae-2582d46fc373">

<img width="302" alt="Screenshot 2023-07-17 at 15 13 04"
src="https://github.com/elastic/kibana/assets/924948/fb8d0e63-e982-406f-bd8d-036d71d37442">

New toolbar with blocked icon changed

<img width="202" alt="Screenshot 2023-07-17 at 15 13 40"
src="https://github.com/elastic/kibana/assets/924948/241206c4-7d3b-4296-bd6b-c2df3f3eabe5">

<img width="220" alt="Screenshot 2023-07-17 at 15 13 35"
src="https://github.com/elastic/kibana/assets/924948/5a648932-2f79-4c0e-a8d0-3ab165f68036">

<img width="272" alt="Screenshot 2023-07-17 at 12 41 12"
src="https://github.com/elastic/kibana/assets/924948/e3778d20-3000-496e-881b-61e5f086ae52">

New group/ungroup icons

<img width="168" alt="Screenshot 2023-07-17 at 12 41 25"
src="https://github.com/elastic/kibana/assets/924948/ffc963e6-4fea-4cb5-b0ef-cf8a71a71d6a">
<img width="252" alt="Screenshot 2023-07-17 at 15 15 27"
src="https://github.com/elastic/kibana/assets/924948/98b8b025-32fd-465e-9a66-40f4f866eb6e">

Selection with icons preview

<img width="260" alt="Screenshot 2023-07-17 at 15 07 17"
src="https://github.com/elastic/kibana/assets/924948/08dbda17-0c12-4fa4-8c92-77bbe90d7e14">
<img width="268" alt="Screenshot 2023-07-17 at 15 07 35"
src="https://github.com/elastic/kibana/assets/924948/78987838-42d5-46bf-9e46-b12cc603fa4e">

Panel with color styling open

<img width="266" alt="Screenshot 2023-07-17 at 15 07 44"
src="https://github.com/elastic/kibana/assets/924948/f5866e29-cf22-4e62-a2ff-3ef901c0d564">

Custom drilldowns (note Google icon has been replaced with a magnifier
icon)

<img width="331" alt="Screenshot 2023-07-18 at 17 49 07"
src="https://github.com/elastic/kibana/assets/924948/42e307d1-69b6-4e79-9e19-64c5efb7ee46">
<img width="381" alt="Screenshot 2023-07-18 at 17 51 44"
src="https://github.com/elastic/kibana/assets/924948/bc70c506-4390-45c1-aff5-8e22a68d7130">
<img width="271" alt="Screenshot 2023-07-17 at 15 08 31"
src="https://github.com/elastic/kibana/assets/924948/59fea7e4-a775-4006-805d-0610d7861890">
<img width="269" alt="Screenshot 2023-07-17 at 15 08 38"
src="https://github.com/elastic/kibana/assets/924948/f6c247a0-921d-4d9c-881a-796e02488df5">

Link selection

<img width="295" alt="Screenshot 2023-07-17 at 15 09 06"
src="https://github.com/elastic/kibana/assets/924948/d6a73013-130e-45a8-bdfc-48ac20e66a85">



### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces&mdash;unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes&mdash;Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Michael Marcialis <[email protected]>
  • Loading branch information
dej611 and MichaelMarcialis authored Jul 20, 2023
1 parent 446157f commit d064bfe
Show file tree
Hide file tree
Showing 42 changed files with 749 additions and 517 deletions.
1 change: 0 additions & 1 deletion x-pack/plugins/graph/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { Start as InspectorPublicPluginStart } from '@kbn/inspector-plugin/publi
import { TableListViewKibanaProvider } from '@kbn/content-management-table-list-view-table';

import './index.scss';
import('./font_awesome');
import { SpacesApi } from '@kbn/spaces-plugin/public';
import { KibanaThemeProvider, toMountPoint } from '@kbn/kibana-react-plugin/public';
import { SavedObjectsManagementPluginStart } from '@kbn/saved-objects-management-plugin/public';
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/graph/public/components/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@import './graph_visualization/index';
@import './venn_diagram/index';
@import './settings/index';
@import './legacy_icon/index';
@import './field_manager/index';
@import './graph';
@import './sidebar';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';
import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';
import { ControlType, Workspace, WorkspaceField } from '../../types';

interface ControlPanelToolBarProps {
Expand Down Expand Up @@ -90,138 +90,126 @@ export const ControlPanelToolBar = ({
<EuiFlexGroup gutterSize="xs" responsive={false}>
<EuiFlexItem grow={false}>
<EuiToolTip content={undoButtonMsg}>
<button
className="kuiButton kuiButton--basic kuiButton--small"
<EuiButtonIcon
iconType={'editorUndo'}
size="xs"
aria-label={undoButtonMsg}
type="button"
isDisabled={workspace.undoLog.length < 1}
onClick={onUndoClick}
disabled={workspace.undoLog.length < 1}
>
<span className="kuiIcon fa-history" />
</button>
/>
</EuiToolTip>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiToolTip content={redoButtonMsg}>
<button
className="kuiButton kuiButton--basic kuiButton--small"
<EuiButtonIcon
iconType="editorRedo"
size="xs"
aria-label={redoButtonMsg}
type="button"
isDisabled={workspace.redoLog.length === 0}
onClick={onRedoClick}
disabled={workspace.redoLog.length === 0}
>
<span className="kuiIcon fa-repeat" />
</button>
/>
</EuiToolTip>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiToolTip content={expandButtonMsg}>
<button
className="kuiButton kuiButton--basic kuiButton--small"
<EuiButtonIcon
iconType="plus"
size="xs"
aria-label={expandButtonMsg}
disabled={liveResponseFields.length === 0 || workspace.nodes.length === 0}
isDisabled={liveResponseFields.length === 0 || workspace.nodes.length === 0}
onClick={onExpandButtonClick}
>
<span className="kuiIcon fa-plus" />
</button>
/>
</EuiToolTip>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiToolTip content={addLinksButtonMsg}>
<button
className="kuiButton kuiButton--basic kuiButton--small"
<EuiButtonIcon
iconType="link"
size="xs"
aria-label={addLinksButtonMsg}
disabled={haveNodes}
isDisabled={haveNodes}
onClick={onAddLinksClick}
>
<span className="kuiIcon fa-link" />
</button>
/>
</EuiToolTip>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiToolTip content={removeVerticesButtonMsg}>
<button
<EuiButtonIcon
data-test-subj="graphRemoveSelection"
className="kuiButton kuiButton--basic kuiButton--small"
disabled={haveNodes}
iconType="trash"
size="xs"
aria-label={removeVerticesButtonMsg}
isDisabled={haveNodes}
onClick={onRemoveVerticesClick}
>
<span className="kuiIcon fa-trash" />
</button>
/>
</EuiToolTip>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiToolTip content={blocklistButtonMsg}>
<button
className="kuiButton kuiButton--basic kuiButton--small"
disabled={workspace.selectedNodes.length === 0}
<EuiButtonIcon
iconType="eyeClosed"
size="xs"
aria-label={blocklistButtonMsg}
isDisabled={workspace.selectedNodes.length === 0}
onClick={onBlockListClick}
>
<span className="kuiIcon fa-ban" />
</button>
/>
</EuiToolTip>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiToolTip content={customStyleButtonMsg}>
<button
className="kuiButton kuiButton--basic kuiButton--small"
disabled={workspace.selectedNodes.length === 0}
<EuiButtonIcon
iconType="brush"
size="xs"
aria-label={customStyleButtonMsg}
isDisabled={workspace.selectedNodes.length === 0}
onClick={onCustomStyleClick}
>
<span className="kuiIcon fa-paint-brush" />
</button>
/>
</EuiToolTip>
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiToolTip content={drillDownButtonMsg}>
<button
className="kuiButton kuiButton--basic kuiButton--small"
disabled={haveNodes}
<EuiButtonIcon
iconType="iInCircle"
size="xs"
aria-label={drillDownButtonMsg}
isDisabled={haveNodes}
onClick={onDrillDownClick}
>
<span className="kuiIcon fa-info" />
</button>
/>
</EuiToolTip>
</EuiFlexItem>

{(workspace.nodes.length === 0 || workspace.force === null) && (
<EuiFlexItem grow={false}>
<EuiToolTip content={runLayoutButtonMsg}>
<button
<EuiButtonIcon
data-test-subj="graphResumeLayout"
className="kuiButton kuiButton--basic kuiButton--small"
disabled={workspace.nodes.length === 0}
iconType="playFilled"
size="xs"
aria-label={runLayoutButtonMsg}
isDisabled={workspace.nodes.length === 0}
onClick={onRunLayoutClick}
>
<span className="kuiIcon fa-play" />
</button>
/>
</EuiToolTip>
</EuiFlexItem>
)}

{workspace.force !== null && workspace.nodes.length > 0 && (
<EuiFlexItem grow={false}>
<EuiToolTip content={pauseLayoutButtonMsg}>
<button
<EuiButtonIcon
data-test-subj="graphPauseLayout"
className="kuiButton kuiButton--basic kuiButton--small"
iconType="pause"
size="xs"
aria-label={pauseLayoutButtonMsg}
onClick={onPauseLayoutClick}
>
<span className="kuiIcon fa-pause" />
</button>
/>
</EuiToolTip>
</EuiFlexItem>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* 2.0.
*/

import { EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';
import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';
import React from 'react';
import { UrlTemplate } from '../../types';
import { IconRenderer } from '../icon_renderer';

interface UrlTemplateButtonsProps {
urlTemplates: UrlTemplate[];
Expand All @@ -21,7 +22,7 @@ export const DrillDownIconLinks = ({
openUrlTemplate,
}: UrlTemplateButtonsProps) => {
const drillDownsWithIcons = urlTemplates.filter(
({ icon }: UrlTemplate) => icon && icon.class !== ''
({ icon }: UrlTemplate) => icon && icon.id !== ''
);

if (drillDownsWithIcons.length === 0) {
Expand All @@ -34,14 +35,12 @@ export const DrillDownIconLinks = ({
return (
<EuiFlexItem grow={false}>
<EuiToolTip content={cur.description}>
<button
className="kuiButton kuiButton--basic kuiButton--small"
type="button"
disabled={hasNodes}
<EuiButtonIcon
iconType={cur.icon ? () => <IconRenderer icon={cur.icon} /> : ''}
size="xs"
isDisabled={hasNodes}
onClick={onUrlTemplateClick}
>
<span className={`kuiIcon ${cur.icon?.class || ''}`} />
</button>
/>
</EuiToolTip>
</EuiFlexItem>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiIcon } from '@elastic/eui';
import { UrlTemplate } from '../../types';
import { IconRenderer } from '../icon_renderer';

interface DrillDownsProps {
urlTemplates: UrlTemplate[];
Expand All @@ -18,7 +20,7 @@ export const DrillDowns = ({ urlTemplates, openUrlTemplate }: DrillDownsProps) =
return (
<div>
<div className="gphSidebar__header">
<span className="kuiIcon fa-info" />
<EuiIcon type="iInCircle" />{' '}
{i18n.translate('xpack.graph.sidebar.drillDownsTitle', {
defaultMessage: 'Drill-downs',
})}
Expand All @@ -41,7 +43,7 @@ export const DrillDowns = ({ urlTemplates, openUrlTemplate }: DrillDownsProps) =
<li className="list-group-item">
{urlTemplate.icon && (
<>
<span className="kuiIcon gphNoUserSelect">{urlTemplate.icon?.code}</span>{' '}
<IconRenderer icon={urlTemplate.icon} className="gphNoUserSelect" />{' '}
</>
)}
<a aria-hidden="true" onClick={onOpenUrlTemplate}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';
import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiIcon, EuiToolTip } from '@elastic/eui';
import { ControlType, TermIntersect, Workspace } from '../../types';
import { VennDiagram } from '../venn_diagram';

Expand Down Expand Up @@ -44,7 +44,7 @@ export const MergeCandidates = ({
return (
<div className="gphSidebar__panel">
<div className="gphSidebar__header">
<span className="kuiIcon fa-link" />
<EuiIcon type="link" />{' '}
{i18n.translate('xpack.graph.sidebar.linkSummaryTitle', {
defaultMessage: 'Link summary',
})}
Expand Down Expand Up @@ -102,28 +102,26 @@ export const MergeCandidates = ({
<div>
<span>
<EuiToolTip content={mergeTerm1ToTerm2ButtonMsg}>
<button
type="button"
<EuiButtonIcon
iconType="doubleArrowRight"
size="xs"
style={{ opacity: 0.2 + mc.overlap / mc.v1 }}
className="kuiButton kuiButton--basic kuiButton--small"
aria-label={mergeTerm1ToTerm2ButtonMsg}
onClick={onMergeTerm1ToTerm2Click}
>
<span className="kuiIcon fa-chevron-circle-right" />
</button>
/>
</EuiToolTip>

<span className="gphLinkSummary__term--1">{mc.term1}</span>
<span className="gphLinkSummary__term--2">{mc.term2}</span>

<EuiToolTip content={mergeTerm2ToTerm1ButtonMsg}>
<button
type="button"
className="kuiButton kuiButton--basic kuiButton--small"
<EuiButtonIcon
iconType="doubleArrowLeft"
size="xs"
style={{ opacity: 0.2 + mc.overlap / mc.v2 }}
aria-label={mergeTerm2ToTerm1ButtonMsg}
onClick={onMergeTerm2ToTerm1Click}
>
<span className="kuiIcon fa-chevron-circle-left" />
</button>
/>
</EuiToolTip>
</span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiIcon } from '@elastic/eui';
import { Workspace } from '../../types';

interface SelectStyleProps {
Expand All @@ -18,7 +19,7 @@ export const SelectStyle = ({ colors, workspace }: SelectStyleProps) => {
return (
<div className="gphSidebar__panel">
<div className="gphSidebar__header">
<span className="kuiIcon fa-paint-brush" />
<EuiIcon type="brush" size="s" />{' '}
{i18n.translate('xpack.graph.sidebar.styleVerticesTitle', {
defaultMessage: 'Style selected vertices',
})}
Expand All @@ -31,11 +32,12 @@ export const SelectStyle = ({ colors, workspace }: SelectStyleProps) => {
workspace.changeHandler();
};
return (
<span
<EuiIcon
type="stopFilled"
color={c}
className="gphColorPicker__color"
aria-hidden="true"
onClick={onSelectColor}
style={{ color: c }}
className="kuiIcon gphColorPicker__color fa-circle"
/>
);
})}
Expand Down
Loading

0 comments on commit d064bfe

Please sign in to comment.