1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00
unleash.unleash/src/lib/addons/slack-app-definition.ts
Nuno Góis d6c8493156
feat: slack app addon default channels (#4308)
https://linear.app/unleash/issue/2-1249/add-support-for-default-slack-channels

Adds support for default Slack channels (multiple, comma-separated). 

Some of the events we are handling do not have associated tags, or maybe
the tags are empty. This adds a "default Slack channels" parameter to
the addon configuration in order to post messages to those channels in
those cases.

<img width="643" alt="image"
src="https://github.com/Unleash/unleash/assets/14320932/ee23d6c7-33b7-4968-a0b1-13b546b5b2a2">

---------

Co-authored-by: Gastón Fournier <gaston@getunleash.io>
2023-07-21 14:15:43 +01:00

89 lines
3.0 KiB
TypeScript

import {
FEATURE_CREATED,
FEATURE_UPDATED,
FEATURE_ARCHIVED,
FEATURE_REVIVED,
FEATURE_STALE_ON,
FEATURE_STALE_OFF,
FEATURE_ENVIRONMENT_ENABLED,
FEATURE_ENVIRONMENT_DISABLED,
FEATURE_STRATEGY_REMOVE,
FEATURE_STRATEGY_UPDATE,
FEATURE_STRATEGY_ADD,
FEATURE_METADATA_UPDATED,
FEATURE_PROJECT_CHANGE,
FEATURE_VARIANTS_UPDATED,
FEATURE_POTENTIALLY_STALE_ON,
} from '../types/events';
import { IAddonDefinition } from '../types/model';
const slackAppDefinition: IAddonDefinition = {
name: 'slack-app',
displayName: 'Slack App',
description:
'The Unleash Slack App posts messages to your Slack workspace. You can decide which channels to post to by configuring your feature toggles with "slack" tags. For example, if you\'d like the bot to post messages to the #general channel, you should configure your feature toggle with the "slack:general" tag.',
documentationUrl: 'https://docs.getunleash.io/docs/addons/slack-app',
alerts: [
{
type: 'info',
text: `The Unleash Slack App bot has access to public channels by default. If you want the bot to post messages to private channels, you'll need to invite it to those channels.`,
},
{
type: 'warning',
text: `Please ensure you have the Unleash Slack App installed in your Slack workspace if you haven't installed it already.`,
},
],
installation: {
url: 'https://unleash-slack-app.vercel.app/install',
title: 'Slack App installation',
helpText:
'After installing the Unleash Slack app in your Slack workspace, paste the access token into the appropriate field below in order to configure this addon.',
},
parameters: [
{
name: 'accessToken',
displayName: 'Access token',
description: '(Required)',
type: 'text',
required: true,
sensitive: true,
},
{
name: 'defaultChannels',
displayName: 'Default channels',
description:
'A comma-separated list of channels to post to if no tagged channels are found (e.g. a toggle without tags, or an event with no tags associated).',
type: 'text',
required: false,
sensitive: false,
},
],
events: [
FEATURE_CREATED,
FEATURE_UPDATED,
FEATURE_ARCHIVED,
FEATURE_REVIVED,
FEATURE_STALE_ON,
FEATURE_STALE_OFF,
FEATURE_ENVIRONMENT_ENABLED,
FEATURE_ENVIRONMENT_DISABLED,
FEATURE_STRATEGY_REMOVE,
FEATURE_STRATEGY_UPDATE,
FEATURE_STRATEGY_ADD,
FEATURE_METADATA_UPDATED,
FEATURE_VARIANTS_UPDATED,
FEATURE_PROJECT_CHANGE,
FEATURE_POTENTIALLY_STALE_ON,
],
tagTypes: [
{
name: 'slack',
description:
'Slack tag used by the slack-addon to specify the slack channel.',
icon: 'S',
},
],
};
export default slackAppDefinition;