forked from github/plane
chore: update view button (#523)
This commit is contained in:
parent
7731ee5de4
commit
3d34741356
@ -118,18 +118,6 @@ export const IssuesView: React.FC<Props> = ({
|
|||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
const { data: viewDetails } = useSWR(
|
|
||||||
workspaceSlug && projectId && viewId ? VIEW_DETAILS(viewId as string) : null,
|
|
||||||
workspaceSlug && projectId && viewId
|
|
||||||
? () =>
|
|
||||||
viewsService.getViewDetails(
|
|
||||||
workspaceSlug as string,
|
|
||||||
projectId as string,
|
|
||||||
viewId as string
|
|
||||||
)
|
|
||||||
: null
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleDeleteIssue = useCallback(
|
const handleDeleteIssue = useCallback(
|
||||||
(issue: IIssue) => {
|
(issue: IIssue) => {
|
||||||
setDeleteIssueModal(true);
|
setDeleteIssueModal(true);
|
||||||
@ -405,8 +393,6 @@ export const IssuesView: React.FC<Props> = ({
|
|||||||
(key) => filters[key as keyof IIssueFilterOptions] === null
|
(key) => filters[key as keyof IIssueFilterOptions] === null
|
||||||
);
|
);
|
||||||
|
|
||||||
const isUpdatingView = JSON.stringify(filters) === JSON.stringify(viewDetails?.query_data);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<CreateUpdateViewModal
|
<CreateUpdateViewModal
|
||||||
@ -556,49 +542,27 @@ export const IssuesView: React.FC<Props> = ({
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{viewId
|
{Object.keys(filters).length > 0 && nullFilters.length !== Object.keys(filters).length && (
|
||||||
? isUpdatingView && (
|
<PrimaryButton
|
||||||
<PrimaryButton
|
onClick={() => {
|
||||||
onClick={() => {
|
if (viewId) {
|
||||||
if (viewId) {
|
setFilters({}, true);
|
||||||
setFilters({}, true);
|
setToastAlert({
|
||||||
setToastAlert({
|
title: "View updated",
|
||||||
title: "View updated",
|
message: "Your view has been updated",
|
||||||
message: "Your view has been updated",
|
type: "success",
|
||||||
type: "success",
|
});
|
||||||
});
|
} else
|
||||||
} else
|
setCreateViewModal({
|
||||||
setCreateViewModal({
|
query: filters,
|
||||||
query: filters,
|
});
|
||||||
});
|
}}
|
||||||
}}
|
className="flex items-center gap-2 text-sm"
|
||||||
className="flex items-center gap-2 text-sm"
|
>
|
||||||
>
|
{!viewId && <PlusIcon className="h-4 w-4" />}
|
||||||
Update view
|
{viewId ? "Update" : "Save"} view
|
||||||
</PrimaryButton>
|
</PrimaryButton>
|
||||||
)
|
)}
|
||||||
: Object.keys(filters).length > 0 &&
|
|
||||||
nullFilters.length !== Object.keys(filters).length && (
|
|
||||||
<PrimaryButton
|
|
||||||
onClick={() => {
|
|
||||||
if (viewId) {
|
|
||||||
setFilters({}, true);
|
|
||||||
setToastAlert({
|
|
||||||
title: "View updated",
|
|
||||||
message: "Your view has been updated",
|
|
||||||
type: "success",
|
|
||||||
});
|
|
||||||
} else
|
|
||||||
setCreateViewModal({
|
|
||||||
query: filters,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
className="flex items-center gap-2 text-sm"
|
|
||||||
>
|
|
||||||
<PlusIcon className="h-4 w-4" />
|
|
||||||
Save view
|
|
||||||
</PrimaryButton>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<DragDropContext onDragEnd={handleOnDragEnd}>
|
<DragDropContext onDragEnd={handleOnDragEnd}>
|
||||||
<StrictModeDroppable droppableId="trashBox">
|
<StrictModeDroppable droppableId="trashBox">
|
||||||
|
Loading…
Reference in New Issue
Block a user