Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of project dir and new deployment selector for subdirectory support w/ select configuration support #1946

Open
wants to merge 5 commits into
base: sagerb-select-from-recursive-entrypoints
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ vendor

# VSCode Extension
extensions/vscode/out
test/sample-content

# webdriver.io service
test/vscode-ui/.wdio-vscode-service
extensions/vscode/dist
extensions/vscode/node_modules
extensions/vscode/webviews/homeView/node_modules
extensions/vscode/webviews/homeView/dist
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes have been replicated into different PR, should clean up after some merges. #1948

4 changes: 2 additions & 2 deletions extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
"category": "Posit Publisher"
},
{
"command": "posit.publisher.homeView.selectConfigForDeployment",
"command": "posit.publisher.homeView.showSelectConfigForDeployment",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change made to remove confusion (mostly my own).

"title": "Select Active Configuration For Deployment",
"category": "Posit Publisher"
},
Expand Down Expand Up @@ -460,7 +460,7 @@
],
"webview/context": [
{
"command": "posit.publisher.homeView.selectConfigForDeployment",
"command": "posit.publisher.homeView.showSelectConfigForDeployment",
"when": "webviewId == 'posit.publisher.homeView' && webviewSection == 'even-easier-deploy-more-menu-matching-configs'"
},
{
Expand Down
6 changes: 3 additions & 3 deletions extensions/vscode/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ const rPackagesCommands = {

const homeViewCommands = {
Refresh: "posit.publisher.homeView.refresh",
SelectConfigForDeployment:
"posit.publisher.homeView.selectConfigForDeployment",
ShowSelectConfigForDeployment:
"posit.publisher.homeView.showSelectConfigForDeployment",
CreateConfigForDeployment:
"posit.publisher.homeView.createConfigForDeployment",
SelectDeployment: "posit.publisher.homeView.selectDeployment",
Expand All @@ -110,7 +110,7 @@ const helpAndFeedbackCommands = {
} as const;

export const LocalState = {
LastSelectionState: "posit.publisher.homeView.lastSelectionState",
LastSelectionState: "posit.publisher.homeView.lastDeploymentSelectedState",
};

export const Commands = {
Expand Down
10 changes: 7 additions & 3 deletions extensions/vscode/src/multiStepInputs/selectConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export async function selectConfig(

const getConfigurations = new Promise<void>(async (resolve, reject) => {
try {
const response = await api.configurations.getAll();
const response = await api.configurations.getAll({
dir: activeDeployment.projectDir,
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only can select configurations from the same location as the deployment file.

let rawConfigs = response.data;
// Filter down configs to same content type as active deployment,
// but also allowing configs if active Deployment is a preDeployment
Expand Down Expand Up @@ -135,7 +137,9 @@ export async function selectConfig(
async (resolve, reject) => {
try {
const python = await getPythonInterpreterPath();
const inspectResponse = await api.configurations.inspect(python);
const inspectResponse = await api.configurations.inspect(python, {
dir: activeDeployment.projectDir,
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is selecting a config for an existing deployment, so we have to limit choices to the configs which are present in that particular project dir where the entrypoint was found.

inspectionResults = filterInspectionResultsToType(
inspectResponse.data,
activeDeployment.type,
Expand Down Expand Up @@ -428,7 +432,7 @@ export async function selectConfig(
) {
return (
config.configurationName ===
state.data.existingConfigurationName.label
state.data.existingConfigurationName.detail
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configuration name is in detail, not sure why old code was working.

);
}
return false;
Expand Down
11 changes: 0 additions & 11 deletions extensions/vscode/src/types/messages/hostToWebviewMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export enum HostToWebviewMessageType {
PUBLISH_FINISH_SUCCESS = "publishFinishSuccess",
PUBLISH_FINISH_FAILURE = "publishFinishFailure",
UPDATE_CONTENTRECORD_SELECTION = "updateContentRecordSelection",
UPDATE_CONFIG_SELECTION = "updateConfigSelection",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no longer update the config selection. The config is ALWAYS determined by what configuration name is present within the contentRecord, which is read from the file. If we want to change it, we patch the deployment, thus updating the file and causing a refresh, where the new configuration name is picked up.

SAVE_SELECTION = "saveSelection",
REFRESH_FILES_LISTS = "refreshFilesLists",
UPDATE_PYTHON_PACKAGES = "updatePythonPackages",
Expand All @@ -45,7 +44,6 @@ export type HostToWebviewMessage =
| PublishFinishSuccessMsg
| PublishFinishFailureMsg
| UpdateContentRecordSelectionMsg
| UpdateConfigSelectionMsg
| SaveSelectionMsg
| RefreshFilesListsMsg
| UpdatePythonPackages
Expand All @@ -60,7 +58,6 @@ export function isHostToWebviewMessage(msg: any): msg is HostToWebviewMessage {
msg.kind === HostToWebviewMessageType.PUBLISH_FINISH_SUCCESS ||
msg.kind === HostToWebviewMessageType.PUBLISH_FINISH_FAILURE ||
msg.kind === HostToWebviewMessageType.UPDATE_CONTENTRECORD_SELECTION ||
msg.kind === HostToWebviewMessageType.UPDATE_CONFIG_SELECTION ||
msg.kind === HostToWebviewMessageType.SAVE_SELECTION ||
msg.kind === HostToWebviewMessageType.REFRESH_FILES_LISTS ||
msg.kind === HostToWebviewMessageType.UPDATE_PYTHON_PACKAGES ||
Expand All @@ -80,7 +77,6 @@ export type RefreshConfigDataMsg = AnyHostToWebviewMessage<
{
configurations: Configuration[];
configurationsInError: ConfigurationError[];
deploymentSelected: DeploymentSelector | null;
}
>;
export type RefreshCredentialDataMsg = AnyHostToWebviewMessage<
Expand Down Expand Up @@ -108,13 +104,6 @@ export type UpdateContentRecordSelectionMsg = AnyHostToWebviewMessage<
saveSelection?: boolean;
}
>;
export type UpdateConfigSelectionMsg = AnyHostToWebviewMessage<
HostToWebviewMessageType.UPDATE_CONFIG_SELECTION,
{
config: Configuration;
saveSelection?: boolean;
}
>;
export type SaveSelectionMsg =
AnyHostToWebviewMessage<HostToWebviewMessageType.SAVE_SELECTION>;

Expand Down
10 changes: 5 additions & 5 deletions extensions/vscode/src/types/messages/webviewToHostMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export enum WebviewToHostMessageType {
INITIALIZING = "initializing",
EDIT_CONFIGURATION = "editConfiguration",
NEW_CONFIGURATION = "newConfiguration",
SELECT_CONFIGURATION = "selectConfiguration",
SHOW_SELECT_CONFIGURATION = "selectConfiguration",
NAVIGATE = "navigate",
SAVE_SELECTION_STATE = "saveSelectionState",
VSCODE_OPEN = "vsCodeOpen",
Expand Down Expand Up @@ -41,7 +41,7 @@ export type WebviewToHostMessage =
| InitializingMsg
| EditConfigurationMsg
| NewConfigurationMsg
| SelectConfigurationMsg
| ShowSelectConfigurationMsg
| NavigateMsg
| SaveSelectionStatedMsg
| VSCodeOpenMsg
Expand All @@ -65,7 +65,7 @@ export function isWebviewToHostMessage(msg: any): msg is WebviewToHostMessage {
msg.kind === WebviewToHostMessageType.INITIALIZING ||
msg.kind === WebviewToHostMessageType.NAVIGATE ||
msg.kind === WebviewToHostMessageType.NEW_CONFIGURATION ||
msg.kind === WebviewToHostMessageType.SELECT_CONFIGURATION ||
msg.kind === WebviewToHostMessageType.SHOW_SELECT_CONFIGURATION ||
msg.kind === WebviewToHostMessageType.SAVE_SELECTION_STATE ||
msg.kind === WebviewToHostMessageType.VSCODE_OPEN ||
msg.kind === WebviewToHostMessageType.INCLUDE_FILE ||
Expand Down Expand Up @@ -106,8 +106,8 @@ export type EditConfigurationMsg = AnyWebviewToHostMessage<
export type NewConfigurationMsg =
AnyWebviewToHostMessage<WebviewToHostMessageType.NEW_CONFIGURATION>;

export type SelectConfigurationMsg =
AnyWebviewToHostMessage<WebviewToHostMessageType.SELECT_CONFIGURATION>;
export type ShowSelectConfigurationMsg =
AnyWebviewToHostMessage<WebviewToHostMessageType.SHOW_SELECT_CONFIGURATION>;

export type NavigateMsg = AnyWebviewToHostMessage<
WebviewToHostMessageType.NAVIGATE,
Expand Down
4 changes: 1 addition & 3 deletions extensions/vscode/src/types/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import {
} from "../api";

export type DeploymentSelector = {
deploymentName: string;
projectDir: string;
configurationName?: string;
deploymentPath: string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deploymentPath value is guaranteed to be unique across the user's installation. This is set by the agent while reading the file system. Once we match up to the applicable contentRecord, we then use information within it to find the configuration and projectDir, thus switching back to a relative access which works for all users, even if sharing files.

};

export type HomeViewState = DeploymentSelector | null;
Expand Down
Loading