mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-16 10:53:31 +00:00
Fix: UI: Changes to adopt to the new Pipeline APIs. (#1032)
This commit is contained in:
parent
ea4e3b4319
commit
255819a352
@ -1,24 +0,0 @@
|
|||||||
import { AxiosResponse } from 'axios';
|
|
||||||
import { Task } from '../generated/entity/data/pipeline';
|
|
||||||
import { getURLWithQueryFields } from '../utils/APIUtils';
|
|
||||||
import APIClient from './index';
|
|
||||||
|
|
||||||
export const getTaskById: Function = (
|
|
||||||
id: string,
|
|
||||||
arrQueryFields: string
|
|
||||||
): Promise<AxiosResponse> => {
|
|
||||||
const url = getURLWithQueryFields(`/tasks/${id}`, arrQueryFields);
|
|
||||||
|
|
||||||
return APIClient.get(url);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const updateTask: Function = (
|
|
||||||
id: string,
|
|
||||||
data: Task
|
|
||||||
): Promise<AxiosResponse> => {
|
|
||||||
const configOptions = {
|
|
||||||
headers: { 'Content-type': 'application/json-patch+json' },
|
|
||||||
};
|
|
||||||
|
|
||||||
return APIClient.patch(`/tasks/${id}`, data, configOptions);
|
|
||||||
};
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { AxiosPromise, AxiosResponse } from 'axios';
|
import { AxiosResponse } from 'axios';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { compare } from 'fast-json-patch';
|
import { compare } from 'fast-json-patch';
|
||||||
import { EntityTags, TableDetail } from 'Models';
|
import { EntityTags, TableDetail } from 'Models';
|
||||||
@ -13,10 +13,8 @@ import {
|
|||||||
removeFollower,
|
removeFollower,
|
||||||
} from '../../axiosAPIs/pipelineAPI';
|
} from '../../axiosAPIs/pipelineAPI';
|
||||||
import { getServiceById } from '../../axiosAPIs/serviceAPI';
|
import { getServiceById } from '../../axiosAPIs/serviceAPI';
|
||||||
import { getTaskById, updateTask } from '../../axiosAPIs/taskAPI';
|
|
||||||
import Description from '../../components/common/description/Description';
|
import Description from '../../components/common/description/Description';
|
||||||
import EntityPageInfo from '../../components/common/entityPageInfo/EntityPageInfo';
|
import EntityPageInfo from '../../components/common/entityPageInfo/EntityPageInfo';
|
||||||
import NonAdminAction from '../../components/common/non-admin-action/NonAdminAction';
|
|
||||||
import RichTextEditorPreviewer from '../../components/common/rich-text-editor/RichTextEditorPreviewer';
|
import RichTextEditorPreviewer from '../../components/common/rich-text-editor/RichTextEditorPreviewer';
|
||||||
import TabsPane from '../../components/common/TabsPane/TabsPane';
|
import TabsPane from '../../components/common/TabsPane/TabsPane';
|
||||||
import { TitleBreadcrumbProps } from '../../components/common/title-breadcrumb/title-breadcrumb.interface';
|
import { TitleBreadcrumbProps } from '../../components/common/title-breadcrumb/title-breadcrumb.interface';
|
||||||
@ -25,8 +23,6 @@ import Entitylineage from '../../components/EntityLineage/EntityLineage.componen
|
|||||||
import Loader from '../../components/Loader/Loader';
|
import Loader from '../../components/Loader/Loader';
|
||||||
import ManageTab from '../../components/ManageTab/ManageTab.component';
|
import ManageTab from '../../components/ManageTab/ManageTab.component';
|
||||||
import { ModalWithMarkdownEditor } from '../../components/Modals/ModalWithMarkdownEditor/ModalWithMarkdownEditor';
|
import { ModalWithMarkdownEditor } from '../../components/Modals/ModalWithMarkdownEditor/ModalWithMarkdownEditor';
|
||||||
import TagsContainer from '../../components/tags-container/tags-container';
|
|
||||||
import Tags from '../../components/tags/tags';
|
|
||||||
import {
|
import {
|
||||||
getServiceDetailsPath,
|
getServiceDetailsPath,
|
||||||
getTeamDetailsPath,
|
getTeamDetailsPath,
|
||||||
@ -40,7 +36,6 @@ import { useAuth } from '../../hooks/authHooks';
|
|||||||
import {
|
import {
|
||||||
addToRecentViewed,
|
addToRecentViewed,
|
||||||
getCurrentUserId,
|
getCurrentUserId,
|
||||||
getHtmlForNonAdminAction,
|
|
||||||
getUserTeams,
|
getUserTeams,
|
||||||
isEven,
|
isEven,
|
||||||
} from '../../utils/CommonUtils';
|
} from '../../utils/CommonUtils';
|
||||||
@ -78,8 +73,6 @@ const MyPipelinePage = () => {
|
|||||||
const [pipelineUrl, setPipelineUrl] = useState<string>('');
|
const [pipelineUrl, setPipelineUrl] = useState<string>('');
|
||||||
const [displayName, setDisplayName] = useState<string>('');
|
const [displayName, setDisplayName] = useState<string>('');
|
||||||
const [serviceType, setServiceType] = useState<string>('');
|
const [serviceType, setServiceType] = useState<string>('');
|
||||||
// const [usage, setUsage] = useState('');
|
|
||||||
// const [weeklyUsageCount, setWeeklyUsageCount] = useState('');
|
|
||||||
const [slashedPipelineName, setSlashedPipelineName] = useState<
|
const [slashedPipelineName, setSlashedPipelineName] = useState<
|
||||||
TitleBreadcrumbProps['titleLinks']
|
TitleBreadcrumbProps['titleLinks']
|
||||||
>([]);
|
>([]);
|
||||||
@ -88,10 +81,7 @@ const MyPipelinePage = () => {
|
|||||||
task: Task;
|
task: Task;
|
||||||
index: number;
|
index: number;
|
||||||
}>();
|
}>();
|
||||||
const [editTaskTags, setEditTaskTags] = useState<{
|
|
||||||
task: Task;
|
|
||||||
index: number;
|
|
||||||
}>();
|
|
||||||
const [entityLineage, setEntityLineage] = useState<EntityLineage>(
|
const [entityLineage, setEntityLineage] = useState<EntityLineage>(
|
||||||
{} as EntityLineage
|
{} as EntityLineage
|
||||||
);
|
);
|
||||||
@ -155,8 +145,6 @@ const MyPipelinePage = () => {
|
|||||||
isLink: true,
|
isLink: true,
|
||||||
openInNewTab: true,
|
openInNewTab: true,
|
||||||
},
|
},
|
||||||
// { key: 'Usage', value: usage },
|
|
||||||
// { key: 'Queries', value: `${weeklyUsageCount} past week` },
|
|
||||||
];
|
];
|
||||||
const fetchTags = () => {
|
const fetchTags = () => {
|
||||||
getTagCategories().then((res) => {
|
getTagCategories().then((res) => {
|
||||||
@ -166,30 +154,6 @@ const MyPipelinePage = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchTasks = async (tasks: Pipeline['tasks']) => {
|
|
||||||
let tasksData: Task[] = [];
|
|
||||||
let promiseArr: Array<AxiosPromise> = [];
|
|
||||||
if (tasks?.length) {
|
|
||||||
promiseArr = tasks.map((task) =>
|
|
||||||
getTaskById(task.id, ['service', 'tags'])
|
|
||||||
);
|
|
||||||
await Promise.allSettled(promiseArr).then(
|
|
||||||
(res: PromiseSettledResult<AxiosResponse>[]) => {
|
|
||||||
if (res.length) {
|
|
||||||
tasksData = res
|
|
||||||
.filter((task) => task.status === 'fulfilled')
|
|
||||||
.map(
|
|
||||||
(task) =>
|
|
||||||
(task as PromiseFulfilledResult<AxiosResponse>).value.data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tasksData;
|
|
||||||
};
|
|
||||||
|
|
||||||
const setFollowersData = (followers: Array<User>) => {
|
const setFollowersData = (followers: Array<User>) => {
|
||||||
// need to check if already following or not with logedIn user id
|
// need to check if already following or not with logedIn user id
|
||||||
setIsFollowing(followers.some(({ id }: { id: string }) => id === USERId));
|
setIsFollowing(followers.some(({ id }: { id: string }) => id === USERId));
|
||||||
@ -203,7 +167,6 @@ const MyPipelinePage = () => {
|
|||||||
'service',
|
'service',
|
||||||
'followers',
|
'followers',
|
||||||
'tags',
|
'tags',
|
||||||
'usageSummary',
|
|
||||||
'tasks',
|
'tasks',
|
||||||
]).then((res: AxiosResponse) => {
|
]).then((res: AxiosResponse) => {
|
||||||
const {
|
const {
|
||||||
@ -217,7 +180,6 @@ const MyPipelinePage = () => {
|
|||||||
displayName,
|
displayName,
|
||||||
tasks,
|
tasks,
|
||||||
pipelineUrl,
|
pipelineUrl,
|
||||||
// usageSummary,
|
|
||||||
} = res.data;
|
} = res.data;
|
||||||
setDisplayName(displayName);
|
setDisplayName(displayName);
|
||||||
setPipelineDetails(res.data);
|
setPipelineDetails(res.data);
|
||||||
@ -260,19 +222,7 @@ const MyPipelinePage = () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
setPipelineUrl(pipelineUrl);
|
setPipelineUrl(pipelineUrl);
|
||||||
fetchTasks(tasks).then((tasks) => setTasks(tasks));
|
setTasks(tasks);
|
||||||
// if (!isNil(usageSummary?.weeklyStats.percentileRank)) {
|
|
||||||
// const percentile = getUsagePercentile(
|
|
||||||
// usageSummary.weeklyStats.percentileRank
|
|
||||||
// );
|
|
||||||
// setUsage(percentile);
|
|
||||||
// } else {
|
|
||||||
// setUsage('--');
|
|
||||||
// }
|
|
||||||
// setWeeklyUsageCount(
|
|
||||||
// usageSummary?.weeklyStats.count.toLocaleString() || '--'
|
|
||||||
// );
|
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -379,20 +329,18 @@ const MyPipelinePage = () => {
|
|||||||
|
|
||||||
const onTaskUpdate = (taskDescription: string) => {
|
const onTaskUpdate = (taskDescription: string) => {
|
||||||
if (editTask) {
|
if (editTask) {
|
||||||
|
const updatedTasks = [...(pipelineDetails.tasks || [])];
|
||||||
|
|
||||||
const updatedTask = {
|
const updatedTask = {
|
||||||
...editTask.task,
|
...editTask.task,
|
||||||
description: taskDescription,
|
description: taskDescription,
|
||||||
};
|
};
|
||||||
const jsonPatch = compare(tasks[editTask.index], updatedTask);
|
updatedTasks[editTask.index] = updatedTask;
|
||||||
updateTask(editTask.task.id, jsonPatch).then((res: AxiosResponse) => {
|
|
||||||
if (res.data) {
|
|
||||||
setTasks((prevTasks) => {
|
|
||||||
const tasks = [...prevTasks];
|
|
||||||
tasks[editTask.index] = res.data;
|
|
||||||
|
|
||||||
return tasks;
|
const updatedPipeline = { ...pipelineDetails, tasks: updatedTasks };
|
||||||
});
|
const jsonPatch = compare(pipelineDetails, updatedPipeline);
|
||||||
}
|
patchPipelineDetails(pipelineId, jsonPatch).then((res: AxiosResponse) => {
|
||||||
|
setTasks(res.data.tasks || []);
|
||||||
});
|
});
|
||||||
setEditTask(undefined);
|
setEditTask(undefined);
|
||||||
} else {
|
} else {
|
||||||
@ -400,49 +348,6 @@ const MyPipelinePage = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEditTaskTag = (task: Task, index: number): void => {
|
|
||||||
setEditTaskTags({ task, index });
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleTaskTagSelection = (selectedTags?: Array<EntityTags>) => {
|
|
||||||
if (selectedTags && editTaskTags) {
|
|
||||||
const prevTags = editTaskTags.task.tags?.filter((tag) =>
|
|
||||||
selectedTags.some((selectedTag) => selectedTag.tagFQN === tag.tagFQN)
|
|
||||||
);
|
|
||||||
const newTags = selectedTags
|
|
||||||
.filter(
|
|
||||||
(selectedTag) =>
|
|
||||||
!editTaskTags.task.tags?.some(
|
|
||||||
(tag) => tag.tagFQN === selectedTag.tagFQN
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.map((tag) => ({
|
|
||||||
labelType: 'Manual',
|
|
||||||
state: 'Confirmed',
|
|
||||||
tagFQN: tag.tagFQN,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const updatedTask = {
|
|
||||||
...editTaskTags.task,
|
|
||||||
tags: [...(prevTags as TagLabel[]), ...newTags],
|
|
||||||
};
|
|
||||||
const jsonPatch = compare(tasks[editTaskTags.index], updatedTask);
|
|
||||||
updateTask(editTaskTags.task.id, jsonPatch).then((res: AxiosResponse) => {
|
|
||||||
if (res.data) {
|
|
||||||
setTasks((prevTasks) => {
|
|
||||||
const tasks = [...prevTasks];
|
|
||||||
tasks[editTaskTags.index] = res.data;
|
|
||||||
|
|
||||||
return tasks;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setEditTaskTags(undefined);
|
|
||||||
} else {
|
|
||||||
setEditTaskTags(undefined);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchPipelineDetail(pipelineFQN);
|
fetchPipelineDetail(pipelineFQN);
|
||||||
setActiveTab(1);
|
setActiveTab(1);
|
||||||
@ -513,7 +418,7 @@ const MyPipelinePage = () => {
|
|||||||
<tr className="tableHead-row">
|
<tr className="tableHead-row">
|
||||||
<th className="tableHead-cell">Task Name</th>
|
<th className="tableHead-cell">Task Name</th>
|
||||||
<th className="tableHead-cell">Description</th>
|
<th className="tableHead-cell">Description</th>
|
||||||
<th className="tableHead-cell tw-w-60">Tags</th>
|
<th className="tableHead-cell">Task Type</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="tableBody">
|
<tbody className="tableBody">
|
||||||
@ -567,49 +472,7 @@ const MyPipelinePage = () => {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td
|
<td className="tableBody-cell">{task.taskType}</td>
|
||||||
className="tw-group tw-relative tableBody-cell"
|
|
||||||
onClick={() => {
|
|
||||||
if (!editTaskTags) {
|
|
||||||
handleEditTaskTag(task, index);
|
|
||||||
}
|
|
||||||
}}>
|
|
||||||
<NonAdminAction
|
|
||||||
html={getHtmlForNonAdminAction(Boolean(owner))}
|
|
||||||
isOwner={hasEditAccess()}
|
|
||||||
position="left"
|
|
||||||
trigger="click">
|
|
||||||
<TagsContainer
|
|
||||||
editable={editTaskTags?.index === index}
|
|
||||||
selectedTags={task.tags as EntityTags[]}
|
|
||||||
tagList={tagList}
|
|
||||||
onCancel={() => {
|
|
||||||
handleTaskTagSelection();
|
|
||||||
}}
|
|
||||||
onSelectionChange={(tags) => {
|
|
||||||
handleTaskTagSelection(tags);
|
|
||||||
}}>
|
|
||||||
{task.tags?.length ? (
|
|
||||||
<button className="tw-opacity-0 tw-ml-1 group-hover:tw-opacity-100 focus:tw-outline-none">
|
|
||||||
<SVGIcons
|
|
||||||
alt="edit"
|
|
||||||
icon="icon-edit"
|
|
||||||
title="Edit"
|
|
||||||
width="10px"
|
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
) : (
|
|
||||||
<span className="tw-opacity-0 group-hover:tw-opacity-100">
|
|
||||||
<Tags
|
|
||||||
className="tw-border-main"
|
|
||||||
tag="+ Add tag"
|
|
||||||
type="outlined"
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</TagsContainer>
|
|
||||||
</NonAdminAction>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user