1.8 KB61 lines
Blame
1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8import App from 'isl/src/App';
9import {getLatestOperationInfo, onOperationExited} from 'isl/src/operationsState';
10import {registerDisposable} from 'isl/src/utils';
11import ReactDOM from 'react-dom/client';
12import serverAPI from '../../isl/src/ClientToServerAPI';
13import {Internal} from './Internal';
14
15// start state side effect fetches
16import './state';
17
18import './vscode-styles.css';
19
20const PHABRICATOR_DIFF_ID_REGEX = /D([1-9][0-9]{5,})/im;
21
22registerDisposable(
23 serverAPI,
24 onOperationExited((progress, operation) => {
25 if (progress.exitCode !== 0) {
26 return; // don't show survey if submit failed
27 }
28 const isJfSubmitOperation = Internal.isJfSubmitOperation;
29 if (!isJfSubmitOperation || !isJfSubmitOperation(operation)) {
30 return; // only show survey for submits
31 }
32
33 // get latest operation
34 const info = getLatestOperationInfo(operation);
35
36 if (info == null || info.commandOutput == null) {
37 return;
38 }
39
40 // phabricator url is in the last line of the commandOutput
41 const message = info.commandOutput[info.commandOutput.length - 1];
42
43 const onCommitFormSubmit = Internal.onCommitFormSubmit;
44
45 const match = PHABRICATOR_DIFF_ID_REGEX.exec(message);
46 if (onCommitFormSubmit !== undefined) {
47 if (match && match[0]) {
48 onCommitFormSubmit(match[0]);
49 } else {
50 onCommitFormSubmit();
51 }
52 }
53 }),
54);
55
56window.addEventListener('load', () => {
57 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
58 const root = ReactDOM.createRoot(document.getElementById('root')!);
59 root.render(<App />);
60});
61