Skip to content

Commit 79512d4

Browse files
committed
frontend: components: redux: Add feature to keep resource maps expanded by default
1 parent 1f33483 commit 79512d4

File tree

16 files changed

+85
-5
lines changed

16 files changed

+85
-5
lines changed

frontend/src/components/App/Settings/Settings.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ export default function Settings() {
4343
const storedTimezone = settingsObj.timezone;
4444
const storedRowsPerPageOptions = settingsObj.tableRowsPerPageOptions;
4545
const storedSortSidebar = settingsObj.sidebarSortAlphabetically;
46+
const resourceMapAlwaysExpand = settingsObj.resourceMapAlwaysExpand;
4647
const storedUseEvict = settingsObj.useEvict;
4748
const [selectedTimezone, setSelectedTimezone] = useState<string>(
4849
storedTimezone || Intl.DateTimeFormat().resolvedOptions().timeZone
4950
);
5051
const [sortSidebar, setSortSidebar] = useState<boolean>(storedSortSidebar);
52+
const [alwaysExpand, setAlwaysExpand] = useState<boolean>(resourceMapAlwaysExpand);
5153
const [useEvict, setUseEvict] = useState<boolean>(storedUseEvict);
5254
const dispatch = useDispatch();
5355
const themeName = useTypedSelector(state => state.theme.name);
@@ -77,10 +79,19 @@ export default function Settings() {
7779
);
7880
}, [useEvict]);
7981

82+
useEffect(() => {
83+
dispatch(
84+
setAppSettings({
85+
resourceMapAlwaysExpand: alwaysExpand,
86+
})
87+
);
88+
}, [alwaysExpand]);
89+
8090
const sidebarLabelID = 'sort-sidebar-label';
8191
const evictLabelID = 'use-evict-label';
8292
const tableRowsLabelID = 'rows-per-page-label';
8393
const timezoneLabelID = 'timezone-label';
94+
const alwaysExpandID = 'always-expand-label';
8495

8596
return (
8697
<SectionBox
@@ -160,6 +171,20 @@ export default function Settings() {
160171
),
161172
nameID: evictLabelID,
162173
},
174+
{
175+
name: t('translation|Always Expand Resource Map groups'),
176+
value: (
177+
<Switch
178+
color="primary"
179+
checked={alwaysExpand}
180+
onChange={e => setAlwaysExpand(e.target.checked)}
181+
inputProps={{
182+
'aria-labelledby': alwaysExpandID,
183+
}}
184+
/>
185+
),
186+
nameID: alwaysExpandID,
187+
},
163188
]}
164189
/>
165190
<Box

frontend/src/components/App/Settings/__snapshots__/Settings.General.stories.storyshot

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,13 @@
382382
</span>
383383
</dd>
384384
<dt
385-
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-3 MuiGrid-grid-md-2 css-1779c3p-MuiGrid-root"
385+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-3 MuiGrid-grid-md-2 css-1g8ukv4-MuiGrid-root"
386386
id="use-evict-label"
387387
>
388388
Use evict for pod deletion
389389
</dt>
390390
<dd
391-
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-9 MuiGrid-grid-md-10 css-ui3itl-MuiGrid-root"
391+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-9 MuiGrid-grid-md-10 css-1dbzfsd-MuiGrid-root"
392392
>
393393
<span
394394
class="MuiSwitch-root MuiSwitch-sizeMedium css-julti5-MuiSwitch-root"
@@ -414,6 +414,38 @@
414414
/>
415415
</span>
416416
</dd>
417+
<dt
418+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-3 MuiGrid-grid-md-2 css-1779c3p-MuiGrid-root"
419+
id="always-expand-label"
420+
>
421+
Always Expand Resource Map groups
422+
</dt>
423+
<dd
424+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-9 MuiGrid-grid-md-10 css-ui3itl-MuiGrid-root"
425+
>
426+
<span
427+
class="MuiSwitch-root MuiSwitch-sizeMedium css-julti5-MuiSwitch-root"
428+
>
429+
<span
430+
class="MuiButtonBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary PrivateSwitchBase-root MuiSwitch-switchBase MuiSwitch-colorPrimary css-1emuodk-MuiButtonBase-root-MuiSwitch-switchBase"
431+
>
432+
<input
433+
aria-labelledby="always-expand-label"
434+
class="PrivateSwitchBase-input MuiSwitch-input css-1m9pwf3"
435+
type="checkbox"
436+
/>
437+
<span
438+
class="MuiSwitch-thumb css-jsexje-MuiSwitch-thumb"
439+
/>
440+
<span
441+
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
442+
/>
443+
</span>
444+
<span
445+
class="MuiSwitch-track css-1yjjitx-MuiSwitch-track"
446+
/>
447+
</span>
448+
</dd>
417449
</dl>
418450
<div
419451
class="MuiBox-root css-1k57ox4"

frontend/src/components/resourceMap/GraphView.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,16 @@ function GraphViewContent({
168168
// Expand all groups state
169169
const [expandAll, setExpandAll] = useState(false);
170170

171+
// Expand by Default
172+
const alwaysExpand = useTypedSelector(state => state.config.settings.resourceMapAlwaysExpand);
173+
useEffect(() => {
174+
if (alwaysExpand) {
175+
setExpandAll(true);
176+
} else {
177+
setExpandAll(false);
178+
}
179+
}, [alwaysExpand]);
180+
171181
// Load source data
172182
const { nodes, edges, selectedSources, sourceData, isLoading, toggleSelection } = useSources();
173183

@@ -237,10 +247,10 @@ function GraphViewContent({
237247

238248
const graphSize = getGraphSize(visibleGraph);
239249
useEffect(() => {
240-
if (expandAll && graphSize > 50) {
250+
if (expandAll && !alwaysExpand && graphSize > 50) {
241251
setExpandAll(false);
242252
}
243-
}, [graphSize]);
253+
}, [graphSize, expandAll, alwaysExpand]);
244254

245255
const contextValue = useMemo(
246256
() => ({ nodeSelection: selectedNodeId, setNodeSelection: setSelectedNodeId }),
@@ -332,7 +342,7 @@ function GraphViewContent({
332342
onClick={() => setHasErrorsFilter(!hasErrorsFilter)}
333343
/>
334344

335-
{graphSize < 50 && (
345+
{(graphSize < 50 || alwaysExpand) && (
336346
<ChipToggleButton
337347
label={t('Expand All')}
338348
isActive={expandAll}

frontend/src/i18n/locales/de/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"Timezone to display for dates": "Zeitzone",
143143
"Sort sidebar items alphabetically": "",
144144
"Use evict for pod deletion": "",
145+
"Always Expand Resource Map groups": "",
145146
"Theme": "Design",
146147
"Cluster Settings": "Cluster-Einstellungen",
147148
"There seem to be no clusters configured…": "",

frontend/src/i18n/locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"Timezone to display for dates": "Timezone to display for dates",
143143
"Sort sidebar items alphabetically": "Sort sidebar items alphabetically",
144144
"Use evict for pod deletion": "Use evict for pod deletion",
145+
"Always Expand Resource Map groups": "Always Expand Resource Map groups",
145146
"Theme": "Theme",
146147
"Cluster Settings": "Cluster Settings",
147148
"There seem to be no clusters configured…": "There seem to be no clusters configured…",

frontend/src/i18n/locales/es/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"Timezone to display for dates": "Huso horario para mostrar en fechas",
143143
"Sort sidebar items alphabetically": "",
144144
"Use evict for pod deletion": "",
145+
"Always Expand Resource Map groups": "",
145146
"Theme": "Tema",
146147
"Cluster Settings": "Configuración del cluster",
147148
"There seem to be no clusters configured…": "No parece haber clusters configurados…",

frontend/src/i18n/locales/fr/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"Timezone to display for dates": "Fuseau horaire à afficher pour les dates",
143143
"Sort sidebar items alphabetically": "Trier les éléments de la barre latérale par ordre alphabétique",
144144
"Use evict for pod deletion": "Utiliser l'éviction pour la suppression de pods",
145+
"Always Expand Resource Map groups": "",
145146
"Theme": "Thème",
146147
"Cluster Settings": "Paramètres du cluster",
147148
"There seem to be no clusters configured…": "Il ne semble pas y avoir de clusters configurés…",

frontend/src/i18n/locales/hi/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"Timezone to display for dates": "तिथियों के लिए प्रदर्शित करने का समय क्षेत्र",
143143
"Sort sidebar items alphabetically": "साइडबार आइटमों को वर्णानुक्रम में सॉर्ट करें",
144144
"Use evict for pod deletion": "Pod हटाने के लिए निष्कासन का उपयोग करें",
145+
"Always Expand Resource Map groups": "",
145146
"Theme": "थीम",
146147
"Cluster Settings": "क्लस्टर सेटिंग्स",
147148
"There seem to be no clusters configured…": "ऐसा लगता है कि कोई क्लस्टर कॉन्फ़िगर नहीं किया गया है…",

frontend/src/i18n/locales/it/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"Timezone to display for dates": "Fuso orario per la visualizzazione delle date",
143143
"Sort sidebar items alphabetically": "",
144144
"Use evict for pod deletion": "",
145+
"Always Expand Resource Map groups": "",
145146
"Theme": "Tema",
146147
"Cluster Settings": "Impostazioni Cluster",
147148
"There seem to be no clusters configured…": "Sembra che non ci siano cluster configurati…",

frontend/src/i18n/locales/ja/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"Timezone to display for dates": "日付表示のタイムゾーン",
143143
"Sort sidebar items alphabetically": "",
144144
"Use evict for pod deletion": "",
145+
"Always Expand Resource Map groups": "",
145146
"Theme": "テーマ",
146147
"Cluster Settings": "クラスター設定",
147148
"There seem to be no clusters configured…": "設定されたクラスターがないようです...",

0 commit comments

Comments
 (0)