Fix #6689 Announcement bug (#6742)

This commit is contained in:
Sachin Chaurasiya 2022-08-16 18:24:39 +05:30 committed by GitHub
parent e6c5d2ccaa
commit 2b28d31072
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 17 deletions

View File

@ -26,10 +26,6 @@ jest.mock('../../../AppState', () => ({
isProfilePicLoading: jest.fn(),
}));
jest.mock('../../../hooks/authHooks', () => ({
useAuth: jest.fn().mockReturnValue({ isAdminUser: false }),
}));
jest.mock('../../../utils/FeedUtils', () => ({
getEntityField: jest.fn(),
getEntityFQN: jest.fn(),

View File

@ -22,7 +22,6 @@ import { ReactionOperation } from '../../../enums/reactions.enum';
import { AnnouncementDetails } from '../../../generated/api/feed/createThread';
import { Post } from '../../../generated/entity/feed/thread';
import { Reaction, ReactionType } from '../../../generated/type/reaction';
import { useAuth } from '../../../hooks/authHooks';
import {
getEntityField,
getEntityFQN,
@ -60,7 +59,6 @@ const ActivityFeedCard: FC<ActivityFeedCardProp> = ({
const entityFQN = getEntityFQN(entityLink as string);
const entityField = getEntityField(entityLink as string);
const { isAdminUser } = useAuth();
const currentUser = AppState.getCurrentUserDetails();
const [feedDetail, setFeedDetail] = useState<Post>(feed);
@ -69,9 +67,7 @@ const ActivityFeedCard: FC<ActivityFeedCardProp> = ({
const [isEditAnnouncement, setEditAnnouncement] = useState<boolean>(false);
const [isEditPost, setEditPost] = useState<boolean>(false);
const isAuthor = Boolean(
feedDetail.from === currentUser?.name || isAdminUser
);
const isAuthor = feedDetail.from === currentUser?.name;
const onFeedUpdate = (data: Operation[]) => {
updateThreadHandler(

View File

@ -14,7 +14,7 @@
import { Button, Space, Typography } from 'antd';
import classNames from 'classnames';
import { isUndefined } from 'lodash';
import React, { FC, useState } from 'react';
import React, { FC, useEffect, useState } from 'react';
import {
getFrontEndFormat,
MarkdownToHTMLConverter,
@ -92,6 +92,10 @@ const FeedCardBody: FC<FeedBodyProp> = ({
/>
);
useEffect(() => {
setPostMessage(message);
}, [message]);
return (
<div className={classNames('tw-group', isEditPost ? '' : className)}>
<div className="feed-meesage">

View File

@ -70,11 +70,7 @@ const PopoverContent: FC<Props> = ({
};
const deleteButtonCheck =
threadId &&
postId &&
onConfirmation &&
(isAuthor || currentUser?.isAdmin) &&
!isThread;
threadId && postId && onConfirmation && isAuthor && !isThread;
const handleDelete = (e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation();
@ -145,8 +141,7 @@ const PopoverContent: FC<Props> = ({
onEdit && onEdit();
};
const editCheck =
(isAnnouncement || !isThread) && (isAuthor || currentUser?.isAdmin);
const editCheck = (isAnnouncement || !isThread) && isAuthor;
return (
<Space>