forked from cerc-io/snowballtools-base
Integrate rollback deployment GQL mutation in frontend (#49)
* Use rollback deployment client in UI * Check if deployements domain is undefined * Fix typo * Rename variable to current deployment * Handle deployment domain relation on rollback --------- Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
committed by
Ashwin Phatak
co-authored by
neeraj
parent
fdf06f9bd0
commit
d97794f1bf
@@ -304,8 +304,21 @@ export class Database {
|
||||
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
||||
|
||||
// TODO: Implement transactions
|
||||
const oldCurrentDeploymentUpdate = await deploymentRepository.update({ project: { id: projectId }, isCurrent: true }, { isCurrent: false });
|
||||
const newCurrentDeploymentUpdate = await deploymentRepository.update({ id: Number(deploymentId) }, { isCurrent: true });
|
||||
const oldCurrentDeployment = await deploymentRepository.findOne({
|
||||
relations: {
|
||||
domain: true
|
||||
},
|
||||
where: {
|
||||
project: {
|
||||
id: projectId
|
||||
},
|
||||
isCurrent: true
|
||||
}
|
||||
});
|
||||
|
||||
const oldCurrentDeploymentUpdate = await deploymentRepository.update({ project: { id: projectId }, isCurrent: true }, { isCurrent: false, domain: null });
|
||||
|
||||
const newCurrentDeploymentUpdate = await deploymentRepository.update({ id: Number(deploymentId) }, { isCurrent: true, domain: oldCurrentDeployment?.domain });
|
||||
|
||||
if (oldCurrentDeploymentUpdate.affected && newCurrentDeploymentUpdate.affected) {
|
||||
return oldCurrentDeploymentUpdate.affected > 0 && newCurrentDeploymentUpdate.affected > 0;
|
||||
|
||||
@@ -56,8 +56,8 @@ export const createResolvers = async (db: Database): Promise<any> => {
|
||||
},
|
||||
|
||||
projectsInOrganization: async (_: any, { organizationId }: {organizationId: string }, context: any) => {
|
||||
const dbProject = await db.getProjectsInOrganization(context.userId, organizationId);
|
||||
return dbProject;
|
||||
const dbProjects = await db.getProjectsInOrganization(context.userId, organizationId);
|
||||
return dbProjects;
|
||||
},
|
||||
|
||||
deployments: async (_: any, { projectId }: { projectId: string }) => {
|
||||
|
||||
Reference in New Issue
Block a user