generated from cockpit-project/starter-kit
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes: #451 For now this adds following keybindings: - `alt + arrow up`: go up one directory - `alt + arrow down`: activate selected item, enter directory - `Enter`: activate selected item, enter directory - `ctrl + shift + L`: focus files breadcrumbs to manually edit it - `F2`: rename selected file - `shift + N`: create new directory - `ctrl + c`: copy file/directory - `ctrl + v`: paste file/directory - `ctrl + a`: select all files Alt + arrow left/right is already supported by cockpit files browser history.
- Loading branch information
1 parent
43bab93
commit eca07b3
Showing
8 changed files
with
519 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import React from 'react'; | ||
|
||
import { Button } from "@patternfly/react-core/dist/esm/components/Button"; | ||
import { | ||
DescriptionList, DescriptionListDescription, DescriptionListGroup, DescriptionListTerm | ||
} from "@patternfly/react-core/dist/esm/components/DescriptionList/index"; | ||
import { Modal, ModalVariant } from "@patternfly/react-core/dist/esm/components/Modal"; | ||
import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/esm/components/Text"; | ||
import { Flex, } from "@patternfly/react-core/dist/esm/layouts/Flex"; | ||
|
||
import cockpit from 'cockpit'; | ||
import { useDialogs } from 'dialogs'; | ||
|
||
const _ = cockpit.gettext; | ||
|
||
export const KeyboardShortcutsHelp = () => { | ||
const Dialogs = useDialogs(); | ||
|
||
const footer = ( | ||
<Button variant="secondary" onClick={Dialogs.close}>{_("Close")}</Button> | ||
); | ||
|
||
const toDescriptionListGroups = (item: [React.JSX.Element, string, string]) => { | ||
return ( | ||
<DescriptionListGroup key={item[2] + "-listgroup"}> | ||
<DescriptionListTerm> | ||
{item[0]} | ||
</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{item[1]} | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
); | ||
}; | ||
|
||
const navShortcuts: Array<[React.JSX.Element, string, string]> = [ | ||
[ | ||
<kbd className="keystroke" key="go-up"> | ||
<kbd className="key">Alt</kbd> + <kbd className="key">{'\u{2191}'}</kbd> | ||
</kbd>, | ||
_("Go up a directory"), | ||
"go-up", | ||
], [ | ||
<kbd className="keystroke" key="go-back"> | ||
<kbd className="key">Alt</kbd> + <kbd className="key">{'\u{2190}'}</kbd> | ||
</kbd>, | ||
_("Go back"), | ||
"go-back", | ||
], [ | ||
<kbd className="keystroke" key="go-forward"> | ||
<kbd className="key">Alt</kbd> + <kbd className="key">{'\u{2192}'}</kbd> | ||
</kbd>, | ||
_("Go forward"), | ||
"go-forward", | ||
], [ | ||
<kbd className="keystroke" key="activate"> | ||
<kbd className="key">Alt</kbd> + <kbd className="key">{'\u{2193}'}</kbd> | ||
</kbd>, | ||
_("Activate selected item, enter directory"), | ||
"activate", | ||
], [ | ||
<kbd className="keystroke" key="activate-enter"> | ||
<kbd className="key">Enter</kbd> | ||
</kbd>, | ||
_("Activate selected item, enter directory"), | ||
"activate-enter", | ||
], [ | ||
<kbd className="keystroke" key="edit-path"> | ||
<kbd className="key">Ctrl</kbd> + | ||
<kbd className="key">Shift</kbd> + | ||
<kbd className="key">L</kbd> | ||
</kbd>, | ||
_("Edit path"), | ||
"edit-path", | ||
] | ||
]; | ||
|
||
const editShortcuts: Array<[React.JSX.Element, string, string]> = [ | ||
[ | ||
<kbd className="key" key="rename">F2</kbd>, | ||
_("Rename selected file or directory"), | ||
"rename", | ||
], [ | ||
<kbd className="keystroke" key="create-dir"> | ||
<kbd className="key">Shift</kbd> + | ||
<kbd className="key" key="mkdir">N</kbd> | ||
</kbd>, | ||
_("Create new directory"), | ||
"mkdir", | ||
], [ | ||
<kbd className="keystroke" key="copy"> | ||
<kbd className="key">Ctrl</kbd> + <kbd className="key">C</kbd> | ||
</kbd>, | ||
_("Copy selected file or directory"), | ||
"copy", | ||
], [ | ||
<kbd className="keystroke" key="paste"> | ||
<kbd className="key">Ctrl</kbd> + <kbd className="key">V</kbd> | ||
</kbd>, | ||
_("Paste file or directory"), | ||
"paste", | ||
], [ | ||
<kbd className="keystroke" key="select-all"> | ||
<kbd className="key">Ctrl</kbd> + <kbd className="key">A</kbd> | ||
</kbd>, | ||
_("Select all"), | ||
"select-all", | ||
] | ||
]; | ||
|
||
return ( | ||
<Modal | ||
position="top" | ||
title={_("Keyboard shortcuts")} | ||
variant={ModalVariant.large} | ||
className="shortcuts-dialog" | ||
onClose={Dialogs.close} | ||
footer={footer} | ||
isOpen | ||
> | ||
<Flex> | ||
<TextContent> | ||
<Text component={TextVariants.h2}>{_("Navigation")}</Text> | ||
<DescriptionList | ||
isHorizontal | ||
isFluid | ||
isFillColumns | ||
> | ||
{navShortcuts.map(toDescriptionListGroups)} | ||
</DescriptionList> | ||
</TextContent> | ||
<TextContent> | ||
<Text component={TextVariants.h2}>{_("Editing")}</Text> | ||
<DescriptionList | ||
isHorizontal | ||
isFluid | ||
isFillColumns | ||
> | ||
{editShortcuts.map(toDescriptionListGroups)} | ||
</DescriptionList> | ||
</TextContent> | ||
</Flex> | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.