Feat(ui): update displayName part 2 (#11584)

* Feat(ui): update displayName part 2

* updated entity name

* fixed cypress failure
This commit is contained in:
Shailesh Parmar 2023-05-15 13:59:09 +05:30 committed by GitHub
parent 019014b8d3
commit 004626320d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 216 additions and 363 deletions

View File

@ -17,6 +17,7 @@ import { ReactComponent as EditIcon } from 'assets/svg/edit-new.svg';
import { AxiosError } from 'axios'; import { AxiosError } from 'axios';
import { ActivityFilters } from 'components/ActivityFeed/ActivityFeedList/ActivityFeedList.interface'; import { ActivityFilters } from 'components/ActivityFeed/ActivityFeedList/ActivityFeedList.interface';
import ErrorPlaceHolder from 'components/common/error-with-placeholder/ErrorPlaceHolder'; import ErrorPlaceHolder from 'components/common/error-with-placeholder/ErrorPlaceHolder';
import { EntityName } from 'components/Modals/EntityNameModal/EntityNameModal.interface';
import { ENTITY_CARD_CLASS } from 'constants/entity.constants'; import { ENTITY_CARD_CLASS } from 'constants/entity.constants';
import { compare } from 'fast-json-patch'; import { compare } from 'fast-json-patch';
import { isEmpty, isUndefined } from 'lodash'; import { isEmpty, isUndefined } from 'lodash';
@ -87,9 +88,6 @@ const DashboardDetails = ({
activeTab, activeTab,
setActiveTabHandler, setActiveTabHandler,
dashboardDetails, dashboardDetails,
descriptionUpdateHandler,
settingsUpdateHandler,
tagUpdateHandler,
charts, charts,
chartDescriptionUpdateHandler, chartDescriptionUpdateHandler,
chartTagUpdateHandler, chartTagUpdateHandler,
@ -106,7 +104,7 @@ const DashboardDetails = ({
fetchFeedHandler, fetchFeedHandler,
updateThreadHandler, updateThreadHandler,
entityFieldTaskCount, entityFieldTaskCount,
onExtensionUpdate, onDashboardUpdate,
}: DashboardDetailsProps) => { }: DashboardDetailsProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [isEdit, setIsEdit] = useState(false); const [isEdit, setIsEdit] = useState(false);
@ -312,12 +310,12 @@ const DashboardDetails = ({
const onDescriptionUpdate = async (updatedHTML: string) => { const onDescriptionUpdate = async (updatedHTML: string) => {
if (description !== updatedHTML) { if (description !== updatedHTML) {
const updatedDashboardDetails = { const updatedDashboard = {
...dashboardDetails, ...dashboardDetails,
description: updatedHTML, description: updatedHTML,
}; };
try { try {
await descriptionUpdateHandler(updatedDashboardDetails); await onDashboardUpdate(updatedDashboard, 'description');
} catch (error) { } catch (error) {
showErrorToast(error as AxiosError); showErrorToast(error as AxiosError);
} finally { } finally {
@ -330,11 +328,11 @@ const DashboardDetails = ({
const onOwnerUpdate = useCallback( const onOwnerUpdate = useCallback(
(newOwner?: Dashboard['owner']) => { (newOwner?: Dashboard['owner']) => {
const updatedDashboardDetails = { const updatedDashboard = {
...dashboardDetails, ...dashboardDetails,
owner: newOwner ? { ...owner, ...newOwner } : undefined, owner: newOwner ? { ...owner, ...newOwner } : undefined,
}; };
settingsUpdateHandler(updatedDashboardDetails); onDashboardUpdate(updatedDashboard, 'owner');
}, },
[owner] [owner]
); );
@ -351,21 +349,21 @@ const DashboardDetails = ({
}, },
] ]
: dashboardDetails.tags; : dashboardDetails.tags;
const updatedDashboardDetails = { const updatedDashboard = {
...dashboardDetails, ...dashboardDetails,
tags: tierTag, tags: tierTag,
}; };
settingsUpdateHandler(updatedDashboardDetails); onDashboardUpdate(updatedDashboard, 'tags');
} }
}; };
const onRemoveTier = () => { const onRemoveTier = () => {
if (dashboardDetails) { if (dashboardDetails) {
const updatedDashboardDetails = { const updatedDashboard = {
...dashboardDetails, ...dashboardDetails,
tags: getTagsWithoutTier(dashboardDetails.tags ?? []), tags: getTagsWithoutTier(dashboardDetails.tags ?? []),
}; };
settingsUpdateHandler(updatedDashboardDetails); onDashboardUpdate(updatedDashboard, 'tags');
} }
}; };
@ -373,10 +371,21 @@ const DashboardDetails = ({
if (selectedTags) { if (selectedTags) {
const updatedTags = [...(tier ? [tier] : []), ...selectedTags]; const updatedTags = [...(tier ? [tier] : []), ...selectedTags];
const updatedDashboard = { ...dashboardDetails, tags: updatedTags }; const updatedDashboard = { ...dashboardDetails, tags: updatedTags };
tagUpdateHandler(updatedDashboard); onDashboardUpdate(updatedDashboard, 'tags');
} }
}; };
const onUpdateDisplayName = async (data: EntityName) => {
const updatedData = {
...dashboardDetails,
displayName: data.displayName,
};
await onDashboardUpdate(updatedData, 'displayName');
};
const onExtensionUpdate = async (updatedData: Dashboard) => {
await onDashboardUpdate(updatedData, 'extension');
};
const handleRestoreDashboard = async () => { const handleRestoreDashboard = async () => {
try { try {
await restoreDashboard(dashboardDetails.id); await restoreDashboard(dashboardDetails.id);
@ -734,7 +743,7 @@ const DashboardDetails = ({
)} )}
entityFqn={dashboardFQN} entityFqn={dashboardFQN}
entityId={dashboardDetails.id} entityId={dashboardDetails.id}
entityName={entityName} entityName={dashboardDetails.name}
entityType={EntityType.DASHBOARD} entityType={EntityType.DASHBOARD}
extraInfo={extraInfo} extraInfo={extraInfo}
followHandler={followDashboard} followHandler={followDashboard}
@ -766,6 +775,7 @@ const DashboardDetails = ({
versionHandler={versionHandler} versionHandler={versionHandler}
onRestoreEntity={handleRestoreDashboard} onRestoreEntity={handleRestoreDashboard}
onThreadLinkSelect={onThreadLinkSelect} onThreadLinkSelect={onThreadLinkSelect}
onUpdateDisplayName={onUpdateDisplayName}
/> />
<div className="tw-mt-4 tw-flex tw-flex-col tw-flex-grow"> <div className="tw-mt-4 tw-flex tw-flex-col tw-flex-grow">
<TabsPane <TabsPane

View File

@ -54,8 +54,6 @@ export interface DashboardDetailsProps {
setActiveTabHandler: (value: number) => void; setActiveTabHandler: (value: number) => void;
followDashboardHandler: () => void; followDashboardHandler: () => void;
unfollowDashboardHandler: () => void; unfollowDashboardHandler: () => void;
settingsUpdateHandler: (updatedDashboard: Dashboard) => Promise<void>;
descriptionUpdateHandler: (updatedDashboard: Dashboard) => Promise<void>;
chartDescriptionUpdateHandler: ( chartDescriptionUpdateHandler: (
index: number, index: number,
chartId: string, chartId: string,
@ -66,7 +64,6 @@ export interface DashboardDetailsProps {
chartId: string, chartId: string,
patch: Array<Operation> patch: Array<Operation>
) => void; ) => void;
tagUpdateHandler: (updatedDashboard: Dashboard) => void;
versionHandler: () => void; versionHandler: () => void;
postFeedHandler: (value: string, id: string) => void; postFeedHandler: (value: string, id: string) => void;
deletePostHandler: ( deletePostHandler: (
@ -75,5 +72,8 @@ export interface DashboardDetailsProps {
isThread: boolean isThread: boolean
) => void; ) => void;
updateThreadHandler: ThreadUpdatedFunc; updateThreadHandler: ThreadUpdatedFunc;
onExtensionUpdate: (updatedDashboard: Dashboard) => Promise<void>; onDashboardUpdate: (
updatedDashboard: Dashboard,
key: keyof Dashboard
) => Promise<void>;
} }

View File

@ -27,17 +27,11 @@ import React from 'react';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import { Dashboard } from '../../generated/entity/data/dashboard'; import { Dashboard } from '../../generated/entity/data/dashboard';
import { GlossaryTerm } from '../../generated/entity/data/glossaryTerm'; import { GlossaryTerm } from '../../generated/entity/data/glossaryTerm';
import { EntityLineage } from '../../generated/type/entityLineage';
import { EntityReference } from '../../generated/type/entityReference';
import { Paging } from '../../generated/type/paging'; import { Paging } from '../../generated/type/paging';
import { TagLabel } from '../../generated/type/tagLabel';
import { fetchGlossaryTerms } from '../../utils/GlossaryUtils'; import { fetchGlossaryTerms } from '../../utils/GlossaryUtils';
import { getClassifications } from '../../utils/TagsUtils'; import { getClassifications } from '../../utils/TagsUtils';
import {
LeafNodes,
LoadingNodeState,
} from '../EntityLineage/EntityLineage.interface';
import DashboardDetails from './DashboardDetails.component'; import DashboardDetails from './DashboardDetails.component';
import { DashboardDetailsProps } from './DashboardDetails.interface';
const mockUserTeam = [ const mockUserTeam = [
{ {
@ -58,7 +52,7 @@ const mockUserTeam = [
}, },
]; ];
const DashboardDetailsProps = { const dashboardDetailsProps: DashboardDetailsProps = {
charts: [ charts: [
{ {
chartUrl: 'http://localhost', chartUrl: 'http://localhost',
@ -70,36 +64,16 @@ const DashboardDetailsProps = {
service: { id: '', type: '' }, service: { id: '', type: '' },
}, },
], ],
serviceType: '',
dashboardUrl: '',
tagList: [],
users: [],
dashboardDetails: {} as Dashboard, dashboardDetails: {} as Dashboard,
entityLineage: {} as EntityLineage,
entityName: '',
activeTab: 1, activeTab: 1,
owner: {} as EntityReference,
description: '',
tier: {} as TagLabel,
followers: [],
dashboardTags: [],
slashedDashboardName: [], slashedDashboardName: [],
setActiveTabHandler: jest.fn(), setActiveTabHandler: jest.fn(),
followDashboardHandler: jest.fn(), followDashboardHandler: jest.fn(),
unfollowDashboardHandler: jest.fn(), unfollowDashboardHandler: jest.fn(),
settingsUpdateHandler: jest.fn(),
descriptionUpdateHandler: jest.fn(),
chartDescriptionUpdateHandler: jest.fn(), chartDescriptionUpdateHandler: jest.fn(),
chartTagUpdateHandler: jest.fn(), chartTagUpdateHandler: jest.fn(),
tagUpdateHandler: jest.fn(), onDashboardUpdate: jest.fn(),
loadNodeHandler: jest.fn(),
lineageLeafNodes: {} as LeafNodes,
isNodeLoading: {} as LoadingNodeState,
version: '',
versionHandler: jest.fn(), versionHandler: jest.fn(),
addLineageHandler: jest.fn(),
removeLineageHandler: jest.fn(),
entityLineageHandler: jest.fn(),
entityThread: [], entityThread: [],
isEntityThreadLoading: false, isEntityThreadLoading: false,
postFeedHandler: jest.fn(), postFeedHandler: jest.fn(),
@ -112,7 +86,6 @@ const DashboardDetailsProps = {
paging: {} as Paging, paging: {} as Paging,
fetchFeedHandler: jest.fn(), fetchFeedHandler: jest.fn(),
updateThreadHandler: jest.fn(), updateThreadHandler: jest.fn(),
onExtensionUpdate: jest.fn(),
}; };
const mockEntityPermissions = { const mockEntityPermissions = {
@ -146,8 +119,8 @@ jest.mock('components/Tag/TagsContainer/tags-container', () => {
return jest.fn().mockImplementation(({ tagList }) => { return jest.fn().mockImplementation(({ tagList }) => {
return ( return (
<> <>
{tagList.map((tag: TagOption, idx: number) => ( {tagList.map((tag: TagOption) => (
<p key={idx}>{tag.fqn}</p> <p key={tag.fqn}>{tag.fqn}</p>
))} ))}
</> </>
); );
@ -221,7 +194,7 @@ jest.mock('../../utils/TagsUtils', () => ({
describe('Test DashboardDetails component', () => { describe('Test DashboardDetails component', () => {
it('Checks if the DashboardDetails component has all the proper components rendered', async () => { it('Checks if the DashboardDetails component has all the proper components rendered', async () => {
const { container } = render( const { container } = render(
<DashboardDetails {...DashboardDetailsProps} />, <DashboardDetails {...dashboardDetailsProps} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -246,7 +219,7 @@ describe('Test DashboardDetails component', () => {
it('Check if active tab is details', async () => { it('Check if active tab is details', async () => {
const { container } = render( const { container } = render(
<DashboardDetails {...DashboardDetailsProps} />, <DashboardDetails {...dashboardDetailsProps} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -258,7 +231,7 @@ describe('Test DashboardDetails component', () => {
it('Check if active tab is activity feed', async () => { it('Check if active tab is activity feed', async () => {
const { container } = render( const { container } = render(
<DashboardDetails {...DashboardDetailsProps} activeTab={2} />, <DashboardDetails {...dashboardDetailsProps} activeTab={2} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -270,7 +243,7 @@ describe('Test DashboardDetails component', () => {
it('Check if active tab is lineage', async () => { it('Check if active tab is lineage', async () => {
const { container } = render( const { container } = render(
<DashboardDetails {...DashboardDetailsProps} activeTab={3} />, <DashboardDetails {...dashboardDetailsProps} activeTab={3} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -282,7 +255,7 @@ describe('Test DashboardDetails component', () => {
it('Check if active tab is custom properties', async () => { it('Check if active tab is custom properties', async () => {
const { container } = render( const { container } = render(
<DashboardDetails {...DashboardDetailsProps} activeTab={4} />, <DashboardDetails {...dashboardDetailsProps} activeTab={4} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -297,7 +270,7 @@ describe('Test DashboardDetails component', () => {
it('Should create an observer if IntersectionObserver is available', async () => { it('Should create an observer if IntersectionObserver is available', async () => {
const { container } = render( const { container } = render(
<DashboardDetails {...DashboardDetailsProps} activeTab={4} />, <DashboardDetails {...dashboardDetailsProps} activeTab={4} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -310,7 +283,7 @@ describe('Test DashboardDetails component', () => {
it('Check if tags and glossary-terms are present', async () => { it('Check if tags and glossary-terms are present', async () => {
await act(async () => { await act(async () => {
render(<DashboardDetails {...DashboardDetailsProps} />, { render(<DashboardDetails {...dashboardDetailsProps} />, {
wrapper: MemoryRouter, wrapper: MemoryRouter,
}); });
}); });
@ -332,7 +305,7 @@ describe('Test DashboardDetails component', () => {
Promise.reject() Promise.reject()
); );
await act(async () => { await act(async () => {
render(<DashboardDetails {...DashboardDetailsProps} />, { render(<DashboardDetails {...dashboardDetailsProps} />, {
wrapper: MemoryRouter, wrapper: MemoryRouter,
}); });
}); });
@ -354,7 +327,7 @@ describe('Test DashboardDetails component', () => {
Promise.reject() Promise.reject()
); );
await act(async () => { await act(async () => {
render(<DashboardDetails {...DashboardDetailsProps} />, { render(<DashboardDetails {...dashboardDetailsProps} />, {
wrapper: MemoryRouter, wrapper: MemoryRouter,
}); });
}); });
@ -381,7 +354,7 @@ describe('Test DashboardDetails component', () => {
Promise.reject() Promise.reject()
); );
const { getByTestId, queryByText } = render( const { getByTestId, queryByText } = render(
<DashboardDetails {...DashboardDetailsProps} />, <DashboardDetails {...dashboardDetailsProps} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }

View File

@ -115,7 +115,6 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
deletePostHandler, deletePostHandler,
paging, paging,
fetchFeedHandler, fetchFeedHandler,
handleExtensionUpdate,
updateThreadHandler, updateThreadHandler,
entityFieldTaskCount, entityFieldTaskCount,
isTableProfileLoading, isTableProfileLoading,
@ -151,7 +150,6 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
usageSummary, usageSummary,
joins, joins,
entityName, entityName,
displayName,
} = useMemo(() => { } = useMemo(() => {
const { tags } = tableDetails; const { tags } = tableDetails;
@ -159,7 +157,7 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
...tableDetails, ...tableDetails,
tier: getTierTags(tags ?? []), tier: getTierTags(tags ?? []),
tableTags: getTagsWithoutTier(tags || []), tableTags: getTagsWithoutTier(tags || []),
entityName: tableDetails.name, entityName: getEntityName(tableDetails),
}; };
}, [tableDetails]); }, [tableDetails]);
const isTourPage = location.pathname.includes(ROUTES.TOUR); const isTourPage = location.pathname.includes(ROUTES.TOUR);
@ -574,6 +572,9 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
const updatedTable = { ...tableDetails, displayName: data.displayName }; const updatedTable = { ...tableDetails, displayName: data.displayName };
await onTableUpdate(updatedTable, 'displayName'); await onTableUpdate(updatedTable, 'displayName');
}; };
const onExtensionUpdate = async (updatedData: Table) => {
await onTableUpdate(updatedData, 'extension');
};
const followTable = () => { const followTable = () => {
isFollowing ? unfollowTableHandler() : followTableHandler(); isFollowing ? unfollowTableHandler() : followTableHandler();
@ -652,7 +653,7 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
canDelete={tablePermissions.Delete} canDelete={tablePermissions.Delete}
currentOwner={tableDetails.owner} currentOwner={tableDetails.owner}
deleted={deleted} deleted={deleted}
displayName={displayName} displayName={tableDetails.displayName}
entityFieldTasks={getEntityFieldThreadCounts( entityFieldTasks={getEntityFieldThreadCounts(
EntityField.TAGS, EntityField.TAGS,
entityFieldTaskCount entityFieldTaskCount
@ -663,7 +664,7 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
)} )}
entityFqn={datasetFQN} entityFqn={datasetFQN}
entityId={tableDetails.id} entityId={tableDetails.id}
entityName={entityName} entityName={tableDetails.name}
entityType={EntityType.TABLE} entityType={EntityType.TABLE}
extraInfo={extraInfo} extraInfo={extraInfo}
followHandler={followTable} followHandler={followTable}
@ -849,7 +850,7 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
tableDetails as CustomPropertyProps['entityDetails'] tableDetails as CustomPropertyProps['entityDetails']
} }
entityType={EntityType.TABLE} entityType={EntityType.TABLE}
handleExtensionUpdate={handleExtensionUpdate} handleExtensionUpdate={onExtensionUpdate}
hasEditAccess={ hasEditAccess={
tablePermissions.EditAll || tablePermissions.EditCustomFields tablePermissions.EditAll || tablePermissions.EditCustomFields
} }

View File

@ -55,7 +55,6 @@ export interface DatasetDetailsProps {
feedType?: FeedFilter, feedType?: FeedFilter,
threadType?: ThreadType threadType?: ThreadType
) => void; ) => void;
handleExtensionUpdate: (updatedTable: Table) => Promise<void>;
updateThreadHandler: ThreadUpdatedFunc; updateThreadHandler: ThreadUpdatedFunc;
onTableUpdate: (updatedTable: Table, key: keyof Table) => Promise<void>; onTableUpdate: (updatedTable: Table, key: keyof Table) => Promise<void>;
} }

View File

@ -110,7 +110,6 @@ const datasetDetailsProps: DatasetDetailsProps = {
createThread: jest.fn(), createThread: jest.fn(),
deletePostHandler: jest.fn(), deletePostHandler: jest.fn(),
fetchFeedHandler: jest.fn(), fetchFeedHandler: jest.fn(),
handleExtensionUpdate: jest.fn(),
updateThreadHandler: jest.fn(), updateThreadHandler: jest.fn(),
onTableUpdate: jest.fn(), onTableUpdate: jest.fn(),
}; };

View File

@ -451,6 +451,9 @@ const GlossaryHeader = ({
<EntityNameModal <EntityNameModal
allowRename allowRename
entity={selectedData as EntityReference} entity={selectedData as EntityReference}
title={t('label.edit-entity', {
entity: t('label.name'),
})}
visible={isNameEditing} visible={isNameEditing}
onCancel={() => setIsNameEditing(false)} onCancel={() => setIsNameEditing(false)}
onSave={onNameSave} onSave={onNameSave}

View File

@ -20,6 +20,7 @@ const EntityNameModal: React.FC<EntityNameModalProps> = ({
entity, entity,
onCancel, onCancel,
onSave, onSave,
title,
// re-name will update actual name of the entity, it will impact across application // re-name will update actual name of the entity, it will impact across application
// By default its disabled, send allowRename true to get the functionality // By default its disabled, send allowRename true to get the functionality
allowRename = false, allowRename = false,
@ -61,9 +62,7 @@ const EntityNameModal: React.FC<EntityNameModalProps> = ({
open={visible} open={visible}
title={ title={
<Typography.Text strong data-testid="header"> <Typography.Text strong data-testid="header">
{t('label.edit-entity', { {title}
entity: allowRename ? t('label.name') : t('label.display-name'),
})}
</Typography.Text> </Typography.Text>
} }
onCancel={onCancel}> onCancel={onCancel}>

View File

@ -18,4 +18,5 @@ export interface EntityNameModalProps {
onCancel: () => void; onCancel: () => void;
onSave: (obj: EntityName) => void; onSave: (obj: EntityName) => void;
entity: Partial<EntityName>; entity: Partial<EntityName>;
title: string;
} }

View File

@ -14,6 +14,7 @@
import { Card } from 'antd'; import { Card } from 'antd';
import { AxiosError } from 'axios'; import { AxiosError } from 'axios';
import { ActivityFilters } from 'components/ActivityFeed/ActivityFeedList/ActivityFeedList.interface'; import { ActivityFilters } from 'components/ActivityFeed/ActivityFeedList/ActivityFeedList.interface';
import { EntityName } from 'components/Modals/EntityNameModal/EntityNameModal.interface';
import { ENTITY_CARD_CLASS } from 'constants/entity.constants'; import { ENTITY_CARD_CLASS } from 'constants/entity.constants';
import { EntityTags, ExtraInfo } from 'Models'; import { EntityTags, ExtraInfo } from 'Models';
import React, { import React, {
@ -72,11 +73,8 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({
activeTab, activeTab,
slashedTopicName, slashedTopicName,
setActiveTabHandler, setActiveTabHandler,
settingsUpdateHandler,
followTopicHandler, followTopicHandler,
unfollowTopicHandler, unfollowTopicHandler,
descriptionUpdateHandler,
tagUpdateHandler,
versionHandler, versionHandler,
entityThread, entityThread,
isEntityThreadLoading, isEntityThreadLoading,
@ -90,7 +88,7 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({
fetchFeedHandler, fetchFeedHandler,
updateThreadHandler, updateThreadHandler,
entityFieldTaskCount, entityFieldTaskCount,
onExtensionUpdate, onTopicUpdate,
}: TopicDetailsProps) => { }: TopicDetailsProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [isEdit, setIsEdit] = useState(false); const [isEdit, setIsEdit] = useState(false);
@ -284,7 +282,7 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({
description: updatedHTML, description: updatedHTML,
}; };
try { try {
await descriptionUpdateHandler(updatedTopicDetails); await onTopicUpdate(updatedTopicDetails, 'description');
} catch (error) { } catch (error) {
showErrorToast(error as AxiosError); showErrorToast(error as AxiosError);
} finally { } finally {
@ -305,7 +303,7 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({
} }
: undefined, : undefined,
}; };
settingsUpdateHandler(updatedTopicDetails); onTopicUpdate(updatedTopicDetails, 'owner');
}, },
[owner] [owner]
); );
@ -316,7 +314,7 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({
...topicDetails, ...topicDetails,
tags: getTagsWithoutTier(topicDetails.tags ?? []), tags: getTagsWithoutTier(topicDetails.tags ?? []),
}; };
settingsUpdateHandler(updatedTopicDetails); onTopicUpdate(updatedTopicDetails, 'tags');
} }
}; };
@ -337,7 +335,7 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({
tags: tierTag, tags: tierTag,
}; };
return settingsUpdateHandler(updatedTopicDetails); return onTopicUpdate(updatedTopicDetails, 'tags');
} else { } else {
return Promise.reject(); return Promise.reject();
} }
@ -371,10 +369,21 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({
if (selectedTags) { if (selectedTags) {
const updatedTags = [...(tier ? [tier] : []), ...selectedTags]; const updatedTags = [...(tier ? [tier] : []), ...selectedTags];
const updatedTopic = { ...topicDetails, tags: updatedTags }; const updatedTopic = { ...topicDetails, tags: updatedTags };
tagUpdateHandler(updatedTopic); onTopicUpdate(updatedTopic, 'tags');
} }
}; };
const handleUpdateDisplayName = async (data: EntityName) => {
const updatedData = {
...topicDetails,
displayName: data.displayName,
};
await onTopicUpdate(updatedData, 'displayName');
};
const onExtensionUpdate = async (updatedData: Topic) => {
await onTopicUpdate(updatedData, 'extension');
};
const onThreadLinkSelect = (link: string, threadType?: ThreadType) => { const onThreadLinkSelect = (link: string, threadType?: ThreadType) => {
setThreadLink(link); setThreadLink(link);
if (threadType) { if (threadType) {
@ -408,10 +417,13 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({
updatedMessageSchema: Topic['messageSchema'] updatedMessageSchema: Topic['messageSchema']
) => { ) => {
try { try {
await settingsUpdateHandler({ await onTopicUpdate(
...topicDetails, {
messageSchema: updatedMessageSchema, ...topicDetails,
}); messageSchema: updatedMessageSchema,
},
'messageSchema'
);
} catch (error) { } catch (error) {
showErrorToast(error as AxiosError); showErrorToast(error as AxiosError);
} }
@ -447,7 +459,7 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({
)} )}
entityFqn={topicFQN} entityFqn={topicFQN}
entityId={topicDetails.id} entityId={topicDetails.id}
entityName={entityName} entityName={topicDetails.name}
entityType={EntityType.TOPIC} entityType={EntityType.TOPIC}
extraInfo={extraInfo} extraInfo={extraInfo}
followHandler={followTopic} followHandler={followTopic}
@ -479,6 +491,7 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({
versionHandler={versionHandler} versionHandler={versionHandler}
onRestoreEntity={handleRestoreTopic} onRestoreEntity={handleRestoreTopic}
onThreadLinkSelect={onThreadLinkSelect} onThreadLinkSelect={onThreadLinkSelect}
onUpdateDisplayName={handleUpdateDisplayName}
/> />
<div className="tw-mt-4 tw-flex tw-flex-col tw-flex-grow"> <div className="tw-mt-4 tw-flex tw-flex-col tw-flex-grow">
<TabsPane <TabsPane

View File

@ -44,9 +44,6 @@ export interface TopicDetailsProps {
setActiveTabHandler: (value: number) => void; setActiveTabHandler: (value: number) => void;
followTopicHandler: () => void; followTopicHandler: () => void;
unfollowTopicHandler: () => void; unfollowTopicHandler: () => void;
settingsUpdateHandler: (updatedTopic: Topic) => Promise<void>;
descriptionUpdateHandler: (updatedTopic: Topic) => Promise<void>;
tagUpdateHandler: (updatedTopic: Topic) => void;
versionHandler: () => void; versionHandler: () => void;
postFeedHandler: (value: string, id: string) => void; postFeedHandler: (value: string, id: string) => void;
deletePostHandler: ( deletePostHandler: (
@ -55,7 +52,7 @@ export interface TopicDetailsProps {
isThread: boolean isThread: boolean
) => void; ) => void;
updateThreadHandler: ThreadUpdatedFunc; updateThreadHandler: ThreadUpdatedFunc;
onExtensionUpdate: (updatedTopic: Topic) => Promise<void>; onTopicUpdate: (updatedData: Topic, key: keyof Topic) => Promise<void>;
} }
export interface TopicConfigObjectInterface { export interface TopicConfigObjectInterface {

View File

@ -19,14 +19,9 @@ import {
} from '@testing-library/react'; } from '@testing-library/react';
import React from 'react'; import React from 'react';
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import { EntityReference } from '../../generated/type/entityReference';
import { Paging } from '../../generated/type/paging'; import { Paging } from '../../generated/type/paging';
import { TagLabel } from '../../generated/type/tagLabel';
import {
LeafNodes,
LoadingNodeState,
} from '../EntityLineage/EntityLineage.interface';
import TopicDetails from './TopicDetails.component'; import TopicDetails from './TopicDetails.component';
import { TopicDetailsProps } from './TopicDetails.interface';
import { TOPIC_DETAILS } from './TopicDetails.mock'; import { TOPIC_DETAILS } from './TopicDetails.mock';
jest.mock('../common/EntitySummaryDetails/EntitySummaryDetails', () => { jest.mock('../common/EntitySummaryDetails/EntitySummaryDetails', () => {
@ -53,37 +48,15 @@ const mockUserTeam = [
}, },
]; ];
const TopicDetailsProps = { const topicDetailsProps: TopicDetailsProps = {
partitions: 0,
cleanupPolicies: [],
maximumMessageSize: 0,
replicationFactor: 0,
retentionSize: 0,
serviceType: '',
users: [],
topicDetails: TOPIC_DETAILS, topicDetails: TOPIC_DETAILS,
entityName: '',
activeTab: 1, activeTab: 1,
owner: {} as EntityReference,
description: '',
tier: {} as TagLabel,
followers: [],
topicTags: [],
slashedTopicName: [], slashedTopicName: [],
setActiveTabHandler: jest.fn(), setActiveTabHandler: jest.fn(),
followTopicHandler: jest.fn(), followTopicHandler: jest.fn(),
unfollowTopicHandler: jest.fn(), unfollowTopicHandler: jest.fn(),
settingsUpdateHandler: jest.fn(), onTopicUpdate: jest.fn(),
descriptionUpdateHandler: jest.fn(),
tagUpdateHandler: jest.fn(),
loadNodeHandler: jest.fn(),
lineageLeafNodes: {} as LeafNodes,
isNodeLoading: {} as LoadingNodeState,
version: '',
versionHandler: jest.fn(), versionHandler: jest.fn(),
addLineageHandler: jest.fn(),
removeLineageHandler: jest.fn(),
entityLineageHandler: jest.fn(),
entityThread: [], entityThread: [],
isEntityThreadLoading: false, isEntityThreadLoading: false,
postFeedHandler: jest.fn(), postFeedHandler: jest.fn(),
@ -96,17 +69,6 @@ const TopicDetailsProps = {
paging: {} as Paging, paging: {} as Paging,
fetchFeedHandler: jest.fn(), fetchFeedHandler: jest.fn(),
updateThreadHandler: jest.fn(), updateThreadHandler: jest.fn(),
lineageTabData: {
loadNodeHandler: jest.fn(),
addLineageHandler: jest.fn(),
removeLineageHandler: jest.fn(),
entityLineageHandler: jest.fn(),
isLineageLoading: false,
entityLineage: { entity: { id: 'test', type: 'topic' } },
lineageLeafNodes: {} as LeafNodes,
isNodeLoading: { id: undefined, state: false },
},
onExtensionUpdate: jest.fn(),
}; };
jest.mock('../EntityLineage/EntityLineage.component', () => { jest.mock('../EntityLineage/EntityLineage.component', () => {
@ -174,7 +136,7 @@ jest.mock('../../utils/CommonUtils', () => ({
describe('Test TopicDetails component', () => { describe('Test TopicDetails component', () => {
it('Checks if the TopicDetails component has all the proper components rendered', async () => { it('Checks if the TopicDetails component has all the proper components rendered', async () => {
const { container } = render(<TopicDetails {...TopicDetailsProps} />, { const { container } = render(<TopicDetails {...topicDetailsProps} />, {
wrapper: MemoryRouter, wrapper: MemoryRouter,
}); });
const EntityPageInfo = await findByText(container, /EntityPageInfo/i); const EntityPageInfo = await findByText(container, /EntityPageInfo/i);
@ -196,7 +158,7 @@ describe('Test TopicDetails component', () => {
}); });
it('Check if active tab is schema', async () => { it('Check if active tab is schema', async () => {
const { container } = render(<TopicDetails {...TopicDetailsProps} />, { const { container } = render(<TopicDetails {...topicDetailsProps} />, {
wrapper: MemoryRouter, wrapper: MemoryRouter,
}); });
const schema = await findByTestId(container, 'label.schema'); const schema = await findByTestId(container, 'label.schema');
@ -208,7 +170,7 @@ describe('Test TopicDetails component', () => {
it('Check if active tab is activity feed', async () => { it('Check if active tab is activity feed', async () => {
const { container } = render( const { container } = render(
<TopicDetails {...TopicDetailsProps} activeTab={2} />, <TopicDetails {...topicDetailsProps} activeTab={2} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -220,7 +182,7 @@ describe('Test TopicDetails component', () => {
it('Check if active tab is sample data', async () => { it('Check if active tab is sample data', async () => {
const { container } = render( const { container } = render(
<TopicDetails {...TopicDetailsProps} activeTab={3} />, <TopicDetails {...topicDetailsProps} activeTab={3} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -232,7 +194,7 @@ describe('Test TopicDetails component', () => {
it('Check if active tab is config', async () => { it('Check if active tab is config', async () => {
const { container } = render( const { container } = render(
<TopicDetails {...TopicDetailsProps} activeTab={4} />, <TopicDetails {...topicDetailsProps} activeTab={4} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -244,7 +206,7 @@ describe('Test TopicDetails component', () => {
it('Should render lineage tab', async () => { it('Should render lineage tab', async () => {
const { container } = render( const { container } = render(
<TopicDetails {...TopicDetailsProps} activeTab={5} />, <TopicDetails {...topicDetailsProps} activeTab={5} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -257,7 +219,7 @@ describe('Test TopicDetails component', () => {
it('Check if active tab is custom properties', async () => { it('Check if active tab is custom properties', async () => {
const { container } = render( const { container } = render(
<TopicDetails {...TopicDetailsProps} activeTab={6} />, <TopicDetails {...topicDetailsProps} activeTab={6} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }
@ -272,7 +234,7 @@ describe('Test TopicDetails component', () => {
it('Should create an observer if IntersectionObserver is available', async () => { it('Should create an observer if IntersectionObserver is available', async () => {
const { container } = render( const { container } = render(
<TopicDetails {...TopicDetailsProps} activeTab={4} />, <TopicDetails {...topicDetailsProps} activeTab={4} />,
{ {
wrapper: MemoryRouter, wrapper: MemoryRouter,
} }

View File

@ -54,7 +54,7 @@ const mockProps = {
entityFQN: 'string', entityFQN: 'string',
entityName: 'string', entityName: 'string',
onClose: jest.fn(), onClose: jest.fn(),
createAnnouncementPermission: true, createPermission: true,
}; };
describe('Test Announcement drawer component', () => { describe('Test Announcement drawer component', () => {

View File

@ -38,7 +38,7 @@ interface Props {
entityFQN: string; entityFQN: string;
entityName: string; entityName: string;
onClose: () => void; onClose: () => void;
createAnnouncementPermission?: boolean; createPermission?: boolean;
} }
const AnnouncementDrawer: FC<Props> = ({ const AnnouncementDrawer: FC<Props> = ({
@ -47,7 +47,7 @@ const AnnouncementDrawer: FC<Props> = ({
entityFQN, entityFQN,
entityType, entityType,
entityName, entityName,
createAnnouncementPermission, createPermission,
}) => { }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [isAnnouncement, setIsAnnouncement] = useState<boolean>(false); const [isAnnouncement, setIsAnnouncement] = useState<boolean>(false);
@ -119,13 +119,10 @@ const AnnouncementDrawer: FC<Props> = ({
onClose={onClose}> onClose={onClose}>
<div className="tw-flex tw-justify-end"> <div className="tw-flex tw-justify-end">
<Tooltip <Tooltip
title={ title={!createPermission && t('message.no-permission-to-view')}>
!createAnnouncementPermission &&
t('message.no-permission-to-view')
}>
<Button <Button
data-testid="add-announcement" data-testid="add-announcement"
disabled={!createAnnouncementPermission} disabled={!createPermission}
type="primary" type="primary"
onClick={() => setIsAnnouncement(true)}> onClick={() => setIsAnnouncement(true)}>
{t('label.add-entity', { entity: t('label.announcement') })} {t('label.add-entity', { entity: t('label.announcement') })}
@ -137,7 +134,7 @@ const AnnouncementDrawer: FC<Props> = ({
className="tw-p-0" className="tw-p-0"
createThread={createThread} createThread={createThread}
deletePostHandler={deletePostHandler} deletePostHandler={deletePostHandler}
editAnnouncementPermission={createAnnouncementPermission} editAnnouncementPermission={createPermission}
key={uniqueId()} key={uniqueId()}
postFeedHandler={postFeedHandler} postFeedHandler={postFeedHandler}
showHeader={false} showHeader={false}

View File

@ -547,7 +547,7 @@ const EntityPageInfo = ({
/> />
{isAnnouncementDrawerOpen && ( {isAnnouncementDrawerOpen && (
<AnnouncementDrawer <AnnouncementDrawer
createAnnouncementPermission={permission?.EditAll} createPermission={permission?.EditAll}
entityFQN={entityFqn || ''} entityFQN={entityFqn || ''}
entityName={entityName || ''} entityName={entityName || ''}
entityType={entityType || ''} entityType={entityType || ''}

View File

@ -315,6 +315,9 @@ const ManageButton: FC<Props> = ({
name: entityName, name: entityName,
displayName, displayName,
}} }}
title={t('label.edit-entity', {
entity: t('label.display-name'),
})}
visible={isDisplayNameEditing} visible={isDisplayNameEditing}
onCancel={() => setIsDisplayNameEditing(false)} onCancel={() => setIsDisplayNameEditing(false)}
onSave={handleDisplayNameUpdate} onSave={handleDisplayNameUpdate}

View File

@ -257,10 +257,20 @@ const DashboardDetailsPage = () => {
} }
}; };
const descriptionUpdateHandler = async (updatedDashboard: Dashboard) => { const onDashboardUpdate = async (
updatedDashboard: Dashboard,
key: keyof Dashboard
) => {
try { try {
const response = await saveUpdatedDashboardData(updatedDashboard); const response = await saveUpdatedDashboardData(updatedDashboard);
setDashboardDetails(response); setDashboardDetails((previous) => {
return {
...previous,
version: response.version,
[key]: response[key],
};
});
getEntityFeedCount(); getEntityFeedCount();
} catch (error) { } catch (error) {
showErrorToast(error as AxiosError); showErrorToast(error as AxiosError);
@ -310,37 +320,6 @@ const DashboardDetailsPage = () => {
} }
}; };
const onTagUpdate = async (updatedDashboard: Dashboard) => {
try {
const res = await saveUpdatedDashboardData(updatedDashboard);
setDashboardDetails(res);
getEntityFeedCount();
} catch (error) {
showErrorToast(
error as AxiosError,
t('server.entity-updating-error', {
entity: t('label.tag-plural'),
})
);
}
};
const settingsUpdateHandler = async (
updatedDashboard: Dashboard
): Promise<void> => {
try {
const res = await saveUpdatedDashboardData(updatedDashboard);
setDashboardDetails(res);
getEntityFeedCount();
} catch (error) {
showErrorToast(
t('server.entity-updating-error', {
entity: getEntityName(updatedDashboard),
})
);
}
};
const onChartUpdate = async ( const onChartUpdate = async (
index: number, index: number,
chartId: string, chartId: string,
@ -456,21 +435,6 @@ const DashboardDetailsPage = () => {
updateThreadData(threadId, postId, isThread, data, setEntityThread); updateThreadData(threadId, postId, isThread, data, setEntityThread);
}; };
const handleExtensionUpdate = async (updatedDashboard: Dashboard) => {
try {
const data = await saveUpdatedDashboardData(updatedDashboard);
setDashboardDetails(data);
getEntityFeedCount();
} catch (error) {
showErrorToast(
error as AxiosError,
t('server.entity-updating-error', {
entity: dashboardDetails.name,
})
);
}
};
useEffect(() => { useEffect(() => {
if ( if (
dashboardDetailsTabs[activeTab - 1].field === dashboardDetailsTabs[activeTab - 1].field ===
@ -501,50 +465,43 @@ const DashboardDetailsPage = () => {
if (isLoading) { if (isLoading) {
return <Loader />; return <Loader />;
} }
if (isError) {
return (
<ErrorPlaceHolder>
{getEntityMissingError('dashboard', dashboardFQN)}
</ErrorPlaceHolder>
);
}
if (!dashboardPermissions.ViewAll && !dashboardPermissions.ViewBasic) {
return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />;
}
return ( return (
<> <DashboardDetails
{isError ? ( activeTab={activeTab}
<ErrorPlaceHolder> chartDescriptionUpdateHandler={onChartUpdate}
{getEntityMissingError('dashboard', dashboardFQN)} chartTagUpdateHandler={handleChartTagSelection}
</ErrorPlaceHolder> charts={charts}
) : ( createThread={createThread}
<> dashboardDetails={dashboardDetails}
{dashboardPermissions.ViewAll || dashboardPermissions.ViewBasic ? ( dashboardFQN={dashboardFQN}
<DashboardDetails deletePostHandler={deletePostHandler}
activeTab={activeTab} entityFieldTaskCount={entityFieldTaskCount}
chartDescriptionUpdateHandler={onChartUpdate} entityFieldThreadCount={entityFieldThreadCount}
chartTagUpdateHandler={handleChartTagSelection} entityThread={entityThread}
charts={charts} feedCount={feedCount}
createThread={createThread} fetchFeedHandler={getFeedData}
dashboardDetails={dashboardDetails} followDashboardHandler={followDashboard}
dashboardFQN={dashboardFQN} isEntityThreadLoading={isEntityThreadLoading}
deletePostHandler={deletePostHandler} paging={paging}
descriptionUpdateHandler={descriptionUpdateHandler} postFeedHandler={postFeedHandler}
entityFieldTaskCount={entityFieldTaskCount} setActiveTabHandler={activeTabHandler}
entityFieldThreadCount={entityFieldThreadCount} slashedDashboardName={slashedDashboardName}
entityThread={entityThread} unfollowDashboardHandler={unFollowDashboard}
feedCount={feedCount} updateThreadHandler={updateThreadHandler}
fetchFeedHandler={getFeedData} versionHandler={versionHandler}
followDashboardHandler={followDashboard} onDashboardUpdate={onDashboardUpdate}
isEntityThreadLoading={isEntityThreadLoading} />
paging={paging}
postFeedHandler={postFeedHandler}
setActiveTabHandler={activeTabHandler}
settingsUpdateHandler={settingsUpdateHandler}
slashedDashboardName={slashedDashboardName}
tagUpdateHandler={onTagUpdate}
unfollowDashboardHandler={unFollowDashboard}
updateThreadHandler={updateThreadHandler}
versionHandler={versionHandler}
onExtensionUpdate={handleExtensionUpdate}
/>
) : (
<ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />
)}
</>
)}
</>
); );
}; };

View File

@ -493,27 +493,6 @@ const DatasetDetailsPage: FunctionComponent = () => {
updateThreadData(threadId, postId, isThread, data, setEntityThread); updateThreadData(threadId, postId, isThread, data, setEntityThread);
}; };
const handleExtensionUpdate = async (updatedTable: Table) => {
try {
const {
version,
owner: ownerValue,
tags,
extension,
} = await saveUpdatedTableData(updatedTable);
setTableDetails((previous) => ({
...previous,
version,
owner: ownerValue,
tags,
extension,
}));
getEntityFeedCount();
} catch (error) {
showErrorToast(error as AxiosError);
}
};
useEffect(() => { useEffect(() => {
if (tablePermissions.ViewAll || tablePermissions.ViewBasic) { if (tablePermissions.ViewAll || tablePermissions.ViewBasic) {
fetchTableDetail(); fetchTableDetail();
@ -568,7 +547,6 @@ const DatasetDetailsPage: FunctionComponent = () => {
feedCount={feedCount} feedCount={feedCount}
fetchFeedHandler={handleFeedFetchFromFeedList} fetchFeedHandler={handleFeedFetchFromFeedList}
followTableHandler={followTable} followTableHandler={followTable}
handleExtensionUpdate={handleExtensionUpdate}
isEntityThreadLoading={isEntityThreadLoading} isEntityThreadLoading={isEntityThreadLoading}
isSampleDataLoading={isSampleDataLoading} isSampleDataLoading={isSampleDataLoading}
isTableProfileLoading={isTableProfileLoading} isTableProfileLoading={isTableProfileLoading}

View File

@ -62,7 +62,6 @@ import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils';
import { showErrorToast } from '../../utils/ToastUtils'; import { showErrorToast } from '../../utils/ToastUtils';
import { import {
getCurrentTopicTab, getCurrentTopicTab,
getFormattedTopicDetails,
topicDetailsTabs, topicDetailsTabs,
} from '../../utils/TopicDetailsUtils'; } from '../../utils/TopicDetailsUtils';
@ -167,6 +166,31 @@ const TopicDetailsPage: FunctionComponent = () => {
return patchTopicDetails(topicId, jsonPatch); return patchTopicDetails(topicId, jsonPatch);
}; };
const onTopicUpdate = async (updatedData: Topic, key: keyof Topic) => {
try {
const res = await saveUpdatedTopicData(updatedData);
setTopicDetails((previous) => {
if (key === 'tags') {
return {
...previous,
version: res.version,
[key]: sortTagsCaseInsensitive(res.tags ?? []),
};
}
return {
...previous,
version: res.version,
[key]: res[key],
};
});
getEntityFeedCount();
} catch (error) {
showErrorToast(error as AxiosError);
}
};
const fetchResourcePermission = async (entityFqn: string) => { const fetchResourcePermission = async (entityFqn: string) => {
setLoading(true); setLoading(true);
try { try {
@ -275,51 +299,6 @@ const TopicDetailsPage: FunctionComponent = () => {
} }
}; };
const descriptionUpdateHandler = async (updatedTopic: Topic) => {
try {
const response = await saveUpdatedTopicData(updatedTopic);
setTopicDetails(response);
getEntityFeedCount();
} catch (error) {
showErrorToast(error as AxiosError);
}
};
const settingsUpdateHandler = async (updatedTopic: Topic): Promise<void> => {
try {
const res = await saveUpdatedTopicData(updatedTopic);
const formattedTopicDetails = getFormattedTopicDetails(res);
setTopicDetails(formattedTopicDetails);
getEntityFeedCount();
} catch (error) {
showErrorToast(
error as AxiosError,
t('server.entity-updating-error', {
entity: getEntityName(topicDetails),
})
);
}
};
const onTagUpdate = async (updatedTopic: Topic) => {
try {
const res = await saveUpdatedTopicData(updatedTopic);
setTopicDetails({
...res,
tags: sortTagsCaseInsensitive(res.tags || []),
});
getEntityFeedCount();
} catch (error) {
showErrorToast(
error as AxiosError,
t('server.entity-updating-error', {
entity: t('label.tag-plural'),
})
);
}
};
const versionHandler = () => { const versionHandler = () => {
currentVersion && currentVersion &&
history.push( history.push(
@ -390,21 +369,6 @@ const TopicDetailsPage: FunctionComponent = () => {
updateThreadData(threadId, postId, isThread, data, setEntityThread); updateThreadData(threadId, postId, isThread, data, setEntityThread);
}; };
const handleExtensionUpdate = async (updatedTopic: Topic) => {
try {
const data = await saveUpdatedTopicData(updatedTopic);
setTopicDetails(data);
getEntityFeedCount();
} catch (error) {
showErrorToast(
error as AxiosError,
t('server.entity-updating-error', {
entity: topicDetails.name,
})
);
}
};
useEffect(() => { useEffect(() => {
if (topicDetailsTabs[activeTab - 1].path !== tab) { if (topicDetailsTabs[activeTab - 1].path !== tab) {
setActiveTab(getCurrentTopicTab(tab)); setActiveTab(getCurrentTopicTab(tab));
@ -429,48 +393,43 @@ const TopicDetailsPage: FunctionComponent = () => {
} }
}, [topicPermissions, topicFQN]); }, [topicPermissions, topicFQN]);
if (isLoading) {
return <Loader />;
}
if (isError) {
return (
<ErrorPlaceHolder>
{getEntityMissingError('topic', topicFQN)}
</ErrorPlaceHolder>
);
}
if (!topicPermissions.ViewAll && !topicPermissions.ViewBasic) {
return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />;
}
return ( return (
<> <TopicDetails
{isLoading ? ( activeTab={activeTab}
<Loader /> createThread={createThread}
) : isError ? ( deletePostHandler={deletePostHandler}
<ErrorPlaceHolder> entityFieldTaskCount={entityFieldTaskCount}
{getEntityMissingError('topic', topicFQN)} entityFieldThreadCount={entityFieldThreadCount}
</ErrorPlaceHolder> entityThread={entityThread}
) : ( feedCount={feedCount}
<> fetchFeedHandler={handleFeedFetchFromFeedList}
{topicPermissions.ViewAll || topicPermissions.ViewBasic ? ( followTopicHandler={followTopic}
<TopicDetails isEntityThreadLoading={isEntityThreadLoading}
activeTab={activeTab} paging={paging}
createThread={createThread} postFeedHandler={postFeedHandler}
deletePostHandler={deletePostHandler} setActiveTabHandler={activeTabHandler}
descriptionUpdateHandler={descriptionUpdateHandler} slashedTopicName={slashedTopicName}
entityFieldTaskCount={entityFieldTaskCount} topicDetails={topicDetails}
entityFieldThreadCount={entityFieldThreadCount} topicFQN={topicFQN}
entityThread={entityThread} unfollowTopicHandler={unFollowTopic}
feedCount={feedCount} updateThreadHandler={updateThreadHandler}
fetchFeedHandler={handleFeedFetchFromFeedList} versionHandler={versionHandler}
followTopicHandler={followTopic} onTopicUpdate={onTopicUpdate}
isEntityThreadLoading={isEntityThreadLoading} />
paging={paging}
postFeedHandler={postFeedHandler}
setActiveTabHandler={activeTabHandler}
settingsUpdateHandler={settingsUpdateHandler}
slashedTopicName={slashedTopicName}
tagUpdateHandler={onTagUpdate}
topicDetails={topicDetails}
topicFQN={topicFQN}
unfollowTopicHandler={unFollowTopic}
updateThreadHandler={updateThreadHandler}
versionHandler={versionHandler}
onExtensionUpdate={handleExtensionUpdate}
/>
) : (
<ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />
)}
</>
)}
</>
); );
}; };

View File

@ -977,6 +977,9 @@ const TagsPage = () => {
<EntityNameModal <EntityNameModal
allowRename allowRename
entity={currentClassification as EntityReference} entity={currentClassification as EntityReference}
title={t('label.edit-entity', {
entity: t('label.name'),
})}
visible={isNameEditing} visible={isNameEditing}
onCancel={() => setIsNameEditing(false)} onCancel={() => setIsNameEditing(false)}
onSave={handleRenameSave} onSave={handleRenameSave}

View File

@ -171,7 +171,6 @@ const TourPage = () => {
feedCount={0} feedCount={0}
fetchFeedHandler={handleCountChange} fetchFeedHandler={handleCountChange}
followTableHandler={handleCountChange} followTableHandler={handleCountChange}
handleExtensionUpdate={handleCountChange}
isEntityThreadLoading={false} isEntityThreadLoading={false}
paging={{} as Paging} paging={{} as Paging}
postFeedHandler={handleCountChange} postFeedHandler={handleCountChange}