Skip to content

Commit

Permalink
feat(config-editor): update the filenames of schema and uischema
Browse files Browse the repository at this point in the history
  • Loading branch information
peterhnm committed Nov 8, 2023
1 parent 6961695 commit 43f6e1f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions apps/miranum-config-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ If you don't have them yet, you can create them using the [Miranum JSON Forms Pl
Once you have your `JSON Schema` and `UI-Schema` files, you need to set the path to those files in the settings.
To do this, open the setting️s (Code > Preferences > Preferences) and search for `miranum-ide`.
There should be an entry called `Miranum IDE > Config Editor: Base Path` with an empty text field.
You need to enter the path to your `JSON Schema` and `UI-Schema` files in this text field.
You need to enter the full path to your `JSON Schema` and `UI-Schema` files in this text field.

### Usage

To use the editor, you have to open or create a `.config.json` file.
The plugin will then search for the `JSON Schema` and `UI-Schema` files in the directory you specified in the settings.
To find the right files, you have to stick to the following naming convention:

| Your Config File | Your JSON Schema | Your UI Schema |
|--------------------------|-----------------------|-------------------------|
| my-config.s3.config.json | schema.s3.config.json | uischema.s3.config.json |
| Your Config File | Your JSON Schema | Your UI Schema |
|--------------------------|------------------|------------------|
| my-config.s3.config.json | s3.schema.json | s3.uischema.json |

The plugin will read these files and display your form in the editor.

Expand Down
6 changes: 3 additions & 3 deletions apps/miranum-config-editor/src/application/usecases.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { ReadJsonFormUseCase } from "./usecases";

describe("Read Json Schema and UI Schema", () => {
const directory = new Map([
["my/base/path/to/schema.s3.config.json", "JSON Schema was read!"],
["my/base/path/to/uischema.s3.config.json", "UI Schema was read!"],
["my/base/path/to/s3.schema.json", "JSON Schema was read!"],
["my/base/path/to/s3.uischema.json", "UI Schema was read!"],
]);
const reader: ReaderOutPort = {
readFile(fileName: string): Promise<string> {
Expand All @@ -16,7 +16,7 @@ describe("Read Json Schema and UI Schema", () => {

it("should work", async () => {
const readJsonFormUseCase = new ReadJsonFormUseCase(reader);
const query = new ReadJsonFormQuery("schema.s3.config.json", "my/base/path/to");
const query = new ReadJsonFormQuery("my-form.s3.config.json", "my/base/path/to");

const files = readJsonFormUseCase.readJsonForm(query);
const schema = await files.get("schema");
Expand Down
11 changes: 8 additions & 3 deletions apps/miranum-config-editor/src/application/usecases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,18 @@ export class ReadJsonFormUseCase implements ReadJsonFormInPort {
) {}

readJsonForm(readJsonFormQuery: ReadJsonFormQuery): Map<string, Promise<string>> {
// The filename consists of the following parts.
// name | type | extension
// my-form.process.config.json
const fileName = readJsonFormQuery.fileName;
const basePath = readJsonFormQuery.basePath;

const extension = fileName.substring(fileName.indexOf("."), fileName.length);
const type = fileName.split(".").slice(-3, 2)[0];

const schema = this.readerOutPort.readFile(`${basePath}/schema${extension}`);
const uischema = this.readerOutPort.readFile(`${basePath}/uischema${extension}`);
const schema = this.readerOutPort.readFile(`${basePath}/${type}.schema.json`);
const uischema = this.readerOutPort.readFile(
`${basePath}/${type}.uischema.json`,
);

return new Map([
["schema", schema],
Expand Down

0 comments on commit 43f6e1f

Please sign in to comment.