Skip to content

Commit 523d435

Browse files
committed
feat(hub-common): update channel ui schemas to use noticeIds rather than manual notice definitions
affects: @esri/hub-common ISSUES CLOSED: 12468
1 parent eed1210 commit 523d435

File tree

5 files changed

+28
-60
lines changed

5 files changed

+28
-60
lines changed

packages/common/src/channels/HubChannel.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ export class HubChannel
150150
throw new Error("HubChannel is already destroyed.");
151151
}
152152

153-
const { updateHubChannel, createHubChannel } = await import("./edit");
154-
155153
if (this.entity.id) {
154+
const { updateHubChannel } = await import("./edit");
156155
this.entity = await updateHubChannel(this.entity, this.context);
157156
} else {
157+
const { createHubChannel } = await import("./edit");
158158
this.entity = await createHubChannel(this.entity, this.context);
159159
}
160160
}

packages/common/src/channels/_internal/ChannelUiSchemaCreate.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,7 @@ export const buildUiSchema = async (
143143
{
144144
type: "Notice",
145145
options: {
146-
notice: {
147-
configuration: {
148-
noticeType: "notice",
149-
closable: false,
150-
kind: "info",
151-
scale: "m",
152-
},
153-
title: `{{${i18nScope}.sections.permissions.notice.title:translate}}`,
154-
message: `{{${i18nScope}.sections.permissions.notice.message:translate}}`,
155-
autoShow: true,
156-
actions: [
157-
{
158-
label: `{{${i18nScope}.sections.permissions.notice.action:translate}}`,
159-
href: "#readMore",
160-
target: "_blank",
161-
},
162-
],
163-
},
146+
noticeId: "20250311-channel-permissions-info",
164147
},
165148
},
166149
{

packages/common/src/channels/_internal/ChannelUiSchemaEdit.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ export const buildUiSchema = async (
1414
options: Partial<IHubChannel>,
1515
context: IArcGISContext
1616
): Promise<IUiSchema> => {
17-
// the create and edit schemas are the same at this time, this leaves the door open for them to change over time
18-
return buildUiSchemaCreate(i18nScope, options, context);
17+
const uiSchema = await buildUiSchemaCreate(i18nScope, options, context);
18+
// the create and edit schemas are the same with the exception of the edit notice
19+
uiSchema.elements.splice(0, 0, {
20+
type: "Notice",
21+
options: {
22+
noticeId: "20250311-channel-edit-warning",
23+
},
24+
});
25+
return uiSchema;
1926
};

packages/common/test/channels/_internal/ChannelUiSchemaCreate.test.ts

+2-36
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,7 @@ describe("ChannelUiSchemaCreate", () => {
109109
{
110110
type: "Notice",
111111
options: {
112-
notice: {
113-
configuration: {
114-
noticeType: "notice",
115-
closable: false,
116-
kind: "info",
117-
scale: "m",
118-
},
119-
title: `{{${i18nScope}.sections.permissions.notice.title:translate}}`,
120-
message: `{{${i18nScope}.sections.permissions.notice.message:translate}}`,
121-
autoShow: true,
122-
actions: [
123-
{
124-
label: `{{${i18nScope}.sections.permissions.notice.action:translate}}`,
125-
href: "#readMore",
126-
target: "_blank",
127-
},
128-
],
129-
},
112+
noticeId: "20250311-channel-permissions-info",
130113
},
131114
},
132115
{
@@ -403,24 +386,7 @@ describe("ChannelUiSchemaCreate", () => {
403386
{
404387
type: "Notice",
405388
options: {
406-
notice: {
407-
configuration: {
408-
noticeType: "notice",
409-
closable: false,
410-
kind: "info",
411-
scale: "m",
412-
},
413-
title: `{{${i18nScope}.sections.permissions.notice.title:translate}}`,
414-
message: `{{${i18nScope}.sections.permissions.notice.message:translate}}`,
415-
autoShow: true,
416-
actions: [
417-
{
418-
label: `{{${i18nScope}.sections.permissions.notice.action:translate}}`,
419-
href: "#readMore",
420-
target: "_blank",
421-
},
422-
],
423-
},
389+
noticeId: "20250311-channel-permissions-info",
424390
},
425391
},
426392
{

packages/common/test/channels/_internal/ChannelUiSchemaEdit.test.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,25 @@ describe("ChannelUiSchemaEdit", () => {
1616
} as unknown as IArcGISContext;
1717

1818
it("should return the schema from buildUiSchemaCreate", async () => {
19-
const expected: IUiSchema = {
19+
const createSchema: IUiSchema = {
2020
type: "Layout",
21+
elements: [],
2122
};
2223
const buildUiSchemaCreateSpy = spyOn(
2324
ChannelUiSchemaCreateModule,
2425
"buildUiSchema"
25-
).and.returnValue(expected);
26+
).and.returnValue(createSchema);
27+
const expected: IUiSchema = {
28+
...createSchema,
29+
elements: [
30+
{
31+
type: "Notice",
32+
options: {
33+
noticeId: "20250311-channel-edit-warning",
34+
},
35+
},
36+
],
37+
};
2638
const result = await buildUiSchema(i18nScope, options, context);
2739
expect(result).toEqual(expected);
2840
expect(buildUiSchemaCreateSpy).toHaveBeenCalledTimes(1);

0 commit comments

Comments
 (0)