Skip to content

Commit

Permalink
Re-org of connection types
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
  • Loading branch information
worksofliam committed Jan 21, 2025
1 parent b1b7286 commit 91e687e
Show file tree
Hide file tree
Showing 19 changed files with 110 additions and 128 deletions.
3 changes: 1 addition & 2 deletions src/Instance.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as vscode from "vscode";
import { ConnectionData, IBMiEvent } from "./typings";
import { ConnectionConfig, ConnectionData, IBMiEvent } from "./typings";
import IBMi, { ConnectionResult } from "./api/IBMi";
import { CodeForIStorage } from "./api/configuration/storage/CodeForIStorage";
import { handleConnectionResults, messageCallback } from "./ui/connection";
import { VsStorage } from "./config/Storage";
import { VsCodeConfig } from "./config/Configuration";
import { ConnectionConfig } from "./api/configuration/config/ConnectionManager";
import { EventEmitter } from "stream";
import { ConnectionStorage } from "./api/configuration/storage/ConnectionStorage";
import { VscodeTools } from "./ui/Tools";
Expand Down
3 changes: 2 additions & 1 deletion src/api/IBMi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import { CachedServerSettings, CodeForIStorage } from './configuration/storage/C
import { Tools } from './Tools';
import * as configVars from './configVars';
import { DebugConfiguration } from "./configuration/DebugConfiguration";
import { ConnectionManager, ConnectionConfig } from './configuration/config/ConnectionManager';
import { ConnectionManager } from './configuration/config/ConnectionManager';
import { CommandData, CommandResult, ConnectionData, IBMiMember, RemoteCommand, WrapResult } from './types';
import { EventEmitter } from 'stream';
import { ConnectionConfig } from './configuration/config/types';

export interface MemberParts extends IBMiMember {
basename: string
Expand Down
78 changes: 2 additions & 76 deletions src/api/configuration/config/ConnectionManager.ts
Original file line number Diff line number Diff line change
@@ -1,82 +1,8 @@

import os from "os";
import { FilterType } from "../../Filter";
import { Config, VirtualConfig } from "./VirtualConfig";
import { DeploymentMethod, ConnectionData } from "../../types";

export type SourceDateMode = "edit" | "diff";
export type DefaultOpenMode = "browse" | "edit";
export type ReconnectMode = "always" | "never" | "ask";

export interface ConnectionConfig extends ConnectionProfile {
host: string;
autoClearTempData: boolean;
connectionProfiles: ConnectionProfile[];
commandProfiles: CommandProfile[];
autoSortIFSShortcuts: boolean;
tempLibrary: string;
tempDir: string;
sourceASP: string;
sourceFileCCSID: string;
autoConvertIFSccsid: boolean;
hideCompileErrors: string[];
enableSourceDates: boolean;
sourceDateMode: SourceDateMode;
sourceDateGutter: boolean;
encodingFor5250: string;
terminalFor5250: string;
setDeviceNameFor5250: boolean;
connectringStringFor5250: string;
autoSaveBeforeAction: boolean;
showDescInLibList: boolean;
debugPort: string;
debugSepPort: string;
debugUpdateProductionFiles: boolean;
debugEnableDebugTracing: boolean;
readOnlyMode: boolean;
quickConnect: boolean;
defaultDeploymentMethod: DeploymentMethod | '';
protectedPaths: string[];
showHiddenFiles: boolean;
lastDownloadLocation: string;
[name: string]: any;
}

export interface ObjectFilters {
name: string
filterType: FilterType
library: string
object: string
types: string[]
member: string
memberType: string
protected: boolean
}

export interface CustomVariable {
name: string
value: string
}

export interface ConnectionProfile {
name: string
homeDirectory: string
currentLibrary: string
libraryList: string[]
objectFilters: ObjectFilters[]
ifsShortcuts: string[]
customVariables: CustomVariable[]
}

export interface CommandProfile {
name: string;
command: string;
}

export interface StoredConnection {
index: number,
data: ConnectionData
};
import { ConnectionData } from "../../types";
import { ConnectionConfig } from "./types";

function initialize(parameters: Partial<ConnectionConfig>): ConnectionConfig {
return {
Expand Down
76 changes: 76 additions & 0 deletions src/api/configuration/config/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { FilterType } from "../../Filter";
import { DeploymentMethod, ConnectionData } from "../../types";

export type SourceDateMode = "edit" | "diff";
export type DefaultOpenMode = "browse" | "edit";
export type ReconnectMode = "always" | "never" | "ask";

export interface ConnectionConfig extends ConnectionProfile {
host: string;
autoClearTempData: boolean;
connectionProfiles: ConnectionProfile[];
commandProfiles: CommandProfile[];
autoSortIFSShortcuts: boolean;
tempLibrary: string;
tempDir: string;
sourceASP: string;
sourceFileCCSID: string;
autoConvertIFSccsid: boolean;
hideCompileErrors: string[];
enableSourceDates: boolean;
sourceDateMode: SourceDateMode;
sourceDateGutter: boolean;
encodingFor5250: string;
terminalFor5250: string;
setDeviceNameFor5250: boolean;
connectringStringFor5250: string;
autoSaveBeforeAction: boolean;
showDescInLibList: boolean;
debugPort: string;
debugSepPort: string;
debugUpdateProductionFiles: boolean;
debugEnableDebugTracing: boolean;
readOnlyMode: boolean;
quickConnect: boolean;
defaultDeploymentMethod: DeploymentMethod | '';
protectedPaths: string[];
showHiddenFiles: boolean;
lastDownloadLocation: string;
[name: string]: any;
}

export interface ObjectFilters {
name: string
filterType: FilterType
library: string
object: string
types: string[]
member: string
memberType: string
protected: boolean
}

export interface CustomVariable {
name: string
value: string
}

export interface ConnectionProfile {
name: string
homeDirectory: string
currentLibrary: string
libraryList: string[]
objectFilters: ObjectFilters[]
ifsShortcuts: string[]
customVariables: CustomVariable[]
}

export interface CommandProfile {
name: string;
command: string;
}

export interface StoredConnection {
index: number,
data: ConnectionData
};
17 changes: 3 additions & 14 deletions src/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ObjectFilters } from "./configuration/config/ConnectionManager";

export type DeploymentMethod = "all" | "staged" | "unstaged" | "changed" | "compare";

Expand Down Expand Up @@ -146,18 +145,6 @@ export interface WithLibrary {

export type FocusOptions = { select?: boolean; focus?: boolean; expand?: boolean | number }

export interface FilteredItem {
filter: ObjectFilters
}

export interface ObjectItem extends FilteredItem, WithPath {
object: IBMiObject
}

export interface MemberItem extends FilteredItem, WithPath {
member: IBMiMember
}

export type IBMiMessage = {
id: string
text: string
Expand Down Expand Up @@ -193,4 +180,6 @@ export type SearchHit = {
export type SearchHitLine = {
number: number
content: string
}
}

export * from "./configuration/config/types";
3 changes: 1 addition & 2 deletions src/commands/open.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { commands, Disposable, l10n, QuickInputButton, QuickPickItem, QuickPickItemButtonEvent, QuickPickItemKind, Range, TextDocument, TextDocumentShowOptions, ThemeIcon, Uri, window } from "vscode";
import { MemberItem, QsysFsOptions, WithPath } from "../typings";
import { DefaultOpenMode, MemberItem, QsysFsOptions, WithPath } from "../typings";
import Instance from "../Instance";
import { Tools } from "../api/Tools";
import { getUriFromPath, parseFSOptions } from "../filesystems/qsys/QSysFs";
import path from "path";
import { VscodeTools } from "../ui/Tools";
import IBMi from "../api/IBMi";
import { DefaultOpenMode } from "../api/configuration/config/ConnectionManager";

const CLEAR_RECENT = `$(trash) Clear recently opened`;
const CLEAR_CACHED = `$(trash) Clear cached`;
Expand Down
2 changes: 1 addition & 1 deletion src/filesystems/local/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { instance } from "../../instantiate";
import IBMi from "../../api/IBMi";
import IBMiContent from "../../api/IBMiContent";
import { VscodeTools } from "../../ui/Tools";
import { ConnectionConfig } from "../../api/configuration/config/ConnectionManager";
import { ConnectionConfig } from "../../typings";

const lastBranch: { [workspaceUri: string]: string } = {};

Expand Down
2 changes: 1 addition & 1 deletion src/filesystems/qsys/FSUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from "path";
import vscode, { l10n } from "vscode";
import { VscodeTools } from "../../ui/Tools";
import IBMi from "../../api/IBMi";
import { ReconnectMode } from "../../api/configuration/config/ConnectionManager";
import { ReconnectMode } from "../../typings";

/**
* Called when a member/streamfile is left open when VS Code is closed and re-opened to reconnect (or not) to the previous IBM i, based on the `autoReconnect` global configuration value.
Expand Down
2 changes: 1 addition & 1 deletion src/filesystems/qsys/sourceDateHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DiffComputer } from "vscode-diff";

import { instance } from "../../instantiate";
import IBMi from "../../api/IBMi";
import { SourceDateMode } from "../../api/configuration/config/ConnectionManager";
import { SourceDateMode } from "../../typings";

const editedTodayColor = new vscode.ThemeColor(`gitDecoration.modifiedResourceForeground`);
const seachGutterColor = new vscode.ThemeColor(`gitDecoration.addedResourceForeground`);
Expand Down
16 changes: 1 addition & 15 deletions src/typings.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { CustomUI } from "./webviews/CustomUI";
import Instance from "./Instance";
import { Tools } from "./api/Tools";
import { DeployTools } from "./filesystems/local/deployTools";
import { ComponentRegistry } from './api/components/manager';
import { ObjectFilters } from './api/configuration/config/ConnectionManager';
import { DeploymentMethod, FileError, IBMiMember, IBMiObject, WithPath } from "./api/types";
import { DeploymentMethod, FileError } from "./api/types";
import { Ignore } from "ignore";
import { WorkspaceFolder } from "vscode";
import { VscodeTools } from "./ui/Tools";
Expand All @@ -18,18 +16,6 @@ export interface CodeForIBMi {
componentRegistry: ComponentRegistry
}

export interface FilteredItem {
filter: ObjectFilters
}

export interface ObjectItem extends FilteredItem, WithPath {
object: IBMiObject
}

export interface MemberItem extends FilteredItem, WithPath {
member: IBMiMember
}

export interface DeploymentParameters {
method: DeploymentMethod
workspaceFolder: WorkspaceFolder
Expand Down
14 changes: 13 additions & 1 deletion src/ui/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TreeItemCollapsibleState, TreeItem, ThemeIcon, ThemeColor, ProviderResult, MarkdownString } from "vscode"
import { FocusOptions } from "../api/types"
import { FocusOptions, IBMiMember, IBMiObject, ObjectFilters, WithPath } from "../api/types"

export type BrowserItemParameters = {
icon?: string
Expand All @@ -8,6 +8,18 @@ export type BrowserItemParameters = {
parent?: BrowserItem
}

export interface FilteredItem {
filter: ObjectFilters
}

export interface ObjectItem extends FilteredItem, WithPath {
object: IBMiObject
}

export interface MemberItem extends FilteredItem, WithPath {
member: IBMiMember
}

export class BrowserItem extends TreeItem {
constructor(label: string, readonly params?: BrowserItemParameters) {
super(label, params?.state);
Expand Down
3 changes: 1 addition & 2 deletions src/ui/views/ConnectionBrowser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import vscode from 'vscode';
import { ConnectionData, Server } from '../../typings';
import { ConnectionConfig, ConnectionData, Server } from '../../typings';

import { instance } from '../../instantiate';
import { Login } from '../../webviews/login';
import IBMi from '../../api/IBMi';
import { ConnectionConfig, ConnectionManager } from '../../api/configuration/config/ConnectionManager';
import { deleteStoredPassword, getStoredPassword, setStoredPassword } from '../../config/passwords';

type CopyOperationItem = {
Expand Down
3 changes: 1 addition & 2 deletions src/ui/views/LibraryListView.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import vscode, { commands, l10n } from "vscode";
import { instance } from "../../instantiate";
import { IBMiObject, WithLibrary } from "../../typings";
import { ConnectionConfig, IBMiObject, WithLibrary } from "../../typings";
import { VscodeTools } from "../Tools";
import { ConnectionConfig } from "../../api/configuration/config/ConnectionManager";
import IBMi from "../../api/IBMi";

export class LibraryListProvider implements vscode.TreeDataProvider<LibraryListNode> {
Expand Down
3 changes: 1 addition & 2 deletions src/ui/views/ProfilesView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import vscode, { l10n, window } from 'vscode';
import { GetNewLibl } from '../../api/components/getNewLibl';
import { instance } from '../../instantiate';
import { Profile } from '../../typings';
import { ConnectionProfile, Profile } from '../../typings';
import { CommandProfileUi } from '../../webviews/commandProfile';
import IBMi from '../../api/IBMi';
import { ConnectionProfile } from '../../api/configuration/config/ConnectionManager';

export class ProfilesView {
private _onDidChangeTreeData = new vscode.EventEmitter<vscode.TreeItem | undefined | null | void>();
Expand Down
3 changes: 1 addition & 2 deletions src/ui/views/objectBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import { Search } from "../../api/Search";
import { Tools } from "../../api/Tools";
import { getMemberUri } from "../../filesystems/qsys/QSysFs";
import { instance } from "../../instantiate";
import { CommandResult, FilteredItem, FocusOptions, IBMiMember, IBMiObject, MemberItem, OBJECT_BROWSER_MIMETYPE, ObjectItem, WithLibrary } from "../../typings";
import { CommandResult, DefaultOpenMode, FilteredItem, FocusOptions, IBMiMember, IBMiObject, MemberItem, OBJECT_BROWSER_MIMETYPE, ObjectFilters, ObjectItem, WithLibrary } from "../../typings";
import { editFilter } from "../../webviews/filters";
import { VscodeTools } from "../Tools";
import { DefaultOpenMode, ObjectFilters } from "../../api/configuration/config/ConnectionManager";
import { BrowserItem, BrowserItemParameters } from "../types";

const URI_LIST_SEPARATOR = "\r\n";
Expand Down
3 changes: 1 addition & 2 deletions src/ui/views/searchView.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import path from 'path';
import vscode from "vscode";
import { SearchHit, SearchHitLine, SearchResults, WithPath } from "../../typings";
import { DefaultOpenMode } from '../../api/configuration/config/ConnectionManager';
import { DefaultOpenMode, SearchHit, SearchHitLine, SearchResults, WithPath } from "../../typings";

export function initializeSearchView(context: vscode.ExtensionContext) {
const searchView = new SearchView();
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/commandProfile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { commands, window } from "vscode";
import { CustomUI } from "../CustomUI";
import { instance } from "../../instantiate";
import IBMi from "../../api/IBMi";
import { CommandProfile } from "../../api/configuration/config/ConnectionManager";
import { CommandProfile } from "../../typings";

export class CommandProfileUi {
static async show(currentName?: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/filters/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { CustomUI } from "../CustomUI";
import { Tools } from "../../api/Tools";
import { instance } from "../../instantiate";
import { ObjectFilters } from "../../api/configuration/config/ConnectionManager";
import IBMi from "../../api/IBMi";
import { ObjectFilters } from "../../typings";

export async function editFilter(filter?: ObjectFilters, copy = false) {
const connection = instance.getConnection();
Expand Down
Loading

0 comments on commit 91e687e

Please sign in to comment.