Skip to content

Commit

Permalink
Remove features and feature_list usage in Notifications (#382)
Browse files Browse the repository at this point in the history
* Rename doesUserHas* access functions to doesUserHave*

Signed-off-by: Mohammad Qureshi <[email protected]>

* Upgrade to kotlin 1.6.10

Signed-off-by: Mohammad Qureshi <[email protected]>

* Remove usage of feature and feature_list in Notifications backend and fix compilation errors

Signed-off-by: Mohammad Qureshi <[email protected]>

* Remove usage of feature and feature_list in Notifications frontend

Signed-off-by: Mohammad Qureshi <[email protected]>
  • Loading branch information
qreshi authored Mar 18, 2022
1 parent 1abbb93 commit 6c56aa9
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 42 deletions.
2 changes: 0 additions & 2 deletions models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { WebhookMethodType } from '../public/pages/Channels/types';
import {
CHANNEL_TYPE,
ENCRYPTION_TYPE,
NOTIFICATION_SOURCE,
} from '../public/utils/constants';

export interface ChannelStatus {
Expand All @@ -31,7 +30,6 @@ export type SenderType = 'smtp_account' | 'ses_account';

export interface ChannelItemType extends ConfigType {
config_type: keyof typeof CHANNEL_TYPE;
feature_list: Array<keyof typeof NOTIFICATION_SOURCE>;
is_enabled: boolean; // active or muted
slack?: {
url: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export function ChannelDetailsActions(props: ChannelDetailsActionsProps) {
try {
await servicesContext.notificationService.sendTestMessage(
props.channel.config_id,
props.channel.feature_list[0]
);
coreContext.notifications.toasts.addSuccess(
'Successfully sent a test message.'
Expand All @@ -62,7 +61,6 @@ export function ChannelDetailsActions(props: ChannelDetailsActionsProps) {
{
label: 'Send test message',
disabled:
props.channel.feature_list.length === 0 ||
!props.channel.config_id ||
!props.channel.is_enabled,
action: sendTestMessage,
Expand Down
2 changes: 0 additions & 2 deletions public/pages/CreateChannel/CreateChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ export function CreateChannel(props: CreateChannelsProps) {
name,
description,
config_type: channelType,
feature_list: ['alerting'], // TODO: Remove this from config when the backend no longer requires it
is_enabled: isEnabled,
};
if (channelType === BACKEND_CHANNEL_TYPE.SLACK) {
Expand Down Expand Up @@ -327,7 +326,6 @@ export function CreateChannel(props: CreateChannelsProps) {

await servicesContext.notificationService.sendTestMessage(
tempChannelId,
config.feature_list[0] // for test message any source works
);
coreContext.notifications.toasts.addSuccess(
'Successfully sent a test message.'
Expand Down
2 changes: 0 additions & 2 deletions public/pages/Emails/__tests__/helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('creates sender and recipient groups as config object', () => {
expect(config).toEqual({
name: 'sender',
config_type: 'smtp_account',
feature_list: ['alerting', 'index_management', 'reports'],
is_enabled: true,
smtp_account: {
host: 'test.com',
Expand Down Expand Up @@ -52,7 +51,6 @@ describe('creates sender and recipient groups as config object', () => {
name: 'recipient group',
config_type: 'email_group',
description: 'test description',
feature_list: ['alerting', 'index_management', 'reports'],
is_enabled: true,
email_group: {
recipient_list: [
Expand Down
5 changes: 1 addition & 4 deletions public/pages/Emails/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { EuiComboBoxOptionOption } from '@elastic/eui';
import { ENCRYPTION_TYPE, NOTIFICATION_SOURCE } from '../../../utils/constants';
import { ENCRYPTION_TYPE } from '../../../utils/constants';

export const createSenderConfigObject = (
senderName: string,
Expand All @@ -16,7 +16,6 @@ export const createSenderConfigObject = (
return {
name: senderName,
config_type: 'smtp_account',
feature_list: Object.keys(NOTIFICATION_SOURCE),
is_enabled: true,
smtp_account: {
host,
Expand All @@ -36,7 +35,6 @@ export const createSesSenderConfigObject = (
return {
name: senderName,
config_type: 'ses_account',
feature_list: Object.keys(NOTIFICATION_SOURCE),
is_enabled: true,
ses_account: {
from_address: email,
Expand All @@ -55,7 +53,6 @@ export const createRecipientGroupConfigObject = (
name,
description,
config_type: 'email_group',
feature_list: Object.keys(NOTIFICATION_SOURCE),
is_enabled: true,
email_group: {
recipient_list: selectedEmailOptions.map((email) => ({
Expand Down
12 changes: 3 additions & 9 deletions public/services/NotificationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
SenderType,
SESSenderItemType,
} from '../../models/interfaces';
import {CHANNEL_TYPE, NOTIFICATION_SOURCE} from '../utils/constants';
import { CHANNEL_TYPE } from '../utils/constants';
import {
configListToChannels,
configListToRecipientGroups,
Expand Down Expand Up @@ -244,16 +244,10 @@ export default class NotificationService {
};

sendTestMessage = async (
configId: string,
feature: keyof typeof NOTIFICATION_SOURCE
configId: string
) => {
const response = await this.httpClient.get(
`${NODE_API.SEND_TEST_MESSAGE}/${configId}`,
{
query: {
feature,
},
}
`${NODE_API.SEND_TEST_MESSAGE}/${configId}`
);
if (response.event_id != null) {
await this.getNotification(response.event_id).then((response) => {
Expand Down
6 changes: 0 additions & 6 deletions public/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ export const BREADCRUMBS = Object.freeze({
EDIT_RECIPIENT_GROUP: { text: 'Edit recipient group' },
});

export const NOTIFICATION_SOURCE = Object.freeze({
alerting: 'Alerting',
index_management: 'ISM',
reports: 'Reporting',
});

export const BACKEND_CHANNEL_TYPE = Object.freeze({
SLACK: 'slack',
EMAIL: 'email',
Expand Down
5 changes: 0 additions & 5 deletions server/routes/configRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ export function configRoutes(router: IRouter) {
schema.arrayOf(schema.string()),
schema.string(),
]),
feature_list: schema.maybe(
schema.oneOf([schema.arrayOf(schema.string()), schema.string()])
),
is_enabled: schema.maybe(schema.boolean()),
sort_field: schema.string(),
sort_order: schema.string(),
Expand All @@ -41,7 +38,6 @@ export function configRoutes(router: IRouter) {
},
async (context, request, response) => {
const config_type = joinRequestParams(request.query.config_type);
const feature_list = joinRequestParams(request.query.feature_list);
const config_id_list = joinRequestParams(request.query.config_id_list);
const encryption_method = joinRequestParams(
request.query['smtp_account.method']
Expand All @@ -61,7 +57,6 @@ export function configRoutes(router: IRouter) {
sort_field: request.query.sort_field,
sort_order: request.query.sort_order,
config_type,
...(feature_list && { feature_list }),
...(query && { text_query: query }), // text_query will exclude keyword fields
...(config_id_list && { config_id_list }),
...(encryption_method && {
Expand Down
4 changes: 0 additions & 4 deletions server/routes/eventRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ export function eventRoutes(router: IRouter) {
params: schema.object({
configId: schema.string(),
}),
query: schema.object({
feature: schema.string(),
}),
},
},
async (context, request, response) => {
Expand All @@ -62,7 +59,6 @@ export function eventRoutes(router: IRouter) {
'notifications.sendTestMessage',
{
configId: request.params.configId,
feature: request.query.feature,
}
);
return response.ok({ body: resp });
Expand Down
6 changes: 0 additions & 6 deletions test/mocks/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const mockChime: ChannelItemType = {
name: 'Chime test channel',
description: 'test description',
config_type: 'chime',
feature_list: ['reports'],
is_enabled: true,
chime: {
url: 'https://chimehook',
Expand All @@ -28,7 +27,6 @@ const mockSlack: ChannelItemType = {
name: 'Slack test channel',
description: 'test description',
config_type: 'slack',
feature_list: ['reports'],
is_enabled: false,
slack: {
url: 'https://chimehook',
Expand All @@ -42,7 +40,6 @@ const mockEmail: ChannelItemType = {
name: 'Email test channel',
description: 'test description',
config_type: 'email',
feature_list: ['alerting'],
is_enabled: true,
email: {
email_account_id: 'dj8etXkBCzVy9Vy-nsiL',
Expand Down Expand Up @@ -76,7 +73,6 @@ const mockEmailWithSES: ChannelItemType = {
name: 'Email test channel',
description: 'test description',
config_type: 'email',
feature_list: ['alerting'],
is_enabled: true,
email: {
email_account_id: 'dj8etXkBCzVy9Vy-nsiL',
Expand Down Expand Up @@ -110,7 +106,6 @@ const mockWebhook: ChannelItemType = {
name: 'Webhook test channel',
description: 'test description',
config_type: 'webhook',
feature_list: ['alerting'],
is_enabled: true,
webhook: {
url: 'https://host:23/path?key1=%23%404&key2=&key3=value3',
Expand All @@ -133,7 +128,6 @@ const mockSNS: ChannelItemType = {
name: 'SNS test channel',
description: 'test description',
config_type: 'sns',
feature_list: ['alerting'],
is_enabled: true,
sns: {
topic_arn: 'arn:aws:sns:us-west-2:012345678912:notifications-test',
Expand Down

0 comments on commit 6c56aa9

Please sign in to comment.