Skip to content

Commit

Permalink
Merge branch 'preview' of github.com:makeplane/plane into fix-issue-r…
Browse files Browse the repository at this point in the history
…endering-performance
  • Loading branch information
rahulramesha committed Aug 26, 2024
2 parents d41edb0 + 4689ebe commit d9b95af
Show file tree
Hide file tree
Showing 126 changed files with 2,764 additions and 2,095 deletions.
29 changes: 29 additions & 0 deletions admin/core/components/authentication/auth-banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { FC } from "react";
import { Info, X } from "lucide-react";
// helpers
import { TAuthErrorInfo } from "@/helpers/authentication.helper";

type TAuthBanner = {
bannerData: TAuthErrorInfo | undefined;
handleBannerData?: (bannerData: TAuthErrorInfo | undefined) => void;
};

export const AuthBanner: FC<TAuthBanner> = (props) => {
const { bannerData, handleBannerData } = props;

if (!bannerData) return <></>;
return (
<div className="relative flex items-center p-2 rounded-md gap-2 border border-custom-primary-100/50 bg-custom-primary-100/10">
<div className="w-4 h-4 flex-shrink-0 relative flex justify-center items-center">
<Info size={16} className="text-custom-primary-100" />
</div>
<div className="w-full text-sm font-medium text-custom-primary-100">{bannerData?.message}</div>
<div
className="relative ml-auto w-6 h-6 rounded-sm flex justify-center items-center transition-all cursor-pointer hover:bg-custom-primary-100/20 text-custom-primary-100/80"
onClick={() => handleBannerData && handleBannerData(undefined)}
>
<X className="w-4 h-4 flex-shrink-0" />
</div>
</div>
);
};
1 change: 1 addition & 0 deletions admin/core/components/authentication/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./auth-banner";
export * from "./email-config-switch";
export * from "./password-config-switch";
export * from "./authentication-method-card";
Expand Down
24 changes: 23 additions & 1 deletion admin/core/components/login/sign-in-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ import { Button, Input, Spinner } from "@plane/ui";
// components
import { Banner } from "@/components/common";
// helpers
import {
authErrorHandler,
EAuthenticationErrorCodes,
EErrorAlertType,
TAuthErrorInfo,
} from "@/helpers/authentication.helper";

import { API_BASE_URL } from "@/helpers/common.helper";
import { AuthService } from "@/services/auth.service";
import { AuthBanner } from "../authentication";
// ui
// icons

Expand Down Expand Up @@ -53,6 +61,7 @@ export const InstanceSignInForm: FC = (props) => {
const [csrfToken, setCsrfToken] = useState<string | undefined>(undefined);
const [formData, setFormData] = useState<TFormData>(defaultFromData);
const [isSubmitting, setIsSubmitting] = useState(false);
const [errorInfo, setErrorInfo] = useState<TAuthErrorInfo | undefined>(undefined);

const handleFormChange = (key: keyof TFormData, value: string | boolean) =>
setFormData((prev) => ({ ...prev, [key]: value }));
Expand Down Expand Up @@ -91,6 +100,15 @@ export const InstanceSignInForm: FC = (props) => {
[formData.email, formData.password, isSubmitting]
);

useEffect(() => {
if (errorCode) {
const errorDetail = authErrorHandler(errorCode?.toString() as EAuthenticationErrorCodes);
if (errorDetail) {
setErrorInfo(errorDetail);
}
}
}, [errorCode]);

return (
<div className="flex-grow container mx-auto max-w-lg px-10 lg:max-w-md lg:px-5 py-10 lg:pt-28 transition-all">
<div className="relative flex flex-col space-y-6">
Expand All @@ -103,7 +121,11 @@ export const InstanceSignInForm: FC = (props) => {
</p>
</div>

{errorData.type && errorData?.message && <Banner type="error" message={errorData?.message} />}
{errorData.type && errorData?.message ? (
<Banner type="error" message={errorData?.message} />
) : (
<>{errorInfo && <AuthBanner bannerData={errorInfo} handleBannerData={(value) => setErrorInfo(value)} />}</>
)}

<form
className="space-y-4"
Expand Down
24 changes: 12 additions & 12 deletions apiserver/Dockerfile.api
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.1-alpine3.17 AS backend
FROM python:3.12.5-alpine AS backend

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
Expand All @@ -7,23 +7,23 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=1

WORKDIR /code

RUN apk --no-cache add \
"libpq~=15" \
"libxslt~=1.1" \
"nodejs-current~=19" \
"xmlsec~=1.2"
RUN apk add --no-cache \
"libpq" \
"libxslt" \
"nodejs-current" \
"xmlsec"

COPY requirements.txt ./
COPY requirements ./requirements
RUN apk add --no-cache libffi-dev
RUN apk add --no-cache --virtual .build-deps \
"bash~=5.2" \
"g++~=12.2" \
"gcc~=12.2" \
"cargo~=1.64" \
"git~=2" \
"make~=4.3" \
"postgresql13-dev~=13" \
"g++" \
"gcc" \
"cargo" \
"git" \
"make" \
"postgresql-dev" \
"libc-dev" \
"linux-headers" \
&& \
Expand Down
22 changes: 11 additions & 11 deletions apiserver/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.1-alpine3.17 AS backend
FROM python:3.12.5-alpine AS backend

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
Expand All @@ -7,18 +7,18 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=1

RUN apk --no-cache add \
"bash~=5.2" \
"libpq~=15" \
"libxslt~=1.1" \
"nodejs-current~=19" \
"xmlsec~=1.2" \
"libpq" \
"libxslt" \
"nodejs-current" \
"xmlsec" \
"libffi-dev" \
"bash~=5.2" \
"g++~=12.2" \
"gcc~=12.2" \
"cargo~=1.64" \
"git~=2" \
"make~=4.3" \
"postgresql13-dev~=13" \
"g++" \
"gcc" \
"cargo" \
"git" \
"make" \
"postgresql-dev" \
"libc-dev" \
"linux-headers"

Expand Down
6 changes: 6 additions & 0 deletions apiserver/plane/api/views/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,12 @@ def post(self, request, slug, project_id, cycle_id):
)
cycle.archived_at = timezone.now()
cycle.save()
UserFavorite.objects.filter(
entity_type="cycle",
entity_identifier=cycle_id,
project_id=project_id,
workspace__slug=slug,
).delete()
return Response(status=status.HTTP_204_NO_CONTENT)

def delete(self, request, slug, project_id, cycle_id):
Expand Down
6 changes: 6 additions & 0 deletions apiserver/plane/api/views/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,12 @@ def post(self, request, slug, project_id, pk):
)
module.archived_at = timezone.now()
module.save()
UserFavorite.objects.filter(
entity_type="module",
entity_identifier=pk,
project_id=project_id,
workspace__slug=slug,
).delete()
return Response(status=status.HTTP_204_NO_CONTENT)

def delete(self, request, slug, project_id, pk):
Expand Down
4 changes: 4 additions & 0 deletions apiserver/plane/api/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ def post(self, request, slug, project_id):
project = Project.objects.get(pk=project_id, workspace__slug=slug)
project.archived_at = timezone.now()
project.save()
UserFavorite.objects.filter(
workspace__slug=slug,
project=project_id,
).delete()
return Response(status=status.HTTP_204_NO_CONTENT)

def delete(self, request, slug, project_id):
Expand Down
2 changes: 1 addition & 1 deletion apiserver/plane/app/permissions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _wrapped_view(instance, request, *args, **kwargs):
# Return permission denied if no conditions are met
return Response(
{"error": "You don't have the required permissions."},
status=status.HTTP_401_UNAUTHORIZED,
status=status.HTTP_403_FORBIDDEN,
)

return _wrapped_view
Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/app/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
SubPageSerializer,
PageDetailSerializer,
PageVersionSerializer,
PageVersionDetailSerializer,
)

from .estimate import (
Expand Down
35 changes: 34 additions & 1 deletion apiserver/plane/app/serializers/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,40 @@ class Meta:
class PageVersionSerializer(BaseSerializer):
class Meta:
model = PageVersion
fields = "__all__"
fields = [
"id",
"workspace",
"page",
"last_saved_at",
"owned_by",
"created_at",
"updated_at",
"created_by",
"updated_by",
]
read_only_fields = [
"workspace",
"page",
]


class PageVersionDetailSerializer(BaseSerializer):
class Meta:
model = PageVersion
fields = [
"id",
"workspace",
"page",
"last_saved_at",
"description_binary",
"description_html",
"description_json",
"owned_by",
"created_at",
"updated_at",
"created_by",
"updated_by",
]
read_only_fields = [
"workspace",
"page",
Expand Down
8 changes: 1 addition & 7 deletions apiserver/plane/app/urls/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
IssueUserDisplayPropertyEndpoint,
IssueViewSet,
LabelViewSet,
BulkIssueOperationsEndpoint,
BulkArchiveIssuesEndpoint,
)

Expand Down Expand Up @@ -304,10 +303,5 @@
}
),
name="project-issue-draft",
),
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/bulk-operation-issues/",
BulkIssueOperationsEndpoint.as_view(),
name="bulk-operations-issues",
),
)
]
3 changes: 0 additions & 3 deletions apiserver/plane/app/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@
IssueSubscriberViewSet,
)


from .issue.bulk_operations import BulkIssueOperationsEndpoint

from .module.base import (
ModuleViewSet,
ModuleLinkViewSet,
Expand Down
6 changes: 6 additions & 0 deletions apiserver/plane/app/views/cycle/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,12 @@ def post(self, request, slug, project_id, cycle_id):

cycle.archived_at = timezone.now()
cycle.save()
UserFavorite.objects.filter(
entity_type="cycle",
entity_identifier=cycle_id,
project_id=project_id,
workspace__slug=slug,
).delete()
return Response(
{"archived_at": str(cycle.archived_at)},
status=status.HTTP_200_OK,
Expand Down
8 changes: 8 additions & 0 deletions apiserver/plane/app/views/cycle/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
ProjectMember,
)
from plane.utils.analytics_plot import burndown_plot
from plane.bgtasks.recent_visited_task import recent_visited_task

# Module imports
from .. import BaseAPIView, BaseViewSet
Expand Down Expand Up @@ -1028,6 +1029,13 @@ def retrieve(self, request, slug, project_id, pk):
cycle_id=pk,
)

recent_visited_task.delay(
slug=slug,
entity_name="cycle",
entity_identifier=pk,
user_id=request.user.id,
project_id=project_id,
)
return Response(
data,
status=status.HTTP_200_OK,
Expand Down
6 changes: 4 additions & 2 deletions apiserver/plane/app/views/exporter/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ExportIssuesEndpoint(BaseAPIView):
model = ExporterHistory
serializer_class = ExporterHistorySerializer

@allow_permission(allowed_roles=[ROLE.ADMIN], level="WORKSPACE")
@allow_permission(allowed_roles=[ROLE.ADMIN, ROLE.MEMBER], level="WORKSPACE")
def post(self, request, slug):
# Get the workspace
workspace = Workspace.objects.get(slug=slug)
Expand Down Expand Up @@ -62,7 +62,9 @@ def post(self, request, slug):
status=status.HTTP_400_BAD_REQUEST,
)

@allow_permission(allowed_roles=[ROLE.ADMIN], level="WORKSPACE")
@allow_permission(
allowed_roles=[ROLE.ADMIN, ROLE.MEMBER], level="WORKSPACE"
)
def get(self, request, slug):
exporter_history = ExporterHistory.objects.filter(
workspace__slug=slug,
Expand Down
5 changes: 4 additions & 1 deletion apiserver/plane/app/views/issue/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
SubGroupedOffsetPaginator,
)
from plane.app.permissions import allow_permission, ROLE
from plane.utils.error_codes import ERROR_CODES

# Module imports
from .. import BaseViewSet, BaseAPIView
Expand Down Expand Up @@ -345,7 +346,9 @@ def post(self, request, slug, project_id):
if issue.state.group not in ["completed", "cancelled"]:
return Response(
{
"error_code": 4091,
"error_code": ERROR_CODES[
"INVALID_ARCHIVE_STATE_GROUP"
],
"error_message": "INVALID_ARCHIVE_STATE_GROUP",
},
status=status.HTTP_400_BAD_REQUEST,
Expand Down
Loading

0 comments on commit d9b95af

Please sign in to comment.