forked from github/plane
chore: subscribed by me tab on my issues page (#1800)
* chore: add subscribed by me tab in my issues * chore: update tab titles * fix: build error
This commit is contained in:
parent
981acc81c1
commit
88e5a05253
@ -200,7 +200,7 @@ export const MyIssuesView: React.FC<Props> = ({
|
|||||||
[makeIssueCopy, handleEditIssue, handleDeleteIssue]
|
[makeIssueCopy, handleEditIssue, handleDeleteIssue]
|
||||||
);
|
);
|
||||||
|
|
||||||
const filtersToDisplay = { ...filters, assignees: null, created_by: null };
|
const filtersToDisplay = { ...filters, assignees: null, created_by: null, subscriber: null };
|
||||||
|
|
||||||
const nullFilters = Object.keys(filtersToDisplay).filter(
|
const nullFilters = Object.keys(filtersToDisplay).filter(
|
||||||
(key) => filtersToDisplay[key as keyof IIssueFilterOptions] === null
|
(key) => filtersToDisplay[key as keyof IIssueFilterOptions] === null
|
||||||
@ -264,7 +264,11 @@ export const MyIssuesView: React.FC<Props> = ({
|
|||||||
disableUserActions={disableUserActions}
|
disableUserActions={disableUserActions}
|
||||||
dragDisabled={groupBy !== "priority"}
|
dragDisabled={groupBy !== "priority"}
|
||||||
emptyState={{
|
emptyState={{
|
||||||
title: "You don't have any issue assigned to you yet",
|
title: filters.assignees
|
||||||
|
? "You don't have any issue assigned to you yet"
|
||||||
|
: filters.created_by
|
||||||
|
? "You have not created any issue yet."
|
||||||
|
: "You have not subscribed to any issue yet.",
|
||||||
description: "Keep track of your work in a single place.",
|
description: "Keep track of your work in a single place.",
|
||||||
primaryButton: {
|
primaryButton: {
|
||||||
icon: <PlusIcon className="h-4 w-4" />,
|
icon: <PlusIcon className="h-4 w-4" />,
|
||||||
|
@ -38,11 +38,12 @@ const inboxParamsToKey = (params: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const myIssuesParamsToKey = (params: any) => {
|
const myIssuesParamsToKey = (params: any) => {
|
||||||
const { assignees, created_by, labels, priority, state_group, target_date } = params;
|
const { assignees, created_by, labels, priority, state_group, subscriber, target_date } = params;
|
||||||
|
|
||||||
let assigneesKey = assignees ? assignees.split(",") : [];
|
let assigneesKey = assignees ? assignees.split(",") : [];
|
||||||
let createdByKey = created_by ? created_by.split(",") : [];
|
let createdByKey = created_by ? created_by.split(",") : [];
|
||||||
let stateGroupKey = state_group ? state_group.split(",") : [];
|
let stateGroupKey = state_group ? state_group.split(",") : [];
|
||||||
|
let subscriberKey = subscriber ? subscriber.split(",") : [];
|
||||||
let priorityKey = priority ? priority.split(",") : [];
|
let priorityKey = priority ? priority.split(",") : [];
|
||||||
let labelsKey = labels ? labels.split(",") : [];
|
let labelsKey = labels ? labels.split(",") : [];
|
||||||
const targetDateKey = target_date ?? "";
|
const targetDateKey = target_date ?? "";
|
||||||
@ -54,10 +55,11 @@ const myIssuesParamsToKey = (params: any) => {
|
|||||||
assigneesKey = assigneesKey.sort().join("_");
|
assigneesKey = assigneesKey.sort().join("_");
|
||||||
createdByKey = createdByKey.sort().join("_");
|
createdByKey = createdByKey.sort().join("_");
|
||||||
stateGroupKey = stateGroupKey.sort().join("_");
|
stateGroupKey = stateGroupKey.sort().join("_");
|
||||||
|
subscriberKey = subscriberKey.sort().join("_");
|
||||||
priorityKey = priorityKey.sort().join("_");
|
priorityKey = priorityKey.sort().join("_");
|
||||||
labelsKey = labelsKey.sort().join("_");
|
labelsKey = labelsKey.sort().join("_");
|
||||||
|
|
||||||
return `${assigneesKey}_${createdByKey}_${stateGroupKey}_${priorityKey}_${type}_${groupBy}_${orderBy}_${labelsKey}_${targetDateKey}`;
|
return `${assigneesKey}_${createdByKey}_${stateGroupKey}_${subscriberKey}_${priorityKey}_${type}_${groupBy}_${orderBy}_${labelsKey}_${targetDateKey}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CURRENT_USER = "CURRENT_USER";
|
export const CURRENT_USER = "CURRENT_USER";
|
||||||
@ -317,9 +319,7 @@ export const USER_PROFILE_PROJECT_SEGREGATION = (workspaceSlug: string, userId:
|
|||||||
export const USER_PROFILE_ISSUES = (workspaceSlug: string, userId: string, params: any) => {
|
export const USER_PROFILE_ISSUES = (workspaceSlug: string, userId: string, params: any) => {
|
||||||
const paramsKey = myIssuesParamsToKey(params);
|
const paramsKey = myIssuesParamsToKey(params);
|
||||||
|
|
||||||
const subscriberKey = params.subscriber ? params.subscriber.toUpperCase() : "NULL";
|
return `USER_PROFILE_ISSUES_${workspaceSlug.toUpperCase()}_${userId.toUpperCase()}_${paramsKey}`;
|
||||||
|
|
||||||
return `USER_PROFILE_ISSUES_${workspaceSlug.toUpperCase()}_${userId.toUpperCase()}_${paramsKey}_${subscriberKey}`;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// reactions
|
// reactions
|
||||||
|
@ -92,6 +92,7 @@ export const initialState: StateType = {
|
|||||||
labels: null,
|
labels: null,
|
||||||
state: null,
|
state: null,
|
||||||
state_group: null,
|
state_group: null,
|
||||||
|
subscriber: null,
|
||||||
created_by: null,
|
created_by: null,
|
||||||
target_date: null,
|
target_date: null,
|
||||||
},
|
},
|
||||||
|
@ -19,7 +19,7 @@ type IssueViewProps = {
|
|||||||
orderBy: TIssueOrderByOptions;
|
orderBy: TIssueOrderByOptions;
|
||||||
showEmptyGroups: boolean;
|
showEmptyGroups: boolean;
|
||||||
showSubIssues: boolean;
|
showSubIssues: boolean;
|
||||||
filters: IIssueFilterOptions & { subscriber: string | null };
|
filters: IIssueFilterOptions;
|
||||||
properties: Properties;
|
properties: Properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ type ContextType = IssueViewProps & {
|
|||||||
setOrderBy: (property: TIssueOrderByOptions) => void;
|
setOrderBy: (property: TIssueOrderByOptions) => void;
|
||||||
setShowEmptyGroups: (property: boolean) => void;
|
setShowEmptyGroups: (property: boolean) => void;
|
||||||
setShowSubIssues: (value: boolean) => void;
|
setShowSubIssues: (value: boolean) => void;
|
||||||
setFilters: (filters: Partial<IIssueFilterOptions & { subscriber: string | null }>) => void;
|
setFilters: (filters: Partial<IIssueFilterOptions>) => void;
|
||||||
setProperties: (key: keyof Properties) => void;
|
setProperties: (key: keyof Properties) => void;
|
||||||
setIssueView: (property: TIssueViewOptions) => void;
|
setIssueView: (property: TIssueViewOptions) => void;
|
||||||
};
|
};
|
||||||
@ -52,7 +52,7 @@ type StateType = {
|
|||||||
orderBy: TIssueOrderByOptions;
|
orderBy: TIssueOrderByOptions;
|
||||||
showEmptyGroups: boolean;
|
showEmptyGroups: boolean;
|
||||||
showSubIssues: boolean;
|
showSubIssues: boolean;
|
||||||
filters: IIssueFilterOptions & { subscriber: string | null };
|
filters: IIssueFilterOptions;
|
||||||
properties: Properties;
|
properties: Properties;
|
||||||
};
|
};
|
||||||
type ReducerFunctionType = (state: StateType, action: ReducerActionType) => StateType;
|
type ReducerFunctionType = (state: StateType, action: ReducerActionType) => StateType;
|
||||||
|
@ -25,6 +25,7 @@ const initialValues: IWorkspaceViewProps = {
|
|||||||
labels: null,
|
labels: null,
|
||||||
priority: null,
|
priority: null,
|
||||||
state_group: null,
|
state_group: null,
|
||||||
|
subscriber: null,
|
||||||
target_date: null,
|
target_date: null,
|
||||||
type: null,
|
type: null,
|
||||||
},
|
},
|
||||||
|
@ -26,6 +26,7 @@ const useMyIssues = (workspaceSlug: string | undefined) => {
|
|||||||
order_by: orderBy,
|
order_by: orderBy,
|
||||||
priority: filters?.priority ? filters?.priority.join(",") : undefined,
|
priority: filters?.priority ? filters?.priority.join(",") : undefined,
|
||||||
state_group: filters?.state_group ? filters?.state_group.join(",") : undefined,
|
state_group: filters?.state_group ? filters?.state_group.join(",") : undefined,
|
||||||
|
subscriber: filters?.subscriber ? filters?.subscriber.join(",") : undefined,
|
||||||
target_date: filters?.target_date ? filters?.target_date.join(",") : undefined,
|
target_date: filters?.target_date ? filters?.target_date.join(",") : undefined,
|
||||||
type: filters?.type ? filters?.type : undefined,
|
type: filters?.type ? filters?.type : undefined,
|
||||||
};
|
};
|
||||||
|
@ -46,7 +46,7 @@ const useProfileIssues = (workspaceSlug: string | undefined, userId: string | un
|
|||||||
state_group: filters?.state_group ? filters?.state_group.join(",") : undefined,
|
state_group: filters?.state_group ? filters?.state_group.join(",") : undefined,
|
||||||
target_date: filters?.target_date ? filters?.target_date.join(",") : undefined,
|
target_date: filters?.target_date ? filters?.target_date.join(",") : undefined,
|
||||||
type: filters?.type ? filters?.type : undefined,
|
type: filters?.type ? filters?.type : undefined,
|
||||||
subscriber: filters?.subscriber ? filters?.subscriber : undefined,
|
subscriber: filters?.subscriber ? filters?.subscriber.join(",") : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { data: userProfileIssues, mutate: mutateProfileIssues } = useSWR(
|
const { data: userProfileIssues, mutate: mutateProfileIssues } = useSWR(
|
||||||
@ -93,7 +93,7 @@ const useProfileIssues = (workspaceSlug: string | undefined, userId: string | un
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (router.pathname.includes("subscribed") && filters.subscriber === null) {
|
if (router.pathname.includes("subscribed") && filters.subscriber === null) {
|
||||||
setFilters({ subscriber: userId });
|
setFilters({ subscriber: [userId] });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}, [filters, router, setFilters, userId]);
|
}, [filters, router, setFilters, userId]);
|
||||||
|
@ -22,7 +22,6 @@ const MyIssuesPage: NextPage = () => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { workspaceSlug } = router.query;
|
const { workspaceSlug } = router.query;
|
||||||
|
|
||||||
const { projects } = useProjects();
|
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
|
|
||||||
const { filters, setFilters } = useMyIssuesFilters(workspaceSlug?.toString());
|
const { filters, setFilters } = useMyIssuesFilters(workspaceSlug?.toString());
|
||||||
@ -30,23 +29,37 @@ const MyIssuesPage: NextPage = () => {
|
|||||||
const tabsList = [
|
const tabsList = [
|
||||||
{
|
{
|
||||||
key: "assigned",
|
key: "assigned",
|
||||||
label: "Assigned to me",
|
label: "Assigned",
|
||||||
selected: (filters?.assignees ?? []).length > 0,
|
selected: (filters?.assignees ?? []).length > 0,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
setFilters({
|
setFilters({
|
||||||
assignees: [user?.id ?? ""],
|
assignees: [user?.id ?? ""],
|
||||||
created_by: null,
|
created_by: null,
|
||||||
|
subscriber: null,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "created",
|
key: "created",
|
||||||
label: "Created by me",
|
label: "Created",
|
||||||
selected: (filters?.created_by ?? []).length > 0,
|
selected: (filters?.created_by ?? []).length > 0,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
setFilters({
|
setFilters({
|
||||||
created_by: [user?.id ?? ""],
|
|
||||||
assignees: null,
|
assignees: null,
|
||||||
|
created_by: [user?.id ?? ""],
|
||||||
|
subscriber: null,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "subscribed",
|
||||||
|
label: "Subscribed",
|
||||||
|
selected: (filters?.subscriber ?? []).length > 0,
|
||||||
|
onClick: () => {
|
||||||
|
setFilters({
|
||||||
|
assignees: null,
|
||||||
|
created_by: null,
|
||||||
|
subscriber: [user?.id ?? ""],
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -55,7 +68,7 @@ const MyIssuesPage: NextPage = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!filters || !user) return;
|
if (!filters || !user) return;
|
||||||
|
|
||||||
if (!filters.assignees && !filters.created_by) {
|
if (!filters.assignees && !filters.created_by && !filters.subscriber) {
|
||||||
setFilters({
|
setFilters({
|
||||||
assignees: [user.id],
|
assignees: [user.id],
|
||||||
});
|
});
|
||||||
|
1
apps/app/types/issues.d.ts
vendored
1
apps/app/types/issues.d.ts
vendored
@ -229,6 +229,7 @@ export interface IIssueFilterOptions {
|
|||||||
target_date: string[] | null;
|
target_date: string[] | null;
|
||||||
state: string[] | null;
|
state: string[] | null;
|
||||||
state_group: TStateGroups[] | null;
|
state_group: TStateGroups[] | null;
|
||||||
|
subscriber: string[] | null;
|
||||||
labels: string[] | null;
|
labels: string[] | null;
|
||||||
priority: string[] | null;
|
priority: string[] | null;
|
||||||
created_by: string[] | null;
|
created_by: string[] | null;
|
||||||
|
Loading…
Reference in New Issue
Block a user