From 55d679742d5aa8d266386b32f9aa035838c1b235 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 18 Sep 2023 11:52:12 -0400 Subject: [PATCH] Adds logging to workspaces --- src/plus/workspaces/workspacesApi.ts | 8 ++++++++ src/plus/workspaces/workspacesService.ts | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/plus/workspaces/workspacesApi.ts b/src/plus/workspaces/workspacesApi.ts index 838f0eb..e76df74 100644 --- a/src/plus/workspaces/workspacesApi.ts +++ b/src/plus/workspaces/workspacesApi.ts @@ -1,5 +1,6 @@ import type { RequestInit } from '@env/fetch'; import type { Container } from '../../container'; +import { log } from '../../system/decorators/log'; import { Logger } from '../../system/logger'; import type { GraphQLRequest, ServerConnection } from '../gk/serverConnection'; import type { @@ -23,6 +24,7 @@ export class WorkspacesApi { private readonly connection: ServerConnection, ) {} + @log() async getWorkspace( id: string, options?: { @@ -93,6 +95,7 @@ export class WorkspacesApi { return json; } + @log() async getWorkspaces(options?: { count?: number; cursor?: string; @@ -216,6 +219,7 @@ export class WorkspacesApi { return outputData; } + @log() async getWorkspaceRepositories( workspaceId: string, options?: { @@ -272,6 +276,7 @@ export class WorkspacesApi { return json; } + @log() async createWorkspace(options: { name: string; description: string; @@ -339,6 +344,7 @@ export class WorkspacesApi { return json; } + @log() async deleteWorkspace(workspaceId: string): Promise { const rsp = await this.fetch({ query: ` @@ -369,6 +375,7 @@ export class WorkspacesApi { return json; } + @log() async addReposToWorkspace( workspaceId: string, repos: AddWorkspaceRepoDescriptor[], @@ -432,6 +439,7 @@ export class WorkspacesApi { return json; } + @log() async removeReposFromWorkspace( workspaceId: string, repos: RemoveWorkspaceRepoDescriptor[], diff --git a/src/plus/workspaces/workspacesService.ts b/src/plus/workspaces/workspacesService.ts index 02c88f9..e606573 100644 --- a/src/plus/workspaces/workspacesService.ts +++ b/src/plus/workspaces/workspacesService.ts @@ -7,6 +7,7 @@ import { RemoteResourceType } from '../../git/models/remoteResource'; import { Repository } from '../../git/models/repository'; import { showRepositoriesPicker } from '../../quickpicks/repositoryPicker'; import { SubscriptionState } from '../../subscription'; +import { log } from '../../system/decorators/log'; import { normalizePath } from '../../system/path'; import { openWorkspace, OpenWorkspaceLocation } from '../../system/utils'; import type { ServerConnection } from '../gk/serverConnection'; @@ -202,6 +203,7 @@ export class WorkspacesService implements Disposable { return this._localWorkspaces?.find(workspace => workspace.id === workspaceId); } + @log() async getWorkspaces(options?: { excludeRepositories?: boolean; force?: boolean }): Promise { const getWorkspacesResponse: GetWorkspacesResponse = { cloudWorkspaces: [], @@ -244,6 +246,7 @@ export class WorkspacesService implements Disposable { return descriptors?.map(d => ({ ...d, workspaceId: workspaceId })) ?? []; } + @log() async addMissingCurrentWorkspaceRepos(options?: { force?: boolean }): Promise { if (this._currentWorkspaceId == null) return; let currentWorkspace = [...(this._cloudWorkspaces ?? []), ...(this._localWorkspaces ?? [])].find( @@ -364,6 +367,7 @@ export class WorkspacesService implements Disposable { ); } + @log() resetWorkspaces(options?: { cloud?: boolean; local?: boolean }) { if (options?.cloud ?? true) { this._cloudWorkspaces = undefined; @@ -444,6 +448,7 @@ export class WorkspacesService implements Disposable { // eslint-disable-next-line @typescript-eslint/unified-signatures repository: Repository, ): Promise; + @log({ args: { 1: false, 2: false } }) async locateWorkspaceRepo( workspaceId: string, descriptor: CloudWorkspaceRepositoryDescriptor | LocalWorkspaceRepositoryDescriptor, @@ -511,6 +516,7 @@ export class WorkspacesService implements Disposable { } } + @log({ args: false }) async createCloudWorkspace(options?: { repos?: Repository[] }): Promise { const input = window.createInputBox(); input.title = 'Create Cloud Workspace'; @@ -754,6 +760,7 @@ export class WorkspacesService implements Disposable { } } + @log() async deleteCloudWorkspace(workspaceId: string) { const confirmation = await window.showWarningMessage( `Are you sure you want to delete this workspace? This cannot be undone.`, @@ -797,6 +804,7 @@ export class WorkspacesService implements Disposable { return repos.filter(repo => !workspaceRepos.find(r => r.id === repo.id)); } + @log({ args: { 1: false } }) async addCloudWorkspaceRepos( workspaceId: string, options?: { repos?: Repository[]; suppressNotifications?: boolean }, @@ -966,6 +974,7 @@ export class WorkspacesService implements Disposable { ); } + @log({ args: { 1: false } }) async removeCloudWorkspaceRepo(workspaceId: string, descriptor: CloudWorkspaceRepositoryDescriptor) { const workspace = this.getCloudWorkspace(workspaceId); if (workspace == null) return; @@ -1008,6 +1017,7 @@ export class WorkspacesService implements Disposable { usePathMapping?: boolean; }, ): Promise; + @log({ args: { 1: false } }) async resolveWorkspaceRepositoriesByName( workspaceOrId: CloudWorkspace | LocalWorkspace | string, options?: { @@ -1104,6 +1114,7 @@ export class WorkspacesService implements Disposable { return workspaceRepositoriesByName; } + @log() async saveAsCodeWorkspaceFile(workspaceId: string): Promise { const workspace = this.getCloudWorkspace(workspaceId) ?? this.getLocalWorkspace(workspaceId); if (workspace == null) return; @@ -1181,6 +1192,7 @@ export class WorkspacesService implements Disposable { void this.openCodeWorkspaceFile(workspaceId, { location: open.location }); } + @log() async chooseCodeWorkspaceAutoAddSetting(options?: { current?: boolean }): Promise { if ( options?.current && @@ -1241,6 +1253,7 @@ export class WorkspacesService implements Disposable { return newWorkspaceAutoAddSetting; } + @log() async openCodeWorkspaceFile(workspaceId: string, options?: { location?: OpenWorkspaceLocation }): Promise { const workspace = this.getCloudWorkspace(workspaceId) ?? this.getLocalWorkspace(workspaceId); if (workspace == null) return;