Skip to content

Commit

Permalink
Add option to show hidden files in IFS browser (on by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrjorgensen committed Feb 11, 2024
1 parent 187c7da commit 1ccacb9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@
"default": false,
"description": "Show description of libraries in User Library List (recommended to also enable SQL)."
},
"showHiddenFiles": {
"type": "boolean",
"default": true,
"description": "Show hidden files and directories in IFS browser."
},
"debugPort": {
"type": "string",
"default": "8005",
Expand Down
4 changes: 3 additions & 1 deletion src/api/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export namespace ConnectionConfiguration {
quickConnect: boolean;
defaultDeploymentMethod: DeploymentMethod | '';
protectedPaths: string[];
showHiddenFiles: boolean;
[name: string]: any;
}

Expand Down Expand Up @@ -140,7 +141,8 @@ export namespace ConnectionConfiguration {
readOnlyMode: (parameters.readOnlyMode === true),
quickConnect: (parameters.quickConnect === true || parameters.quickConnect === undefined),
defaultDeploymentMethod: parameters.defaultDeploymentMethod || ``,
protectedPaths: (parameters.protectedPaths || [])
protectedPaths: (parameters.protectedPaths || []),
showHiddenFiles: (parameters.showHiddenFiles === true || parameters.showHiddenFiles === undefined),
}
}

Expand Down
14 changes: 12 additions & 2 deletions src/views/ifsBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { BrowserItem, BrowserItemParameters, FocusOptions, IFSFile, IFS_BROWSER_
const URI_LIST_MIMETYPE = "text/uri-list";
const URI_LIST_SEPARATOR = "\r\n";
const PROTECTED_DIRS = /^(\/|\/QOpenSys|\/QSYS\.LIB|\/QDLS|\/QOPT|\/QNTC|\/QFileSvr\.400|\/bin|\/dev|\/home|\/tmp|\/usr|\/var)$/i;
const ALWAYS_SHOW_FILES = /^(\.gitignore|\.vscode)$/i;
type DragNDropAction = "move" | "copy";
type DragNDropBehavior = DragNDropAction | "ask";
const getDragDropBehavior = () => GlobalConfiguration.get<DragNDropBehavior>(`IfsBrowser.DragAndDropDefaultBehavior`) || "ask";
Expand All @@ -23,6 +24,10 @@ function isProtected(path: string) {
return PROTECTED_DIRS.test(path) || instance.getContent()?.isProtectedPath(path);
}

function alwaysShow(name: string) {
return ALWAYS_SHOW_FILES.test(name);
}

class IFSBrowser implements vscode.TreeDataProvider<BrowserItem> {
private readonly emitter = new vscode.EventEmitter<BrowserItem | BrowserItem[] | undefined | null | void>();
readonly onDidChangeTreeData = this.emitter.event;
Expand Down Expand Up @@ -153,11 +158,16 @@ class IFSDirectoryItem extends IFSItem {

async getChildren(): Promise<BrowserItem[]> {
const content = instance.getContent();
const showHidden = instance.getConfig()?.showHiddenFiles;
if (content) {
try {
const objects = await content.getFileList(this.path, this.sort, handleFileListErrors);
const directories = objects.filter(o => o.type === `directory`);
const streamFiles = objects.filter(o => o.type === `streamfile`);
const directories = objects
.filter(o => o.type === `directory`)
.filter(o => showHidden || !o.name.startsWith(`.`) || alwaysShow(o.name));
const streamFiles = objects
.filter(o => o.type === `streamfile`)
.filter(o => showHidden || !o.name.startsWith(`.`) || alwaysShow(o.name));
await storeIFSList(this.path, streamFiles.map(o => o.name));
return [...directories.map(directory => new IFSDirectoryItem(directory, this)),
...streamFiles.map(file => new IFSFileItem(file, this))];
Expand Down
3 changes: 2 additions & 1 deletion src/webviews/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class SettingsUI {
.addCheckbox(`quickConnect`, `Quick Connect`, `When enabled, server settings from previous connection will be used, resulting in much quicker connection. If server settings are changed, right-click the connection in Connection Browser and select <code>Connect and Reload Server Settings</code> to refresh the cache.`, config.quickConnect)
.addCheckbox(`enableSQL`, `Enable SQL`, `Must be enabled to make the use of SQL and is enabled by default. If you find SQL isn't working for some reason, disable this. If your QCCSID system value is set to 65535, it is recommended that SQL is disabled. When disabled, will use import files where possible.`, config.enableSQL)
.addCheckbox(`showDescInLibList`, `Show description of libraries in User Library List view`, `When enabled, library text and attribute will be shown in User Library List. It is recommended to also enable SQL for this.`, config.showDescInLibList)
.addCheckbox(`showHiddenFiles`, `Show hidden files and directories in IFS browser.`, `When diabled, hidden files and directories (i.e. names starting with '.') will not be shown in the IFS browser, except for special config files.`, config.showHiddenFiles)
.addCheckbox(`autoConvertIFSccsid`, `Support EBCDIC streamfiles`, `Enable converting EBCDIC to UTF-8 when opening streamfiles. When disabled, assumes all streamfiles are in UTF8. When enabled, will open streamfiles regardless of encoding. May slow down open and save operations.<br><br>You can find supported CCSIDs with <code>/usr/bin/iconv -l</code>`, config.autoConvertIFSccsid)
.addHorizontalRule()
.addCheckbox(`autoSaveBeforeAction`, `Auto Save for Actions`, `When current editor has unsaved changes, automatically save it before running an action.`, config.autoSaveBeforeAction)
Expand Down Expand Up @@ -256,7 +257,7 @@ export class SettingsUI {
restart = true;
}

const reloadBrowsers = config.protectedPaths.join(",") !== data.protectedPaths.join(",");
const reloadBrowsers = config.protectedPaths.join(",") !== data.protectedPaths.join(",") || config.showHiddenFiles !== data.showHiddenFiles;

Object.assign(config, data);
await instance.setConfig(config);
Expand Down

0 comments on commit 1ccacb9

Please sign in to comment.