[WEB-1684] chore: handled estimate dropdown render dynaically for in workspace and project level issues. (#4936)
* chore: handled estimate dropdown render dynaically for in workspace and project level issues. * chore: issue manager updated --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
This commit is contained in:
parent
f087af3946
commit
a3a1e9cf9e
7 changed files with 66 additions and 38 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,6 +218,18 @@ export const EstimateDropdown: React.FC<Props> = observer((props) => {
|
|||
/>
|
||||
</div>
|
||||
<div className="mt-2 max-h-48 space-y-1 overflow-y-scroll">
|
||||
{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>
|
||||
) : (
|
||||
<>
|
||||
{filteredOptions ? (
|
||||
filteredOptions.length > 0 ? (
|
||||
filteredOptions.map((option) => (
|
||||
|
|
@ -236,6 +250,8 @@ export const EstimateDropdown: React.FC<Props> = observer((props) => {
|
|||
) : (
|
||||
<p className="px-1.5 py-1 italic text-custom-text-400">Loading...</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Combobox.Options>
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue