Skip to content

Commit 34ca19e

Browse files
author
Marc Udoff
committed
Clean up git menu
1 parent 103ea8d commit 34ca19e

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

src/gitMenuCommands.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ export function addCommands(
6363
console.error(e);
6464
main.dispose();
6565
}
66-
}
66+
},
67+
isVisible: () => model.pathRepository !== null
6768
});
6869

6970
/** Add open/go to git interface command */
@@ -95,7 +96,8 @@ export function addCommands(
9596
await model.init(currentPath);
9697
model.pathRepository = currentPath;
9798
}
98-
}
99+
},
100+
isVisible: () => model.pathRepository === null
99101
});
100102

101103
/** Open URL externally */
@@ -129,7 +131,7 @@ export function addCommands(
129131
commands.addCommand(CommandIDs.gitAddRemote, {
130132
label: 'Add remote repository',
131133
caption: 'Add a Git remote repository',
132-
isEnabled: () => model.pathRepository !== null,
134+
isVisible: () => model.pathRepository !== null,
133135
execute: async args => {
134136
if (model.pathRepository === null) {
135137
console.warn('Not in a Git repository. Unable to add a remote.');
@@ -168,6 +170,7 @@ export function addCommands(
168170
execute: async () => {
169171
await doGitClone(model, fileBrowser.model.path);
170172
fileBrowser.model.refresh();
171-
}
173+
},
174+
isVisible: () => model.pathRepository === null
172175
});
173176
}

src/index.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,30 +143,32 @@ function createGitMenu(
143143
const menu = new Menu({ commands });
144144
menu.title.label = 'Git';
145145
[
146-
CommandIDs.gitUI,
147-
CommandIDs.gitTerminalCommand,
148146
CommandIDs.gitInit,
149147
CommandIDs.gitClone,
150-
CommandIDs.gitAddRemote
148+
CommandIDs.gitAddRemote,
149+
CommandIDs.gitTerminalCommand
151150
].forEach(command => {
152151
menu.addItem({ command });
153152
});
154153

154+
menu.addItem({ type: 'separator' });
155+
156+
menu.addItem({ command: CommandIDs.gitToggleSimpleStaging });
157+
158+
menu.addItem({ command: CommandIDs.gitToggleDoubleClickDiff });
159+
160+
menu.addItem({ type: 'separator' });
161+
155162
const tutorial = new Menu({ commands });
156-
tutorial.title.label = ' Tutorial ';
163+
tutorial.title.label = ' Help ';
157164
RESOURCES.map(args => {
158165
tutorial.addItem({
159166
args,
160167
command: CommandIDs.gitOpenUrl
161168
});
162169
});
163-
menu.addItem({ type: 'submenu', submenu: tutorial });
164-
165-
menu.addItem({ type: 'separator' });
166170

167-
menu.addItem({ command: CommandIDs.gitToggleSimpleStaging });
168-
169-
menu.addItem({ command: CommandIDs.gitToggleDoubleClickDiff });
171+
menu.addItem({ type: 'submenu', submenu: tutorial });
170172

171173
return menu;
172174
}

0 commit comments

Comments
 (0)