|
@@ -6,7 +6,6 @@ import { useTranslation } from 'next-i18next';
|
|
|
import { useRouter } from 'next/router';
|
|
import { useRouter } from 'next/router';
|
|
|
|
|
|
|
|
import { NotifyType, TriggerEventType } from '~/client/interfaces/global-notification';
|
|
import { NotifyType, TriggerEventType } from '~/client/interfaces/global-notification';
|
|
|
-import AdminNotificationContainer from '~/client/services/AdminNotificationContainer';
|
|
|
|
|
import { toastError } from '~/client/util/apiNotification';
|
|
import { toastError } from '~/client/util/apiNotification';
|
|
|
import { apiv3Post } from '~/client/util/apiv3-client';
|
|
import { apiv3Post } from '~/client/util/apiv3-client';
|
|
|
import { useIsMailerSetup } from '~/stores/context';
|
|
import { useIsMailerSetup } from '~/stores/context';
|
|
@@ -14,7 +13,6 @@ import { useSWRxGlobalNotification } from '~/stores/global-notification';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
|
|
|
|
|
-import { withUnstatedContainers } from '../../UnstatedUtils';
|
|
|
|
|
import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
|
|
import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
|
|
|
|
|
|
|
|
import TriggerEventCheckBox from './TriggerEventCheckBox';
|
|
import TriggerEventCheckBox from './TriggerEventCheckBox';
|
|
@@ -24,11 +22,9 @@ const logger = loggerFactory('growi:manageGlobalNotification');
|
|
|
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
- adminNotificationContainer: AdminNotificationContainer,
|
|
|
|
|
globalNotificationId?: string,
|
|
globalNotificationId?: string,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
const ManageGlobalNotification = (props: Props): JSX.Element => {
|
|
const ManageGlobalNotification = (props: Props): JSX.Element => {
|
|
|
|
|
|
|
|
const [triggerPath, setTriggerPath] = useState('');
|
|
const [triggerPath, setTriggerPath] = useState('');
|
|
@@ -36,7 +32,7 @@ const ManageGlobalNotification = (props: Props): JSX.Element => {
|
|
|
const [emailToSend, setEmailToSend] = useState('');
|
|
const [emailToSend, setEmailToSend] = useState('');
|
|
|
const [slackChannelToSend, setSlackChannelToSend] = useState('');
|
|
const [slackChannelToSend, setSlackChannelToSend] = useState('');
|
|
|
const [triggerEvents, setTriggerEvents] = useState(new Set());
|
|
const [triggerEvents, setTriggerEvents] = useState(new Set());
|
|
|
- const { data: globalNotificationData, update: updateGlobalNotification } = useSWRxGlobalNotification(props.globalNotificationId || '');
|
|
|
|
|
|
|
+ const { data: globalNotificationData, update: updateGlobalNotification } = useSWRxGlobalNotification(props.notificationId || '');
|
|
|
const globalNotification = useMemo(() => globalNotificationData?.globalNotification, [globalNotificationData?.globalNotification]);
|
|
const globalNotification = useMemo(() => globalNotificationData?.globalNotification, [globalNotificationData?.globalNotification]);
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
@@ -92,10 +88,8 @@ const ManageGlobalNotification = (props: Props): JSX.Element => {
|
|
|
triggerEvents: [...triggerEvents],
|
|
triggerEvents: [...triggerEvents],
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const globalNotificationId = globalNotification?._id;
|
|
|
|
|
-
|
|
|
|
|
try {
|
|
try {
|
|
|
- if (globalNotificationId != null) {
|
|
|
|
|
|
|
+ if (props.globalNotificationId != null) {
|
|
|
await updateGlobalNotification(requestParams);
|
|
await updateGlobalNotification(requestParams);
|
|
|
router.push('/admin/notification');
|
|
router.push('/admin/notification');
|
|
|
}
|
|
}
|
|
@@ -108,11 +102,10 @@ const ManageGlobalNotification = (props: Props): JSX.Element => {
|
|
|
toastError(err);
|
|
toastError(err);
|
|
|
logger.error(err);
|
|
logger.error(err);
|
|
|
}
|
|
}
|
|
|
- }, [emailToSend, globalNotification, notifyType, router, slackChannelToSend, triggerEvents, triggerPath, updateGlobalNotification]);
|
|
|
|
|
|
|
+ }, [emailToSend, notifyType, props.globalNotificationId, router, slackChannelToSend, triggerEvents, triggerPath, updateGlobalNotification]);
|
|
|
|
|
|
|
|
|
|
|
|
|
const { data: isMailerSetup } = useIsMailerSetup();
|
|
const { data: isMailerSetup } = useIsMailerSetup();
|
|
|
- const { adminNotificationContainer } = props;
|
|
|
|
|
const { t } = useTranslation('admin');
|
|
const { t } = useTranslation('admin');
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -315,13 +308,10 @@ const ManageGlobalNotification = (props: Props): JSX.Element => {
|
|
|
|
|
|
|
|
<AdminUpdateButtonRow
|
|
<AdminUpdateButtonRow
|
|
|
onClick={updateButtonClickedHandler}
|
|
onClick={updateButtonClickedHandler}
|
|
|
- disabled={adminNotificationContainer.state.retrieveError != null}
|
|
|
|
|
|
|
+ disabled={false}
|
|
|
/>
|
|
/>
|
|
|
</>
|
|
</>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-const ManageGlobalNotificationWrapper = withUnstatedContainers(ManageGlobalNotification, [AdminNotificationContainer]);
|
|
|
|
|
-
|
|
|
|
|
-export default ManageGlobalNotificationWrapper;
|
|
|
|
|
|
|
+export default ManageGlobalNotification;
|