mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 09:35:38 -05:00
Another code layering (#4037)
* working on formatting * fixed basic lint errors; starting moving things to their appropriate location * formatting * update tslint to match the version of vscode we have * remove unused code * work in progress fixing layering * formatting * moved connection management service to platform * formatting * add missing file * moving more servies * formatting * moving more services * formatting * wip * moving more services * formatting * move css file * add missing svgs * moved the rest of services * formatting * changing around some references * formatting * revert tslint * revert some changes that brake things * formatting * fix tests * fix testzx * fix tests * fix tests * fix compile issue
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const IFileBrowserDialogController = createDecorator<IFileBrowserDialogController>('fileBrowserDialogService');
|
||||
export interface IFileBrowserDialogController {
|
||||
_serviceBrand: any;
|
||||
/**
|
||||
* Show file browser dialog
|
||||
*/
|
||||
showDialog(ownerUri: string,
|
||||
expandPath: string,
|
||||
fileFilters: { label: string, filters: string[] }[],
|
||||
fileValidationServiceType: string,
|
||||
isWide: boolean,
|
||||
handleOnOk: (path: string) => void): void;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import { FileNode } from 'sql/workbench/services/fileBrowser/common/fileNode';
|
||||
|
||||
/**
|
||||
* File tree info needed to render initially
|
||||
*/
|
||||
export class FileBrowserTree {
|
||||
public rootNode: FileNode;
|
||||
public selectedNode: FileNode;
|
||||
public expandedNodes: FileNode[];
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { IFileBrowserService } from 'sql/platform/fileBrowser/common/interfaces';
|
||||
import { localize } from 'vs/nls';
|
||||
|
||||
/**
|
||||
* View model for file browser dialog
|
||||
*/
|
||||
export class FileBrowserViewModel {
|
||||
private _ownerUri: string;
|
||||
private _expandPath: string;
|
||||
private _fileFilters: [{ label: string, filters: string[] }];
|
||||
private _fileValidationServiceType: string;
|
||||
public formattedFileFilters: string[];
|
||||
|
||||
constructor( @IFileBrowserService private _fileBrowserService: IFileBrowserService) {
|
||||
}
|
||||
|
||||
public onAddFileTree(onAddFileTreeCallback) {
|
||||
this._fileBrowserService.onAddFileTree(args => onAddFileTreeCallback(args));
|
||||
}
|
||||
|
||||
public onPathValidate(onPathValidateCallback) {
|
||||
this._fileBrowserService.onPathValidate(args => onPathValidateCallback(args));
|
||||
}
|
||||
|
||||
public initialize(ownerUri: string,
|
||||
expandPath: string,
|
||||
fileFilters: [{ label: string, filters: string[] }],
|
||||
fileValidationServiceType: string,
|
||||
) {
|
||||
this._ownerUri = ownerUri;
|
||||
this._expandPath = expandPath;
|
||||
this._fileValidationServiceType = fileValidationServiceType;
|
||||
|
||||
if (!fileFilters) {
|
||||
this._fileFilters = [{ label: localize('allFiles', 'All files'), filters: ['*'] }];
|
||||
} else {
|
||||
this._fileFilters = fileFilters;
|
||||
}
|
||||
this.formattedFileFilters = [];
|
||||
for (var i = 0; i < this._fileFilters.length; i++) {
|
||||
var filterStr = this._fileFilters[i].label + '(' + this._fileFilters[i].filters.join(';') + ')';
|
||||
this.formattedFileFilters.push(filterStr);
|
||||
}
|
||||
}
|
||||
|
||||
public validateFilePaths(selectedFiles: string[]) {
|
||||
this._fileBrowserService.validateFilePaths(this._ownerUri, this._fileValidationServiceType, selectedFiles);
|
||||
}
|
||||
|
||||
public openFileBrowser(filterIndex: number, changeFilter: boolean) {
|
||||
if (this._fileFilters[filterIndex]) {
|
||||
this._fileBrowserService.openFileBrowser(this._ownerUri, this._expandPath, this._fileFilters[filterIndex].filters, changeFilter);
|
||||
}
|
||||
}
|
||||
|
||||
public closeFileBrowser() {
|
||||
this._fileBrowserService.closeFileBrowser(this._ownerUri);
|
||||
}
|
||||
}
|
||||
72
src/sql/workbench/services/fileBrowser/common/fileNode.ts
Normal file
72
src/sql/workbench/services/fileBrowser/common/fileNode.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
|
||||
/**
|
||||
* File/folder node in file browser
|
||||
* FileTreeNode is converted to this FileNode for UI interactions
|
||||
*/
|
||||
export class FileNode {
|
||||
/**
|
||||
* Node id
|
||||
*/
|
||||
public id: string;
|
||||
|
||||
/**
|
||||
* Connection uri
|
||||
*/
|
||||
public ownerUri: string;
|
||||
|
||||
/**
|
||||
* File or folder name
|
||||
*/
|
||||
public name: string;
|
||||
|
||||
/**
|
||||
* Full path of file or folder
|
||||
*/
|
||||
public fullPath: string;
|
||||
|
||||
/**
|
||||
* Parent node
|
||||
*/
|
||||
public parent: FileNode;
|
||||
|
||||
/**
|
||||
* Children nodes
|
||||
*/
|
||||
public children: FileNode[];
|
||||
|
||||
/**
|
||||
* Is the node expanded
|
||||
*/
|
||||
public isExpanded: boolean;
|
||||
|
||||
/**
|
||||
* Is the node file or folder
|
||||
*/
|
||||
public isFile: boolean;
|
||||
|
||||
/**
|
||||
* Does this node have children
|
||||
*/
|
||||
public hasChildren: boolean;
|
||||
|
||||
constructor(id: string, name: string, fullPath: string, isFile: boolean, isExpanded: boolean, ownerUri: string, parent: FileNode) {
|
||||
if (id) {
|
||||
this.id = id;
|
||||
} else {
|
||||
this.id = generateUuid();
|
||||
}
|
||||
|
||||
this.name = name;
|
||||
this.fullPath = fullPath;
|
||||
this.isFile = isFile;
|
||||
this.ownerUri = ownerUri;
|
||||
this.isExpanded = isExpanded;
|
||||
this.parent = parent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* List of services that provide file validation callback to file browser service
|
||||
*/
|
||||
|
||||
export const backup: string = 'Backup';
|
||||
export const restore: string = 'Restore';
|
||||
Reference in New Issue
Block a user