feat: incomplete cycle endpoint added , issue sidebar cycle fix (#582)

* feat: incomplete cycle endpoint added , issue sidebar cycle fix

* fix: fetch key
This commit is contained in:
Anmol Singh Bhatia 2023-03-29 19:21:15 +05:30 committed by GitHub
parent 7337707a4e
commit cfd97041b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 8 deletions

View File

@ -14,7 +14,7 @@ import { CyclesIcon } from "components/icons";
// types // types
import { ICycle, IIssue, UserAuth } from "types"; import { ICycle, IIssue, UserAuth } from "types";
// fetch-keys // fetch-keys
import { CYCLE_ISSUES, CYCLE_LIST, ISSUE_DETAILS } from "constants/fetch-keys"; import { CYCLE_ISSUES, CYCLE_INCOMPLETE_LIST, ISSUE_DETAILS } from "constants/fetch-keys";
type Props = { type Props = {
issueDetail: IIssue | undefined; issueDetail: IIssue | undefined;
@ -30,10 +30,10 @@ export const SidebarCycleSelect: React.FC<Props> = ({
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId, issueId } = router.query; const { workspaceSlug, projectId, issueId } = router.query;
const { data: cycles } = useSWR( const { data: incompleteCycles } = useSWR(
workspaceSlug && projectId ? CYCLE_LIST(projectId as string) : null, workspaceSlug && projectId ? CYCLE_INCOMPLETE_LIST(projectId as string) : null,
workspaceSlug && projectId workspaceSlug && projectId
? () => cyclesService.getCycles(workspaceSlug as string, projectId as string) ? () => cyclesService.getIncompleteCycles(workspaceSlug as string, projectId as string)
: null : null
); );
@ -77,16 +77,16 @@ export const SidebarCycleSelect: React.FC<Props> = ({
onChange={(value: any) => { onChange={(value: any) => {
!value !value
? removeIssueFromCycle(issueCycle?.id ?? "", issueCycle?.cycle ?? "") ? removeIssueFromCycle(issueCycle?.id ?? "", issueCycle?.cycle ?? "")
: handleCycleChange(cycles?.find((c) => c.id === value) as ICycle); : handleCycleChange(incompleteCycles?.find((c) => c.id === value) as ICycle);
}} }}
width="w-full" width="w-full"
position="right" position="right"
disabled={isNotAllowed} disabled={isNotAllowed}
> >
{cycles ? ( {incompleteCycles ? (
cycles.length > 0 ? ( incompleteCycles.length > 0 ? (
<> <>
{cycles.map((option) => ( {incompleteCycles.map((option) => (
<CustomSelect.Option key={option.id} value={option.id}> <CustomSelect.Option key={option.id} value={option.id}>
<Tooltip position="left-bottom" tooltipContent={option.name}> <Tooltip position="left-bottom" tooltipContent={option.name}>
<span className="w-full max-w-[125px] truncate ">{option.name}</span> <span className="w-full max-w-[125px] truncate ">{option.name}</span>

View File

@ -72,6 +72,7 @@ export const PROJECT_GITHUB_REPOSITORY = (projectId: string) =>
`PROJECT_GITHUB_REPOSITORY_${projectId.toUpperCase()}`; `PROJECT_GITHUB_REPOSITORY_${projectId.toUpperCase()}`;
export const CYCLE_LIST = (projectId: string) => `CYCLE_LIST_${projectId.toUpperCase()}`; export const CYCLE_LIST = (projectId: string) => `CYCLE_LIST_${projectId.toUpperCase()}`;
export const CYCLE_INCOMPLETE_LIST = (projectId: string) => `CYCLE_INCOMPLETE_LIST_${projectId.toUpperCase()}`;
export const CYCLE_ISSUES = (cycleId: string) => `CYCLE_ISSUES_${cycleId.toUpperCase()}`; export const CYCLE_ISSUES = (cycleId: string) => `CYCLE_ISSUES_${cycleId.toUpperCase()}`;
export const CYCLE_ISSUES_WITH_PARAMS = (cycleId: string, params?: any) => { export const CYCLE_ISSUES_WITH_PARAMS = (cycleId: string, params?: any) => {
if (!params) return `CYCLE_ISSUES_WITH_PARAMS_${cycleId.toUpperCase()}`; if (!params) return `CYCLE_ISSUES_WITH_PARAMS_${cycleId.toUpperCase()}`;

View File

@ -42,6 +42,14 @@ class ProjectCycleServices extends APIService {
}); });
} }
async getIncompleteCycles(workspaceSlug: string, projectId: string): Promise<ICycle[]> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/incomplete-cycles/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async getCycleDetails( async getCycleDetails(
workspaceSlug: string, workspaceSlug: string,
projectId: string, projectId: string,