Skip to content

Commit 7280962

Browse files
committed
add disabled option to menu
1 parent 53ad6ad commit 7280962

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

src/reactComponents/Menu.tsx

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ function getItem(
6060
label: React.ReactNode,
6161
key: React.Key,
6262
icon?: React.ReactNode,
63-
children?: MenuItem[]
63+
children?: MenuItem[],
64+
disabled?: boolean
6465
): MenuItem {
6566
return {
6667
key,
6768
icon,
6869
children,
6970
label,
71+
disabled
7072
} as MenuItem;
7173
}
7274

@@ -82,7 +84,7 @@ function getDivider(): MenuItem {
8284
/**
8385
* Generates menu items for a given project.
8486
*/
85-
function getMenuItems(project: commonStorage.Project): MenuItem[] {
87+
function getMenuItems(t: (key: string) => string, project: commonStorage.Project): MenuItem[] {
8688
const mechanisms: MenuItem[] = [];
8789
const opmodes: MenuItem[] = [];
8890

@@ -113,20 +115,27 @@ function getMenuItems(project: commonStorage.Project): MenuItem[] {
113115
opmodes.push(getItem('Manage...', 'manageOpmodes'));
114116

115117
return [
116-
getItem('Project', '100', <FolderOutlined />, [
117-
getItem('Save', 'save', <SaveOutlined />),
118-
getItem('Deploy', 'deploy'),
118+
getItem(t('Project'), 'project', <FolderOutlined />, [
119+
getItem(t('Save'), 'save', <SaveOutlined />),
120+
getItem(t('Deploy'), 'deploy', undefined, undefined, true),
119121
getDivider(),
120-
getItem('Manage...', 'manageProjects'),
122+
getItem(t('Manage') + '...', 'manageProjects'),
121123
]),
122-
getItem('Explorer', 'explorer', <FileOutlined />, [
123-
getItem('Robot', project.modulePath, <RobotOutlined />),
124-
getItem('Mechanisms', '2', <BlockOutlined />, mechanisms),
125-
getItem('OpModes', '3', <CodeOutlined />, opmodes),
124+
getItem(t('Explorer'), 'explorer', <FileOutlined />, [
125+
getItem(t('Robot'), project.modulePath, <RobotOutlined />),
126+
getItem(t('Mechanisms'), 'mechanisms', <BlockOutlined />, mechanisms),
127+
getItem(t('OpModes'), 'opmodes', <CodeOutlined />, opmodes),
126128
]),
127-
getItem('Settings', '4', <SettingOutlined />, [
128-
getItem('WPI toolbox', '42'),
129+
getItem(t('Settings'), 'settings', <SettingOutlined />, [
130+
getItem(t('WPI toolbox'), 'wpi_toolbox'),
131+
getItem(t('Theme') + '...', 'theme')
129132
]),
133+
getItem(t('Help'), 'help', <FileOutlined />, [
134+
getItem(t('Documentation'), 'documentation'),
135+
getItem(t('Tutorials'), 'tutorials'),
136+
getItem(t('About'), 'about', <FileOutlined />),
137+
]),
138+
getItem(t('About'), 'about', <FileOutlined />),
130139
];
131140
}
132141

@@ -268,7 +277,7 @@ export function Component(props: MenuProps): React.JSX.Element {
268277
React.useEffect(() => {
269278
if (props.project) {
270279
setMostRecentProject();
271-
setMenuItems(getMenuItems(props.project));
280+
setMenuItems(getMenuItems(t, props.project));
272281
setNoProjects(false);
273282
}
274283
}, [props.project]);

0 commit comments

Comments
 (0)