Procházet zdrojové kódy

Adds logging to workspaces

main
Eric Amodio před 1 rokem
rodič
revize
55d679742d
2 změnil soubory, kde provedl 21 přidání a 0 odebrání
  1. +8
    -0
      src/plus/workspaces/workspacesApi.ts
  2. +13
    -0
      src/plus/workspaces/workspacesService.ts

+ 8
- 0
src/plus/workspaces/workspacesApi.ts Zobrazit soubor

@ -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<DeleteWorkspaceResponse | undefined> {
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[],

+ 13
- 0
src/plus/workspaces/workspacesService.ts Zobrazit soubor

@ -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<GetWorkspacesResponse> {
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<void> {
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<void>;
@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<void> {
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<WorkspaceRepositoriesByName>;
@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<void> {
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<WorkspaceAutoAddSetting> {
if (
options?.current &&
@ -1241,6 +1253,7 @@ export class WorkspacesService implements Disposable {
return newWorkspaceAutoAddSetting;
}
@log()
async openCodeWorkspaceFile(workspaceId: string, options?: { location?: OpenWorkspaceLocation }): Promise<void> {
const workspace = this.getCloudWorkspace(workspaceId) ?? this.getLocalWorkspace(workspaceId);
if (workspace == null) return;

Načítá se…
Zrušit
Uložit