mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-10-05 16:37:44 +03:00
GitButler WIP Commit
This commit is contained in:
parent
9301248b00
commit
c42738dd95
43
app/src/lib/projects/projectService.ts
Normal file
43
app/src/lib/projects/projectService.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import type { HttpClient } from '$lib/backend/httpClient';
|
||||
import type { CloudProject, Project } from '$lib/projects/types';
|
||||
|
||||
export class ProjectService {
|
||||
constructor(
|
||||
private project: Project,
|
||||
private httpClient: HttpClient
|
||||
) {}
|
||||
|
||||
async createCloudProject(
|
||||
token: string,
|
||||
params: {
|
||||
name: string;
|
||||
description?: string;
|
||||
uid?: string;
|
||||
}
|
||||
): Promise<CloudProject> {
|
||||
return await this.httpClient.post('projects.json', {
|
||||
body: params,
|
||||
token
|
||||
});
|
||||
}
|
||||
|
||||
async updateCloudProject(
|
||||
token: string,
|
||||
repositoryId: string,
|
||||
params: {
|
||||
name: string;
|
||||
description?: string;
|
||||
}
|
||||
): Promise<CloudProject> {
|
||||
return await this.httpClient.put(`projects/${repositoryId}.json`, {
|
||||
body: params,
|
||||
token
|
||||
});
|
||||
}
|
||||
|
||||
async getCloudProject(token: string, repositoryId: string): Promise<CloudProject> {
|
||||
return await this.httpClient.get(`projects/${repositoryId}.json`, {
|
||||
token
|
||||
});
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ export async function load({ params, parent }) {
|
||||
const {
|
||||
authService,
|
||||
githubService,
|
||||
projectService,
|
||||
projectListingService,
|
||||
remoteUrl$,
|
||||
} = await parent();
|
||||
|
||||
@ -31,7 +31,7 @@ export async function load({ params, parent }) {
|
||||
// synchronously available are much greater than the cost.
|
||||
let project: Project | undefined = undefined;
|
||||
try {
|
||||
project = await projectService.getProject(projectId);
|
||||
project = await projectListingService.getProject(projectId);
|
||||
invoke('set_project_active', { id: projectId }).then((_r) => {});
|
||||
} catch (err: any) {
|
||||
throw error(400, {
|
||||
|
Loading…
Reference in New Issue
Block a user