@theia/scm-extra 1.34.2 → 1.34.3
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/LICENSE +641 -641
- package/README.md +32 -32
- package/lib/browser/history/index.d.ts +3 -3
- package/lib/browser/history/index.js +31 -31
- package/lib/browser/history/scm-history-constants.d.ts +38 -38
- package/lib/browser/history/scm-history-constants.js +41 -41
- package/lib/browser/history/scm-history-contribution.d.ts +18 -18
- package/lib/browser/history/scm-history-contribution.js +101 -101
- package/lib/browser/history/scm-history-frontend-module.d.ts +3 -3
- package/lib/browser/history/scm-history-frontend-module.js +33 -33
- package/lib/browser/history/scm-history-provider.d.ts +8 -8
- package/lib/browser/history/scm-history-provider.js +25 -25
- package/lib/browser/history/scm-history-widget.d.ts +89 -89
- package/lib/browser/history/scm-history-widget.js +487 -487
- package/lib/browser/scm-extra-contribution.d.ts +1 -1
- package/lib/browser/scm-extra-contribution.js +20 -20
- package/lib/browser/scm-extra-frontend-module.d.ts +3 -3
- package/lib/browser/scm-extra-frontend-module.js +26 -26
- package/lib/browser/scm-extra-layout-migrations.d.ts +5 -5
- package/lib/browser/scm-extra-layout-migrations.js +42 -42
- package/lib/browser/scm-file-change-label-provider.d.ts +16 -16
- package/lib/browser/scm-file-change-label-provider.js +79 -79
- package/lib/browser/scm-file-change-node.d.ts +23 -23
- package/lib/browser/scm-file-change-node.js +26 -26
- package/lib/browser/scm-navigable-list-widget.d.ts +56 -56
- package/lib/browser/scm-navigable-list-widget.js +179 -179
- package/package.json +8 -8
- package/src/browser/history/index.ts +21 -21
- package/src/browser/history/scm-history-constants.ts +69 -69
- package/src/browser/history/scm-history-contribution.ts +90 -90
- package/src/browser/history/scm-history-frontend-module.ts +36 -36
- package/src/browser/history/scm-history-provider.ts +27 -27
- package/src/browser/history/scm-history-widget.tsx +566 -566
- package/src/browser/scm-extra-contribution.ts +18 -18
- package/src/browser/scm-extra-frontend-module.ts +27 -27
- package/src/browser/scm-extra-layout-migrations.ts +32 -32
- package/src/browser/scm-file-change-label-provider.ts +73 -73
- package/src/browser/scm-file-change-node.ts +45 -45
- package/src/browser/scm-navigable-list-widget.tsx +197 -197
- package/src/browser/style/history.css +127 -127
|
@@ -1,488 +1,488 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
27
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.ScmHistoryList = exports.ScmHistoryWidget = exports.ScmHistorySupport = exports.ScmCommitNode = void 0;
|
|
31
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
32
|
-
const core_1 = require("@theia/core");
|
|
33
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
34
|
-
const cancellation_1 = require("@theia/core/lib/common/cancellation");
|
|
35
|
-
const react_virtuoso_1 = require("@theia/core/shared/react-virtuoso");
|
|
36
|
-
const uri_1 = require("@theia/core/lib/common/uri");
|
|
37
|
-
const scm_file_change_node_1 = require("../scm-file-change-node");
|
|
38
|
-
const scm_avatar_service_1 = require("@theia/scm/lib/browser/scm-avatar-service");
|
|
39
|
-
const scm_navigable_list_widget_1 = require("../scm-navigable-list-widget");
|
|
40
|
-
const React = require("@theia/core/shared/react");
|
|
41
|
-
const alert_message_1 = require("@theia/core/lib/browser/widgets/alert-message");
|
|
42
|
-
const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
|
|
43
|
-
const nls_1 = require("@theia/core/lib/common/nls");
|
|
44
|
-
const scm_history_provider_1 = require("./scm-history-provider");
|
|
45
|
-
const throttle = require("@theia/core/shared/lodash.throttle");
|
|
46
|
-
const scm_history_constants_1 = require("./scm-history-constants");
|
|
47
|
-
Object.defineProperty(exports, "ScmCommitNode", { enumerable: true, get: function () { return scm_history_constants_1.ScmCommitNode; } });
|
|
48
|
-
Object.defineProperty(exports, "ScmHistorySupport", { enumerable: true, get: function () { return scm_history_constants_1.ScmHistorySupport; } });
|
|
49
|
-
let ScmHistoryWidget = class ScmHistoryWidget extends scm_navigable_list_widget_1.ScmNavigableListWidget {
|
|
50
|
-
constructor(openerService, shell, fileService, avatarService, widgetManager) {
|
|
51
|
-
super();
|
|
52
|
-
this.openerService = openerService;
|
|
53
|
-
this.shell = shell;
|
|
54
|
-
this.fileService = fileService;
|
|
55
|
-
this.avatarService = avatarService;
|
|
56
|
-
this.widgetManager = widgetManager;
|
|
57
|
-
this.toDisposeOnRepositoryChange = new core_1.DisposableCollection();
|
|
58
|
-
this.toDisposeOnRefresh = new core_1.DisposableCollection();
|
|
59
|
-
this.setContent = throttle((options) => this.doSetContent(options), 100);
|
|
60
|
-
this.loadMoreRows = (index) => this.doLoadMoreRows(index);
|
|
61
|
-
this.renderCommit = (commit) => this.doRenderCommit(commit);
|
|
62
|
-
this.renderFileChangeList = (fileChange) => this.doRenderFileChangeList(fileChange);
|
|
63
|
-
this.id = scm_history_constants_1.SCM_HISTORY_ID;
|
|
64
|
-
this.scrollContainer = 'scm-history-list-container';
|
|
65
|
-
this.title.label = scm_history_constants_1.SCM_HISTORY_LABEL;
|
|
66
|
-
this.title.caption = scm_history_constants_1.SCM_HISTORY_LABEL;
|
|
67
|
-
this.title.iconClass = (0, browser_1.codicon)('history');
|
|
68
|
-
this.title.closable = true;
|
|
69
|
-
this.addClass('theia-scm');
|
|
70
|
-
this.addClass('theia-scm-history');
|
|
71
|
-
this.status = { state: 'loading' };
|
|
72
|
-
this.resetState();
|
|
73
|
-
this.cancelIndicator = new cancellation_1.CancellationTokenSource();
|
|
74
|
-
}
|
|
75
|
-
init() {
|
|
76
|
-
this.refreshOnRepositoryChange();
|
|
77
|
-
this.toDispose.push(this.scmService.onDidChangeSelectedRepository(() => this.refreshOnRepositoryChange()));
|
|
78
|
-
this.toDispose.push(this.labelProvider.onDidChange(event => {
|
|
79
|
-
if (this.scmNodes.some(node => scm_file_change_node_1.ScmFileChangeNode.is(node) && event.affects(new uri_1.default(node.fileChange.uri)))) {
|
|
80
|
-
this.update();
|
|
81
|
-
}
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
|
-
refreshOnRepositoryChange() {
|
|
85
|
-
this.toDisposeOnRepositoryChange.dispose();
|
|
86
|
-
const repository = this.scmService.selectedRepository;
|
|
87
|
-
if (repository && scm_history_provider_1.ScmHistoryProvider.is(repository.provider)) {
|
|
88
|
-
this.historySupport = repository.provider.historySupport;
|
|
89
|
-
if (this.historySupport) {
|
|
90
|
-
this.toDisposeOnRepositoryChange.push(this.historySupport.onDidChangeHistory(() => this.setContent(this.options)));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
this.historySupport = undefined;
|
|
95
|
-
}
|
|
96
|
-
this.setContent(this.options);
|
|
97
|
-
// If switching repository, discard options because they are specific to a repository
|
|
98
|
-
this.options = this.createHistoryOptions();
|
|
99
|
-
this.refresh();
|
|
100
|
-
}
|
|
101
|
-
createHistoryOptions() {
|
|
102
|
-
return {
|
|
103
|
-
maxCount: scm_history_constants_1.SCM_HISTORY_MAX_COUNT
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
refresh() {
|
|
107
|
-
this.toDisposeOnRefresh.dispose();
|
|
108
|
-
this.toDispose.push(this.toDisposeOnRefresh);
|
|
109
|
-
const repository = this.scmService.selectedRepository;
|
|
110
|
-
this.title.label = scm_history_constants_1.SCM_HISTORY_LABEL;
|
|
111
|
-
if (repository) {
|
|
112
|
-
this.title.label += ': ' + repository.provider.label;
|
|
113
|
-
}
|
|
114
|
-
const area = this.shell.getAreaFor(this);
|
|
115
|
-
if (area === 'left') {
|
|
116
|
-
this.shell.leftPanelHandler.refresh();
|
|
117
|
-
}
|
|
118
|
-
else if (area === 'right') {
|
|
119
|
-
this.shell.rightPanelHandler.refresh();
|
|
120
|
-
}
|
|
121
|
-
this.update();
|
|
122
|
-
if (repository) {
|
|
123
|
-
this.toDisposeOnRefresh.push(repository.onDidChange(() => this.update()));
|
|
124
|
-
// render synchronously to avoid cursor jumping
|
|
125
|
-
// see https://stackoverflow.com/questions/28922275/in-reactjs-why-does-setstate-behave-differently-when-called-synchronously/28922465#28922465
|
|
126
|
-
this.toDisposeOnRefresh.push(repository.input.onDidChange(() => this.setContent(this.options)));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
onAfterAttach(msg) {
|
|
130
|
-
super.onAfterAttach(msg);
|
|
131
|
-
this.addListNavigationKeyListeners(this.node);
|
|
132
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
-
this.addEventListener(this.node, 'ps-scroll-y', (e) => {
|
|
134
|
-
var _a;
|
|
135
|
-
if ((_a = this.listView) === null || _a === void 0 ? void 0 : _a.list) {
|
|
136
|
-
const { scrollTop } = e.target;
|
|
137
|
-
this.listView.list.scrollTo({
|
|
138
|
-
top: scrollTop
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
async doSetContent(options) {
|
|
144
|
-
this.resetState(options);
|
|
145
|
-
if (options && options.uri) {
|
|
146
|
-
try {
|
|
147
|
-
const fileStat = await this.fileService.resolve(new uri_1.default(options.uri));
|
|
148
|
-
this.singleFileMode = !fileStat.isDirectory;
|
|
149
|
-
}
|
|
150
|
-
catch (_a) {
|
|
151
|
-
this.singleFileMode = true;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
await this.addCommits(options);
|
|
155
|
-
this.onDataReady();
|
|
156
|
-
if (this.scmNodes.length > 0) {
|
|
157
|
-
this.selectNode(this.scmNodes[0]);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
resetState(options) {
|
|
161
|
-
this.options = options || this.createHistoryOptions();
|
|
162
|
-
this.hasMoreCommits = true;
|
|
163
|
-
this.allowScrollToSelected = true;
|
|
164
|
-
}
|
|
165
|
-
async addCommits(options) {
|
|
166
|
-
// const repository: Repository | undefined = this.repositoryProvider.findRepositoryOrSelected(options);
|
|
167
|
-
const repository = this.scmService.selectedRepository;
|
|
168
|
-
this.cancelIndicator.cancel();
|
|
169
|
-
this.cancelIndicator = new cancellation_1.CancellationTokenSource();
|
|
170
|
-
const token = this.cancelIndicator.token;
|
|
171
|
-
if (repository) {
|
|
172
|
-
if (this.historySupport) {
|
|
173
|
-
try {
|
|
174
|
-
const currentCommits = this.status.state === 'ready' ? this.status.commits : [];
|
|
175
|
-
let history = await this.historySupport.getCommitHistory(options);
|
|
176
|
-
if (token.isCancellationRequested || !this.hasMoreCommits) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (options && ((options.maxCount && history.length < options.maxCount) || (!options.maxCount && currentCommits))) {
|
|
180
|
-
this.hasMoreCommits = false;
|
|
181
|
-
}
|
|
182
|
-
if (currentCommits.length > 0) {
|
|
183
|
-
history = history.slice(1);
|
|
184
|
-
}
|
|
185
|
-
const commits = [];
|
|
186
|
-
for (const commit of history) {
|
|
187
|
-
const fileChangeNodes = [];
|
|
188
|
-
await Promise.all(commit.fileChanges.map(async (fileChange) => {
|
|
189
|
-
fileChangeNodes.push({
|
|
190
|
-
fileChange, commitId: commit.id
|
|
191
|
-
});
|
|
192
|
-
}));
|
|
193
|
-
const avatarUrl = await this.avatarService.getAvatar(commit.authorEmail);
|
|
194
|
-
commits.push({
|
|
195
|
-
commitDetails: commit,
|
|
196
|
-
authorAvatar: avatarUrl,
|
|
197
|
-
fileChangeNodes,
|
|
198
|
-
expanded: false,
|
|
199
|
-
selected: false
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
currentCommits.push(...commits);
|
|
203
|
-
this.status = { state: 'ready', commits: currentCommits };
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
if (options && options.uri && repository) {
|
|
207
|
-
this.hasMoreCommits = false;
|
|
208
|
-
}
|
|
209
|
-
this.status = { state: 'error', errorMessage: React.createElement(React.Fragment, null,
|
|
210
|
-
" ",
|
|
211
|
-
error.message,
|
|
212
|
-
" ") };
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
this.status = { state: 'error', errorMessage: React.createElement(React.Fragment, null,
|
|
217
|
-
"History is not supported for ",
|
|
218
|
-
repository.provider.label,
|
|
219
|
-
" source control.") };
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
this.status = {
|
|
224
|
-
state: 'error',
|
|
225
|
-
errorMessage: React.createElement(React.Fragment, null, nls_1.nls.localizeByDefault('No source control providers registered.'))
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
async addOrRemoveFileChangeNodes(commit) {
|
|
230
|
-
const id = this.scmNodes.findIndex(node => node === commit);
|
|
231
|
-
if (commit.expanded) {
|
|
232
|
-
this.removeFileChangeNodes(commit, id);
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
await this.addFileChangeNodes(commit, id);
|
|
236
|
-
}
|
|
237
|
-
commit.expanded = !commit.expanded;
|
|
238
|
-
this.update();
|
|
239
|
-
}
|
|
240
|
-
async addFileChangeNodes(commit, scmNodesArrayIndex) {
|
|
241
|
-
if (commit.fileChangeNodes) {
|
|
242
|
-
this.scmNodes.splice(scmNodesArrayIndex + 1, 0, ...commit.fileChangeNodes.map(node => Object.assign(node, { commitSha: commit.commitDetails.id })));
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
removeFileChangeNodes(commit, scmNodesArrayIndex) {
|
|
246
|
-
if (commit.fileChangeNodes) {
|
|
247
|
-
this.scmNodes.splice(scmNodesArrayIndex + 1, commit.fileChangeNodes.length);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
storeState() {
|
|
251
|
-
const { options, singleFileMode } = this;
|
|
252
|
-
return {
|
|
253
|
-
options,
|
|
254
|
-
singleFileMode
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
|
-
restoreState(oldState) {
|
|
259
|
-
this.options = oldState['options'];
|
|
260
|
-
this.options.maxCount = scm_history_constants_1.SCM_HISTORY_MAX_COUNT;
|
|
261
|
-
this.singleFileMode = oldState['singleFileMode'];
|
|
262
|
-
this.setContent(this.options);
|
|
263
|
-
}
|
|
264
|
-
onDataReady() {
|
|
265
|
-
if (this.status.state === 'ready') {
|
|
266
|
-
this.scmNodes = this.status.commits;
|
|
267
|
-
}
|
|
268
|
-
this.update();
|
|
269
|
-
}
|
|
270
|
-
render() {
|
|
271
|
-
let content;
|
|
272
|
-
switch (this.status.state) {
|
|
273
|
-
case 'ready':
|
|
274
|
-
content = React.createElement(React.Fragment, null,
|
|
275
|
-
this.renderHistoryHeader(),
|
|
276
|
-
this.renderCommitList());
|
|
277
|
-
break;
|
|
278
|
-
case 'error':
|
|
279
|
-
const reason = this.status.errorMessage;
|
|
280
|
-
let path = '';
|
|
281
|
-
if (this.options.uri) {
|
|
282
|
-
const relPathEncoded = this.scmLabelProvider.relativePath(this.options.uri);
|
|
283
|
-
const relPath = relPathEncoded ? `${decodeURIComponent(relPathEncoded)}` : '';
|
|
284
|
-
const repo = this.scmService.findRepository(new uri_1.default(this.options.uri));
|
|
285
|
-
const repoName = repo ? `${this.labelProvider.getName(new uri_1.default(repo.provider.rootUri))}` : '';
|
|
286
|
-
const relPathAndRepo = [relPath, repoName].filter(Boolean).join(' in ');
|
|
287
|
-
path = ` for ${relPathAndRepo}`;
|
|
288
|
-
}
|
|
289
|
-
content = React.createElement(alert_message_1.AlertMessage, { type: 'WARNING', header: `There is no history available${path}.` }, reason);
|
|
290
|
-
break;
|
|
291
|
-
case 'loading':
|
|
292
|
-
content = React.createElement("div", { className: 'spinnerContainer' },
|
|
293
|
-
React.createElement("span", { className: `${(0, browser_1.codicon)('loading')} theia-animation-spin large-spinner` }));
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
return React.createElement("div", { className: 'history-container' }, content);
|
|
297
|
-
}
|
|
298
|
-
renderHistoryHeader() {
|
|
299
|
-
if (this.options.uri) {
|
|
300
|
-
const path = this.scmLabelProvider.relativePath(this.options.uri);
|
|
301
|
-
const fileName = path.split('/').pop();
|
|
302
|
-
return React.createElement("div", { className: 'diff-header' },
|
|
303
|
-
this.renderHeaderRow({ name: 'repository', value: this.getRepositoryLabel(this.options.uri) }),
|
|
304
|
-
this.renderHeaderRow({ name: 'file', value: fileName, title: path }),
|
|
305
|
-
React.createElement("div", { className: 'theia-header' }, "Commits"));
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
renderCommitList() {
|
|
309
|
-
const list = React.createElement("div", { className: 'listContainer', id: this.scrollContainer },
|
|
310
|
-
React.createElement(ScmHistoryList, { ref: listView => this.listView = (listView || undefined), rows: this.scmNodes, hasMoreRows: this.hasMoreCommits, loadMoreRows: this.loadMoreRows, renderCommit: this.renderCommit, renderFileChangeList: this.renderFileChangeList }));
|
|
311
|
-
this.allowScrollToSelected = true;
|
|
312
|
-
return list;
|
|
313
|
-
}
|
|
314
|
-
doLoadMoreRows(index) {
|
|
315
|
-
let resolver;
|
|
316
|
-
const promise = new Promise(resolve => resolver = resolve);
|
|
317
|
-
const lastRow = this.scmNodes[index - 1];
|
|
318
|
-
if (scm_history_constants_1.ScmCommitNode.is(lastRow)) {
|
|
319
|
-
const toRevision = lastRow.commitDetails.id;
|
|
320
|
-
this.addCommits({
|
|
321
|
-
range: { toRevision },
|
|
322
|
-
maxCount: scm_history_constants_1.SCM_HISTORY_MAX_COUNT,
|
|
323
|
-
uri: this.options.uri
|
|
324
|
-
}).then(() => {
|
|
325
|
-
this.allowScrollToSelected = false;
|
|
326
|
-
this.onDataReady();
|
|
327
|
-
resolver();
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
return promise;
|
|
331
|
-
}
|
|
332
|
-
doRenderCommit(commit) {
|
|
333
|
-
let expansionToggleIcon = (0, browser_1.codicon)('chevron-right');
|
|
334
|
-
if (commit && commit.expanded) {
|
|
335
|
-
expansionToggleIcon = (0, browser_1.codicon)('chevron-down');
|
|
336
|
-
}
|
|
337
|
-
return React.createElement("div", { className: `containerHead${commit.selected ? ' ' + browser_1.SELECTED_CLASS : ''}`, onClick: e => {
|
|
338
|
-
if (commit.selected && !this.singleFileMode) {
|
|
339
|
-
this.addOrRemoveFileChangeNodes(commit);
|
|
340
|
-
}
|
|
341
|
-
else {
|
|
342
|
-
this.selectNode(commit);
|
|
343
|
-
}
|
|
344
|
-
e.preventDefault();
|
|
345
|
-
}, onDoubleClick: e => {
|
|
346
|
-
if (this.singleFileMode && commit.fileChangeNodes.length > 0) {
|
|
347
|
-
this.openFile(commit.fileChangeNodes[0].fileChange);
|
|
348
|
-
}
|
|
349
|
-
e.preventDefault();
|
|
350
|
-
} },
|
|
351
|
-
React.createElement("div", { className: 'headContent' },
|
|
352
|
-
React.createElement("div", { className: 'image-container' },
|
|
353
|
-
React.createElement("img", { className: 'gravatar', src: commit.authorAvatar })),
|
|
354
|
-
React.createElement("div", { className: `headLabelContainer${this.singleFileMode ? ' singleFileMode' : ''}` },
|
|
355
|
-
React.createElement("div", { className: 'headLabel noWrapInfo noselect' }, commit.commitDetails.summary),
|
|
356
|
-
React.createElement("div", { className: 'commitTime noWrapInfo noselect' }, commit.commitDetails.authorDateRelative + ' by ' + commit.commitDetails.authorName)),
|
|
357
|
-
React.createElement("div", { className: `${(0, browser_1.codicon)('eye')} detailButton`, onClick: () => this.openDetailWidget(commit) }),
|
|
358
|
-
!this.singleFileMode && React.createElement("div", { className: 'expansionToggle noselect' },
|
|
359
|
-
React.createElement("div", { className: 'toggle' },
|
|
360
|
-
React.createElement("div", { className: 'number' }, commit.commitDetails.fileChanges.length.toString()),
|
|
361
|
-
React.createElement("div", { className: 'icon ' + expansionToggleIcon })))));
|
|
362
|
-
}
|
|
363
|
-
async openDetailWidget(commitNode) {
|
|
364
|
-
const options = Object.assign(Object.assign({}, commitNode.commitDetails.commitDetailOptions), { mode: 'reveal' });
|
|
365
|
-
(0, browser_1.open)(this.openerService, commitNode.commitDetails.commitDetailUri, options);
|
|
366
|
-
}
|
|
367
|
-
doRenderFileChangeList(fileChange) {
|
|
368
|
-
const fileChangeElement = this.renderScmItem(fileChange, fileChange.commitId);
|
|
369
|
-
return fileChangeElement;
|
|
370
|
-
}
|
|
371
|
-
renderScmItem(change, commitSha) {
|
|
372
|
-
return React.createElement(scm_navigable_list_widget_1.ScmItemComponent, Object.assign({ key: change.fileChange.uri.toString() }, {
|
|
373
|
-
labelProvider: this.labelProvider,
|
|
374
|
-
scmLabelProvider: this.scmLabelProvider,
|
|
375
|
-
change,
|
|
376
|
-
revealChange: () => this.openFile(change.fileChange),
|
|
377
|
-
selectNode: () => this.selectNode(change)
|
|
378
|
-
}));
|
|
379
|
-
}
|
|
380
|
-
navigateLeft() {
|
|
381
|
-
const selected = this.getSelected();
|
|
382
|
-
if (selected && this.status.state === 'ready') {
|
|
383
|
-
if (scm_history_constants_1.ScmCommitNode.is(selected)) {
|
|
384
|
-
const idx = this.status.commits.findIndex(c => c.commitDetails.id === selected.commitDetails.id);
|
|
385
|
-
if (selected.expanded) {
|
|
386
|
-
this.addOrRemoveFileChangeNodes(selected);
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
if (idx > 0) {
|
|
390
|
-
this.selectNode(this.status.commits[idx - 1]);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
else if (scm_file_change_node_1.ScmFileChangeNode.is(selected)) {
|
|
395
|
-
const idx = this.status.commits.findIndex(c => c.commitDetails.id === selected.commitId);
|
|
396
|
-
this.selectNode(this.status.commits[idx]);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
this.update();
|
|
400
|
-
}
|
|
401
|
-
navigateRight() {
|
|
402
|
-
const selected = this.getSelected();
|
|
403
|
-
if (selected) {
|
|
404
|
-
if (scm_history_constants_1.ScmCommitNode.is(selected) && !selected.expanded && !this.singleFileMode) {
|
|
405
|
-
this.addOrRemoveFileChangeNodes(selected);
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
this.selectNextNode();
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
this.update();
|
|
412
|
-
}
|
|
413
|
-
handleListEnter() {
|
|
414
|
-
const selected = this.getSelected();
|
|
415
|
-
if (selected) {
|
|
416
|
-
if (scm_history_constants_1.ScmCommitNode.is(selected)) {
|
|
417
|
-
if (this.singleFileMode) {
|
|
418
|
-
this.openFile(selected.fileChangeNodes[0].fileChange);
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
this.openDetailWidget(selected);
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
else if (scm_file_change_node_1.ScmFileChangeNode.is(selected)) {
|
|
425
|
-
this.openFile(selected.fileChange);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
this.update();
|
|
429
|
-
}
|
|
430
|
-
openFile(change) {
|
|
431
|
-
const uriToOpen = change.getUriToOpen();
|
|
432
|
-
(0, browser_1.open)(this.openerService, uriToOpen, { mode: 'reveal' });
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
__decorate([
|
|
436
|
-
(0, inversify_1.postConstruct)(),
|
|
437
|
-
__metadata("design:type", Function),
|
|
438
|
-
__metadata("design:paramtypes", []),
|
|
439
|
-
__metadata("design:returntype", void 0)
|
|
440
|
-
], ScmHistoryWidget.prototype, "init", null);
|
|
441
|
-
ScmHistoryWidget = __decorate([
|
|
442
|
-
(0, inversify_1.injectable)(),
|
|
443
|
-
__param(0, (0, inversify_1.inject)(browser_1.OpenerService)),
|
|
444
|
-
__param(1, (0, inversify_1.inject)(browser_1.ApplicationShell)),
|
|
445
|
-
__param(2, (0, inversify_1.inject)(file_service_1.FileService)),
|
|
446
|
-
__param(3, (0, inversify_1.inject)(scm_avatar_service_1.ScmAvatarService)),
|
|
447
|
-
__param(4, (0, inversify_1.inject)(browser_1.WidgetManager)),
|
|
448
|
-
__metadata("design:paramtypes", [Object, browser_1.ApplicationShell,
|
|
449
|
-
file_service_1.FileService,
|
|
450
|
-
scm_avatar_service_1.ScmAvatarService,
|
|
451
|
-
browser_1.WidgetManager])
|
|
452
|
-
], ScmHistoryWidget);
|
|
453
|
-
exports.ScmHistoryWidget = ScmHistoryWidget;
|
|
454
|
-
class ScmHistoryList extends React.Component {
|
|
455
|
-
constructor() {
|
|
456
|
-
super(...arguments);
|
|
457
|
-
this.checkIfRowIsLoaded = (opts) => this.doCheckIfRowIsLoaded(opts);
|
|
458
|
-
}
|
|
459
|
-
doCheckIfRowIsLoaded(opts) {
|
|
460
|
-
const row = this.props.rows[opts.index];
|
|
461
|
-
return !!row;
|
|
462
|
-
}
|
|
463
|
-
render() {
|
|
464
|
-
const { hasMoreRows, loadMoreRows, rows } = this.props;
|
|
465
|
-
return React.createElement(react_virtuoso_1.Virtuoso, { ref: list => this.list = (list || undefined), data: rows, itemContent: index => this.renderRow(index), endReached: hasMoreRows ? loadMoreRows : undefined, overscan: 500, style: {
|
|
466
|
-
overflowX: 'hidden'
|
|
467
|
-
} });
|
|
468
|
-
}
|
|
469
|
-
renderRow(index) {
|
|
470
|
-
if (this.checkIfRowIsLoaded({ index })) {
|
|
471
|
-
const row = this.props.rows[index];
|
|
472
|
-
if (scm_history_constants_1.ScmCommitNode.is(row)) {
|
|
473
|
-
const head = this.props.renderCommit(row);
|
|
474
|
-
return React.createElement("div", { className: `commitListElement${index === 0 ? ' first' : ''}` }, head);
|
|
475
|
-
}
|
|
476
|
-
else if (scm_file_change_node_1.ScmFileChangeNode.is(row)) {
|
|
477
|
-
return React.createElement("div", { className: 'fileChangeListElement' }, this.props.renderFileChangeList(row));
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
else {
|
|
481
|
-
return React.createElement("div", { className: `commitListElement${index === 0 ? ' first' : ''}` },
|
|
482
|
-
React.createElement("span", { className: `${(0, browser_1.codicon)('loading')} theia-animation-spin` }));
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
;
|
|
486
|
-
}
|
|
487
|
-
exports.ScmHistoryList = ScmHistoryList;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2018 TypeFox and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
27
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.ScmHistoryList = exports.ScmHistoryWidget = exports.ScmHistorySupport = exports.ScmCommitNode = void 0;
|
|
31
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
32
|
+
const core_1 = require("@theia/core");
|
|
33
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
34
|
+
const cancellation_1 = require("@theia/core/lib/common/cancellation");
|
|
35
|
+
const react_virtuoso_1 = require("@theia/core/shared/react-virtuoso");
|
|
36
|
+
const uri_1 = require("@theia/core/lib/common/uri");
|
|
37
|
+
const scm_file_change_node_1 = require("../scm-file-change-node");
|
|
38
|
+
const scm_avatar_service_1 = require("@theia/scm/lib/browser/scm-avatar-service");
|
|
39
|
+
const scm_navigable_list_widget_1 = require("../scm-navigable-list-widget");
|
|
40
|
+
const React = require("@theia/core/shared/react");
|
|
41
|
+
const alert_message_1 = require("@theia/core/lib/browser/widgets/alert-message");
|
|
42
|
+
const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
|
|
43
|
+
const nls_1 = require("@theia/core/lib/common/nls");
|
|
44
|
+
const scm_history_provider_1 = require("./scm-history-provider");
|
|
45
|
+
const throttle = require("@theia/core/shared/lodash.throttle");
|
|
46
|
+
const scm_history_constants_1 = require("./scm-history-constants");
|
|
47
|
+
Object.defineProperty(exports, "ScmCommitNode", { enumerable: true, get: function () { return scm_history_constants_1.ScmCommitNode; } });
|
|
48
|
+
Object.defineProperty(exports, "ScmHistorySupport", { enumerable: true, get: function () { return scm_history_constants_1.ScmHistorySupport; } });
|
|
49
|
+
let ScmHistoryWidget = class ScmHistoryWidget extends scm_navigable_list_widget_1.ScmNavigableListWidget {
|
|
50
|
+
constructor(openerService, shell, fileService, avatarService, widgetManager) {
|
|
51
|
+
super();
|
|
52
|
+
this.openerService = openerService;
|
|
53
|
+
this.shell = shell;
|
|
54
|
+
this.fileService = fileService;
|
|
55
|
+
this.avatarService = avatarService;
|
|
56
|
+
this.widgetManager = widgetManager;
|
|
57
|
+
this.toDisposeOnRepositoryChange = new core_1.DisposableCollection();
|
|
58
|
+
this.toDisposeOnRefresh = new core_1.DisposableCollection();
|
|
59
|
+
this.setContent = throttle((options) => this.doSetContent(options), 100);
|
|
60
|
+
this.loadMoreRows = (index) => this.doLoadMoreRows(index);
|
|
61
|
+
this.renderCommit = (commit) => this.doRenderCommit(commit);
|
|
62
|
+
this.renderFileChangeList = (fileChange) => this.doRenderFileChangeList(fileChange);
|
|
63
|
+
this.id = scm_history_constants_1.SCM_HISTORY_ID;
|
|
64
|
+
this.scrollContainer = 'scm-history-list-container';
|
|
65
|
+
this.title.label = scm_history_constants_1.SCM_HISTORY_LABEL;
|
|
66
|
+
this.title.caption = scm_history_constants_1.SCM_HISTORY_LABEL;
|
|
67
|
+
this.title.iconClass = (0, browser_1.codicon)('history');
|
|
68
|
+
this.title.closable = true;
|
|
69
|
+
this.addClass('theia-scm');
|
|
70
|
+
this.addClass('theia-scm-history');
|
|
71
|
+
this.status = { state: 'loading' };
|
|
72
|
+
this.resetState();
|
|
73
|
+
this.cancelIndicator = new cancellation_1.CancellationTokenSource();
|
|
74
|
+
}
|
|
75
|
+
init() {
|
|
76
|
+
this.refreshOnRepositoryChange();
|
|
77
|
+
this.toDispose.push(this.scmService.onDidChangeSelectedRepository(() => this.refreshOnRepositoryChange()));
|
|
78
|
+
this.toDispose.push(this.labelProvider.onDidChange(event => {
|
|
79
|
+
if (this.scmNodes.some(node => scm_file_change_node_1.ScmFileChangeNode.is(node) && event.affects(new uri_1.default(node.fileChange.uri)))) {
|
|
80
|
+
this.update();
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
refreshOnRepositoryChange() {
|
|
85
|
+
this.toDisposeOnRepositoryChange.dispose();
|
|
86
|
+
const repository = this.scmService.selectedRepository;
|
|
87
|
+
if (repository && scm_history_provider_1.ScmHistoryProvider.is(repository.provider)) {
|
|
88
|
+
this.historySupport = repository.provider.historySupport;
|
|
89
|
+
if (this.historySupport) {
|
|
90
|
+
this.toDisposeOnRepositoryChange.push(this.historySupport.onDidChangeHistory(() => this.setContent(this.options)));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this.historySupport = undefined;
|
|
95
|
+
}
|
|
96
|
+
this.setContent(this.options);
|
|
97
|
+
// If switching repository, discard options because they are specific to a repository
|
|
98
|
+
this.options = this.createHistoryOptions();
|
|
99
|
+
this.refresh();
|
|
100
|
+
}
|
|
101
|
+
createHistoryOptions() {
|
|
102
|
+
return {
|
|
103
|
+
maxCount: scm_history_constants_1.SCM_HISTORY_MAX_COUNT
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
refresh() {
|
|
107
|
+
this.toDisposeOnRefresh.dispose();
|
|
108
|
+
this.toDispose.push(this.toDisposeOnRefresh);
|
|
109
|
+
const repository = this.scmService.selectedRepository;
|
|
110
|
+
this.title.label = scm_history_constants_1.SCM_HISTORY_LABEL;
|
|
111
|
+
if (repository) {
|
|
112
|
+
this.title.label += ': ' + repository.provider.label;
|
|
113
|
+
}
|
|
114
|
+
const area = this.shell.getAreaFor(this);
|
|
115
|
+
if (area === 'left') {
|
|
116
|
+
this.shell.leftPanelHandler.refresh();
|
|
117
|
+
}
|
|
118
|
+
else if (area === 'right') {
|
|
119
|
+
this.shell.rightPanelHandler.refresh();
|
|
120
|
+
}
|
|
121
|
+
this.update();
|
|
122
|
+
if (repository) {
|
|
123
|
+
this.toDisposeOnRefresh.push(repository.onDidChange(() => this.update()));
|
|
124
|
+
// render synchronously to avoid cursor jumping
|
|
125
|
+
// see https://stackoverflow.com/questions/28922275/in-reactjs-why-does-setstate-behave-differently-when-called-synchronously/28922465#28922465
|
|
126
|
+
this.toDisposeOnRefresh.push(repository.input.onDidChange(() => this.setContent(this.options)));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
onAfterAttach(msg) {
|
|
130
|
+
super.onAfterAttach(msg);
|
|
131
|
+
this.addListNavigationKeyListeners(this.node);
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
133
|
+
this.addEventListener(this.node, 'ps-scroll-y', (e) => {
|
|
134
|
+
var _a;
|
|
135
|
+
if ((_a = this.listView) === null || _a === void 0 ? void 0 : _a.list) {
|
|
136
|
+
const { scrollTop } = e.target;
|
|
137
|
+
this.listView.list.scrollTo({
|
|
138
|
+
top: scrollTop
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async doSetContent(options) {
|
|
144
|
+
this.resetState(options);
|
|
145
|
+
if (options && options.uri) {
|
|
146
|
+
try {
|
|
147
|
+
const fileStat = await this.fileService.resolve(new uri_1.default(options.uri));
|
|
148
|
+
this.singleFileMode = !fileStat.isDirectory;
|
|
149
|
+
}
|
|
150
|
+
catch (_a) {
|
|
151
|
+
this.singleFileMode = true;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
await this.addCommits(options);
|
|
155
|
+
this.onDataReady();
|
|
156
|
+
if (this.scmNodes.length > 0) {
|
|
157
|
+
this.selectNode(this.scmNodes[0]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
resetState(options) {
|
|
161
|
+
this.options = options || this.createHistoryOptions();
|
|
162
|
+
this.hasMoreCommits = true;
|
|
163
|
+
this.allowScrollToSelected = true;
|
|
164
|
+
}
|
|
165
|
+
async addCommits(options) {
|
|
166
|
+
// const repository: Repository | undefined = this.repositoryProvider.findRepositoryOrSelected(options);
|
|
167
|
+
const repository = this.scmService.selectedRepository;
|
|
168
|
+
this.cancelIndicator.cancel();
|
|
169
|
+
this.cancelIndicator = new cancellation_1.CancellationTokenSource();
|
|
170
|
+
const token = this.cancelIndicator.token;
|
|
171
|
+
if (repository) {
|
|
172
|
+
if (this.historySupport) {
|
|
173
|
+
try {
|
|
174
|
+
const currentCommits = this.status.state === 'ready' ? this.status.commits : [];
|
|
175
|
+
let history = await this.historySupport.getCommitHistory(options);
|
|
176
|
+
if (token.isCancellationRequested || !this.hasMoreCommits) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (options && ((options.maxCount && history.length < options.maxCount) || (!options.maxCount && currentCommits))) {
|
|
180
|
+
this.hasMoreCommits = false;
|
|
181
|
+
}
|
|
182
|
+
if (currentCommits.length > 0) {
|
|
183
|
+
history = history.slice(1);
|
|
184
|
+
}
|
|
185
|
+
const commits = [];
|
|
186
|
+
for (const commit of history) {
|
|
187
|
+
const fileChangeNodes = [];
|
|
188
|
+
await Promise.all(commit.fileChanges.map(async (fileChange) => {
|
|
189
|
+
fileChangeNodes.push({
|
|
190
|
+
fileChange, commitId: commit.id
|
|
191
|
+
});
|
|
192
|
+
}));
|
|
193
|
+
const avatarUrl = await this.avatarService.getAvatar(commit.authorEmail);
|
|
194
|
+
commits.push({
|
|
195
|
+
commitDetails: commit,
|
|
196
|
+
authorAvatar: avatarUrl,
|
|
197
|
+
fileChangeNodes,
|
|
198
|
+
expanded: false,
|
|
199
|
+
selected: false
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
currentCommits.push(...commits);
|
|
203
|
+
this.status = { state: 'ready', commits: currentCommits };
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
if (options && options.uri && repository) {
|
|
207
|
+
this.hasMoreCommits = false;
|
|
208
|
+
}
|
|
209
|
+
this.status = { state: 'error', errorMessage: React.createElement(React.Fragment, null,
|
|
210
|
+
" ",
|
|
211
|
+
error.message,
|
|
212
|
+
" ") };
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
this.status = { state: 'error', errorMessage: React.createElement(React.Fragment, null,
|
|
217
|
+
"History is not supported for ",
|
|
218
|
+
repository.provider.label,
|
|
219
|
+
" source control.") };
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
this.status = {
|
|
224
|
+
state: 'error',
|
|
225
|
+
errorMessage: React.createElement(React.Fragment, null, nls_1.nls.localizeByDefault('No source control providers registered.'))
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async addOrRemoveFileChangeNodes(commit) {
|
|
230
|
+
const id = this.scmNodes.findIndex(node => node === commit);
|
|
231
|
+
if (commit.expanded) {
|
|
232
|
+
this.removeFileChangeNodes(commit, id);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
await this.addFileChangeNodes(commit, id);
|
|
236
|
+
}
|
|
237
|
+
commit.expanded = !commit.expanded;
|
|
238
|
+
this.update();
|
|
239
|
+
}
|
|
240
|
+
async addFileChangeNodes(commit, scmNodesArrayIndex) {
|
|
241
|
+
if (commit.fileChangeNodes) {
|
|
242
|
+
this.scmNodes.splice(scmNodesArrayIndex + 1, 0, ...commit.fileChangeNodes.map(node => Object.assign(node, { commitSha: commit.commitDetails.id })));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
removeFileChangeNodes(commit, scmNodesArrayIndex) {
|
|
246
|
+
if (commit.fileChangeNodes) {
|
|
247
|
+
this.scmNodes.splice(scmNodesArrayIndex + 1, commit.fileChangeNodes.length);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
storeState() {
|
|
251
|
+
const { options, singleFileMode } = this;
|
|
252
|
+
return {
|
|
253
|
+
options,
|
|
254
|
+
singleFileMode
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
258
|
+
restoreState(oldState) {
|
|
259
|
+
this.options = oldState['options'];
|
|
260
|
+
this.options.maxCount = scm_history_constants_1.SCM_HISTORY_MAX_COUNT;
|
|
261
|
+
this.singleFileMode = oldState['singleFileMode'];
|
|
262
|
+
this.setContent(this.options);
|
|
263
|
+
}
|
|
264
|
+
onDataReady() {
|
|
265
|
+
if (this.status.state === 'ready') {
|
|
266
|
+
this.scmNodes = this.status.commits;
|
|
267
|
+
}
|
|
268
|
+
this.update();
|
|
269
|
+
}
|
|
270
|
+
render() {
|
|
271
|
+
let content;
|
|
272
|
+
switch (this.status.state) {
|
|
273
|
+
case 'ready':
|
|
274
|
+
content = React.createElement(React.Fragment, null,
|
|
275
|
+
this.renderHistoryHeader(),
|
|
276
|
+
this.renderCommitList());
|
|
277
|
+
break;
|
|
278
|
+
case 'error':
|
|
279
|
+
const reason = this.status.errorMessage;
|
|
280
|
+
let path = '';
|
|
281
|
+
if (this.options.uri) {
|
|
282
|
+
const relPathEncoded = this.scmLabelProvider.relativePath(this.options.uri);
|
|
283
|
+
const relPath = relPathEncoded ? `${decodeURIComponent(relPathEncoded)}` : '';
|
|
284
|
+
const repo = this.scmService.findRepository(new uri_1.default(this.options.uri));
|
|
285
|
+
const repoName = repo ? `${this.labelProvider.getName(new uri_1.default(repo.provider.rootUri))}` : '';
|
|
286
|
+
const relPathAndRepo = [relPath, repoName].filter(Boolean).join(' in ');
|
|
287
|
+
path = ` for ${relPathAndRepo}`;
|
|
288
|
+
}
|
|
289
|
+
content = React.createElement(alert_message_1.AlertMessage, { type: 'WARNING', header: `There is no history available${path}.` }, reason);
|
|
290
|
+
break;
|
|
291
|
+
case 'loading':
|
|
292
|
+
content = React.createElement("div", { className: 'spinnerContainer' },
|
|
293
|
+
React.createElement("span", { className: `${(0, browser_1.codicon)('loading')} theia-animation-spin large-spinner` }));
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
return React.createElement("div", { className: 'history-container' }, content);
|
|
297
|
+
}
|
|
298
|
+
renderHistoryHeader() {
|
|
299
|
+
if (this.options.uri) {
|
|
300
|
+
const path = this.scmLabelProvider.relativePath(this.options.uri);
|
|
301
|
+
const fileName = path.split('/').pop();
|
|
302
|
+
return React.createElement("div", { className: 'diff-header' },
|
|
303
|
+
this.renderHeaderRow({ name: 'repository', value: this.getRepositoryLabel(this.options.uri) }),
|
|
304
|
+
this.renderHeaderRow({ name: 'file', value: fileName, title: path }),
|
|
305
|
+
React.createElement("div", { className: 'theia-header' }, "Commits"));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
renderCommitList() {
|
|
309
|
+
const list = React.createElement("div", { className: 'listContainer', id: this.scrollContainer },
|
|
310
|
+
React.createElement(ScmHistoryList, { ref: listView => this.listView = (listView || undefined), rows: this.scmNodes, hasMoreRows: this.hasMoreCommits, loadMoreRows: this.loadMoreRows, renderCommit: this.renderCommit, renderFileChangeList: this.renderFileChangeList }));
|
|
311
|
+
this.allowScrollToSelected = true;
|
|
312
|
+
return list;
|
|
313
|
+
}
|
|
314
|
+
doLoadMoreRows(index) {
|
|
315
|
+
let resolver;
|
|
316
|
+
const promise = new Promise(resolve => resolver = resolve);
|
|
317
|
+
const lastRow = this.scmNodes[index - 1];
|
|
318
|
+
if (scm_history_constants_1.ScmCommitNode.is(lastRow)) {
|
|
319
|
+
const toRevision = lastRow.commitDetails.id;
|
|
320
|
+
this.addCommits({
|
|
321
|
+
range: { toRevision },
|
|
322
|
+
maxCount: scm_history_constants_1.SCM_HISTORY_MAX_COUNT,
|
|
323
|
+
uri: this.options.uri
|
|
324
|
+
}).then(() => {
|
|
325
|
+
this.allowScrollToSelected = false;
|
|
326
|
+
this.onDataReady();
|
|
327
|
+
resolver();
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
return promise;
|
|
331
|
+
}
|
|
332
|
+
doRenderCommit(commit) {
|
|
333
|
+
let expansionToggleIcon = (0, browser_1.codicon)('chevron-right');
|
|
334
|
+
if (commit && commit.expanded) {
|
|
335
|
+
expansionToggleIcon = (0, browser_1.codicon)('chevron-down');
|
|
336
|
+
}
|
|
337
|
+
return React.createElement("div", { className: `containerHead${commit.selected ? ' ' + browser_1.SELECTED_CLASS : ''}`, onClick: e => {
|
|
338
|
+
if (commit.selected && !this.singleFileMode) {
|
|
339
|
+
this.addOrRemoveFileChangeNodes(commit);
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
this.selectNode(commit);
|
|
343
|
+
}
|
|
344
|
+
e.preventDefault();
|
|
345
|
+
}, onDoubleClick: e => {
|
|
346
|
+
if (this.singleFileMode && commit.fileChangeNodes.length > 0) {
|
|
347
|
+
this.openFile(commit.fileChangeNodes[0].fileChange);
|
|
348
|
+
}
|
|
349
|
+
e.preventDefault();
|
|
350
|
+
} },
|
|
351
|
+
React.createElement("div", { className: 'headContent' },
|
|
352
|
+
React.createElement("div", { className: 'image-container' },
|
|
353
|
+
React.createElement("img", { className: 'gravatar', src: commit.authorAvatar })),
|
|
354
|
+
React.createElement("div", { className: `headLabelContainer${this.singleFileMode ? ' singleFileMode' : ''}` },
|
|
355
|
+
React.createElement("div", { className: 'headLabel noWrapInfo noselect' }, commit.commitDetails.summary),
|
|
356
|
+
React.createElement("div", { className: 'commitTime noWrapInfo noselect' }, commit.commitDetails.authorDateRelative + ' by ' + commit.commitDetails.authorName)),
|
|
357
|
+
React.createElement("div", { className: `${(0, browser_1.codicon)('eye')} detailButton`, onClick: () => this.openDetailWidget(commit) }),
|
|
358
|
+
!this.singleFileMode && React.createElement("div", { className: 'expansionToggle noselect' },
|
|
359
|
+
React.createElement("div", { className: 'toggle' },
|
|
360
|
+
React.createElement("div", { className: 'number' }, commit.commitDetails.fileChanges.length.toString()),
|
|
361
|
+
React.createElement("div", { className: 'icon ' + expansionToggleIcon })))));
|
|
362
|
+
}
|
|
363
|
+
async openDetailWidget(commitNode) {
|
|
364
|
+
const options = Object.assign(Object.assign({}, commitNode.commitDetails.commitDetailOptions), { mode: 'reveal' });
|
|
365
|
+
(0, browser_1.open)(this.openerService, commitNode.commitDetails.commitDetailUri, options);
|
|
366
|
+
}
|
|
367
|
+
doRenderFileChangeList(fileChange) {
|
|
368
|
+
const fileChangeElement = this.renderScmItem(fileChange, fileChange.commitId);
|
|
369
|
+
return fileChangeElement;
|
|
370
|
+
}
|
|
371
|
+
renderScmItem(change, commitSha) {
|
|
372
|
+
return React.createElement(scm_navigable_list_widget_1.ScmItemComponent, Object.assign({ key: change.fileChange.uri.toString() }, {
|
|
373
|
+
labelProvider: this.labelProvider,
|
|
374
|
+
scmLabelProvider: this.scmLabelProvider,
|
|
375
|
+
change,
|
|
376
|
+
revealChange: () => this.openFile(change.fileChange),
|
|
377
|
+
selectNode: () => this.selectNode(change)
|
|
378
|
+
}));
|
|
379
|
+
}
|
|
380
|
+
navigateLeft() {
|
|
381
|
+
const selected = this.getSelected();
|
|
382
|
+
if (selected && this.status.state === 'ready') {
|
|
383
|
+
if (scm_history_constants_1.ScmCommitNode.is(selected)) {
|
|
384
|
+
const idx = this.status.commits.findIndex(c => c.commitDetails.id === selected.commitDetails.id);
|
|
385
|
+
if (selected.expanded) {
|
|
386
|
+
this.addOrRemoveFileChangeNodes(selected);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
if (idx > 0) {
|
|
390
|
+
this.selectNode(this.status.commits[idx - 1]);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
else if (scm_file_change_node_1.ScmFileChangeNode.is(selected)) {
|
|
395
|
+
const idx = this.status.commits.findIndex(c => c.commitDetails.id === selected.commitId);
|
|
396
|
+
this.selectNode(this.status.commits[idx]);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
this.update();
|
|
400
|
+
}
|
|
401
|
+
navigateRight() {
|
|
402
|
+
const selected = this.getSelected();
|
|
403
|
+
if (selected) {
|
|
404
|
+
if (scm_history_constants_1.ScmCommitNode.is(selected) && !selected.expanded && !this.singleFileMode) {
|
|
405
|
+
this.addOrRemoveFileChangeNodes(selected);
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
this.selectNextNode();
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
this.update();
|
|
412
|
+
}
|
|
413
|
+
handleListEnter() {
|
|
414
|
+
const selected = this.getSelected();
|
|
415
|
+
if (selected) {
|
|
416
|
+
if (scm_history_constants_1.ScmCommitNode.is(selected)) {
|
|
417
|
+
if (this.singleFileMode) {
|
|
418
|
+
this.openFile(selected.fileChangeNodes[0].fileChange);
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
this.openDetailWidget(selected);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
else if (scm_file_change_node_1.ScmFileChangeNode.is(selected)) {
|
|
425
|
+
this.openFile(selected.fileChange);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
this.update();
|
|
429
|
+
}
|
|
430
|
+
openFile(change) {
|
|
431
|
+
const uriToOpen = change.getUriToOpen();
|
|
432
|
+
(0, browser_1.open)(this.openerService, uriToOpen, { mode: 'reveal' });
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
__decorate([
|
|
436
|
+
(0, inversify_1.postConstruct)(),
|
|
437
|
+
__metadata("design:type", Function),
|
|
438
|
+
__metadata("design:paramtypes", []),
|
|
439
|
+
__metadata("design:returntype", void 0)
|
|
440
|
+
], ScmHistoryWidget.prototype, "init", null);
|
|
441
|
+
ScmHistoryWidget = __decorate([
|
|
442
|
+
(0, inversify_1.injectable)(),
|
|
443
|
+
__param(0, (0, inversify_1.inject)(browser_1.OpenerService)),
|
|
444
|
+
__param(1, (0, inversify_1.inject)(browser_1.ApplicationShell)),
|
|
445
|
+
__param(2, (0, inversify_1.inject)(file_service_1.FileService)),
|
|
446
|
+
__param(3, (0, inversify_1.inject)(scm_avatar_service_1.ScmAvatarService)),
|
|
447
|
+
__param(4, (0, inversify_1.inject)(browser_1.WidgetManager)),
|
|
448
|
+
__metadata("design:paramtypes", [Object, browser_1.ApplicationShell,
|
|
449
|
+
file_service_1.FileService,
|
|
450
|
+
scm_avatar_service_1.ScmAvatarService,
|
|
451
|
+
browser_1.WidgetManager])
|
|
452
|
+
], ScmHistoryWidget);
|
|
453
|
+
exports.ScmHistoryWidget = ScmHistoryWidget;
|
|
454
|
+
class ScmHistoryList extends React.Component {
|
|
455
|
+
constructor() {
|
|
456
|
+
super(...arguments);
|
|
457
|
+
this.checkIfRowIsLoaded = (opts) => this.doCheckIfRowIsLoaded(opts);
|
|
458
|
+
}
|
|
459
|
+
doCheckIfRowIsLoaded(opts) {
|
|
460
|
+
const row = this.props.rows[opts.index];
|
|
461
|
+
return !!row;
|
|
462
|
+
}
|
|
463
|
+
render() {
|
|
464
|
+
const { hasMoreRows, loadMoreRows, rows } = this.props;
|
|
465
|
+
return React.createElement(react_virtuoso_1.Virtuoso, { ref: list => this.list = (list || undefined), data: rows, itemContent: index => this.renderRow(index), endReached: hasMoreRows ? loadMoreRows : undefined, overscan: 500, style: {
|
|
466
|
+
overflowX: 'hidden'
|
|
467
|
+
} });
|
|
468
|
+
}
|
|
469
|
+
renderRow(index) {
|
|
470
|
+
if (this.checkIfRowIsLoaded({ index })) {
|
|
471
|
+
const row = this.props.rows[index];
|
|
472
|
+
if (scm_history_constants_1.ScmCommitNode.is(row)) {
|
|
473
|
+
const head = this.props.renderCommit(row);
|
|
474
|
+
return React.createElement("div", { className: `commitListElement${index === 0 ? ' first' : ''}` }, head);
|
|
475
|
+
}
|
|
476
|
+
else if (scm_file_change_node_1.ScmFileChangeNode.is(row)) {
|
|
477
|
+
return React.createElement("div", { className: 'fileChangeListElement' }, this.props.renderFileChangeList(row));
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
return React.createElement("div", { className: `commitListElement${index === 0 ? ' first' : ''}` },
|
|
482
|
+
React.createElement("span", { className: `${(0, browser_1.codicon)('loading')} theia-animation-spin` }));
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
;
|
|
486
|
+
}
|
|
487
|
+
exports.ScmHistoryList = ScmHistoryList;
|
|
488
488
|
//# sourceMappingURL=scm-history-widget.js.map
|