Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/tree/accounts/AccountItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export class AccountItem extends TreeItem implements PiExtTreeItem, Reorderable
}

async viewProperties(): Promise<string> {
return JSON.stringify(this.account, undefined, 4);
const { id, ...accountWithoutId } = this.account as any;
return JSON.stringify(accountWithoutId, undefined, 4);
}

getResourceId(): string {
Expand Down
16 changes: 9 additions & 7 deletions src/tree/accounts/AccountsItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ export class AccountsItem extends TreeItem implements PiExtTreeItem, Reorderer {
}

const showDeprecated = settingUtils.getShowDeprecatedResources();

// Separate deprecated and non-deprecated accounts
const nonDeprecatedAccounts = accounts.filter(a => !a.is_deprecated);
const deprecatedAccounts = showDeprecated ? accounts.filter(a => a.is_deprecated) : [];

const orderedAccounts: Account[] = await this.getOrderedResourceModels(nonDeprecatedAccounts);

// Cache all accounts (both deprecated and non-deprecated) to preserve deprecated items after reordering
const allAccounts = [...orderedAccounts, ...accounts.filter(a => a.is_deprecated)];
ext.resourceCache.set(AccountsItem.generatePiExtAccountsId(this.email), allAccounts);

const items: PiExtTreeItem[] = orderedAccounts.map(a => new AccountItem(this, this.email, a));

// Add deprecated accounts at the end
if (deprecatedAccounts.length > 0) {
items.push(...deprecatedAccounts.map(a => new AccountDeprecatedItem(this, this.email, a)));
Expand Down Expand Up @@ -91,16 +91,18 @@ export class AccountsItem extends TreeItem implements PiExtTreeItem, Reorderer {
async viewProperties(): Promise<string> {
const accounts: Account[] = await AccountsItem.getAccountsWithCache(this.email);
const showDeprecated = settingUtils.getShowDeprecatedResources();

// Separate deprecated and non-deprecated accounts
const nonDeprecatedAccounts = accounts.filter(a => !a.is_deprecated);
const deprecatedAccounts = showDeprecated ? accounts.filter(a => a.is_deprecated) : [];

// Order non-deprecated accounts and append deprecated ones at the end
const orderedAccounts = await this.getOrderedResourceModels(nonDeprecatedAccounts);
const result = [...orderedAccounts, ...deprecatedAccounts];

return JSON.stringify(result, undefined, 4);

// Remove id field from all accounts
const resultWithoutId = result.map(({ id, ...account }: any) => account);
return JSON.stringify(resultWithoutId, undefined, 4);
}

static async getAccounts(email: string): Promise<Account[]> {
Expand Down
3 changes: 2 additions & 1 deletion src/tree/holdings/HoldingItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export class HoldingItem extends TreeItem implements PiExtTreeItem, Reorderable
}

viewProperties(): string {
return JSON.stringify(this.holding, undefined, 4);
const { id, ...holdingWithoutId } = this.holding as any;
return JSON.stringify(holdingWithoutId, undefined, 4);
}

getResourceId(): string {
Expand Down
16 changes: 9 additions & 7 deletions src/tree/holdings/HoldingsItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ export class HoldingsItem extends TreeItem implements PiExtTreeItem, Reorderer {
}

const showDeprecated = settingUtils.getShowDeprecatedResources();

// Separate deprecated and non-deprecated holdings
const nonDeprecatedHoldings = holdings.filter(h => !h.is_deprecated);
const deprecatedHoldings = showDeprecated ? holdings.filter(h => h.is_deprecated) : [];

const orderedHoldings: Holding[] = await this.getOrderedResourceModels(nonDeprecatedHoldings);

// Cache all holdings (both deprecated and non-deprecated) to preserve deprecated items after reordering
const allHoldings = [...orderedHoldings, ...holdings.filter(h => h.is_deprecated)];
ext.resourceCache.set(HoldingsItem.generatePiExtHoldingsId(this.email), allHoldings);

const items: PiExtTreeItem[] = orderedHoldings.map(h => new HoldingItem(this, this.email, h));

// Add deprecated holdings at the end
if (deprecatedHoldings.length > 0) {
items.push(...deprecatedHoldings.map(h => new HoldingDeprecatedItem(this, this.email, h)));
Expand Down Expand Up @@ -91,16 +91,18 @@ export class HoldingsItem extends TreeItem implements PiExtTreeItem, Reorderer {
async viewProperties(): Promise<string> {
const holdings: Holding[] = await HoldingsItem.getHoldingsWithCache(this.email);
const showDeprecated = settingUtils.getShowDeprecatedResources();

// Separate deprecated and non-deprecated holdings
const nonDeprecatedHoldings = holdings.filter(h => !h.is_deprecated);
const deprecatedHoldings = showDeprecated ? holdings.filter(h => h.is_deprecated) : [];

// Order non-deprecated holdings and append deprecated ones at the end
const orderedHoldings = await this.getOrderedResourceModels(nonDeprecatedHoldings);
const result = [...orderedHoldings, ...deprecatedHoldings];

return JSON.stringify(result, undefined, 4);

// Remove id field from all holdings
const resultWithoutId = result.map(({ id, ...holding }: any) => holding);
return JSON.stringify(resultWithoutId, undefined, 4);
}

static async getHoldings(email: string): Promise<Holding[]> {
Expand Down