diff --git a/web/components/headers/cycle-issues.tsx b/web/components/headers/cycle-issues.tsx
index ed43ca272..121bb39f7 100644
--- a/web/components/headers/cycle-issues.tsx
+++ b/web/components/headers/cycle-issues.tsx
@@ -1,9 +1,9 @@
-import { useCallback, useState } from "react";
+import React, { useCallback, useState } from "react";
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
// hooks
import { useMobxStore } from "lib/mobx/store-provider";
-import { useApplication, useLabel, useProject, useProjectState, useUser } from "hooks/store";
+import { useApplication, useCycle, useLabel, useProject, useProjectState, useUser } from "hooks/store";
import useLocalStorage from "hooks/use-local-storage";
// components
import { DisplayFiltersSelection, FiltersDropdown, FilterSelection, LayoutSelection } from "components/issues";
@@ -23,6 +23,31 @@ import { EFilterType } from "store_legacy/issues/types";
import { EProjectStore } from "store_legacy/command-palette.store";
import { EUserProjectRoles } from "constants/project";
+const CycleDropdownOption: React.FC<{ cycleId: string }> = ({ cycleId }) => {
+ // router
+ const router = useRouter();
+ const { workspaceSlug, projectId } = router.query;
+
+ // store hooks
+ const { getCycleById } = useCycle();
+
+ const cycle = getCycleById(cycleId);
+
+ if (!cycle) return null;
+
+ return (
+ router.push(`/${workspaceSlug}/projects/${projectId}/cycles/${cycle.id}`)}
+ >
+
+
+ {truncateText(cycle.name, 40)}
+
+
+ );
+};
+
export const CycleIssuesHeader: React.FC = observer(() => {
// states
const [analyticsModal, setAnalyticsModal] = useState(false);
@@ -35,11 +60,11 @@ export const CycleIssuesHeader: React.FC = observer(() => {
};
// store hooks
const {
- cycle: cycleStore,
projectIssuesFilter: projectIssueFiltersStore,
projectMember: { projectMembers },
cycleIssuesFilter: { issueFilters, updateFilters },
} = useMobxStore();
+ const { projectAllCycles, getCycleById } = useCycle();
const {
commandPalette: { toggleCreateIssueModal },
eventTracker: { setTrackElement },
@@ -105,8 +130,7 @@ export const CycleIssuesHeader: React.FC = observer(() => {
[workspaceSlug, projectId, cycleId, updateFilters]
);
- const cyclesList = cycleStore.projectCycles;
- const cycleDetails = cycleId ? cycleStore.getCycleById(cycleId.toString()) : undefined;
+ const cycleDetails = cycleId ? getCycleById(cycleId.toString()) : undefined;
const canUserCreateIssue =
currentProjectRole && [EUserProjectRoles.ADMIN, EUserProjectRoles.MEMBER].includes(currentProjectRole);
@@ -157,16 +181,8 @@ export const CycleIssuesHeader: React.FC = observer(() => {
width="auto"
placement="bottom-start"
>
- {cyclesList?.map((cycle) => (
- router.push(`/${workspaceSlug}/projects/${projectId}/cycles/${cycle.id}`)}
- >
-
-
- {truncateText(cycle.name, 40)}
-
-
+ {projectAllCycles?.map((cycleId) => (
+
))}
}
diff --git a/web/components/headers/module-issues.tsx b/web/components/headers/module-issues.tsx
index 8f49c9e5d..03810aa73 100644
--- a/web/components/headers/module-issues.tsx
+++ b/web/components/headers/module-issues.tsx
@@ -3,7 +3,7 @@ import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
// hooks
import { useMobxStore } from "lib/mobx/store-provider";
-import { useApplication, useLabel, useProject, useProjectState, useUser } from "hooks/store";
+import { useApplication, useLabel, useModule, useProject, useProjectState, useUser } from "hooks/store";
import useLocalStorage from "hooks/use-local-storage";
// components
import { DisplayFiltersSelection, FiltersDropdown, FilterSelection, LayoutSelection } from "components/issues";
@@ -24,6 +24,31 @@ import { EFilterType } from "store_legacy/issues/types";
import { EProjectStore } from "store_legacy/command-palette.store";
import { EUserProjectRoles } from "constants/project";
+const ModuleDropdownOption: React.FC<{ moduleId: string }> = ({ moduleId }) => {
+ // router
+ const router = useRouter();
+ const { workspaceSlug, projectId } = router.query;
+
+ // store hooks
+ const { getModuleById } = useModule();
+
+ const moduleDetail = getModuleById(moduleId);
+
+ if (!moduleDetail) return null;
+
+ return (
+ router.push(`/${workspaceSlug}/projects/${projectId}/modules/${moduleDetail.id}`)}
+ >
+
+
+ {truncateText(moduleDetail.name, 40)}
+
+
+ );
+};
+
export const ModuleIssuesHeader: React.FC = observer(() => {
// states
const [analyticsModal, setAnalyticsModal] = useState(false);
@@ -36,10 +61,10 @@ export const ModuleIssuesHeader: React.FC = observer(() => {
};
// store hooks
const {
- module: moduleStore,
projectMember: { projectMembers },
moduleIssuesFilter: { issueFilters, updateFilters },
} = useMobxStore();
+ const { projectModules, getModuleById } = useModule();
const {
commandPalette: { toggleCreateIssueModal },
eventTracker: { setTrackElement },
@@ -105,8 +130,7 @@ export const ModuleIssuesHeader: React.FC = observer(() => {
[workspaceSlug, projectId, moduleId, updateFilters]
);
- const modulesList = projectId ? moduleStore.modules[projectId.toString()] : undefined;
- const moduleDetails = moduleId ? moduleStore.getModuleById(moduleId.toString()) : undefined;
+ const moduleDetails = moduleId ? getModuleById(moduleId.toString()) : undefined;
const canUserCreateIssue =
currentProjectRole && [EUserProjectRoles.ADMIN, EUserProjectRoles.MEMBER].includes(currentProjectRole);
@@ -157,16 +181,8 @@ export const ModuleIssuesHeader: React.FC = observer(() => {
width="auto"
placement="bottom-start"
>
- {modulesList?.map((module) => (
- router.push(`/${workspaceSlug}/projects/${projectId}/modules/${module.id}`)}
- >
-
-
- {truncateText(module.name, 40)}
-
-
+ {projectModules?.map((moduleId) => (
+
))}
}
diff --git a/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx b/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx
index b20aa36b9..f1e58778f 100644
--- a/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx
+++ b/web/components/issues/issue-layouts/roots/cycle-layout-root.tsx
@@ -32,7 +32,6 @@ export const CycleLayoutRoot: React.FC = observer(() => {
};
// store hooks
const {
- cycle: cycleStore,
cycleIssues: { loader, getIssues, fetchIssues },
cycleIssuesFilter: { issueFilters, fetchFilters },
} = useMobxStore();
diff --git a/web/components/issues/select/cycle.tsx b/web/components/issues/select/cycle.tsx
index 2a9f4ee11..8e2143a1f 100644
--- a/web/components/issues/select/cycle.tsx
+++ b/web/components/issues/select/cycle.tsx
@@ -1,8 +1,8 @@
import React, { useState } from "react";
import { observer } from "mobx-react-lite";
import { usePopper } from "react-popper";
-// mobx store
-import { useMobxStore } from "lib/mobx/store-provider";
+// hooks
+import { useCycle } from "hooks/store";
// ui
import { Combobox } from "@headlessui/react";
// icons
@@ -28,28 +28,28 @@ export const IssueCycleSelect: React.FC = observer((props
placement: "bottom-start",
});
- const { cycle: cycleStore } = useMobxStore();
+ const { projectAllCycles, fetchAllCycles, getCycleById } = useCycle();
const fetchCycles = () => {
- if (workspaceSlug && projectId) cycleStore.fetchCycles(workspaceSlug, projectId, "all");
+ if (workspaceSlug && projectId) fetchAllCycles(workspaceSlug, projectId);
};
- const cycles = cycleStore.projectCycles;
+ const selectedCycleId = projectAllCycles ? projectAllCycles?.find((cycleId) => cycleId === value) : null;
+ const selectedCycle = selectedCycleId ? getCycleById(selectedCycleId) : null;
- const selectedCycle = cycles ? cycles?.find((i) => i.id === value) : undefined;
-
- const options = cycles?.map((cycle) => ({
- value: cycle.id,
- query: cycle.name,
- content: (
-
-
-
-
- {cycle.name}
-
- ),
- }));
+ const options = projectAllCycles?.map((cycleId) => {
+ const cycleDetail = getCycleById(cycleId);
+ return {
+ value: cycleId,
+ query: cycleDetail?.name ?? "",
+ content: (
+
+
+ {cycleDetail?.name}
+
+ ),
+ };
+ });
const filteredOptions =
query === "" ? options : options?.filter((option) => option.query.toLowerCase().includes(query.toLowerCase()));
diff --git a/web/components/issues/sidebar-select/module.tsx b/web/components/issues/sidebar-select/module.tsx
index c96799bc6..55339bebf 100644
--- a/web/components/issues/sidebar-select/module.tsx
+++ b/web/components/issues/sidebar-select/module.tsx
@@ -2,7 +2,8 @@ import React, { useState } from "react";
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
import { mutate } from "swr";
-// mobx store
+// hooks
+import { useModule } from "hooks/store";
import { useMobxStore } from "lib/mobx/store-provider";
// ui
import { CustomSearchSelect, DiceIcon, Spinner, Tooltip } from "@plane/ui";
@@ -25,9 +26,9 @@ export const SidebarModuleSelect: React.FC = observer((props) => {
const { workspaceSlug, projectId } = router.query;
// mobx store
const {
- module: { projectModules },
moduleIssues: { removeIssueFromModule, addIssueToModule },
} = useMobxStore();
+ const { projectModules, getModuleById } = useModule();
const [isUpdating, setIsUpdating] = useState(false);
@@ -63,18 +64,24 @@ export const SidebarModuleSelect: React.FC = observer((props) => {
});
};
- const options = projectModules?.map((module) => ({
- value: module.id,
- query: module.name,
- content: (
-
-
-
-
- {module.name}
-
- ),
- }));
+ const selectedModuleId = projectModules ? projectModules.find((moduleId) => moduleId === issueModule?.module) : null;
+ const selectedModule = selectedModuleId ? getModuleById(selectedModuleId) : null;
+
+ const options = projectModules?.map((moduleId) => {
+ const moduleDetail = getModuleById(moduleId);
+ return {
+ value: moduleId,
+ query: moduleDetail?.name ?? "",
+ content: (
+
+
+
+
+ {moduleDetail?.name}
+
+ ),
+ };
+ });
const issueModule = issueDetail?.issue_module;
@@ -88,15 +95,15 @@ export const SidebarModuleSelect: React.FC = observer((props) => {
value === issueModule?.module_detail.id
? handleRemoveIssueFromModule(issueModule?.id ?? "", issueModule?.module ?? "")
: handleModuleChange
- ? handleModuleChange(value)
- : handleModuleStoreChange(value);
+ ? handleModuleChange(value)
+ : handleModuleStoreChange(value);
}}
options={options}
customButton={
m.id === issueModule?.module)?.name ?? "No module"}`}
+ tooltipContent={`${selectedModule?.name ?? "No module"}`}
>