Skip to content

Commit f9c5df2

Browse files
authored
Merge pull request #4469 from alokdangre/fix-keyboard-shortcuts-errors
frontend: Add configurable keyboard shortcuts
2 parents 04384a4 + 46920cf commit f9c5df2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1720
-663
lines changed

e2e-tests/tests/headlamp.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ test('main page should have global search along with react-hotkey hint text', as
5757
const searchHintContainer = globalSearch.locator('xpath=following-sibling::div');
5858
const pressTextExists = await searchHintContainer.getByText(/^Press/).isVisible();
5959
const slashHotKeyExists = await searchHintContainer
60-
.locator('div')
61-
.filter({ hasText: /^\/$/ })
60+
.locator('kbd')
61+
.filter({ hasText: '/' })
6262
.isVisible();
6363
const toSearchTextExists = await searchHintContainer.getByText(/to search$/).isVisible();
6464

frontend/src/components/App/Home/index.stories.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { Meta, StoryFn } from '@storybook/react';
1919
import { Provider } from 'react-redux';
2020
import { MemoryRouter } from 'react-router-dom';
2121
import { initialState } from '../../../redux/configSlice';
22+
import shortcutsReducer from '../../../redux/shortcutsSlice';
2223
import Home from '.';
2324

2425
const ourState = {
@@ -51,6 +52,7 @@ const ourState = {
5152
drawerMode: {
5253
isDetailDrawerEnabled: false,
5354
},
55+
shortcuts: { ...shortcutsReducer(undefined, { type: '' }) },
5456
};
5557

5658
// @todo: Add a way for the results from useClustersVersion to be mocked, so not

frontend/src/components/App/Layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import AlertNotification from '../common/AlertNotification';
4646
import DetailsDrawer from '../common/Resource/DetailsDrawer';
4747
import Sidebar, { NavigationTabs } from '../Sidebar';
4848
import RouteSwitcher from './RouteSwitcher';
49+
import ShortcutsSettings from './Settings/ShortcutsSettings';
4950
import TopBar from './TopBar';
5051
import VersionDialog from './VersionDialog';
5152

@@ -289,6 +290,7 @@ export default function Layout({}: LayoutProps) {
289290
{t('Skip to main content')}
290291
</Link>
291292
<VersionDialog />
293+
<ShortcutsSettings />
292294
<CssBaseline enableColorScheme />
293295
<ActionsNotifier />
294296
<Box sx={{ display: 'flex', height: '100dvh' }}>

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { setTheme, useAppThemes } from '../themeSlice';
3535
import DrawerModeSettings from './DrawerModeSettings';
3636
import { useSettings } from './hook';
3737
import NumRowsInput from './NumRowsInput';
38+
import { ShortcutsList } from './ShortcutsSettings';
3839
import { ThemePreview } from './ThemePreview';
3940

4041
export default function Settings() {
@@ -243,6 +244,21 @@ export default function Settings() {
243244
</Box>
244245
</Box>
245246
</Box>
247+
<Box sx={{ mt: 4 }}>
248+
<SectionBox
249+
title={t('translation|Keyboard Shortcuts')}
250+
headerProps={{
251+
headerStyle: 'subsection',
252+
}}
253+
>
254+
<Typography variant="body2" sx={{ mb: 2, color: 'text.secondary' }}>
255+
{t(
256+
'translation|Configure keyboard shortcuts for quick access to various parts of the application.'
257+
)}
258+
</Typography>
259+
<ShortcutsList />
260+
</SectionBox>
261+
</Box>
246262
</SectionBox>
247263
);
248264
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2025 The Kubernetes Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { Meta, StoryFn } from '@storybook/react';
18+
import { Provider } from 'react-redux';
19+
import { MemoryRouter } from 'react-router-dom';
20+
import store from '../../../redux/stores/store';
21+
import ShortcutsSettings from './ShortcutsSettings';
22+
23+
export default {
24+
title: 'Settings/ShortcutsSettings',
25+
component: ShortcutsSettings,
26+
decorators: [
27+
Story => (
28+
<Provider store={store}>
29+
<MemoryRouter>
30+
<Story />
31+
</MemoryRouter>
32+
</Provider>
33+
),
34+
],
35+
} as Meta<typeof ShortcutsSettings>;
36+
37+
const Template: StoryFn<typeof ShortcutsSettings> = () => {
38+
store.dispatch({ type: 'shortcuts/setShortcutsDialogOpen', payload: true });
39+
return <ShortcutsSettings />;
40+
};
41+
42+
export const Default = Template.bind({});
43+
Default.args = {};

0 commit comments

Comments
 (0)