|
1 | 1 | import React, { useState, useCallback, useMemo } from 'react'; |
2 | | -import { ReactFlow, Background, Controls, MarkerType, Node, Panel } from '@xyflow/react'; |
| 2 | +import { ReactFlow, Background, Controls, MarkerType, Node } from '@xyflow/react'; |
| 3 | +import { Button, Popover } from '@ui5/webcomponents-react'; |
3 | 4 | import type { NodeProps } from '@xyflow/react'; |
4 | | -import { RadioButton, FlexBox, FlexBoxAlignItems } from '@ui5/webcomponents-react'; |
5 | 5 | import styles from './Graph.module.css'; |
6 | 6 | import '@xyflow/react/dist/style.css'; |
7 | 7 | import { NodeData, ColorBy } from './types'; |
@@ -32,7 +32,8 @@ const Graph: React.FC = () => { |
32 | 32 | const { t } = useTranslation(); |
33 | 33 | const { openInAside } = useSplitter(); |
34 | 34 | const { isDarkTheme } = useTheme(); |
35 | | - const [colorBy, setColorBy] = useState<ColorBy>('provider'); |
| 35 | + const [colorBy, setColorBy] = useState<ColorBy>('source'); |
| 36 | + const [filterPopoverOpen, setFilterPopoverOpen] = useState(false); |
36 | 37 |
|
37 | 38 | const handleYamlClick = useCallback( |
38 | 39 | (item: ManagedResourceItem) => { |
@@ -92,37 +93,56 @@ const Graph: React.FC = () => { |
92 | 93 | > |
93 | 94 | <Controls showInteractive={false} /> |
94 | 95 | <Background /> |
95 | | - <Panel position="top-left"> |
96 | | - <FlexBox alignItems={FlexBoxAlignItems.Center} role="radiogroup"> |
97 | | - <fieldset className={styles.fieldsetReset}> |
98 | | - <div className={styles.graphHeader}> |
99 | | - <span className={styles.colorizedTitle}>{t('Graphs.colorizedTitle')}</span> |
100 | | - <RadioButton |
101 | | - name="colorBy" |
102 | | - text={t('Graphs.colorsProviderConfig')} |
103 | | - checked={colorBy === 'provider'} |
104 | | - onChange={() => setColorBy('provider')} |
105 | | - /> |
106 | | - <RadioButton |
107 | | - name="colorBy" |
108 | | - text={t('Graphs.colorsProvider')} |
109 | | - checked={colorBy === 'source'} |
110 | | - onChange={() => setColorBy('source')} |
111 | | - /> |
112 | | - <RadioButton |
113 | | - name="colorBy" |
114 | | - text={t('Graphs.colorsFlux')} |
115 | | - checked={colorBy === 'flux'} |
116 | | - onChange={() => setColorBy('flux')} |
117 | | - /> |
118 | | - </div> |
119 | | - </fieldset> |
120 | | - </FlexBox> |
121 | | - </Panel> |
122 | | - <Panel position="top-right"> |
123 | | - <Legend legendItems={legendItems} /> |
124 | | - </Panel> |
125 | 96 | </ReactFlow> |
| 97 | + |
| 98 | + <div className={styles.topLegendContainer}> |
| 99 | + <Legend legendItems={legendItems}/> |
| 100 | + <Popover |
| 101 | + opener="filter-button" |
| 102 | + open={filterPopoverOpen} |
| 103 | + onClose={() => setFilterPopoverOpen(false)} |
| 104 | + placement="Top" |
| 105 | + > |
| 106 | + <div className={styles.popoverButtonContainer}> |
| 107 | + <Button |
| 108 | + design={colorBy === 'source' ? 'Emphasized' : 'Default'} |
| 109 | + onClick={() => { |
| 110 | + setColorBy('source'); |
| 111 | + setFilterPopoverOpen(false); |
| 112 | + }} |
| 113 | + > |
| 114 | + {t('Graphs.colorsProvider')} |
| 115 | + </Button> |
| 116 | + <Button |
| 117 | + design={colorBy === 'provider' ? 'Emphasized' : 'Default'} |
| 118 | + onClick={() => { |
| 119 | + setColorBy('provider'); |
| 120 | + setFilterPopoverOpen(false); |
| 121 | + }} |
| 122 | + > |
| 123 | + {t('Graphs.colorsProviderConfig')} |
| 124 | + </Button> |
| 125 | + <Button |
| 126 | + design={colorBy === 'flux' ? 'Emphasized' : 'Default'} |
| 127 | + onClick={() => { |
| 128 | + setColorBy('flux'); |
| 129 | + setFilterPopoverOpen(false); |
| 130 | + }} |
| 131 | + > |
| 132 | + {t('Graphs.colorsFlux')} |
| 133 | + </Button> |
| 134 | + </div> |
| 135 | + </Popover> |
| 136 | + <div className={styles.filterIcon}> |
| 137 | + <Button |
| 138 | + id="filter-button" |
| 139 | + design="Transparent" |
| 140 | + icon="filter" |
| 141 | + tooltip={t('Graphs.colorizedTitle')} |
| 142 | + onClick={() => setFilterPopoverOpen(!filterPopoverOpen)} |
| 143 | + /> |
| 144 | + </div> |
| 145 | + </div> |
126 | 146 | </div> |
127 | 147 | </div> |
128 | 148 | ); |
|
0 commit comments