Skip to content

Commit 97eb678

Browse files
committed
Add an accept button to the commit message input dialog
- on the input field where we show the generated commit message, show 'check' action in top right corner, accepting the message as an alternative to tappng enter. - move translation to command [Fragment]
1 parent 42228fd commit 97eb678

2 files changed

Lines changed: 33 additions & 5 deletions

File tree

‎apps/editor/src/commands/generate-commit-message-command/generate-commit-message-command.ts‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const generate_commit_message_command = (
8686

8787
force_quick_pick = false
8888

89-
if (api_config_data === 'back') {
89+
if (api_config_data == 'back') {
9090
if (was_empty_stage) {
9191
if (!show_back_button) {
9292
await vscode.commands.executeCommand('git.unstageAll')
@@ -148,23 +148,33 @@ export const generate_commit_message_command = (
148148
input_box.title = t('command.commit-message.input.title')
149149
input_box.prompt = t('command.commit-message.input.prompt')
150150

151+
const accept_button = {
152+
iconPath: new vscode.ThemeIcon('check'),
153+
tooltip: t('command.commit-message.input.accept')
154+
}
155+
151156
if (has_default_config && !files_staged_by_action) {
152157
input_box.buttons = [
158+
accept_button,
153159
{
154160
iconPath: new vscode.ThemeIcon('close'),
155161
tooltip: t('common.close')
156162
}
157163
]
158164
} else {
159-
input_box.buttons = [vscode.QuickInputButtons.Back]
165+
input_box.buttons = [accept_button, vscode.QuickInputButtons.Back]
160166
}
161167

162168
let is_resolved = false
163169

164170
input_box.onDidTriggerButton((button) => {
165-
if (
171+
if (button.tooltip == t('command.commit-message.input.accept')) {
172+
is_resolved = true
173+
resolve(input_box.value)
174+
input_box.hide()
175+
} else if (
166176
button === vscode.QuickInputButtons.Back ||
167-
button.tooltip === t('common.close')
177+
button.tooltip == t('common.close')
168178
) {
169179
is_resolved = true
170180
resolve('back')
@@ -189,7 +199,7 @@ export const generate_commit_message_command = (
189199
}
190200
)
191201

192-
if (edited_message === 'back') {
202+
if (edited_message == 'back') {
193203
if (has_default_config) {
194204
if (files_staged_by_action) {
195205
await vscode.commands.executeCommand('git.unstageAll')

‎apps/editor/src/i18n/translations/commands/generate-commit-message.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,24 @@ export const generate_commit_message = {
3535
hu: 'Szerkessze a commit üzenetet.',
3636
bg: 'Редактирайте commit съобщението.'
3737
},
38+
'command.commit-message.input.accept': {
39+
en: 'Accept',
40+
pl: 'Akceptuj',
41+
'zh-cn': '接受',
42+
ja: '承認',
43+
'zh-tw': '接受',
44+
de: 'Akzeptieren',
45+
es: 'Aceptar',
46+
fr: 'Accepter',
47+
'pt-br': 'Aceitar',
48+
ru: 'Принять',
49+
ko: '수락',
50+
it: 'Accetta',
51+
tr: 'Kabul Et',
52+
cs: 'Přijmout',
53+
hu: 'Elfogadás',
54+
bg: 'Приемане'
55+
},
3856
'command.commit-message.copied': {
3957
en: 'Commit message prompt copied to clipboard ({tokens} tokens).',
4058
pl: 'Wiadomość commita skopiowana do schowka ({tokens} tokenów).',

0 commit comments

Comments
 (0)