addons/vscode/webview/islWebviewEntry.tsxblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import App from 'isl/src/App';
b69ab319import {getLatestOperationInfo, onOperationExited} from 'isl/src/operationsState';
b69ab3110import {registerDisposable} from 'isl/src/utils';
b69ab3111import ReactDOM from 'react-dom/client';
b69ab3112import serverAPI from '../../isl/src/ClientToServerAPI';
b69ab3113import {Internal} from './Internal';
b69ab3114
b69ab3115// start state side effect fetches
b69ab3116import './state';
b69ab3117
b69ab3118import './vscode-styles.css';
b69ab3119
b69ab3120const PHABRICATOR_DIFF_ID_REGEX = /D([1-9][0-9]{5,})/im;
b69ab3121
b69ab3122registerDisposable(
b69ab3123 serverAPI,
b69ab3124 onOperationExited((progress, operation) => {
b69ab3125 if (progress.exitCode !== 0) {
b69ab3126 return; // don't show survey if submit failed
b69ab3127 }
b69ab3128 const isJfSubmitOperation = Internal.isJfSubmitOperation;
b69ab3129 if (!isJfSubmitOperation || !isJfSubmitOperation(operation)) {
b69ab3130 return; // only show survey for submits
b69ab3131 }
b69ab3132
b69ab3133 // get latest operation
b69ab3134 const info = getLatestOperationInfo(operation);
b69ab3135
b69ab3136 if (info == null || info.commandOutput == null) {
b69ab3137 return;
b69ab3138 }
b69ab3139
b69ab3140 // phabricator url is in the last line of the commandOutput
b69ab3141 const message = info.commandOutput[info.commandOutput.length - 1];
b69ab3142
b69ab3143 const onCommitFormSubmit = Internal.onCommitFormSubmit;
b69ab3144
b69ab3145 const match = PHABRICATOR_DIFF_ID_REGEX.exec(message);
b69ab3146 if (onCommitFormSubmit !== undefined) {
b69ab3147 if (match && match[0]) {
b69ab3148 onCommitFormSubmit(match[0]);
b69ab3149 } else {
b69ab3150 onCommitFormSubmit();
b69ab3151 }
b69ab3152 }
b69ab3153 }),
b69ab3154);
b69ab3155
b69ab3156window.addEventListener('load', () => {
b69ab3157 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
b69ab3158 const root = ReactDOM.createRoot(document.getElementById('root')!);
b69ab3159 root.render(<App />);
b69ab3160});