mirror of
https://github.com/snowball-tools/snowballtools-base
synced 2025-08-10 00:04:09 +00:00
Handle review comments
This commit is contained in:
parent
65a52cb9dc
commit
ab65337cdc
@ -149,15 +149,15 @@ export class Database {
|
||||
|
||||
async getDeployment (options: FindOneOptions<Deployment>): Promise<Deployment | null> {
|
||||
const deploymentRepository = this.dataSource.getRepository(Deployment);
|
||||
|
||||
const deployment = await deploymentRepository.findOne(options);
|
||||
|
||||
return deployment;
|
||||
}
|
||||
|
||||
async getDomains (options: FindManyOptions<Domain>): Promise<Domain[]> {
|
||||
const domainRepository = this.dataSource.getRepository(Domain);
|
||||
|
||||
const domains = await domainRepository.find(options);
|
||||
|
||||
return domains;
|
||||
}
|
||||
|
||||
@ -223,18 +223,18 @@ export class Database {
|
||||
}
|
||||
}
|
||||
|
||||
async addProjectMember (data: DeepPartial<ProjectMember>): Promise<boolean> {
|
||||
async addProjectMember (data: DeepPartial<ProjectMember>): Promise<ProjectMember> {
|
||||
const projectMemberRepository = this.dataSource.getRepository(ProjectMember);
|
||||
const newProjectMember = await projectMemberRepository.save(data);
|
||||
|
||||
return Boolean(newProjectMember);
|
||||
return newProjectMember;
|
||||
}
|
||||
|
||||
async addEnvironmentVariables (data: DeepPartial<EnvironmentVariable>[]): Promise<boolean> {
|
||||
async addEnvironmentVariables (data: DeepPartial<EnvironmentVariable>[]): Promise<EnvironmentVariable[]> {
|
||||
const environmentVariableRepository = this.dataSource.getRepository(EnvironmentVariable);
|
||||
const savedEnvironmentVariables = await environmentVariableRepository.save(data);
|
||||
|
||||
return savedEnvironmentVariables.length > 0;
|
||||
return savedEnvironmentVariables;
|
||||
}
|
||||
|
||||
async updateEnvironmentVariable (environmentVariableId: string, update: DeepPartial<EnvironmentVariable>): Promise<boolean> {
|
||||
|
@ -10,6 +10,7 @@ import { isUserOwner } from './utils';
|
||||
import { Permission } from './entity/ProjectMember';
|
||||
import { Domain } from './entity/Domain';
|
||||
import { Project } from './entity/Project';
|
||||
import { EnvironmentVariable } from './entity/EnvironmentVariable';
|
||||
|
||||
const log = debug('snowball:database');
|
||||
|
||||
@ -102,10 +103,7 @@ export const createResolvers = async (db: Database, app: OAuthApp, service: Serv
|
||||
return service.addEnvironmentVariables(projectId, data);
|
||||
},
|
||||
|
||||
updateEnvironmentVariable: async (_: any, { environmentVariableId, data }: { environmentVariableId: string, data : {
|
||||
key: string
|
||||
value: string
|
||||
}}) => {
|
||||
updateEnvironmentVariable: async (_: any, { environmentVariableId, data }: { environmentVariableId: string, data : DeepPartial<EnvironmentVariable>}) => {
|
||||
return service.updateEnvironmentVariable(environmentVariableId, data);
|
||||
},
|
||||
|
||||
|
@ -185,7 +185,7 @@ type Mutation {
|
||||
updateProjectMember(projectMemberId: String!, data: UpdateProjectMemberInput): Boolean!
|
||||
removeProjectMember(projectMemberId: String!): Boolean!
|
||||
addEnvironmentVariables(projectId: String!, data: [AddEnvironmentVariableInput!]): Boolean!
|
||||
updateEnvironmentVariable(environmentVariableId: String!, environmentVariable: UpdateEnvironmentVariableInput!): Boolean!
|
||||
updateEnvironmentVariable(environmentVariableId: String!, data: UpdateEnvironmentVariableInput!): Boolean!
|
||||
removeEnvironmentVariable(environmentVariableId: String!): Boolean!
|
||||
updateDeploymentToProd(deploymentId: String!): Boolean!
|
||||
addProject(projectDetails: AddProjectInput): Boolean!
|
||||
|
@ -99,7 +99,7 @@ export class Service {
|
||||
});
|
||||
}
|
||||
|
||||
return await this.db.addProjectMember({
|
||||
const newProjectMember = await this.db.addProjectMember({
|
||||
project: {
|
||||
id: projectId
|
||||
},
|
||||
@ -109,6 +109,8 @@ export class Service {
|
||||
id: user.id
|
||||
}
|
||||
});
|
||||
|
||||
return Boolean(newProjectMember);
|
||||
} catch (err) {
|
||||
log(err);
|
||||
return false;
|
||||
@ -130,17 +132,15 @@ export class Service {
|
||||
});
|
||||
}).flat();
|
||||
|
||||
return await this.db.addEnvironmentVariables(formattedEnvironmentVariables);
|
||||
const savedEnvironmentVariables = await this.db.addEnvironmentVariables(formattedEnvironmentVariables);
|
||||
return savedEnvironmentVariables.length > 0;
|
||||
} catch (err) {
|
||||
log(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async updateEnvironmentVariable (environmentVariableId: string, data : {
|
||||
key: string
|
||||
value: string
|
||||
}): Promise<boolean> {
|
||||
async updateEnvironmentVariable (environmentVariableId: string, data : DeepPartial<EnvironmentVariable>): Promise<boolean> {
|
||||
try {
|
||||
return await this.db.updateEnvironmentVariable(environmentVariableId, data);
|
||||
} catch (err) {
|
||||
|
@ -1,13 +1,14 @@
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { Organization } from 'gql-client';
|
||||
|
||||
import { Outlet } from 'react-router-dom';
|
||||
|
||||
import Sidebar from '../components/Sidebar';
|
||||
import { useGQLClient } from '../context/GQLClientContext';
|
||||
import { Organization } from 'gql-client';
|
||||
|
||||
// TODO: Implement organization switcher
|
||||
// TODO: Projects get organization details through routes instead of context
|
||||
const USER_ORGANIZATION_INDEX = 1;
|
||||
const USER_ORGANIZATION_INDEX = 0;
|
||||
|
||||
const Dashboard = () => {
|
||||
const client = useGQLClient();
|
||||
|
@ -1,11 +1,11 @@
|
||||
import React from 'react';
|
||||
import { Outlet, useNavigate, useOutletContext } from 'react-router-dom';
|
||||
import { Organization } from 'gql-client';
|
||||
|
||||
import { IconButton, Typography } from '@material-tailwind/react';
|
||||
|
||||
import HorizontalLine from '../components/HorizontalLine';
|
||||
import ProjectSearchBar from '../components/projects/ProjectSearchBar';
|
||||
import { Organization } from 'gql-client';
|
||||
|
||||
const ProjectSearch = () => {
|
||||
const navigate = useNavigate();
|
||||
|
@ -160,16 +160,16 @@ export class GQLClient {
|
||||
return result.data;
|
||||
}
|
||||
|
||||
async updateEnvironmentVariable (environmentVariableId: string, environmentVariable: UpdateEnvironmentVariableInput): Promise<UpdateEnvironmentVariableResponse> {
|
||||
const { data } = await this.client.mutate({
|
||||
async updateEnvironmentVariable (environmentVariableId: string, data: UpdateEnvironmentVariableInput): Promise<UpdateEnvironmentVariableResponse> {
|
||||
const result = await this.client.mutate({
|
||||
mutation: updateEnvironmentVariable,
|
||||
variables: {
|
||||
environmentVariableId,
|
||||
environmentVariable
|
||||
data
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
return result.data;
|
||||
}
|
||||
|
||||
async removeEnvironmentVariable (environmentVariableId: string): Promise<RemoveEnvironmentVariableResponse> {
|
||||
|
@ -25,8 +25,8 @@ mutation ($projectId: String!, $data: [AddEnvironmentVariableInput!]) {
|
||||
`;
|
||||
|
||||
export const updateEnvironmentVariable = gql`
|
||||
mutation ($environmentVariableId: String!, $environmentVariable: UpdateEnvironmentVariableInput!) {
|
||||
updateEnvironmentVariable(environmentVariableId: $environmentVariableId, environmentVariable: $environmentVariable)
|
||||
mutation ($environmentVariableId: String!, $data: UpdateEnvironmentVariableInput!) {
|
||||
updateEnvironmentVariable(environmentVariableId: $environmentVariableId, data: $data)
|
||||
}
|
||||
`;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user