Przeglądaj źródła

Merge pull request #4527 from weseek/imprv/79839-show-action-time-on-popup

Imprv/79839 show action time on popup
Yuki Takei 4 lat temu
rodzic
commit
0e357c6343

+ 3 - 1
packages/app/src/components/FormattedDistanceDate.jsx

@@ -23,7 +23,7 @@ const FormattedDistanceDate = (props) => {
   return (
   return (
     <>
     <>
       <span id={elemId}>{formatDistanceStrict(date, baseDate)}</span>
       <span id={elemId}>{formatDistanceStrict(date, baseDate)}</span>
-      <UncontrolledTooltip placement="bottom" fade={false} target={elemId}>{dateFormatted}</UncontrolledTooltip>
+      {props.isShowTooltip && <UncontrolledTooltip placement="bottom" fade={false} target={elemId}>{dateFormatted}</UncontrolledTooltip>}
     </>
     </>
   );
   );
 };
 };
@@ -34,9 +34,11 @@ FormattedDistanceDate.propTypes = {
   baseDate: PropTypes.instanceOf(Date),
   baseDate: PropTypes.instanceOf(Date),
   // the number(sec) from 'baseDate' to avoid format
   // the number(sec) from 'baseDate' to avoid format
   differenceForAvoidingFormat: PropTypes.number,
   differenceForAvoidingFormat: PropTypes.number,
+  isShowTooltip: PropTypes.bool,
 };
 };
 FormattedDistanceDate.defaultProps = {
 FormattedDistanceDate.defaultProps = {
   differenceForAvoidingFormat: 86400 * 3,
   differenceForAvoidingFormat: 86400 * 3,
+  isShowTooltip: true,
 };
 };
 
 
 export default FormattedDistanceDate;
 export default FormattedDistanceDate;

+ 23 - 14
packages/app/src/components/InAppNotification/InAppNotification.tsx

@@ -3,6 +3,7 @@ import React from 'react';
 import { UserPicture } from '@growi/ui';
 import { UserPicture } from '@growi/ui';
 import { PageCommentNotification } from './PageCommentNotification';
 import { PageCommentNotification } from './PageCommentNotification';
 import { InAppNotification as IInAppNotification } from '../../interfaces/in-app-notification';
 import { InAppNotification as IInAppNotification } from '../../interfaces/in-app-notification';
+import FormattedDistanceDate from '../FormattedDistanceDate';
 
 
 interface Props {
 interface Props {
   notification: IInAppNotification
   notification: IInAppNotification
@@ -35,12 +36,11 @@ export const InAppNotification = (props: Props): JSX.Element => {
     return actionedUsers;
     return actionedUsers;
   };
   };
 
 
-  const renderUserImage = () => {
+  const renderUserImage = (): JSX.Element => {
     const actionUsers = notification.actionUsers;
     const actionUsers = notification.actionUsers;
 
 
     if (actionUsers.length < 1) {
     if (actionUsers.length < 1) {
-    // what is this case?
-      return '';
+      return <></>;
     }
     }
 
 
     return <UserPicture user={actionUsers[0]} size="md" noTooltip />;
     return <UserPicture user={actionUsers[0]} size="md" noTooltip />;
@@ -52,16 +52,25 @@ export const InAppNotification = (props: Props): JSX.Element => {
     ...props,
     ...props,
   };
   };
 
 
-  switch (componentName) {
-    case 'Page:COMMENT':
-      return (
-        <>
-          {renderUserImage()}
-          <PageCommentNotification {...propsNew} onClick={props.onClick(props.notification)} />
-        </>
+  const renderInAppNotificationContent = (): JSX.Element => {
+    switch (componentName) {
+      case 'Page:COMMENT':
+        return <PageCommentNotification {...propsNew} onClick={props.onClick(props.notification)} />;
+      default:
+        return <></>;
+    }
+  };
+
+  return (
+    <>
+      {/* TODO: notification popup adjustment by #79315 */}
+      <div>
+        {renderUserImage()}
+        {renderInAppNotificationContent()}
+      </div>
+      <FormattedDistanceDate id={props.notification._id} date={props.notification.createdAt} isShowTooltip={false} />
+    </>
+  );
+
 
 
-      );
-    default:
-      return <></>;
-  }
 };
 };

+ 1 - 1
packages/app/src/components/InAppNotification/InAppNotificationDropdown.tsx

@@ -155,7 +155,7 @@ const InAppNotificationDropdown: FC<Props> = (props: Props) => {
       <DropdownMenu right>
       <DropdownMenu right>
         <InAppNotificationContents />
         <InAppNotificationContents />
         <DropdownItem divider />
         <DropdownItem divider />
-        {/* TODO: Able to show all notifications by GW-7534 */}
+        {/* TODO: Able to show all notifications by #79317 */}
         <a>See All</a>
         <a>See All</a>
       </DropdownMenu>
       </DropdownMenu>
     </Dropdown>
     </Dropdown>