Browse Source

Adds logging to workspaces

main
Eric Amodio 1 year ago
parent
commit
55d679742d
2 changed files with 21 additions and 0 deletions
  1. +8
    -0
      src/plus/workspaces/workspacesApi.ts
  2. +13
    -0
      src/plus/workspaces/workspacesService.ts

+ 8
- 0
src/plus/workspaces/workspacesApi.ts View File

@ -1,5 +1,6 @@
import type { RequestInit } from '@env/fetch'; import type { RequestInit } from '@env/fetch';
import type { Container } from '../../container'; import type { Container } from '../../container';
import { log } from '../../system/decorators/log';
import { Logger } from '../../system/logger'; import { Logger } from '../../system/logger';
import type { GraphQLRequest, ServerConnection } from '../gk/serverConnection'; import type { GraphQLRequest, ServerConnection } from '../gk/serverConnection';
import type { import type {
@ -23,6 +24,7 @@ export class WorkspacesApi {
private readonly connection: ServerConnection, private readonly connection: ServerConnection,
) {} ) {}
@log()
async getWorkspace( async getWorkspace(
id: string, id: string,
options?: { options?: {
@ -93,6 +95,7 @@ export class WorkspacesApi {
return json; return json;
} }
@log()
async getWorkspaces(options?: { async getWorkspaces(options?: {
count?: number; count?: number;
cursor?: string; cursor?: string;
@ -216,6 +219,7 @@ export class WorkspacesApi {
return outputData; return outputData;
} }
@log()
async getWorkspaceRepositories( async getWorkspaceRepositories(
workspaceId: string, workspaceId: string,
options?: { options?: {
@ -272,6 +276,7 @@ export class WorkspacesApi {
return json; return json;
} }
@log()
async createWorkspace(options: { async createWorkspace(options: {
name: string; name: string;
description: string; description: string;
@ -339,6 +344,7 @@ export class WorkspacesApi {
return json; return json;
} }
@log()
async deleteWorkspace(workspaceId: string): Promise<DeleteWorkspaceResponse | undefined> { async deleteWorkspace(workspaceId: string): Promise<DeleteWorkspaceResponse | undefined> {
const rsp = await this.fetch({ const rsp = await this.fetch({
query: ` query: `
@ -369,6 +375,7 @@ export class WorkspacesApi {
return json; return json;
} }
@log()
async addReposToWorkspace( async addReposToWorkspace(
workspaceId: string, workspaceId: string,
repos: AddWorkspaceRepoDescriptor[], repos: AddWorkspaceRepoDescriptor[],
@ -432,6 +439,7 @@ export class WorkspacesApi {
return json; return json;
} }
@log()
async removeReposFromWorkspace( async removeReposFromWorkspace(
workspaceId: string, workspaceId: string,
repos: RemoveWorkspaceRepoDescriptor[], repos: RemoveWorkspaceRepoDescriptor[],

+ 13
- 0
src/plus/workspaces/workspacesService.ts View File

@ -7,6 +7,7 @@ import { RemoteResourceType } from '../../git/models/remoteResource';
import { Repository } from '../../git/models/repository'; import { Repository } from '../../git/models/repository';
import { showRepositoriesPicker } from '../../quickpicks/repositoryPicker'; import { showRepositoriesPicker } from '../../quickpicks/repositoryPicker';
import { SubscriptionState } from '../../subscription'; import { SubscriptionState } from '../../subscription';
import { log } from '../../system/decorators/log';
import { normalizePath } from '../../system/path'; import { normalizePath } from '../../system/path';
import { openWorkspace, OpenWorkspaceLocation } from '../../system/utils'; import { openWorkspace, OpenWorkspaceLocation } from '../../system/utils';
import type { ServerConnection } from '../gk/serverConnection'; import type { ServerConnection } from '../gk/serverConnection';
@ -202,6 +203,7 @@ export class WorkspacesService implements Disposable {
return this._localWorkspaces?.find(workspace => workspace.id === workspaceId); return this._localWorkspaces?.find(workspace => workspace.id === workspaceId);
} }
@log()
async getWorkspaces(options?: { excludeRepositories?: boolean; force?: boolean }): Promise<GetWorkspacesResponse> { async getWorkspaces(options?: { excludeRepositories?: boolean; force?: boolean }): Promise<GetWorkspacesResponse> {
const getWorkspacesResponse: GetWorkspacesResponse = { const getWorkspacesResponse: GetWorkspacesResponse = {
cloudWorkspaces: [], cloudWorkspaces: [],
@ -244,6 +246,7 @@ export class WorkspacesService implements Disposable {
return descriptors?.map(d => ({ ...d, workspaceId: workspaceId })) ?? []; return descriptors?.map(d => ({ ...d, workspaceId: workspaceId })) ?? [];
} }
@log()
async addMissingCurrentWorkspaceRepos(options?: { force?: boolean }): Promise<void> { async addMissingCurrentWorkspaceRepos(options?: { force?: boolean }): Promise<void> {
if (this._currentWorkspaceId == null) return; if (this._currentWorkspaceId == null) return;
let currentWorkspace = [...(this._cloudWorkspaces ?? []), ...(this._localWorkspaces ?? [])].find( let currentWorkspace = [...(this._cloudWorkspaces ?? []), ...(this._localWorkspaces ?? [])].find(
@ -364,6 +367,7 @@ export class WorkspacesService implements Disposable {
); );
} }
@log()
resetWorkspaces(options?: { cloud?: boolean; local?: boolean }) { resetWorkspaces(options?: { cloud?: boolean; local?: boolean }) {
if (options?.cloud ?? true) { if (options?.cloud ?? true) {
this._cloudWorkspaces = undefined; this._cloudWorkspaces = undefined;
@ -444,6 +448,7 @@ export class WorkspacesService implements Disposable {
// eslint-disable-next-line @typescript-eslint/unified-signatures // eslint-disable-next-line @typescript-eslint/unified-signatures
repository: Repository, repository: Repository,
): Promise<void>; ): Promise<void>;
@log({ args: { 1: false, 2: false } })
async locateWorkspaceRepo( async locateWorkspaceRepo(
workspaceId: string, workspaceId: string,
descriptor: CloudWorkspaceRepositoryDescriptor | LocalWorkspaceRepositoryDescriptor, descriptor: CloudWorkspaceRepositoryDescriptor | LocalWorkspaceRepositoryDescriptor,
@ -511,6 +516,7 @@ export class WorkspacesService implements Disposable {
} }
} }
@log({ args: false })
async createCloudWorkspace(options?: { repos?: Repository[] }): Promise<void> { async createCloudWorkspace(options?: { repos?: Repository[] }): Promise<void> {
const input = window.createInputBox(); const input = window.createInputBox();
input.title = 'Create Cloud Workspace'; input.title = 'Create Cloud Workspace';
@ -754,6 +760,7 @@ export class WorkspacesService implements Disposable {
} }
} }
@log()
async deleteCloudWorkspace(workspaceId: string) { async deleteCloudWorkspace(workspaceId: string) {
const confirmation = await window.showWarningMessage( const confirmation = await window.showWarningMessage(
`Are you sure you want to delete this workspace? This cannot be undone.`, `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)); return repos.filter(repo => !workspaceRepos.find(r => r.id === repo.id));
} }
@log({ args: { 1: false } })
async addCloudWorkspaceRepos( async addCloudWorkspaceRepos(
workspaceId: string, workspaceId: string,
options?: { repos?: Repository[]; suppressNotifications?: boolean }, options?: { repos?: Repository[]; suppressNotifications?: boolean },
@ -966,6 +974,7 @@ export class WorkspacesService implements Disposable {
); );
} }
@log({ args: { 1: false } })
async removeCloudWorkspaceRepo(workspaceId: string, descriptor: CloudWorkspaceRepositoryDescriptor) { async removeCloudWorkspaceRepo(workspaceId: string, descriptor: CloudWorkspaceRepositoryDescriptor) {
const workspace = this.getCloudWorkspace(workspaceId); const workspace = this.getCloudWorkspace(workspaceId);
if (workspace == null) return; if (workspace == null) return;
@ -1008,6 +1017,7 @@ export class WorkspacesService implements Disposable {
usePathMapping?: boolean; usePathMapping?: boolean;
}, },
): Promise<WorkspaceRepositoriesByName>; ): Promise<WorkspaceRepositoriesByName>;
@log({ args: { 1: false } })
async resolveWorkspaceRepositoriesByName( async resolveWorkspaceRepositoriesByName(
workspaceOrId: CloudWorkspace | LocalWorkspace | string, workspaceOrId: CloudWorkspace | LocalWorkspace | string,
options?: { options?: {
@ -1104,6 +1114,7 @@ export class WorkspacesService implements Disposable {
return workspaceRepositoriesByName; return workspaceRepositoriesByName;
} }
@log()
async saveAsCodeWorkspaceFile(workspaceId: string): Promise<void> { async saveAsCodeWorkspaceFile(workspaceId: string): Promise<void> {
const workspace = this.getCloudWorkspace(workspaceId) ?? this.getLocalWorkspace(workspaceId); const workspace = this.getCloudWorkspace(workspaceId) ?? this.getLocalWorkspace(workspaceId);
if (workspace == null) return; if (workspace == null) return;
@ -1181,6 +1192,7 @@ export class WorkspacesService implements Disposable {
void this.openCodeWorkspaceFile(workspaceId, { location: open.location }); void this.openCodeWorkspaceFile(workspaceId, { location: open.location });
} }
@log()
async chooseCodeWorkspaceAutoAddSetting(options?: { current?: boolean }): Promise<WorkspaceAutoAddSetting> { async chooseCodeWorkspaceAutoAddSetting(options?: { current?: boolean }): Promise<WorkspaceAutoAddSetting> {
if ( if (
options?.current && options?.current &&
@ -1241,6 +1253,7 @@ export class WorkspacesService implements Disposable {
return newWorkspaceAutoAddSetting; return newWorkspaceAutoAddSetting;
} }
@log()
async openCodeWorkspaceFile(workspaceId: string, options?: { location?: OpenWorkspaceLocation }): Promise<void> { async openCodeWorkspaceFile(workspaceId: string, options?: { location?: OpenWorkspaceLocation }): Promise<void> {
const workspace = this.getCloudWorkspace(workspaceId) ?? this.getLocalWorkspace(workspaceId); const workspace = this.getCloudWorkspace(workspaceId) ?? this.getLocalWorkspace(workspaceId);
if (workspace == null) return; if (workspace == null) return;

Loading…
Cancel
Save