Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
INT-2373 do not initialize the VSCE if there is no active workspace (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
grzpab authored Jan 3, 2024
1 parent d03e9ff commit 490cfd3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
7 changes: 7 additions & 0 deletions intuita-webview/src/main/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,10 @@
height: 4em;
width: 100%;
}

.warning {
font-size: var(--type-ramp-base-font-size);
line-height: var(--type-ramp-base-line-height);
display: block;
color: var(--foreground);
}
17 changes: 15 additions & 2 deletions intuita-webview/src/main/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ function App() {
}, []);

useEffect(() => {
if (mainWebviewViewProps.toaster === null) {
if (
mainWebviewViewProps === null ||
mainWebviewViewProps.toaster === null
) {
return;
}

Expand Down Expand Up @@ -122,7 +125,7 @@ function App() {
kind: 'webview.main.setToaster',
value: null,
});
}, [mainWebviewViewProps.toaster]);
}, [mainWebviewViewProps, mainWebviewViewProps?.toaster]);

const handlePanelTabClick = (id: ActiveTabId) => {
vscode.postMessage({
Expand All @@ -131,6 +134,16 @@ function App() {
});
};

if (mainWebviewViewProps === null) {
return (
<main className="App" ref={ref}>
<p className="warning">
Open a workspace folder to use the Intuita VSCode Extension.
</p>
</main>
);
}

return (
<main className="App" ref={ref}>
<VSCodePanels
Expand Down
3 changes: 2 additions & 1 deletion src/components/webview/MainProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ export class MainViewProvider implements WebviewViewProvider {
}

if (
prevProps.activeTabId !== nextProps.activeTabId &&
nextProps !== null &&
prevProps?.activeTabId !== nextProps.activeTabId &&
nextProps.activeTabId === 'codemodRuns' &&
!nextProps.clearingInProgress
) {
Expand Down
4 changes: 4 additions & 0 deletions src/selectors/selectMainWebviewViewProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export const selectMainWebviewViewProps = (
autocompleteItems: ReadonlyArray<string>,
executionQueue: ReadonlyArray<CodemodHash>,
) => {
if (rootUri === null) {
return null;
}

if (state.activeTabId === 'codemods') {
return {
activeTabId: state.activeTabId,
Expand Down

0 comments on commit 490cfd3

Please sign in to comment.