Load all data workspace projects directly from workspace (#15921)

* Load all projects directly from workspace

* fixes

* Remove relativity and fix tests

* fix compile

* PR comments

* remove unused

* distro
This commit is contained in:
Charles Gagnon
2021-06-30 10:58:34 -07:00
committed by GitHub
parent 66c1fdc457
commit 7ce791d826
30 changed files with 124 additions and 1113 deletions

View File

@@ -13,13 +13,7 @@ export const UnknownProjectsError = (projectFiles: string[]): string => { return
export const SelectProjectFileActionName = localize('SelectProjectFileActionName', "Select");
export const AllProjectTypes = localize('AllProjectTypes', "All Project Types");
export const ProviderNotFoundForProjectTypeError = (projectType: string): string => { return localize('UnknownProjectTypeError', "No provider was found for project type with id: '{0}'", projectType); };
export const WorkspaceRequiredMessage = localize('dataworkspace.workspaceRequiredMessage', "A workspace is required in order to use the project feature.");
export const OpenWorkspace = localize('dataworkspace.openWorkspace', "Open Workspace…");
export const CreateWorkspaceConfirmation = localize('dataworkspace.createWorkspaceConfirmation', "A workspace will be created and opened in order to open the project. Azure Data Studio will restart and if there is a folder currently open, it will be closed.");
export const EnterWorkspaceConfirmation = localize('dataworkspace.enterWorkspaceConfirmation', "To open this workspace, Azure Data Studio will restart. If there is a workspace or folder currently open, it will be closed.");
export const WorkspaceContainsNotAddedProjects = localize('dataworkspace.workspaceContainsNotAddedProjects', "The current workspace contains one or more projects that have not been added to the workspace. Use the 'Open existing' dialog to add projects to the projects pane.");
export const LaunchOpenExisitingDialog = localize('dataworkspace.launchOpenExistingDialog', "Launch 'Open Existing' Dialog");
export const DoNotAskAgain = localize('dataworkspace.doNotAskAgain', "Don't Ask Again");
export const RestartConfirmation = localize('dataworkspace.restartConfirmation', "Azure Data Studio needs to be restarted for the project to be created and added to the workspace, do this now?");
export const ProjectsFailedToLoad = localize('dataworkspace.projectsFailedToLoad', "Some projects failed to load. To view more details, [open the developer console](command:workbench.action.toggleDevTools)");
export const fileDoesNotExist = (name: string): string => { return localize('fileDoesNotExist', "File '{0}' doesn't exist", name); };
export const projectNameNull = localize('projectNameNull', "Project name is null");
@@ -27,13 +21,8 @@ export const noPreviousData = (tableName: string): string => { return localize('
export const gitCloneMessage = (url: string): string => { return localize('gitCloneMessage', "Cloning git repository '{0}'...", url); };
export const gitCloneError = localize('gitCloneError', "Error during git clone. View git output for more details");
// config settings
export const projectsConfigurationKey = 'projects';
export const showNotAddedProjectsMessageKey = 'showNotAddedProjectsInWorkspacePrompt';
// UI
export const OkButtonText = localize('dataworkspace.ok', "OK");
export const CancelButtonText = localize('dataworkspace.cancel', "Cancel");
export const BrowseButtonText = localize('dataworkspace.browse', "Browse");
export const BrowseEllipsis = localize('dataworkspace.browseEllipsis', "Browse...");
export const OpenButtonText = localize('dataworkspace.open', "Open");
@@ -51,20 +40,14 @@ export const ProjectNamePlaceholder = localize('dataworkspace.projectNamePlaceho
export const EnterProjectName = localize('dataworkspace.enterProjectName', "Enter Project Name");
export const ProjectLocationTitle = localize('dataworkspace.projectLocationTitle', "Location");
export const ProjectLocationPlaceholder = localize('dataworkspace.projectLocationPlaceholder', "Select location to create project");
export const AddProjectToCurrentWorkspace = localize('dataworkspace.AddProjectToCurrentWorkspace', "This project will be added to the current workspace.");
export const NewWorkspaceWillBeCreated = localize('dataworkspace.NewWorkspaceWillBeCreated', "A workspace will be created for this project.");
export const WorkspaceLocationTitle = localize('dataworkspace.workspaceLocationTitle', "Workspace location");
export const ProjectParentDirectoryNotExistError = (location: string): string => { return localize('dataworkspace.projectParentDirectoryNotExistError', "The selected project location '{0}' does not exist or is not a directory.", location); };
export const ProjectDirectoryAlreadyExistError = (projectName: string, location: string): string => { return localize('dataworkspace.projectDirectoryAlreadyExistError', "There is already a directory named '{0}' in the selected location: '{1}'.", projectName, location); };
export const ProjectDirectoryAlreadyExistErrorShort = (projectName: string) => { return localize('dataworkspace.projectDirectoryAlreadyExistErrorShort', "Directory '{0}' already exists in the selected location, please choose another", projectName); };
export const WorkspaceFileInvalidError = (workspace: string): string => { return localize('dataworkspace.workspaceFileInvalidError', "The selected workspace file path '{0}' does not have the required file extension {1}.", workspace, WorkspaceFileExtension); };
export const WorkspaceParentDirectoryNotExistError = (location: string): string => { return localize('dataworkspace.workspaceParentDirectoryNotExistError', "The selected workspace location '{0}' does not exist or is not a directory.", location); };
export const WorkspaceFileAlreadyExistsError = (file: string): string => { return localize('dataworkspace.workspaceFileAlreadyExistsError', "The selected workspace file '{0}' already exists. To add the project to an existing workspace, use the Open Existing dialog to first open the workspace.", file); };
export const SelectProjectType = localize('dataworkspace.selectProjectType', "Select Project Type");
export const SelectProjectLocation = localize('dataworkspace.selectProjectLocation', "Select Project Location");
export const NameCannotBeEmpty = localize('dataworkspace.nameCannotBeEmpty', "Name cannot be empty");
//Open Existing Dialog
export const OpenExistingDialogTitle = localize('dataworkspace.openExistingDialogTitle', "Open existing");
export const OpenExistingDialogTitle = localize('dataworkspace.openExistingDialogTitle', "Open Existing Project");
export const FileNotExistError = (fileType: string, filePath: string): string => { return localize('dataworkspace.fileNotExistError', "The selected {0} file '{1}' does not exist or is not a file.", fileType, filePath); };
export const CloneParentDirectoryNotExistError = (location: string): string => { return localize('dataworkspace.cloneParentDirectoryNotExistError', "The selected clone path '{0}' does not exist or is not a directory.", location); };
export const Project = localize('dataworkspace.project', "Project");

View File

@@ -12,12 +12,12 @@ export class DataWorkspaceExtension implements IExtension {
constructor(private workspaceService: WorkspaceService) {
}
getProjectsInWorkspace(ext?: string): vscode.Uri[] {
getProjectsInWorkspace(ext?: string): Promise<vscode.Uri[]> {
return this.workspaceService.getProjectsInWorkspace(ext);
}
addProjectsToWorkspace(projectFiles: vscode.Uri[], workspaceFilePath?: vscode.Uri): Promise<void> {
return this.workspaceService.addProjectsToWorkspace(projectFiles, workspaceFilePath);
addProjectsToWorkspace(projectFiles: vscode.Uri[]): Promise<void> {
return this.workspaceService.addProjectsToWorkspace(projectFiles);
}
showProjectsView(): void {

View File

@@ -51,7 +51,7 @@ export interface IWorkspaceService {
/**
* Gets the project files in current workspace
*/
getProjectsInWorkspace(): vscode.Uri[];
getProjectsInWorkspace(): Promise<vscode.Uri[]>;
/**
* Gets the project provider by project file
@@ -66,28 +66,20 @@ export interface IWorkspaceService {
*/
addProjectsToWorkspace(projectFiles: vscode.Uri[], workspaceFilePath?: vscode.Uri): Promise<void>;
/**
* Remove the project from workspace
* @param projectFile The project file to be removed
*/
removeProject(projectFile: vscode.Uri): Promise<void>;
/**
* Creates a new project from workspace
* @param name The name of the project
* @param location The location of the project
* @param projectTypeId The project type id
* @param workspaceFile The workspace file to create if a workspace isn't currently open
*/
createProject(name: string, location: vscode.Uri, projectTypeId: string, workspaceFile?: vscode.Uri): Promise<vscode.Uri>;
createProject(name: string, location: vscode.Uri, projectTypeId: string): Promise<vscode.Uri>;
/**
* Clones git repository and adds projects to workspace
* @param url The url to clone from
* @param localClonePath local path to clone repository to
* @param workspaceFile workspace file to add the projects to
*/
gitCloneProject(url: string, localClonePath: string, workspaceFile: vscode.Uri): Promise<void>;
gitCloneProject(url: string, localClonePath: string): Promise<void>;
readonly isProjectProviderAvailable: boolean;
@@ -100,9 +92,4 @@ export interface IWorkspaceService {
* Verify that a workspace is open or if one isn't, ask user to pick whether a workspace should be automatically created
*/
validateWorkspace(): Promise<boolean>;
/**
* Shows confirmation message that the extension host will be restarted and current workspace/file will be closed. If confirmed, the specified workspace will be entered.
*/
enterWorkspace(workspaceFile: vscode.Uri): Promise<void>;
}

View File

@@ -4,9 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import AdsTelemetryReporter from '@microsoft/ads-extension-telemetry';
import * as path from 'path';
import * as utils from './utils';
import * as vscode from 'vscode';
const packageJson = require('../../package.json');
@@ -14,28 +12,6 @@ let packageInfo = utils.getPackageInfo(packageJson)!;
export const TelemetryReporter = new AdsTelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
export function calculateRelativity(projectPath: string, workspacePath?: string): string {
workspacePath = workspacePath ?? vscode.workspace.workspaceFile?.fsPath;
if (!workspacePath) {
return 'noWorkspace';
}
const relativePath = path.relative(path.dirname(projectPath), path.dirname(workspacePath));
if (relativePath.length === 0) { // no path difference
return 'sameFolder';
}
const pathParts = relativePath.split(path.sep);
if (pathParts.every(x => x === '..')) {
return 'directAncestor';
}
return 'other'; // sibling, cousin, descendant, etc.
}
export enum TelemetryViews {
WorkspaceTreePane = 'WorkspaceTreePane',

View File

@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import * as vscode from 'vscode';
import type * as azdataType from 'azdata';
export async function directoryExist(directoryPath: string): Promise<boolean> {
@@ -32,13 +31,6 @@ async function getFileStatus(path: string): Promise<fs.Stats | undefined> {
}
}
/**
* if the current workspace is untitled, the returned URI of vscode.workspace.workspaceFile will use the `untitled` scheme
*/
export function isCurrentWorkspaceUntitled(): boolean {
return !!vscode.workspace.workspaceFile && vscode.workspace.workspaceFile.scheme.toLowerCase() === 'untitled';
}
export interface IPackageInfo {
name: string;
version: string;