mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
Merge branches 'develop' and 'develop' of github.com:makeplane/plane into develop
This commit is contained in:
commit
a77ceb636f
@ -40,6 +40,7 @@ class CycleSerializer(BaseSerializer):
|
||||
started_estimates = serializers.IntegerField(read_only=True)
|
||||
workspace_detail = WorkspaceLiteSerializer(read_only=True, source="workspace")
|
||||
project_detail = ProjectLiteSerializer(read_only=True, source="project")
|
||||
status = serializers.CharField(read_only=True)
|
||||
|
||||
def validate(self, data):
|
||||
if (
|
||||
|
@ -11,6 +11,10 @@ from django.db.models import (
|
||||
Count,
|
||||
Prefetch,
|
||||
Sum,
|
||||
Case,
|
||||
When,
|
||||
Value,
|
||||
CharField
|
||||
)
|
||||
from django.core import serializers
|
||||
from django.utils import timezone
|
||||
@ -157,6 +161,28 @@ class CycleViewSet(WebhookMixin, BaseViewSet):
|
||||
),
|
||||
)
|
||||
)
|
||||
.annotate(
|
||||
status=Case(
|
||||
When(
|
||||
Q(start_date__lte=timezone.now()) & Q(end_date__gte=timezone.now()),
|
||||
then=Value("CURRENT")
|
||||
),
|
||||
When(
|
||||
start_date__gt=timezone.now(),
|
||||
then=Value("UPCOMING")
|
||||
),
|
||||
When(
|
||||
end_date__lt=timezone.now(),
|
||||
then=Value("COMPLETED")
|
||||
),
|
||||
When(
|
||||
Q(start_date__isnull=True) & Q(end_date__isnull=True),
|
||||
then=Value("DRAFT")
|
||||
),
|
||||
default=Value("DRAFT"),
|
||||
output_field=CharField(),
|
||||
)
|
||||
)
|
||||
.prefetch_related(
|
||||
Prefetch(
|
||||
"issue_cycle__issue__assignees",
|
||||
@ -177,7 +203,7 @@ class CycleViewSet(WebhookMixin, BaseViewSet):
|
||||
queryset = self.get_queryset()
|
||||
cycle_view = request.GET.get("cycle_view", "all")
|
||||
|
||||
queryset = queryset.order_by("-is_favorite","-created_at")
|
||||
queryset = queryset.order_by("-is_favorite", "-created_at")
|
||||
|
||||
# Current Cycle
|
||||
if cycle_view == "current":
|
||||
@ -575,7 +601,9 @@ class CycleIssueViewSet(WebhookMixin, BaseViewSet):
|
||||
)
|
||||
)
|
||||
|
||||
issues = IssueStateSerializer(issues, many=True, fields=fields if fields else None).data
|
||||
issues = IssueStateSerializer(
|
||||
issues, many=True, fields=fields if fields else None
|
||||
).data
|
||||
issue_dict = {str(issue["id"]): issue for issue in issues}
|
||||
return Response(issue_dict, status=status.HTTP_200_OK)
|
||||
|
||||
@ -805,4 +833,4 @@ class TransferCycleIssueEndpoint(BaseAPIView):
|
||||
updated_cycles, ["cycle_id"], batch_size=100
|
||||
)
|
||||
|
||||
return Response({"message": "Success"}, status=status.HTTP_200_OK)
|
||||
return Response({"message": "Success"}, status=status.HTTP_200_OK)
|
||||
|
@ -18,7 +18,8 @@ type Props = {
|
||||
|
||||
export const NotAuthorizedView: React.FC<Props> = ({ actionButton, type }) => {
|
||||
const { user } = useUser();
|
||||
const { asPath: currentPath } = useRouter();
|
||||
const { query } = useRouter();
|
||||
const { next_path } = query;
|
||||
|
||||
return (
|
||||
<DefaultLayout>
|
||||
@ -37,7 +38,7 @@ export const NotAuthorizedView: React.FC<Props> = ({ actionButton, type }) => {
|
||||
{user ? (
|
||||
<p>
|
||||
You have signed in as {user.email}. <br />
|
||||
<Link href={`/?next=${currentPath}`}>
|
||||
<Link href={`/?next_path=${next_path}`}>
|
||||
<span className="font-medium text-custom-text-100">Sign in</span>
|
||||
</Link>{" "}
|
||||
with different account that has access to this page.
|
||||
@ -45,7 +46,7 @@ export const NotAuthorizedView: React.FC<Props> = ({ actionButton, type }) => {
|
||||
) : (
|
||||
<p>
|
||||
You need to{" "}
|
||||
<Link href={`/?next=${currentPath}`}>
|
||||
<Link href={`/?next_path=${next_path}`}>
|
||||
<span className="font-medium text-custom-text-100">Sign in</span>
|
||||
</Link>{" "}
|
||||
with an account that has access to this page.
|
||||
|
@ -11,7 +11,6 @@ import {
|
||||
CopyPlus,
|
||||
Calendar,
|
||||
Link2Icon,
|
||||
RocketIcon,
|
||||
Users2Icon,
|
||||
ArchiveIcon,
|
||||
PaperclipIcon,
|
||||
@ -48,8 +47,8 @@ const IssueLink = ({ activity }: { activity: IIssueActivity }) => {
|
||||
rel={activity.issue === null ? "" : "noopener noreferrer"}
|
||||
className="inline-flex items-center gap-1 font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
{activity.issue_detail ? `${activity.project_detail.identifier}-${activity.issue_detail.sequence_id}` : "Issue"}
|
||||
<RocketIcon size={12} color="#6b7280" className="flex-shrink-0" />
|
||||
{activity.issue_detail ? `${activity.project_detail.identifier}-${activity.issue_detail.sequence_id}` : "Issue"}{" "}
|
||||
<span className="font-normal">{activity.issue_detail?.name}</span>
|
||||
</a>
|
||||
</Tooltip>
|
||||
);
|
||||
@ -163,7 +162,6 @@ const activityDetails: {
|
||||
className="inline-flex items-center gap-1 font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
attachment
|
||||
<RocketIcon size={12} color="#6b7280" />
|
||||
</a>
|
||||
{showIssue && (
|
||||
<>
|
||||
@ -239,7 +237,6 @@ const activityDetails: {
|
||||
className="inline-flex items-center gap-1 truncate font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
<span className="truncate">{activity.new_value}</span>
|
||||
<RocketIcon size={12} color="#6b7280" className="flex-shrink-0" />
|
||||
</a>
|
||||
</>
|
||||
);
|
||||
@ -254,7 +251,6 @@ const activityDetails: {
|
||||
className="inline-flex items-center gap-1 truncate font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
<span className="truncate">{activity.new_value}</span>
|
||||
<RocketIcon size={12} color="#6b7280" className="flex-shrink-0" />
|
||||
</a>
|
||||
</>
|
||||
);
|
||||
@ -269,7 +265,6 @@ const activityDetails: {
|
||||
className="inline-flex items-center gap-1 truncate font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
<span className="truncate">{activity.old_value}</span>
|
||||
<RocketIcon size={12} color="#6b7280" className="flex-shrink-0" />
|
||||
</a>
|
||||
</>
|
||||
);
|
||||
@ -398,7 +393,6 @@ const activityDetails: {
|
||||
className="inline-flex items-center gap-1 font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
link
|
||||
<RocketIcon size={12} color="#6b7280" />
|
||||
</a>
|
||||
{showIssue && (
|
||||
<>
|
||||
@ -420,7 +414,6 @@ const activityDetails: {
|
||||
className="inline-flex items-center gap-1 font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
link
|
||||
<RocketIcon size={12} color="#6b7280" />
|
||||
</a>
|
||||
{showIssue && (
|
||||
<>
|
||||
@ -442,7 +435,6 @@ const activityDetails: {
|
||||
className="inline-flex items-center gap-1 font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
link
|
||||
<RocketIcon size={12} color="#6b7280" />
|
||||
</a>
|
||||
{showIssue && (
|
||||
<>
|
||||
@ -469,7 +461,6 @@ const activityDetails: {
|
||||
className="inline-flex items-center gap-1 truncate font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
<span className="truncate">{activity.new_value}</span>
|
||||
<RocketIcon size={12} color="#6b7280" className="flex-shrink-0" />
|
||||
</a>
|
||||
</>
|
||||
);
|
||||
@ -484,7 +475,6 @@ const activityDetails: {
|
||||
className="inline-flex items-center gap-1 truncate font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
<span className="truncate">{activity.new_value}</span>
|
||||
<RocketIcon size={12} color="#6b7280" className="flex-shrink-0" />
|
||||
</a>
|
||||
</>
|
||||
);
|
||||
@ -499,7 +489,6 @@ const activityDetails: {
|
||||
className="inline-flex items-center gap-1 truncate font-medium text-custom-text-100 hover:underline"
|
||||
>
|
||||
<span className="truncate">{activity.old_value}</span>
|
||||
<RocketIcon size={12} color="#6b7280" className="flex-shrink-0" />
|
||||
</a>
|
||||
</>
|
||||
);
|
||||
|
@ -28,7 +28,7 @@ import { ViewIssueLabel } from "components/issues";
|
||||
// icons
|
||||
import { AlarmClock, AlertTriangle, ArrowRight, CalendarDays, Star, Target } from "lucide-react";
|
||||
// helpers
|
||||
import { getDateRangeStatus, renderShortDateWithYearFormat, findHowManyDaysLeft } from "helpers/date-time.helper";
|
||||
import { renderShortDateWithYearFormat, findHowManyDaysLeft } from "helpers/date-time.helper";
|
||||
import { truncateText } from "helpers/string.helper";
|
||||
// types
|
||||
import { ICycle } from "types";
|
||||
@ -137,7 +137,7 @@ export const ActiveCycleDetails: React.FC<IActiveCycleDetails> = observer((props
|
||||
cancelled: cycle.cancelled_issues,
|
||||
};
|
||||
|
||||
const cycleStatus = getDateRangeStatus(cycle.start_date, cycle.end_date);
|
||||
const cycleStatus = cycle.status.toLocaleLowerCase();
|
||||
|
||||
const handleAddToFavorites = (e: MouseEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault();
|
||||
|
@ -10,15 +10,10 @@ import { Avatar, AvatarGroup, CustomMenu, Tooltip, LayersIcon, CycleGroupIcon }
|
||||
// icons
|
||||
import { Info, LinkIcon, Pencil, Star, Trash2 } from "lucide-react";
|
||||
// helpers
|
||||
import {
|
||||
getDateRangeStatus,
|
||||
findHowManyDaysLeft,
|
||||
renderShortDate,
|
||||
renderShortMonthDate,
|
||||
} from "helpers/date-time.helper";
|
||||
import { findHowManyDaysLeft, renderShortDate, renderShortMonthDate } from "helpers/date-time.helper";
|
||||
import { copyTextToClipboard } from "helpers/string.helper";
|
||||
// types
|
||||
import { ICycle } from "types";
|
||||
import { ICycle, TCycleGroups } from "types";
|
||||
// store
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// constants
|
||||
@ -45,7 +40,7 @@ export const CyclesBoardCard: FC<ICyclesBoardCard> = (props) => {
|
||||
const [updateModal, setUpdateModal] = useState(false);
|
||||
const [deleteModal, setDeleteModal] = useState(false);
|
||||
// computed
|
||||
const cycleStatus = getDateRangeStatus(cycle.start_date, cycle.end_date);
|
||||
const cycleStatus = cycle.status.toLocaleLowerCase() as TCycleGroups;
|
||||
const isCompleted = cycleStatus === "completed";
|
||||
const endDate = new Date(cycle.end_date ?? "");
|
||||
const startDate = new Date(cycle.start_date ?? "");
|
||||
|
@ -13,15 +13,10 @@ import { CustomMenu, Tooltip, CircularProgressIndicator, CycleGroupIcon, AvatarG
|
||||
// icons
|
||||
import { Check, Info, LinkIcon, Pencil, Star, Trash2, User2 } from "lucide-react";
|
||||
// helpers
|
||||
import {
|
||||
getDateRangeStatus,
|
||||
findHowManyDaysLeft,
|
||||
renderShortDate,
|
||||
renderShortMonthDate,
|
||||
} from "helpers/date-time.helper";
|
||||
import { findHowManyDaysLeft, renderShortDate, renderShortMonthDate } from "helpers/date-time.helper";
|
||||
import { copyTextToClipboard } from "helpers/string.helper";
|
||||
// types
|
||||
import { ICycle } from "types";
|
||||
import { ICycle, TCycleGroups } from "types";
|
||||
// constants
|
||||
import { CYCLE_STATUS } from "constants/cycle";
|
||||
import { EUserWorkspaceRoles } from "constants/workspace";
|
||||
@ -50,7 +45,7 @@ export const CyclesListItem: FC<TCyclesListItem> = (props) => {
|
||||
const [updateModal, setUpdateModal] = useState(false);
|
||||
const [deleteModal, setDeleteModal] = useState(false);
|
||||
// computed
|
||||
const cycleStatus = getDateRangeStatus(cycle.start_date, cycle.end_date);
|
||||
const cycleStatus = cycle.status.toLocaleLowerCase() as TCycleGroups;
|
||||
const isCompleted = cycleStatus === "completed";
|
||||
const endDate = new Date(cycle.end_date ?? "");
|
||||
const startDate = new Date(cycle.start_date ?? "");
|
||||
|
@ -3,7 +3,7 @@ import { useRouter } from "next/router";
|
||||
// ui
|
||||
import { Tooltip, ContrastIcon } from "@plane/ui";
|
||||
// helpers
|
||||
import { getDateRangeStatus, renderShortDate } from "helpers/date-time.helper";
|
||||
import { renderShortDate } from "helpers/date-time.helper";
|
||||
// types
|
||||
import { ICycle } from "types";
|
||||
|
||||
@ -11,8 +11,7 @@ export const CycleGanttBlock = ({ data }: { data: ICycle }) => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug } = router.query;
|
||||
|
||||
const cycleStatus = getDateRangeStatus(data?.start_date, data?.end_date);
|
||||
|
||||
const cycleStatus = data.status.toLocaleLowerCase();
|
||||
return (
|
||||
<div
|
||||
className="relative flex h-full w-full items-center rounded"
|
||||
@ -21,12 +20,12 @@ export const CycleGanttBlock = ({ data }: { data: ICycle }) => {
|
||||
cycleStatus === "current"
|
||||
? "#09a953"
|
||||
: cycleStatus === "upcoming"
|
||||
? "#f7ae59"
|
||||
: cycleStatus === "completed"
|
||||
? "#3f76ff"
|
||||
: cycleStatus === "draft"
|
||||
? "rgb(var(--color-text-200))"
|
||||
: "",
|
||||
? "#f7ae59"
|
||||
: cycleStatus === "completed"
|
||||
? "#3f76ff"
|
||||
: cycleStatus === "draft"
|
||||
? "rgb(var(--color-text-200))"
|
||||
: "",
|
||||
}}
|
||||
onClick={() => router.push(`/${workspaceSlug}/projects/${data?.project}/cycles/${data?.id}`)}
|
||||
>
|
||||
@ -52,7 +51,7 @@ export const CycleGanttSidebarBlock = ({ data }: { data: ICycle }) => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug } = router.query;
|
||||
|
||||
const cycleStatus = getDateRangeStatus(data?.start_date, data?.end_date);
|
||||
const cycleStatus = data.status.toLocaleLowerCase();
|
||||
|
||||
return (
|
||||
<div
|
||||
@ -65,12 +64,12 @@ export const CycleGanttSidebarBlock = ({ data }: { data: ICycle }) => {
|
||||
cycleStatus === "current"
|
||||
? "#09a953"
|
||||
: cycleStatus === "upcoming"
|
||||
? "#f7ae59"
|
||||
: cycleStatus === "completed"
|
||||
? "#3f76ff"
|
||||
: cycleStatus === "draft"
|
||||
? "rgb(var(--color-text-200))"
|
||||
: ""
|
||||
? "#f7ae59"
|
||||
: cycleStatus === "completed"
|
||||
? "#3f76ff"
|
||||
: cycleStatus === "draft"
|
||||
? "rgb(var(--color-text-200))"
|
||||
: ""
|
||||
}`}
|
||||
/>
|
||||
<h6 className="flex-grow truncate text-sm font-medium">{data?.name}</h6>
|
||||
|
@ -31,7 +31,6 @@ import {
|
||||
import { copyUrlToClipboard } from "helpers/string.helper";
|
||||
import {
|
||||
findHowManyDaysLeft,
|
||||
getDateRangeStatus,
|
||||
isDateGreaterThanToday,
|
||||
renderDateFormat,
|
||||
renderShortDate,
|
||||
@ -275,10 +274,7 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {
|
||||
[workspaceSlug, projectId, cycleId, issueFilters, updateFilters]
|
||||
);
|
||||
|
||||
const cycleStatus =
|
||||
cycleDetails?.start_date && cycleDetails?.end_date
|
||||
? getDateRangeStatus(cycleDetails?.start_date, cycleDetails?.end_date)
|
||||
: "draft";
|
||||
const cycleStatus = cycleDetails.status.toLocaleLowerCase();
|
||||
const isCompleted = cycleStatus === "completed";
|
||||
|
||||
const isStartValid = new Date(`${cycleDetails?.start_date}`) <= new Date();
|
||||
|
@ -15,8 +15,6 @@ import { AlertCircle, Search, X } from "lucide-react";
|
||||
import { INCOMPLETE_CYCLES_LIST } from "constants/fetch-keys";
|
||||
// types
|
||||
import { ICycle } from "types";
|
||||
//helper
|
||||
import { getDateRangeStatus } from "helpers/date-time.helper";
|
||||
|
||||
type Props = {
|
||||
isOpen: boolean;
|
||||
@ -138,7 +136,7 @@ export const TransferIssuesModal: React.FC<Props> = observer(({ isOpen, handleCl
|
||||
<div className="flex w-full justify-between">
|
||||
<span>{option?.name}</span>
|
||||
<span className=" flex items-center rounded-full bg-custom-background-80 px-2 capitalize">
|
||||
{getDateRangeStatus(option?.start_date, option?.end_date)}
|
||||
{option.status}
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
|
@ -95,7 +95,7 @@ export const GlobalIssuesHeader: React.FC<Props> = observer((props) => {
|
||||
<PhotoFilterIcon className="h-4 w-4 text-custom-text-300" />
|
||||
)
|
||||
}
|
||||
label={`Workspace ${activeLayout === "spreadsheet" ? "Issues" : "Views"}`}
|
||||
label={`All ${activeLayout === "spreadsheet" ? "Issues" : "Views"}`}
|
||||
/>
|
||||
</Breadcrumbs>
|
||||
</div>
|
||||
|
@ -23,7 +23,7 @@ export const ArchivedIssueQuickActions: React.FC<IQuickActionProps> = (props) =>
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const handleCopyIssueLink = () => {
|
||||
copyUrlToClipboard(`/${workspaceSlug}/projects/${issue.project}/archived-issues/${issue.id}`).then(() =>
|
||||
copyUrlToClipboard(`${workspaceSlug}/projects/${issue.project}/archived-issues/${issue.id}`).then(() =>
|
||||
setToastAlert({
|
||||
type: "success",
|
||||
title: "Link copied",
|
||||
|
@ -27,7 +27,7 @@ export const CycleIssueQuickActions: React.FC<IQuickActionProps> = (props) => {
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const handleCopyIssueLink = () => {
|
||||
copyUrlToClipboard(`/${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`).then(() =>
|
||||
copyUrlToClipboard(`${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`).then(() =>
|
||||
setToastAlert({
|
||||
type: "success",
|
||||
title: "Link copied",
|
||||
|
@ -27,7 +27,7 @@ export const ModuleIssueQuickActions: React.FC<IQuickActionProps> = (props) => {
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const handleCopyIssueLink = () => {
|
||||
copyUrlToClipboard(`/${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`).then(() =>
|
||||
copyUrlToClipboard(`${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`).then(() =>
|
||||
setToastAlert({
|
||||
type: "success",
|
||||
title: "Link copied",
|
||||
|
@ -37,7 +37,7 @@ export const ProjectIssueQuickActions: React.FC<IQuickActionProps> = (props) =>
|
||||
const { setToastAlert } = useToast();
|
||||
|
||||
const handleCopyIssueLink = () => {
|
||||
copyUrlToClipboard(`/${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`).then(() =>
|
||||
copyUrlToClipboard(`${workspaceSlug}/projects/${issue.project}/issues/${issue.id}`).then(() =>
|
||||
setToastAlert({
|
||||
type: "success",
|
||||
title: "Link copied",
|
||||
|
@ -17,8 +17,6 @@ import {
|
||||
import { TransferIssues, TransferIssuesModal } from "components/cycles";
|
||||
// ui
|
||||
import { Spinner } from "@plane/ui";
|
||||
// helpers
|
||||
import { getDateRangeStatus } from "helpers/date-time.helper";
|
||||
|
||||
export const CycleLayoutRoot: React.FC = observer(() => {
|
||||
const [transferIssuesModal, setTransferIssuesModal] = useState(false);
|
||||
@ -50,10 +48,7 @@ export const CycleLayoutRoot: React.FC = observer(() => {
|
||||
const activeLayout = issueFilters?.displayFilters?.layout;
|
||||
|
||||
const cycleDetails = cycleId ? cycleStore.cycle_details[cycleId.toString()] : undefined;
|
||||
const cycleStatus =
|
||||
cycleDetails?.start_date && cycleDetails?.end_date
|
||||
? getDateRangeStatus(cycleDetails?.start_date, cycleDetails?.end_date)
|
||||
: "draft";
|
||||
const cycleStatus = cycleDetails?.status.toLocaleLowerCase() ?? "draft";
|
||||
|
||||
return (
|
||||
<>
|
||||
|
@ -88,7 +88,7 @@ export const IssueActivityCard: FC<IIssueActivityCard> = (props) => {
|
||||
</div>
|
||||
</div>
|
||||
<div className="min-w-0 flex-1 py-3">
|
||||
<div className="break-words text-xs text-custom-text-200">
|
||||
<div className="flex gap-1 break-words text-xs text-custom-text-200">
|
||||
{activityItem.field === "archived_at" && activityItem.new_value !== "restore" ? (
|
||||
<span className="text-gray font-medium">Plane</span>
|
||||
) : activityItem.actor_detail.is_bot ? (
|
||||
@ -101,8 +101,8 @@ export const IssueActivityCard: FC<IIssueActivityCard> = (props) => {
|
||||
: activityItem.actor_detail.display_name}
|
||||
</span>
|
||||
</Link>
|
||||
)}{" "}
|
||||
{message}{" "}
|
||||
)}
|
||||
{message}
|
||||
<Tooltip
|
||||
tooltipContent={`${renderLongDateFormat(activityItem.created_at)}, ${render24HourFormatTime(
|
||||
activityItem.created_at
|
||||
|
@ -35,31 +35,34 @@ export const SidebarParentSelect: React.FC<Props> = ({ onChange, issueDetails, p
|
||||
issueId={issueId as string}
|
||||
projectId={projectId as string}
|
||||
/>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className={`flex items-center gap-2 rounded bg-custom-background-80 px-2.5 py-0.5 text-xs max-w-max" ${
|
||||
<div
|
||||
className={`flex items-center gap-2 rounded bg-custom-background-80 px-2.5 py-0.5 text-xs w-max max-w-max" ${
|
||||
disabled ? "cursor-not-allowed" : "cursor-pointer "
|
||||
}`}
|
||||
onClick={() => {
|
||||
if (issueDetails?.parent) {
|
||||
onChange("");
|
||||
setSelectedParentIssue(null);
|
||||
} else {
|
||||
setIsParentModalOpen(true);
|
||||
}
|
||||
}}
|
||||
disabled={disabled}
|
||||
>
|
||||
{selectedParentIssue && issueDetails?.parent ? (
|
||||
`${selectedParentIssue.project__identifier}-${selectedParentIssue.sequence_id}`
|
||||
) : !selectedParentIssue && issueDetails?.parent ? (
|
||||
`${issueDetails.parent_detail?.project_detail.identifier}-${issueDetails.parent_detail?.sequence_id}`
|
||||
) : (
|
||||
<span className="text-custom-text-200">Select issue</span>
|
||||
<button type="button" className="flex-shrink-0" onClick={() => setIsParentModalOpen(true)} disabled={disabled}>
|
||||
{selectedParentIssue && issueDetails?.parent ? (
|
||||
`${selectedParentIssue.project__identifier}-${selectedParentIssue.sequence_id}`
|
||||
) : !selectedParentIssue && issueDetails?.parent ? (
|
||||
`${issueDetails.parent_detail?.project_detail.identifier}-${issueDetails.parent_detail?.sequence_id}`
|
||||
) : (
|
||||
<span className="text-custom-text-200">Select issue</span>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{issueDetails?.parent && (
|
||||
<button
|
||||
type="button"
|
||||
className="flex-shrink-0"
|
||||
onClick={() => {
|
||||
onChange("");
|
||||
setSelectedParentIssue(null);
|
||||
}}
|
||||
>
|
||||
<X className="h-2.5 w-2.5" />
|
||||
</button>
|
||||
)}
|
||||
{issueDetails?.parent && <X className="h-2.5 w-2.5" />}
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
@ -1,7 +1,5 @@
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import { UserService } from "services/user.service";
|
||||
// components
|
||||
@ -9,7 +7,6 @@ import { ActivityMessage } from "components/core";
|
||||
// ui
|
||||
import { ProfileEmptyState } from "components/ui";
|
||||
import { Loader } from "@plane/ui";
|
||||
import { Rocket } from "lucide-react";
|
||||
// image
|
||||
import recentActivityEmptyState from "public/empty-state/recent_activity.svg";
|
||||
// helpers
|
||||
@ -67,10 +64,9 @@ export const ProfileActivity = () => {
|
||||
href={`/${workspaceSlug}/projects/${activity.project}/issues/${activity.issue}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-1 font-medium text-custom-text-100 hover:underline"
|
||||
className="inline-flex items-center gap-1 font-medium text-custom-text-200 hover:underline"
|
||||
>
|
||||
Issue
|
||||
<Rocket className="h-3 w-3" />
|
||||
Issue.
|
||||
</a>
|
||||
</span>
|
||||
)}
|
||||
|
@ -170,18 +170,6 @@ export const formatLongDateDistance = (date: string | Date) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getDateRangeStatus = (startDate: string | null | undefined, endDate: string | null | undefined) => {
|
||||
if (!startDate || !endDate) return "draft";
|
||||
|
||||
const now = new Date();
|
||||
const start = new Date(startDate);
|
||||
const end = new Date(endDate);
|
||||
|
||||
if (start <= now && end >= now) return "current";
|
||||
else if (start > now) return "upcoming";
|
||||
else return "completed";
|
||||
};
|
||||
|
||||
export const renderShortDateWithYearFormat = (date: string | Date, placeholder?: string) => {
|
||||
if (!date || date === "") return null;
|
||||
|
||||
|
@ -17,36 +17,54 @@ const useSignInRedirection = (): UseSignInRedirectionProps => {
|
||||
const [error, setError] = useState<any | null>(null);
|
||||
// router
|
||||
const router = useRouter();
|
||||
const { next_url } = router.query;
|
||||
const { next_path } = router.query;
|
||||
// mobx store
|
||||
const {
|
||||
user: { fetchCurrentUser, fetchCurrentUserSettings },
|
||||
} = useMobxStore();
|
||||
|
||||
const isValidURL = (url: string): boolean => {
|
||||
const disallowedSchemes = /^(https?|ftp):\/\//i;
|
||||
return !disallowedSchemes.test(url);
|
||||
};
|
||||
|
||||
console.log("next_path", next_path);
|
||||
|
||||
const handleSignInRedirection = useCallback(
|
||||
async (user: IUser) => {
|
||||
// if the user is not onboarded, redirect them to the onboarding page
|
||||
if (!user.is_onboarded) {
|
||||
router.push("/onboarding");
|
||||
return;
|
||||
}
|
||||
// if next_url is provided, redirect the user to that url
|
||||
if (next_url) {
|
||||
router.push(next_url.toString());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// if the user is not onboarded, redirect them to the onboarding page
|
||||
if (!user.is_onboarded) {
|
||||
router.push("/onboarding");
|
||||
return;
|
||||
}
|
||||
// if next_path is provided, redirect the user to that url
|
||||
if (next_path) {
|
||||
if (isValidURL(next_path.toString())) {
|
||||
router.push(next_path.toString());
|
||||
return;
|
||||
} else {
|
||||
router.push("/");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if the user is onboarded, fetch their last workspace details
|
||||
await fetchCurrentUserSettings()
|
||||
.then((userSettings: IUserSettings) => {
|
||||
const workspaceSlug =
|
||||
userSettings?.workspace?.last_workspace_slug || userSettings?.workspace?.fallback_workspace_slug;
|
||||
if (workspaceSlug) router.push(`/${workspaceSlug}`);
|
||||
else router.push("/profile");
|
||||
})
|
||||
.catch((err) => setError(err));
|
||||
// Fetch the current user settings
|
||||
const userSettings: IUserSettings = await fetchCurrentUserSettings();
|
||||
|
||||
// Extract workspace details
|
||||
const workspaceSlug =
|
||||
userSettings?.workspace?.last_workspace_slug || userSettings?.workspace?.fallback_workspace_slug;
|
||||
|
||||
// Redirect based on workspace details or to profile if not available
|
||||
if (workspaceSlug) router.push(`/${workspaceSlug}`);
|
||||
else router.push("/profile");
|
||||
} catch (error) {
|
||||
console.error("Error in handleSignInRedirection:", error);
|
||||
setError(error);
|
||||
}
|
||||
},
|
||||
[fetchCurrentUserSettings, router, next_url]
|
||||
[fetchCurrentUserSettings, router, next_path]
|
||||
);
|
||||
|
||||
const updateUserInfo = useCallback(async () => {
|
||||
|
@ -12,7 +12,7 @@ const workspaceService = new WorkspaceService();
|
||||
|
||||
const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "admin") => {
|
||||
const router = useRouter();
|
||||
const { next_url } = router.query;
|
||||
const { next_path } = router.query;
|
||||
|
||||
const [isRouteAccess, setIsRouteAccess] = useState(true);
|
||||
const {
|
||||
@ -29,6 +29,11 @@ const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "adm
|
||||
shouldRetryOnError: false,
|
||||
});
|
||||
|
||||
const isValidURL = (url: string): boolean => {
|
||||
const disallowedSchemes = /^(https?|ftp):\/\//i;
|
||||
return !disallowedSchemes.test(url);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const handleWorkSpaceRedirection = async () => {
|
||||
workspaceService.userWorkspaces().then(async (userWorkspaces) => {
|
||||
@ -84,8 +89,15 @@ const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "adm
|
||||
if (!isLoading) {
|
||||
setIsRouteAccess(() => true);
|
||||
if (user) {
|
||||
if (next_url) router.push(next_url.toString());
|
||||
else handleUserRouteAuthentication();
|
||||
if (next_path) {
|
||||
if (isValidURL(next_path.toString())) {
|
||||
router.push(next_path.toString());
|
||||
return;
|
||||
} else {
|
||||
router.push("/");
|
||||
return;
|
||||
}
|
||||
} else handleUserRouteAuthentication();
|
||||
} else {
|
||||
if (routeAuth === "sign-in") {
|
||||
setIsRouteAccess(() => false);
|
||||
@ -97,7 +109,7 @@ const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "adm
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [user, isLoading, routeAuth, router, next_url]);
|
||||
}, [user, isLoading, routeAuth, router, next_path]);
|
||||
|
||||
return {
|
||||
isLoading: isRouteAccess,
|
||||
|
@ -31,7 +31,7 @@ export default function useUser({ redirectTo = "", redirectIfFound = false, opti
|
||||
) {
|
||||
router.push(redirectTo);
|
||||
return;
|
||||
// const nextLocation = router.asPath.split("?next=")[1];
|
||||
// const nextLocation = router.asPath.split("?next_path=")[1];
|
||||
// if (nextLocation) {
|
||||
// router.push(nextLocation as string);
|
||||
// return;
|
||||
|
@ -56,7 +56,7 @@ export const UserAuthWrapper: FC<IUserAuthWrapper> = observer((props) => {
|
||||
|
||||
if (currentUserError) {
|
||||
const redirectTo = router.asPath;
|
||||
router.push(`/?next=${redirectTo}`);
|
||||
router.push(`/?next_path=${redirectTo}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,6 @@ import { Controller, useForm } from "react-hook-form";
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// services
|
||||
import { WorkspaceService } from "services/workspace.service";
|
||||
// hooks
|
||||
import useUserAuth from "hooks/use-user-auth";
|
||||
// layouts
|
||||
import DefaultLayout from "layouts/default-layout";
|
||||
import { UserAuthWrapper } from "layouts/auth-layout";
|
||||
@ -45,8 +43,6 @@ const OnboardingPage: NextPageWithLayout = observer(() => {
|
||||
|
||||
const { setTheme } = useTheme();
|
||||
|
||||
const {} = useUserAuth("onboarding");
|
||||
|
||||
const { control, setValue } = useForm<{ full_name: string }>({
|
||||
defaultValues: {
|
||||
full_name: "",
|
||||
@ -158,8 +154,8 @@ const OnboardingPage: NextPageWithLayout = observer(() => {
|
||||
currentUser?.first_name
|
||||
? `${currentUser?.first_name} ${currentUser?.last_name ?? ""}`
|
||||
: value.length > 0
|
||||
? value
|
||||
: currentUser?.email
|
||||
? value
|
||||
: currentUser?.email
|
||||
}
|
||||
src={currentUser?.avatar}
|
||||
size={35}
|
||||
@ -174,8 +170,8 @@ const OnboardingPage: NextPageWithLayout = observer(() => {
|
||||
{currentUser?.first_name
|
||||
? `${currentUser?.first_name} ${currentUser?.last_name ?? ""}`
|
||||
: value.length > 0
|
||||
? value
|
||||
: null}
|
||||
? value
|
||||
: null}
|
||||
</p>
|
||||
)}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import { RootStore } from "../root";
|
||||
import { ProjectService } from "services/project";
|
||||
import { IssueService } from "services/issue";
|
||||
import { CycleService } from "services/cycle.service";
|
||||
import { getDateRangeStatus } from "helpers/date-time.helper";
|
||||
|
||||
export interface ICycleStore {
|
||||
loader: boolean;
|
||||
@ -318,7 +317,7 @@ export class CycleStore implements ICycleStore {
|
||||
};
|
||||
|
||||
addCycleToFavorites = async (workspaceSlug: string, projectId: string, cycle: ICycle) => {
|
||||
const cycleStatus = getDateRangeStatus(cycle.start_date, cycle.end_date);
|
||||
const cycleStatus = cycle.status;
|
||||
|
||||
const statusCyclesList = this.cycles[projectId]?.[cycleStatus] ?? [];
|
||||
const allCyclesList = this.projectCycles ?? [];
|
||||
@ -379,7 +378,7 @@ export class CycleStore implements ICycleStore {
|
||||
};
|
||||
|
||||
removeCycleFromFavorites = async (workspaceSlug: string, projectId: string, cycle: ICycle) => {
|
||||
const cycleStatus = getDateRangeStatus(cycle.start_date, cycle.end_date);
|
||||
const cycleStatus = cycle.status;
|
||||
|
||||
const statusCyclesList = this.cycles[projectId]?.[cycleStatus] ?? [];
|
||||
const allCyclesList = this.projectCycles ?? [];
|
||||
|
3
web/types/cycles.d.ts
vendored
3
web/types/cycles.d.ts
vendored
@ -2,6 +2,8 @@ import type { IUser, IIssue, IProjectLite, IWorkspaceLite, IIssueFilterOptions,
|
||||
|
||||
export type TCycleView = "all" | "active" | "upcoming" | "completed" | "draft";
|
||||
|
||||
export type TCycleGroups = "current" | "upcoming" | "completed" | "draft";
|
||||
|
||||
export type TCycleLayout = "list" | "board" | "gantt";
|
||||
|
||||
export interface ICycle {
|
||||
@ -24,6 +26,7 @@ export interface ICycle {
|
||||
owned_by: IUser;
|
||||
project: string;
|
||||
project_detail: IProjectLite;
|
||||
status: TCycleGroups;
|
||||
sort_order: number;
|
||||
start_date: string | null;
|
||||
started_issues: number;
|
||||
|
Loading…
Reference in New Issue
Block a user