@theia/scm 1.45.1 → 1.46.0-next.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -31
- package/lib/browser/decorations/scm-decorations-service.d.ts +14 -14
- package/lib/browser/decorations/scm-decorations-service.js +101 -101
- package/lib/browser/decorations/scm-navigator-decorator.d.ts +25 -25
- package/lib/browser/decorations/scm-navigator-decorator.js +132 -132
- package/lib/browser/decorations/scm-tab-bar-decorator.d.ts +17 -17
- package/lib/browser/decorations/scm-tab-bar-decorator.js +93 -93
- package/lib/browser/dirty-diff/content-lines.d.ts +12 -12
- package/lib/browser/dirty-diff/content-lines.js +106 -106
- package/lib/browser/dirty-diff/content-lines.spec.d.ts +1 -1
- package/lib/browser/dirty-diff/content-lines.spec.js +39 -39
- package/lib/browser/dirty-diff/diff-computer.d.ts +29 -29
- package/lib/browser/dirty-diff/diff-computer.js +102 -102
- package/lib/browser/dirty-diff/diff-computer.spec.d.ts +1 -1
- package/lib/browser/dirty-diff/diff-computer.spec.js +315 -315
- package/lib/browser/dirty-diff/dirty-diff-decorator.d.ts +14 -14
- package/lib/browser/dirty-diff/dirty-diff-decorator.js +98 -98
- package/lib/browser/dirty-diff/dirty-diff-module.d.ts +3 -3
- package/lib/browser/dirty-diff/dirty-diff-module.js +24 -24
- package/lib/browser/scm-amend-component.d.ts +123 -123
- package/lib/browser/scm-amend-component.js +463 -463
- package/lib/browser/scm-amend-widget.d.ts +20 -20
- package/lib/browser/scm-amend-widget.js +101 -101
- package/lib/browser/scm-avatar-service.d.ts +3 -3
- package/lib/browser/scm-avatar-service.js +36 -36
- package/lib/browser/scm-commit-widget.d.ts +52 -52
- package/lib/browser/scm-commit-widget.js +199 -199
- package/lib/browser/scm-context-key-service.d.ts +10 -10
- package/lib/browser/scm-context-key-service.js +58 -58
- package/lib/browser/scm-contribution.d.ts +83 -83
- package/lib/browser/scm-contribution.js +356 -356
- package/lib/browser/scm-frontend-module.d.ts +6 -6
- package/lib/browser/scm-frontend-module.js +130 -130
- package/lib/browser/scm-groups-tree-model.d.ts +14 -14
- package/lib/browser/scm-groups-tree-model.js +97 -97
- package/lib/browser/scm-input.d.ts +53 -53
- package/lib/browser/scm-input.js +127 -127
- package/lib/browser/scm-layout-migrations.d.ts +9 -9
- package/lib/browser/scm-layout-migrations.js +79 -79
- package/lib/browser/scm-no-repository-widget.d.ts +8 -8
- package/lib/browser/scm-no-repository-widget.js +49 -49
- package/lib/browser/scm-preferences.d.ts +11 -11
- package/lib/browser/scm-preferences.js +51 -51
- package/lib/browser/scm-provider.d.ts +58 -58
- package/lib/browser/scm-provider.js +19 -19
- package/lib/browser/scm-quick-open-service.d.ts +11 -11
- package/lib/browser/scm-quick-open-service.js +73 -73
- package/lib/browser/scm-repository.d.ts +17 -17
- package/lib/browser/scm-repository.js +41 -41
- package/lib/browser/scm-service.d.ts +26 -26
- package/lib/browser/scm-service.js +108 -108
- package/lib/browser/scm-tree-label-provider.d.ts +7 -7
- package/lib/browser/scm-tree-label-provider.js +57 -57
- package/lib/browser/scm-tree-model.d.ts +74 -74
- package/lib/browser/scm-tree-model.js +351 -351
- package/lib/browser/scm-tree-widget.d.ts +208 -208
- package/lib/browser/scm-tree-widget.js +703 -703
- package/lib/browser/scm-widget.d.ts +40 -40
- package/lib/browser/scm-widget.js +218 -218
- package/package.json +6 -6
- package/src/browser/decorations/scm-decorations-service.ts +78 -78
- package/src/browser/decorations/scm-navigator-decorator.ts +121 -121
- package/src/browser/decorations/scm-tab-bar-decorator.ts +83 -83
- package/src/browser/dirty-diff/content-lines.spec.ts +42 -42
- package/src/browser/dirty-diff/content-lines.ts +112 -112
- package/src/browser/dirty-diff/diff-computer.spec.ts +387 -387
- package/src/browser/dirty-diff/diff-computer.ts +129 -129
- package/src/browser/dirty-diff/dirty-diff-decorator.ts +107 -107
- package/src/browser/dirty-diff/dirty-diff-module.ts +24 -24
- package/src/browser/scm-amend-component.tsx +600 -600
- package/src/browser/scm-amend-widget.tsx +77 -77
- package/src/browser/scm-avatar-service.ts +27 -27
- package/src/browser/scm-commit-widget.tsx +215 -215
- package/src/browser/scm-context-key-service.ts +46 -46
- package/src/browser/scm-contribution.ts +361 -361
- package/src/browser/scm-frontend-module.ts +149 -149
- package/src/browser/scm-groups-tree-model.ts +78 -78
- package/src/browser/scm-input.ts +164 -164
- package/src/browser/scm-layout-migrations.ts +64 -64
- package/src/browser/scm-no-repository-widget.tsx +41 -41
- package/src/browser/scm-preferences.ts +63 -63
- package/src/browser/scm-provider.ts +91 -91
- package/src/browser/scm-quick-open-service.ts +48 -48
- package/src/browser/scm-repository.ts +52 -52
- package/src/browser/scm-service.ts +108 -108
- package/src/browser/scm-tree-label-provider.ts +44 -44
- package/src/browser/scm-tree-model.ts +405 -405
- package/src/browser/scm-tree-widget.tsx +838 -838
- package/src/browser/scm-widget.tsx +204 -204
- package/src/browser/style/dirty-diff-decorator.css +52 -52
- package/src/browser/style/dirty-diff.css +50 -50
- package/src/browser/style/index.css +271 -271
- package/src/browser/style/scm-amend-component.css +94 -94
- package/src/browser/style/scm.svg +4 -4
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 Arm and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import { SelectionService } from '@theia/core/lib/common';
|
|
19
|
-
import * as React from '@theia/core/shared/react';
|
|
20
|
-
import {
|
|
21
|
-
ContextMenuRenderer, ReactWidget, LabelProvider, KeybindingRegistry, StorageService
|
|
22
|
-
} from '@theia/core/lib/browser';
|
|
23
|
-
import { ScmService } from './scm-service';
|
|
24
|
-
import { ScmAvatarService } from './scm-avatar-service';
|
|
25
|
-
import { ScmAmendComponent } from './scm-amend-component';
|
|
26
|
-
|
|
27
|
-
@injectable()
|
|
28
|
-
export class ScmAmendWidget extends ReactWidget {
|
|
29
|
-
|
|
30
|
-
static ID = 'scm-amend-widget';
|
|
31
|
-
|
|
32
|
-
@inject(ScmService) protected readonly scmService: ScmService;
|
|
33
|
-
@inject(ScmAvatarService) protected readonly avatarService: ScmAvatarService;
|
|
34
|
-
@inject(StorageService) protected readonly storageService: StorageService;
|
|
35
|
-
@inject(SelectionService) protected readonly selectionService: SelectionService;
|
|
36
|
-
@inject(LabelProvider) protected readonly labelProvider: LabelProvider;
|
|
37
|
-
@inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry;
|
|
38
|
-
|
|
39
|
-
protected shouldScrollToRow = true;
|
|
40
|
-
|
|
41
|
-
constructor(
|
|
42
|
-
@inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer,
|
|
43
|
-
) {
|
|
44
|
-
super();
|
|
45
|
-
this.scrollOptions = {
|
|
46
|
-
suppressScrollX: true,
|
|
47
|
-
minScrollbarLength: 35
|
|
48
|
-
};
|
|
49
|
-
this.id = ScmAmendWidget.ID;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected render(): React.ReactNode {
|
|
53
|
-
const repository = this.scmService.selectedRepository;
|
|
54
|
-
if (repository && repository.provider.amendSupport) {
|
|
55
|
-
return React.createElement(
|
|
56
|
-
ScmAmendComponent,
|
|
57
|
-
{
|
|
58
|
-
key: `amend:${repository.provider.rootUri}`,
|
|
59
|
-
style: { flexGrow: 0 },
|
|
60
|
-
repository: repository,
|
|
61
|
-
scmAmendSupport: repository.provider.amendSupport,
|
|
62
|
-
setCommitMessage: this.setInputValue,
|
|
63
|
-
avatarService: this.avatarService,
|
|
64
|
-
storageService: this.storageService,
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
protected setInputValue = (event: React.FormEvent<HTMLTextAreaElement> | React.ChangeEvent<HTMLTextAreaElement> | string) => {
|
|
71
|
-
const repository = this.scmService.selectedRepository;
|
|
72
|
-
if (repository) {
|
|
73
|
-
repository.input.value = typeof event === 'string' ? event : event.currentTarget.value;
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2020 Arm and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import { SelectionService } from '@theia/core/lib/common';
|
|
19
|
+
import * as React from '@theia/core/shared/react';
|
|
20
|
+
import {
|
|
21
|
+
ContextMenuRenderer, ReactWidget, LabelProvider, KeybindingRegistry, StorageService
|
|
22
|
+
} from '@theia/core/lib/browser';
|
|
23
|
+
import { ScmService } from './scm-service';
|
|
24
|
+
import { ScmAvatarService } from './scm-avatar-service';
|
|
25
|
+
import { ScmAmendComponent } from './scm-amend-component';
|
|
26
|
+
|
|
27
|
+
@injectable()
|
|
28
|
+
export class ScmAmendWidget extends ReactWidget {
|
|
29
|
+
|
|
30
|
+
static ID = 'scm-amend-widget';
|
|
31
|
+
|
|
32
|
+
@inject(ScmService) protected readonly scmService: ScmService;
|
|
33
|
+
@inject(ScmAvatarService) protected readonly avatarService: ScmAvatarService;
|
|
34
|
+
@inject(StorageService) protected readonly storageService: StorageService;
|
|
35
|
+
@inject(SelectionService) protected readonly selectionService: SelectionService;
|
|
36
|
+
@inject(LabelProvider) protected readonly labelProvider: LabelProvider;
|
|
37
|
+
@inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry;
|
|
38
|
+
|
|
39
|
+
protected shouldScrollToRow = true;
|
|
40
|
+
|
|
41
|
+
constructor(
|
|
42
|
+
@inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer,
|
|
43
|
+
) {
|
|
44
|
+
super();
|
|
45
|
+
this.scrollOptions = {
|
|
46
|
+
suppressScrollX: true,
|
|
47
|
+
minScrollbarLength: 35
|
|
48
|
+
};
|
|
49
|
+
this.id = ScmAmendWidget.ID;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected render(): React.ReactNode {
|
|
53
|
+
const repository = this.scmService.selectedRepository;
|
|
54
|
+
if (repository && repository.provider.amendSupport) {
|
|
55
|
+
return React.createElement(
|
|
56
|
+
ScmAmendComponent,
|
|
57
|
+
{
|
|
58
|
+
key: `amend:${repository.provider.rootUri}`,
|
|
59
|
+
style: { flexGrow: 0 },
|
|
60
|
+
repository: repository,
|
|
61
|
+
scmAmendSupport: repository.provider.amendSupport,
|
|
62
|
+
setCommitMessage: this.setInputValue,
|
|
63
|
+
avatarService: this.avatarService,
|
|
64
|
+
storageService: this.storageService,
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected setInputValue = (event: React.FormEvent<HTMLTextAreaElement> | React.ChangeEvent<HTMLTextAreaElement> | string) => {
|
|
71
|
+
const repository = this.scmService.selectedRepository;
|
|
72
|
+
if (repository) {
|
|
73
|
+
repository.input.value = typeof event === 'string' ? event : event.currentTarget.value;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { Md5 } from 'ts-md5';
|
|
19
|
-
|
|
20
|
-
@injectable()
|
|
21
|
-
export class ScmAvatarService {
|
|
22
|
-
|
|
23
|
-
async getAvatar(email: string): Promise<string> {
|
|
24
|
-
const hash = Md5.hashStr(email);
|
|
25
|
-
return `https://www.gravatar.com/avatar/${hash}?d=robohash`;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { Md5 } from 'ts-md5';
|
|
19
|
+
|
|
20
|
+
@injectable()
|
|
21
|
+
export class ScmAvatarService {
|
|
22
|
+
|
|
23
|
+
async getAvatar(email: string): Promise<string> {
|
|
24
|
+
const hash = Md5.hashStr(email);
|
|
25
|
+
return `https://www.gravatar.com/avatar/${hash}?d=robohash`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,215 +1,215 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import { DisposableCollection } from '@theia/core';
|
|
19
|
-
import { Message } from '@theia/core/shared/@phosphor/messaging';
|
|
20
|
-
import * as React from '@theia/core/shared/react';
|
|
21
|
-
import TextareaAutosize from 'react-autosize-textarea';
|
|
22
|
-
import { ScmInput, ScmInputIssueType } from './scm-input';
|
|
23
|
-
import {
|
|
24
|
-
ContextMenuRenderer, ReactWidget, KeybindingRegistry, StatefulWidget
|
|
25
|
-
} from '@theia/core/lib/browser';
|
|
26
|
-
import { ScmService } from './scm-service';
|
|
27
|
-
|
|
28
|
-
@injectable()
|
|
29
|
-
export class ScmCommitWidget extends ReactWidget implements StatefulWidget {
|
|
30
|
-
|
|
31
|
-
static ID = 'scm-commit-widget';
|
|
32
|
-
|
|
33
|
-
@inject(ScmService) protected readonly scmService: ScmService;
|
|
34
|
-
@inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry;
|
|
35
|
-
|
|
36
|
-
protected readonly toDisposeOnRepositoryChange = new DisposableCollection();
|
|
37
|
-
|
|
38
|
-
protected shouldScrollToRow = true;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Don't modify DOM use React! only exposed for `focusInput`
|
|
42
|
-
* Use `this.scmService.selectedRepository?.input.value` as a single source of truth!
|
|
43
|
-
*/
|
|
44
|
-
protected readonly inputRef = React.createRef<HTMLTextAreaElement>();
|
|
45
|
-
|
|
46
|
-
constructor(
|
|
47
|
-
@inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer,
|
|
48
|
-
) {
|
|
49
|
-
super();
|
|
50
|
-
this.scrollOptions = {
|
|
51
|
-
suppressScrollX: true,
|
|
52
|
-
minScrollbarLength: 35
|
|
53
|
-
};
|
|
54
|
-
this.addClass('theia-scm-commit');
|
|
55
|
-
this.id = ScmCommitWidget.ID;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
protected override onAfterAttach(msg: Message): void {
|
|
59
|
-
super.onAfterAttach(msg);
|
|
60
|
-
this.refreshOnRepositoryChange();
|
|
61
|
-
this.toDisposeOnDetach.push(this.scmService.onDidChangeSelectedRepository(() => {
|
|
62
|
-
this.refreshOnRepositoryChange();
|
|
63
|
-
this.update();
|
|
64
|
-
}));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
protected refreshOnRepositoryChange(): void {
|
|
68
|
-
this.toDisposeOnRepositoryChange.dispose();
|
|
69
|
-
const repository = this.scmService.selectedRepository;
|
|
70
|
-
if (repository) {
|
|
71
|
-
this.toDisposeOnRepositoryChange.push(repository.provider.onDidChange(async () => {
|
|
72
|
-
this.update();
|
|
73
|
-
}));
|
|
74
|
-
this.toDisposeOnRepositoryChange.push(repository.provider.onDidChangeCommitTemplate(e => {
|
|
75
|
-
this.setInputValue(e);
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
protected override onActivateRequest(msg: Message): void {
|
|
81
|
-
super.onActivateRequest(msg);
|
|
82
|
-
this.focus();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public focus(): void {
|
|
86
|
-
(this.inputRef.current || this.node).focus();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
protected render(): React.ReactNode {
|
|
90
|
-
const repository = this.scmService.selectedRepository;
|
|
91
|
-
if (repository) {
|
|
92
|
-
return React.createElement('div', this.createContainerAttributes(), this.renderInput(repository.input));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Create the container attributes for the widget.
|
|
98
|
-
*/
|
|
99
|
-
protected createContainerAttributes(): React.HTMLAttributes<HTMLElement> {
|
|
100
|
-
return {
|
|
101
|
-
style: { flexGrow: 0 }
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
protected renderInput(input: ScmInput): React.ReactNode {
|
|
106
|
-
let validationStatus = 'idle';
|
|
107
|
-
if (input.issue) {
|
|
108
|
-
switch (input.issue.type) {
|
|
109
|
-
case ScmInputIssueType.Error:
|
|
110
|
-
validationStatus = 'error';
|
|
111
|
-
break;
|
|
112
|
-
case ScmInputIssueType.Information:
|
|
113
|
-
validationStatus = 'info';
|
|
114
|
-
break;
|
|
115
|
-
case ScmInputIssueType.Warning:
|
|
116
|
-
validationStatus = 'warning';
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
const validationMessage = input.issue ? input.issue.message : '';
|
|
121
|
-
const format = (value: string, ...args: string[]): string => {
|
|
122
|
-
if (args.length !== 0) {
|
|
123
|
-
return value.replace(/{(\d+)}/g, (found, n) => {
|
|
124
|
-
const i = parseInt(n);
|
|
125
|
-
return isNaN(i) || i < 0 || i >= args.length ? found : args[i];
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
return value;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const keybinding = this.keybindings.acceleratorFor(this.keybindings.getKeybindingsForCommand('scm.acceptInput')[0]).join('+');
|
|
132
|
-
const message = format(input.placeholder || '', keybinding);
|
|
133
|
-
const textArea = input.visible &&
|
|
134
|
-
<TextareaAutosize
|
|
135
|
-
className={`${ScmCommitWidget.Styles.INPUT_MESSAGE} theia-input theia-scm-input-message-${validationStatus}`}
|
|
136
|
-
id={ScmCommitWidget.Styles.INPUT_MESSAGE}
|
|
137
|
-
placeholder={message}
|
|
138
|
-
spellCheck={false}
|
|
139
|
-
autoFocus={true}
|
|
140
|
-
value={input.value}
|
|
141
|
-
disabled={!input.enabled}
|
|
142
|
-
onChange={this.setInputValue}
|
|
143
|
-
ref={this.inputRef}
|
|
144
|
-
rows={1}
|
|
145
|
-
maxRows={6} /* from VS Code */>
|
|
146
|
-
</TextareaAutosize>;
|
|
147
|
-
return <div className={ScmCommitWidget.Styles.INPUT_MESSAGE_CONTAINER}>
|
|
148
|
-
{textArea}
|
|
149
|
-
<div
|
|
150
|
-
className={
|
|
151
|
-
`${ScmCommitWidget.Styles.VALIDATION_MESSAGE} ${ScmCommitWidget.Styles.NO_SELECT}
|
|
152
|
-
theia-scm-validation-message-${validationStatus} theia-scm-input-message-${validationStatus}`
|
|
153
|
-
}
|
|
154
|
-
style={{
|
|
155
|
-
display: !!input.issue ? 'block' : 'none'
|
|
156
|
-
}}>{validationMessage}</div>
|
|
157
|
-
</div>;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
protected setInputValue = (event: React.FormEvent<HTMLTextAreaElement> | React.ChangeEvent<HTMLTextAreaElement> | string) => {
|
|
161
|
-
const repository = this.scmService.selectedRepository;
|
|
162
|
-
if (repository) {
|
|
163
|
-
repository.input.value = typeof event === 'string' ? event : event.currentTarget.value;
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Store the tree state.
|
|
169
|
-
*/
|
|
170
|
-
storeState(): ScmCommitWidget.State {
|
|
171
|
-
const message = this.scmService.selectedRepository?.input.value;
|
|
172
|
-
return { message };
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Restore the state.
|
|
177
|
-
* @param oldState the old state object.
|
|
178
|
-
*/
|
|
179
|
-
restoreState(oldState: ScmCommitWidget.State): void {
|
|
180
|
-
const value = oldState.message;
|
|
181
|
-
if (!value) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
let repository = this.scmService.selectedRepository;
|
|
185
|
-
if (repository) {
|
|
186
|
-
repository.input.value = value;
|
|
187
|
-
} else {
|
|
188
|
-
const listener = this.scmService.onDidChangeSelectedRepository(() => {
|
|
189
|
-
repository = this.scmService.selectedRepository;
|
|
190
|
-
if (repository) {
|
|
191
|
-
listener.dispose();
|
|
192
|
-
if (!repository.input.value) {
|
|
193
|
-
repository.input.value = value;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
this.toDispose.push(listener);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export namespace ScmCommitWidget {
|
|
204
|
-
|
|
205
|
-
export namespace Styles {
|
|
206
|
-
export const INPUT_MESSAGE_CONTAINER = 'theia-scm-input-message-container';
|
|
207
|
-
export const INPUT_MESSAGE = 'theia-scm-input-message';
|
|
208
|
-
export const VALIDATION_MESSAGE = 'theia-scm-input-validation-message';
|
|
209
|
-
export const NO_SELECT = 'no-select';
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export interface State {
|
|
213
|
-
message?: string
|
|
214
|
-
}
|
|
215
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import { DisposableCollection } from '@theia/core';
|
|
19
|
+
import { Message } from '@theia/core/shared/@phosphor/messaging';
|
|
20
|
+
import * as React from '@theia/core/shared/react';
|
|
21
|
+
import TextareaAutosize from 'react-autosize-textarea';
|
|
22
|
+
import { ScmInput, ScmInputIssueType } from './scm-input';
|
|
23
|
+
import {
|
|
24
|
+
ContextMenuRenderer, ReactWidget, KeybindingRegistry, StatefulWidget
|
|
25
|
+
} from '@theia/core/lib/browser';
|
|
26
|
+
import { ScmService } from './scm-service';
|
|
27
|
+
|
|
28
|
+
@injectable()
|
|
29
|
+
export class ScmCommitWidget extends ReactWidget implements StatefulWidget {
|
|
30
|
+
|
|
31
|
+
static ID = 'scm-commit-widget';
|
|
32
|
+
|
|
33
|
+
@inject(ScmService) protected readonly scmService: ScmService;
|
|
34
|
+
@inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry;
|
|
35
|
+
|
|
36
|
+
protected readonly toDisposeOnRepositoryChange = new DisposableCollection();
|
|
37
|
+
|
|
38
|
+
protected shouldScrollToRow = true;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Don't modify DOM use React! only exposed for `focusInput`
|
|
42
|
+
* Use `this.scmService.selectedRepository?.input.value` as a single source of truth!
|
|
43
|
+
*/
|
|
44
|
+
protected readonly inputRef = React.createRef<HTMLTextAreaElement>();
|
|
45
|
+
|
|
46
|
+
constructor(
|
|
47
|
+
@inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer,
|
|
48
|
+
) {
|
|
49
|
+
super();
|
|
50
|
+
this.scrollOptions = {
|
|
51
|
+
suppressScrollX: true,
|
|
52
|
+
minScrollbarLength: 35
|
|
53
|
+
};
|
|
54
|
+
this.addClass('theia-scm-commit');
|
|
55
|
+
this.id = ScmCommitWidget.ID;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protected override onAfterAttach(msg: Message): void {
|
|
59
|
+
super.onAfterAttach(msg);
|
|
60
|
+
this.refreshOnRepositoryChange();
|
|
61
|
+
this.toDisposeOnDetach.push(this.scmService.onDidChangeSelectedRepository(() => {
|
|
62
|
+
this.refreshOnRepositoryChange();
|
|
63
|
+
this.update();
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected refreshOnRepositoryChange(): void {
|
|
68
|
+
this.toDisposeOnRepositoryChange.dispose();
|
|
69
|
+
const repository = this.scmService.selectedRepository;
|
|
70
|
+
if (repository) {
|
|
71
|
+
this.toDisposeOnRepositoryChange.push(repository.provider.onDidChange(async () => {
|
|
72
|
+
this.update();
|
|
73
|
+
}));
|
|
74
|
+
this.toDisposeOnRepositoryChange.push(repository.provider.onDidChangeCommitTemplate(e => {
|
|
75
|
+
this.setInputValue(e);
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
protected override onActivateRequest(msg: Message): void {
|
|
81
|
+
super.onActivateRequest(msg);
|
|
82
|
+
this.focus();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public focus(): void {
|
|
86
|
+
(this.inputRef.current || this.node).focus();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
protected render(): React.ReactNode {
|
|
90
|
+
const repository = this.scmService.selectedRepository;
|
|
91
|
+
if (repository) {
|
|
92
|
+
return React.createElement('div', this.createContainerAttributes(), this.renderInput(repository.input));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Create the container attributes for the widget.
|
|
98
|
+
*/
|
|
99
|
+
protected createContainerAttributes(): React.HTMLAttributes<HTMLElement> {
|
|
100
|
+
return {
|
|
101
|
+
style: { flexGrow: 0 }
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
protected renderInput(input: ScmInput): React.ReactNode {
|
|
106
|
+
let validationStatus = 'idle';
|
|
107
|
+
if (input.issue) {
|
|
108
|
+
switch (input.issue.type) {
|
|
109
|
+
case ScmInputIssueType.Error:
|
|
110
|
+
validationStatus = 'error';
|
|
111
|
+
break;
|
|
112
|
+
case ScmInputIssueType.Information:
|
|
113
|
+
validationStatus = 'info';
|
|
114
|
+
break;
|
|
115
|
+
case ScmInputIssueType.Warning:
|
|
116
|
+
validationStatus = 'warning';
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const validationMessage = input.issue ? input.issue.message : '';
|
|
121
|
+
const format = (value: string, ...args: string[]): string => {
|
|
122
|
+
if (args.length !== 0) {
|
|
123
|
+
return value.replace(/{(\d+)}/g, (found, n) => {
|
|
124
|
+
const i = parseInt(n);
|
|
125
|
+
return isNaN(i) || i < 0 || i >= args.length ? found : args[i];
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return value;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const keybinding = this.keybindings.acceleratorFor(this.keybindings.getKeybindingsForCommand('scm.acceptInput')[0]).join('+');
|
|
132
|
+
const message = format(input.placeholder || '', keybinding);
|
|
133
|
+
const textArea = input.visible &&
|
|
134
|
+
<TextareaAutosize
|
|
135
|
+
className={`${ScmCommitWidget.Styles.INPUT_MESSAGE} theia-input theia-scm-input-message-${validationStatus}`}
|
|
136
|
+
id={ScmCommitWidget.Styles.INPUT_MESSAGE}
|
|
137
|
+
placeholder={message}
|
|
138
|
+
spellCheck={false}
|
|
139
|
+
autoFocus={true}
|
|
140
|
+
value={input.value}
|
|
141
|
+
disabled={!input.enabled}
|
|
142
|
+
onChange={this.setInputValue}
|
|
143
|
+
ref={this.inputRef}
|
|
144
|
+
rows={1}
|
|
145
|
+
maxRows={6} /* from VS Code */>
|
|
146
|
+
</TextareaAutosize>;
|
|
147
|
+
return <div className={ScmCommitWidget.Styles.INPUT_MESSAGE_CONTAINER}>
|
|
148
|
+
{textArea}
|
|
149
|
+
<div
|
|
150
|
+
className={
|
|
151
|
+
`${ScmCommitWidget.Styles.VALIDATION_MESSAGE} ${ScmCommitWidget.Styles.NO_SELECT}
|
|
152
|
+
theia-scm-validation-message-${validationStatus} theia-scm-input-message-${validationStatus}`
|
|
153
|
+
}
|
|
154
|
+
style={{
|
|
155
|
+
display: !!input.issue ? 'block' : 'none'
|
|
156
|
+
}}>{validationMessage}</div>
|
|
157
|
+
</div>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
protected setInputValue = (event: React.FormEvent<HTMLTextAreaElement> | React.ChangeEvent<HTMLTextAreaElement> | string) => {
|
|
161
|
+
const repository = this.scmService.selectedRepository;
|
|
162
|
+
if (repository) {
|
|
163
|
+
repository.input.value = typeof event === 'string' ? event : event.currentTarget.value;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Store the tree state.
|
|
169
|
+
*/
|
|
170
|
+
storeState(): ScmCommitWidget.State {
|
|
171
|
+
const message = this.scmService.selectedRepository?.input.value;
|
|
172
|
+
return { message };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Restore the state.
|
|
177
|
+
* @param oldState the old state object.
|
|
178
|
+
*/
|
|
179
|
+
restoreState(oldState: ScmCommitWidget.State): void {
|
|
180
|
+
const value = oldState.message;
|
|
181
|
+
if (!value) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
let repository = this.scmService.selectedRepository;
|
|
185
|
+
if (repository) {
|
|
186
|
+
repository.input.value = value;
|
|
187
|
+
} else {
|
|
188
|
+
const listener = this.scmService.onDidChangeSelectedRepository(() => {
|
|
189
|
+
repository = this.scmService.selectedRepository;
|
|
190
|
+
if (repository) {
|
|
191
|
+
listener.dispose();
|
|
192
|
+
if (!repository.input.value) {
|
|
193
|
+
repository.input.value = value;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
this.toDispose.push(listener);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export namespace ScmCommitWidget {
|
|
204
|
+
|
|
205
|
+
export namespace Styles {
|
|
206
|
+
export const INPUT_MESSAGE_CONTAINER = 'theia-scm-input-message-container';
|
|
207
|
+
export const INPUT_MESSAGE = 'theia-scm-input-message';
|
|
208
|
+
export const VALIDATION_MESSAGE = 'theia-scm-input-validation-message';
|
|
209
|
+
export const NO_SELECT = 'no-select';
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export interface State {
|
|
213
|
+
message?: string
|
|
214
|
+
}
|
|
215
|
+
}
|