-
Notifications
You must be signed in to change notification settings - Fork 10
/
notices.ts
127 lines (118 loc) · 4.23 KB
/
notices.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/** User role, i.e. who will see the notice. Defaults to "all" */
export enum Audience {
SysAdmin = "sysadmin",
TeamAdmin = "teamadmin",
Member = "member",
All = "all",
}
/** SKU. Defaults to "all" */
export enum SKU {
Team = "team",
E0 = "e0",
E10 = "e10",
E20 = "e20",
All = "all",
}
/** Instance type. Defaults to "both" */
export enum InstanceType {
Cloud = "cloud",
OnPrem = "onprem",
Both = "both"
}
/** Client type. Defaults to "all" */
export enum ClientType {
Desktop = "desktop",
Web = "web",
Mobile = "mobile",
MobileAndroid = "mobile-android",
MobileIOS = "mobile-ios",
All = "all"
}
/** Possible actions to execute on button press */
export enum Action {
URL = "url",
}
export type Conditions = {
audience?: Audience;
sku?: SKU;
instanceType?: InstanceType;
/** When to display the notice.
* Examples:
* "2020-03-01T00:00:00Z" - show on specified date
* ">= 2020-03-01T00:00:00Z" - show after specified date
* "< 2020-03-01T00:00:00Z" - show before the specified date
* "> 2020-03-01T00:00:00Z <= 2020-04-01T00:00:00Z" - show only between the specified dates
*/
displayDate?: string;
/**
* What server versions does this notice apply to.
* Format: semver ranges (https://devhints.io/semver)
* Example: [">=1.2.3 < ~2.4.x"]
* Example: ["<v5.19", "v5.20-v5.22"]
*/
serverVersion?: string[];
/**
* What mobile client versions does this notice apply to.
* Format: semver ranges (https://devhints.io/semver)
* Example: [">=1.2.3 < ~2.4.x"]
* Example: ["<v5.19", "v5.20-v5.22"]
*/
mobileVersion?: string[];
/**
* What desktop client versions does this notice apply to.
* Format: semver ranges (https://devhints.io/semver)
* Example: [">=1.2.3 < ~2.4.x"]
* Example: ["<v5.19", "v5.20-v5.22"]
*/
desktopVersion?: string[];
/**
* Map of mattermost server config paths and their values. Notice will be displayed only if the values match the target server config
* Example: serverConfig: { "PluginSettings.Enable": true, "GuestAccountsSettings.Enable": false }
*/
serverConfig?: Record<string, any>;
/**
* Map of user's settings and their values. Notice will be displayed only if the values match the viewing users' config
* Example: userConfig: { "new_sidebar.disabled": true }
*/
userConfig?: Record<string, any>;
/** Only show the notice when server has more than specified number of users */
numberOfUsers?: number;
/** Only show the notice when server has more than specified number of posts */
numberOfPosts?: number;
/** Only show the notice on specific clients. Defaults to 'all' */
clientType?: ClientType;
};
export type Message = {
/** Notice title. Use {{Mattermost}} instead of plain text to support white-labeling. Text supports Markdown. */
title: string;
/** Notice content. Use {{Mattermost}} instead of plain text to support white-labeling. Text supports Markdown. */
description: string;
image?: string;
/** Optional override for the action button text (defaults to OK) */
actionText?: string;
/** Optional action to perform on action button click. (defaults to closing the notice) */
action?: Action;
/** Optional action parameter.
* Example: {"action": "url", actionParam: "/console/some-page"}
*/
actionParam?: string;
}
export type ProductNotice = {
/** Unique identifier for this notice. Can be a running number. Used for storing 'viewed' state on the server. */
id: string;
conditions: Conditions;
/** Notice message data, organized by locale.
* Example:
* "localizedMessages": {
* "en-US": { "title": "English", description: "English description"},
* "fr-FR": { "title": "Frances", description: "French description"}
* }
*/
localizedMessages: Record<string, Message>;
/** Configurable flag if the notice should reappear after it’s seen and dismissed */
repeatable?: boolean;
}
/** List of product notices. Order is important and is used to resolve priorities.
* Each notice will only be show if conditions are met.
*/
export type ProductNotices = ProductNotice[];