Skip to content

Commit f5df357

Browse files
committed
Incorporate SUBMIT_COMMIT_COMMAND into CommandIDs enum
1 parent e8dc142 commit f5df357

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

src/commandsAndMenu.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ function pluralizedContextLabel(singular: string, plural: string) {
106106
};
107107
}
108108

109-
export const SUBMIT_COMMIT_COMMAND = 'git:submit-commit';
110-
111109
/**
112110
* Add the commands for the git extension.
113111
*/
@@ -128,7 +126,7 @@ export function addCommands(
128126
* The label and caption are given to ensure that the command will
129127
* show up in the shortcut editor UI with a nice description.
130128
*/
131-
commands.addCommand(SUBMIT_COMMIT_COMMAND, {
129+
commands.addCommand(CommandIDs.gitSubmitCommand, {
132130
label: 'Commit from the Commit Box',
133131
caption:
134132
'Submit the commit using the summary and description from commit box',

src/components/CommitBox.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
commitButtonClass
88
} from '../style/CommitBox';
99
import { CommandRegistry } from '@lumino/commands';
10-
import { SUBMIT_COMMIT_COMMAND } from '../commandsAndMenu';
10+
import { CommandIDs } from '../tokens';
1111

1212
/**
1313
* Interface describing component properties.
@@ -136,7 +136,7 @@ export class CommitBox extends React.Component<
136136
*/
137137
private _getSubmitKeystroke = (): string => {
138138
const binding = this.props.commands.keyBindings.find(
139-
binding => binding.command === SUBMIT_COMMIT_COMMAND
139+
binding => binding.command === CommandIDs.gitSubmitCommand
140140
);
141141
return binding.keys.join(' ');
142142
};
@@ -201,7 +201,7 @@ export class CommitBox extends React.Component<
201201
_: CommandRegistry,
202202
commandArgs: CommandRegistry.ICommandExecutedArgs
203203
): void => {
204-
if (commandArgs.id === SUBMIT_COMMIT_COMMAND && this._canCommit()) {
204+
if (commandArgs.id === CommandIDs.gitSubmitCommand && this._canCommit()) {
205205
this._onCommitSubmit();
206206
}
207207
};

src/tokens.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -862,5 +862,6 @@ export enum CommandIDs {
862862
gitClone = 'git:clone',
863863
gitOpenGitignore = 'git:open-gitignore',
864864
gitPush = 'git:push',
865-
gitPull = 'git:pull'
865+
gitPull = 'git:pull',
866+
gitSubmitCommand = 'git:submit-commit'
866867
}

tests/test-components/CommitBox.spec.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import 'jest';
33
import { shallow } from 'enzyme';
44
import { CommitBox} from '../../src/components/CommitBox';
55
import { CommandRegistry } from '@lumino/commands';
6-
import { SUBMIT_COMMIT_COMMAND } from '../../src/commandsAndMenu';
6+
import { CommandIDs } from '../../src/tokens';
77

88
describe('CommitBox', () => {
99

1010
const defaultCommands = new CommandRegistry()
1111
defaultCommands.addKeyBinding({
1212
keys: ['Accel Enter'],
13-
command: SUBMIT_COMMIT_COMMAND,
13+
command: CommandIDs.gitSubmitCommand,
1414
selector: '.jp-git-CommitBox'
1515
})
1616

@@ -59,7 +59,7 @@ describe('CommitBox', () => {
5959
const adjustedCommands = new CommandRegistry()
6060
adjustedCommands.addKeyBinding({
6161
keys: ['Shift Enter'],
62-
command: SUBMIT_COMMIT_COMMAND,
62+
command: CommandIDs.gitSubmitCommand,
6363
selector: '.jp-git-CommitBox'
6464
})
6565
const props = {

0 commit comments

Comments
 (0)