Skip to content
7 changes: 6 additions & 1 deletion src/api/IBMiContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,12 @@ export default class IBMiContent {
*/
getMemberInfo(library: string, sourceFile: string, member: string) {
const component = this.ibmi.getComponent<GetMemberInfo>(GetMemberInfo.ID)!;
return component.getMemberInfo(this.ibmi, library, sourceFile, member);

if (component) {
return component.getMemberInfo(this.ibmi, library, sourceFile, member);
} else {
return Promise.resolve(undefined);
}
}

/**
Expand Down
30 changes: 24 additions & 6 deletions src/api/components/getMemberInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,31 @@ export class GetMemberInfo implements IBMiComponent {
});
}

private static parseDateString(tsString: string|undefined): Date | undefined {
if (!tsString) {
return undefined;
}

const dateParts = tsString.split('-');
const timeParts = dateParts[3].split('.');

const year = parseInt(dateParts[0], 10);
const month = parseInt(dateParts[1], 10) - 1; // Months are zero-based in JavaScript
const day = parseInt(dateParts[2], 10);
const hours = parseInt(timeParts[0], 10);
const minutes = parseInt(timeParts[1], 10);
const seconds = parseInt(timeParts[2], 10);

return new Date(year, month, day, hours, minutes, seconds);
}

async getMemberInfo(connection: IBMi, library: string, sourceFile: string, member: string): Promise<IBMiMember | undefined> {
const config = connection.config!;
const tempLib = config.tempLibrary;
const statement = `select * from table(${tempLib}.${this.procedureName}('${library}', '${sourceFile}', '${member}'))`;

let results: Tools.DB2Row[] = [];
if (config.enableSQL) {
if (connection.enableSQL) {
try {
results = await connection.runSQL(statement);
} catch (e) { } // Ignore errors, will return undefined.
Expand All @@ -78,8 +96,8 @@ export class GetMemberInfo implements IBMiComponent {
name: result.MEMBER,
extension: result.EXTENSION,
text: result.DESCRIPTION,
created: new Date(result.CREATED ? Number(result.CREATED) : 0),
changed: new Date(result.CHANGED ? Number(result.CHANGED) : 0)
created: GetMemberInfo.parseDateString(String(result.CREATED)),
Comment thread
worksofliam marked this conversation as resolved.
changed: GetMemberInfo.parseDateString(String(result.CHANGED))
} as IBMiMember
}
}
Expand All @@ -92,7 +110,7 @@ export class GetMemberInfo implements IBMiComponent {
.join(' union all ');

let results: Tools.DB2Row[] = [];
if (config.enableSQL) {
if (connection.enableSQL) {
try {
results = await connection.runSQL(statement);
} catch (e) { }; // Ignore errors, will return undefined.
Expand All @@ -110,8 +128,8 @@ export class GetMemberInfo implements IBMiComponent {
name: result.MEMBER,
extension: result.EXTENSION,
text: result.DESCRIPTION,
created: new Date(result.CREATED ? Number(result.CREATED) : 0),
changed: new Date(result.CHANGED ? Number(result.CHANGED) : 0)
created: GetMemberInfo.parseDateString(String(result.CREATED)),
changed: GetMemberInfo.parseDateString(String(result.CHANGED))
} as IBMiMember
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/components/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class ComponentManager {
const installed = lastInstalled.find(i => i.id.name === component.getIdentification().name);
const sameVersion = installed && (installed.id.version === component.getIdentification().version);

if (!installed || !sameVersion) {
if (!installed || !sameVersion || installed.state === `NotChecked`) {
await newComponent.check();
} else {
newComponent.overrideState(installed.state);
Expand Down
4 changes: 2 additions & 2 deletions src/api/tests/suites/components.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ describe('Component Tests', () => {
expect(memberInfoC?.library).toBe(tempLib);
expect(memberInfoC?.file).toBe(tempSPF);
expect(memberInfoC?.name).toBe(tempMbr);
expect(memberInfoC?.created).toBeTypeOf('number');
expect(memberInfoC?.changed).toBeTypeOf('number');
expect(memberInfoC?.created).toBeTypeOf('object');
expect(memberInfoC?.changed).toBeTypeOf('object');

// Cleanup...
await connection!.runCommand({
Expand Down
6 changes: 6 additions & 0 deletions src/commands/open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ export function registerOpenCommands(instance: Instance): Disposable[] {
});

quickPick.onDidAccept(async () => {
quickPick.busy = true;
quickPick.enabled = false;

let selection = quickPick.selectedItems.length === 1 ? quickPick.selectedItems[0].label : undefined;
if (selection && selection !== LOADING_LABEL) {
if (selection === CLEAR_RECENT) {
Expand Down Expand Up @@ -408,6 +411,9 @@ export function registerOpenCommands(instance: Instance): Disposable[] {
}
}
}

quickPick.busy = false;
quickPick.enabled = true;
Comment thread
worksofliam marked this conversation as resolved.
Outdated
});

quickPick.onDidTriggerItemButton((event: QuickPickItemButtonEvent<QuickPickItem>) => {
Expand Down