From 001879b012af3a5e62467d93883fcf36be358e49 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Tue, 22 Oct 2024 14:25:17 +0100 Subject: [PATCH] re-use a json schema type for icons --- .../messages/new-tab/types/rmf-message.json | 41 ++++++++----------- special-pages/types/new-tab.ts | 7 ++-- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/special-pages/messages/new-tab/types/rmf-message.json b/special-pages/messages/new-tab/types/rmf-message.json index 4110572e65..25df8891e8 100644 --- a/special-pages/messages/new-tab/types/rmf-message.json +++ b/special-pages/messages/new-tab/types/rmf-message.json @@ -50,14 +50,8 @@ "type": "string" }, "icon": { - "enum": [ - "Announce", - "DDGAnnounce", - "CriticalUpdate", - "AppUpdate", - "PrivacyPro" - ] - }, + "$ref": "#/definitions/rmf-icon" + } }, "required": [ "messageType", @@ -84,13 +78,7 @@ "type": "string" }, "icon": { - "enum": [ - "Announce", - "DDGAnnounce", - "CriticalUpdate", - "AppUpdate", - "PrivacyPro" - ] + "$ref": "#/definitions/rmf-icon" }, "primaryActionText": { "type": "string" @@ -122,13 +110,7 @@ "type": "string" }, "icon": { - "enum": [ - "Announce", - "DDGAnnounce", - "CriticalUpdate", - "AppUpdate", - "PrivacyPro" - ] + "$ref": "#/definitions/rmf-icon" }, "primaryActionText": { "type": "string" @@ -149,5 +131,18 @@ } ] } + }, + "definitions": { + "rmf-icon": { + "title": "RMF Icon", + "type": "string", + "enum": [ + "Announce", + "DDGAnnounce", + "CriticalUpdate", + "AppUpdate", + "PrivacyPro" + ] + } } -} \ No newline at end of file +} diff --git a/special-pages/types/new-tab.ts b/special-pages/types/new-tab.ts index 312c23b083..f713b7cbf0 100644 --- a/special-pages/types/new-tab.ts +++ b/special-pages/types/new-tab.ts @@ -27,6 +27,7 @@ export type WidgetConfigs = WidgetConfigItem[]; */ export type Widgets = WidgetListItem[]; export type RMFMessage = SmallMessage | MediumMessage | BigSingleActionMessage | BigTwoActionMessage; +export type RMFIcon = "Announce" | "DDGAnnounce" | "CriticalUpdate" | "AppUpdate" | "PrivacyPro"; /** * Requests, Notifications and Subscriptions from the NewTab feature @@ -157,14 +158,14 @@ export interface MediumMessage { id: string; titleText: string; descriptionText: string; - icon: "Announce" | "DDGAnnounce" | "CriticalUpdate" | "AppUpdate" | "PrivacyPro"; + icon: RMFIcon; } export interface BigSingleActionMessage { messageType: "big_single_action"; id: string; titleText: string; descriptionText: string; - icon: "Announce" | "DDGAnnounce" | "CriticalUpdate" | "AppUpdate" | "PrivacyPro"; + icon: RMFIcon; primaryActionText: string; } export interface BigTwoActionMessage { @@ -172,7 +173,7 @@ export interface BigTwoActionMessage { id: string; titleText: string; descriptionText: string; - icon: "Announce" | "DDGAnnounce" | "CriticalUpdate" | "AppUpdate" | "PrivacyPro"; + icon: RMFIcon; primaryActionText: string; secondaryActionText: string; }