mirror of
https://github.com/outline/outline.git
synced 2025-12-21 02:29:41 -06:00
* Add recent documents to command menu Add priority key to actions and sections * refactor * Rename section * refactor, remove more unused code
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
import { SettingsIcon } from "outline-icons";
|
|
import * as React from "react";
|
|
import { createAction } from "~/actions";
|
|
import { NavigationSection } from "~/actions/sections";
|
|
import useSettingsConfig from "~/hooks/useSettingsConfig";
|
|
import history from "~/utils/history";
|
|
|
|
const useSettingsAction = () => {
|
|
const config = useSettingsConfig();
|
|
const actions = React.useMemo(
|
|
() =>
|
|
config.map((item) => {
|
|
const Icon = item.icon;
|
|
return {
|
|
id: item.path,
|
|
name: item.name,
|
|
icon: <Icon />,
|
|
section: NavigationSection,
|
|
perform: () => history.push(item.path),
|
|
};
|
|
}),
|
|
[config]
|
|
);
|
|
|
|
const navigateToSettings = React.useMemo(
|
|
() =>
|
|
createAction({
|
|
id: "settings",
|
|
name: ({ t }) => t("Settings"),
|
|
section: NavigationSection,
|
|
shortcut: ["g", "s"],
|
|
icon: <SettingsIcon />,
|
|
children: () => actions,
|
|
}),
|
|
[actions]
|
|
);
|
|
|
|
return navigateToSettings;
|
|
};
|
|
|
|
export default useSettingsAction;
|