Initial work for Manage Access dialog (#7483)

* Add width and height properties to checkbox component

* Initial work on manage access dialog

* Add missed change

* Add comments and clean up

* Initial work on manage access dialog

* Add missed change

* Add comments and clean up

* Add return type

* Address comments and use apiWrapper

* Fix compile error
This commit is contained in:
Charles Gagnon
2019-10-03 08:58:06 -07:00
committed by GitHub
parent 6582debd73
commit af24a9d002
13 changed files with 567 additions and 29 deletions

View File

@@ -65,8 +65,20 @@ export interface IFileSource {
readFileLines(path: string, maxLines: number): Promise<Buffer>;
writeFile(localFile: IFile, remoteDir: string): Promise<string>;
delete(path: string, recursive?: boolean): Promise<void>;
/**
* Get ACL status for given path
* @param path The path to the file/folder to get the status of
*/
getAclStatus(path: string): Promise<IAclStatus>;
setAcl(path: string, aclEntries: AclEntry[]): Promise<void>;
/**
* Sets the ACL status for given path
* @param path The path to the file/folder to set the ACL on
* @param ownerEntry The entry corresponding to the path owner
* @param groupEntry The entry corresponding to the path owning group
* @param otherEntry The entry corresponding to default permissions for all other users
* @param aclEntries The ACL entries to set
*/
setAcl(path: string, ownerEntry: AclEntry, groupEntry: AclEntry, otherEntry: AclEntry, aclEntries: AclEntry[]): Promise<void>;
exists(path: string): Promise<boolean>;
}
@@ -323,11 +335,14 @@ export class HdfsFileSource implements IFileSource {
/**
* Sets the ACL status for given path
* @param path The path to the file/folder to set the ACL on
* @param ownerEntry The entry corresponding to the path owner
* @param groupEntry The entry corresponding to the path owning group
* @param otherEntry The entry corresponding to default permissions for all other users
* @param aclEntries The ACL entries to set
*/
public setAcl(path: string, aclEntries: AclEntry[]): Promise<void> {
public setAcl(path: string, ownerEntry: AclEntry, groupEntry: AclEntry, otherEntry: AclEntry, aclEntries: AclEntry[]): Promise<void> {
return new Promise((resolve, reject) => {
this.client.setAcl(path, aclEntries, (error: HdfsError) => {
this.client.setAcl(path, ownerEntry, groupEntry, otherEntry, aclEntries, (error: HdfsError) => {
if (error) {
reject(error);
} else {

View File

@@ -21,6 +21,7 @@ import * as utils from '../utils';
import { AppContext } from '../appContext';
import { TreeNode } from './treeNodes';
import { MssqlObjectExplorerNodeProvider } from './objectExplorerNodeProvider';
import { ManageAccessDialog } from '../hdfs/ui/hdfsManageAccessDialog';
async function getSaveableUri(apiWrapper: ApiWrapper, fileName: string, isPreview?: boolean): Promise<vscode.Uri> {
let root = utils.getUserHome();
@@ -384,3 +385,24 @@ export class CopyPathCommand extends Command {
}
}
}
export class ManageAccessCommand extends Command {
constructor(appContext: AppContext) {
super('mssqlCluster.manageAccess', appContext);
}
async execute(context: ICommandViewContext | ICommandObjectExplorerContext, ...args: any[]): Promise<void> {
try {
let node = await getNode<HdfsFileSourceNode>(context, this.appContext);
if (node) {
new ManageAccessDialog(node.hdfsPath, node.fileSource, this.apiWrapper).openDialog();
} else {
this.apiWrapper.showErrorMessage(LocalizedConstants.msgMissingNodeContext);
}
} catch (err) {
this.apiWrapper.showErrorMessage(
localize('manageAccessError', "An unexpected error occurred while opening the Manage Access dialog: {0}", utils.getErrorMessage(err, true)));
}
}
}

View File

@@ -75,7 +75,7 @@ export class HdfsProvider implements vscode.TreeDataProvider<TreeNode>, ITreeCha
}
export abstract class HdfsFileSourceNode extends TreeNode {
constructor(protected context: TreeDataContext, protected _path: string, protected fileSource: IFileSource) {
constructor(protected context: TreeDataContext, protected _path: string, public readonly fileSource: IFileSource) {
super();
}