|
@@ -6,97 +6,24 @@ import type { HasObjectId } from '@growi/core';
|
|
|
import { useRouter } from 'next/router';
|
|
import { useRouter } from 'next/router';
|
|
|
|
|
|
|
|
import type { IInAppNotificationOpenable } from '~/client/interfaces/in-app-notification-openable';
|
|
import type { IInAppNotificationOpenable } from '~/client/interfaces/in-app-notification-openable';
|
|
|
-import { SupportedAction } from '~/interfaces/activity';
|
|
|
|
|
import type { IInAppNotification } from '~/interfaces/in-app-notification';
|
|
import type { IInAppNotification } from '~/interfaces/in-app-notification';
|
|
|
|
|
|
|
|
import { ModelNotification } from './ModelNotification';
|
|
import { ModelNotification } from './ModelNotification';
|
|
|
|
|
+import { useActionMsgAndIconForPageModelNotification } from './useActionAndMsg';
|
|
|
|
|
+
|
|
|
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
|
notification: IInAppNotification & HasObjectId
|
|
notification: IInAppNotification & HasObjectId
|
|
|
actionUsers: string
|
|
actionUsers: string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export type ActionMsgAndIconType = {
|
|
|
|
|
- actionMsg: string
|
|
|
|
|
- actionIcon: string
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-const useActionMsgAndIcon = (notification: IInAppNotification & HasObjectId): ActionMsgAndIconType => {
|
|
|
|
|
- const actionType: string = notification.action;
|
|
|
|
|
- let actionMsg: string;
|
|
|
|
|
- let actionIcon: string;
|
|
|
|
|
-
|
|
|
|
|
- switch (actionType) {
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_LIKE:
|
|
|
|
|
- actionMsg = 'liked';
|
|
|
|
|
- actionIcon = 'icon-like';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_BOOKMARK:
|
|
|
|
|
- actionMsg = 'bookmarked on';
|
|
|
|
|
- actionIcon = 'icon-star';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_UPDATE:
|
|
|
|
|
- actionMsg = 'updated on';
|
|
|
|
|
- actionIcon = 'ti ti-agenda';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_RENAME:
|
|
|
|
|
- actionMsg = 'renamed';
|
|
|
|
|
- actionIcon = 'icon-action-redo';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_DUPLICATE:
|
|
|
|
|
- actionMsg = 'duplicated';
|
|
|
|
|
- actionIcon = 'icon-docs';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_DELETE:
|
|
|
|
|
- actionMsg = 'deleted';
|
|
|
|
|
- actionIcon = 'icon-trash';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_DELETE_COMPLETELY:
|
|
|
|
|
- actionMsg = 'completely deleted';
|
|
|
|
|
- actionIcon = 'icon-fire';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_REVERT:
|
|
|
|
|
- actionMsg = 'reverted';
|
|
|
|
|
- actionIcon = 'icon-action-undo';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_RECURSIVELY_RENAME:
|
|
|
|
|
- actionMsg = 'renamed under';
|
|
|
|
|
- actionIcon = 'icon-action-redo';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_RECURSIVELY_DELETE:
|
|
|
|
|
- actionMsg = 'deleted under';
|
|
|
|
|
- actionIcon = 'icon-trash';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_RECURSIVELY_DELETE_COMPLETELY:
|
|
|
|
|
- actionMsg = 'deleted completely under';
|
|
|
|
|
- actionIcon = 'icon-fire';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_PAGE_RECURSIVELY_REVERT:
|
|
|
|
|
- actionMsg = 'reverted under';
|
|
|
|
|
- actionIcon = 'icon-action-undo';
|
|
|
|
|
- break;
|
|
|
|
|
- case SupportedAction.ACTION_COMMENT_CREATE:
|
|
|
|
|
- actionMsg = 'commented on';
|
|
|
|
|
- actionIcon = 'icon-bubble';
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- actionMsg = '';
|
|
|
|
|
- actionIcon = '';
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return {
|
|
|
|
|
- actionMsg,
|
|
|
|
|
- actionIcon,
|
|
|
|
|
- };
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
const PageModelNotification: ForwardRefRenderFunction<IInAppNotificationOpenable, Props> = (props: Props, ref) => {
|
|
const PageModelNotification: ForwardRefRenderFunction<IInAppNotificationOpenable, Props> = (props: Props, ref) => {
|
|
|
|
|
|
|
|
const {
|
|
const {
|
|
|
notification, actionUsers,
|
|
notification, actionUsers,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
- const { actionMsg, actionIcon } = useActionMsgAndIcon(notification);
|
|
|
|
|
|
|
+ const { actionMsg, actionIcon } = useActionMsgAndIconForPageModelNotification(notification);
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
|
|
|