diff --git a/frontend/app/components/shared/SharePopup/SessionCopyLink/SessionCopyLink.tsx b/frontend/app/components/shared/SharePopup/SessionCopyLink/SessionCopyLink.tsx
index ce41b3800..9d9e49963 100644
--- a/frontend/app/components/shared/SharePopup/SessionCopyLink/SessionCopyLink.tsx
+++ b/frontend/app/components/shared/SharePopup/SessionCopyLink/SessionCopyLink.tsx
@@ -9,7 +9,8 @@ import { DateTime } from 'luxon';
function SessionCopyLink({ startedAt }: any) {
const [copied, setCopied] = React.useState(false);
const { store } = React.useContext(PlayerContext);
- const time = store.get().time;
+
+ const time = store?.get().time;
const copyHandler = () => {
setCopied(true);
diff --git a/frontend/app/components/shared/SharePopup/SharePopup.js b/frontend/app/components/shared/SharePopup/SharePopup.js
deleted file mode 100644
index 9cebad02a..000000000
--- a/frontend/app/components/shared/SharePopup/SharePopup.js
+++ /dev/null
@@ -1,211 +0,0 @@
-import React from 'react';
-import { connect } from 'react-redux';
-import { toast } from 'react-toastify';
-import { Form, Button, Popover, Loader } from 'UI';
-import styles from './sharePopup.module.css';
-import IntegrateSlackButton from '../IntegrateSlackButton/IntegrateSlackButton';
-import SessionCopyLink from './SessionCopyLink';
-import Select from 'Shared/Select';
-import cn from 'classnames';
-import { fetchList as fetchSlack, sendSlackMsg } from 'Duck/integrations/slack';
-import { fetchList as fetchTeams, sendMsTeamsMsg } from 'Duck/integrations/teams';
-
-@connect(
- (state) => ({
- sessionId: state.getIn(['sessions', 'current']).sessionId,
- channels: state.getIn(['slack', 'list']),
- slackLoaded: state.getIn(['slack', 'loaded']),
- msTeamsChannels: state.getIn(['teams', 'list']),
- msTeamsLoaded: state.getIn(['teams', 'loaded']),
- tenantId: state.getIn(['user', 'account', 'tenantId']),
- }),
- { fetchSlack, fetchTeams, sendSlackMsg, sendMsTeamsMsg }
-)
-export default class SharePopup extends React.PureComponent {
- state = {
- comment: '',
- isOpen: false,
- channelId: this.props.channels.getIn([0, 'webhookId']),
- teamsChannel: this.props.msTeamsChannels.getIn([0, 'webhookId']),
- loadingSlack: false,
- loadingTeams: false,
- };
-
- componentDidUpdate() {
- if (this.state.isOpen) {
- if (this.props.channels.size === 0 && !this.props.slackLoaded) {
- this.props.fetchSlack();
- }
- if (this.props.msTeamsChannels.size === 0 && !this.props.msTeamsLoaded) {
- this.props.fetchTeams();
- }
- }
- }
-
- editMessage = (e) => this.setState({ comment: e.target.value });
- shareToSlack = () => {
- this.setState({ loadingSlack: true }, () => {
- this.props
- .sendSlackMsg({
- integrationId: this.state.channelId,
- entity: 'sessions',
- entityId: this.props.sessionId,
- data: { comment: this.state.comment },
- })
- .then(() => this.handleSuccess('Slack'));
- });
- };
-
- shareToMSTeams = () => {
- this.setState({ loadingTeams: true }, () => {
- this.props
- .sendMsTeamsMsg({
- integrationId: this.state.teamsChannel,
- entity: 'sessions',
- entityId: this.props.sessionId,
- data: { comment: this.state.comment },
- })
- .then(() => this.handleSuccess('MS Teams'));
- });
- };
-
- handleOpen = () => {
- setTimeout(function () {
- document.getElementById('message').focus();
- }, 100);
- };
-
- handleClose = () => {
- this.setState({ comment: '' });
- };
-
- handleSuccess = (endpoint) => {
- const obj = endpoint === 'Slack' ? { loadingSlack: false } : { loadingTeams: false };
- this.setState(obj);
- toast.success(`Sent to ${endpoint}.`);
- };
-
- changeSlackChannel = ({ value }) => this.setState({ channelId: value.value });
-
- changeTeamsChannel = ({ value }) => this.setState({ teamsChannel: value.value });
-
- onClickHandler = () => {
- this.setState({ isOpen: true });
- };
-
- render() {
- const { trigger, channels, msTeamsChannels, showCopyLink = false } = this.props;
- const { comment, channelId, teamsChannel, loadingSlack, loadingTeams } = this.state;
-
- const slackOptions = channels
- .map(({ webhookId, name }) => ({ value: webhookId, label: name }))
- .toJS();
-
- const msTeamsOptions = msTeamsChannels
- .map(({ webhookId, name }) => ({ value: webhookId, label: name }))
- .toJS();
-
- return (
-
this.setState({ isOpen: true })}
- onClose={() => this.setState({ isOpen: false, comment: '' })}
- render={() => (
-
- {this.state.loadingTeams || this.state.loadingSlack ? (
-
- ) : (
- <>
-
- Share
-
- {slackOptions.length > 0 || msTeamsOptions.length > 0 ? (
-
-
-
-
- {slackOptions.length > 0 && (
-
-
-
-
- {this.state.channelId && (
-
- )}
-
-
- )}
- {msTeamsOptions.length > 0 && (
-
-
-
-
- {this.state.teamsChannel && (
-
- )}
-
-
- )}
-
-
-
-
-
- ) : (
- <>
-
-
-
- {showCopyLink && (
- <>
-
-
-
-
- >
- )}
- >
- )}
- >
- )}
-
- )}
- >
- {trigger}
-
- );
- }
-}
diff --git a/frontend/app/components/shared/SharePopup/SharePopup.tsx b/frontend/app/components/shared/SharePopup/SharePopup.tsx
new file mode 100644
index 000000000..ee55216ce
--- /dev/null
+++ b/frontend/app/components/shared/SharePopup/SharePopup.tsx
@@ -0,0 +1,289 @@
+import { useModal } from 'Components/Modal';
+import React, { useState, useEffect } from 'react';
+import { connect } from 'react-redux';
+import { toast } from 'react-toastify';
+import { Icon, Loader } from 'UI';
+import styles from './sharePopup.module.css';
+import IntegrateSlackButton from '../IntegrateSlackButton/IntegrateSlackButton';
+import SessionCopyLink from './SessionCopyLink';
+import Select from 'Shared/Select';
+import { fetchList as fetchSlack, sendSlackMsg } from 'Duck/integrations/slack';
+import { fetchList as fetchTeams, sendMsTeamsMsg } from 'Duck/integrations/teams';
+import { Button, Segmented } from 'antd';
+
+interface Msg {
+ integrationId: string;
+ entity: 'sessions';
+ entityId: string;
+ data: { comment: string };
+}
+
+const SharePopup = ({
+ trigger,
+ showCopyLink = false,
+}: {
+ trigger: string;
+ showCopyLink?: boolean;
+}) => {
+ const { showModal, hideModal } = useModal();
+
+ const openModal = () => {
+ showModal(
+
,
+ { right: true, width: 300 }
+ );
+ };
+
+ return (
+
+ {trigger}
+
+ );
+};
+
+
+interface Props {
+ sessionId: string;
+ channels: { webhookId: string; name: string }[];
+ slackLoaded: boolean;
+ msTeamsChannels: { webhookId: string; name: string }[];
+ msTeamsLoaded: boolean;
+ tenantId: string;
+ fetchSlack: () => void;
+ fetchTeams: () => void;
+ sendSlackMsg: (msg: Msg) => any;
+ sendMsTeamsMsg: (msg: Msg) => any;
+ showCopyLink?: boolean;
+ hideModal: () => void;
+}
+
+function ShareModalComp({
+ sessionId,
+ sendSlackMsg,
+ sendMsTeamsMsg,
+ showCopyLink,
+ channels,
+ slackLoaded,
+ msTeamsChannels,
+ msTeamsLoaded,
+ fetchSlack,
+ fetchTeams,
+ hideModal,
+}: Props) {
+ const [shareTo, setShareTo] = useState('slack');
+ const [comment, setComment] = useState('');
+ // @ts-ignore
+ const [channelId, setChannelId] = useState(channels.getIn([0, 'webhookId']));
+ // @ts-ignore
+ const [teamsChannel, setTeamsChannel] = useState(msTeamsChannels.getIn([0, 'webhookId']));
+ const [loadingSlack, setLoadingSlack] = useState(false);
+ const [loadingTeams, setLoadingTeams] = useState(false);
+
+ const isLoading = loadingSlack || loadingTeams;
+
+ useEffect(() => {
+ // @ts-ignore
+ if (channels.size === 0 && !slackLoaded) {
+ fetchSlack();
+ }
+ // @ts-ignore
+ if (msTeamsChannels.size === 0 && !msTeamsLoaded) {
+ fetchTeams();
+ }
+ }, [channels, slackLoaded, msTeamsChannels, msTeamsLoaded, fetchSlack, fetchTeams]);
+
+ const editMessage = (e: React.ChangeEvent
) => setComment(e.target.value);
+ const shareToSlack = () => {
+ setLoadingSlack(true);
+ sendSlackMsg({
+ integrationId: channelId,
+ entity: 'sessions',
+ entityId: sessionId,
+ data: { comment },
+ }).then(() => handleSuccess('Slack'));
+ };
+
+ const shareToMSTeams = () => {
+ setLoadingTeams(true);
+ sendMsTeamsMsg({
+ integrationId: teamsChannel,
+ entity: 'sessions',
+ entityId: sessionId,
+ data: { comment },
+ }).then(() => handleSuccess('MS Teams'));
+ };
+
+ const handleSuccess = (endpoint: string) => {
+ if (endpoint === 'Slack') {
+ setLoadingSlack(false);
+ } else {
+ setLoadingTeams(false);
+ }
+ // @ts-ignore
+ toast.success(`Sent to ${endpoint}.`);
+ };
+
+ const changeSlackChannel = (value: any) => setChannelId(value.value);
+ const changeTeamsChannel = (value: any) => setTeamsChannel(value.value);
+
+ const slackOptions = channels
+ .map(({ webhookId, name }) => ({
+ value: webhookId,
+ label: name,
+ }))
+ // @ts-ignore
+ .toJS();
+
+ const msTeamsOptions = msTeamsChannels
+ .map(({ webhookId, name }) => ({
+ value: webhookId,
+ label: name,
+ }))
+ // @ts-ignore
+ .toJS();
+
+ const sendMsg = () => {
+ if (shareTo === 'slack') {
+ shareToSlack();
+ } else {
+ shareToMSTeams();
+ }
+ hideModal();
+ }
+ const hasBoth = slackOptions.length > 0 && msTeamsOptions.length > 0;
+ const hasNothing = slackOptions.length === 0 && msTeamsOptions.length === 0;
+ return (
+
+ {isLoading ? (
+
+ ) : (
+ <>
+
+ {!hasNothing ? (
+
+
+
+
+ Share via
+
+ {hasBoth ? (
+
+
+ Slack
+ ,
+ value: 'slack',
+ },
+ {
+ label:
,
+ value: 'teams',
+ },
+ ]}
+ onChange={(value) => setShareTo(value as 'slack' | 'teams')}
+ />
+ ) : (
+
+
0
+ ? 'integrations/slack-bw'
+ : 'integrations/teams-white'
+ }
+ />
+ {slackOptions.length > 0 ? 'Slack' : 'MS Teams'}
+
+ )}
+
+
+
+
Select a channel or individual
+ {shareTo === 'slack' ? (
+
+ ) : (
+
+ )}
+
+
+
+
+
+
+
+
+
+
+
+
+ ) : (
+ <>
+
+
+
+ {showCopyLink && (
+ <>
+
+
+
+
+ >
+ )}
+ >
+ )}
+ >
+ )}
+
+ );
+}
+
+const mapStateToProps = (state: Record