Skip to content

Commit eeba709

Browse files
committed
feat: added Custom Channel event type
1 parent 10aede0 commit eeba709

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

src/main/default/classes/StreamingMonitorController.cls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ public abstract class StreamingMonitorController {
55
public final static String EVT_PLATFORM_EVENT = 'PlatformEvent';
66
public final static String EVT_CDC_STANDARD = 'ChangeDataCaptureEvent';
77
public final static String EVT_CDC_CUSTOM = 'CustomCDC';
8+
public final static String EVT_CUSTOM_CHANNEL = 'CustomChannel';
89
public final static String EVT_MONITORING = 'MonitoringEvent';
910

1011
private final static List<String> MONITORING_EVENTS = new List<String>{
@@ -58,6 +59,7 @@ public abstract class StreamingMonitorController {
5859
channels.put(EVT_PLATFORM_EVENT, getPlatformEventChannels());
5960
channels.put(EVT_CDC_STANDARD, getChangeDataCaptureEventChannels());
6061
channels.put(EVT_CDC_CUSTOM, new List<ComboBoxItem>());
62+
channels.put(EVT_CUSTOM_CHANNEL, new List<ComboBoxItem>());
6163
channels.put(EVT_MONITORING, getEventMonitoringChannels());
6264
return channels;
6365
}

src/main/default/lwc/actions/actions.js

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
EVT_PLATFORM_EVENT,
99
EVT_CDC_STANDARD,
1010
EVT_CDC_CUSTOM,
11+
EVT_CUSTOM_CHANNEL,
1112
EVT_MONITORING,
1213
getChannelPrefix
1314
} from 'c/streamingUtility';
@@ -103,10 +104,14 @@ export default class Actions extends LightningElement {
103104
handleSubEventTypeChange(event) {
104105
this.subEventType = event.detail.value;
105106
this.subEventName = undefined;
106-
this.subChannel =
107-
this.subEventType === EVT_CDC_CUSTOM
108-
? getChannelPrefix(EVT_CDC_CUSTOM)
109-
: '';
107+
if (
108+
this.subEventType === EVT_CDC_CUSTOM ||
109+
this.subEventType === EVT_CUSTOM_CHANNEL
110+
) {
111+
this.subChannel = getChannelPrefix(this.subEventType);
112+
} else {
113+
this.subChannel = '';
114+
}
110115
}
111116

112117
handleSubEventNameChange(event) {
@@ -167,6 +172,8 @@ export default class Actions extends LightningElement {
167172
}
168173
if (this.subEventType === EVT_CDC_CUSTOM) {
169174
return 'The /data/ChangeEvents channel and custom channels require manual channel input';
175+
} else if (this.subEventType === EVT_CUSTOM_CHANNEL) {
176+
return 'Custom channels require manual channel input';
170177
}
171178
const eventDefinition = EVENT_TYPES.find(
172179
(e) => e.value === this.subEventType
@@ -185,15 +192,26 @@ export default class Actions extends LightningElement {
185192
}
186193

187194
get isSubChannelDisabled() {
188-
return this.subEventType !== EVT_CDC_CUSTOM;
195+
return (
196+
this.subEventType !== EVT_CDC_CUSTOM &&
197+
this.subEventType !== EVT_CUSTOM_CHANNEL
198+
);
189199
}
190200

191201
get isSubscribeDisabled() {
202+
if (
203+
this.subEventType === EVT_CDC_CUSTOM ||
204+
this.subEventType === EVT_CUSTOM_CHANNEL
205+
) {
206+
const channel = this.subChannel.trim();
207+
return (
208+
channel === '' ||
209+
channel === getChannelPrefix(this.subEventType)
210+
);
211+
}
192212
return (
193-
(this.subEventType === EVT_CDC_CUSTOM &&
194-
this.subChannel.trim() === '') ||
195-
(this.subEventType !== EVT_CDC_CUSTOM &&
196-
this.subEventName === undefined)
213+
this.subEventType !== EVT_CDC_CUSTOM &&
214+
this.subEventName === undefined
197215
);
198216
}
199217

src/main/default/lwc/streamingUtility/streamingUtility.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const EVT_STD_PLATFORM_EVENT = 'StandardPlatformEvent';
44
export const EVT_PLATFORM_EVENT = 'PlatformEvent';
55
export const EVT_CDC_STANDARD = 'ChangeDataCaptureEvent';
66
export const EVT_CDC_CUSTOM = 'CustomCDC';
7+
export const EVT_CUSTOM_CHANNEL = 'CustomChannel';
78
export const EVT_MONITORING = 'MonitoringEvent';
89

910
export const CHANNEL_ALL_CDC = '/data/ChangeEvents';
@@ -29,6 +30,11 @@ export const EVENT_TYPES = [
2930
value: EVT_PLATFORM_EVENT,
3031
channelPrefix: '/event/'
3132
},
33+
{
34+
label: 'Custom Channel',
35+
value: EVT_CUSTOM_CHANNEL,
36+
channelPrefix: '/event/'
37+
},
3238
{
3339
label: 'Change Data Capture event',
3440
value: EVT_CDC_STANDARD,

0 commit comments

Comments
 (0)