mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
3c2f5d12ed
* chore: add next theme and initial setup * chore: add dark mode colors to layouts * chore: user general setting page theming * chore: dashboard theming * chore: project page theming * chore: workspace setting page theming * chore: my issue page theming * chore: cmdk theming * chore: change hardcode bg and text color to theme * chore: change color name according to the design * style: fix card in the dashboard * style: fix merge conflict design issues * style: add light high contrast and dark high contrast * style: fix cmd k menu color and selection * feat: change theme from cmdk menu * chore: add multiple theme field to custom theme * chore: removed custom theming * fix: build error --------- Co-authored-by: Saheb Giri <iamsahebgiri@gmail.com>
114 lines
3.6 KiB
TypeScript
114 lines
3.6 KiB
TypeScript
import React from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import useSWR, { mutate } from "swr";
|
|
|
|
// services
|
|
import issuesService from "services/issues.service";
|
|
import cyclesService from "services/cycles.service";
|
|
// ui
|
|
import { Spinner, CustomSelect, Tooltip } from "components/ui";
|
|
// helper
|
|
import { truncateText } from "helpers/string.helper";
|
|
// icons
|
|
import { CyclesIcon } from "components/icons";
|
|
// types
|
|
import { ICycle, IIssue, UserAuth } from "types";
|
|
// fetch-keys
|
|
import { CYCLE_ISSUES, CYCLE_INCOMPLETE_LIST, ISSUE_DETAILS } from "constants/fetch-keys";
|
|
|
|
type Props = {
|
|
issueDetail: IIssue | undefined;
|
|
handleCycleChange: (cycle: ICycle) => void;
|
|
userAuth: UserAuth;
|
|
};
|
|
|
|
export const SidebarCycleSelect: React.FC<Props> = ({
|
|
issueDetail,
|
|
handleCycleChange,
|
|
userAuth,
|
|
}) => {
|
|
const router = useRouter();
|
|
const { workspaceSlug, projectId, issueId } = router.query;
|
|
|
|
const { data: incompleteCycles } = useSWR(
|
|
workspaceSlug && projectId ? CYCLE_INCOMPLETE_LIST(projectId as string) : null,
|
|
workspaceSlug && projectId
|
|
? () => cyclesService.getIncompleteCycles(workspaceSlug as string, projectId as string)
|
|
: null
|
|
);
|
|
|
|
const removeIssueFromCycle = (bridgeId: string, cycleId: string) => {
|
|
if (!workspaceSlug || !projectId) return;
|
|
|
|
issuesService
|
|
.removeIssueFromCycle(workspaceSlug as string, projectId as string, cycleId, bridgeId)
|
|
.then((res) => {
|
|
mutate(ISSUE_DETAILS(issueId as string));
|
|
|
|
mutate(CYCLE_ISSUES(cycleId));
|
|
})
|
|
.catch((e) => {
|
|
console.log(e);
|
|
});
|
|
};
|
|
|
|
const issueCycle = issueDetail?.issue_cycle;
|
|
|
|
const isNotAllowed = userAuth.isGuest || userAuth.isViewer;
|
|
|
|
return (
|
|
<div className="flex flex-wrap items-center py-2">
|
|
<div className="flex items-center gap-x-2 text-sm sm:basis-1/2">
|
|
<CyclesIcon className="h-4 w-4 flex-shrink-0" />
|
|
<p>Cycle</p>
|
|
</div>
|
|
<div className="space-y-1 sm:basis-1/2">
|
|
<CustomSelect
|
|
label={
|
|
<Tooltip position="left" tooltipContent={`${issueCycle ? issueCycle.cycle_detail.name : ""}`}>
|
|
<span
|
|
className={`w-full max-w-[125px] truncate text-left sm:block ${
|
|
issueCycle ? "" : "text-brand-base"
|
|
}`}
|
|
>
|
|
{issueCycle ? truncateText(issueCycle.cycle_detail.name, 15) : "None"}
|
|
</span>
|
|
</Tooltip>
|
|
}
|
|
value={issueCycle?.cycle_detail.id}
|
|
onChange={(value: any) => {
|
|
!value
|
|
? removeIssueFromCycle(issueCycle?.id ?? "", issueCycle?.cycle ?? "")
|
|
: handleCycleChange(incompleteCycles?.find((c) => c.id === value) as ICycle);
|
|
}}
|
|
width="w-full"
|
|
position="right"
|
|
maxHeight="rg"
|
|
disabled={isNotAllowed}
|
|
>
|
|
{incompleteCycles ? (
|
|
incompleteCycles.length > 0 ? (
|
|
<>
|
|
{incompleteCycles.map((option) => (
|
|
<CustomSelect.Option key={option.id} value={option.id}>
|
|
<Tooltip position="left-bottom" tooltipContent={option.name}>
|
|
<span className="w-full truncate ">{truncateText(option.name, 15)}</span>
|
|
</Tooltip>
|
|
</CustomSelect.Option>
|
|
))}
|
|
<CustomSelect.Option value={null}>None</CustomSelect.Option>
|
|
</>
|
|
) : (
|
|
<div className="text-center">No cycles found</div>
|
|
)
|
|
) : (
|
|
<Spinner />
|
|
)}
|
|
</CustomSelect>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|