Skip to content

Commit 0551ca9

Browse files
joaquimrochaashu8912
authored andcommitted
flux: Persist overview filter preferences in plugin settings
Signed-off-by: Joaquim Rocha <me@joaquimrocha.com>
1 parent 0bc6f8b commit 0551ca9

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

flux/src/overview/index.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
} from '../common/Resources';
4141
import Table from '../common/Table';
4242
import { useFluxCheck } from '../helpers';
43+
import { store } from '../settings';
4344

4445
// Helper to get failed count for a resource class
4546
function getFailedCount(items: KubeObject[] | null) {
@@ -109,8 +110,10 @@ function getDisplayName(resourceClass: KubeObjectClass) {
109110
}
110111

111112
export function FluxOverview() {
112-
const [sortFilter, setSortFilter] = useState('failed');
113-
const [showFilter, setShowFilter] = useState('configured');
113+
const [sortFilter, setSortFilter] = useState(() => store.get()?.overviewSortFilter ?? 'failed');
114+
const [showFilter, setShowFilter] = useState(
115+
() => store.get()?.overviewShowFilter ?? 'configured'
116+
);
114117
const fluxCheck = useFluxCheck();
115118
const namespace = fluxCheck.namespace;
116119

@@ -232,11 +235,15 @@ export function FluxOverview() {
232235
]);
233236

234237
const handleSortFilterChange = event => {
235-
setSortFilter(event.target.value);
238+
const value = event.target.value;
239+
setSortFilter(value);
240+
store.set({ ...store.get(), overviewSortFilter: value });
236241
};
237242

238243
const handleShowFilterChange = event => {
239-
setShowFilter(event.target.value);
244+
const value = event.target.value;
245+
setShowFilter(value);
246+
store.set({ ...store.get(), overviewShowFilter: value });
240247
};
241248

242249
return (

flux/src/settings/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,16 @@ function AutoSaveSwitch({
5050
);
5151
}
5252

53-
interface PluginConfig {
53+
export interface PluginConfig {
5454
linkHRelToKs: boolean;
55+
overviewShowFilter: 'configured' | 'all';
56+
overviewSortFilter: string;
5557
}
5658

5759
const DEFAULT_CONFIG: PluginConfig = {
5860
linkHRelToKs: false,
61+
overviewShowFilter: 'configured',
62+
overviewSortFilter: 'failed',
5963
};
6064

6165
export const store = new ConfigStore<PluginConfig>('@headlamp-k8s/flux');

0 commit comments

Comments
 (0)