Skip to content

Commit

Permalink
refactor(ui): improve differentiation between name and title
Browse files Browse the repository at this point in the history
  • Loading branch information
timonback committed Aug 16, 2024
1 parent 1746421 commit 79cbc94
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class ChannelMainComponent implements OnInit {

this.defaultExample = this.schema.example || noExample;
this.exampleTextAreaLineCount = this.defaultExample?.lineCount || 1;
this.defaultExampleType = this.operation().message.payload.type;
this.defaultExampleType = this.operation().message.payload.name;

this.headersSchemaIdentifier =
this.operation().message.headers.name.slice(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class ChannelOperationComponent implements OnInit {

defaultSchema: Schema = initSchema;
defaultExample: Example = initExample;
defaultExampleType: string = "";
originalDefaultExample: Example = this.defaultExample;

headers: Schema = initSchema;
Expand Down Expand Up @@ -57,7 +56,6 @@ export class ChannelOperationComponent implements OnInit {
const schema = schemas.get(schemaIdentifier)!!;
this.defaultSchema = schema;
this.originalDefaultExample = schema.example || noExample;
this.defaultExampleType = this.operation().message.payload.type;

const headersSchemaIdentifier =
this.operation().message.headers.name.slice(
Expand Down Expand Up @@ -123,7 +121,7 @@ export class ChannelOperationComponent implements OnInit {

publish(): void {
const example = this.defaultExample.value;
const payloadType = this.defaultExampleType;
const payloadType = this.operation().message.payload.name;
const headers = this.headersExample.value;
const bindings = this.messageBindingExampleString;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h2>Schemas</h2>
><div class="type-badge">{{ schema.type }}</div></span
>
</div>
<div class="table-row" *ngIf="schema.description">
<div class="table-row description" *ngIf="schema.description">
<span>Description</span>
<markdown [data]="schema.description"></markdown>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ describe("SchemaRangeComponent", function () {
});
};

const minimalSchema: Schema = {
title: "test",
name: "test",
anchorUrl: "test",
anchorIdentifier: "test",
usedBy: [],
};

it("should create the component", async () => {
await renderComponent({
title: "test",
name: "test",
anchorIdentifier: "test",
usedBy: [],
...minimalSchema,
minimum: 0.1,
maximum: 10,
exclusiveMinimum: true,
Expand All @@ -29,10 +34,7 @@ describe("SchemaRangeComponent", function () {

it("should have `( 0.1 .. 10 )` as value", async () => {
await renderComponent({
title: "test",
name: "test",
anchorIdentifier: "test",
usedBy: [],
...minimalSchema,
minimum: 0.1,
maximum: 10,
exclusiveMinimum: true,
Expand All @@ -44,10 +46,7 @@ describe("SchemaRangeComponent", function () {

it("should have `[ 0.1 .. 10 )` as value", async () => {
await renderComponent({
title: "test",
name: "test",
anchorIdentifier: "test",
usedBy: [],
...minimalSchema,
minimum: 0.1,
maximum: 10,
exclusiveMinimum: false,
Expand All @@ -59,10 +58,7 @@ describe("SchemaRangeComponent", function () {

it("should have `( 0.1 .. 10 ]` as value", async () => {
await renderComponent({
title: "test",
name: "test",
anchorIdentifier: "test",
usedBy: [],
...minimalSchema,
minimum: 0.1,
maximum: 10,
exclusiveMinimum: true,
Expand All @@ -74,10 +70,7 @@ describe("SchemaRangeComponent", function () {

it("should have `[ 0.1 .. 10 ]` as value", async () => {
await renderComponent({
title: "test",
name: "test",
anchorIdentifier: "test",
usedBy: [],
...minimalSchema,
minimum: 0.1,
maximum: 10,
});
Expand All @@ -87,10 +80,7 @@ describe("SchemaRangeComponent", function () {

it("should have `> 0.1` as value", async () => {
await renderComponent({
title: "test",
name: "test",
anchorIdentifier: "test",
usedBy: [],
...minimalSchema,
minimum: 0.1,
exclusiveMinimum: true,
});
Expand All @@ -100,10 +90,7 @@ describe("SchemaRangeComponent", function () {

it("should have `< 10` as value", async () => {
await renderComponent({
title: "test",
name: "test",
anchorIdentifier: "test",
usedBy: [],
...minimalSchema,
maximum: 10,
exclusiveMaximum: true,
});
Expand All @@ -113,10 +100,7 @@ describe("SchemaRangeComponent", function () {

it("should have `>= 0.1` as value", async () => {
await renderComponent({
title: "test",
name: "test",
anchorIdentifier: "test",
usedBy: [],
...minimalSchema,
minimum: 0.1,
});

Expand All @@ -125,10 +109,7 @@ describe("SchemaRangeComponent", function () {

it("should have `<= 10` as value", async () => {
await renderComponent({
title: "test",
name: "test",
anchorIdentifier: "test",
usedBy: [],
...minimalSchema,
maximum: 10,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
<ng-container *ngIf="property.value.items">
<span
class="type"
*ngIf="property.value.items.type && !property.value.items.anchorUrl"
*ngIf="
property.value.items.type && !property.value.items.refAnchorUrl
"
>{{ property.value.items.type }}[]</span
>
<span class="type" *ngIf="property.value.items.anchorUrl">
<a [href]="property.value.items.anchorUrl"
>{{ property.value.items.refTitle }}[]</a
<span class="type" *ngIf="property.value.items.refAnchorUrl">
<a [href]="property.value.items.refAnchorUrl"
>{{ property.value.items.refName }}[]</a
>
</span>
</ng-container>
Expand Down
1 change: 1 addition & 0 deletions springwolf-ui/src/app/models/channel.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ChannelOperation {
export interface Channel {
name: string;
anchorIdentifier: string;
anchorUrl: string;
description?: string;
operations: ChannelOperation[];
bindings: Bindings;
Expand Down
1 change: 0 additions & 1 deletion springwolf-ui/src/app/models/message.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export interface Message {
contentType: string;
payload: {
name: string;
type: string;
title: string;
anchorUrl: string;
};
Expand Down
4 changes: 2 additions & 2 deletions springwolf-ui/src/app/models/schema.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface Schema {
*/
title: string;
anchorIdentifier: string;
anchorUrl: string;
usedBy: { name: string; anchorUrl: string; type: "channel" | "schema" }[];
description?: string;
deprecated?: boolean;
Expand All @@ -21,9 +22,8 @@ export interface Schema {
type?: string;
format?: string;
// type == ref
anchorUrl?: string;
refAnchorUrl?: string;
refName?: string;
refTitle?: string;
// type == object
properties?: { [key: string]: Schema };
required?: string[];
Expand Down
Loading

0 comments on commit 79cbc94

Please sign in to comment.