forked from cerc-io/snowballtools-base
Implement routes for project settings tab (#64)
* Add routes to settings tab panel * Refactor code to move settings tab components to pages * Rename registry fields in project and deployment entity * Use kebab case for routes --------- Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
@@ -63,10 +63,10 @@ export class Deployment {
|
||||
url!: string;
|
||||
|
||||
@Column('varchar')
|
||||
recordId!: string;
|
||||
registryRecordId!: string;
|
||||
|
||||
@Column('simple-json')
|
||||
recordData!: ApplicationRecord;
|
||||
registryRecordData!: ApplicationRecord;
|
||||
|
||||
@Column({
|
||||
enum: Environment
|
||||
|
||||
@@ -56,10 +56,10 @@ export class Project {
|
||||
prodBranch!: string;
|
||||
|
||||
@Column('varchar', { nullable: true })
|
||||
recordId!: string | null;
|
||||
registryRecordId!: string | null;
|
||||
|
||||
@Column('simple-json', { nullable: true })
|
||||
recordData!: ApplicationDeploymentRequest | null;
|
||||
registryRecordData!: ApplicationDeploymentRequest | null;
|
||||
|
||||
@Column('text', { default: '' })
|
||||
description!: string;
|
||||
|
||||
@@ -13,6 +13,7 @@ const APP_RECORD_TYPE = 'ApplicationRecord';
|
||||
const DEPLOYMENT_RECORD_TYPE = 'ApplicationDeploymentRequest';
|
||||
const AUTHORITY_NAME = 'snowball';
|
||||
|
||||
// TODO: Move registry code to laconic-sdk/watcher-ts
|
||||
export class Registry {
|
||||
private registry: LaconicRegistry;
|
||||
private registryConfig: RegistryConfig;
|
||||
@@ -22,7 +23,7 @@ export class Registry {
|
||||
this.registry = new LaconicRegistry(registryConfig.gqlEndpoint, registryConfig.restEndpoint, registryConfig.chainId);
|
||||
}
|
||||
|
||||
async createApplicationRecord (data: { recordName: string, appType: string }): Promise<{recordId: string, recordData: ApplicationRecord}> {
|
||||
async createApplicationRecord (data: { recordName: string, appType: string }): Promise<{registryRecordId: string, registryRecordData: ApplicationRecord}> {
|
||||
// TODO: Get record name from repo package.json name
|
||||
const recordName = data.recordName;
|
||||
|
||||
@@ -77,10 +78,10 @@ export class Registry {
|
||||
await this.registry.setName({ cid: result.data.id, crn: `${crn}@${applicationRecord.app_version}` }, this.registryConfig.privateKey, this.registryConfig.fee);
|
||||
await this.registry.setName({ cid: result.data.id, crn: `${crn}@${applicationRecord.repository_ref}` }, this.registryConfig.privateKey, this.registryConfig.fee);
|
||||
|
||||
return { recordId: result.data.id, recordData: applicationRecord };
|
||||
return { registryRecordId: result.data.id, registryRecordData: applicationRecord };
|
||||
}
|
||||
|
||||
async createApplicationDeploymentRequest (data: { appName: string }): Promise<{recordId: string, recordData: ApplicationDeploymentRequest}> {
|
||||
async createApplicationDeploymentRequest (data: { appName: string }): Promise<{registryRecordId: string, registryRecordData: ApplicationDeploymentRequest}> {
|
||||
const crn = this.getCrn(data.appName);
|
||||
const records = await this.registry.resolveNames([crn]);
|
||||
const applicationRecord = records[0];
|
||||
@@ -124,7 +125,7 @@ export class Registry {
|
||||
log(`Application deployment request record published: ${result.data.id}`);
|
||||
log('Application deployment request data:', applicationDeploymentRequest);
|
||||
|
||||
return { recordId: result.data.id, recordData: applicationDeploymentRequest };
|
||||
return { registryRecordId: result.data.id, registryRecordData: applicationDeploymentRequest };
|
||||
}
|
||||
|
||||
getCrn (appName: string): string {
|
||||
|
||||
@@ -214,7 +214,7 @@ export class Service {
|
||||
}
|
||||
|
||||
async createDeployment (userId: string, data: DeepPartial<Deployment>): Promise<Deployment> {
|
||||
const { recordId, recordData } = await this.registry.createApplicationRecord({
|
||||
const { registryRecordId, registryRecordData } = await this.registry.createApplicationRecord({
|
||||
recordName: data.project?.name ?? '',
|
||||
appType: data.project?.template ?? ''
|
||||
});
|
||||
@@ -226,15 +226,15 @@ export class Service {
|
||||
environment: data.environment,
|
||||
isCurrent: data.isCurrent,
|
||||
status: DeploymentStatus.Building,
|
||||
recordId,
|
||||
recordData,
|
||||
registryRecordId,
|
||||
registryRecordData,
|
||||
domain: data.domain,
|
||||
createdBy: Object.assign(new User(), {
|
||||
id: userId
|
||||
})
|
||||
});
|
||||
|
||||
log(`Application record ${recordId} published for deployment ${newDeployement.id}`);
|
||||
log(`Application record ${registryRecordId} published for deployment ${newDeployement.id}`);
|
||||
return newDeployement;
|
||||
}
|
||||
|
||||
@@ -262,10 +262,10 @@ export class Service {
|
||||
domain: null
|
||||
});
|
||||
|
||||
const { recordId, recordData } = await this.registry.createApplicationDeploymentRequest({ appName: project.name });
|
||||
const { registryRecordId, registryRecordData } = await this.registry.createApplicationDeploymentRequest({ appName: project.name });
|
||||
await this.db.updateProjectById(project.id, {
|
||||
recordId,
|
||||
recordData
|
||||
registryRecordId,
|
||||
registryRecordData
|
||||
});
|
||||
|
||||
return project;
|
||||
|
||||
Reference in New Issue
Block a user