cc083dbdc9
Added editable fields to the project details page for Storage Limit and Bandwidth limit. Leveraged existing types when possible. Added fixed checking into the limits to prevent reducing limits beyond current usage, as well as limiting usage to less than the default paid tier maximum. Change-Id: I07ce53470919a8a9d4dce56ade6904ede8daf34c
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
import { Project, ProjectFields, ProjectLimits, ProjectsApi, ProjectsCursor, ProjectsPage } from '@/types/projects';
|
|
|
|
/**
|
|
* Mock for ProjectsApi
|
|
*/
|
|
export class ProjectsApiMock implements ProjectsApi {
|
|
private mockProjects: Project[] = [];
|
|
private mockLimits: ProjectLimits;
|
|
private mockProjectsPage: ProjectsPage;
|
|
|
|
public setMockProjects(mockProjects: Project[]): void {
|
|
this.mockProjects = mockProjects;
|
|
}
|
|
|
|
public setMockLimits(mockLimits: ProjectLimits): void {
|
|
this.mockLimits = mockLimits;
|
|
}
|
|
|
|
create(_createProjectFields: ProjectFields): Promise<Project> {
|
|
throw new Error('not implemented');
|
|
}
|
|
|
|
delete(_projectId: string): Promise<void> {
|
|
throw new Error('not implemented');
|
|
}
|
|
|
|
get(): Promise<Project[]> {
|
|
return Promise.resolve(this.mockProjects);
|
|
}
|
|
|
|
getOwnedProjects(_cursor: ProjectsCursor): Promise<ProjectsPage> {
|
|
return Promise.resolve(this.mockProjectsPage);
|
|
}
|
|
|
|
update(_projectId: string, _projectFields: ProjectFields, _projectLimits: ProjectLimits): Promise<void> {
|
|
return Promise.resolve();
|
|
}
|
|
|
|
getLimits(_projectId: string): Promise<ProjectLimits> {
|
|
return Promise.resolve(this.mockLimits);
|
|
}
|
|
|
|
getTotalLimits(): Promise<ProjectLimits> {
|
|
return Promise.resolve(this.mockLimits);
|
|
}
|
|
}
|