-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: editable metlo-config (#74)
Co-authored-by: Akshay Shekhawat <[email protected]>
- Loading branch information
1 parent
ce3fb95
commit 12fd0dd
Showing
19 changed files
with
532 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Response } from "express" | ||
import { UpdateMetloConfigParams } from "@common/types" | ||
import { getMetloConfig, updateMetloConfig } from "services/metlo-config" | ||
import ApiResponseHandler from "api-response-handler" | ||
import Error404NotFound from "errors/error-404-not-found" | ||
import { MetloRequest } from "types" | ||
|
||
export const updateMetloConfigHandler = async ( | ||
req: MetloRequest, | ||
res: Response, | ||
): Promise<void> => { | ||
try { | ||
const updateMetloConfigParams: UpdateMetloConfigParams = req.body | ||
await updateMetloConfig(req.ctx, updateMetloConfigParams) | ||
await ApiResponseHandler.success(res, null) | ||
} catch (err) { | ||
await ApiResponseHandler.error(res, err) | ||
} | ||
} | ||
|
||
export const getMetloConfigHandler = async ( | ||
req: MetloRequest, | ||
res: Response, | ||
): Promise<void> => { | ||
try { | ||
const metloConfig = await getMetloConfig(req.ctx) | ||
if (!metloConfig) { | ||
throw new Error404NotFound("No config saved yet.") | ||
} | ||
await ApiResponseHandler.success(res, metloConfig) | ||
} catch (err) { | ||
await ApiResponseHandler.error(res, err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
backend/src/migrations/1667599667595-add-metlo-config-table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class addMetloConfigTable1667599667595 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TABLE IF NOT EXISTS "metlo_config" ("uuid" uuid NOT NULL DEFAULT uuid_generate_v4(), "configString" character varying NOT NULL, CONSTRAINT "PK_af010f5deb8072a39d9aa13c89b" PRIMARY KEY ("uuid"))`, | ||
) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE IF EXISTS "metlo_config"`) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
backend/src/migrations/1667606447208-update-disabledPaths-column-blockFields-table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class updateDisabledPathsColumnBlockFieldsTable1667606447208 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "block_fields" DROP COLUMN "disabledPaths"`, | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "block_fields" ADD "disabledPaths" jsonb`, | ||
) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "block_fields" DROP COLUMN "disabledPaths"`, | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "block_fields" ADD "disabledPaths" character varying array NOT NULL DEFAULT '{}'`, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { | ||
BaseEntity, | ||
Column, | ||
CreateDateColumn, | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
UpdateDateColumn, | ||
} from "typeorm" | ||
|
||
@Entity() | ||
export class MetloConfig extends BaseEntity { | ||
@PrimaryGeneratedColumn("uuid") | ||
uuid: string | ||
|
||
@Column() | ||
configString: string | ||
} |
Oops, something went wrong.