feat(notifications): add slack notification agent

re #365
This commit is contained in:
sct
2020-12-25 19:02:04 +09:00
parent 5d06a34731
commit 1163e81adc
12 changed files with 657 additions and 24 deletions

View File

@@ -2,6 +2,8 @@ import Link from 'next/link';
import { useRouter } from 'next/router';
import React from 'react';
import { defineMessages, useIntl } from 'react-intl';
import DiscordLogo from '../../assets/extlogos/discord_white.svg';
import SlackLogo from '../../assets/extlogos/slack.svg';
const messages = defineMessages({
notificationsettings: 'Notification Settings',
@@ -10,31 +12,64 @@ const messages = defineMessages({
});
interface SettingsRoute {
text: string;
text: React.ReactNode;
route: string;
regex: RegExp;
}
const settingsRoutes: SettingsRoute[] = [
{
text: 'Email',
text: (
<span className="flex items-center">
<svg
className="h-4 mr-2"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207"
/>
</svg>
Email
</span>
),
route: '/settings/notifications/email',
regex: /^\/settings\/notifications\/email/,
},
{
text: 'Discord',
text: (
<span className="flex items-center">
<DiscordLogo className="h-4 mr-2" />
Discord
</span>
),
route: '/settings/notifications/discord',
regex: /^\/settings\/notifications\/discord/,
},
{
text: (
<span className="flex items-center">
<SlackLogo className="h-4 mr-2" />
Slack
</span>
),
route: '/settings/notifications/slack',
regex: /^\/settings\/notifications\/slack/,
},
];
const SettingsNotifications: React.FC = ({ children }) => {
const router = useRouter();
const intl = useIntl();
const activeLinkColor = 'bg-gray-700';
const activeLinkColor = 'bg-indigo-700';
const inactiveLinkColor = '';
const inactiveLinkColor = 'bg-gray-800';
const SettingsLink: React.FC<{
route: string;
@@ -62,10 +97,10 @@ const SettingsNotifications: React.FC = ({ children }) => {
return (
<>
<div className="mb-6">
<h3 className="text-lg leading-6 font-medium text-gray-200">
<h3 className="text-lg font-medium leading-6 text-gray-200">
{intl.formatMessage(messages.notificationsettings)}
</h3>
<p className="mt-1 max-w-2xl text-sm leading-5 text-gray-500">
<p className="max-w-2xl mt-1 text-sm leading-5 text-gray-500">
{intl.formatMessage(messages.notificationsettingsDescription)}
</p>
</div>
@@ -87,7 +122,7 @@ const SettingsNotifications: React.FC = ({ children }) => {
)?.route
}
aria-label="Selected tab"
className="bg-gray-800 text-white mt-1 rounded-md form-select block w-full pl-3 pr-10 py-2 text-base leading-6 border-gray-700 focus:outline-none focus:ring-blue focus:border-blue-300 sm:text-sm sm:leading-5 transition ease-in-out duration-150"
className="block w-full py-2 pl-3 pr-10 mt-1 text-base leading-6 text-white transition duration-150 ease-in-out bg-gray-800 border-gray-700 rounded-md form-select focus:outline-none focus:ring-blue focus:border-blue-300 sm:text-sm sm:leading-5"
>
{settingsRoutes.map((route, index) => (
<SettingsLink