Skip to content

Commit 9961fa6

Browse files
authored
Support update Maven profiles (#1331)
Signed-off-by: Sheng Chen <[email protected]>
1 parent 1790bd0 commit 9961fa6

23 files changed

+270
-43
lines changed

src/project-settings/assets/classpath/features/ClasspathConfigurationView.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import Output from "./components/Output";
88
import Sources from "./components/Sources";
99
import Libraries from "./components/Libraries";
1010
import Exception from "./components/Exception";
11-
import { ClasspathViewException, ProjectInfo } from "../../../handlers/classpath/types";
12-
import { catchException, initializeProjectsData, listVmInstalls, loadClasspath, updateActiveTab } from "./classpathConfigurationViewSlice";
11+
import { ClasspathViewException, ProjectInfo } from "../../../types";
12+
import { catchException, listVmInstalls, loadClasspath, updateActiveTab } from "./classpathConfigurationViewSlice";
1313
import JdkRuntime from "./components/JdkRuntime";
1414
import { ClasspathRequest } from "../../vscode/utils";
1515
import { VSCodePanelTab, VSCodePanelView, VSCodePanels, VSCodeProgressRing } from "@vscode/webview-ui-toolkit/react";
1616
import { ProjectType } from "../../../../utils/webview";
1717
import UnmanagedFolderSources from "./components/UnmanagedFolderSources";
1818
import Hint from "./components/Hint";
1919
import "../style.scss";
20-
import { listProjects, setProjectType } from "../../mainpage/features/commonSlice";
20+
import { setProjectType } from "../../mainpage/features/commonSlice";
2121

2222
const ClasspathConfigurationView = (): JSX.Element => {
2323
const activeTab: string = useSelector((state: any) => state.classpathConfig.ui.activeTab);
@@ -62,10 +62,7 @@ const ClasspathConfigurationView = (): JSX.Element => {
6262

6363
const onMessage = (event: any) => {
6464
const { data } = event;
65-
if (data.command === "classpath.onDidListProjects") {
66-
dispatch(initializeProjectsData({ projectsNum: data.projectInfo?.length }));
67-
dispatch(listProjects(data.projectInfo));
68-
} else if (data.command === "classpath.onDidListVmInstalls") {
65+
if (data.command === "classpath.onDidListVmInstalls") {
6966
dispatch(listVmInstalls(data.vmInstalls))
7067
} else if (data.command === "classpath.onDidLoadProjectClasspath") {
7168
dispatch(setProjectType({
@@ -87,7 +84,6 @@ const ClasspathConfigurationView = (): JSX.Element => {
8784
// redux store is empty. When switching between tabs, the
8885
// state will be preserved.
8986
ClasspathRequest.onWillListProjects();
90-
ClasspathRequest.onWillListVmInstalls();
9187
}
9288
return () => {
9389
window.removeEventListener("message", onMessage);

src/project-settings/assets/classpath/features/classpathConfigurationViewSlice.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4-
import { createSlice, current } from "@reduxjs/toolkit";
4+
import { createSlice } from "@reduxjs/toolkit";
55
import _ from "lodash";
6-
import { ClasspathEntry } from "../../../handlers/classpath/types";
6+
import { ClasspathEntry } from "../../../types";
77

88
export const classpathConfigurationViewSlice = createSlice({
99
name: "classpathConfig",
@@ -25,7 +25,7 @@ export const classpathConfigurationViewSlice = createSlice({
2525
updateActiveTab: (state, action) => {
2626
state.ui.activeTab = action.payload;
2727
},
28-
initializeProjectsData: (state, action) => {
28+
initializeClasspathData: (state, action) => {
2929
const projectNum = action.payload.projectsNum;
3030
state.data.activeVmInstallPath = Array(projectNum).fill("");
3131
state.data.sources = Array(projectNum).fill([]);
@@ -40,13 +40,13 @@ export const classpathConfigurationViewSlice = createSlice({
4040
state.data.output[activeProjectIndex] = action.payload.output;
4141
state.data.activeVmInstallPath[activeProjectIndex] = action.payload.activeVmInstallPath;
4242
// Only update the array when they have different elements.
43-
const currentSources = _.sortBy(current(state.data.sources), ["path", "output"]); // TODO: activeProjectIndex needed?
43+
const currentSources = _.sortBy(state.data.sources[activeProjectIndex], ["path", "output"]);
4444
const newSources = _.sortBy(action.payload.sources, ["path", "output"]);
4545
if (!_.isEqual(currentSources, newSources)) {
4646
state.data.sources[activeProjectIndex] = action.payload.sources;
4747
}
4848

49-
const currentLibs = _.sortBy(current(state.data.libraries), ["path"]);
49+
const currentLibs = _.sortBy(state.data.libraries[activeProjectIndex], ["path"]);
5050
const newLibs = _.sortBy(action.payload.libraries, ["path"]);
5151
if (!_.isEqual(currentLibs, newLibs)) {
5252
state.data.libraries[activeProjectIndex] = action.payload.libraries;
@@ -97,7 +97,7 @@ function isDifferentStringArray(a1: string[], a2: string[]): boolean {
9797

9898
export const {
9999
updateActiveTab,
100-
initializeProjectsData,
100+
initializeClasspathData,
101101
listVmInstalls,
102102
loadClasspath,
103103
updateSource,

src/project-settings/assets/classpath/features/components/Exception.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import React from "react";
55
import { useSelector } from "react-redux";
66
import { encodeCommandUriWithTelemetry, supportedByNavigator } from "../../../../../utils/webview";
7-
import { ClasspathViewException } from "../../../../handlers/classpath/types";
7+
import { ClasspathViewException } from "../../../../types";
88
import { WEBVIEW_ID } from "../../utils";
99

1010
const Exception = (): JSX.Element | null => {

src/project-settings/assets/classpath/features/components/Hint.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { VSCodeLink} from "@vscode/webview-ui-toolkit/react";
55
import React, { useEffect } from "react";
6-
import { ProjectInfo } from "../../../../handlers/classpath/types";
6+
import { ProjectInfo } from "../../../../types";
77
import { useSelector } from "react-redux";
88
import { ProjectType } from "../../../../../utils/webview";
99
import { updateMaxHeight } from "../../utils";

src/project-settings/assets/classpath/features/components/JdkRuntime.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React, { Dispatch, useEffect, useState } from "react";
55
import { ClasspathRequest, CommonRequest } from "../../../vscode/utils";
66
import { VSCodeDivider, VSCodeDropdown, VSCodeOption, } from "@vscode/webview-ui-toolkit/react";
77
import { useDispatch, useSelector } from "react-redux";
8-
import { VmInstall } from "../../../../handlers/classpath/types";
8+
import { VmInstall } from "../../../../types";
99
import { setJdks } from "../classpathConfigurationViewSlice";
1010

1111
const JdkRuntime = (): JSX.Element => {
@@ -97,6 +97,9 @@ const JdkRuntime = (): JSX.Element => {
9797
// to change its style.
9898
document.querySelector("#jdk-dropdown")?.shadowRoot
9999
?.querySelector(".listbox")?.setAttribute("style", "max-height: initial;");
100+
if (vmInstalls.length === 0) {
101+
ClasspathRequest.onWillListVmInstalls();
102+
}
100103
return () => window.removeEventListener("message", onDidChangeJdk);
101104
}, []);
102105

src/project-settings/assets/classpath/features/components/Libraries.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useSelector, useDispatch } from "react-redux";
77
import { removeReferencedLibrary, addLibraries } from "../classpathConfigurationViewSlice";
88
import { ClasspathRequest } from "../../../vscode/utils";
99
import { VSCodeButton, VSCodeDataGrid, VSCodeDataGridCell, VSCodeDataGridRow, VSCodeDivider } from "@vscode/webview-ui-toolkit/react";
10-
import { ClasspathEntry, ClasspathEntryKind } from "../../../../handlers/classpath/types";
10+
import { ClasspathEntry, ClasspathEntryKind } from "../../../../types";
1111

1212
const Libraries = (): JSX.Element => {
1313

src/project-settings/assets/classpath/features/components/Sources.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Dispatch } from "@reduxjs/toolkit";
77
import { updateSource } from "../classpathConfigurationViewSlice";
88
import { ClasspathRequest } from "../../../vscode/utils";
99
import { VSCodeButton, VSCodeDataGrid, VSCodeDataGridCell, VSCodeDataGridRow, VSCodeDivider, VSCodeTextField } from "@vscode/webview-ui-toolkit/react";
10-
import { ClasspathEntry, ClasspathEntryKind } from "../../../../handlers/classpath/types";
10+
import { ClasspathEntry, ClasspathEntryKind } from "../../../../types";
1111

1212
const Sources = (): JSX.Element => {
1313

src/project-settings/assets/classpath/features/components/UnmanagedFolderSources.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { updateSource } from "../classpathConfigurationViewSlice";
88
import { ClasspathRequest } from "../../../vscode/utils";
99
import { ProjectType } from "../../../../../utils/webview";
1010
import { VSCodeButton, VSCodeDataGrid, VSCodeDataGridCell, VSCodeDataGridRow, VSCodeDivider } from "@vscode/webview-ui-toolkit/react";
11-
import { ClasspathEntry } from "../../../../handlers/classpath/types";
11+
import { ClasspathEntry } from "../../../../types";
1212

1313
const UnmanagedFolderSources = (): JSX.Element => {
1414

src/project-settings/assets/classpath/style.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@
112112
}
113113
}
114114

115+
.setting-section-subtitle {
116+
display: flex;
117+
align-items: baseline;
118+
}
119+
115120
.setting-section-text {
116121
width: 100%;
117122
max-width: 420px;

src/project-settings/assets/mainpage/features/ProjectSettingView.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
import React, { Dispatch } from "react";
55
import { useDispatch, useSelector } from "react-redux";
66
import ClasspathConfigurationView from "../../classpath/features/ClasspathConfigurationView";
7-
import { updateActiveTab } from "../../classpath/features/classpathConfigurationViewSlice";
7+
import { initializeClasspathData, updateActiveTab } from "../../classpath/features/classpathConfigurationViewSlice";
88
import "../style.scss";
9-
import { updateActiveSection } from "./commonSlice";
9+
import { listProjects, updateActiveSection } from "./commonSlice";
1010
import ProjectSelector from "./component/ProjectSelector";
1111
import { VSCodeDivider } from "@vscode/webview-ui-toolkit/react";
1212
import Footer from "./component/Footer";
1313
import SideBar from "./component/SideBar";
14+
import MavenConfigurationView from "../../maven/features/MavenConfigurationView";
15+
import { SectionId } from "../../../types";
16+
import { initializeMavenData } from "../../maven/features/mavenConfigurationViewSlice";
1417

1518
const ProjectSettingView = (): JSX.Element => {
1619
const activeSection: string = useSelector((state: any) => state.commonConfig.ui.activeSection);
@@ -24,8 +27,10 @@ const ProjectSettingView = (): JSX.Element => {
2427
}, []);
2528

2629
const getSectionContent = () => {
27-
if (activeSection === "classpath") {
30+
if (activeSection === SectionId.Classpath) {
2831
return <ClasspathConfigurationView />;
32+
} else if (activeSection === SectionId.Maven) {
33+
return <MavenConfigurationView />;
2934
}
3035

3136
return null;
@@ -38,7 +43,7 @@ const ProjectSettingView = (): JSX.Element => {
3843
dispatch(updateActiveSection(routes[0]));
3944
if (routes.length > 1) {
4045
switch (routes[0]) {
41-
case "classpath":
46+
case SectionId.Classpath:
4247
// TODO: sometimes when directly trigger 'Configure Java Runtime', the tab won't
4348
// focus to the JDK part, need to investigate
4449
dispatch(updateActiveTab(routes[1]));
@@ -47,6 +52,10 @@ const ProjectSettingView = (): JSX.Element => {
4752
break;
4853
}
4954
}
55+
} else if (data.command === "main.onDidListProjects") {
56+
dispatch(initializeClasspathData({ projectsNum: data.projectInfo?.length }));
57+
dispatch(initializeMavenData({ projectsNum: data.projectInfo?.length }));
58+
dispatch(listProjects(data.projectInfo));
5059
}
5160
}
5261

0 commit comments

Comments
 (0)