Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public Thread createToEntity(CreateThread create, String user) {
.withId(randomUUID)
.withThreadTs(System.currentTimeMillis())
.withMessage(create.getMessage())
.withCreatedBy(create.getFrom())
.withCreatedBy(user)
.withAbout(create.getAbout())
.withAddressedTo(create.getAddressedTo())
.withReactions(Collections.emptyList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public Post createToEntity(CreatePost create, String user) {
return new Post()
.withId(UUID.randomUUID())
.withMessage(create.getMessage())
.withFrom(create.getFrom())
.withFrom(user)
.withReactions(Collections.emptyList())
.withPostTs(System.currentTimeMillis());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@
"description": "Message in Markdown format. See markdown support for more details.",
"type": "string"
},
"from": {
"description": "Name of the User posting the message",
"type": "string"
}
},
"required": ["message", "from"],
"required": ["message"],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
"description": "Message",
"type": "string"
},
"from": {
"description": "Name of the User (regular user or bot) posting the message",
"type": "string"
},
"addressedTo": {
"description": "User or team this thread is addressed to in format <#E::{entities}::{entityName}::{field}::{fieldValue}.",
"$ref": "../../type/basic.json#/definitions/entityLink"
Expand Down Expand Up @@ -69,6 +65,6 @@
"default": null
}
},
"required": ["message", "from", "about"],
"required": ["message", "about"],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ const ActivityFeedProvider = ({ children, user }: Props) => {

const data = {
message: value,
from: currentUser.name,
} as Post;

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ import { Button, Dropdown, Menu, Segmented, Space, Typography } from 'antd';
import { AxiosError } from 'axios';
import classNames from 'classnames';
import { isEmpty } from 'lodash';
import { RefObject, useCallback, useEffect, useMemo, useState } from 'react';
import {
RefObject,
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { ReactComponent as AllActivityIcon } from '../../../assets/svg/all-activity-v2.svg';
import { ReactComponent as TaskCloseIcon } from '../../../assets/svg/ic-check-circle-new.svg';
import { ReactComponent as TaskCloseIconBlue } from '../../../assets/svg/ic-close-task.svg';
Expand Down Expand Up @@ -89,6 +96,7 @@ export const ActivityFeedTab = ({
urlFqn = '',
}: ActivityFeedTabProps) => {
const navigate = useNavigate();
const location = useLocation();
const { t } = useTranslation();
const { currentUser } = useApplicationStore();
const { isAdminUser } = useAuth();
Expand All @@ -99,8 +107,10 @@ export const ActivityFeedTab = ({
root: document.querySelector('#center-container'),
rootMargin: '0px 0px 2px 0px',
});
const { subTab: activeTab = subTab } =
useRequiredParams<{ tab: EntityTabs; subTab: ActivityFeedTabs }>();
const { subTab: activeTab = subTab } = useRequiredParams<{
tab: EntityTabs;
subTab: ActivityFeedTabs;
}>();
const [taskFilter, setTaskFilter] = useState<ThreadTaskStatus>(
ThreadTaskStatus.Open
);
Expand All @@ -113,6 +123,7 @@ export const ActivityFeedTab = ({
data: FEED_COUNT_INITIAL_DATA,
});
const [isFirstLoad, setIsFirstLoad] = useState<boolean>(true);
const processedRefreshKeyRef = useRef<number | undefined>(undefined);

const {
selectedThread,
Expand Down Expand Up @@ -278,6 +289,39 @@ export const ActivityFeedTab = ({
}
}, [feedFilter, threadType, fqn]);

useEffect(() => {
const refreshKey = (location.state as { tasksRefreshKey?: number } | null)
?.tasksRefreshKey;
if (
refreshKey !== undefined &&
refreshKey !== processedRefreshKeyRef.current &&
fqn &&
isTaskActiveTab
) {
processedRefreshKeyRef.current = refreshKey;
getFeedData(
feedFilter,
undefined,
threadType,
entityType,
fqn,
taskFilter
);
navigate('.', { replace: true, state: {} });
}
}, [
entityType,
feedFilter,
fqn,
getFeedData,
isTaskActiveTab,
location.key,
location.state,
navigate,
taskFilter,
threadType,
]);

useEffect(() => {
if (feedCount) {
setCountData((prev) => ({ ...prev, data: feedCount }));
Expand Down Expand Up @@ -328,7 +372,8 @@ export const ActivityFeedTab = ({
'flex items-center justify-between px-4 py-2 gap-2',
{ active: taskFilter === ThreadTaskStatus.Open }
)}
data-testid="open-tasks">
data-testid="open-tasks"
>
<div className="flex items-center space-x-2">
{taskFilter === ThreadTaskStatus.Open ? (
<TaskOpenIcon
Expand All @@ -341,14 +386,16 @@ export const ActivityFeedTab = ({
<span
className={classNames('task-tab-filter-item', {
selected: taskFilter === ThreadTaskStatus.Open,
})}>
})}
>
{t('label.open')}
</span>
</div>
<span
className={classNames('task-count-container d-flex flex-center', {
active: taskFilter === ThreadTaskStatus.Open,
})}>
})}
>
<span className="task-count-text">
{countData?.data?.openTaskCount}
</span>
Expand All @@ -368,7 +415,8 @@ export const ActivityFeedTab = ({
'flex items-center justify-between px-4 py-2 gap-2',
{ active: taskFilter === ThreadTaskStatus.Closed }
)}
data-testid="closed-tasks">
data-testid="closed-tasks"
>
<div className="flex items-center space-x-2">
{taskFilter === ThreadTaskStatus.Closed ? (
<TaskCloseIconBlue
Expand All @@ -384,14 +432,16 @@ export const ActivityFeedTab = ({
<span
className={classNames('task-tab-filter-item', {
selected: taskFilter === ThreadTaskStatus.Closed,
})}>
})}
>
{t('label.closed')}
</span>
</div>
<span
className={classNames('task-count-container d-flex flex-center', {
active: taskFilter === ThreadTaskStatus.Closed,
})}>
})}
>
<span className="task-count-text">
{countData?.data?.closedTaskCount}
</span>
Expand Down Expand Up @@ -585,7 +635,8 @@ export const ActivityFeedTab = ({
'three-panel-layout':
layoutType === ActivityFeedLayoutType.THREE_PANEL,
})}
id="center-container">
id="center-container"
>
{(isTaskActiveTab || isMentionTabSelected) && (
<div className="d-flex gap-4 task-filter-container justify-between items-center ">
<Dropdown
Expand All @@ -595,7 +646,8 @@ export const ActivityFeedTab = ({
selectedKeys: [...taskFilter],
}}
overlayClassName="task-tab-custom-dropdown"
trigger={['click']}>
trigger={['click']}
>
<Button
className={classNames('feed-filter-icon', {
'cursor-pointer': !isMentionTabSelected,
Expand Down Expand Up @@ -640,15 +692,17 @@ export const ActivityFeedTab = ({
'hide-panel': isFullWidth,
'three-panel-layout':
layoutType === ActivityFeedLayoutType.THREE_PANEL,
})}>
})}
>
{loader}
{selectedThread && !loading
? getRightPanelContent(selectedThread)
: !loading && (
<div className="p-x-md no-data-placeholder-container-right-panel d-flex justify-center items-center h-full">
<ErrorPlaceHolderNew
icon={<NoConversationsIcon />}
type={ERROR_PLACEHOLDER_TYPE.CUSTOM}>
type={ERROR_PLACEHOLDER_TYPE.CUSTOM}
>
<Typography.Paragraph className="placeholder-text">
{getRightPanelPlaceholder}
</Typography.Paragraph>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { useElementInView } from '../../../hooks/useElementInView';
import { getAllFeeds } from '../../../rest/feedsAPI';
import { showErrorToast } from '../../../utils/ToastUtils';

import { useApplicationStore } from '../../../hooks/useApplicationStore';
import ErrorPlaceHolder from '../../common/ErrorWithPlaceholder/ErrorPlaceHolder';
import Loader from '../../common/Loader/Loader';
import ConfirmationModal from '../../Modals/ConfirmationModal/ConfirmationModal';
Expand All @@ -55,7 +54,6 @@ const ActivityThreadPanelBody: FC<ActivityThreadPanelBodyProp> = ({
threadType,
}) => {
const { t } = useTranslation();
const { currentUser } = useApplicationStore();
const [threads, setThreads] = useState<Thread[]>([]);
const [selectedThread, setSelectedThread] = useState<Thread>();
const [selectedThreadId, setSelectedThreadId] = useState<string>('');
Expand Down Expand Up @@ -163,7 +161,6 @@ const ActivityThreadPanelBody: FC<ActivityThreadPanelBodyProp> = ({
const onPostThread = async (value: string) => {
const data = {
message: value,
from: currentUser?.name ?? '',
about: threadLink,
};
await createThread(data);
Expand Down Expand Up @@ -250,7 +247,8 @@ const ActivityThreadPanelBody: FC<ActivityThreadPanelBodyProp> = ({
<Space
align="center"
className="w-full justify-end p-r-xs m-t-xs"
size={4}>
size={4}
>
<Switch size="small" onChange={onSwitchChange} />
<span>{t('label.closed-task-plural')}</span>
</Space>
Expand All @@ -263,7 +261,8 @@ const ActivityThreadPanelBody: FC<ActivityThreadPanelBodyProp> = ({
className="m-b-sm p-0"
size="small"
type="link"
onClick={onBack}>
onClick={onBack}
>
{t('label.back')}
</Button>
<ActivityThread
Expand Down Expand Up @@ -294,7 +293,8 @@ const ActivityThreadPanelBody: FC<ActivityThreadPanelBodyProp> = ({
{isTaskType && !isThreadLoading && (
<ErrorPlaceHolder
className="mt-24"
type={ERROR_PLACEHOLDER_TYPE.CUSTOM}>
type={ERROR_PLACEHOLDER_TYPE.CUSTOM}
>
<Typography.Paragraph>
{isTaskClosed
? t('message.no-closed-task')
Expand All @@ -317,7 +317,8 @@ const ActivityThreadPanelBody: FC<ActivityThreadPanelBodyProp> = ({
<div
data-testid="observer-element"
id="observer-element"
ref={elementRef as RefObject<HTMLDivElement>}>
ref={elementRef as RefObject<HTMLDivElement>}
>
{getLoader()}
</div>
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { getEntityFeedLink } from '../../../utils/EntityUtils';
import { showErrorToast, showSuccessToast } from '../../../utils/ToastUtils';

import { useSnackbar } from 'notistack';
import { useApplicationStore } from '../../../hooks/useApplicationStore';
import { FieldProp, FieldTypes } from '../../../interface/FormUtils.interface';
import { getField } from '../../../utils/formUtils';
import {
Expand Down Expand Up @@ -61,8 +60,6 @@ const AddAnnouncementModal: FC<Props> = ({
entityFQN,
showToastInSnackbar = false,
}) => {
const { currentUser } = useApplicationStore();

const [isLoading, setIsLoading] = useState<boolean>(false);
const { enqueueSnackbar } = useSnackbar();
const { t } = useTranslation();
Expand All @@ -85,7 +82,6 @@ const AddAnnouncementModal: FC<Props> = ({
: showErrorToast(t('message.announcement-invalid-start-time'));
} else {
const announcementData: CreateThread = {
from: currentUser?.name as string,
message: title,
about: getEntityFeedLink(entityType, entityFQN),
announcementDetails: {
Expand Down Expand Up @@ -151,13 +147,15 @@ const AddAnnouncementModal: FC<Props> = ({
open={open}
title={t('message.make-an-announcement')}
width={720}
onCancel={onCancel}>
onCancel={onCancel}
>
<Form<CreateAnnouncement>
data-testid="announcement-form"
id="announcement-form"
layout="vertical"
validateMessages={VALIDATION_MESSAGES}
onFinish={handleCreateAnnouncement}>
onFinish={handleCreateAnnouncement}
>
<Form.Item
label={`${t('label.title')}:`}
messageVariables={{ fieldName: 'title' }}
Expand All @@ -168,7 +166,8 @@ const AddAnnouncementModal: FC<Props> = ({
max: 124,
min: 5,
},
]}>
]}
>
<Input placeholder={t('label.announcement-title')} type="text" />
</Form.Item>
<Space className="announcement-date-space" size={16}>
Expand All @@ -182,7 +181,8 @@ const AddAnnouncementModal: FC<Props> = ({
{
required: true,
},
]}>
]}
>
<DatePicker className="w-full" />
</Form.Item>
<Form.Item
Expand All @@ -195,7 +195,8 @@ const AddAnnouncementModal: FC<Props> = ({
{
required: true,
},
]}>
]}
>
<DatePicker className="w-full" />
</Form.Item>
</Space>
Expand Down
Loading
Loading