forked from github/plane
fix: workspace view filters count fix (#2307)
This commit is contained in:
parent
f1879a404d
commit
4cab00ec79
@ -299,8 +299,6 @@ export const WorkspaceFiltersList: React.FC<Props> = ({
|
|||||||
: key === "project"
|
: key === "project"
|
||||||
? filters.project?.map((projectId) => {
|
? filters.project?.map((projectId) => {
|
||||||
const currentProject = project?.find((p) => p.id === projectId);
|
const currentProject = project?.find((p) => p.id === projectId);
|
||||||
console.log("currentProject", currentProject);
|
|
||||||
console.log("currentProject", projectId);
|
|
||||||
return (
|
return (
|
||||||
<p
|
<p
|
||||||
key={currentProject?.id}
|
key={currentProject?.id}
|
||||||
|
@ -12,7 +12,6 @@ import { CustomMenu } from "components/ui";
|
|||||||
import viewsService from "services/views.service";
|
import viewsService from "services/views.service";
|
||||||
// types
|
// types
|
||||||
import { IView } from "types";
|
import { IView } from "types";
|
||||||
import { IWorkspaceView } from "types/workspace-views";
|
|
||||||
// fetch keys
|
// fetch keys
|
||||||
import { VIEWS_LIST } from "constants/fetch-keys";
|
import { VIEWS_LIST } from "constants/fetch-keys";
|
||||||
// hooks
|
// hooks
|
||||||
@ -21,18 +20,12 @@ import useToast from "hooks/use-toast";
|
|||||||
import { truncateText } from "helpers/string.helper";
|
import { truncateText } from "helpers/string.helper";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
view: IView | IWorkspaceView;
|
view: IView;
|
||||||
viewType: "project" | "workspace";
|
|
||||||
handleEditView: () => void;
|
handleEditView: () => void;
|
||||||
handleDeleteView: () => void;
|
handleDeleteView: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SingleViewItem: React.FC<Props> = ({
|
export const SingleViewItem: React.FC<Props> = ({ view, handleEditView, handleDeleteView }) => {
|
||||||
view,
|
|
||||||
viewType,
|
|
||||||
handleEditView,
|
|
||||||
handleDeleteView,
|
|
||||||
}) => {
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug, projectId } = router.query;
|
const { workspaceSlug, projectId } = router.query;
|
||||||
|
|
||||||
@ -88,10 +81,7 @@ export const SingleViewItem: React.FC<Props> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const viewRedirectionUrl =
|
const viewRedirectionUrl = `/${workspaceSlug}/projects/${projectId}/views/${view.id}`;
|
||||||
viewType === "project"
|
|
||||||
? `/${workspaceSlug}/projects/${projectId}/views/${view.id}`
|
|
||||||
: `/${workspaceSlug}/workspace-views/issues?globalViewId=${view.id}`;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="group hover:bg-custom-background-90 border-b border-custom-border-200">
|
<div className="group hover:bg-custom-background-90 border-b border-custom-border-200">
|
||||||
@ -126,8 +116,7 @@ export const SingleViewItem: React.FC<Props> = ({
|
|||||||
filters
|
filters
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{viewType === "project" ? (
|
{view.is_favorite ? (
|
||||||
view.is_favorite ? (
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
@ -149,8 +138,7 @@ export const SingleViewItem: React.FC<Props> = ({
|
|||||||
>
|
>
|
||||||
<StarIcon className="h-4 w-4 " color="rgb(var(--color-text-200))" />
|
<StarIcon className="h-4 w-4 " color="rgb(var(--color-text-200))" />
|
||||||
</button>
|
</button>
|
||||||
)
|
)}
|
||||||
) : null}
|
|
||||||
<CustomMenu width="auto" ellipsis>
|
<CustomMenu width="auto" ellipsis>
|
||||||
<CustomMenu.MenuItem
|
<CustomMenu.MenuItem
|
||||||
onClick={(e: any) => {
|
onClick={(e: any) => {
|
||||||
|
110
web/components/workspace/views/single-workspace-view-item.tsx
Normal file
110
web/components/workspace/views/single-workspace-view-item.tsx
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
import Link from "next/link";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
|
// icons
|
||||||
|
import { TrashIcon, PencilIcon } from "@heroicons/react/24/outline";
|
||||||
|
import { PhotoFilterOutlined } from "@mui/icons-material";
|
||||||
|
//components
|
||||||
|
import { CustomMenu } from "components/ui";
|
||||||
|
import { IWorkspaceView } from "types/workspace-views";
|
||||||
|
// helpers
|
||||||
|
import { truncateText } from "helpers/string.helper";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
view: IWorkspaceView;
|
||||||
|
handleEditView: () => void;
|
||||||
|
handleDeleteView: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const SingleWorkspaceViewItem: React.FC<Props> = ({
|
||||||
|
view,
|
||||||
|
handleEditView,
|
||||||
|
handleDeleteView,
|
||||||
|
}) => {
|
||||||
|
const router = useRouter();
|
||||||
|
const { workspaceSlug } = router.query;
|
||||||
|
|
||||||
|
const viewRedirectionUrl = `/${workspaceSlug}/workspace-views/issues?globalViewId=${view.id}`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="group hover:bg-custom-background-90 border-b border-custom-border-200">
|
||||||
|
<Link href={viewRedirectionUrl}>
|
||||||
|
<a className="flex items-center justify-between relative rounded px-5 py-4 w-full">
|
||||||
|
<div className="flex items-center justify-between w-full">
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<div
|
||||||
|
className={`flex items-center justify-center h-10 w-10 rounded bg-custom-background-90 group-hover:bg-custom-background-100`}
|
||||||
|
>
|
||||||
|
<PhotoFilterOutlined className="!text-base !leading-6" />
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-col">
|
||||||
|
<p className="truncate text-sm leading-4 font-medium">
|
||||||
|
{truncateText(view.name, 75)}
|
||||||
|
</p>
|
||||||
|
{view?.description && (
|
||||||
|
<p className="text-xs text-custom-text-200">{view.description}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="ml-2 flex flex-shrink-0">
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<p className="rounded bg-custom-background-80 py-1 px-2 text-xs text-custom-text-200 opacity-0 group-hover:opacity-100">
|
||||||
|
{view.query_data.filters && Object.keys(view.query_data.filters).length > 0
|
||||||
|
? `${Object.keys(view.query_data.filters)
|
||||||
|
.map((key: string) =>
|
||||||
|
view.query_data.filters[key as keyof typeof view.query_data.filters] !==
|
||||||
|
null
|
||||||
|
? isNaN(
|
||||||
|
(
|
||||||
|
view.query_data.filters[
|
||||||
|
key as keyof typeof view.query_data.filters
|
||||||
|
] as any
|
||||||
|
).length
|
||||||
|
)
|
||||||
|
? 0
|
||||||
|
: (
|
||||||
|
view.query_data.filters[
|
||||||
|
key as keyof typeof view.query_data.filters
|
||||||
|
] as any
|
||||||
|
).length
|
||||||
|
: 0
|
||||||
|
)
|
||||||
|
.reduce((curr, prev) => curr + prev, 0)} filters`
|
||||||
|
: "0 filters"}
|
||||||
|
</p>
|
||||||
|
<CustomMenu width="auto" ellipsis>
|
||||||
|
<CustomMenu.MenuItem
|
||||||
|
onClick={(e: any) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
handleEditView();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="flex items-center justify-start gap-2">
|
||||||
|
<PencilIcon className="h-3.5 w-3.5" />
|
||||||
|
<span>Edit View</span>
|
||||||
|
</span>
|
||||||
|
</CustomMenu.MenuItem>
|
||||||
|
<CustomMenu.MenuItem
|
||||||
|
onClick={(e: any) => {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
handleDeleteView();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="flex items-center justify-start gap-2">
|
||||||
|
<TrashIcon className="h-3.5 w-3.5" />
|
||||||
|
<span>Delete View</span>
|
||||||
|
</span>
|
||||||
|
</CustomMenu.MenuItem>
|
||||||
|
</CustomMenu>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@ -107,7 +107,6 @@ const ProjectViews: NextPage = () => {
|
|||||||
<SingleViewItem
|
<SingleViewItem
|
||||||
key={view.id}
|
key={view.id}
|
||||||
view={view}
|
view={view}
|
||||||
viewType="project"
|
|
||||||
handleEditView={() => handleEditView(view)}
|
handleEditView={() => handleEditView(view)}
|
||||||
handleDeleteView={() => handleDeleteView(view)}
|
handleDeleteView={() => handleDeleteView(view)}
|
||||||
/>
|
/>
|
||||||
|
@ -11,7 +11,7 @@ import workspaceService from "services/workspace.service";
|
|||||||
// layouts
|
// layouts
|
||||||
import { WorkspaceAuthorizationLayout } from "layouts/auth-layout";
|
import { WorkspaceAuthorizationLayout } from "layouts/auth-layout";
|
||||||
// components
|
// components
|
||||||
import { SingleViewItem } from "components/views";
|
import { SingleWorkspaceViewItem } from "components/workspace/views/single-workspace-view-item";
|
||||||
import { WorkspaceIssuesViewOptions } from "components/issues/workspace-views/workspace-issue-view-option";
|
import { WorkspaceIssuesViewOptions } from "components/issues/workspace-views/workspace-issue-view-option";
|
||||||
import { CreateUpdateWorkspaceViewModal } from "components/workspace/views/modal";
|
import { CreateUpdateWorkspaceViewModal } from "components/workspace/views/modal";
|
||||||
import { DeleteWorkspaceViewModal } from "components/workspace/views/delete-workspace-view-modal";
|
import { DeleteWorkspaceViewModal } from "components/workspace/views/delete-workspace-view-modal";
|
||||||
@ -169,10 +169,9 @@ const WorkspaceViews: NextPage = () => {
|
|||||||
filteredOptions.length > 0 ? (
|
filteredOptions.length > 0 ? (
|
||||||
<div>
|
<div>
|
||||||
{filteredOptions.map((view) => (
|
{filteredOptions.map((view) => (
|
||||||
<SingleViewItem
|
<SingleWorkspaceViewItem
|
||||||
key={view.id}
|
key={view.id}
|
||||||
view={view}
|
view={view}
|
||||||
viewType="workspace"
|
|
||||||
handleEditView={() => handleEditView(view)}
|
handleEditView={() => handleEditView(view)}
|
||||||
handleDeleteView={() => handleDeleteView(view)}
|
handleDeleteView={() => handleDeleteView(view)}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user