Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

[WEB-1684] chore: handled estimate dropdown render dynaically for in workspace and project level issues. (#4936)

guru_sainatha3a1e9cf9e02
diff --git a/apiserver/plane/api/views/cycle.py b/apiserver/plane/api/views/cycle.py
index 5c35563cb1..9e7be51804 100644
--- a/apiserver/plane/api/views/cycle.py
+++ b/apiserver/plane/api/views/cycle.py
@@ -856,7 +856,7 @@ class TransferCycleIssueAPIEndpoint(BaseAPIView):
if estimate_type:
assignee_estimate_data = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_cycle__cycle_id=cycle_id,
workspace__slug=slug,
project_id=project_id,
@@ -910,7 +910,7 @@ class TransferCycleIssueAPIEndpoint(BaseAPIView):
]
label_distribution_data = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_cycle__cycle_id=cycle_id,
workspace__slug=slug,
project_id=project_id,
@@ -971,7 +971,7 @@ class TransferCycleIssueAPIEndpoint(BaseAPIView):
# Get the assignee distribution
assignee_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_cycle__cycle_id=cycle_id,
workspace__slug=slug,
project_id=project_id,
@@ -1028,7 +1028,7 @@ class TransferCycleIssueAPIEndpoint(BaseAPIView):
# Get the label distribution
label_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_cycle__cycle_id=cycle_id,
workspace__slug=slug,
project_id=project_id,
diff --git a/apiserver/plane/app/views/cycle/archive.py b/apiserver/plane/app/views/cycle/archive.py
index f99c2ec972..dc5f6a5730 100644
--- a/apiserver/plane/app/views/cycle/archive.py
+++ b/apiserver/plane/app/views/cycle/archive.py
@@ -177,7 +177,6 @@ class CycleArchiveUnarchiveEndpoint(BaseAPIView):
)
def get(self, request, slug, project_id, pk=None):
- plot_type = request.GET.get("plot_type", "issues")
if pk is None:
queryset = (
self.get_queryset()
@@ -279,7 +278,7 @@ class CycleArchiveUnarchiveEndpoint(BaseAPIView):
# Assignee Distribution
assignee_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_cycle__cycle_id=pk,
workspace__slug=slug,
project_id=project_id,
@@ -327,7 +326,7 @@ class CycleArchiveUnarchiveEndpoint(BaseAPIView):
# Label Distribution
label_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_cycle__cycle_id=pk,
workspace__slug=slug,
project_id=project_id,
@@ -376,7 +375,7 @@ class CycleArchiveUnarchiveEndpoint(BaseAPIView):
queryset=queryset,
slug=slug,
project_id=project_id,
- plot_type=plot_type,
+ plot_type="issues",
cycle_id=pk,
)
diff --git a/apiserver/plane/app/views/cycle/base.py b/apiserver/plane/app/views/cycle/base.py
index 8c3f98ac65..2fbdc33e64 100644
--- a/apiserver/plane/app/views/cycle/base.py
+++ b/apiserver/plane/app/views/cycle/base.py
@@ -1223,7 +1223,7 @@ class TransferCycleIssueEndpoint(BaseAPIView):
if estimate_type:
assignee_estimate_data = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_cycle__cycle_id=cycle_id,
workspace__slug=slug,
project_id=project_id,
@@ -1277,7 +1277,7 @@ class TransferCycleIssueEndpoint(BaseAPIView):
]
label_distribution_data = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_cycle__cycle_id=cycle_id,
workspace__slug=slug,
project_id=project_id,
@@ -1338,7 +1338,7 @@ class TransferCycleIssueEndpoint(BaseAPIView):
# Get the assignee distribution
assignee_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_cycle__cycle_id=cycle_id,
workspace__slug=slug,
project_id=project_id,
@@ -1395,7 +1395,7 @@ class TransferCycleIssueEndpoint(BaseAPIView):
# Get the label distribution
label_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_cycle__cycle_id=cycle_id,
workspace__slug=slug,
project_id=project_id,
diff --git a/apiserver/plane/app/views/module/archive.py b/apiserver/plane/app/views/module/archive.py
index 5bc91ff1c7..8f6d9c6b0e 100644
--- a/apiserver/plane/app/views/module/archive.py
+++ b/apiserver/plane/app/views/module/archive.py
@@ -233,7 +233,7 @@ class ModuleArchiveUnarchiveEndpoint(BaseAPIView):
if estimate_type:
label_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_module__module_id=pk,
workspace__slug=slug,
project_id=project_id,
@@ -279,7 +279,7 @@ class ModuleArchiveUnarchiveEndpoint(BaseAPIView):
)
assignee_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_module__module_id=pk,
workspace__slug=slug,
project_id=project_id,
@@ -329,7 +329,7 @@ class ModuleArchiveUnarchiveEndpoint(BaseAPIView):
)
)
assignee_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_module__module_id=pk,
workspace__slug=slug,
project_id=project_id,
@@ -379,7 +379,7 @@ class ModuleArchiveUnarchiveEndpoint(BaseAPIView):
)
label_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_module__module_id=pk,
workspace__slug=slug,
project_id=project_id,
diff --git a/apiserver/plane/app/views/module/base.py b/apiserver/plane/app/views/module/base.py
index e1a323880a..ca0f562834 100644
--- a/apiserver/plane/app/views/module/base.py
+++ b/apiserver/plane/app/views/module/base.py
@@ -456,7 +456,7 @@ class ModuleViewSet(BaseViewSet):
if estimate_type:
assignee_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_module__module_id=pk,
workspace__slug=slug,
project_id=project_id,
@@ -502,7 +502,7 @@ class ModuleViewSet(BaseViewSet):
)
label_distribution = (
- Issue.objects.filter(
+ Issue.issue_objects.filter(
issue_module__module_id=pk,
workspace__slug=slug,
project_id=project_id,
diff --git a/web/core/components/dropdowns/estimate.tsx b/web/core/components/dropdowns/estimate.tsx
index 839696bba8..13c7ee94d9 100644
--- a/web/core/components/dropdowns/estimate.tsx
+++ b/web/core/components/dropdowns/estimate.tsx
@@ -81,11 +81,13 @@ export const EstimateDropdown: React.FC<Props> = observer((props) => {
// router
const { workspaceSlug } = useParams();
// store hooks
- const { currentActiveEstimateId, getProjectEstimates } = useProjectEstimates();
+ const { currentActiveEstimateIdByProjectId, getProjectEstimates } = useProjectEstimates();
const { estimatePointIds, estimatePointById } = useEstimate(
- currentActiveEstimateId ? currentActiveEstimateId : undefined
+ projectId ? currentActiveEstimateIdByProjectId(projectId) : undefined
);
+ const currentActiveEstimateId = projectId ? currentActiveEstimateIdByProjectId(projectId) : undefined;
+
const options: DropdownOptions = (estimatePointIds ?? [])
?.map((estimatePoint) => {
const currentEstimatePoint = estimatePointById(estimatePoint);
@@ -216,25 +218,39 @@ export const EstimateDropdown: React.FC<Props> = observer((props) => {
/>
</div>
<div className="mt-2 max-h-48 space-y-1 overflow-y-scroll">
- {filteredOptions ? (
- filteredOptions.length > 0 ? (
- filteredOptions.map((option) => (
- <Combobox.Option key={option.value} value={option.value}>
- {({ active, selected }) => (
- <div
- className={`flex w-full cursor-pointer select-none items-center justify-between gap-2 truncate rounded px-1 py-1.5 ${active ? `!hover:bg-custom-background-80` : ``} ${selected ? "text-custom-text-100" : "text-custom-text-200"}`}
- >
- <span className="flex-grow truncate">{option.content}</span>
- {selected && <Check className="h-3.5 w-3.5 flex-shrink-0" />}
- </div>
- )}
- </Combobox.Option>
- ))
- ) : (
- <p className="px-1.5 py-1 italic text-custom-text-400">No matching results</p>
- )
+ {currentActiveEstimateId === undefined ? (
+ <div
+ className={`flex w-full cursor-pointer select-none items-center justify-between gap-2 truncate rounded px-1 py-1.5 text-custom-text-200`}
+ >
+ {/* NOTE: This condition renders when estimates are not enabled for the project */}
+ <div className="flex-grow flex items-center gap-2">
+ <Triangle className="h-3 w-3 flex-shrink-0" />
+ <span className="flex-grow truncate">No estimate</span>
+ </div>
+ </div>
) : (
- <p className="px-1.5 py-1 italic text-custom-text-400">Loading...</p>
+ <>
+ {filteredOptions ? (
+ filteredOptions.length > 0 ? (
+ filteredOptions.map((option) => (
+ <Combobox.Option key={option.value} value={option.value}>
+ {({ active, selected }) => (
+ <div
+ className={`flex w-full cursor-pointer select-none items-center justify-between gap-2 truncate rounded px-1 py-1.5 ${active ? `!hover:bg-custom-background-80` : ``} ${selected ? "text-custom-text-100" : "text-custom-text-200"}`}
+ >
+ <span className="flex-grow truncate">{option.content}</span>
+ {selected && <Check className="h-3.5 w-3.5 flex-shrink-0" />}
+ </div>
+ )}
+ </Combobox.Option>
+ ))
+ ) : (
+ <p className="px-1.5 py-1 italic text-custom-text-400">No matching results</p>
+ )
+ ) : (
+ <p className="px-1.5 py-1 italic text-custom-text-400">Loading...</p>
+ )}
+ </>
)}
</div>
</div>
diff --git a/web/core/store/estimates/project-estimate.store.ts b/web/core/store/estimates/project-estimate.store.ts
index f4a4500ec7..12d896dcb5 100644
--- a/web/core/store/estimates/project-estimate.store.ts
+++ b/web/core/store/estimates/project-estimate.store.ts
@@ -29,6 +29,7 @@ export interface IProjectEstimateStore {
archivedEstimateIds: string[] | undefined;
areEstimateEnabledByProjectId: (projectId: string) => boolean;
estimateIdsByProjectId: (projectId: string) => string[] | undefined;
+ currentActiveEstimateIdByProjectId: (projectId: string) => string | undefined;
estimateById: (estimateId: string) => IEstimate | undefined;
// actions
getWorkspaceEstimates: (workspaceSlug: string, loader?: TEstimateLoader) => Promise<IEstimateType[] | undefined>;
@@ -123,6 +124,18 @@ export class ProjectEstimateStore implements IProjectEstimateStore {
return projectEstimatesIds ?? undefined;
});
+ /**
+ * @description get current active estimate id for a project
+ * @returns { string | undefined }
+ */
+ currentActiveEstimateIdByProjectId = computedFn((projectId: string): string | undefined => {
+ if (!projectId) return undefined;
+ const currentActiveEstimateId = Object.values(this.estimates || {}).find(
+ (p) => p.project === projectId && p.last_used
+ );
+ return currentActiveEstimateId?.id ?? undefined;
+ });
+
/**
* @description get estimate by id
* @returns { IEstimate | undefined }