Merge branch 'develop' of github.com:makeplane/plane into dev/api_logging

This commit is contained in:
pablohashescobar 2023-10-30 11:35:38 +05:30
commit f231ac0a79
180 changed files with 8244 additions and 6618 deletions

3
.gitignore vendored
View File

@ -16,7 +16,8 @@ node_modules
# Production # Production
/build /build
dist dist/
out/
# Misc # Misc
.DS_Store .DS_Store

View File

@ -75,13 +75,13 @@ class IssueCreateSerializer(BaseSerializer):
project_detail = ProjectLiteSerializer(read_only=True, source="project") project_detail = ProjectLiteSerializer(read_only=True, source="project")
workspace_detail = WorkspaceLiteSerializer(read_only=True, source="workspace") workspace_detail = WorkspaceLiteSerializer(read_only=True, source="workspace")
assignees_list = serializers.ListField( assignees = serializers.ListField(
child=serializers.PrimaryKeyRelatedField(queryset=User.objects.all()), child=serializers.PrimaryKeyRelatedField(queryset=User.objects.all()),
write_only=True, write_only=True,
required=False, required=False,
) )
labels_list = serializers.ListField( labels = serializers.ListField(
child=serializers.PrimaryKeyRelatedField(queryset=Label.objects.all()), child=serializers.PrimaryKeyRelatedField(queryset=Label.objects.all()),
write_only=True, write_only=True,
required=False, required=False,
@ -99,6 +99,12 @@ class IssueCreateSerializer(BaseSerializer):
"updated_at", "updated_at",
] ]
def to_representation(self, instance):
data = super().to_representation(instance)
data['assignees'] = [str(assignee.id) for assignee in instance.assignees.all()]
data['labels'] = [str(label.id) for label in instance.labels.all()]
return data
def validate(self, data): def validate(self, data):
if ( if (
data.get("start_date", None) is not None data.get("start_date", None) is not None
@ -109,8 +115,8 @@ class IssueCreateSerializer(BaseSerializer):
return data return data
def create(self, validated_data): def create(self, validated_data):
assignees = validated_data.pop("assignees_list", None) assignees = validated_data.pop("assignees", None)
labels = validated_data.pop("labels_list", None) labels = validated_data.pop("labels", None)
project_id = self.context["project_id"] project_id = self.context["project_id"]
workspace_id = self.context["workspace_id"] workspace_id = self.context["workspace_id"]
@ -168,8 +174,8 @@ class IssueCreateSerializer(BaseSerializer):
return issue return issue
def update(self, instance, validated_data): def update(self, instance, validated_data):
assignees = validated_data.pop("assignees_list", None) assignees = validated_data.pop("assignees", None)
labels = validated_data.pop("labels_list", None) labels = validated_data.pop("labels", None)
# Related models # Related models
project_id = instance.project_id project_id = instance.project_id

View File

@ -17,7 +17,7 @@ from plane.api.views import (
IssueSubscriberViewSet, IssueSubscriberViewSet,
IssueReactionViewSet, IssueReactionViewSet,
CommentReactionViewSet, CommentReactionViewSet,
IssuePropertyViewSet, IssueUserDisplayPropertyEndpoint,
IssueArchiveViewSet, IssueArchiveViewSet,
IssueRelationViewSet, IssueRelationViewSet,
IssueDraftViewSet, IssueDraftViewSet,
@ -235,28 +235,11 @@ urlpatterns = [
## End Comment Reactions ## End Comment Reactions
## IssueProperty ## IssueProperty
path( path(
"workspaces/<str:slug>/projects/<uuid:project_id>/issue-properties/", "workspaces/<str:slug>/projects/<uuid:project_id>/issue-display-properties/",
IssuePropertyViewSet.as_view( IssueUserDisplayPropertyEndpoint.as_view(),
{ name="project-issue-display-properties",
"get": "list",
"post": "create",
}
),
name="project-issue-roadmap",
), ),
path( ## IssueProperty End
"workspaces/<str:slug>/projects/<uuid:project_id>/issue-properties/<uuid:pk>/",
IssuePropertyViewSet.as_view(
{
"get": "retrieve",
"put": "update",
"patch": "partial_update",
"delete": "destroy",
}
),
name="project-issue-roadmap",
),
## IssueProperty Ebd
## Issue Archives ## Issue Archives
path( path(
"workspaces/<str:slug>/projects/<uuid:project_id>/archived-issues/", "workspaces/<str:slug>/projects/<uuid:project_id>/archived-issues/",

View File

@ -82,7 +82,7 @@ from plane.api.views import (
BulkDeleteIssuesEndpoint, BulkDeleteIssuesEndpoint,
BulkImportIssuesEndpoint, BulkImportIssuesEndpoint,
ProjectUserViewsEndpoint, ProjectUserViewsEndpoint,
IssuePropertyViewSet, IssueUserDisplayPropertyEndpoint,
LabelViewSet, LabelViewSet,
SubIssuesEndpoint, SubIssuesEndpoint,
IssueLinkViewSet, IssueLinkViewSet,
@ -1008,26 +1008,9 @@ urlpatterns = [
## End Comment Reactions ## End Comment Reactions
## IssueProperty ## IssueProperty
path( path(
"workspaces/<str:slug>/projects/<uuid:project_id>/issue-properties/", "workspaces/<str:slug>/projects/<uuid:project_id>/issue-display-properties/",
IssuePropertyViewSet.as_view( IssueUserDisplayPropertyEndpoint.as_view(),
{ name="project-issue-display-properties",
"get": "list",
"post": "create",
}
),
name="project-issue-roadmap",
),
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/issue-properties/<uuid:pk>/",
IssuePropertyViewSet.as_view(
{
"get": "retrieve",
"put": "update",
"patch": "partial_update",
"delete": "destroy",
}
),
name="project-issue-roadmap",
), ),
## IssueProperty Ebd ## IssueProperty Ebd
## Issue Archives ## Issue Archives

View File

@ -71,7 +71,7 @@ from .issue import (
WorkSpaceIssuesEndpoint, WorkSpaceIssuesEndpoint,
IssueActivityEndpoint, IssueActivityEndpoint,
IssueCommentViewSet, IssueCommentViewSet,
IssuePropertyViewSet, IssueUserDisplayPropertyEndpoint,
LabelViewSet, LabelViewSet,
BulkDeleteIssuesEndpoint, BulkDeleteIssuesEndpoint,
UserWorkSpaceIssues, UserWorkSpaceIssues,

View File

@ -84,6 +84,7 @@ class BaseViewSet(TimezoneMixin, ModelViewSet, BasePaginator):
capture_exception(e) capture_exception(e)
return Response({"error": f"key {e} does not exist"}, status=status.HTTP_400_BAD_REQUEST) return Response({"error": f"key {e} does not exist"}, status=status.HTTP_400_BAD_REQUEST)
print(e) if settings.DEBUG else print("Server Error")
capture_exception(e) capture_exception(e)
return Response({"error": "Something went wrong please try again later"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response({"error": "Something went wrong please try again later"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
@ -161,6 +162,7 @@ class BaseAPIView(TimezoneMixin, APIView, BasePaginator):
if isinstance(e, KeyError): if isinstance(e, KeyError):
return Response({"error": f"key {e} does not exist"}, status=status.HTTP_400_BAD_REQUEST) return Response({"error": f"key {e} does not exist"}, status=status.HTTP_400_BAD_REQUEST)
print(e) if settings.DEBUG else print("Server Error")
capture_exception(e) capture_exception(e)
return Response({"error": "Something went wrong please try again later"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response({"error": "Something went wrong please try again later"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)

View File

@ -579,6 +579,7 @@ class CycleIssueViewSet(BaseViewSet):
) )
) )
total_issues = issues.count()
issues_data = IssueStateSerializer(issues, many=True).data issues_data = IssueStateSerializer(issues, many=True).data
if sub_group_by and sub_group_by == group_by: if sub_group_by and sub_group_by == group_by:
@ -588,14 +589,14 @@ class CycleIssueViewSet(BaseViewSet):
) )
if group_by: if group_by:
grouped_results = group_results(issues_data, group_by, sub_group_by)
return Response( return Response(
group_results(issues_data, group_by, sub_group_by), {"data": grouped_results, "total_issues": total_issues},
status=status.HTTP_200_OK, status=status.HTTP_200_OK,
) )
return Response( return Response(
issues_data, {"data": issues_data, "total_issues": total_issues}, status=status.HTTP_200_OK
status=status.HTTP_200_OK,
) )
def create(self, request, slug, project_id, cycle_id): def create(self, request, slug, project_id, cycle_id):

View File

@ -130,7 +130,7 @@ class IssueViewSet(BaseViewSet):
queryset=IssueReaction.objects.select_related("actor"), queryset=IssueReaction.objects.select_related("actor"),
) )
) )
) ).distinct()
@method_decorator(gzip_page) @method_decorator(gzip_page)
def list(self, request, slug, project_id): def list(self, request, slug, project_id):
@ -217,6 +217,7 @@ class IssueViewSet(BaseViewSet):
else: else:
issue_queryset = issue_queryset.order_by(order_by_param) issue_queryset = issue_queryset.order_by(order_by_param)
total_issues = issue_queryset.count()
issues = IssueLiteSerializer(issue_queryset, many=True).data issues = IssueLiteSerializer(issue_queryset, many=True).data
## Grouping the results ## Grouping the results
@ -229,12 +230,16 @@ class IssueViewSet(BaseViewSet):
) )
if group_by: if group_by:
grouped_results = group_results(issues, group_by, sub_group_by)
return Response( return Response(
group_results(issues, group_by, sub_group_by), {"data": grouped_results, "total_issues": total_issues},
status=status.HTTP_200_OK, status=status.HTTP_200_OK,
) )
return Response(issues, status=status.HTTP_200_OK) return Response(
{"data": issues, "total_issues": total_issues}, status=status.HTTP_200_OK
)
def create(self, request, slug, project_id): def create(self, request, slug, project_id):
project = Project.objects.get(pk=project_id) project = Project.objects.get(pk=project_id)
@ -421,6 +426,7 @@ class UserWorkSpaceIssues(BaseAPIView):
else: else:
issue_queryset = issue_queryset.order_by(order_by_param) issue_queryset = issue_queryset.order_by(order_by_param)
total_issues = issue_queryset.count()
issues = IssueLiteSerializer(issue_queryset, many=True).data issues = IssueLiteSerializer(issue_queryset, many=True).data
## Grouping the results ## Grouping the results
@ -433,12 +439,15 @@ class UserWorkSpaceIssues(BaseAPIView):
) )
if group_by: if group_by:
grouped_results = group_results(issues, group_by, sub_group_by)
return Response( return Response(
group_results(issues, group_by, sub_group_by), {"data": grouped_results, "total_issues": total_issues},
status=status.HTTP_200_OK, status=status.HTTP_200_OK,
) )
return Response(issues, status=status.HTTP_200_OK) return Response(
{"data": issues, "total_issues": total_issues}, status=status.HTTP_200_OK
)
class WorkSpaceIssuesEndpoint(BaseAPIView): class WorkSpaceIssuesEndpoint(BaseAPIView):
@ -597,41 +606,12 @@ class IssueCommentViewSet(BaseViewSet):
return Response(status=status.HTTP_204_NO_CONTENT) return Response(status=status.HTTP_204_NO_CONTENT)
class IssuePropertyViewSet(BaseViewSet): class IssueUserDisplayPropertyEndpoint(BaseAPIView):
serializer_class = IssuePropertySerializer
model = IssueProperty
permission_classes = [ permission_classes = [
ProjectEntityPermission, ProjectLitePermission,
] ]
filterset_fields = [] def post(self, request, slug, project_id):
def perform_create(self, serializer):
serializer.save(
project_id=self.kwargs.get("project_id"), user=self.request.user
)
def get_queryset(self):
return self.filter_queryset(
super()
.get_queryset()
.filter(workspace__slug=self.kwargs.get("slug"))
.filter(project_id=self.kwargs.get("project_id"))
.filter(user=self.request.user)
.filter(project__project_projectmember__member=self.request.user)
.select_related("project")
.select_related("workspace")
)
def list(self, request, slug, project_id):
queryset = self.get_queryset()
serializer = IssuePropertySerializer(queryset, many=True)
return Response(
serializer.data[0] if len(serializer.data) > 0 else [],
status=status.HTTP_200_OK,
)
def create(self, request, slug, project_id):
issue_property, created = IssueProperty.objects.get_or_create( issue_property, created = IssueProperty.objects.get_or_create(
user=request.user, user=request.user,
project_id=project_id, project_id=project_id,
@ -640,16 +620,20 @@ class IssuePropertyViewSet(BaseViewSet):
if not created: if not created:
issue_property.properties = request.data.get("properties", {}) issue_property.properties = request.data.get("properties", {})
issue_property.save() issue_property.save()
serializer = IssuePropertySerializer(issue_property)
return Response(serializer.data, status=status.HTTP_200_OK)
issue_property.properties = request.data.get("properties", {}) issue_property.properties = request.data.get("properties", {})
issue_property.save() issue_property.save()
serializer = IssuePropertySerializer(issue_property) serializer = IssuePropertySerializer(issue_property)
return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.data, status=status.HTTP_201_CREATED)
def get(self, request, slug, project_id):
issue_property, _ = IssueProperty.objects.get_or_create(
user=request.user, project_id=project_id
)
serializer = IssuePropertySerializer(issue_property)
return Response(serializer.data, status=status.HTTP_200_OK)
class LabelViewSet(BaseViewSet): class LabelViewSet(BaseViewSet):
serializer_class = LabelSerializer serializer_class = LabelSerializer
model = Label model = Label
@ -963,8 +947,8 @@ class IssueAttachmentEndpoint(BaseAPIView):
issue_attachments = IssueAttachment.objects.filter( issue_attachments = IssueAttachment.objects.filter(
issue_id=issue_id, workspace__slug=slug, project_id=project_id issue_id=issue_id, workspace__slug=slug, project_id=project_id
) )
serilaizer = IssueAttachmentSerializer(issue_attachments, many=True) serializer = IssueAttachmentSerializer(issue_attachments, many=True)
return Response(serilaizer.data, status=status.HTTP_200_OK) return Response(serializer.data, status=status.HTTP_200_OK)
class IssueArchiveViewSet(BaseViewSet): class IssueArchiveViewSet(BaseViewSet):
@ -1165,9 +1149,7 @@ class IssueSubscriberViewSet(BaseViewSet):
def list(self, request, slug, project_id, issue_id): def list(self, request, slug, project_id, issue_id):
members = ( members = (
ProjectMember.objects.filter( ProjectMember.objects.filter(workspace__slug=slug, project_id=project_id)
workspace__slug=slug, project_id=project_id
)
.annotate( .annotate(
is_subscribed=Exists( is_subscribed=Exists(
IssueSubscriber.objects.filter( IssueSubscriber.objects.filter(
@ -2169,14 +2151,21 @@ class IssueDraftViewSet(BaseViewSet):
else: else:
issue_queryset = issue_queryset.order_by(order_by_param) issue_queryset = issue_queryset.order_by(order_by_param)
total_issues = issue_queryset.count()
issues = IssueLiteSerializer(issue_queryset, many=True).data issues = IssueLiteSerializer(issue_queryset, many=True).data
## Grouping the results ## Grouping the results
group_by = request.GET.get("group_by", False) group_by = request.GET.get("group_by", False)
if group_by: if group_by:
return Response(group_results(issues, group_by), status=status.HTTP_200_OK) grouped_results = group_results(issues, group_by)
return Response(
{"data": grouped_results, "total_issues": total_issues},
status=status.HTTP_200_OK,
)
return Response(issues, status=status.HTTP_200_OK) return Response(
{"data": issues, "total_issues": total_issues}, status=status.HTTP_200_OK
)
def create(self, request, slug, project_id): def create(self, request, slug, project_id):
project = Project.objects.get(pk=project_id) project = Project.objects.get(pk=project_id)

View File

@ -149,6 +149,9 @@ class ModuleViewSet(BaseViewSet):
if serializer.is_valid(): if serializer.is_valid():
serializer.save() serializer.save()
module = Module.objects.get(pk=serializer.data["id"])
serializer = ModuleSerializer(module)
return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@ -361,7 +364,7 @@ class ModuleIssueViewSet(BaseViewSet):
.values("count") .values("count")
) )
) )
total_issues = issues.count()
issues_data = IssueStateSerializer(issues, many=True).data issues_data = IssueStateSerializer(issues, many=True).data
if sub_group_by and sub_group_by == group_by: if sub_group_by and sub_group_by == group_by:
@ -371,14 +374,14 @@ class ModuleIssueViewSet(BaseViewSet):
) )
if group_by: if group_by:
grouped_results = group_results(issues_data, group_by, sub_group_by)
return Response( return Response(
group_results(issues_data, group_by, sub_group_by), {"data": grouped_results, "total_issues": total_issues},
status=status.HTTP_200_OK, status=status.HTTP_200_OK,
) )
return Response( return Response(
issues_data, {"data": issues_data, "total_issues": total_issues}, status=status.HTTP_200_OK
status=status.HTTP_200_OK,
) )
def create(self, request, slug, project_id, module_id): def create(self, request, slug, project_id, module_id):

View File

@ -69,6 +69,7 @@ from plane.db.models import (
ModuleMember, ModuleMember,
Inbox, Inbox,
ProjectDeployBoard, ProjectDeployBoard,
IssueProperty,
) )
from plane.bgtasks.project_invitation_task import project_invitation from plane.bgtasks.project_invitation_task import project_invitation
@ -201,6 +202,11 @@ class ProjectViewSet(BaseViewSet):
project_member = ProjectMember.objects.create( project_member = ProjectMember.objects.create(
project_id=serializer.data["id"], member=request.user, role=20 project_id=serializer.data["id"], member=request.user, role=20
) )
# Also create the issue property for the user
_ = IssueProperty.objects.create(
project_id=serializer.data["id"],
user=request.user,
)
if serializer.data["project_lead"] is not None and str( if serializer.data["project_lead"] is not None and str(
serializer.data["project_lead"] serializer.data["project_lead"]
@ -210,6 +216,11 @@ class ProjectViewSet(BaseViewSet):
member_id=serializer.data["project_lead"], member_id=serializer.data["project_lead"],
role=20, role=20,
) )
# Also create the issue property for the user
IssueProperty.objects.create(
project_id=serializer.data["id"],
user_id=serializer.data["project_lead"],
)
# Default states # Default states
states = [ states = [
@ -262,12 +273,9 @@ class ProjectViewSet(BaseViewSet):
] ]
) )
data = serializer.data project = self.get_queryset().filter(pk=serializer.data["id"]).first()
# Additional fields of the member serializer = ProjectListSerializer(project)
data["sort_order"] = project_member.sort_order return Response(serializer.data, status=status.HTTP_201_CREATED)
data["member_role"] = project_member.role
data["is_member"] = True
return Response(data, status=status.HTTP_201_CREATED)
return Response( return Response(
serializer.errors, serializer.errors,
status=status.HTTP_400_BAD_REQUEST, status=status.HTTP_400_BAD_REQUEST,
@ -317,6 +325,8 @@ class ProjectViewSet(BaseViewSet):
color="#ff7700", color="#ff7700",
) )
project = self.get_queryset().filter(pk=serializer.data["id"]).first()
serializer = ProjectListSerializer(project)
return Response(serializer.data, status=status.HTTP_200_OK) return Response(serializer.data, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@ -393,6 +403,8 @@ class InviteProjectEndpoint(BaseAPIView):
member=user, project_id=project_id, role=role member=user, project_id=project_id, role=role
) )
_ = IssueProperty.objects.create(user=user, project_id=project_id)
return Response( return Response(
ProjectMemberSerializer(project_member).data, status=status.HTTP_200_OK ProjectMemberSerializer(project_member).data, status=status.HTTP_200_OK
) )
@ -428,6 +440,18 @@ class UserProjectInvitationsViewset(BaseViewSet):
] ]
) )
IssueProperty.objects.bulk_create(
[
ProjectMember(
project=invitation.project,
workspace=invitation.project.workspace,
user=request.user,
created_by=request.user,
)
for invitation in project_invitations
]
)
# Delete joined project invites # Delete joined project invites
project_invitations.delete() project_invitations.delete()
@ -560,6 +584,7 @@ class AddMemberToProjectEndpoint(BaseAPIView):
status=status.HTTP_400_BAD_REQUEST, status=status.HTTP_400_BAD_REQUEST,
) )
bulk_project_members = [] bulk_project_members = []
bulk_issue_props = []
project_members = ( project_members = (
ProjectMember.objects.filter( ProjectMember.objects.filter(
@ -574,7 +599,8 @@ class AddMemberToProjectEndpoint(BaseAPIView):
sort_order = [ sort_order = [
project_member.get("sort_order") project_member.get("sort_order")
for project_member in project_members for project_member in project_members
if str(project_member.get("member_id")) == str(member.get("member_id")) if str(project_member.get("member_id"))
== str(member.get("member_id"))
] ]
bulk_project_members.append( bulk_project_members.append(
ProjectMember( ProjectMember(
@ -585,6 +611,13 @@ class AddMemberToProjectEndpoint(BaseAPIView):
sort_order=sort_order[0] - 10000 if len(sort_order) else 65535, sort_order=sort_order[0] - 10000 if len(sort_order) else 65535,
) )
) )
bulk_issue_props.append(
IssueProperty(
user_id=member.get("member_id"),
project_id=project_id,
workspace_id=project.workspace_id,
)
)
project_members = ProjectMember.objects.bulk_create( project_members = ProjectMember.objects.bulk_create(
bulk_project_members, bulk_project_members,
@ -592,7 +625,12 @@ class AddMemberToProjectEndpoint(BaseAPIView):
ignore_conflicts=True, ignore_conflicts=True,
) )
_ = IssueProperty.objects.bulk_create(
bulk_issue_props, batch_size=10, ignore_conflicts=True
)
serializer = ProjectMemberSerializer(project_members, many=True) serializer = ProjectMemberSerializer(project_members, many=True)
return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.data, status=status.HTTP_201_CREATED)
@ -614,6 +652,7 @@ class AddTeamToProjectEndpoint(BaseAPIView):
workspace = Workspace.objects.get(slug=slug) workspace = Workspace.objects.get(slug=slug)
project_members = [] project_members = []
issue_props = []
for member in team_members: for member in team_members:
project_members.append( project_members.append(
ProjectMember( ProjectMember(
@ -623,11 +662,23 @@ class AddTeamToProjectEndpoint(BaseAPIView):
created_by=request.user, created_by=request.user,
) )
) )
issue_props.append(
IssueProperty(
project_id=project_id,
user_id=member,
workspace=workspace,
created_by=request.user,
)
)
ProjectMember.objects.bulk_create( ProjectMember.objects.bulk_create(
project_members, batch_size=10, ignore_conflicts=True project_members, batch_size=10, ignore_conflicts=True
) )
_ = IssueProperty.objects.bulk_create(
issue_props, batch_size=10, ignore_conflicts=True
)
serializer = ProjectMemberSerializer(project_members, many=True) serializer = ProjectMemberSerializer(project_members, many=True)
return Response(serializer.data, status=status.HTTP_201_CREATED) return Response(serializer.data, status=status.HTTP_201_CREATED)
@ -743,6 +794,19 @@ class ProjectJoinEndpoint(BaseAPIView):
ignore_conflicts=True, ignore_conflicts=True,
) )
IssueProperty.objects.bulk_create(
[
IssueProperty(
project_id=project_id,
user=request.user,
workspace=workspace,
created_by=request.user,
)
for project_id in project_ids
],
ignore_conflicts=True,
)
return Response( return Response(
{"message": "Projects joined successfully"}, {"message": "Projects joined successfully"},
status=status.HTTP_201_CREATED, status=status.HTTP_201_CREATED,

View File

@ -184,6 +184,7 @@ class GlobalViewIssuesViewSet(BaseViewSet):
else: else:
issue_queryset = issue_queryset.order_by(order_by_param) issue_queryset = issue_queryset.order_by(order_by_param)
total_issues = issue_queryset.count()
issues = IssueLiteSerializer(issue_queryset, many=True).data issues = IssueLiteSerializer(issue_queryset, many=True).data
## Grouping the results ## Grouping the results
@ -196,11 +197,15 @@ class GlobalViewIssuesViewSet(BaseViewSet):
) )
if group_by: if group_by:
grouped_results = group_results(issues, group_by, sub_group_by)
return Response( return Response(
group_results(issues, group_by, sub_group_by), status=status.HTTP_200_OK {"data": grouped_results, "total_issues": total_issues},
status=status.HTTP_200_OK,
) )
return Response(issues, status=status.HTTP_200_OK) return Response(
{"data": issues, "total_issues": total_issues}, status=status.HTTP_200_OK
)
class IssueViewViewSet(BaseViewSet): class IssueViewViewSet(BaseViewSet):

View File

@ -1223,14 +1223,21 @@ class WorkspaceUserProfileIssuesEndpoint(BaseAPIView):
else: else:
issue_queryset = issue_queryset.order_by(order_by_param) issue_queryset = issue_queryset.order_by(order_by_param)
total_issues = issue_queryset.count()
issues = IssueLiteSerializer(issue_queryset, many=True).data issues = IssueLiteSerializer(issue_queryset, many=True).data
## Grouping the results ## Grouping the results
group_by = request.GET.get("group_by", False) group_by = request.GET.get("group_by", False)
if group_by: if group_by:
return Response(group_results(issues, group_by), status=status.HTTP_200_OK) grouped_results = group_results(issues, group_by)
return Response(
{"data": grouped_results, "total_issues": total_issues},
status=status.HTTP_200_OK,
)
return Response(issues, status=status.HTTP_200_OK) return Response(
{"data": issues, "total_issues": total_issues}, status=status.HTTP_200_OK
)
class WorkspaceLabelsEndpoint(BaseAPIView): class WorkspaceLabelsEndpoint(BaseAPIView):

View File

@ -25,6 +25,7 @@ from plane.db.models import (
WorkspaceIntegration, WorkspaceIntegration,
Label, Label,
User, User,
IssueProperty,
) )
from .workspace_invitation_task import workspace_invitation from .workspace_invitation_task import workspace_invitation
from plane.bgtasks.user_welcome_task import send_welcome_slack from plane.bgtasks.user_welcome_task import send_welcome_slack
@ -103,6 +104,20 @@ def service_importer(service, importer_id):
ignore_conflicts=True, ignore_conflicts=True,
) )
IssueProperty.objects.bulk_create(
[
IssueProperty(
project_id=importer.project_id,
workspace_id=importer.workspace_id,
user=user,
created_by=importer.created_by,
)
for user in workspace_users
],
batch_size=100,
ignore_conflicts=True,
)
# Check if sync config is on for github importers # Check if sync config is on for github importers
if service == "github" and importer.config.get("sync", False): if service == "github" and importer.config.get("sync", False):
name = importer.metadata.get("name", False) name = importer.metadata.get("name", False)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,102 @@
# Python imports
import json
# Django imports
from django.utils import timezone
# Module imports
from plane.db.models import IssueSubscriber, Project, IssueAssignee, Issue, Notification
# Third Party imports
from celery import shared_task
@shared_task
def notifications(type, issue_id, project_id, actor_id, subscriber, issue_activities_created):
issue_activities_created = (
json.loads(issue_activities_created) if issue_activities_created is not None else None
)
if type not in [
"cycle.activity.created",
"cycle.activity.deleted",
"module.activity.created",
"module.activity.deleted",
"issue_reaction.activity.created",
"issue_reaction.activity.deleted",
"comment_reaction.activity.created",
"comment_reaction.activity.deleted",
"issue_vote.activity.created",
"issue_vote.activity.deleted",
"issue_draft.activity.created",
"issue_draft.activity.updated",
"issue_draft.activity.deleted",
]:
# Create Notifications
bulk_notifications = []
issue_subscribers = list(
IssueSubscriber.objects.filter(project_id=project_id, issue_id=issue_id)
.exclude(subscriber_id=actor_id)
.values_list("subscriber", flat=True)
)
issue_assignees = list(
IssueAssignee.objects.filter(project_id=project_id, issue_id=issue_id)
.exclude(assignee_id=actor_id)
.values_list("assignee", flat=True)
)
issue_subscribers = issue_subscribers + issue_assignees
issue = Issue.objects.filter(pk=issue_id).first()
if subscriber:
# add the user to issue subscriber
try:
_ = IssueSubscriber.objects.get_or_create(
issue_id=issue_id, subscriber_id=actor_id
)
except Exception as e:
pass
project = Project.objects.get(pk=project_id)
for subscriber in list(set(issue_subscribers)):
for issue_activity in issue_activities_created:
bulk_notifications.append(
Notification(
workspace=project.workspace,
sender="in_app:issue_activities",
triggered_by_id=actor_id,
receiver_id=subscriber,
entity_identifier=issue_id,
entity_name="issue",
project=project,
title=issue_activity.get("comment"),
data={
"issue": {
"id": str(issue_id),
"name": str(issue.name),
"identifier": str(issue.project.identifier),
"sequence_id": issue.sequence_id,
"state_name": issue.state.name,
"state_group": issue.state.group,
},
"issue_activity": {
"id": str(issue_activity.get("id")),
"verb": str(issue_activity.get("verb")),
"field": str(issue_activity.get("field")),
"actor": str(issue_activity.get("actor_id")),
"new_value": str(issue_activity.get("new_value")),
"old_value": str(issue_activity.get("old_value")),
"issue_comment": str(
issue_activity.get("issue_comment").comment_stripped
if issue_activity.get("issue_comment") is not None
else ""
),
},
},
)
)
# Bulk create notifications
Notification.objects.bulk_create(bulk_notifications, batch_size=100)

View File

@ -0,0 +1,21 @@
# Generated by Django 4.2.5 on 2023-10-18 12:04
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import plane.db.models.issue
class Migration(migrations.Migration):
dependencies = [
('db', '0045_issueactivity_epoch_workspacemember_issue_props_and_more'),
]
operations = [
migrations.AlterField(
model_name='issueproperty',
name='properties',
field=models.JSONField(default=plane.db.models.issue.get_default_properties),
),
]

View File

@ -16,6 +16,24 @@ from . import ProjectBaseModel
from plane.utils.html_processor import strip_tags from plane.utils.html_processor import strip_tags
def get_default_properties():
return {
"assignee": True,
"start_date": True,
"due_date": True,
"labels": True,
"key": True,
"priority": True,
"state": True,
"sub_issue_count": True,
"link": True,
"attachment_count": True,
"estimate": True,
"created_on": True,
"updated_on": True,
}
# TODO: Handle identifiers for Bulk Inserts - nk # TODO: Handle identifiers for Bulk Inserts - nk
class IssueManager(models.Manager): class IssueManager(models.Manager):
def get_queryset(self): def get_queryset(self):
@ -39,7 +57,7 @@ class Issue(ProjectBaseModel):
("high", "High"), ("high", "High"),
("medium", "Medium"), ("medium", "Medium"),
("low", "Low"), ("low", "Low"),
("none", "None") ("none", "None"),
) )
parent = models.ForeignKey( parent = models.ForeignKey(
"self", "self",
@ -186,7 +204,7 @@ class IssueRelation(ProjectBaseModel):
("relates_to", "Relates To"), ("relates_to", "Relates To"),
("blocked_by", "Blocked By"), ("blocked_by", "Blocked By"),
) )
issue = models.ForeignKey( issue = models.ForeignKey(
Issue, related_name="issue_relation", on_delete=models.CASCADE Issue, related_name="issue_relation", on_delete=models.CASCADE
) )
@ -208,7 +226,7 @@ class IssueRelation(ProjectBaseModel):
ordering = ("-created_at",) ordering = ("-created_at",)
def __str__(self): def __str__(self):
return f"{self.issue.name} {self.related_issue.name}" return f"{self.issue.name} {self.related_issue.name}"
class IssueAssignee(ProjectBaseModel): class IssueAssignee(ProjectBaseModel):
@ -327,7 +345,9 @@ class IssueComment(ProjectBaseModel):
comment_json = models.JSONField(blank=True, default=dict) comment_json = models.JSONField(blank=True, default=dict)
comment_html = models.TextField(blank=True, default="<p></p>") comment_html = models.TextField(blank=True, default="<p></p>")
attachments = ArrayField(models.URLField(), size=10, blank=True, default=list) attachments = ArrayField(models.URLField(), size=10, blank=True, default=list)
issue = models.ForeignKey(Issue, on_delete=models.CASCADE, related_name="issue_comments") issue = models.ForeignKey(
Issue, on_delete=models.CASCADE, related_name="issue_comments"
)
# System can also create comment # System can also create comment
actor = models.ForeignKey( actor = models.ForeignKey(
settings.AUTH_USER_MODEL, settings.AUTH_USER_MODEL,
@ -367,7 +387,7 @@ class IssueProperty(ProjectBaseModel):
on_delete=models.CASCADE, on_delete=models.CASCADE,
related_name="issue_property_user", related_name="issue_property_user",
) )
properties = models.JSONField(default=dict) properties = models.JSONField(default=get_default_properties)
class Meta: class Meta:
verbose_name = "Issue Property" verbose_name = "Issue Property"
@ -515,7 +535,10 @@ class IssueVote(ProjectBaseModel):
) )
class Meta: class Meta:
unique_together = ["issue", "actor",] unique_together = [
"issue",
"actor",
]
verbose_name = "Issue Vote" verbose_name = "Issue Vote"
verbose_name_plural = "Issue Votes" verbose_name_plural = "Issue Votes"
db_table = "issue_votes" db_table = "issue_votes"

View File

@ -14,19 +14,21 @@ from .common import * # noqa
# Database # Database
DEBUG = int(os.environ.get("DEBUG", 0)) == 1 DEBUG = int(os.environ.get("DEBUG", 0)) == 1
DATABASES = { if bool(os.environ.get("DATABASE_URL")):
"default": { # Parse database configuration from $DATABASE_URL
"ENGINE": "django.db.backends.postgresql", DATABASES["default"] = dj_database_url.config()
"NAME": "plane", else:
"USER": os.environ.get("PGUSER", ""), DATABASES = {
"PASSWORD": os.environ.get("PGPASSWORD", ""), "default": {
"HOST": os.environ.get("PGHOST", ""), "ENGINE": "django.db.backends.postgresql",
"NAME": os.environ.get("POSTGRES_DB"),
"USER": os.environ.get("POSTGRES_USER"),
"PASSWORD": os.environ.get("POSTGRES_PASSWORD"),
"HOST": os.environ.get("POSTGRES_HOST"),
}
} }
}
# Parse database configuration from $DATABASE_URL
DATABASES["default"] = dj_database_url.config()
SITE_ID = 1 SITE_ID = 1
# Set the variable true if running in docker environment # Set the variable true if running in docker environment
@ -278,4 +280,3 @@ SCOUT_NAME = "Plane"
# Unsplash Access key # Unsplash Access key
UNSPLASH_ACCESS_KEY = os.environ.get("UNSPLASH_ACCESS_KEY") UNSPLASH_ACCESS_KEY = os.environ.get("UNSPLASH_ACCESS_KEY")

View File

@ -1,10 +1,24 @@
import re import re
import uuid
from datetime import timedelta from datetime import timedelta
from django.utils import timezone from django.utils import timezone
# The date from pattern # The date from pattern
pattern = re.compile(r"\d+_(weeks|months)$") pattern = re.compile(r"\d+_(weeks|months)$")
# check the valid uuids
def filter_valid_uuids(uuid_list):
valid_uuids = []
for uuid_str in uuid_list:
try:
uuid_obj = uuid.UUID(uuid_str)
valid_uuids.append(uuid_obj)
except ValueError:
# ignore the invalid uuids
pass
return valid_uuids
# Get the 2_weeks, 3_months # Get the 2_weeks, 3_months
def string_date_filter(filter, duration, subsequent, term, date_filter, offset): def string_date_filter(filter, duration, subsequent, term, date_filter, offset):
@ -61,40 +75,41 @@ def date_filter(filter, date_term, queries):
def filter_state(params, filter, method): def filter_state(params, filter, method):
if method == "GET": if method == "GET":
states = params.get("state").split(",") states = [item for item in params.get("state").split(",") if item != 'null']
states = filter_valid_uuids(states)
if len(states) and "" not in states: if len(states) and "" not in states:
filter["state__in"] = states filter["state__in"] = states
else: else:
if params.get("state", None) and len(params.get("state")): if params.get("state", None) and len(params.get("state")) and params.get("state") != 'null':
filter["state__in"] = params.get("state") filter["state__in"] = params.get("state")
return filter return filter
def filter_state_group(params, filter, method): def filter_state_group(params, filter, method):
if method == "GET": if method == "GET":
state_group = params.get("state_group").split(",") state_group = [item for item in params.get("state_group").split(",") if item != 'null']
if len(state_group) and "" not in state_group: if len(state_group) and "" not in state_group:
filter["state__group__in"] = state_group filter["state__group__in"] = state_group
else: else:
if params.get("state_group", None) and len(params.get("state_group")): if params.get("state_group", None) and len(params.get("state_group")) and params.get("state_group") != 'null':
filter["state__group__in"] = params.get("state_group") filter["state__group__in"] = params.get("state_group")
return filter return filter
def filter_estimate_point(params, filter, method): def filter_estimate_point(params, filter, method):
if method == "GET": if method == "GET":
estimate_points = params.get("estimate_point").split(",") estimate_points = [item for item in params.get("estimate_point").split(",") if item != 'null']
if len(estimate_points) and "" not in estimate_points: if len(estimate_points) and "" not in estimate_points:
filter["estimate_point__in"] = estimate_points filter["estimate_point__in"] = estimate_points
else: else:
if params.get("estimate_point", None) and len(params.get("estimate_point")): if params.get("estimate_point", None) and len(params.get("estimate_point")) and params.get("estimate_point") != 'null':
filter["estimate_point__in"] = params.get("estimate_point") filter["estimate_point__in"] = params.get("estimate_point")
return filter return filter
def filter_priority(params, filter, method): def filter_priority(params, filter, method):
if method == "GET": if method == "GET":
priorities = params.get("priority").split(",") priorities = [item for item in params.get("priority").split(",") if item != 'null']
if len(priorities) and "" not in priorities: if len(priorities) and "" not in priorities:
filter["priority__in"] = priorities filter["priority__in"] = priorities
return filter return filter
@ -102,44 +117,48 @@ def filter_priority(params, filter, method):
def filter_parent(params, filter, method): def filter_parent(params, filter, method):
if method == "GET": if method == "GET":
parents = params.get("parent").split(",") parents = [item for item in params.get("parent").split(",") if item != 'null']
parents = filter_valid_uuids(parents)
if len(parents) and "" not in parents: if len(parents) and "" not in parents:
filter["parent__in"] = parents filter["parent__in"] = parents
else: else:
if params.get("parent", None) and len(params.get("parent")): if params.get("parent", None) and len(params.get("parent")) and params.get("parent") != 'null':
filter["parent__in"] = params.get("parent") filter["parent__in"] = params.get("parent")
return filter return filter
def filter_labels(params, filter, method): def filter_labels(params, filter, method):
if method == "GET": if method == "GET":
labels = params.get("labels").split(",") labels = [item for item in params.get("labels").split(",") if item != 'null']
labels = filter_valid_uuids(labels)
if len(labels) and "" not in labels: if len(labels) and "" not in labels:
filter["labels__in"] = labels filter["labels__in"] = labels
else: else:
if params.get("labels", None) and len(params.get("labels")): if params.get("labels", None) and len(params.get("labels")) and params.get("labels") != 'null':
filter["labels__in"] = params.get("labels") filter["labels__in"] = params.get("labels")
return filter return filter
def filter_assignees(params, filter, method): def filter_assignees(params, filter, method):
if method == "GET": if method == "GET":
assignees = params.get("assignees").split(",") assignees = [item for item in params.get("assignees").split(",") if item != 'null']
assignees = filter_valid_uuids(assignees)
if len(assignees) and "" not in assignees: if len(assignees) and "" not in assignees:
filter["assignees__in"] = assignees filter["assignees__in"] = assignees
else: else:
if params.get("assignees", None) and len(params.get("assignees")): if params.get("assignees", None) and len(params.get("assignees")) and params.get("assignees") != 'null':
filter["assignees__in"] = params.get("assignees") filter["assignees__in"] = params.get("assignees")
return filter return filter
def filter_created_by(params, filter, method): def filter_created_by(params, filter, method):
if method == "GET": if method == "GET":
created_bys = params.get("created_by").split(",") created_bys = [item for item in params.get("created_by").split(",") if item != 'null']
created_bys = filter_valid_uuids(created_bys)
if len(created_bys) and "" not in created_bys: if len(created_bys) and "" not in created_bys:
filter["created_by__in"] = created_bys filter["created_by__in"] = created_bys
else: else:
if params.get("created_by", None) and len(params.get("created_by")): if params.get("created_by", None) and len(params.get("created_by")) and params.get("created_by") != 'null':
filter["created_by__in"] = params.get("created_by") filter["created_by__in"] = params.get("created_by")
return filter return filter
@ -219,44 +238,47 @@ def filter_issue_state_type(params, filter, method):
def filter_project(params, filter, method): def filter_project(params, filter, method):
if method == "GET": if method == "GET":
projects = params.get("project").split(",") projects = [item for item in params.get("project").split(",") if item != 'null']
projects = filter_valid_uuids(projects)
if len(projects) and "" not in projects: if len(projects) and "" not in projects:
filter["project__in"] = projects filter["project__in"] = projects
else: else:
if params.get("project", None) and len(params.get("project")): if params.get("project", None) and len(params.get("project")) and params.get("project") != 'null':
filter["project__in"] = params.get("project") filter["project__in"] = params.get("project")
return filter return filter
def filter_cycle(params, filter, method): def filter_cycle(params, filter, method):
if method == "GET": if method == "GET":
cycles = params.get("cycle").split(",") cycles = [item for item in params.get("cycle").split(",") if item != 'null']
cycles = filter_valid_uuids(cycles)
if len(cycles) and "" not in cycles: if len(cycles) and "" not in cycles:
filter["issue_cycle__cycle_id__in"] = cycles filter["issue_cycle__cycle_id__in"] = cycles
else: else:
if params.get("cycle", None) and len(params.get("cycle")): if params.get("cycle", None) and len(params.get("cycle")) and params.get("cycle") != 'null':
filter["issue_cycle__cycle_id__in"] = params.get("cycle") filter["issue_cycle__cycle_id__in"] = params.get("cycle")
return filter return filter
def filter_module(params, filter, method): def filter_module(params, filter, method):
if method == "GET": if method == "GET":
modules = params.get("module").split(",") modules = [item for item in params.get("module").split(",") if item != 'null']
modules = filter_valid_uuids(modules)
if len(modules) and "" not in modules: if len(modules) and "" not in modules:
filter["issue_module__module_id__in"] = modules filter["issue_module__module_id__in"] = modules
else: else:
if params.get("module", None) and len(params.get("module")): if params.get("module", None) and len(params.get("module")) and params.get("module") != 'null':
filter["issue_module__module_id__in"] = params.get("module") filter["issue_module__module_id__in"] = params.get("module")
return filter return filter
def filter_inbox_status(params, filter, method): def filter_inbox_status(params, filter, method):
if method == "GET": if method == "GET":
status = params.get("inbox_status").split(",") status = [item for item in params.get("inbox_status").split(",") if item != 'null']
if len(status) and "" not in status: if len(status) and "" not in status:
filter["issue_inbox__status__in"] = status filter["issue_inbox__status__in"] = status
else: else:
if params.get("inbox_status", None) and len(params.get("inbox_status")): if params.get("inbox_status", None) and len(params.get("inbox_status")) and params.get("inbox_status") != 'null':
filter["issue_inbox__status__in"] = params.get("inbox_status") filter["issue_inbox__status__in"] = params.get("inbox_status")
return filter return filter
@ -275,11 +297,12 @@ def filter_sub_issue_toggle(params, filter, method):
def filter_subscribed_issues(params, filter, method): def filter_subscribed_issues(params, filter, method):
if method == "GET": if method == "GET":
subscribers = params.get("subscriber").split(",") subscribers = [item for item in params.get("subscriber").split(",") if item != 'null']
subscribers = filter_valid_uuids(subscribers)
if len(subscribers) and "" not in subscribers: if len(subscribers) and "" not in subscribers:
filter["issue_subscribers__subscriber_id__in"] = subscribers filter["issue_subscribers__subscriber_id__in"] = subscribers
else: else:
if params.get("subscriber", None) and len(params.get("subscriber")): if params.get("subscriber", None) and len(params.get("subscriber")) and params.get("subscriber") != 'null':
filter["issue_subscribers__subscriber_id__in"] = params.get("subscriber") filter["issue_subscribers__subscriber_id__in"] = params.get("subscriber")
return filter return filter

View File

@ -27,6 +27,7 @@
"next-themes": "^0.2.1" "next-themes": "^0.2.1"
}, },
"dependencies": { "dependencies": {
"react-moveable" : "^0.54.2",
"@blueprintjs/popover2": "^2.0.10", "@blueprintjs/popover2": "^2.0.10",
"@tiptap/core": "^2.1.7", "@tiptap/core": "^2.1.7",
"@tiptap/extension-color": "^2.1.11", "@tiptap/extension-color": "^2.1.11",

View File

@ -213,7 +213,9 @@ module.exports = {
}, },
}, },
}), }),
screens: {
"3xl": "1792px",
},
// scale down font sizes to 90% of default // scale down font sizes to 90% of default
fontSize: { fontSize: {
xs: "0.675rem", xs: "0.675rem",

View File

@ -16,6 +16,7 @@
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist" "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
}, },
"devDependencies": { "devDependencies": {
"@types/react-color" : "^3.0.9",
"@types/node": "^20.5.2", "@types/node": "^20.5.2",
"@types/react": "18.2.0", "@types/react": "18.2.0",
"@types/react-dom": "18.2.0", "@types/react-dom": "18.2.0",

View File

@ -0,0 +1,102 @@
import React, { Children } from "react";
interface ICircularProgressIndicator {
size: number;
percentage: number;
strokeWidth?: number;
strokeColor?: string;
children?: React.ReactNode;
}
export const CircularProgressIndicator: React.FC<ICircularProgressIndicator> = (
props
) => {
const { size = 40, percentage = 25, strokeWidth = 6, children } = props;
const sqSize = size;
const radius = (size - strokeWidth) / 2;
const viewBox = `0 0 ${sqSize} ${sqSize}`;
const dashArray = radius * Math.PI * 2;
const dashOffset = dashArray - (dashArray * percentage) / 100;
return (
<div className="relative">
<svg width={size} height={size} viewBox={viewBox} fill="none">
<circle
className="fill-none stroke-custom-background-80"
cx={size / 2}
cy={size / 2}
r={radius}
strokeWidth={`${strokeWidth}px`}
style={{ filter: "url(#filter0_bi_377_19141)" }}
/>
<defs>
<filter
id="filter0_bi_377_19141"
x="-3.57544"
y="-3.57422"
width="45.2227"
height="45.2227"
filterUnits="userSpaceOnUse"
color-interpolation-filters="sRGB"
>
<feFlood flood-opacity="0" result="BackgroundImageFix" />
<feGaussianBlur in="BackgroundImageFix" stdDeviation="2" />
<feComposite
in2="SourceAlpha"
operator="in"
result="effect1_backgroundBlur_377_19141"
/>
<feBlend
mode="normal"
in="SourceGraphic"
in2="effect1_backgroundBlur_377_19141"
result="shape"
/>
<feColorMatrix
in="SourceAlpha"
type="matrix"
values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
result="hardAlpha"
/>
<feOffset dx="1" dy="1" />
<feGaussianBlur stdDeviation="2" />
<feComposite in2="hardAlpha" operator="arithmetic" k2="-1" k3="1" />
<feColorMatrix
type="matrix"
values="0 0 0 0 0.63125 0 0 0 0 0.6625 0 0 0 0 0.75 0 0 0 0.35 0"
/>
<feBlend
mode="normal"
in2="shape"
result="effect2_innerShadow_377_19141"
/>
</filter>
</defs>
<circle
className="stroke-custom-primary-100 fill-none "
cx={size / 2}
cy={size / 2}
r={radius}
strokeWidth={`${strokeWidth}px`}
transform={`rotate(-90 ${size / 2} ${size / 2})`}
style={{
strokeDasharray: dashArray,
strokeDashoffset: dashOffset,
}}
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
<div
className="absolute"
style={{
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
}}
>
{children}
</div>
</div>
);
};

View File

@ -1,3 +1,4 @@
export * from "./radial-progress"; export * from "./radial-progress";
export * from "./progress-bar"; export * from "./progress-bar";
export * from "./linear-progress-indicator"; export * from "./linear-progress-indicator";
export * from "./circular-progress-indicator";

View File

@ -8,6 +8,9 @@ const nextConfig = {
experimental: { experimental: {
outputFileTracingRoot: path.join(__dirname, "../"), outputFileTracingRoot: path.join(__dirname, "../"),
}, },
images: {
unoptimized: true,
},
output: "standalone", output: "standalone",
}; };

View File

@ -7,7 +7,8 @@
"develop": "next dev -p 4000", "develop": "next dev -p 4000",
"build": "next build", "build": "next build",
"start": "next start -p 4000", "start": "next start -p 4000",
"lint": "next lint" "lint": "next lint",
"export": "next export"
}, },
"dependencies": { "dependencies": {
"@blueprintjs/core": "^4.16.3", "@blueprintjs/core": "^4.16.3",
@ -16,6 +17,8 @@
"@emotion/styled": "^11.11.0", "@emotion/styled": "^11.11.0",
"@headlessui/react": "^1.7.13", "@headlessui/react": "^1.7.13",
"@mui/material": "^5.14.1", "@mui/material": "^5.14.1",
"@plane/ui": "*",
"@plane/lite-text-editor": "*",
"@plane/rich-text-editor": "*", "@plane/rich-text-editor": "*",
"axios": "^1.3.4", "axios": "^1.3.4",
"clsx": "^2.0.0", "clsx": "^2.0.0",

View File

@ -15,58 +15,63 @@ type Props = {
export const LinksList: React.FC<Props> = ({ links, handleDeleteLink, handleEditLink, userAuth }) => { export const LinksList: React.FC<Props> = ({ links, handleDeleteLink, handleEditLink, userAuth }) => {
const isNotAllowed = userAuth.isGuest || userAuth.isViewer; const isNotAllowed = userAuth.isGuest || userAuth.isViewer;
return ( return (
<> <>
{links.map((link) => ( {links.map((link) => (
<div key={link.id} className="relative"> <div key={link.id} className="relative flex flex-col rounded-md bg-custom-background-90 p-2.5">
{!isNotAllowed && ( <div className="flex items-start justify-between gap-2 w-full">
<div className="absolute top-1.5 right-1.5 z-[1] flex items-center gap-1"> <div className="flex items-start gap-2">
<button <span className="py-1">
type="button" <LinkIcon className="h-3 w-3 flex-shrink-0" />
className="grid h-7 w-7 place-items-center rounded bg-custom-background-90 p-1 outline-none hover:bg-custom-background-80" </span>
onClick={() => handleEditLink(link)} <span className="text-xs break-all">{link.title && link.title !== "" ? link.title : link.url}</span>
>
<Pencil className="text-custom-text-200" />
</button>
<a
href={link.url}
target="_blank"
rel="noopener noreferrer"
className="grid h-7 w-7 place-items-center rounded bg-custom-background-90 p-1 outline-none hover:bg-custom-background-80"
>
<ExternalLinkIcon className="h-4 w-4 text-custom-text-200" />
</a>
<button
type="button"
className="grid h-7 w-7 place-items-center rounded bg-custom-background-90 p-1 text-red-500 outline-none duration-300 hover:bg-red-500/20"
onClick={() => handleDeleteLink(link.id)}
>
<Trash2 className="h-4 w-4" />
</button>
</div> </div>
)}
<a {!isNotAllowed && (
href={link.url} <div className="flex items-center gap-2 flex-shrink-0 z-[1]">
target="_blank" <button
rel="noopener noreferrer" type="button"
className="relative flex gap-2 rounded-md bg-custom-background-90 p-2" className="flex items-center justify-center p-1 hover:bg-custom-background-80"
> onClick={(e) => {
<div className="mt-0.5"> e.preventDefault();
<LinkIcon className="h-3.5 w-3.5" /> e.stopPropagation();
</div> handleEditLink(link);
<div> }}
<h5 className="w-4/5 break-words">{link.title ?? link.url}</h5> >
<p className="mt-0.5 text-custom-text-200"> <Pencil className="h-3 w-3 text-custom-text-200 stroke-[1.5]" />
Added {timeAgo(link.created_at)} </button>
<br /> <a
by{" "} href={link.url}
{link.created_by_detail.is_bot target="_blank"
? link.created_by_detail.first_name + " Bot" rel="noopener noreferrer"
: link.created_by_detail.display_name} className="flex items-center justify-center p-1 hover:bg-custom-background-80"
</p> >
</div> <ExternalLinkIcon className="h-3 w-3 text-custom-text-200 stroke-[1.5]" />
</a> </a>
<button
type="button"
className="flex items-center justify-center p-1 hover:bg-custom-background-80"
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
handleDeleteLink(link.id);
}}
>
<Trash2 className="h-3 w-3" />
</button>
</div>
)}
</div>
<div className="px-5">
<p className="text-xs mt-0.5 text-custom-text-300 stroke-[1.5]">
Added {timeAgo(link.created_at)}
<br />
by{" "}
{link.created_by_detail.is_bot
? link.created_by_detail.first_name + " Bot"
: link.created_by_detail.display_name}
</p>
</div>
</div> </div>
))} ))}
</> </>

View File

@ -1,11 +1,16 @@
import React from "react"; import React from "react";
import Image from "next/image";
// headless ui // headless ui
import { Tab } from "@headlessui/react"; import { Tab } from "@headlessui/react";
// hooks // hooks
import useLocalStorage from "hooks/use-local-storage"; import useLocalStorage from "hooks/use-local-storage";
import useIssuesView from "hooks/use-issues-view"; import useIssuesView from "hooks/use-issues-view";
// images
import emptyLabel from "public/empty-state/empty_label.svg";
import emptyMembers from "public/empty-state/empty_members.svg";
// components // components
import { StateGroupIcon } from "@plane/ui";
import { SingleProgressStats } from "components/core"; import { SingleProgressStats } from "components/core";
// ui // ui
import { Avatar } from "components/ui"; import { Avatar } from "components/ui";
@ -17,9 +22,7 @@ import {
TLabelsDistribution, TLabelsDistribution,
TStateGroups, TStateGroups,
} from "types"; } from "types";
// constants
import { STATE_GROUP_COLORS } from "constants/state";
// types
type Props = { type Props = {
distribution: { distribution: {
assignees: TAssigneesDistribution[]; assignees: TAssigneesDistribution[];
@ -33,6 +36,7 @@ type Props = {
module?: IModule; module?: IModule;
roundedTab?: boolean; roundedTab?: boolean;
noBackground?: boolean; noBackground?: boolean;
isPeekModuleDetails?: boolean;
}; };
export const SidebarProgressStats: React.FC<Props> = ({ export const SidebarProgressStats: React.FC<Props> = ({
@ -42,6 +46,7 @@ export const SidebarProgressStats: React.FC<Props> = ({
module, module,
roundedTab, roundedTab,
noBackground, noBackground,
isPeekModuleDetails = false,
}) => { }) => {
const { filters, setFilters } = useIssuesView(); const { filters, setFilters } = useIssuesView();
@ -55,7 +60,6 @@ export const SidebarProgressStats: React.FC<Props> = ({
return 1; return 1;
case "States": case "States":
return 2; return 2;
default: default:
return 0; return 0;
} }
@ -72,7 +76,6 @@ export const SidebarProgressStats: React.FC<Props> = ({
return setTab("Labels"); return setTab("Labels");
case 2: case 2:
return setTab("States"); return setTab("States");
default: default:
return setTab("Assignees"); return setTab("Assignees");
} }
@ -82,15 +85,17 @@ export const SidebarProgressStats: React.FC<Props> = ({
as="div" as="div"
className={`flex w-full items-center gap-2 justify-between rounded-md ${ className={`flex w-full items-center gap-2 justify-between rounded-md ${
noBackground ? "" : "bg-custom-background-90" noBackground ? "" : "bg-custom-background-90"
} px-1 py-1.5 } p-0.5
${module ? "text-xs" : "text-sm"} `} ${module ? "text-xs" : "text-sm"}`}
> >
<Tab <Tab
className={({ selected }) => className={({ selected }) =>
`w-full ${ `w-full ${
roundedTab ? "rounded-3xl border border-custom-border-200" : "rounded" roundedTab ? "rounded-3xl border border-custom-border-200" : "rounded"
} px-3 py-1 text-custom-text-100 ${ } px-3 py-1 text-custom-text-100 ${
selected ? " bg-custom-primary text-white" : " hover:bg-custom-background-80" selected
? "bg-custom-background-100 text-custom-text-300 shadow-custom-shadow-2xs"
: "text-custom-text-400 hover:text-custom-text-300"
}` }`
} }
> >
@ -101,7 +106,9 @@ export const SidebarProgressStats: React.FC<Props> = ({
`w-full ${ `w-full ${
roundedTab ? "rounded-3xl border border-custom-border-200" : "rounded" roundedTab ? "rounded-3xl border border-custom-border-200" : "rounded"
} px-3 py-1 text-custom-text-100 ${ } px-3 py-1 text-custom-text-100 ${
selected ? " bg-custom-primary text-white" : " hover:bg-custom-background-80" selected
? "bg-custom-background-100 text-custom-text-300 shadow-custom-shadow-2xs"
: "text-custom-text-400 hover:text-custom-text-300"
}` }`
} }
> >
@ -112,113 +119,128 @@ export const SidebarProgressStats: React.FC<Props> = ({
`w-full ${ `w-full ${
roundedTab ? "rounded-3xl border border-custom-border-200" : "rounded" roundedTab ? "rounded-3xl border border-custom-border-200" : "rounded"
} px-3 py-1 text-custom-text-100 ${ } px-3 py-1 text-custom-text-100 ${
selected ? " bg-custom-primary text-white" : " hover:bg-custom-background-80" selected
? "bg-custom-background-100 text-custom-text-300 shadow-custom-shadow-2xs"
: "text-custom-text-400 hover:text-custom-text-300"
}` }`
} }
> >
States States
</Tab> </Tab>
</Tab.List> </Tab.List>
<Tab.Panels className="flex w-full items-center justify-between pt-1 text-custom-text-200"> <Tab.Panels className="flex w-full items-center justify-between text-custom-text-200">
<Tab.Panel as="div" className="w-full space-y-1"> <Tab.Panel as="div" className="flex flex-col gap-1.5 pt-3.5 w-full h-44 overflow-y-auto">
{distribution.assignees.map((assignee, index) => { {distribution.assignees.length > 0 ? (
if (assignee.assignee_id) distribution.assignees.map((assignee, index) => {
return ( if (assignee.assignee_id)
<SingleProgressStats return (
key={assignee.assignee_id} <SingleProgressStats
title={ key={assignee.assignee_id}
<div className="flex items-center gap-2"> title={
<Avatar <div className="flex items-center gap-2">
user={{ <Avatar
id: assignee.assignee_id, user={{
avatar: assignee.avatar ?? "", id: assignee.assignee_id,
first_name: assignee.first_name ?? "", avatar: assignee.avatar ?? "",
last_name: assignee.last_name ?? "", first_name: assignee.first_name ?? "",
display_name: assignee.display_name ?? "", last_name: assignee.last_name ?? "",
}} display_name: assignee.display_name ?? "",
/> }}
<span>{assignee.display_name}</span> height="18px"
</div> width="18px"
}
completed={assignee.completed_issues}
total={assignee.total_issues}
onClick={() => {
if (filters?.assignees?.includes(assignee.assignee_id ?? ""))
setFilters({
assignees: filters?.assignees?.filter((a) => a !== assignee.assignee_id),
});
else
setFilters({
assignees: [...(filters?.assignees ?? []), assignee.assignee_id ?? ""],
});
}}
selected={filters?.assignees?.includes(assignee.assignee_id ?? "")}
/>
);
else
return (
<SingleProgressStats
key={`unassigned-${index}`}
title={
<div className="flex items-center gap-2">
<div className="h-5 w-5 rounded-full border-2 border-custom-border-200 bg-custom-background-80">
<img
src="/user.png"
height="100%"
width="100%"
className="rounded-full"
alt="User"
/> />
<span>{assignee.display_name}</span>
</div> </div>
<span>No assignee</span> }
</div> completed={assignee.completed_issues}
} total={assignee.total_issues}
completed={assignee.completed_issues} {...(!isPeekModuleDetails && {
total={assignee.total_issues} onClick: () => {
/> if (filters?.assignees?.includes(assignee.assignee_id ?? ""))
); setFilters({
})} assignees: filters?.assignees?.filter((a) => a !== assignee.assignee_id),
</Tab.Panel> });
<Tab.Panel as="div" className="w-full space-y-1"> else
{distribution.labels.map((label, index) => ( setFilters({
<SingleProgressStats assignees: [...(filters?.assignees ?? []), assignee.assignee_id ?? ""],
key={label.label_id ?? `no-label-${index}`} });
title={ },
<div className="flex items-center gap-2"> selected: filters?.assignees?.includes(assignee.assignee_id ?? ""),
<span })}
className="block h-3 w-3 rounded-full"
style={{
backgroundColor: label.color ?? "transparent",
}}
/> />
<span className="text-xs">{label.label_name ?? "No labels"}</span> );
</div> else
} return (
completed={label.completed_issues} <SingleProgressStats
total={label.total_issues} key={`unassigned-${index}`}
onClick={() => { title={
if (filters.labels?.includes(label.label_id ?? "")) <div className="flex items-center gap-2">
setFilters({ <div className="h-4 w-4 rounded-full border-2 border-custom-border-200 bg-custom-background-80">
labels: filters?.labels?.filter((l) => l !== label.label_id), <img src="/user.png" height="100%" width="100%" className="rounded-full" alt="User" />
}); </div>
else setFilters({ labels: [...(filters?.labels ?? []), label.label_id ?? ""] }); <span>No assignee</span>
}} </div>
selected={filters?.labels?.includes(label.label_id ?? "")} }
/> completed={assignee.completed_issues}
))} total={assignee.total_issues}
/>
);
})
) : (
<div className="flex flex-col items-center justify-center gap-2 h-full">
<div className="flex items-center justify-center h-20 w-20 bg-custom-background-80 rounded-full">
<Image src={emptyMembers} className="h-12 w-12" alt="empty members" />
</div>
<h6 className="text-base text-custom-text-300">No assignees yet</h6>
</div>
)}
</Tab.Panel> </Tab.Panel>
<Tab.Panel as="div" className="w-full space-y-1"> <Tab.Panel as="div" className="flex flex-col gap-1.5 pt-3.5 w-full h-44 overflow-y-auto">
{distribution.labels.length > 0 ? (
distribution.labels.map((label, index) => (
<SingleProgressStats
key={label.label_id ?? `no-label-${index}`}
title={
<div className="flex items-center gap-2">
<span
className="block h-3 w-3 rounded-full"
style={{
backgroundColor: label.color ?? "transparent",
}}
/>
<span className="text-xs">{label.label_name ?? "No labels"}</span>
</div>
}
completed={label.completed_issues}
total={label.total_issues}
{...(!isPeekModuleDetails && {
onClick: () => {
if (filters.labels?.includes(label.label_id ?? ""))
setFilters({
labels: filters?.labels?.filter((l) => l !== label.label_id),
});
else setFilters({ labels: [...(filters?.labels ?? []), label.label_id ?? ""] });
},
selected: filters?.labels?.includes(label.label_id ?? ""),
})}
/>
))
) : (
<div className="flex flex-col items-center justify-center gap-2 h-full">
<div className="flex items-center justify-center h-20 w-20 bg-custom-background-80 rounded-full">
<Image src={emptyLabel} className="h-12 w-12" alt="empty label" />
</div>
<h6 className="text-base text-custom-text-300">No labels yet</h6>
</div>
)}
</Tab.Panel>
<Tab.Panel as="div" className="flex flex-col gap-1.5 pt-3.5 w-full h-44 overflow-y-auto">
{Object.keys(groupedIssues).map((group, index) => ( {Object.keys(groupedIssues).map((group, index) => (
<SingleProgressStats <SingleProgressStats
key={index} key={index}
title={ title={
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<span <StateGroupIcon stateGroup={group as TStateGroups} />
className="block h-3 w-3 rounded-full "
style={{
backgroundColor: STATE_GROUP_COLORS[group as TStateGroups],
}}
/>
<span className="text-xs capitalize">{group}</span> <span className="text-xs capitalize">{group}</span>
</div> </div>
} }

View File

@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { ProgressBar } from "@plane/ui"; import { CircularProgressIndicator } from "@plane/ui";
type TSingleProgressStatsProps = { type TSingleProgressStatsProps = {
title: any; title: any;
@ -27,7 +27,7 @@ export const SingleProgressStats: React.FC<TSingleProgressStatsProps> = ({
<div className="flex w-1/2 items-center justify-end gap-1 px-2"> <div className="flex w-1/2 items-center justify-end gap-1 px-2">
<div className="flex h-5 items-center justify-center gap-1"> <div className="flex h-5 items-center justify-center gap-1">
<span className="h-4 w-4"> <span className="h-4 w-4">
<ProgressBar value={completed} maxValue={total} /> <CircularProgressIndicator percentage={(completed / total) * 100} size={14} strokeWidth={2} />
</span> </span>
<span className="w-8 text-right"> <span className="w-8 text-right">
{isNaN(Math.floor((completed / total) * 100)) ? "0" : Math.floor((completed / total) * 100)}% {isNaN(Math.floor((completed / total) * 100)) ? "0" : Math.floor((completed / total) * 100)}%

View File

@ -0,0 +1,160 @@
import React, { useState } from "react";
import { usePopper } from "react-popper";
import { Combobox } from "@headlessui/react";
import { Check, ChevronDown, Search, Triangle } from "lucide-react";
// types
import { Tooltip } from "components/ui";
import { Placement } from "@popperjs/core";
// constants
import { IEstimatePoint } from "types";
type Props = {
value: number | null;
onChange: (value: number | null) => void;
estimatePoints: IEstimatePoint[] | undefined;
className?: string;
buttonClassName?: string;
optionsClassName?: string;
placement?: Placement;
hideDropdownArrow?: boolean;
disabled?: boolean;
};
export const EstimateSelect: React.FC<Props> = (props) => {
const {
value,
onChange,
estimatePoints,
className = "",
buttonClassName = "",
optionsClassName = "",
placement,
hideDropdownArrow = false,
disabled = false,
} = props;
const [query, setQuery] = useState("");
const [referenceElement, setReferenceElement] = useState<HTMLButtonElement | null>(null);
const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);
const { styles, attributes } = usePopper(referenceElement, popperElement, {
placement: placement ?? "bottom-start",
modifiers: [
{
name: "preventOverflow",
options: {
padding: 12,
},
},
],
});
const options: { value: number | null; query: string; content: any }[] | undefined = estimatePoints?.map(
(estimate) => ({
value: estimate.key,
query: estimate.value,
content: (
<div className="flex items-center gap-2">
<Triangle className="h-3 w-3" strokeWidth={2} />
{estimate.value}
</div>
),
})
);
options?.unshift({
value: null,
query: "none",
content: (
<div className="flex items-center gap-2">
<Triangle className="h-3 w-3" strokeWidth={2} />
None
</div>
),
});
const filteredOptions =
query === "" ? options : options?.filter((option) => option.query.toLowerCase().includes(query.toLowerCase()));
const selectedEstimate = estimatePoints?.find((e) => e.key === value);
const label = (
<Tooltip tooltipHeading="Estimate" tooltipContent={selectedEstimate?.value ?? "None"} position="top">
<div className="flex items-center cursor-pointer w-full gap-2 text-custom-text-200">
<Triangle className="h-3 w-3" strokeWidth={2} />
<span className="truncate">{selectedEstimate?.value ?? "None"}</span>
</div>
</Tooltip>
);
return (
<Combobox
as="div"
className={`flex-shrink-0 text-left ${className}`}
value={value}
onChange={(val) => onChange(val as number | null)}
disabled={disabled}
>
<Combobox.Button as={React.Fragment}>
<button
ref={setReferenceElement}
type="button"
className={`flex items-center justify-between gap-1 w-full text-xs px-2.5 py-1 rounded border-[0.5px] border-custom-border-300 duration-300 focus:outline-none ${
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
} ${buttonClassName}`}
>
{label}
{!hideDropdownArrow && !disabled && <ChevronDown className="h-3 w-3" aria-hidden="true" />}
</button>
</Combobox.Button>
<Combobox.Options className="fixed z-10">
<div
className={`border border-custom-border-300 px-2 py-2.5 rounded bg-custom-background-100 text-xs shadow-custom-shadow-rg focus:outline-none w-48 whitespace-nowrap my-1 ${optionsClassName}`}
ref={setPopperElement}
style={styles.popper}
{...attributes.popper}
>
<div className="flex w-full items-center justify-start rounded border border-custom-border-200 bg-custom-background-90 px-2">
<Search className="h-3.5 w-3.5 text-custom-text-300" />
<Combobox.Input
className="w-full bg-transparent py-1 px-2 text-xs text-custom-text-200 placeholder:text-custom-text-400 focus:outline-none"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
/>
</div>
<div className={`mt-2 space-y-1 max-h-48 overflow-y-scroll`}>
{filteredOptions ? (
filteredOptions.length > 0 ? (
filteredOptions.map((option) => (
<Combobox.Option
key={option.value}
value={option.value}
className={({ active, selected }) =>
`flex items-center justify-between gap-2 cursor-pointer select-none truncate rounded px-1 py-1.5 ${
active ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
}
>
{({ selected }) => (
<>
{option.content}
{selected && <Check className="h-3.5 w-3.5" />}
</>
)}
</Combobox.Option>
))
) : (
<span className="flex items-center gap-2 p-1">
<p className="text-left text-custom-text-200 ">No matching results</p>
</span>
)
) : (
<p className="text-center text-custom-text-200">Loading...</p>
)}
</div>
</div>
</Combobox.Options>
</Combobox>
);
};

View File

@ -1,3 +1,4 @@
export * from "./create-update-estimate-modal"; export * from "./create-update-estimate-modal";
export * from "./single-estimate";
export * from "./delete-estimate-modal"; export * from "./delete-estimate-modal";
export * from "./estimate-select";
export * from "./single-estimate";

View File

@ -1,6 +1,4 @@
import { FC, useEffect, useState } from "react"; import { FC, useEffect, useState } from "react";
// next
import { useRouter } from "next/router";
// icons // icons
// components // components
import { GanttChartBlocks } from "components/gantt-chart"; import { GanttChartBlocks } from "components/gantt-chart";
@ -13,7 +11,7 @@ import { MonthChartView } from "./month";
// import { QuarterChartView } from "./quarter"; // import { QuarterChartView } from "./quarter";
// import { YearChartView } from "./year"; // import { YearChartView } from "./year";
// icons // icons
import { Expand, PlusIcon, Shrink } from "lucide-react"; import { Expand, Shrink } from "lucide-react";
// views // views
import { import {
// generateHourChart, // generateHourChart,
@ -28,7 +26,6 @@ import {
// getNumberOfDaysBetweenTwoDatesInYear, // getNumberOfDaysBetweenTwoDatesInYear,
getMonthChartItemPositionWidthInMonth, getMonthChartItemPositionWidthInMonth,
} from "../views"; } from "../views";
// import { GanttInlineCreateIssueForm } from "components/core/views/gantt-chart-view/inline-create-issue-form";
// types // types
import { ChartDataType, IBlockUpdateData, IGanttBlock, TGanttViews } from "../types"; import { ChartDataType, IBlockUpdateData, IGanttBlock, TGanttViews } from "../types";
// data // data
@ -65,15 +62,9 @@ export const ChartViewRoot: FC<ChartViewRootProps> = ({
enableReorder, enableReorder,
bottomSpacing, bottomSpacing,
}) => { }) => {
// router
const router = useRouter();
const { cycleId, moduleId } = router.query;
const isCyclePage = router.pathname.split("/")[4] === "cycles" && !cycleId;
const isModulePage = router.pathname.split("/")[4] === "modules" && !moduleId;
// states // states
const [itemsContainerWidth, setItemsContainerWidth] = useState<number>(0); const [itemsContainerWidth, setItemsContainerWidth] = useState<number>(0);
const [fullScreenMode, setFullScreenMode] = useState<boolean>(false); const [fullScreenMode, setFullScreenMode] = useState<boolean>(false);
const [isCreateIssueFormOpen, setIsCreateIssueFormOpen] = useState(false);
const [chartBlocks, setChartBlocks] = useState<IGanttBlock[] | null>(null); // blocks state management starts const [chartBlocks, setChartBlocks] = useState<IGanttBlock[] | null>(null); // blocks state management starts
// hooks // hooks
const { currentView, currentViewData, renderView, dispatch, allViews, updateScrollLeft } = useChart(); const { currentView, currentViewData, renderView, dispatch, allViews, updateScrollLeft } = useChart();
@ -297,44 +288,6 @@ export const ChartViewRoot: FC<ChartViewRootProps> = ({
SidebarBlockRender={SidebarBlockRender} SidebarBlockRender={SidebarBlockRender}
enableReorder={enableReorder} enableReorder={enableReorder}
/> />
{chartBlocks && !(isCyclePage || isModulePage) && (
<div className="pl-2.5 py-3">
{/* <GanttInlineCreateIssueForm
isOpen={isCreateIssueFormOpen}
handleClose={() => setIsCreateIssueFormOpen(false)}
onSuccess={() => {
const ganttSidebar = document.getElementById(`gantt-sidebar-${cycleId}`);
const timeoutId = setTimeout(() => {
if (ganttSidebar)
ganttSidebar.scrollBy({
top: ganttSidebar.scrollHeight,
left: 0,
behavior: "smooth",
});
clearTimeout(timeoutId);
}, 10);
}}
prePopulatedData={{
start_date: new Date(Date.now()).toISOString().split("T")[0],
target_date: new Date(Date.now() + 86400000).toISOString().split("T")[0],
...(cycleId && { cycle: cycleId.toString() }),
...(moduleId && { module: moduleId.toString() }),
}}
/> */}
{!isCreateIssueFormOpen && (
<button
type="button"
onClick={() => setIsCreateIssueFormOpen(true)}
className="flex items-center gap-x-[6px] text-custom-primary-100 px-2 pl-[1.875rem] py-1 rounded-md"
>
<PlusIcon className="h-4 w-4" />
<span className="text-sm font-medium text-custom-primary-100">New Issue</span>
</button>
)}
</div>
)}
</div> </div>
<div <div
className="relative flex h-full w-full flex-1 flex-col overflow-hidden overflow-x-auto horizontal-scroll-enable" className="relative flex h-full w-full flex-1 flex-col overflow-hidden overflow-x-auto horizontal-scroll-enable"

View File

@ -0,0 +1,158 @@
import { useRouter } from "next/router";
import { DragDropContext, Draggable, DropResult } from "react-beautiful-dnd";
import StrictModeDroppable from "components/dnd/StrictModeDroppable";
import { MoreVertical } from "lucide-react";
// hooks
import { useChart } from "./hooks";
// ui
import { Loader } from "@plane/ui";
// helpers
import { findTotalDaysInRange } from "helpers/date-time.helper";
// types
import { IBlockUpdateData, IGanttBlock } from "./types";
type Props = {
title: string;
blockUpdateHandler: (block: any, payload: IBlockUpdateData) => void;
blocks: IGanttBlock[] | null;
SidebarBlockRender: React.FC<any>;
enableReorder: boolean;
};
export const GanttSidebar: React.FC<Props> = (props) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { title, blockUpdateHandler, blocks, SidebarBlockRender, enableReorder } = props;
const router = useRouter();
const { cycleId } = router.query;
const { activeBlock, dispatch } = useChart();
// update the active block on hover
const updateActiveBlock = (block: IGanttBlock | null) => {
dispatch({
type: "PARTIAL_UPDATE",
payload: {
activeBlock: block,
},
});
};
const handleOrderChange = (result: DropResult) => {
if (!blocks) return;
const { source, destination } = result;
// return if dropped outside the list
if (!destination) return;
// return if dropped on the same index
if (source.index === destination.index) return;
let updatedSortOrder = blocks[source.index].sort_order;
// update the sort order to the lowest if dropped at the top
if (destination.index === 0) updatedSortOrder = blocks[0].sort_order - 1000;
// update the sort order to the highest if dropped at the bottom
else if (destination.index === blocks.length - 1) updatedSortOrder = blocks[blocks.length - 1].sort_order + 1000;
// update the sort order to the average of the two adjacent blocks if dropped in between
else {
const destinationSortingOrder = blocks[destination.index].sort_order;
const relativeDestinationSortingOrder =
source.index < destination.index
? blocks[destination.index + 1].sort_order
: blocks[destination.index - 1].sort_order;
updatedSortOrder = (destinationSortingOrder + relativeDestinationSortingOrder) / 2;
}
// extract the element from the source index and insert it at the destination index without updating the entire array
const removedElement = blocks.splice(source.index, 1)[0];
blocks.splice(destination.index, 0, removedElement);
// call the block update handler with the updated sort order, new and old index
blockUpdateHandler(removedElement.data, {
sort_order: {
destinationIndex: destination.index,
newSortOrder: updatedSortOrder,
sourceIndex: source.index,
},
});
};
return (
<DragDropContext onDragEnd={handleOrderChange}>
<StrictModeDroppable droppableId="gantt-sidebar">
{(droppableProvided) => (
<div
id={`gantt-sidebar-${cycleId}`}
className="max-h-full overflow-y-auto pl-2.5 mt-3"
ref={droppableProvided.innerRef}
{...droppableProvided.droppableProps}
>
<>
{blocks ? (
blocks.map((block, index) => {
const duration = findTotalDaysInRange(block.start_date ?? "", block.target_date ?? "", true);
return (
<Draggable
key={`sidebar-block-${block.id}`}
draggableId={`sidebar-block-${block.id}`}
index={index}
isDragDisabled={!enableReorder}
>
{(provided, snapshot) => (
<div
className={`h-11 ${snapshot.isDragging ? "bg-custom-background-80 rounded" : ""}`}
onMouseEnter={() => updateActiveBlock(block)}
onMouseLeave={() => updateActiveBlock(null)}
ref={provided.innerRef}
{...provided.draggableProps}
>
<div
id={`sidebar-block-${block.id}`}
className={`group h-full w-full flex items-center gap-2 rounded-l px-2 pr-4 ${
activeBlock?.id === block.id ? "bg-custom-background-80" : ""
}`}
>
{enableReorder && (
<button
type="button"
className="rounded p-0.5 text-custom-sidebar-text-200 flex flex-shrink-0 opacity-0 group-hover:opacity-100"
{...provided.dragHandleProps}
>
<MoreVertical className="h-3.5 w-3.5" />
<MoreVertical className="h-3.5 w-3.5 -ml-5" />
</button>
)}
<div className="flex-grow truncate h-full flex items-center justify-between gap-2">
<div className="flex-grow truncate">
<SidebarBlockRender data={block.data} />
</div>
<div className="flex-shrink-0 text-sm text-custom-text-200">
{duration} day{duration > 1 ? "s" : ""}
</div>
</div>
</div>
</div>
)}
</Draggable>
);
})
) : (
<Loader className="pr-2 space-y-3">
<Loader.Item height="34px" />
<Loader.Item height="34px" />
<Loader.Item height="34px" />
<Loader.Item height="34px" />
</Loader>
)}
{droppableProvided.placeholder}
</>
</div>
)}
</StrictModeDroppable>
</DragDropContext>
);
};

View File

@ -0,0 +1,158 @@
import { useRouter } from "next/router";
import { DragDropContext, Draggable, DropResult } from "react-beautiful-dnd";
import StrictModeDroppable from "components/dnd/StrictModeDroppable";
import { MoreVertical } from "lucide-react";
// hooks
import { useChart } from "./hooks";
// ui
import { Loader } from "@plane/ui";
// helpers
import { findTotalDaysInRange } from "helpers/date-time.helper";
// types
import { IBlockUpdateData, IGanttBlock } from "./types";
type Props = {
title: string;
blockUpdateHandler: (block: any, payload: IBlockUpdateData) => void;
blocks: IGanttBlock[] | null;
SidebarBlockRender: React.FC<any>;
enableReorder: boolean;
};
export const GanttSidebar: React.FC<Props> = (props) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { title, blockUpdateHandler, blocks, SidebarBlockRender, enableReorder } = props;
const router = useRouter();
const { cycleId } = router.query;
const { activeBlock, dispatch } = useChart();
// update the active block on hover
const updateActiveBlock = (block: IGanttBlock | null) => {
dispatch({
type: "PARTIAL_UPDATE",
payload: {
activeBlock: block,
},
});
};
const handleOrderChange = (result: DropResult) => {
if (!blocks) return;
const { source, destination } = result;
// return if dropped outside the list
if (!destination) return;
// return if dropped on the same index
if (source.index === destination.index) return;
let updatedSortOrder = blocks[source.index].sort_order;
// update the sort order to the lowest if dropped at the top
if (destination.index === 0) updatedSortOrder = blocks[0].sort_order - 1000;
// update the sort order to the highest if dropped at the bottom
else if (destination.index === blocks.length - 1) updatedSortOrder = blocks[blocks.length - 1].sort_order + 1000;
// update the sort order to the average of the two adjacent blocks if dropped in between
else {
const destinationSortingOrder = blocks[destination.index].sort_order;
const relativeDestinationSortingOrder =
source.index < destination.index
? blocks[destination.index + 1].sort_order
: blocks[destination.index - 1].sort_order;
updatedSortOrder = (destinationSortingOrder + relativeDestinationSortingOrder) / 2;
}
// extract the element from the source index and insert it at the destination index without updating the entire array
const removedElement = blocks.splice(source.index, 1)[0];
blocks.splice(destination.index, 0, removedElement);
// call the block update handler with the updated sort order, new and old index
blockUpdateHandler(removedElement.data, {
sort_order: {
destinationIndex: destination.index,
newSortOrder: updatedSortOrder,
sourceIndex: source.index,
},
});
};
return (
<DragDropContext onDragEnd={handleOrderChange}>
<StrictModeDroppable droppableId="gantt-sidebar">
{(droppableProvided) => (
<div
id={`gantt-sidebar-${cycleId}`}
className="max-h-full overflow-y-auto pl-2.5 mt-3"
ref={droppableProvided.innerRef}
{...droppableProvided.droppableProps}
>
<>
{blocks ? (
blocks.map((block, index) => {
const duration = findTotalDaysInRange(block.start_date ?? "", block.target_date ?? "", true);
return (
<Draggable
key={`sidebar-block-${block.id}`}
draggableId={`sidebar-block-${block.id}`}
index={index}
isDragDisabled={!enableReorder}
>
{(provided, snapshot) => (
<div
className={`h-11 ${snapshot.isDragging ? "bg-custom-background-80 rounded" : ""}`}
onMouseEnter={() => updateActiveBlock(block)}
onMouseLeave={() => updateActiveBlock(null)}
ref={provided.innerRef}
{...provided.draggableProps}
>
<div
id={`sidebar-block-${block.id}`}
className={`group h-full w-full flex items-center gap-2 rounded-l px-2 pr-4 ${
activeBlock?.id === block.id ? "bg-custom-background-80" : ""
}`}
>
{enableReorder && (
<button
type="button"
className="rounded p-0.5 text-custom-sidebar-text-200 flex flex-shrink-0 opacity-0 group-hover:opacity-100"
{...provided.dragHandleProps}
>
<MoreVertical className="h-3.5 w-3.5" />
<MoreVertical className="h-3.5 w-3.5 -ml-5" />
</button>
)}
<div className="flex-grow truncate h-full flex items-center justify-between gap-2">
<div className="flex-grow truncate">
<SidebarBlockRender data={block.data} />
</div>
<div className="flex-shrink-0 text-sm text-custom-text-200">
{duration} day{duration > 1 ? "s" : ""}
</div>
</div>
</div>
</div>
)}
</Draggable>
);
})
) : (
<Loader className="pr-2 space-y-3">
<Loader.Item height="34px" />
<Loader.Item height="34px" />
<Loader.Item height="34px" />
<Loader.Item height="34px" />
</Loader>
)}
{droppableProvided.placeholder}
</>
</div>
)}
</StrictModeDroppable>
</DragDropContext>
);
};

View File

@ -6,6 +6,8 @@ import { MoreVertical } from "lucide-react";
import { useChart } from "./hooks"; import { useChart } from "./hooks";
// ui // ui
import { Loader } from "@plane/ui"; import { Loader } from "@plane/ui";
// components
import { GanttInlineCreateIssueForm } from "components/issues";
// helpers // helpers
import { findTotalDaysInRange } from "helpers/date-time.helper"; import { findTotalDaysInRange } from "helpers/date-time.helper";
// types // types
@ -17,11 +19,12 @@ type Props = {
blocks: IGanttBlock[] | null; blocks: IGanttBlock[] | null;
SidebarBlockRender: React.FC<any>; SidebarBlockRender: React.FC<any>;
enableReorder: boolean; enableReorder: boolean;
enableQuickIssueCreate?: boolean;
}; };
export const GanttSidebar: React.FC<Props> = (props) => { export const GanttSidebar: React.FC<Props> = (props) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
const { title, blockUpdateHandler, blocks, SidebarBlockRender, enableReorder } = props; const { title, blockUpdateHandler, blocks, SidebarBlockRender, enableReorder, enableQuickIssueCreate } = props;
const router = useRouter(); const router = useRouter();
const { cycleId } = router.query; const { cycleId } = router.query;
@ -150,6 +153,7 @@ export const GanttSidebar: React.FC<Props> = (props) => {
)} )}
{droppableProvided.placeholder} {droppableProvided.placeholder}
</> </>
<GanttInlineCreateIssueForm />
</div> </div>
)} )}
</StrictModeDroppable> </StrictModeDroppable>

View File

@ -18,3 +18,4 @@ export * from "./project-draft-issues";
export * from "./project-archived-issue-details"; export * from "./project-archived-issue-details";
export * from "./project-archived-issues"; export * from "./project-archived-issues";
export * from "./project-issue-details"; export * from "./project-issue-details";
export * from "./user-profile";

View File

@ -1,25 +1,28 @@
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import Link from "next/link"; import Link from "next/link";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Plus } from "lucide-react"; import { GanttChart, LayoutGrid, List, Plus } from "lucide-react";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// hooks // hooks
import useLocalStorage from "hooks/use-local-storage"; import useLocalStorage from "hooks/use-local-storage";
// ui // ui
import { Breadcrumbs, BreadcrumbItem, Button, Tooltip } from "@plane/ui"; import { Breadcrumbs, BreadcrumbItem, Button, Tooltip } from "@plane/ui";
import { Icon } from "components/ui";
// helper // helper
import { replaceUnderscoreIfSnakeCase, truncateText } from "helpers/string.helper"; import { replaceUnderscoreIfSnakeCase, truncateText } from "helpers/string.helper";
const moduleViewOptions: { type: "grid" | "gantt_chart"; icon: any }[] = [ const moduleViewOptions: { type: "list" | "grid" | "gantt_chart"; icon: any }[] = [
{ {
type: "gantt_chart", type: "list",
icon: "view_timeline", icon: List,
}, },
{ {
type: "grid", type: "grid",
icon: "table_rows", icon: LayoutGrid,
},
{
type: "gantt_chart",
icon: GanttChart,
}, },
]; ];
@ -67,7 +70,7 @@ export const ModulesListHeader: React.FC = observer(() => {
}`} }`}
onClick={() => setModulesView(option.type)} onClick={() => setModulesView(option.type)}
> >
<Icon iconName={option.icon} className={`!text-base ${option.type === "grid" ? "rotate-90" : ""}`} /> <option.icon className="h-3.5 w-3.5" />
</button> </button>
</Tooltip> </Tooltip>
))} ))}

View File

@ -0,0 +1,25 @@
import { FC } from "react";
import { useRouter } from "next/router";
// ui
import { BreadcrumbItem, Breadcrumbs } from "@plane/ui";
// hooks
import { observer } from "mobx-react-lite";
export const UserProfileHeader: FC = observer(() => {
const router = useRouter();
return (
<div
className={`relative flex w-full flex-shrink-0 flex-row z-10 items-center justify-between gap-x-2 gap-y-4 border-b border-custom-border-200 bg-custom-sidebar-background-100 p-4`}
>
<div className="flex items-center gap-2 flex-grow w-full whitespace-nowrap overflow-ellipsis">
<div>
<Breadcrumbs onBack={() => router.back()}>
<BreadcrumbItem title="User Profile" unshrinkTitle />
</Breadcrumbs>
</div>
</div>
</div>
);
});

View File

@ -44,12 +44,23 @@ export const CalendarChart: React.FC<Props> = observer((props) => {
<div className="h-full w-full grid grid-cols-1 divide-y-[0.5px] divide-custom-border-200"> <div className="h-full w-full grid grid-cols-1 divide-y-[0.5px] divide-custom-border-200">
{allWeeksOfActiveMonth && {allWeeksOfActiveMonth &&
Object.values(allWeeksOfActiveMonth).map((week: ICalendarWeek, weekIndex) => ( Object.values(allWeeksOfActiveMonth).map((week: ICalendarWeek, weekIndex) => (
<CalendarWeekDays key={weekIndex} week={week} issues={issues} quickActions={quickActions} /> <CalendarWeekDays
key={weekIndex}
week={week}
issues={issues}
enableQuickIssueCreate
quickActions={quickActions}
/>
))} ))}
</div> </div>
)} )}
{layout === "week" && ( {layout === "week" && (
<CalendarWeekDays week={calendarStore.allDaysOfActiveWeek} issues={issues} quickActions={quickActions} /> <CalendarWeekDays
week={calendarStore.allDaysOfActiveWeek}
issues={issues}
enableQuickIssueCreate
quickActions={quickActions}
/>
)} )}
</div> </div>
</div> </div>

View File

@ -4,7 +4,7 @@ import { Droppable } from "@hello-pangea/dnd";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { CalendarIssueBlocks, ICalendarDate } from "components/issues"; import { CalendarIssueBlocks, ICalendarDate, CalendarInlineCreateIssueForm } from "components/issues";
// helpers // helpers
import { renderDateFormat } from "helpers/date-time.helper"; import { renderDateFormat } from "helpers/date-time.helper";
// types // types
@ -17,10 +17,11 @@ type Props = {
date: ICalendarDate; date: ICalendarDate;
issues: IIssueGroupedStructure | null; issues: IIssueGroupedStructure | null;
quickActions: (issue: IIssue) => React.ReactNode; quickActions: (issue: IIssue) => React.ReactNode;
enableQuickIssueCreate?: boolean;
}; };
export const CalendarDayTile: React.FC<Props> = observer((props) => { export const CalendarDayTile: React.FC<Props> = observer((props) => {
const { date, issues, quickActions } = props; const { date, issues, quickActions, enableQuickIssueCreate } = props;
const { issueFilter: issueFilterStore } = useMobxStore(); const { issueFilter: issueFilterStore } = useMobxStore();
@ -29,35 +30,56 @@ export const CalendarDayTile: React.FC<Props> = observer((props) => {
const issuesList = issues ? (issues as IIssueGroupedStructure)[renderDateFormat(date.date)] : null; const issuesList = issues ? (issues as IIssueGroupedStructure)[renderDateFormat(date.date)] : null;
return ( return (
<Droppable droppableId={renderDateFormat(date.date)}> <>
{(provided, snapshot) => ( <div className="group w-full h-full relative flex flex-col bg-custom-background-90">
{/* header */}
<div <div
className={`flex-grow p-2 space-y-1 w-full flex flex-col overflow-hidden ${ className={`text-xs text-right flex-shrink-0 py-1 px-2 ${
snapshot.isDraggingOver || date.date.getDay() === 0 || date.date.getDay() === 6 calendarLayout === "month" // if month layout, highlight current month days
? date.is_current_month
? "font-medium"
: "text-custom-text-300"
: "font-medium" // if week layout, highlight all days
} ${
date.date.getDay() === 0 || date.date.getDay() === 6
? "bg-custom-background-90" ? "bg-custom-background-90"
: "bg-custom-background-100" : "bg-custom-background-100"
} ${calendarLayout === "month" ? "min-h-[9rem]" : ""}`} }`}
{...provided.droppableProps}
ref={provided.innerRef}
> >
<> {date.date.getDate() === 1 && MONTHS_LIST[date.date.getMonth() + 1].shortTitle + " "}
<div {date.date.getDate()}
className={`text-xs text-right ${
calendarLayout === "month" // if month layout, highlight current month days
? date.is_current_month
? "font-medium"
: "text-custom-text-300"
: "font-medium" // if week layout, highlight all days
}`}
>
{date.date.getDate() === 1 && MONTHS_LIST[date.date.getMonth() + 1].shortTitle + " "}
{date.date.getDate()}
</div>
<CalendarIssueBlocks issues={issuesList} quickActions={quickActions} />
{provided.placeholder}
</>
</div> </div>
)}
</Droppable> {/* content */}
<div className="w-full h-full">
<Droppable droppableId={renderDateFormat(date.date)} isDropDisabled={false}>
{(provided, snapshot) => (
<div
className={`h-full w-full overflow-y-auto select-none ${
snapshot.isDraggingOver || date.date.getDay() === 0 || date.date.getDay() === 6
? "bg-custom-background-90"
: "bg-custom-background-100"
} ${calendarLayout === "month" ? "min-h-[9rem]" : ""}`}
{...provided.droppableProps}
ref={provided.innerRef}
>
<CalendarIssueBlocks issues={issuesList} quickActions={quickActions} />
{enableQuickIssueCreate && (
<div className="py-1 px-2">
<CalendarInlineCreateIssueForm
groupId={renderDateFormat(date.date)}
prePopulatedData={{
target_date: renderDateFormat(date.date),
}}
/>
</div>
)}
{provided.placeholder}
</div>
)}
</Droppable>
</div>
</div>
</>
); );
}); });

View File

@ -7,3 +7,4 @@ export * from "./header";
export * from "./issue-blocks"; export * from "./issue-blocks";
export * from "./week-days"; export * from "./week-days";
export * from "./week-header"; export * from "./week-header";
export * from "./inline-create-issue-form";

View File

@ -0,0 +1,234 @@
import { useEffect, useRef, useState } from "react";
import { useRouter } from "next/router";
import { Transition } from "@headlessui/react";
import { useForm } from "react-hook-form";
// store
import { observer } from "mobx-react-lite";
import { useMobxStore } from "lib/mobx/store-provider";
// hooks
import useToast from "hooks/use-toast";
import useKeypress from "hooks/use-keypress";
import useProjectDetails from "hooks/use-project-details";
import useOutsideClickDetector from "hooks/use-outside-click-detector";
// constants
import { createIssuePayload } from "constants/issue";
// icons
import { PlusIcon } from "lucide-react";
// types
import { IIssue } from "types";
type Props = {
groupId?: string;
dependencies?: any[];
prePopulatedData?: Partial<IIssue>;
onSuccess?: (data: IIssue) => Promise<void> | void;
};
const useCheckIfThereIsSpaceOnRight = (ref: React.RefObject<HTMLDivElement>, deps: any[]) => {
const [isThereSpaceOnRight, setIsThereSpaceOnRight] = useState(true);
const router = useRouter();
const { moduleId, cycleId, viewId } = router.query;
const container = document.getElementById(`calendar-view-${cycleId ?? moduleId ?? viewId}`);
useEffect(() => {
if (!ref.current) return;
const { right } = ref.current.getBoundingClientRect();
const width = right;
const innerWidth = container?.getBoundingClientRect().width ?? window.innerWidth;
if (width > innerWidth) setIsThereSpaceOnRight(false);
else setIsThereSpaceOnRight(true);
}, [ref, deps, container]);
return isThereSpaceOnRight;
};
const defaultValues: Partial<IIssue> = {
name: "",
};
const Inputs = (props: any) => {
const { register, setFocus, projectDetails } = props;
useEffect(() => {
setFocus("name");
}, [setFocus]);
return (
<>
<h4 className="text-sm font-medium leading-5 text-custom-text-400">{projectDetails?.identifier ?? "..."}</h4>
<input
type="text"
autoComplete="off"
placeholder="Issue Title"
{...register("name", {
required: "Issue title is required.",
})}
className="w-full pr-2 py-1.5 rounded-md bg-transparent text-sm font-medium leading-5 text-custom-text-200 outline-none"
/>
</>
);
};
export const CalendarInlineCreateIssueForm: React.FC<Props> = observer((props) => {
const { prePopulatedData, dependencies = [], groupId } = props;
// router
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
// store
const { workspace: workspaceStore, quickAddIssue: quickAddStore } = useMobxStore();
// ref
const ref = useRef<HTMLDivElement>(null);
// states
const [isOpen, setIsOpen] = useState(false);
const { setToastAlert } = useToast();
const { projectDetails } = useProjectDetails();
const {
reset,
handleSubmit,
register,
setFocus,
formState: { errors, isSubmitting },
} = useForm<IIssue>({ defaultValues });
const handleClose = () => {
setIsOpen(false);
};
useKeypress("Escape", handleClose);
useOutsideClickDetector(ref, handleClose);
// derived values
const workspaceDetail = workspaceStore.getWorkspaceBySlug(workspaceSlug?.toString()!);
useEffect(() => {
if (!isOpen) reset({ ...defaultValues });
}, [isOpen, reset]);
useEffect(() => {
if (!errors) return;
Object.keys(errors).forEach((key) => {
const error = errors[key as keyof IIssue];
setToastAlert({
type: "error",
title: "Error!",
message: error?.message?.toString() || "Some error occurred. Please try again.",
});
});
}, [errors, setToastAlert]);
const isSpaceOnRight = useCheckIfThereIsSpaceOnRight(ref, dependencies);
const onSubmitHandler = async (formData: IIssue) => {
if (isSubmitting || !workspaceSlug || !projectId) return;
// resetting the form so that user can add another issue quickly
reset({ ...defaultValues, ...(prePopulatedData ?? {}) });
const payload = createIssuePayload(workspaceDetail!, projectDetails!, {
...(prePopulatedData ?? {}),
...formData,
labels_list:
formData.labels_list?.length !== 0
? formData.labels_list
: prePopulatedData?.labels && prePopulatedData?.labels.toString() !== "none"
? [prePopulatedData.labels as any]
: [],
assignees_list:
formData.assignees_list?.length !== 0
? formData.assignees_list
: prePopulatedData?.assignees && prePopulatedData?.assignees.toString() !== "none"
? [prePopulatedData.assignees as any]
: [],
});
try {
quickAddStore.createIssue(
workspaceSlug.toString(),
projectId.toString(),
{
group_id: groupId ?? null,
sub_group_id: null,
},
payload
);
setToastAlert({
type: "success",
title: "Success!",
message: "Issue created successfully.",
});
} catch (err: any) {
Object.keys(err || {}).forEach((key) => {
const error = err?.[key];
const errorTitle = error ? (Array.isArray(error) ? error.join(", ") : error) : null;
setToastAlert({
type: "error",
title: "Error!",
message: errorTitle || "Some error occurred. Please try again.",
});
});
}
};
return (
<>
<Transition
show={isOpen}
enter="transition ease-in-out duration-200 transform"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="transition ease-in-out duration-200 transform"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<div
ref={ref}
className={`transition-all z-20 w-full ${
isOpen ? "opacity-100 scale-100" : "opacity-0 pointer-events-none scale-95"
}`}
>
<form
onSubmit={handleSubmit(onSubmitHandler)}
className="flex w-full px-1.5 border-[0.5px] border-custom-border-100 rounded z-50 items-center gap-x-2 bg-custom-background-100 shadow-custom-shadow-sm transition-opacity"
>
<Inputs register={register} setFocus={setFocus} projectDetails={projectDetails} />
</form>
</div>
</Transition>
{!isOpen && (
<div className="hidden group-hover:block border-[0.5px] border-custom-border-200 rounded">
<button
type="button"
className="w-full flex items-center gap-x-[6px] text-custom-primary-100 px-1 py-1.5 rounded-md"
onClick={() => setIsOpen(true)}
>
<PlusIcon className="h-4 w-4" />
<span className="text-sm font-medium text-custom-primary-100">New Issue</span>
</button>
</div>
)}
</>
);
});

View File

@ -17,42 +17,44 @@ export const CalendarIssueBlocks: React.FC<Props> = observer((props) => {
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;
return ( return (
<div className="space-y-2 h-full w-full overflow-y-auto p-0.5"> <>
{issues?.map((issue, index) => ( {issues?.map((issue, index) => (
<Draggable key={issue.id} draggableId={issue.id} index={index}> <Draggable key={issue.id} draggableId={issue.id} index={index}>
{(provided, snapshot) => ( {(provided, snapshot) => (
<Link href={`/${workspaceSlug?.toString()}/projects/${issue.project}/issues/${issue.id}`}> <div
<a className="p-1 px-2 relative"
className={`group/calendar-block h-8 w-full shadow-custom-shadow-2xs rounded py-1.5 px-1 flex items-center gap-1.5 border-[0.5px] border-custom-border-100 ${ {...provided.draggableProps}
snapshot.isDragging {...provided.dragHandleProps}
? "shadow-custom-shadow-rg bg-custom-background-90" ref={provided.innerRef}
: "bg-custom-background-100 hover:bg-custom-background-90" >
}`} {issue?.tempId !== undefined && (
{...provided.draggableProps} <div className="absolute top-0 left-0 w-full h-full animate-pulse bg-custom-background-100/20 z-[99999]" />
{...provided.dragHandleProps} )}
ref={provided.innerRef} <Link href={`/${workspaceSlug?.toString()}/projects/${issue.project}/issues/${issue.id}`}>
> <a
<span className={`group/calendar-block h-8 w-full shadow-custom-shadow-2xs rounded py-1.5 px-1 flex items-center gap-1.5 border-[0.5px] border-custom-border-100 ${
className="h-full w-0.5 rounded flex-shrink-0" snapshot.isDragging
style={{ ? "shadow-custom-shadow-rg bg-custom-background-90"
backgroundColor: issue.state_detail.color, : "bg-custom-background-100 hover:bg-custom-background-90"
}} }`}
/> >
<div className="text-xs text-custom-text-300 flex-shrink-0"> <span
{issue.project_detail.identifier}-{issue.sequence_id} className="h-full w-0.5 rounded flex-shrink-0"
</div> style={{
<h6 className="text-xs flex-grow truncate">{issue.name}</h6> backgroundColor: issue.state_detail.color,
<div className="hidden group-hover/calendar-block:block">{quickActions(issue)}</div> }}
{/* <IssueQuickActions />
issue={issue} <div className="text-xs text-custom-text-300 flex-shrink-0">
handleDelete={async () => handleIssues(issue.target_date ?? "", issue, "delete")} {issue.project_detail.identifier}-{issue.sequence_id}
handleUpdate={async (data) => handleIssues(issue.target_date ?? "", data, "update")} </div>
/> */} <h6 className="text-xs flex-grow truncate">{issue.name}</h6>
</a> <div className="hidden group-hover/calendar-block:block">{quickActions(issue)}</div>
</Link> </a>
</Link>
</div>
)} )}
</Draggable> </Draggable>
))} ))}
</div> </>
); );
}); });

View File

@ -11,12 +11,16 @@ import { IIssueGroupedStructure } from "store/issue";
import { IIssue } from "types"; import { IIssue } from "types";
export const CycleCalendarLayout: React.FC = observer(() => { export const CycleCalendarLayout: React.FC = observer(() => {
const { cycleIssue: cycleIssueStore, issueFilter: issueFilterStore, issueDetail: issueDetailStore } = useMobxStore(); const {
cycleIssue: cycleIssueStore,
issueFilter: issueFilterStore,
issueDetail: issueDetailStore,
cycleIssueCalendarView: cycleIssueCalendarViewStore,
} = useMobxStore();
const router = useRouter(); const router = useRouter();
const { workspaceSlug, cycleId } = router.query; const { workspaceSlug, cycleId } = router.query;
// TODO: add drag and drop functionality
const onDragEnd = (result: DropResult) => { const onDragEnd = (result: DropResult) => {
if (!result) return; if (!result) return;
@ -26,7 +30,7 @@ export const CycleCalendarLayout: React.FC = observer(() => {
// return if dropped on the same date // return if dropped on the same date
if (result.destination.droppableId === result.source.droppableId) return; if (result.destination.droppableId === result.source.droppableId) return;
// issueKanBanViewStore?.handleDragDrop(result.source, result.destination); cycleIssueCalendarViewStore?.handleDragDrop(result.source, result.destination);
}; };
const issues = cycleIssueStore.getIssues; const issues = cycleIssueStore.getIssues;

View File

@ -15,12 +15,12 @@ export const ModuleCalendarLayout: React.FC = observer(() => {
moduleIssue: moduleIssueStore, moduleIssue: moduleIssueStore,
issueFilter: issueFilterStore, issueFilter: issueFilterStore,
issueDetail: issueDetailStore, issueDetail: issueDetailStore,
moduleIssueCalendarView: moduleIssueCalendarViewStore,
} = useMobxStore(); } = useMobxStore();
const router = useRouter(); const router = useRouter();
const { workspaceSlug, moduleId } = router.query; const { workspaceSlug, moduleId } = router.query;
// TODO: add drag and drop functionality
const onDragEnd = (result: DropResult) => { const onDragEnd = (result: DropResult) => {
if (!result) return; if (!result) return;
@ -30,7 +30,7 @@ export const ModuleCalendarLayout: React.FC = observer(() => {
// return if dropped on the same date // return if dropped on the same date
if (result.destination.droppableId === result.source.droppableId) return; if (result.destination.droppableId === result.source.droppableId) return;
// issueKanBanViewStore?.handleDragDrop(result.source, result.destination); moduleIssueCalendarViewStore?.handleDragDrop(result.source, result.destination);
}; };
const issues = moduleIssueStore.getIssues; const issues = moduleIssueStore.getIssues;

View File

@ -11,12 +11,16 @@ import { IIssueGroupedStructure } from "store/issue";
import { IIssue } from "types"; import { IIssue } from "types";
export const CalendarLayout: React.FC = observer(() => { export const CalendarLayout: React.FC = observer(() => {
const { issue: issueStore, issueFilter: issueFilterStore, issueDetail: issueDetailStore } = useMobxStore(); const {
issue: issueStore,
issueFilter: issueFilterStore,
issueDetail: issueDetailStore,
issueCalendarView: issueCalendarViewStore,
} = useMobxStore();
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;
// TODO: add drag and drop functionality
const onDragEnd = (result: DropResult) => { const onDragEnd = (result: DropResult) => {
if (!result) return; if (!result) return;
@ -26,7 +30,7 @@ export const CalendarLayout: React.FC = observer(() => {
// return if dropped on the same date // return if dropped on the same date
if (result.destination.droppableId === result.source.droppableId) return; if (result.destination.droppableId === result.source.droppableId) return;
// issueKanBanViewStore?.handleDragDrop(result.source, result.destination); issueCalendarViewStore?.handleDragDrop(result.source, result.destination);
}; };
const issues = issueStore.getIssues; const issues = issueStore.getIssues;

View File

@ -15,12 +15,12 @@ export const ProjectViewCalendarLayout: React.FC = observer(() => {
projectViewIssues: projectViewIssuesStore, projectViewIssues: projectViewIssuesStore,
issueFilter: issueFilterStore, issueFilter: issueFilterStore,
issueDetail: issueDetailStore, issueDetail: issueDetailStore,
projectViewIssueCalendarView: projectViewIssueCalendarViewStore,
} = useMobxStore(); } = useMobxStore();
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;
// TODO: add drag and drop functionality
const onDragEnd = (result: DropResult) => { const onDragEnd = (result: DropResult) => {
if (!result) return; if (!result) return;
@ -30,7 +30,7 @@ export const ProjectViewCalendarLayout: React.FC = observer(() => {
// return if dropped on the same date // return if dropped on the same date
if (result.destination.droppableId === result.source.droppableId) return; if (result.destination.droppableId === result.source.droppableId) return;
// issueKanBanViewStore?.handleDragDrop(result.source, result.destination); projectViewIssueCalendarViewStore?.handleDragDrop(result.source, result.destination);
}; };
const issues = projectViewIssuesStore.getIssues; const issues = projectViewIssuesStore.getIssues;

View File

@ -15,10 +15,11 @@ type Props = {
issues: IIssueGroupedStructure | null; issues: IIssueGroupedStructure | null;
week: ICalendarWeek | undefined; week: ICalendarWeek | undefined;
quickActions: (issue: IIssue) => React.ReactNode; quickActions: (issue: IIssue) => React.ReactNode;
enableQuickIssueCreate?: boolean;
}; };
export const CalendarWeekDays: React.FC<Props> = observer((props) => { export const CalendarWeekDays: React.FC<Props> = observer((props) => {
const { issues, week, quickActions } = props; const { issues, week, quickActions, enableQuickIssueCreate } = props;
const { issueFilter: issueFilterStore } = useMobxStore(); const { issueFilter: issueFilterStore } = useMobxStore();
@ -37,7 +38,13 @@ export const CalendarWeekDays: React.FC<Props> = observer((props) => {
if (!showWeekends && (date.date.getDay() === 0 || date.date.getDay() === 6)) return null; if (!showWeekends && (date.date.getDay() === 0 || date.date.getDay() === 6)) return null;
return ( return (
<CalendarDayTile key={renderDateFormat(date.date)} date={date} issues={issues} quickActions={quickActions} /> <CalendarDayTile
key={renderDateFormat(date.date)}
date={date}
issues={issues}
quickActions={quickActions}
enableQuickIssueCreate={enableQuickIssueCreate}
/>
); );
})} })}
</div> </div>

View File

@ -3,3 +3,4 @@ export * from "./cycle-root";
export * from "./module-root"; export * from "./module-root";
export * from "./project-view-root"; export * from "./project-view-root";
export * from "./root"; export * from "./root";
export * from "./inline-create-issue-form";

View File

@ -0,0 +1,196 @@
import { useEffect, useState, useRef } from "react";
import { useRouter } from "next/router";
import { useForm } from "react-hook-form";
import { Transition } from "@headlessui/react";
import { PlusIcon } from "lucide-react";
// store
import { observer } from "mobx-react-lite";
import { useMobxStore } from "lib/mobx/store-provider";
// constants
import { createIssuePayload } from "constants/issue";
// hooks
import useToast from "hooks/use-toast";
import useKeypress from "hooks/use-keypress";
import useProjectDetails from "hooks/use-project-details";
import useOutsideClickDetector from "hooks/use-outside-click-detector";
// types
import { IIssue } from "types";
import { renderDateFormat } from "helpers/date-time.helper";
type Props = {
prePopulatedData?: Partial<IIssue>;
onSuccess?: (data: IIssue) => Promise<void> | void;
};
const defaultValues: Partial<IIssue> = {
name: "",
};
const Inputs = (props: any) => {
const { register, setFocus } = props;
useEffect(() => {
setFocus("name");
}, [setFocus]);
return (
<input
type="text"
autoComplete="off"
placeholder="Issue Title"
{...register("name", {
required: "Issue title is required.",
})}
className="w-full px-2 rounded-md bg-transparent text-sm font-medium leading-5 text-custom-text-200 outline-none"
/>
);
};
export const GanttInlineCreateIssueForm: React.FC<Props> = observer((props) => {
const { prePopulatedData } = props;
// router
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
// store
const { workspace: workspaceStore, quickAddIssue: quickAddStore } = useMobxStore();
const { projectDetails } = useProjectDetails();
const {
reset,
handleSubmit,
setFocus,
register,
formState: { errors, isSubmitting },
} = useForm<IIssue>({ defaultValues });
// ref
const ref = useRef<HTMLFormElement>(null);
// states
const [isOpen, setIsOpen] = useState(false);
const handleClose = () => setIsOpen(false);
// hooks
useKeypress("Escape", handleClose);
useOutsideClickDetector(ref, handleClose);
const { setToastAlert } = useToast();
// derived values
const workspaceDetail = workspaceStore.getWorkspaceBySlug(workspaceSlug?.toString()!);
useEffect(() => {
if (!isOpen) reset({ ...defaultValues });
}, [isOpen, reset]);
useEffect(() => {
if (!errors) return;
Object.keys(errors).forEach((key) => {
const error = errors[key as keyof IIssue];
setToastAlert({
type: "error",
title: "Error!",
message: error?.message?.toString() || "Some error occurred. Please try again.",
});
});
}, [errors, setToastAlert]);
const onSubmitHandler = async (formData: IIssue) => {
if (isSubmitting || !workspaceSlug || !projectId) return;
// resetting the form so that user can add another issue quickly
reset({ ...defaultValues, ...(prePopulatedData ?? {}) });
const payload = createIssuePayload(workspaceDetail!, projectDetails!, {
...(prePopulatedData ?? {}),
...formData,
labels_list:
formData.labels_list?.length !== 0
? formData.labels_list
: prePopulatedData?.labels && prePopulatedData?.labels.toString() !== "none"
? [prePopulatedData.labels as any]
: [],
start_date: renderDateFormat(new Date()),
target_date: renderDateFormat(new Date(new Date().getTime() + 24 * 60 * 60 * 1000)),
});
try {
quickAddStore.createIssue(
workspaceSlug.toString(),
projectId.toString(),
{
group_id: null,
sub_group_id: null,
},
payload
);
setToastAlert({
type: "success",
title: "Success!",
message: "Issue created successfully.",
});
} catch (err: any) {
Object.keys(err || {}).forEach((key) => {
const error = err?.[key];
const errorTitle = error ? (Array.isArray(error) ? error.join(", ") : error) : null;
setToastAlert({
type: "error",
title: "Error!",
message: errorTitle || "Some error occurred. Please try again.",
});
});
}
};
return (
<>
<Transition
show={isOpen}
enter="transition ease-in-out duration-200 transform"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="transition ease-in-out duration-200 transform"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<form
ref={ref}
className="flex py-3 px-4 border-[0.5px] border-custom-border-100 mr-2.5 items-center rounded gap-x-2 bg-custom-background-100 shadow-custom-shadow-sm"
onSubmit={handleSubmit(onSubmitHandler)}
>
<div className="w-[14px] h-[14px] rounded-full border border-custom-border-1000 flex-shrink-0" />
<h4 className="text-sm text-custom-text-400">{projectDetails?.identifier ?? "..."}</h4>
<Inputs register={register} setFocus={setFocus} />
</form>
</Transition>
{isOpen && (
<p className="text-xs ml-3 mt-3 italic text-custom-text-200">
Press {"'"}Enter{"'"} to add another issue
</p>
)}
{!isOpen && (
<button
type="button"
className="flex items-center gap-x-[6px] text-custom-primary-100 px-2 py-1 rounded-md"
onClick={() => setIsOpen(true)}
>
<PlusIcon className="h-4 w-4" />
<span className="text-sm font-medium text-custom-primary-100">New Issue</span>
</button>
)}
</>
);
});

View File

@ -2,7 +2,7 @@ import { Draggable } from "@hello-pangea/dnd";
// components // components
import { KanBanProperties } from "./properties"; import { KanBanProperties } from "./properties";
// types // types
import { IIssue } from "types"; import { IEstimatePoint, IIssue, IIssueLabels, IState, IUserLite } from "types";
interface IssueBlockProps { interface IssueBlockProps {
sub_group_id: string; sub_group_id: string;
@ -18,10 +18,27 @@ interface IssueBlockProps {
) => void; ) => void;
quickActions: (sub_group_by: string | null, group_by: string | null, issue: IIssue) => React.ReactNode; quickActions: (sub_group_by: string | null, group_by: string | null, issue: IIssue) => React.ReactNode;
displayProperties: any; displayProperties: any;
states: IState[] | null;
labels: IIssueLabels[] | null;
members: IUserLite[] | null;
estimates: IEstimatePoint[] | null;
} }
export const KanbanIssueBlock: React.FC<IssueBlockProps> = (props) => { export const KanbanIssueBlock: React.FC<IssueBlockProps> = (props) => {
const { sub_group_id, columnId, index, issue, isDragDisabled, handleIssues, quickActions, displayProperties } = props; const {
sub_group_id,
columnId,
index,
issue,
isDragDisabled,
handleIssues,
quickActions,
displayProperties,
states,
labels,
members,
estimates,
} = props;
const updateIssue = (sub_group_by: string | null, group_by: string | null, issueToUpdate: IIssue) => { const updateIssue = (sub_group_by: string | null, group_by: string | null, issueToUpdate: IIssue) => {
if (issueToUpdate) handleIssues(sub_group_by, group_by, issueToUpdate, "update"); if (issueToUpdate) handleIssues(sub_group_by, group_by, issueToUpdate, "update");
@ -37,6 +54,9 @@ export const KanbanIssueBlock: React.FC<IssueBlockProps> = (props) => {
{...provided.dragHandleProps} {...provided.dragHandleProps}
ref={provided.innerRef} ref={provided.innerRef}
> >
{issue.tempId !== undefined && (
<div className="absolute top-0 left-0 w-full h-full animate-pulse bg-custom-background-100/20 z-[99999]" />
)}
<div className="absolute top-3 right-3 hidden group-hover/kanban-block:block"> <div className="absolute top-3 right-3 hidden group-hover/kanban-block:block">
{quickActions( {quickActions(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id, !sub_group_id && sub_group_id === "null" ? null : sub_group_id,
@ -54,7 +74,7 @@ export const KanbanIssueBlock: React.FC<IssueBlockProps> = (props) => {
{issue.project_detail.identifier}-{issue.sequence_id} {issue.project_detail.identifier}-{issue.sequence_id}
</div> </div>
)} )}
<div className="line-clamp-2 h-[40px] text-sm font-medium text-custom-text-100">{issue.name}</div> <div className="line-clamp-2 text-sm font-medium text-custom-text-100">{issue.name}</div>
<div> <div>
<KanBanProperties <KanBanProperties
sub_group_id={sub_group_id} sub_group_id={sub_group_id}
@ -62,6 +82,10 @@ export const KanbanIssueBlock: React.FC<IssueBlockProps> = (props) => {
issue={issue} issue={issue}
handleIssues={updateIssue} handleIssues={updateIssue}
display_properties={displayProperties} display_properties={displayProperties}
states={states}
labels={labels}
members={members}
estimates={estimates}
/> />
</div> </div>
</div> </div>

View File

@ -1,6 +1,6 @@
// components // components
import { KanbanIssueBlock } from "components/issues"; import { KanbanIssueBlock } from "components/issues";
import { IIssue } from "types"; import { IEstimatePoint, IIssue, IIssueLabels, IState, IUserLite } from "types";
interface IssueBlocksListProps { interface IssueBlocksListProps {
sub_group_id: string; sub_group_id: string;
@ -15,10 +15,26 @@ interface IssueBlocksListProps {
) => void; ) => void;
quickActions: (sub_group_by: string | null, group_by: string | null, issue: IIssue) => React.ReactNode; quickActions: (sub_group_by: string | null, group_by: string | null, issue: IIssue) => React.ReactNode;
display_properties: any; display_properties: any;
states: IState[] | null;
labels: IIssueLabels[] | null;
members: IUserLite[] | null;
estimates: IEstimatePoint[] | null;
} }
export const KanbanIssueBlocksList: React.FC<IssueBlocksListProps> = (props) => { export const KanbanIssueBlocksList: React.FC<IssueBlocksListProps> = (props) => {
const { sub_group_id, columnId, issues, isDragDisabled, handleIssues, quickActions, display_properties } = props; const {
sub_group_id,
columnId,
issues,
isDragDisabled,
handleIssues,
quickActions,
display_properties,
states,
labels,
members,
estimates,
} = props;
return ( return (
<> <>
@ -35,6 +51,10 @@ export const KanbanIssueBlocksList: React.FC<IssueBlocksListProps> = (props) =>
columnId={columnId} columnId={columnId}
sub_group_id={sub_group_id} sub_group_id={sub_group_id}
isDragDisabled={isDragDisabled} isDragDisabled={isDragDisabled}
states={states}
labels={labels}
members={members}
estimates={estimates}
/> />
))} ))}
</> </>

View File

@ -5,9 +5,9 @@ import { Droppable } from "@hello-pangea/dnd";
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { KanBanGroupByHeaderRoot } from "./headers/group-by-root"; import { KanBanGroupByHeaderRoot } from "./headers/group-by-root";
import { KanbanIssueBlocksList } from "components/issues"; import { KanbanIssueBlocksList, BoardInlineCreateIssueForm } from "components/issues";
// types // types
import { IIssue } from "types"; import { IEstimatePoint, IIssue, IIssueLabels, IProject, IState, IUserLite } from "types";
// constants // constants
import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES, getValueFromObject } from "constants/issue"; import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES, getValueFromObject } from "constants/issue";
@ -29,6 +29,12 @@ export interface IGroupByKanBan {
display_properties: any; display_properties: any;
kanBanToggle: any; kanBanToggle: any;
handleKanBanToggle: any; handleKanBanToggle: any;
enableQuickIssueCreate?: boolean;
states: IState[] | null;
labels: IIssueLabels[] | null;
members: IUserLite[] | null;
priorities: any;
estimates: IEstimatePoint[] | null;
} }
const GroupByKanBan: React.FC<IGroupByKanBan> = observer((props) => { const GroupByKanBan: React.FC<IGroupByKanBan> = observer((props) => {
@ -45,6 +51,12 @@ const GroupByKanBan: React.FC<IGroupByKanBan> = observer((props) => {
display_properties, display_properties,
kanBanToggle, kanBanToggle,
handleKanBanToggle, handleKanBanToggle,
states,
labels,
members,
priorities,
estimates,
enableQuickIssueCreate,
} = props; } = props;
const verticalAlignPosition = (_list: any) => const verticalAlignPosition = (_list: any) =>
@ -93,6 +105,10 @@ const GroupByKanBan: React.FC<IGroupByKanBan> = observer((props) => {
handleIssues={handleIssues} handleIssues={handleIssues}
quickActions={quickActions} quickActions={quickActions}
display_properties={display_properties} display_properties={display_properties}
states={states}
labels={labels}
members={members}
estimates={estimates}
/> />
) : ( ) : (
isDragDisabled && ( isDragDisabled && (
@ -106,6 +122,16 @@ const GroupByKanBan: React.FC<IGroupByKanBan> = observer((props) => {
)} )}
</Droppable> </Droppable>
</div> </div>
{enableQuickIssueCreate && (
<BoardInlineCreateIssueForm
groupId={getValueFromObject(_list, listKey) as string}
subGroupId={sub_group_id}
prePopulatedData={{
...(group_by && { [group_by]: getValueFromObject(_list, listKey) }),
...(sub_group_by && sub_group_id !== "null" && { [sub_group_by]: sub_group_id }),
}}
/>
)}
</div> </div>
))} ))}
</div> </div>
@ -128,14 +154,14 @@ export interface IKanBan {
display_properties: any; display_properties: any;
kanBanToggle: any; kanBanToggle: any;
handleKanBanToggle: any; handleKanBanToggle: any;
states: IState[] | null;
states: any;
stateGroups: any; stateGroups: any;
priorities: any; priorities: any;
labels: any; labels: IIssueLabels[] | null;
members: any; members: IUserLite[] | null;
projects: any; projects: IProject[] | null;
estimates: any; estimates: IEstimatePoint[] | null;
enableQuickIssueCreate?: boolean;
} }
export const KanBan: React.FC<IKanBan> = observer((props) => { export const KanBan: React.FC<IKanBan> = observer((props) => {
@ -156,6 +182,7 @@ export const KanBan: React.FC<IKanBan> = observer((props) => {
members, members,
projects, projects,
estimates, estimates,
enableQuickIssueCreate,
} = props; } = props;
const { project: projectStore, issueKanBanView: issueKanBanViewStore } = useMobxStore(); const { project: projectStore, issueKanBanView: issueKanBanViewStore } = useMobxStore();
@ -176,6 +203,12 @@ export const KanBan: React.FC<IKanBan> = observer((props) => {
display_properties={display_properties} display_properties={display_properties}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
enableQuickIssueCreate={enableQuickIssueCreate}
states={states}
labels={labels}
members={members}
priorities={priorities}
estimates={estimates}
/> />
)} )}
@ -193,6 +226,12 @@ export const KanBan: React.FC<IKanBan> = observer((props) => {
display_properties={display_properties} display_properties={display_properties}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
enableQuickIssueCreate={enableQuickIssueCreate}
states={states}
labels={labels}
members={members}
priorities={priorities}
estimates={estimates}
/> />
)} )}
@ -210,6 +249,12 @@ export const KanBan: React.FC<IKanBan> = observer((props) => {
display_properties={display_properties} display_properties={display_properties}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
enableQuickIssueCreate={enableQuickIssueCreate}
states={states}
labels={labels}
members={members}
priorities={priorities}
estimates={estimates}
/> />
)} )}
@ -227,6 +272,12 @@ export const KanBan: React.FC<IKanBan> = observer((props) => {
display_properties={display_properties} display_properties={display_properties}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
enableQuickIssueCreate={enableQuickIssueCreate}
states={states}
labels={labels}
members={members}
priorities={priorities}
estimates={estimates}
/> />
)} )}
@ -244,6 +295,12 @@ export const KanBan: React.FC<IKanBan> = observer((props) => {
display_properties={display_properties} display_properties={display_properties}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
enableQuickIssueCreate={enableQuickIssueCreate}
states={states}
labels={labels}
members={members}
priorities={priorities}
estimates={estimates}
/> />
)} )}
@ -261,6 +318,12 @@ export const KanBan: React.FC<IKanBan> = observer((props) => {
display_properties={display_properties} display_properties={display_properties}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
enableQuickIssueCreate={enableQuickIssueCreate}
states={states}
labels={labels}
members={members}
priorities={priorities}
estimates={estimates}
/> />
)} )}
</div> </div>

View File

@ -1,5 +1,4 @@
export * from "./block"; export * from "./block";
export * from "./roots";
export * from "./blocks-list"; export * from "./blocks-list";
export * from "./cycle-root"; export * from "./inline-create-issue-form";
export * from "./module-root";
export * from "./root";

View File

@ -0,0 +1,202 @@
import { useEffect, useState, useRef } from "react";
import { useRouter } from "next/router";
import { useForm } from "react-hook-form";
import { Transition } from "@headlessui/react";
import { PlusIcon } from "lucide-react";
// store
import { observer } from "mobx-react-lite";
import { useMobxStore } from "lib/mobx/store-provider";
// hooks
import useToast from "hooks/use-toast";
import useKeypress from "hooks/use-keypress";
import useProjectDetails from "hooks/use-project-details";
import useOutsideClickDetector from "hooks/use-outside-click-detector";
// constants
import { createIssuePayload } from "constants/issue";
// types
import { IIssue } from "types";
type Props = {
groupId?: string;
subGroupId?: string;
prePopulatedData?: Partial<IIssue>;
onSuccess?: (data: IIssue) => Promise<void> | void;
};
const defaultValues: Partial<IIssue> = {
name: "",
};
const Inputs = (props: any) => {
const { register, setFocus, projectDetails } = props;
useEffect(() => {
setFocus("name");
}, [setFocus]);
return (
<div>
<h4 className="text-sm font-medium leading-5 text-custom-text-300">{projectDetails?.identifier ?? "..."}</h4>
<input
autoComplete="off"
placeholder="Issue Title"
{...register("name", {
required: "Issue title is required.",
})}
className="w-full px-2 pl-0 py-1.5 rounded-md bg-transparent text-sm font-medium leading-5 text-custom-text-200 outline-none"
/>
</div>
);
};
export const BoardInlineCreateIssueForm: React.FC<Props> = observer((props) => {
const { prePopulatedData, groupId, subGroupId } = props;
// router
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
// store
const { workspace: workspaceStore, quickAddIssue: quickAddStore } = useMobxStore();
// ref
const ref = useRef<HTMLFormElement>(null);
// states
const [isOpen, setIsOpen] = useState(false);
const { setToastAlert } = useToast();
const { projectDetails } = useProjectDetails();
const {
reset,
handleSubmit,
register,
setFocus,
formState: { errors, isSubmitting },
} = useForm<IIssue>({ defaultValues });
const handleClose = () => {
setIsOpen(false);
};
useKeypress("Escape", handleClose);
useOutsideClickDetector(ref, handleClose);
// derived values
const workspaceDetail = workspaceStore.getWorkspaceBySlug(workspaceSlug?.toString()!);
useEffect(() => {
if (!isOpen) reset({ ...defaultValues });
}, [isOpen, reset]);
useEffect(() => {
if (!errors) return;
Object.keys(errors).forEach((key) => {
const error = errors[key as keyof IIssue];
setToastAlert({
type: "error",
title: "Error!",
message: error?.message?.toString() || "Some error occurred. Please try again.",
});
});
}, [errors, setToastAlert]);
const onSubmitHandler = async (formData: IIssue) => {
if (isSubmitting || !workspaceSlug || !projectId) return;
// resetting the form so that user can add another issue quickly
reset({ ...defaultValues, ...(prePopulatedData ?? {}) });
const payload = createIssuePayload(workspaceDetail!, projectDetails!, {
...(prePopulatedData ?? {}),
...formData,
labels_list:
formData.labels_list && formData.labels_list.length !== 0
? formData.labels_list
: prePopulatedData?.labels && prePopulatedData?.labels.toString() !== "none"
? [prePopulatedData.labels as any]
: [],
assignees_list:
formData.assignees_list && formData.assignees_list.length !== 0
? formData.assignees_list
: prePopulatedData?.assignees && prePopulatedData?.assignees.toString() !== "none"
? [prePopulatedData.assignees as any]
: [],
});
try {
quickAddStore.createIssue(
workspaceSlug.toString(),
projectId.toString(),
{
group_id: groupId ?? null,
sub_group_id: subGroupId ?? null,
},
payload
);
setToastAlert({
type: "success",
title: "Success!",
message: "Issue created successfully.",
});
} catch (err: any) {
Object.keys(err || {}).forEach((key) => {
const error = err?.[key];
const errorTitle = error ? (Array.isArray(error) ? error.join(", ") : error) : null;
setToastAlert({
type: "error",
title: "Error!",
message: errorTitle || "Some error occurred. Please try again.",
});
});
}
};
return (
<div>
<Transition
show={isOpen}
enter="transition ease-in-out duration-200 transform"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="transition ease-in-out duration-200 transform"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<form
ref={ref}
onSubmit={handleSubmit(onSubmitHandler)}
className="flex flex-col border-[0.5px] border-custom-border-100 justify-between gap-1.5 group/card relative select-none px-3.5 py-3 h-[118px] mb-3 rounded bg-custom-background-100 shadow-custom-shadow-sm"
>
<Inputs register={register} setFocus={setFocus} projectDetails={projectDetails} />
</form>
</Transition>
{isOpen && (
<p className="text-xs ml-3 italic text-custom-text-200">
Press {"'"}Enter{"'"} to add another issue
</p>
)}
{!isOpen && (
<button
type="button"
className="flex items-center gap-x-[6px] text-custom-primary-100 px-2 py-1 rounded-md"
onClick={() => setIsOpen(true)}
>
<PlusIcon className="h-4 w-4" />
<span className="text-sm font-medium text-custom-primary-100">New Issue</span>
</button>
)}
</div>
);
});

View File

@ -10,190 +10,196 @@ import { IssuePropertyAssignee } from "../properties/assignee";
import { IssuePropertyEstimates } from "../properties/estimates"; import { IssuePropertyEstimates } from "../properties/estimates";
import { IssuePropertyDate } from "../properties/date"; import { IssuePropertyDate } from "../properties/date";
import { Tooltip } from "@plane/ui"; import { Tooltip } from "@plane/ui";
import { IEstimatePoint, IIssue, IIssueLabels, IState, IUserLite, TIssuePriorities } from "types";
export interface IKanBanProperties { export interface IKanBanProperties {
sub_group_id: string; sub_group_id: string;
columnId: string; columnId: string;
issue: any; issue: IIssue;
handleIssues?: (sub_group_by: string | null, group_by: string | null, issue: any) => void; handleIssues: (sub_group_by: string | null, group_by: string | null, issue: IIssue) => void;
display_properties: any; display_properties: any;
states: IState[] | null;
labels: IIssueLabels[] | null;
members: IUserLite[] | null;
estimates: IEstimatePoint[] | null;
} }
export const KanBanProperties: React.FC<IKanBanProperties> = observer( export const KanBanProperties: React.FC<IKanBanProperties> = observer((props) => {
({ sub_group_id, columnId: group_id, issue, handleIssues, display_properties }) => { const {
const handleState = (id: string) => { sub_group_id,
if (handleIssues) columnId: group_id,
handleIssues( issue,
!sub_group_id && sub_group_id === "null" ? null : sub_group_id, handleIssues,
!group_id && group_id === "null" ? null : group_id, display_properties,
{ ...issue, state: id } states,
); labels,
}; members,
estimates,
} = props;
const handlePriority = (id: string) => { const handleState = (state: IState) => {
if (handleIssues) handleIssues(
handleIssues( !sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!sub_group_id && sub_group_id === "null" ? null : sub_group_id, !group_id && group_id === "null" ? null : group_id,
!group_id && group_id === "null" ? null : group_id, { ...issue, state: state.id }
{ ...issue, priority: id }
);
};
const handleLabel = (ids: string[]) => {
if (handleIssues)
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, labels: ids }
);
};
const handleAssignee = (ids: string[]) => {
if (handleIssues)
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, assignees: ids }
);
};
const handleStartDate = (date: string) => {
if (handleIssues)
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, start_date: date }
);
};
const handleTargetDate = (date: string) => {
if (handleIssues)
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, target_date: date }
);
};
const handleEstimate = (id: string) => {
if (handleIssues)
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, estimate_point: id }
);
};
return (
<div className="relative flex gap-2 overflow-x-auto whitespace-nowrap">
{/* basic properties */}
{/* state */}
{display_properties && display_properties?.state && (
<IssuePropertyState
value={issue?.state || null}
dropdownArrow={false}
onChange={(id: string) => handleState(id)}
disabled={false}
/>
)}
{/* priority */}
{display_properties && display_properties?.priority && (
<IssuePropertyPriority
value={issue?.priority || null}
dropdownArrow={false}
onChange={(id: string) => handlePriority(id)}
disabled={false}
/>
)}
{/* label */}
{display_properties && display_properties?.labels && (
<IssuePropertyLabels
value={issue?.labels || null}
dropdownArrow={false}
onChange={(ids: string[]) => handleLabel(ids)}
disabled={false}
/>
)}
{/* assignee */}
{display_properties && display_properties?.assignee && (
<IssuePropertyAssignee
value={issue?.assignees || null}
dropdownArrow={false}
onChange={(ids: string[]) => handleAssignee(ids)}
disabled={false}
/>
)}
{/* start date */}
{display_properties && display_properties?.start_date && (
<IssuePropertyDate
value={issue?.start_date || null}
onChange={(date: string) => handleStartDate(date)}
disabled={false}
/>
)}
{/* target/due date */}
{display_properties && display_properties?.due_date && (
<IssuePropertyDate
value={issue?.target_date || null}
onChange={(date: string) => handleTargetDate(date)}
disabled={false}
/>
)}
{/* estimates */}
{display_properties && display_properties?.estimate && (
<IssuePropertyEstimates
value={issue?.estimate_point?.toString() || null}
dropdownArrow={false}
onChange={(id: string) => handleEstimate(id)}
disabled={false}
workspaceSlug={issue?.workspace_detail?.slug || null}
projectId={issue?.project_detail?.id || null}
/>
)}
{/* extra render properties */}
{/* sub-issues */}
{display_properties && display_properties?.sub_issue_count && (
<Tooltip tooltipHeading="Sub-issue" tooltipContent={`${issue.sub_issues_count}`}>
<div className="flex-shrink-0 border border-custom-border-300 min-w-[22px] h-[22px] overflow-hidden rounded-sm flex justify-center items-center cursor-pointer">
<div className="flex-shrink-0 w-[16px] h-[16px] flex justify-center items-center">
<Layers width={10} strokeWidth={2} />
</div>
<div className="pl-0.5 pr-1 text-xs">{issue.sub_issues_count}</div>
</div>
</Tooltip>
)}
{/* attachments */}
{display_properties && display_properties?.attachment_count && (
<Tooltip tooltipHeading="Attachments" tooltipContent={`${issue.attachment_count}`}>
<div className="flex-shrink-0 border border-custom-border-300 min-w-[22px] h-[22px] overflow-hidden rounded-sm flex justify-center items-center cursor-pointer">
<div className="flex-shrink-0 w-[16px] h-[16px] flex justify-center items-center">
<Paperclip width={10} strokeWidth={2} />
</div>
<div className="pl-0.5 pr-1 text-xs">{issue.attachment_count}</div>
</div>
</Tooltip>
)}
{/* link */}
{display_properties && display_properties?.link && (
<Tooltip tooltipHeading="Links" tooltipContent={`${issue.link_count}`}>
<div className="flex-shrink-0 border border-custom-border-300 min-w-[22px] h-[22px] overflow-hidden rounded-sm flex justify-center items-center cursor-pointer">
<div className="flex-shrink-0 w-[16px] h-[16px] flex justify-center items-center">
<Link width={10} strokeWidth={2} />
</div>
<div className="pl-0.5 pr-1 text-xs">{issue.link_count}</div>
</div>
</Tooltip>
)}
</div>
); );
} };
);
const handlePriority = (value: TIssuePriorities) => {
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, priority: value }
);
};
const handleLabel = (ids: string[]) => {
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, labels_list: ids }
);
};
const handleAssignee = (ids: string[]) => {
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, assignees_list: ids }
);
};
const handleStartDate = (date: string) => {
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, start_date: date }
);
};
const handleTargetDate = (date: string) => {
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, target_date: date }
);
};
const handleEstimate = (value: number | null) => {
handleIssues(
!sub_group_id && sub_group_id === "null" ? null : sub_group_id,
!group_id && group_id === "null" ? null : group_id,
{ ...issue, estimate_point: value }
);
};
return (
<div className="flex items-center gap-2 flex-wrap whitespace-nowrap">
{/* basic properties */}
{/* state */}
{display_properties && display_properties?.state && (
<IssuePropertyState
value={issue?.state_detail || null}
onChange={handleState}
states={states}
disabled={false}
hideDropdownArrow={true}
/>
)}
{/* priority */}
{display_properties && display_properties?.priority && (
<IssuePropertyPriority
value={issue?.priority || null}
onChange={handlePriority}
disabled={false}
hideDropdownArrow={true}
/>
)}
{/* label */}
{display_properties && display_properties?.labels && (
<IssuePropertyLabels
value={issue?.labels || null}
onChange={handleLabel}
labels={labels}
disabled={false}
hideDropdownArrow={true}
/>
)}
{/* assignee */}
{display_properties && display_properties?.assignee && (
<IssuePropertyAssignee
value={issue?.assignees || null}
hideDropdownArrow={true}
onChange={handleAssignee}
members={members}
disabled={false}
/>
)}
{/* start date */}
{display_properties && display_properties?.start_date && (
<IssuePropertyDate
value={issue?.start_date || null}
onChange={(date: string) => handleStartDate(date)}
disabled={false}
placeHolder="Start date"
/>
)}
{/* target/due date */}
{display_properties && display_properties?.due_date && (
<IssuePropertyDate
value={issue?.target_date || null}
onChange={(date: string) => handleTargetDate(date)}
disabled={false}
placeHolder="Target date"
/>
)}
{/* estimates */}
{display_properties && display_properties?.estimate && (
<IssuePropertyEstimates
value={issue?.estimate_point || null}
onChange={handleEstimate}
estimatePoints={estimates}
disabled={false}
hideDropdownArrow={true}
/>
)}
{/* extra render properties */}
{/* sub-issues */}
{display_properties && display_properties?.sub_issue_count && (
<Tooltip tooltipHeading="Sub-issues" tooltipContent={`${issue.sub_issues_count}`}>
<div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<Layers className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
<div className="text-xs">{issue.sub_issues_count}</div>
</div>
</Tooltip>
)}
{/* attachments */}
{display_properties && display_properties?.attachment_count && (
<Tooltip tooltipHeading="Attachments" tooltipContent={`${issue.attachment_count}`}>
<div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<Paperclip className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
<div className="text-xs">{issue.attachment_count}</div>
</div>
</Tooltip>
)}
{/* link */}
{display_properties && display_properties?.link && (
<Tooltip tooltipHeading="Links" tooltipContent={`${issue.link_count}`}>
<div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<Link className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
<div className="text-xs">{issue.link_count}</div>
</div>
</Tooltip>
)}
</div>
);
});

View File

@ -5,9 +5,11 @@ import { DragDropContext } from "@hello-pangea/dnd";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { KanBanSwimLanes } from "./swimlanes"; import { KanBanSwimLanes } from "../swimlanes";
import { KanBan } from "./default"; import { KanBan } from "../default";
import { CycleIssueQuickActions } from "components/issues"; import { CycleIssueQuickActions } from "components/issues";
// helpers
import { orderArrayBy } from "helpers/array.helper";
// types // types
import { IIssue } from "types"; import { IIssue } from "types";
// constants // constants
@ -25,7 +27,7 @@ export const CycleKanBanLayout: React.FC = observer(() => {
} = useMobxStore(); } = useMobxStore();
const router = useRouter(); const router = useRouter();
const { workspaceSlug, cycleId } = router.query; const { workspaceSlug, projectId, cycleId } = router.query;
const issues = cycleIssueStore?.getIssues; const issues = cycleIssueStore?.getIssues;
@ -60,12 +62,12 @@ export const CycleKanBanLayout: React.FC = observer(() => {
if (!workspaceSlug || !cycleId) return; if (!workspaceSlug || !cycleId) return;
if (action === "update") { if (action === "update") {
cycleIssueStore.updateIssueStructure(group_by, null, issue); cycleIssueStore.updateIssueStructure(group_by, sub_group_by, issue);
issueDetailStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue); issueDetailStore.updateIssue(workspaceSlug.toString(), issue.project, issue.id, issue);
} }
if (action === "delete") cycleIssueStore.deleteIssue(group_by, null, issue); if (action === "delete") cycleIssueStore.deleteIssue(group_by, sub_group_by, issue);
if (action === "remove" && issue.bridge_id) { if (action === "remove" && issue.bridge_id) {
cycleIssueStore.deleteIssue(group_by, null, issue); cycleIssueStore.deleteIssue(group_by, sub_group_by, issue);
cycleIssueStore.removeIssueFromCycle( cycleIssueStore.removeIssueFromCycle(
workspaceSlug.toString(), workspaceSlug.toString(),
issue.project, issue.project,
@ -81,13 +83,18 @@ export const CycleKanBanLayout: React.FC = observer(() => {
cycleIssueKanBanViewStore.handleKanBanToggle(toggle, value); cycleIssueKanBanViewStore.handleKanBanToggle(toggle, value);
}; };
const projectDetails = projectId ? projectStore.project_details[projectId.toString()] : null;
const states = projectStore?.projectStates || null; const states = projectStore?.projectStates || null;
const priorities = ISSUE_PRIORITIES || null; const priorities = ISSUE_PRIORITIES || null;
const labels = projectStore?.projectLabels || null; const labels = projectStore?.projectLabels || null;
const members = projectStore?.projectMembers || null; const members = projectStore?.projectMembers || null;
const stateGroups = ISSUE_STATE_GROUPS || null; const stateGroups = ISSUE_STATE_GROUPS || null;
const projects = projectStore?.projectStates || null; const projects = workspaceSlug ? projectStore?.projects[workspaceSlug.toString()] || null : null;
const estimates = null; const estimates =
projectDetails?.estimate !== null
? projectStore.projectEstimates?.find((e) => e.id === projectDetails?.estimate) || null
: null;
return ( return (
<div className={`relative min-w-full w-max min-h-full h-max bg-custom-background-90 px-3`}> <div className={`relative min-w-full w-max min-h-full h-max bg-custom-background-90 px-3`}>
@ -113,9 +120,9 @@ export const CycleKanBanLayout: React.FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} estimates={estimates?.points ? orderArrayBy(estimates.points, "key") : null}
/> />
) : ( ) : (
<KanBanSwimLanes <KanBanSwimLanes
@ -138,9 +145,9 @@ export const CycleKanBanLayout: React.FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} estimates={estimates?.points ? orderArrayBy(estimates.points, "key") : null}
/> />
)} )}
</DragDropContext> </DragDropContext>

View File

@ -0,0 +1,5 @@
export * from "./cycle-root";
export * from "./module-root";
export * from "./profile-issues-root";
export * from "./project-root";
export * from "./project-view-root";

View File

@ -5,9 +5,11 @@ import { DragDropContext } from "@hello-pangea/dnd";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { KanBanSwimLanes } from "./swimlanes"; import { KanBanSwimLanes } from "../swimlanes";
import { KanBan } from "./default"; import { KanBan } from "../default";
import { ModuleIssueQuickActions } from "components/issues"; import { ModuleIssueQuickActions } from "components/issues";
// helpers
import { orderArrayBy } from "helpers/array.helper";
// types // types
import { IIssue } from "types"; import { IIssue } from "types";
// constants // constants
@ -25,7 +27,7 @@ export const ModuleKanBanLayout: React.FC = observer(() => {
} = useMobxStore(); } = useMobxStore();
const router = useRouter(); const router = useRouter();
const { workspaceSlug, moduleId } = router.query; const { workspaceSlug, projectId, moduleId } = router.query;
const issues = moduleIssueStore?.getIssues; const issues = moduleIssueStore?.getIssues;
@ -81,13 +83,18 @@ export const ModuleKanBanLayout: React.FC = observer(() => {
moduleIssueKanBanViewStore.handleKanBanToggle(toggle, value); moduleIssueKanBanViewStore.handleKanBanToggle(toggle, value);
}; };
const projectDetails = projectId ? projectStore.project_details[projectId.toString()] : null;
const states = projectStore?.projectStates || null; const states = projectStore?.projectStates || null;
const priorities = ISSUE_PRIORITIES || null; const priorities = ISSUE_PRIORITIES || null;
const labels = projectStore?.projectLabels || null; const labels = projectStore?.projectLabels || null;
const members = projectStore?.projectMembers || null; const members = projectStore?.projectMembers || null;
const stateGroups = ISSUE_STATE_GROUPS || null; const stateGroups = ISSUE_STATE_GROUPS || null;
const projects = projectStore?.projectStates || null; const projects = workspaceSlug ? projectStore?.projects[workspaceSlug.toString()] || null : null;
const estimates = null; const estimates =
projectDetails?.estimate !== null
? projectStore.projectEstimates?.find((e) => e.id === projectDetails?.estimate) || null
: null;
return ( return (
<div className={`relative min-w-full w-max min-h-full h-max bg-custom-background-90 px-3`}> <div className={`relative min-w-full w-max min-h-full h-max bg-custom-background-90 px-3`}>
@ -113,9 +120,9 @@ export const ModuleKanBanLayout: React.FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} estimates={estimates?.points ? orderArrayBy(estimates.points, "key") : null}
/> />
) : ( ) : (
<KanBanSwimLanes <KanBanSwimLanes
@ -138,9 +145,9 @@ export const ModuleKanBanLayout: React.FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} estimates={estimates?.points ? orderArrayBy(estimates.points, "key") : null}
/> />
)} )}
</DragDropContext> </DragDropContext>

View File

@ -5,8 +5,8 @@ import { DragDropContext } from "@hello-pangea/dnd";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { KanBanSwimLanes } from "./swimlanes"; import { KanBanSwimLanes } from "../swimlanes";
import { KanBan } from "./default"; import { KanBan } from "../default";
import { ProjectIssueQuickActions } from "components/issues"; import { ProjectIssueQuickActions } from "components/issues";
// constants // constants
import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES } from "constants/issue"; import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES } from "constants/issue";
@ -79,7 +79,6 @@ export const ProfileIssuesKanBanLayout: FC = observer(() => {
const members = projectStore?.projectMembers || null; const members = projectStore?.projectMembers || null;
const stateGroups = ISSUE_STATE_GROUPS || null; const stateGroups = ISSUE_STATE_GROUPS || null;
const projects = projectStore?.workspaceProjects || null; const projects = projectStore?.workspaceProjects || null;
const estimates = null;
return ( return (
<div className={`relative min-w-full w-max min-h-full h-max bg-custom-background-90 px-3`}> <div className={`relative min-w-full w-max min-h-full h-max bg-custom-background-90 px-3`}>
@ -104,9 +103,9 @@ export const ProfileIssuesKanBanLayout: FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} estimates={null}
/> />
) : ( ) : (
<KanBanSwimLanes <KanBanSwimLanes
@ -128,9 +127,9 @@ export const ProfileIssuesKanBanLayout: FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} estimates={null}
/> />
)} )}
</DragDropContext> </DragDropContext>

View File

@ -1,13 +1,15 @@
import { FC, useCallback } from "react"; import { useCallback } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { DragDropContext } from "@hello-pangea/dnd"; import { DragDropContext } from "@hello-pangea/dnd";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { KanBanSwimLanes } from "./swimlanes"; import { KanBanSwimLanes } from "../swimlanes";
import { KanBan } from "./default"; import { KanBan } from "../default";
import { ProjectIssueQuickActions } from "components/issues"; import { ProjectIssueQuickActions } from "components/issues";
// helpers
import { orderArrayBy } from "helpers/array.helper";
// types // types
import { IIssue } from "types"; import { IIssue } from "types";
// constants // constants
@ -15,9 +17,9 @@ import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES } from "constants/issue";
export interface IKanBanLayout {} export interface IKanBanLayout {}
export const KanBanLayout: FC = observer(() => { export const KanBanLayout: React.FC = observer(() => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug, projectId } = router.query;
const { const {
project: projectStore, project: projectStore,
@ -72,13 +74,18 @@ export const KanBanLayout: FC = observer(() => {
issueKanBanViewStore.handleKanBanToggle(toggle, value); issueKanBanViewStore.handleKanBanToggle(toggle, value);
}; };
const projectDetails = projectId ? projectStore.project_details[projectId.toString()] : null;
const states = projectStore?.projectStates || null; const states = projectStore?.projectStates || null;
const priorities = ISSUE_PRIORITIES || null; const priorities = ISSUE_PRIORITIES || null;
const labels = projectStore?.projectLabels || null; const labels = projectStore?.projectLabels || null;
const members = projectStore?.projectMembers || null; const members = projectStore?.projectMembers || null;
const stateGroups = ISSUE_STATE_GROUPS || null; const stateGroups = ISSUE_STATE_GROUPS || null;
const projects = projectStore?.projectStates || null; const projects = workspaceSlug ? projectStore?.projects[workspaceSlug.toString()] || null : null;
const estimates = null; const estimates =
projectDetails?.estimate !== null
? projectStore.projectEstimates?.find((e) => e.id === projectDetails?.estimate) || null
: null;
return ( return (
<div className={`relative min-w-full w-max min-h-full h-max bg-custom-background-90 px-3`}> <div className={`relative min-w-full w-max min-h-full h-max bg-custom-background-90 px-3`}>
@ -103,9 +110,10 @@ export const KanBanLayout: FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} enableQuickIssueCreate
estimates={estimates?.points ? orderArrayBy(estimates.points, "key") : null}
/> />
) : ( ) : (
<KanBanSwimLanes <KanBanSwimLanes
@ -127,9 +135,9 @@ export const KanBanLayout: FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} estimates={estimates?.points ? orderArrayBy(estimates.points, "key") : null}
/> />
)} )}
</DragDropContext> </DragDropContext>

View File

@ -4,8 +4,8 @@ import { DragDropContext } from "@hello-pangea/dnd";
// mobx // mobx
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// components // components
import { KanBanSwimLanes } from "./swimlanes"; import { KanBanSwimLanes } from "../swimlanes";
import { KanBan } from "./default"; import { KanBan } from "../default";
// store // store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
import { RootStore } from "store/root"; import { RootStore } from "store/root";
@ -14,7 +14,7 @@ import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES } from "constants/issue";
export interface IViewKanBanLayout {} export interface IViewKanBanLayout {}
export const ViewKanBanLayout: React.FC = observer(() => { export const ProjectViewKanBanLayout: React.FC = observer(() => {
const { const {
project: projectStore, project: projectStore,
issue: issueStore, issue: issueStore,

View File

@ -7,7 +7,7 @@ import { KanBanGroupByHeaderRoot } from "./headers/group-by-root";
import { KanBanSubGroupByHeaderRoot } from "./headers/sub-group-by-root"; import { KanBanSubGroupByHeaderRoot } from "./headers/sub-group-by-root";
import { KanBan } from "./default"; import { KanBan } from "./default";
// types // types
import { IIssue } from "types"; import { IEstimatePoint, IIssue, IIssueLabels, IProject, IState, IUserLite } from "types";
// constants // constants
import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES, getValueFromObject } from "constants/issue"; import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES, getValueFromObject } from "constants/issue";
@ -19,6 +19,11 @@ interface ISubGroupSwimlaneHeader {
listKey: string; listKey: string;
kanBanToggle: any; kanBanToggle: any;
handleKanBanToggle: any; handleKanBanToggle: any;
states: IState[] | null;
labels: IIssueLabels[] | null;
members: IUserLite[] | null;
projects: IProject[] | null;
estimates: IEstimatePoint[] | null;
} }
const SubGroupSwimlaneHeader: React.FC<ISubGroupSwimlaneHeader> = ({ const SubGroupSwimlaneHeader: React.FC<ISubGroupSwimlaneHeader> = ({
issues, issues,
@ -71,13 +76,13 @@ interface ISubGroupSwimlane extends ISubGroupSwimlaneHeader {
display_properties: any; display_properties: any;
kanBanToggle: any; kanBanToggle: any;
handleKanBanToggle: any; handleKanBanToggle: any;
states: any; states: IState[] | null;
stateGroups: any; stateGroups: any;
priorities: any; priorities: any;
labels: any; labels: IIssueLabels[] | null;
members: any; members: IUserLite[] | null;
projects: any; projects: IProject[] | null;
estimates: any; estimates: IEstimatePoint[] | null;
} }
const SubGroupSwimlane: React.FC<ISubGroupSwimlane> = observer((props) => { const SubGroupSwimlane: React.FC<ISubGroupSwimlane> = observer((props) => {
const { const {
@ -148,6 +153,7 @@ const SubGroupSwimlane: React.FC<ISubGroupSwimlane> = observer((props) => {
members={members} members={members}
projects={projects} projects={projects}
estimates={estimates} estimates={estimates}
enableQuickIssueCreate
/> />
</div> </div>
)} )}
@ -171,13 +177,13 @@ export interface IKanBanSwimLanes {
display_properties: any; display_properties: any;
kanBanToggle: any; kanBanToggle: any;
handleKanBanToggle: any; handleKanBanToggle: any;
states: any; states: IState[] | null;
stateGroups: any; stateGroups: any;
priorities: any; priorities: any;
labels: any; labels: IIssueLabels[] | null;
members: any; members: IUserLite[] | null;
projects: any; projects: IProject[] | null;
estimates: any; estimates: IEstimatePoint[] | null;
} }
export const KanBanSwimLanes: React.FC<IKanBanSwimLanes> = observer((props) => { export const KanBanSwimLanes: React.FC<IKanBanSwimLanes> = observer((props) => {
@ -213,6 +219,11 @@ export const KanBanSwimLanes: React.FC<IKanBanSwimLanes> = observer((props) => {
listKey={`id`} listKey={`id`}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
states={states}
labels={labels}
members={members}
projects={projects}
estimates={estimates}
/> />
)} )}
@ -225,6 +236,11 @@ export const KanBanSwimLanes: React.FC<IKanBanSwimLanes> = observer((props) => {
listKey={`key`} listKey={`key`}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
states={states}
labels={labels}
members={members}
projects={projects}
estimates={estimates}
/> />
)} )}
@ -237,6 +253,11 @@ export const KanBanSwimLanes: React.FC<IKanBanSwimLanes> = observer((props) => {
listKey={`key`} listKey={`key`}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
states={states}
labels={labels}
members={members}
projects={projects}
estimates={estimates}
/> />
)} )}
@ -249,6 +270,11 @@ export const KanBanSwimLanes: React.FC<IKanBanSwimLanes> = observer((props) => {
listKey={`id`} listKey={`id`}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
states={states}
labels={labels}
members={members}
projects={projects}
estimates={estimates}
/> />
)} )}
@ -261,6 +287,11 @@ export const KanBanSwimLanes: React.FC<IKanBanSwimLanes> = observer((props) => {
listKey={`member.id`} listKey={`member.id`}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
states={states}
labels={labels}
members={members}
projects={projects}
estimates={estimates}
/> />
)} )}
@ -273,6 +304,11 @@ export const KanBanSwimLanes: React.FC<IKanBanSwimLanes> = observer((props) => {
listKey={`member.id`} listKey={`member.id`}
kanBanToggle={kanBanToggle} kanBanToggle={kanBanToggle}
handleKanBanToggle={handleKanBanToggle} handleKanBanToggle={handleKanBanToggle}
states={states}
labels={labels}
members={members}
projects={projects}
estimates={estimates}
/> />
)} )}
</div> </div>

View File

@ -4,7 +4,7 @@ import { IssuePeekOverview } from "components/issues/issue-peek-overview";
// ui // ui
import { Tooltip } from "@plane/ui"; import { Tooltip } from "@plane/ui";
// types // types
import { IIssue } from "types"; import { IEstimatePoint, IIssue, IIssueLabels, IState, IUserLite } from "types";
interface IssueBlockProps { interface IssueBlockProps {
columnId: string; columnId: string;
@ -12,28 +12,30 @@ interface IssueBlockProps {
handleIssues: (group_by: string | null, issue: IIssue, action: "update" | "delete") => void; handleIssues: (group_by: string | null, issue: IIssue, action: "update" | "delete") => void;
quickActions: (group_by: string | null, issue: IIssue) => React.ReactNode; quickActions: (group_by: string | null, issue: IIssue) => React.ReactNode;
display_properties: any; display_properties: any;
states: any; states: IState[] | null;
labels: any; labels: IIssueLabels[] | null;
members: any; members: IUserLite[] | null;
priorities: any; estimates: IEstimatePoint[] | null;
} }
export const IssueBlock: React.FC<IssueBlockProps> = (props) => { export const IssueBlock: React.FC<IssueBlockProps> = (props) => {
const { columnId, issue, handleIssues, quickActions, display_properties, states, labels, members, priorities } = const { columnId, issue, handleIssues, quickActions, display_properties, states, labels, members, estimates } = props;
props;
const updateIssue = (group_by: string | null, issueToUpdate: IIssue) => { const updateIssue = (group_by: string | null, issueToUpdate: IIssue) => {
if (issueToUpdate && handleIssues) handleIssues(group_by, issueToUpdate, "update"); handleIssues(group_by, issueToUpdate, "update");
}; };
return ( return (
<> <>
<div className="text-sm p-3 shadow-custom-shadow-2xs bg-custom-background-100 flex items-center gap-3 border-b border-custom-border-200 hover:bg-custom-background-80"> <div className="text-sm p-3 relative shadow-custom-shadow-2xs bg-custom-background-100 flex items-center gap-3 border-b border-custom-border-200 hover:bg-custom-background-80">
{display_properties && display_properties?.key && ( {display_properties && display_properties?.key && (
<div className="flex-shrink-0 text-xs text-custom-text-300"> <div className="flex-shrink-0 text-xs text-custom-text-300">
{issue?.project_detail?.identifier}-{issue.sequence_id} {issue?.project_detail?.identifier}-{issue.sequence_id}
</div> </div>
)} )}
{issue?.tempId !== undefined && (
<div className="absolute top-0 left-0 w-full h-full animate-pulse bg-custom-background-100/20 z-[99999]" />
)}
<IssuePeekOverview <IssuePeekOverview
workspaceSlug={issue?.workspace_detail?.slug} workspaceSlug={issue?.workspace_detail?.slug}
projectId={issue?.project_detail?.id} projectId={issue?.project_detail?.id}
@ -55,7 +57,7 @@ export const IssueBlock: React.FC<IssueBlockProps> = (props) => {
states={states} states={states}
labels={labels} labels={labels}
members={members} members={members}
priorities={priorities} estimates={estimates}
/> />
{quickActions(!columnId && columnId === "null" ? null : columnId, issue)} {quickActions(!columnId && columnId === "null" ? null : columnId, issue)}
</div> </div>

View File

@ -2,7 +2,7 @@ import { FC } from "react";
// components // components
import { IssueBlock } from "components/issues"; import { IssueBlock } from "components/issues";
// types // types
import { IIssue } from "types"; import { IEstimatePoint, IIssue, IIssueLabels, IState, IUserLite } from "types";
interface Props { interface Props {
columnId: string; columnId: string;
@ -10,14 +10,14 @@ interface Props {
handleIssues: (group_by: string | null, issue: IIssue, action: "update" | "delete") => void; handleIssues: (group_by: string | null, issue: IIssue, action: "update" | "delete") => void;
quickActions: (group_by: string | null, issue: IIssue) => React.ReactNode; quickActions: (group_by: string | null, issue: IIssue) => React.ReactNode;
display_properties: any; display_properties: any;
states: any; states: IState[] | null;
labels: any; labels: IIssueLabels[] | null;
members: any; members: IUserLite[] | null;
priorities: any; estimates: IEstimatePoint[] | null;
} }
export const IssueBlocksList: FC<Props> = (props) => { export const IssueBlocksList: FC<Props> = (props) => {
const { columnId, issues, handleIssues, quickActions, display_properties, states, labels, members, priorities } = const { columnId, issues, handleIssues, quickActions, display_properties, states, labels, members, estimates } =
props; props;
return ( return (
@ -35,7 +35,7 @@ export const IssueBlocksList: FC<Props> = (props) => {
states={states} states={states}
labels={labels} labels={labels}
members={members} members={members}
priorities={priorities} estimates={estimates}
/> />
))} ))}
</> </>

View File

@ -2,11 +2,11 @@ import React from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// components // components
import { ListGroupByHeaderRoot } from "./headers/group-by-root"; import { ListGroupByHeaderRoot } from "./headers/group-by-root";
import { IssueBlock } from "./block"; import { IssueBlocksList, ListInlineCreateIssueForm } from "components/issues";
// types
import { IEstimatePoint, IIssue, IIssueLabels, IProject, IState, IUserLite } from "types";
// constants // constants
import { getValueFromObject } from "constants/issue"; import { getValueFromObject } from "constants/issue";
import { IIssue } from "types";
import { IssueBlocksList } from "./blocks-list";
export interface IGroupByList { export interface IGroupByList {
issues: any; issues: any;
@ -17,13 +17,14 @@ export interface IGroupByList {
quickActions: (group_by: string | null, issue: IIssue) => React.ReactNode; quickActions: (group_by: string | null, issue: IIssue) => React.ReactNode;
display_properties: any; display_properties: any;
is_list?: boolean; is_list?: boolean;
states: any; states: IState[] | null;
labels: any; labels: IIssueLabels[] | null;
members: any; members: IUserLite[] | null;
projects: any; projects: IProject[] | null;
stateGroups: any; stateGroups: any;
priorities: any; priorities: any;
estimates: any; enableQuickIssueCreate?: boolean;
estimates: IEstimatePoint[] | null;
} }
const GroupByList: React.FC<IGroupByList> = observer((props) => { const GroupByList: React.FC<IGroupByList> = observer((props) => {
@ -43,6 +44,7 @@ const GroupByList: React.FC<IGroupByList> = observer((props) => {
stateGroups, stateGroups,
priorities, priorities,
estimates, estimates,
enableQuickIssueCreate,
} = props; } = props;
return ( return (
@ -72,10 +74,18 @@ const GroupByList: React.FC<IGroupByList> = observer((props) => {
states={states} states={states}
labels={labels} labels={labels}
members={members} members={members}
priorities={priorities} estimates={estimates}
/> />
)} )}
</div> </div>
{enableQuickIssueCreate && (
<ListInlineCreateIssueForm
groupId={getValueFromObject(_list, listKey) as string}
prePopulatedData={{
[group_by!]: getValueFromObject(_list, listKey),
}}
/>
)}
</div> </div>
))} ))}
</div> </div>
@ -90,13 +100,14 @@ export interface IList {
handleIssues: (group_by: string | null, issue: IIssue, action: "update" | "delete") => void; handleIssues: (group_by: string | null, issue: IIssue, action: "update" | "delete") => void;
quickActions: (group_by: string | null, issue: IIssue) => React.ReactNode; quickActions: (group_by: string | null, issue: IIssue) => React.ReactNode;
display_properties: any; display_properties: any;
states: any; states: IState[] | null;
labels: any; labels: IIssueLabels[] | null;
members: any; members: IUserLite[] | null;
projects: any; projects: IProject[] | null;
stateGroups: any; stateGroups: any;
priorities: any; priorities: any;
estimates: any; enableQuickIssueCreate?: boolean;
estimates: IEstimatePoint[] | null;
} }
export const List: React.FC<IList> = observer((props) => { export const List: React.FC<IList> = observer((props) => {
@ -113,6 +124,7 @@ export const List: React.FC<IList> = observer((props) => {
stateGroups, stateGroups,
priorities, priorities,
estimates, estimates,
enableQuickIssueCreate,
} = props; } = props;
return ( return (
@ -134,6 +146,7 @@ export const List: React.FC<IList> = observer((props) => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
estimates={estimates} estimates={estimates}
enableQuickIssueCreate={enableQuickIssueCreate}
/> />
)} )}
@ -153,6 +166,7 @@ export const List: React.FC<IList> = observer((props) => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
estimates={estimates} estimates={estimates}
enableQuickIssueCreate={enableQuickIssueCreate}
/> />
)} )}
@ -172,6 +186,7 @@ export const List: React.FC<IList> = observer((props) => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
estimates={estimates} estimates={estimates}
enableQuickIssueCreate={enableQuickIssueCreate}
/> />
)} )}
@ -191,6 +206,7 @@ export const List: React.FC<IList> = observer((props) => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
estimates={estimates} estimates={estimates}
enableQuickIssueCreate={enableQuickIssueCreate}
/> />
)} )}
@ -210,6 +226,7 @@ export const List: React.FC<IList> = observer((props) => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
estimates={estimates} estimates={estimates}
enableQuickIssueCreate={enableQuickIssueCreate}
/> />
)} )}
@ -229,6 +246,7 @@ export const List: React.FC<IList> = observer((props) => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
estimates={estimates} estimates={estimates}
enableQuickIssueCreate={enableQuickIssueCreate}
/> />
)} )}
@ -248,6 +266,7 @@ export const List: React.FC<IList> = observer((props) => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
estimates={estimates} estimates={estimates}
enableQuickIssueCreate={enableQuickIssueCreate}
/> />
)} )}
@ -267,6 +286,7 @@ export const List: React.FC<IList> = observer((props) => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
estimates={estimates} estimates={estimates}
enableQuickIssueCreate={enableQuickIssueCreate}
/> />
)} )}
</div> </div>

View File

@ -1,5 +1,4 @@
export * from "./roots";
export * from "./block"; export * from "./block";
export * from "./blocks-list"; export * from "./blocks-list";
export * from "./cycle-root"; export * from "./inline-create-issue-form";
export * from "./module-root";
export * from "./root";

View File

@ -0,0 +1,201 @@
import { useEffect, useState, useRef } from "react";
import { useRouter } from "next/router";
import { useForm } from "react-hook-form";
import { Transition } from "@headlessui/react";
// hooks
import useToast from "hooks/use-toast";
import useKeypress from "hooks/use-keypress";
import useProjectDetails from "hooks/use-project-details";
import useOutsideClickDetector from "hooks/use-outside-click-detector";
// store
import { observer } from "mobx-react-lite";
import { useMobxStore } from "lib/mobx/store-provider";
// constants
import { createIssuePayload } from "constants/issue";
// types
import { IIssue } from "types";
import { PlusIcon } from "lucide-react";
type Props = {
groupId?: string;
prePopulatedData?: Partial<IIssue>;
onSuccess?: (data: IIssue) => Promise<void> | void;
};
const defaultValues: Partial<IIssue> = {
name: "",
};
const Inputs = (props: any) => {
const { register, setFocus, projectDetails } = props;
useEffect(() => {
setFocus("name");
}, [setFocus]);
return (
<>
<h4 className="text-sm font-medium leading-5 text-custom-text-400">{projectDetails?.identifier ?? "..."}</h4>
<input
type="text"
autoComplete="off"
placeholder="Issue Title"
{...register("name", {
required: "Issue title is required.",
})}
className="w-full px-2 py-3 rounded-md bg-transparent text-sm font-medium leading-5 text-custom-text-200 outline-none"
/>
</>
);
};
export const ListInlineCreateIssueForm: React.FC<Props> = observer((props) => {
const { prePopulatedData, groupId } = props;
// router
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
// store
const { workspace: workspaceStore, quickAddIssue: quickAddStore } = useMobxStore();
const { projectDetails } = useProjectDetails();
const {
reset,
handleSubmit,
setFocus,
register,
formState: { errors, isSubmitting },
} = useForm<IIssue>({ defaultValues });
// ref
const ref = useRef<HTMLFormElement>(null);
// states
const [isOpen, setIsOpen] = useState(false);
const handleClose = () => setIsOpen(false);
// hooks
useKeypress("Escape", handleClose);
useOutsideClickDetector(ref, handleClose);
const { setToastAlert } = useToast();
// derived values
const workspaceDetail = workspaceStore.getWorkspaceBySlug(workspaceSlug?.toString()!);
useEffect(() => {
if (!isOpen) reset({ ...defaultValues });
}, [isOpen, reset]);
useEffect(() => {
if (!errors) return;
Object.keys(errors).forEach((key) => {
const error = errors[key as keyof IIssue];
setToastAlert({
type: "error",
title: "Error!",
message: error?.message?.toString() || "Some error occurred. Please try again.",
});
});
}, [errors, setToastAlert]);
const onSubmitHandler = async (formData: IIssue) => {
if (isSubmitting || !workspaceSlug || !projectId) return;
// resetting the form so that user can add another issue quickly
reset({ ...defaultValues });
const payload = createIssuePayload(workspaceDetail!, projectDetails!, {
...(prePopulatedData ?? {}),
...formData,
labels_list:
formData.labels_list?.length !== 0
? formData.labels_list
: prePopulatedData?.labels && prePopulatedData?.labels.toString() !== "none"
? [prePopulatedData.labels as any]
: [],
assignees_list:
formData.assignees_list?.length !== 0
? formData.assignees_list
: prePopulatedData?.assignees && prePopulatedData?.assignees.toString() !== "none"
? [prePopulatedData.assignees as any]
: [],
});
try {
quickAddStore.createIssue(
workspaceSlug.toString(),
projectId.toString(),
{
group_id: groupId ?? null,
sub_group_id: null,
},
payload
);
setToastAlert({
type: "success",
title: "Success!",
message: "Issue created successfully.",
});
} catch (err: any) {
Object.keys(err || {}).forEach((key) => {
const error = err?.[key];
const errorTitle = error ? (Array.isArray(error) ? error.join(", ") : error) : null;
setToastAlert({
type: "error",
title: "Error!",
message: errorTitle || "Some error occurred. Please try again.",
});
});
}
};
return (
<div>
<Transition
show={isOpen}
enter="transition ease-in-out duration-200 transform"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="transition ease-in-out duration-200 transform"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<form
ref={ref}
onSubmit={handleSubmit(onSubmitHandler)}
className="flex border-[0.5px] border-t-0 border-custom-border-100 px-4 items-center gap-x-5 bg-custom-background-100 shadow-custom-shadow-sm z-10"
>
<Inputs register={register} setFocus={setFocus} projectDetails={projectDetails} />
</form>
</Transition>
{isOpen && (
<p className="text-xs ml-3 mt-3 italic text-custom-text-200">
Press {"'"}Enter{"'"} to add another issue
</p>
)}
{!isOpen && (
<button
type="button"
className="flex items-center gap-x-[6px] text-custom-primary-100 px-2 py-1 rounded-md"
onClick={() => setIsOpen(true)}
>
<PlusIcon className="h-4 w-4" />
<span className="text-sm font-medium text-custom-primary-100">New Issue</span>
</button>
)}
</div>
);
});

View File

@ -11,49 +11,48 @@ import { IssuePropertyDate } from "../properties/date";
// ui // ui
import { Tooltip } from "@plane/ui"; import { Tooltip } from "@plane/ui";
// types // types
import { IIssue } from "types"; import { IEstimatePoint, IIssue, IIssueLabels, IState, IUserLite, TIssuePriorities } from "types";
export interface IKanBanProperties { export interface IKanBanProperties {
columnId: string; columnId: string;
issue: any; issue: IIssue;
handleIssues?: (group_by: string | null, issue: IIssue) => void; handleIssues: (group_by: string | null, issue: IIssue) => void;
display_properties: any; display_properties: any;
states: any; states: IState[] | null;
labels: any; labels: IIssueLabels[] | null;
members: any; members: IUserLite[] | null;
priorities: any; estimates: IEstimatePoint[] | null;
} }
export const KanBanProperties: FC<IKanBanProperties> = observer((props) => { export const KanBanProperties: FC<IKanBanProperties> = observer((props) => {
const { columnId: group_id, issue, handleIssues, display_properties, states, labels, members, priorities } = props; const { columnId: group_id, issue, handleIssues, display_properties, states, labels, members, estimates } = props;
const handleState = (id: string) => { const handleState = (state: IState) => {
if (handleIssues) handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, state: id }); handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, state: state.id });
}; };
const handlePriority = (id: string) => { const handlePriority = (value: TIssuePriorities) => {
if (handleIssues) handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, priority: id }); handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, priority: value });
}; };
const handleLabel = (ids: string[]) => { const handleLabel = (ids: string[]) => {
if (handleIssues) handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, labels: ids }); handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, labels_list: ids });
}; };
const handleAssignee = (ids: string[]) => { const handleAssignee = (ids: string[]) => {
if (handleIssues) handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, assignees: ids }); handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, assignees_list: ids });
}; };
const handleStartDate = (date: string) => { const handleStartDate = (date: string) => {
if (handleIssues) handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, start_date: date }); handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, start_date: date });
}; };
const handleTargetDate = (date: string) => { const handleTargetDate = (date: string) => {
if (handleIssues) handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, target_date: date }); handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, target_date: date });
}; };
const handleEstimate = (id: string) => { const handleEstimate = (value: number | null) => {
if (handleIssues) handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, estimate_point: value });
handleIssues(!group_id && group_id === "null" ? null : group_id, { ...issue, estimate_point: id });
}; };
return ( return (
@ -62,22 +61,21 @@ export const KanBanProperties: FC<IKanBanProperties> = observer((props) => {
{/* state */} {/* state */}
{display_properties && display_properties?.state && states && ( {display_properties && display_properties?.state && states && (
<IssuePropertyState <IssuePropertyState
value={issue?.state || null} value={issue?.state_detail || null}
dropdownArrow={false} hideDropdownArrow={true}
onChange={(id: string) => handleState(id)} onChange={handleState}
disabled={false} disabled={false}
list={states} states={states}
/> />
)} )}
{/* priority */} {/* priority */}
{display_properties && display_properties?.priority && priorities && ( {display_properties && display_properties?.priority && (
<IssuePropertyPriority <IssuePropertyPriority
value={issue?.priority || null} value={issue?.priority || null}
dropdownArrow={false} onChange={handlePriority}
onChange={(id: string) => handlePriority(id)}
disabled={false} disabled={false}
list={priorities} hideDropdownArrow={true}
/> />
)} )}
@ -85,10 +83,10 @@ export const KanBanProperties: FC<IKanBanProperties> = observer((props) => {
{display_properties && display_properties?.labels && labels && ( {display_properties && display_properties?.labels && labels && (
<IssuePropertyLabels <IssuePropertyLabels
value={issue?.labels || null} value={issue?.labels || null}
dropdownArrow={false} onChange={handleLabel}
onChange={(ids: string[]) => handleLabel(ids)} labels={labels}
disabled={false} disabled={false}
list={labels} hideDropdownArrow={true}
/> />
)} )}
@ -96,10 +94,10 @@ export const KanBanProperties: FC<IKanBanProperties> = observer((props) => {
{display_properties && display_properties?.assignee && members && ( {display_properties && display_properties?.assignee && members && (
<IssuePropertyAssignee <IssuePropertyAssignee
value={issue?.assignees || null} value={issue?.assignees || null}
dropdownArrow={false} hideDropdownArrow={true}
onChange={(ids: string[]) => handleAssignee(ids)} onChange={handleAssignee}
disabled={false} disabled={false}
list={members} members={members}
/> />
)} )}
@ -109,7 +107,7 @@ export const KanBanProperties: FC<IKanBanProperties> = observer((props) => {
value={issue?.start_date || null} value={issue?.start_date || null}
onChange={(date: string) => handleStartDate(date)} onChange={(date: string) => handleStartDate(date)}
disabled={false} disabled={false}
placeHolder={`Start date`} placeHolder="Start date"
/> />
)} )}
@ -119,31 +117,28 @@ export const KanBanProperties: FC<IKanBanProperties> = observer((props) => {
value={issue?.target_date || null} value={issue?.target_date || null}
onChange={(date: string) => handleTargetDate(date)} onChange={(date: string) => handleTargetDate(date)}
disabled={false} disabled={false}
placeHolder={`Target date`} placeHolder="Target date"
/> />
)} )}
{/* estimates */} {/* estimates */}
{display_properties && display_properties?.estimate && ( {display_properties && display_properties?.estimate && (
<IssuePropertyEstimates <IssuePropertyEstimates
value={issue?.estimate_point?.toString() || null} value={issue?.estimate_point || null}
dropdownArrow={false} estimatePoints={estimates}
onChange={(id: string) => handleEstimate(id)} hideDropdownArrow={true}
onChange={handleEstimate}
disabled={false} disabled={false}
workspaceSlug={issue?.workspace_detail?.slug || null}
projectId={issue?.project_detail?.id || null}
/> />
)} )}
{/* extra render properties */} {/* extra render properties */}
{/* sub-issues */} {/* sub-issues */}
{display_properties && display_properties?.sub_issue_count && ( {display_properties && display_properties?.sub_issue_count && (
<Tooltip tooltipHeading="Sub-issue" tooltipContent={`${issue.sub_issues_count}`}> <Tooltip tooltipHeading="Sub-issues" tooltipContent={`${issue.sub_issues_count}`}>
<div className="flex-shrink-0 border border-custom-border-300 min-w-[22px] h-[22px] overflow-hidden rounded-sm flex justify-center items-center cursor-pointer"> <div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<div className="flex-shrink-0 w-[16px] h-[16px] flex justify-center items-center"> <Layers className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
<Layers width={10} strokeWidth={2} /> <div className="text-xs">{issue.sub_issues_count}</div>
</div>
<div className="pl-0.5 pr-1 text-xs">{issue.sub_issues_count}</div>
</div> </div>
</Tooltip> </Tooltip>
)} )}
@ -151,11 +146,9 @@ export const KanBanProperties: FC<IKanBanProperties> = observer((props) => {
{/* attachments */} {/* attachments */}
{display_properties && display_properties?.attachment_count && ( {display_properties && display_properties?.attachment_count && (
<Tooltip tooltipHeading="Attachments" tooltipContent={`${issue.attachment_count}`}> <Tooltip tooltipHeading="Attachments" tooltipContent={`${issue.attachment_count}`}>
<div className="flex-shrink-0 border border-custom-border-300 min-w-[22px] h-[22px] overflow-hidden rounded-sm flex justify-center items-center cursor-pointer"> <div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<div className="flex-shrink-0 w-[16px] h-[16px] flex justify-center items-center"> <Paperclip className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
<Paperclip width={10} strokeWidth={2} /> <div className="text-xs">{issue.attachment_count}</div>
</div>
<div className="pl-0.5 pr-1 text-xs">{issue.attachment_count}</div>
</div> </div>
</Tooltip> </Tooltip>
)} )}
@ -163,11 +156,9 @@ export const KanBanProperties: FC<IKanBanProperties> = observer((props) => {
{/* link */} {/* link */}
{display_properties && display_properties?.link && ( {display_properties && display_properties?.link && (
<Tooltip tooltipHeading="Links" tooltipContent={`${issue.link_count}`}> <Tooltip tooltipHeading="Links" tooltipContent={`${issue.link_count}`}>
<div className="flex-shrink-0 border border-custom-border-300 min-w-[22px] h-[22px] overflow-hidden rounded-sm flex justify-center items-center cursor-pointer"> <div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<div className="flex-shrink-0 w-[16px] h-[16px] flex justify-center items-center"> <Link className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
<Link width={10} strokeWidth={2} /> <div className="text-xs">{issue.link_count}</div>
</div>
<div className="pl-0.5 pr-1 text-xs">{issue.link_count}</div>
</div> </div>
</Tooltip> </Tooltip>
)} )}

View File

@ -4,8 +4,10 @@ import { observer } from "mobx-react-lite";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { List } from "./default"; import { List } from "../default";
import { CycleIssueQuickActions } from "components/issues"; import { CycleIssueQuickActions } from "components/issues";
// helpers
import { orderArrayBy } from "helpers/array.helper";
// types // types
import { IIssue } from "types"; import { IIssue } from "types";
// constants // constants
@ -15,7 +17,7 @@ export interface ICycleListLayout {}
export const CycleListLayout: React.FC = observer(() => { export const CycleListLayout: React.FC = observer(() => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, cycleId } = router.query; const { workspaceSlug, projectId, cycleId } = router.query;
const { const {
project: projectStore, project: projectStore,
@ -52,13 +54,18 @@ export const CycleListLayout: React.FC = observer(() => {
[cycleIssueStore, issueDetailStore, cycleId, workspaceSlug] [cycleIssueStore, issueDetailStore, cycleId, workspaceSlug]
); );
const projectDetails = projectId ? projectStore.project_details[projectId.toString()] : null;
const states = projectStore?.projectStates || null; const states = projectStore?.projectStates || null;
const priorities = ISSUE_PRIORITIES || null; const priorities = ISSUE_PRIORITIES || null;
const labels = projectStore?.projectLabels || null; const labels = projectStore?.projectLabels || null;
const members = projectStore?.projectMembers || null; const members = projectStore?.projectMembers || null;
const stateGroups = ISSUE_STATE_GROUPS || null; const stateGroups = ISSUE_STATE_GROUPS || null;
const projects = projectStore?.projectStates || null; const projects = workspaceSlug ? projectStore?.projects[workspaceSlug.toString()] || null : null;
const estimates = null; const estimates =
projectDetails?.estimate !== null
? projectStore.projectEstimates?.find((e) => e.id === projectDetails?.estimate) || null
: null;
return ( return (
<div className={`relative w-full h-full bg-custom-background-90`}> <div className={`relative w-full h-full bg-custom-background-90`}>
@ -79,9 +86,9 @@ export const CycleListLayout: React.FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} estimates={estimates?.points ? orderArrayBy(estimates.points, "key") : null}
/> />
</div> </div>
); );

View File

@ -0,0 +1,5 @@
export * from "./cycle-root";
export * from "./module-root";
export * from "./profile-issues-root";
export * from "./project-root";
export * from "./project-view-root";

View File

@ -4,8 +4,10 @@ import { observer } from "mobx-react-lite";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { List } from "./default"; import { List } from "../default";
import { ModuleIssueQuickActions } from "components/issues"; import { ModuleIssueQuickActions } from "components/issues";
// helpers
import { orderArrayBy } from "helpers/array.helper";
// types // types
import { IIssue } from "types"; import { IIssue } from "types";
// constants // constants
@ -15,7 +17,7 @@ export interface IModuleListLayout {}
export const ModuleListLayout: React.FC = observer(() => { export const ModuleListLayout: React.FC = observer(() => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, moduleId } = router.query; const { workspaceSlug, projectId, moduleId } = router.query;
const { const {
project: projectStore, project: projectStore,
@ -52,13 +54,18 @@ export const ModuleListLayout: React.FC = observer(() => {
[moduleIssueStore, issueDetailStore, moduleId, workspaceSlug] [moduleIssueStore, issueDetailStore, moduleId, workspaceSlug]
); );
const projectDetails = projectId ? projectStore.project_details[projectId.toString()] : null;
const states = projectStore?.projectStates || null; const states = projectStore?.projectStates || null;
const priorities = ISSUE_PRIORITIES || null; const priorities = ISSUE_PRIORITIES || null;
const labels = projectStore?.projectLabels || null; const labels = projectStore?.projectLabels || null;
const members = projectStore?.projectMembers || null; const members = projectStore?.projectMembers || null;
const stateGroups = ISSUE_STATE_GROUPS || null; const stateGroups = ISSUE_STATE_GROUPS || null;
const projects = projectStore?.projectStates || null; const projects = workspaceSlug ? projectStore?.projects[workspaceSlug.toString()] || null : null;
const estimates = null; const estimates =
projectDetails?.estimate !== null
? projectStore.projectEstimates?.find((e) => e.id === projectDetails?.estimate) || null
: null;
return ( return (
<div className={`relative w-full h-full bg-custom-background-90`}> <div className={`relative w-full h-full bg-custom-background-90`}>
@ -79,9 +86,9 @@ export const ModuleListLayout: React.FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} estimates={estimates?.points ? orderArrayBy(estimates.points, "key") : null}
/> />
</div> </div>
); );

View File

@ -4,7 +4,7 @@ import { observer } from "mobx-react-lite";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { List } from "./default"; import { List } from "../default";
import { ProjectIssueQuickActions } from "components/issues"; import { ProjectIssueQuickActions } from "components/issues";
// types // types
import { IIssue } from "types"; import { IIssue } from "types";
@ -50,7 +50,6 @@ export const ProfileIssuesListLayout: FC = observer(() => {
const members = projectStore?.projectMembers || null; const members = projectStore?.projectMembers || null;
const stateGroups = ISSUE_STATE_GROUPS || null; const stateGroups = ISSUE_STATE_GROUPS || null;
const projects = projectStore?.workspaceProjects || null; const projects = projectStore?.workspaceProjects || null;
const estimates = null;
return ( return (
<div className={`relative w-full h-full bg-custom-background-90`}> <div className={`relative w-full h-full bg-custom-background-90`}>
@ -70,9 +69,9 @@ export const ProfileIssuesListLayout: FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} estimates={null}
/> />
</div> </div>
); );

View File

@ -4,8 +4,10 @@ import { observer } from "mobx-react-lite";
// hooks // hooks
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { List } from "./default"; import { List } from "../default";
import { ProjectIssueQuickActions } from "components/issues"; import { ProjectIssueQuickActions } from "components/issues";
// helpers
import { orderArrayBy } from "helpers/array.helper";
// types // types
import { IIssue } from "types"; import { IIssue } from "types";
// constants // constants
@ -13,7 +15,7 @@ import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES } from "constants/issue";
export const ListLayout: FC = observer(() => { export const ListLayout: FC = observer(() => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug, projectId } = router.query;
const { const {
project: projectStore, project: projectStore,
@ -41,13 +43,18 @@ export const ListLayout: FC = observer(() => {
[issueStore, issueDetailStore, workspaceSlug] [issueStore, issueDetailStore, workspaceSlug]
); );
const projectDetails = projectId ? projectStore.project_details[projectId.toString()] : null;
const states = projectStore?.projectStates || null; const states = projectStore?.projectStates || null;
const priorities = ISSUE_PRIORITIES || null; const priorities = ISSUE_PRIORITIES || null;
const labels = projectStore?.projectLabels || null; const labels = projectStore?.projectLabels || null;
const members = projectStore?.projectMembers || null; const members = projectStore?.projectMembers || null;
const stateGroups = ISSUE_STATE_GROUPS || null; const stateGroups = ISSUE_STATE_GROUPS || null;
const projects = projectStore?.projectStates || null; const projects = workspaceSlug ? projectStore?.projects[workspaceSlug.toString()] || null : null;
const estimates = null; const estimates =
projectDetails?.estimate !== null
? projectStore.projectEstimates?.find((e) => e.id === projectDetails?.estimate) || null
: null;
return ( return (
<div className="relative w-full h-full bg-custom-background-90"> <div className="relative w-full h-full bg-custom-background-90">
@ -67,9 +74,10 @@ export const ListLayout: FC = observer(() => {
stateGroups={stateGroups} stateGroups={stateGroups}
priorities={priorities} priorities={priorities}
labels={labels} labels={labels}
members={members} members={members?.map((m) => m.member) ?? null}
projects={projects} projects={projects}
estimates={estimates} enableQuickIssueCreate
estimates={estimates?.points ? orderArrayBy(estimates.points, "key") : null}
/> />
</div> </div>
); );

View File

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// components // components
import { List } from "./default"; import { List } from "../default";
// store // store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
import { RootStore } from "store/root"; import { RootStore } from "store/root";
@ -10,7 +10,7 @@ import { ISSUE_STATE_GROUPS, ISSUE_PRIORITIES } from "constants/issue";
export interface IViewListLayout {} export interface IViewListLayout {}
export const ViewListLayout: React.FC = observer(() => { export const ProjectViewListLayout: React.FC = observer(() => {
const { project: projectStore, issue: issueStore, issueFilter: issueFilterStore }: RootStore = useMobxStore(); const { project: projectStore, issue: issueStore, issueFilter: issueFilterStore }: RootStore = useMobxStore();
const issues = issueStore?.getIssues; const issues = issueStore?.getIssues;

View File

@ -1,252 +1,28 @@
import { FC, useRef, useState } from "react";
import { Combobox } from "@headlessui/react";
import { ChevronDown, Search, X, Check } from "lucide-react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// components // components
import { Tooltip } from "@plane/ui"; import { MembersSelect } from "components/project";
// hooks // types
import useDynamicDropdownPosition from "hooks/use-dynamic-dropdown"; import { IUserLite } from "types";
interface IFiltersOption {
id: string;
title: string;
avatar: string;
}
export interface IIssuePropertyAssignee { export interface IIssuePropertyAssignee {
value?: any; value: string[];
onChange?: (id: any, data: any) => void; onChange: (data: string[]) => void;
members: IUserLite[] | null;
disabled?: boolean; disabled?: boolean;
list?: any; hideDropdownArrow?: boolean;
className?: string;
buttonClassName?: string;
optionsClassName?: string;
dropdownArrow?: boolean;
} }
export const IssuePropertyAssignee: FC<IIssuePropertyAssignee> = observer((props) => { export const IssuePropertyAssignee: React.FC<IIssuePropertyAssignee> = observer((props) => {
const { value, onChange, disabled, list, className, buttonClassName, optionsClassName, dropdownArrow = true } = props; const { value, onChange, members, disabled = false, hideDropdownArrow = false } = props;
const dropdownBtn = useRef<any>(null);
const dropdownOptions = useRef<any>(null);
const [isOpen, setIsOpen] = useState<boolean>(false);
const [search, setSearch] = useState<string>("");
const options: IFiltersOption[] | [] =
(list &&
list?.length > 0 &&
list.map((_member: any) => ({
id: _member?.member?.id,
title: _member?.member?.display_name,
avatar: _member?.member?.avatar && _member?.member?.avatar !== "" ? _member?.member?.avatar : null,
}))) ||
[];
useDynamicDropdownPosition(isOpen, () => setIsOpen(false), dropdownBtn, dropdownOptions);
const selectedOption: IFiltersOption[] =
(value && value?.length > 0 && options.filter((_member: IFiltersOption) => value.includes(_member.id))) || [];
const filteredOptions: IFiltersOption[] =
search === ""
? options && options.length > 0
? options
: []
: options && options.length > 0
? options.filter((_member: IFiltersOption) =>
_member.title.toLowerCase().replace(/\s+/g, "").includes(search.toLowerCase().replace(/\s+/g, ""))
)
: [];
const assigneeRenderLength = 5;
return ( return (
<Combobox <MembersSelect
multiple={true} value={value}
as="div" onChange={onChange}
className={`${className}`} members={members ?? undefined}
value={selectedOption.map((_member: IFiltersOption) => _member.id) as string[]}
onChange={(data: string[]) => {
if (onChange && selectedOption) onChange(data, selectedOption);
}}
disabled={disabled} disabled={disabled}
> hideDropdownArrow={hideDropdownArrow}
{({ open }: { open: boolean }) => { multiple
if (open) { />
if (!isOpen) setIsOpen(true);
} else if (isOpen) setIsOpen(false);
return (
<>
<Combobox.Button
ref={dropdownBtn}
type="button"
className={`flex items-center justify-between gap-1 px-1 py-0.5 rounded-sm shadow-sm border border-custom-border-300 duration-300 outline-none ${
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
} ${buttonClassName}`}
>
{selectedOption && selectedOption?.length > 0 ? (
<>
{selectedOption?.length > 1 ? (
<Tooltip
tooltipHeading={`Assignees`}
tooltipContent={(selectedOption.map((_label: IFiltersOption) => _label.title) || []).join(", ")}
>
<div className="flex-shrink-0 flex justify-center items-center gap-1 pr-[8px]">
{selectedOption.slice(0, assigneeRenderLength).map((_assignee) => (
<div
key={_assignee?.id}
className="flex-shrink-0 w-[16px] h-[16px] rounded-sm bg-gray-700 flex justify-center items-center text-white capitalize relative -mr-[8px] text-xs overflow-hidden border border-custom-border-300"
>
{_assignee && _assignee.avatar ? (
<img
src={_assignee.avatar}
className="absolute top-0 left-0 h-full w-full object-cover"
alt={_assignee.title}
/>
) : (
_assignee.title[0]
)}
</div>
))}
{selectedOption.length > assigneeRenderLength && (
<div className="flex-shrink-0 h-[16px] px-0.5 rounded-sm bg-gray-700 flex justify-center items-center text-white capitalize relative -mr-[8px] text-xs overflow-hidden border border-custom-border-300">
+{selectedOption?.length - assigneeRenderLength}
</div>
)}
</div>
</Tooltip>
) : (
<Tooltip
tooltipHeading={`Assignees`}
tooltipContent={(selectedOption.map((_label: IFiltersOption) => _label.title) || []).join(", ")}
>
<div className="flex-shrink-0 flex justify-center items-center gap-1 text-xs">
<div className="flex-shrink-0 w-4 h-4 rounded-sm flex justify-center items-center text-white capitalize relative overflow-hidden text-xs">
{selectedOption[0] && selectedOption[0].avatar ? (
<img
src={selectedOption[0].avatar}
className="absolute top-0 left-0 h-full w-full object-cover"
alt={selectedOption[0].title}
/>
) : (
<div className="w-full h-full bg-gray-700 flex justify-center items-center">
{selectedOption[0].title[0]}
</div>
)}
</div>
<div className="line-clamp-1">{selectedOption[0].title}</div>
</div>
</Tooltip>
)}
</>
) : (
<Tooltip tooltipHeading={`Assignees`} tooltipContent={``}>
<div className="text-xs">Select Assignees</div>
</Tooltip>
)}
{dropdownArrow && !disabled && (
<div className="flex-shrink-0 w-[14px] h-[14px] flex justify-center items-center">
<ChevronDown width={14} strokeWidth={2} />
</div>
)}
</Combobox.Button>
<div className={`${open ? "fixed z-20 top-0 left-0 h-full w-full cursor-auto" : ""}`}>
<Combobox.Options
ref={dropdownOptions}
className={`absolute z-10 border border-custom-border-300 p-2 rounded bg-custom-background-100 text-xs shadow-lg focus:outline-none whitespace-nowrap mt-1 space-y-1 ${optionsClassName}`}
>
{options && options.length > 0 ? (
<>
<div className="flex w-full items-center justify-start rounded border border-custom-border-200 bg-custom-background-90 px-1">
<div className="flex-shrink-0 flex justify-center items-center w-[16px] h-[16px] rounded-sm">
<Search width={12} strokeWidth={2} />
</div>
<div>
<Combobox.Input
className="w-full bg-transparent p-1 text-xs text-custom-text-200 placeholder:text-custom-text-400 focus:outline-none"
value={search}
onChange={(e) => setSearch(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
/>
</div>
{search && search.length > 0 && (
<div
onClick={() => setSearch("")}
className="flex-shrink-0 flex justify-center items-center w-[16px] h-[16px] rounded-sm cursor-pointer hover:bg-custom-background-80"
>
<X width={12} strokeWidth={2} />
</div>
)}
</div>
<div className={`space-y-0.5 max-h-48 overflow-y-scroll`}>
{filteredOptions ? (
filteredOptions.length > 0 ? (
filteredOptions.map((option) => (
<Combobox.Option
key={option.id}
value={option.id}
className={({ active }) =>
`cursor-pointer select-none truncate rounded px-1 py-1.5 ${
active || (value && value.length > 0 && value.includes(option?.id))
? "bg-custom-background-80"
: ""
} ${
value && value.length > 0 && value.includes(option?.id)
? "text-custom-text-100"
: "text-custom-text-200"
}`
}
>
<div className="flex items-center gap-1 w-full px-1">
<div className="flex-shrink-0 w-[18px] h-[18px] rounded-sm flex justify-center items-center text-white capitalize relative overflow-hidden">
{option && option.avatar ? (
<img
src={option.avatar}
className="absolute top-0 left-0 h-full w-full object-cover"
alt={option.title}
/>
) : (
<div className="w-full h-full bg-gray-700 flex justify-center items-center">
{option.title[0]}
</div>
)}
</div>
<div className="line-clamp-1">{option.title}</div>
{value && value.length > 0 && value.includes(option?.id) && (
<div className="flex-shrink-0 ml-auto w-[13px] h-[13px] flex justify-center items-center">
<Check width={13} strokeWidth={2} />
</div>
)}
</div>
</Combobox.Option>
))
) : (
<span className="flex items-center gap-2 p-1">
<p className="text-left text-custom-text-200 ">No matching results</p>
</span>
)
) : (
<p className="text-center text-custom-text-200">Loading...</p>
)}
</div>
</>
) : (
<p className="text-center text-custom-text-200">No options available.</p>
)}
</Combobox.Options>
</div>
</>
);
}}
</Combobox>
); );
}); });

View File

@ -15,85 +15,81 @@ import useDynamicDropdownPosition from "hooks/use-dynamic-dropdown";
import { renderDateFormat } from "helpers/date-time.helper"; import { renderDateFormat } from "helpers/date-time.helper";
export interface IIssuePropertyDate { export interface IIssuePropertyDate {
value?: any; value: any;
onChange?: (date: any) => void; onChange: (date: any) => void;
disabled?: boolean; disabled?: boolean;
placeHolder?: string; placeHolder?: string;
} }
export const IssuePropertyDate: React.FC<IIssuePropertyDate> = observer( export const IssuePropertyDate: React.FC<IIssuePropertyDate> = observer((props) => {
({ value, onChange, disabled, placeHolder }) => { const { value, onChange, disabled, placeHolder } = props;
const dropdownBtn = React.useRef<any>(null);
const dropdownOptions = React.useRef<any>(null);
const [isOpen, setIsOpen] = React.useState<boolean>(false); const dropdownBtn = React.useRef<any>(null);
const dropdownOptions = React.useRef<any>(null);
useDynamicDropdownPosition(isOpen, () => setIsOpen(false), dropdownBtn, dropdownOptions); const [isOpen, setIsOpen] = React.useState<boolean>(false);
return ( useDynamicDropdownPosition(isOpen, () => setIsOpen(false), dropdownBtn, dropdownOptions);
<Popover as="div" className="relative">
{({ open }) => {
if (open) {
if (!isOpen) setIsOpen(true);
} else if (isOpen) setIsOpen(false);
return ( return (
<> <Popover as="div" className="relative">
<Popover.Button {({ open }) => {
ref={dropdownBtn} if (open) {
className={`flex items-center justify-between gap-1 px-1 py-0.5 rounded-sm shadow-sm border border-custom-border-300 duration-300 outline-none ${ if (!isOpen) setIsOpen(true);
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80" } else if (isOpen) setIsOpen(false);
}`}
>
<Tooltip tooltipHeading={placeHolder ? placeHolder : `Select date`} tooltipContent={value}>
<div className="flex-shrink-0 overflow-hidden rounded-sm flex justify-center items-center">
<div className="flex-shrink-0 w-[16px] h-[16px] flex justify-center items-center">
<Calendar width={10} strokeWidth={2} />
</div>
{value ? (
<>
<div className="px-1 text-xs">{value}</div>
<div
className="flex-shrink-0 w-[16px] h-[16px] flex justify-center items-center cursor-pointer"
onClick={() => {
if (onChange) onChange(null);
}}
>
<X width={10} strokeWidth={2} />
</div>
</>
) : (
<div className="text-xs">{placeHolder ? placeHolder : `Select date`}</div>
)}
</div>
</Tooltip>
</Popover.Button>
<div className={`${open ? "fixed z-20 top-0 left-0 h-full w-full cursor-auto" : ""}`}> return (
<Popover.Panel <>
ref={dropdownOptions} <Popover.Button
className={`absolute z-10 rounded bg-custom-background-100 text-xs shadow-lg focus:outline-none whitespace-nowrap mt-1`} ref={dropdownBtn}
> className={`px-2.5 py-1 h-5 flex items-center rounded border-[0.5px] border-custom-border-300 duration-300 outline-none ${
{({ close }) => ( disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
<DatePicker }`}
selected={value ? new Date(value) : new Date()} >
onChange={(val: any) => { <Tooltip tooltipHeading={placeHolder} tooltipContent={value ?? "None"}>
if (onChange && val) { <div className="overflow-hidden flex justify-center items-center gap-2">
onChange(renderDateFormat(val)); <Calendar className="h-3 w-3" strokeWidth={2} />
close(); {value && (
} <>
}} <div className="text-xs">{value}</div>
dateFormat="dd-MM-yyyy" <div
calendarClassName="h-full" className="flex-shrink-0 flex justify-center items-center"
inline onClick={() => {
/> if (onChange) onChange(null);
}}
>
<X className="h-2.5 w-2.5" strokeWidth={2} />
</div>
</>
)} )}
</Popover.Panel> </div>
</div> </Tooltip>
</> </Popover.Button>
);
}} <div className={`${open ? "fixed z-20 top-0 left-0 h-full w-full cursor-auto" : ""}`}>
</Popover> <Popover.Panel
); ref={dropdownOptions}
} className={`absolute z-10 rounded bg-custom-background-100 text-xs shadow-lg focus:outline-none whitespace-nowrap mt-1`}
); >
{({ close }) => (
<DatePicker
selected={value ? new Date(value) : new Date()}
onChange={(val: any) => {
if (onChange && val) {
onChange(renderDateFormat(val));
close();
}
}}
dateFormat="dd-MM-yyyy"
calendarClassName="h-full"
inline
/>
)}
</Popover.Panel>
</div>
</>
);
}}
</Popover>
);
});

View File

@ -1,217 +1,28 @@
import React from "react";
// headless ui
import { Combobox } from "@headlessui/react";
// lucide icons
import { ChevronDown, Search, X, Check, Triangle } from "lucide-react";
// mobx
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// components // components
import { Tooltip } from "@plane/ui"; import { EstimateSelect } from "components/estimates";
// hooks // types
import useDynamicDropdownPosition from "hooks/use-dynamic-dropdown"; import { IEstimatePoint } from "types";
// mobx
import { useMobxStore } from "lib/mobx/store-provider";
import { RootStore } from "store/root";
interface IFiltersOption {
id: string;
title: string;
key: string;
}
export interface IIssuePropertyEstimates { export interface IIssuePropertyEstimates {
value?: any; value: number | null;
onChange?: (id: any) => void; onChange: (value: number | null) => void;
estimatePoints: IEstimatePoint[] | null;
disabled?: boolean; disabled?: boolean;
hideDropdownArrow?: boolean;
workspaceSlug?: string;
projectId?: string;
className?: string;
buttonClassName?: string;
optionsClassName?: string;
dropdownArrow?: boolean;
} }
export const IssuePropertyEstimates: React.FC<IIssuePropertyEstimates> = observer( export const IssuePropertyEstimates: React.FC<IIssuePropertyEstimates> = observer((props) => {
({ const { value, onChange, estimatePoints, disabled, hideDropdownArrow = false } = props;
value,
onChange,
disabled,
workspaceSlug, return (
projectId, <EstimateSelect
value={value}
className, onChange={onChange}
buttonClassName, estimatePoints={estimatePoints ?? undefined}
optionsClassName, buttonClassName="h-5"
dropdownArrow = true, disabled={disabled}
}) => { hideDropdownArrow={hideDropdownArrow}
const { project: projectStore }: RootStore = useMobxStore(); />
);
const dropdownBtn = React.useRef<any>(null); });
const dropdownOptions = React.useRef<any>(null);
const [isOpen, setIsOpen] = React.useState<boolean>(false);
const [search, setSearch] = React.useState<string>("");
const projectDetail =
(workspaceSlug && projectId && projectStore?.getProjectById(workspaceSlug, projectId)) || null;
const projectEstimateId = (projectDetail && projectDetail?.estimate) || null;
const estimates = (projectEstimateId && projectStore?.getProjectEstimateById(projectEstimateId)) || null;
const options: IFiltersOption[] | [] =
(estimates &&
estimates.points &&
estimates.points.length > 0 &&
estimates.points.map((_estimate) => ({
id: _estimate?.id,
title: _estimate?.value,
key: _estimate?.key.toString(),
}))) ||
[];
useDynamicDropdownPosition(isOpen, () => setIsOpen(false), dropdownBtn, dropdownOptions);
const selectedOption: IFiltersOption | null | undefined =
(value && options.find((_estimate: IFiltersOption) => _estimate.key === value)) || null;
const filteredOptions: IFiltersOption[] =
search === ""
? options && options.length > 0
? options
: []
: options && options.length > 0
? options.filter((_estimate: IFiltersOption) =>
_estimate.title.toLowerCase().replace(/\s+/g, "").includes(search.toLowerCase().replace(/\s+/g, ""))
)
: [];
return (
<Combobox
as="div"
className={`${className}`}
value={selectedOption && selectedOption.key}
onChange={(data: string) => {
if (onChange) onChange(data);
}}
disabled={disabled}
>
{({ open }: { open: boolean }) => {
if (open) {
if (!isOpen) setIsOpen(true);
} else if (isOpen) setIsOpen(false);
return (
<>
<Combobox.Button
ref={dropdownBtn}
type="button"
className={`flex items-center justify-between gap-1 px-1 py-0.5 rounded-sm shadow-sm border border-custom-border-300 duration-300 outline-none ${
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
} ${buttonClassName}`}
>
{selectedOption ? (
<Tooltip tooltipHeading={`Estimates`} tooltipContent={selectedOption?.title}>
<div className="flex-shrink-0 flex justify-center items-center gap-1">
<div className="flex-shrink-0 w-[12px] h-[12px] flex justify-center items-center">
<Triangle width={14} strokeWidth={2} />
</div>
<div className="pl-0.5 pr-1 text-xs">{selectedOption?.title}</div>
</div>
</Tooltip>
) : (
<Tooltip tooltipHeading={`Estimates`} tooltipContent={``}>
<div className="text-xs">Select Estimates</div>
</Tooltip>
)}
{dropdownArrow && !disabled && (
<div className="flex-shrink-0 w-[14px] h-[14px] flex justify-center items-center">
<ChevronDown width={14} strokeWidth={2} />
</div>
)}
</Combobox.Button>
<div className={`${open ? "fixed z-20 top-0 left-0 h-full w-full cursor-auto" : ""}`}>
<Combobox.Options
ref={dropdownOptions}
className={`absolute z-10 border border-custom-border-300 p-2 rounded bg-custom-background-100 text-xs shadow-lg focus:outline-none whitespace-nowrap mt-1 space-y-1 ${optionsClassName}`}
>
{options && options.length > 0 ? (
<>
<div className="flex w-full items-center justify-start rounded border border-custom-border-200 bg-custom-background-90 px-1">
<div className="flex-shrink-0 flex justify-center items-center w-[16px] h-[16px] rounded-sm">
<Search width={12} strokeWidth={2} />
</div>
<div>
<Combobox.Input
className="w-full bg-transparent p-1 text-xs text-custom-text-200 placeholder:text-custom-text-400 focus:outline-none"
value={search}
onChange={(e) => setSearch(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
/>
</div>
{search && search.length > 0 && (
<div
onClick={() => setSearch("")}
className="flex-shrink-0 flex justify-center items-center w-[16px] h-[16px] rounded-sm cursor-pointer hover:bg-custom-background-80"
>
<X width={12} strokeWidth={2} />
</div>
)}
</div>
<div className={`space-y-0.5 max-h-48 overflow-y-scroll`}>
{filteredOptions ? (
filteredOptions.length > 0 ? (
filteredOptions.map((option) => (
<Combobox.Option
key={option.key}
value={option.key}
className={({ active, selected }) =>
`cursor-pointer select-none truncate rounded px-1 py-1.5 ${
active || selected ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
}
>
{({ selected }) => (
<div className="flex items-center gap-1 w-full px-1">
<div className="flex-shrink-0 w-[13px] h-[13px] flex justify-center items-center">
<Triangle width={14} strokeWidth={2} />
</div>
<div className="line-clamp-1">{option.title}</div>
{selected && (
<div className="flex-shrink-0 ml-auto w-[13px] h-[13px] flex justify-center items-center">
<Check width={13} strokeWidth={2} />
</div>
)}
</div>
)}
</Combobox.Option>
))
) : (
<span className="flex items-center gap-2 p-1">
<p className="text-left text-custom-text-200 ">No matching results</p>
</span>
)
) : (
<p className="text-center text-custom-text-200">Loading...</p>
)}
</div>
</>
) : (
<p className="text-center text-custom-text-200">No options available.</p>
)}
</Combobox.Options>
</div>
</>
);
}}
</Combobox>
);
}
);

View File

@ -1,230 +1,28 @@
import { FC, useRef, useState } from "react";
import { Combobox } from "@headlessui/react";
import { ChevronDown, Search, X, Check } from "lucide-react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// components // components
import { Tooltip } from "@plane/ui"; import { LabelSelect } from "components/project";
// hooks // types
import useDynamicDropdownPosition from "hooks/use-dynamic-dropdown"; import { IIssueLabels } from "types";
interface IFiltersOption {
id: string;
title: string;
color: string | null;
}
export interface IIssuePropertyLabels { export interface IIssuePropertyLabels {
value?: any; value: string[];
onChange?: (id: any, data: any) => void; onChange: (data: string[]) => void;
labels: IIssueLabels[] | null;
disabled?: boolean; disabled?: boolean;
list?: any; hideDropdownArrow?: boolean;
className?: string;
buttonClassName?: string;
optionsClassName?: string;
dropdownArrow?: boolean;
} }
export const IssuePropertyLabels: FC<IIssuePropertyLabels> = observer((props) => { export const IssuePropertyLabels: React.FC<IIssuePropertyLabels> = observer((props) => {
const { const { value, onChange, labels, disabled, hideDropdownArrow = false } = props;
value,
onChange,
disabled,
list,
className,
buttonClassName,
optionsClassName,
dropdownArrow = true,
} = props;
const dropdownBtn = useRef<any>(null);
const dropdownOptions = useRef<any>(null);
const [isOpen, setIsOpen] = useState<boolean>(false);
const [search, setSearch] = useState<string>("");
const options: IFiltersOption[] | [] =
(list &&
list?.length > 0 &&
list.map((_label: any) => ({
id: _label?.id,
title: _label?.name,
color: _label?.color || null,
}))) ||
[];
useDynamicDropdownPosition(isOpen, () => setIsOpen(false), dropdownBtn, dropdownOptions);
const selectedOption: IFiltersOption[] =
(value && value?.length > 0 && options.filter((_label: IFiltersOption) => value.includes(_label.id))) || [];
const filteredOptions: IFiltersOption[] =
search === ""
? options && options.length > 0
? options
: []
: options && options.length > 0
? options.filter((_label: IFiltersOption) =>
_label.title.toLowerCase().replace(/\s+/g, "").includes(search.toLowerCase().replace(/\s+/g, ""))
)
: [];
return ( return (
<Combobox <LabelSelect
multiple={true} value={value}
as="div" onChange={onChange}
className={`${className}`} labels={labels ?? undefined}
value={selectedOption.map((_label: IFiltersOption) => _label.id) as string[]} buttonClassName="h-5"
onChange={(data: string[]) => {
if (onChange && selectedOption) onChange(data, selectedOption);
}}
disabled={disabled} disabled={disabled}
> hideDropdownArrow={hideDropdownArrow}
{({ open }: { open: boolean }) => { />
if (open) {
if (!isOpen) setIsOpen(true);
} else if (isOpen) setIsOpen(false);
return (
<>
<Combobox.Button
ref={dropdownBtn}
type="button"
className={`flex items-center justify-between gap-1 px-1 py-0.5 rounded-sm shadow-sm border border-custom-border-300 duration-300 outline-none ${
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
} ${buttonClassName}`}
>
{selectedOption && selectedOption?.length > 0 ? (
<>
{selectedOption?.length === 1 ? (
<Tooltip
tooltipHeading={`Labels`}
tooltipContent={(selectedOption.map((_label: IFiltersOption) => _label.title) || []).join(", ")}
>
<div className="flex-shrink-0 flex justify-center items-center gap-1">
<div
className="flex-shrink-0 w-[10px] h-[10px] rounded-full"
style={{
backgroundColor: selectedOption[0]?.color || "#444",
}}
/>
<div className="pl-0.5 pr-1 text-xs">{selectedOption[0]?.title}</div>
</div>
</Tooltip>
) : (
<Tooltip
tooltipHeading={`Labels`}
tooltipContent={(selectedOption.map((_label: IFiltersOption) => _label.title) || []).join(", ")}
>
<div className="flex-shrink-0 flex justify-center items-center gap-1">
<div
className="flex-shrink-0 w-[10px] h-[10px] rounded-full"
style={{ backgroundColor: "#444" }}
/>
<div className="pl-0.5 pr-1 text-xs">{selectedOption?.length} Labels</div>
</div>
</Tooltip>
)}
</>
) : (
<Tooltip tooltipHeading={`Labels`} tooltipContent={``}>
<div className="text-xs">Select Labels</div>
</Tooltip>
)}
{dropdownArrow && !disabled && (
<div className="flex-shrink-0 w-[14px] h-[14px] flex justify-center items-center">
<ChevronDown width={14} strokeWidth={2} />
</div>
)}
</Combobox.Button>
<div className={`${open ? "fixed z-20 top-0 left-0 h-full w-full cursor-auto" : ""}`}>
<Combobox.Options
ref={dropdownOptions}
className={`absolute z-10 border border-custom-border-300 p-2 rounded bg-custom-background-100 text-xs shadow-lg focus:outline-none whitespace-nowrap mt-1 space-y-1 ${optionsClassName}`}
>
{options && options.length > 0 ? (
<>
<div className="flex w-full items-center justify-start rounded border border-custom-border-200 bg-custom-background-90 px-1">
<div className="flex-shrink-0 flex justify-center items-center w-[16px] h-[16px] rounded-sm">
<Search width={12} strokeWidth={2} />
</div>
<div>
<Combobox.Input
className="w-full bg-transparent p-1 text-xs text-custom-text-200 placeholder:text-custom-text-400 focus:outline-none"
value={search}
onChange={(e) => setSearch(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
/>
</div>
{search && search.length > 0 && (
<div
onClick={() => setSearch("")}
className="flex-shrink-0 flex justify-center items-center w-[16px] h-[16px] rounded-sm cursor-pointer hover:bg-custom-background-80"
>
<X width={12} strokeWidth={2} />
</div>
)}
</div>
<div className={`space-y-0.5 max-h-48 overflow-y-scroll`}>
{filteredOptions ? (
filteredOptions.length > 0 ? (
filteredOptions.map((option) => (
<Combobox.Option
key={option.id}
value={option.id}
className={({ active }) =>
`cursor-pointer select-none truncate rounded px-1 py-1.5 ${
active || (value && value.length > 0 && value.includes(option?.id))
? "bg-custom-background-80"
: ""
} ${
value && value.length > 0 && value.includes(option?.id)
? "text-custom-text-100"
: "text-custom-text-200"
}`
}
>
<div className="flex items-center gap-1 w-full px-1">
<div
className="flex-shrink-0 w-[10px] h-[10px] rounded-full"
style={{
backgroundColor: option.color || "#444",
}}
/>
<div className="line-clamp-1">{option.title}</div>
{value && value.length > 0 && value.includes(option?.id) && (
<div className="flex-shrink-0 ml-auto w-[13px] h-[13px] flex justify-center items-center">
<Check width={13} strokeWidth={2} />
</div>
)}
</div>
</Combobox.Option>
))
) : (
<span className="flex items-center gap-2 p-1">
<p className="text-left text-custom-text-200 ">No matching results</p>
</span>
)
) : (
<p className="text-center text-custom-text-200">Loading...</p>
)}
</div>
</>
) : (
<p className="text-center text-custom-text-200">No options available.</p>
)}
</Combobox.Options>
</div>
</>
);
}}
</Combobox>
); );
}); });

View File

@ -1,223 +1,25 @@
import { FC, useRef, useState } from "react"; import { PrioritySelect } from "components/project";
import { Combobox } from "@headlessui/react";
import { ChevronDown, Search, X, Check, AlertCircle, SignalHigh, SignalMedium, SignalLow, Ban } from "lucide-react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// components // types
import { Tooltip } from "@plane/ui"; import { TIssuePriorities } from "types";
// hooks
import useDynamicDropdownPosition from "hooks/use-dynamic-dropdown";
interface IFiltersOption {
id: string;
title: string;
}
export interface IIssuePropertyPriority { export interface IIssuePropertyPriority {
value?: any; value: TIssuePriorities;
onChange?: (id: any, data: IFiltersOption) => void; onChange: (value: TIssuePriorities) => void;
disabled?: boolean; disabled?: boolean;
list?: any; hideDropdownArrow?: boolean;
className?: string;
buttonClassName?: string;
optionsClassName?: string;
dropdownArrow?: boolean;
} }
const Icon = ({ priority }: any) => ( export const IssuePropertyPriority: React.FC<IIssuePropertyPriority> = observer((props) => {
<div className="w-full h-full"> const { value, onChange, disabled, hideDropdownArrow = false } = props;
{priority === "urgent" ? (
<div className="border border-red-500 bg-red-500 text-white w-full h-full overflow-hidden flex justify-center items-center rounded-sm">
<AlertCircle size={12} strokeWidth={2} />
</div>
) : priority === "high" ? (
<div className="border border-red-500/20 bg-red-500/10 text-red-500 w-full h-full overflow-hidden flex justify-center items-center rounded-sm">
<SignalHigh size={12} strokeWidth={2} className="pl-[3px]" />
</div>
) : priority === "medium" ? (
<div className="border border-orange-500/20 bg-orange-500/10 text-orange-500 w-full h-full overflow-hidden flex justify-center items-center rounded-sm">
<SignalMedium size={12} strokeWidth={2} className="pl-[3px]" />
</div>
) : priority === "low" ? (
<div className="border border-green-500/20 bg-green-500/10 text-green-500 w-full h-full overflow-hidden flex justify-center items-center rounded-sm">
<SignalLow size={12} strokeWidth={2} className="pl-[3px]" />
</div>
) : (
<div className="border border-custom-border-400/20 bg-custom-text-400/10 text-custom-text-400 w-full h-full overflow-hidden flex justify-center items-center rounded-sm">
<Ban size={12} strokeWidth={2} />
</div>
)}
</div>
);
export const IssuePropertyPriority: FC<IIssuePropertyPriority> = observer((props) => {
const {
value,
onChange,
disabled,
list,
className,
buttonClassName,
optionsClassName,
dropdownArrow = true,
} = props;
const dropdownBtn = useRef<any>(null);
const dropdownOptions = useRef<any>(null);
const [isOpen, setIsOpen] = useState<boolean>(false);
const [search, setSearch] = useState<string>("");
const options: IFiltersOption[] | [] =
(list &&
list?.length > 0 &&
list.map((_priority: any) => ({
id: _priority?.key,
title: _priority?.title,
}))) ||
[];
useDynamicDropdownPosition(isOpen, () => setIsOpen(false), dropdownBtn, dropdownOptions);
const selectedOption: IFiltersOption | null | undefined =
(value && options.find((_priority: IFiltersOption) => _priority.id === value)) || null;
const filteredOptions: IFiltersOption[] =
search === ""
? options && options.length > 0
? options
: []
: options && options.length > 0
? options.filter((_priority: IFiltersOption) =>
_priority.title.toLowerCase().replace(/\s+/g, "").includes(search.toLowerCase().replace(/\s+/g, ""))
)
: [];
return ( return (
<Combobox <PrioritySelect
as="div" value={value}
className={`${className}`} onChange={onChange}
value={selectedOption && selectedOption.id} buttonClassName="!h-5 p-1.5"
onChange={(data: string) => {
if (onChange && selectedOption) onChange(data, selectedOption);
}}
disabled={disabled} disabled={disabled}
> hideDropdownArrow={hideDropdownArrow}
{({ open }: { open: boolean }) => { />
if (open) {
if (!isOpen) setIsOpen(true);
} else if (isOpen) setIsOpen(false);
return (
<>
<Combobox.Button
ref={dropdownBtn}
type="button"
className={`flex items-center justify-between gap-1 px-1 py-0.5 rounded-sm shadow-sm border border-custom-border-300 duration-300 outline-none ${
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
} ${buttonClassName}`}
>
{selectedOption ? (
<Tooltip tooltipHeading={`Priority`} tooltipContent={selectedOption?.title}>
<div className="flex-shrink-0 flex justify-center items-center gap-1">
<div className="flex-shrink-0 w-[16px] h-[16px] flex justify-center items-center">
<Icon priority={selectedOption?.id} />
</div>
<div className="pl-0.5 pr-1 text-xs">{selectedOption?.title}</div>
</div>
</Tooltip>
) : (
<Tooltip tooltipHeading={`Priority`} tooltipContent={``}>
<div className="text-xs">Select Priority</div>
</Tooltip>
)}
{dropdownArrow && !disabled && (
<div className="flex-shrink-0 w-[14px] h-[14px] flex justify-center items-center">
<ChevronDown width={14} strokeWidth={2} />
</div>
)}
</Combobox.Button>
<div className={`${open ? "fixed z-20 top-0 left-0 h-full w-full cursor-auto" : ""}`}>
<Combobox.Options
ref={dropdownOptions}
className={`absolute z-10 border border-custom-border-300 p-2 rounded bg-custom-background-100 text-xs shadow-lg focus:outline-none whitespace-nowrap mt-1 space-y-1 ${optionsClassName}`}
>
{options && options.length > 0 ? (
<>
<div className="flex w-full items-center justify-start rounded border border-custom-border-200 bg-custom-background-90 px-1">
<div className="flex-shrink-0 flex justify-center items-center w-[16px] h-[16px] rounded-sm">
<Search width={12} strokeWidth={2} />
</div>
<div>
<Combobox.Input
className="w-full bg-transparent p-1 text-xs text-custom-text-200 placeholder:text-custom-text-400 focus:outline-none"
value={search}
onChange={(e) => setSearch(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
/>
</div>
{search && search.length > 0 && (
<div
onClick={() => setSearch("")}
className="flex-shrink-0 flex justify-center items-center w-[16px] h-[16px] rounded-sm cursor-pointer hover:bg-custom-background-80"
>
<X width={12} strokeWidth={2} />
</div>
)}
</div>
<div className={`space-y-0.5 max-h-48 overflow-y-scroll`}>
{filteredOptions ? (
filteredOptions.length > 0 ? (
filteredOptions.map((option) => (
<Combobox.Option
key={option.id}
value={option.id}
className={({ active, selected }) =>
`cursor-pointer select-none truncate rounded px-1 py-1.5 ${
active || selected ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
}
>
{({ selected }) => (
<div className="flex items-center gap-1 w-full px-1">
<div className="flex-shrink-0 w-[16px] h-[16px] flex justify-center items-center">
<Icon priority={option?.id} />
</div>
<div className="line-clamp-1">{option.title}</div>
{selected && (
<div className="flex-shrink-0 ml-auto w-[13px] h-[13px] flex justify-center items-center">
<Check width={13} strokeWidth={2} />
</div>
)}
</div>
)}
</Combobox.Option>
))
) : (
<span className="flex items-center gap-2 p-1">
<p className="text-left text-custom-text-200 ">No matching results</p>
</span>
)
) : (
<p className="text-center text-custom-text-200">Loading...</p>
)}
</div>
</>
) : (
<p className="text-center text-custom-text-200">No options available.</p>
)}
</Combobox.Options>
</div>
</>
);
}}
</Combobox>
); );
}); });

View File

@ -1,214 +1,28 @@
import { FC, useRef, useState } from "react";
import { Combobox } from "@headlessui/react";
import { ChevronDown, Search, X, Check } from "lucide-react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// components // components
import { Tooltip, StateGroupIcon } from "@plane/ui"; import { StateSelect } from "components/states";
// hooks
import useDynamicDropdownPosition from "hooks/use-dynamic-dropdown";
// types // types
import { IState } from "types"; import { IState } from "types";
interface IFiltersOption {
id: string;
title: string;
group: string;
color: string | null;
}
export interface IIssuePropertyState { export interface IIssuePropertyState {
value?: any; value: IState;
onChange?: (id: any, data: IFiltersOption) => void; onChange: (state: IState) => void;
states: IState[] | null;
disabled?: boolean; disabled?: boolean;
list?: any; hideDropdownArrow?: boolean;
className?: string;
buttonClassName?: string;
optionsClassName?: string;
dropdownArrow?: boolean;
} }
export const IssuePropertyState: FC<IIssuePropertyState> = observer((props) => { export const IssuePropertyState: React.FC<IIssuePropertyState> = observer((props) => {
const { const { value, onChange, states, disabled, hideDropdownArrow = false } = props;
value,
onChange,
disabled,
list,
className,
buttonClassName,
optionsClassName,
dropdownArrow = true,
} = props;
const dropdownBtn = useRef<any>(null);
const dropdownOptions = useRef<any>(null);
const [isOpen, setIsOpen] = useState<boolean>(false);
const [search, setSearch] = useState<string>("");
const options: IFiltersOption[] | [] =
(list &&
list?.length > 0 &&
list.map((_state: IState) => ({
id: _state?.id,
title: _state?.name,
group: _state?.group,
color: _state?.color || null,
}))) ||
[];
useDynamicDropdownPosition(isOpen, () => setIsOpen(false), dropdownBtn, dropdownOptions);
const selectedOption: IFiltersOption | null | undefined =
(value && options.find((_state: IFiltersOption) => _state.id === value)) || null;
const filteredOptions: IFiltersOption[] =
search === ""
? options && options.length > 0
? options
: []
: options && options.length > 0
? options.filter((_state: IFiltersOption) =>
_state.title.toLowerCase().replace(/\s+/g, "").includes(search.toLowerCase().replace(/\s+/g, ""))
)
: [];
return ( return (
<Combobox <StateSelect
as="div" value={value}
className={`${className}`} onChange={onChange}
value={selectedOption && selectedOption.id} states={states ?? undefined}
onChange={(data: string) => { buttonClassName="h-5"
if (onChange && selectedOption) onChange(data, selectedOption);
}}
disabled={disabled} disabled={disabled}
> hideDropdownArrow={hideDropdownArrow}
{({ open }: { open: boolean }) => { />
if (open) {
if (!isOpen) setIsOpen(true);
} else if (isOpen) setIsOpen(false);
return (
<>
<Combobox.Button
ref={dropdownBtn}
type="button"
className={`flex items-center justify-between gap-1 px-1 py-0.5 rounded-sm shadow-sm border border-custom-border-300 duration-300 outline-none ${
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
} ${buttonClassName}`}
>
{selectedOption ? (
<Tooltip tooltipHeading={`State`} tooltipContent={selectedOption?.title}>
<div className="flex-shrink-0 flex justify-center items-center gap-1">
<div className="flex-shrink-0 w-[12px] h-[12px] flex justify-center items-center">
<StateGroupIcon
stateGroup={selectedOption?.group as any}
color={(selectedOption?.color || null) as any}
width="12"
height="12"
/>
</div>
<div className="pl-0.5 pr-1 text-xs">{selectedOption?.title}</div>
</div>
</Tooltip>
) : (
<Tooltip tooltipHeading={`State`} tooltipContent={``}>
<div className="text-xs">Select State</div>
</Tooltip>
)}
{dropdownArrow && !disabled && (
<div className="flex-shrink-0 w-[14px] h-[14px] flex justify-center items-center">
<ChevronDown width={14} strokeWidth={2} />
</div>
)}
</Combobox.Button>
<div className={`${open ? "fixed z-20 top-0 left-0 h-full w-full cursor-auto" : ""}`}>
<Combobox.Options
ref={dropdownOptions}
className={`absolute z-10 border border-custom-border-300 p-2 rounded bg-custom-background-100 text-xs shadow-lg focus:outline-none whitespace-nowrap mt-1 space-y-1 ${optionsClassName}`}
>
{options && options.length > 0 ? (
<>
<div className="flex w-full items-center justify-start rounded border border-custom-border-200 bg-custom-background-90 px-1">
<div className="flex-shrink-0 flex justify-center items-center w-[16px] h-[16px] rounded-sm">
<Search width={12} strokeWidth={2} />
</div>
<div>
<Combobox.Input
className="w-full bg-transparent p-1 text-xs text-custom-text-200 placeholder:text-custom-text-400 focus:outline-none"
value={search}
onChange={(e) => setSearch(e.target.value)}
placeholder="Search"
displayValue={(assigned: any) => assigned?.name}
/>
</div>
{search && search.length > 0 && (
<div
onClick={() => setSearch("")}
className="flex-shrink-0 flex justify-center items-center w-[16px] h-[16px] rounded-sm cursor-pointer hover:bg-custom-background-80"
>
<X width={12} strokeWidth={2} />
</div>
)}
</div>
<div className={`space-y-0.5 max-h-48 overflow-y-scroll`}>
{filteredOptions ? (
filteredOptions.length > 0 ? (
filteredOptions.map((option) => (
<Combobox.Option
key={option.id}
value={option.id}
className={({ active, selected }) =>
`cursor-pointer select-none truncate rounded px-1 py-1.5 ${
active || selected ? "bg-custom-background-80" : ""
} ${selected ? "text-custom-text-100" : "text-custom-text-200"}`
}
>
{({ selected }) => (
<div className="flex items-center gap-1 w-full px-1">
<div className="flex-shrink-0 w-[13px] h-[13px] flex justify-center items-center">
<StateGroupIcon
stateGroup={option?.group as any}
color={(option?.color || null) as any}
width="13"
height="13"
/>
</div>
<div className="line-clamp-1">{option.title}</div>
{selected && (
<div className="flex-shrink-0 ml-auto w-[13px] h-[13px] flex justify-center items-center">
<Check width={13} strokeWidth={2} />
</div>
)}
</div>
)}
</Combobox.Option>
))
) : (
<span className="flex items-center gap-2 p-1">
<p className="text-left text-custom-text-200 ">No matching results</p>
</span>
)
) : (
<p className="text-center text-custom-text-200">Loading...</p>
)}
</div>
</>
) : (
<p className="text-center text-custom-text-200">No options available.</p>
)}
</Combobox.Options>
</div>
</>
);
}}
</Combobox>
); );
}); });

View File

@ -4,6 +4,8 @@ import React from "react";
import { StateSelect } from "components/states"; import { StateSelect } from "components/states";
// hooks // hooks
import useSubIssue from "hooks/use-sub-issue"; import useSubIssue from "hooks/use-sub-issue";
// helpers
import { getStatesList } from "helpers/state.helper";
// types // types
import { IIssue, IStateResponse } from "types"; import { IIssue, IStateResponse } from "types";
@ -22,12 +24,14 @@ export const SpreadsheetStateColumn: React.FC<Props> = (props) => {
const { subIssues, isLoading } = useSubIssue(issue.project_detail.id, issue.id, isExpanded); const { subIssues, isLoading } = useSubIssue(issue.project_detail.id, issue.id, isExpanded);
const statesList = getStatesList(states);
return ( return (
<> <>
<StateSelect <StateSelect
value={issue.state_detail} value={issue.state_detail}
onChange={(data) => onChange({ state: data.id, state_detail: data })} onChange={(data) => onChange({ state: data.id, state_detail: data })}
stateGroups={states} states={statesList}
buttonClassName="!shadow-none !border-0" buttonClassName="!shadow-none !border-0"
hideDropdownArrow hideDropdownArrow
disabled={disabled} disabled={disabled}

View File

@ -2,3 +2,4 @@ export * from "./columns";
export * from "./roots"; export * from "./roots";
export * from "./spreadsheet-column"; export * from "./spreadsheet-column";
export * from "./spreadsheet-view"; export * from "./spreadsheet-view";
export * from "./inline-create-issue-form";

View File

@ -0,0 +1,207 @@
import { useEffect, useState, useRef } from "react";
import { useRouter } from "next/router";
import { useForm } from "react-hook-form";
import { Transition } from "@headlessui/react";
// hooks
import useToast from "hooks/use-toast";
import useKeypress from "hooks/use-keypress";
import useProjectDetails from "hooks/use-project-details";
import useOutsideClickDetector from "hooks/use-outside-click-detector";
// store
import { observer } from "mobx-react-lite";
import { useMobxStore } from "lib/mobx/store-provider";
// constants
import { createIssuePayload } from "constants/issue";
// types
import { IIssue } from "types";
import { PlusIcon } from "lucide-react";
type Props = {
groupId?: string;
prePopulatedData?: Partial<IIssue>;
onSuccess?: (data: IIssue) => Promise<void> | void;
};
const defaultValues: Partial<IIssue> = {
name: "",
};
const Inputs = (props: any) => {
const { register, setFocus, projectDetails } = props;
useEffect(() => {
setFocus("name");
}, [setFocus]);
return (
<>
<h4 className="text-sm font-medium leading-5 text-custom-text-400">{projectDetails?.identifier ?? "..."}</h4>
<input
type="text"
autoComplete="off"
placeholder="Issue Title"
{...register("name", {
required: "Issue title is required.",
})}
className="w-full px-2 py-3 rounded-md bg-transparent text-sm font-medium leading-5 text-custom-text-200 outline-none"
/>
</>
);
};
export const SpreadsheetInlineCreateIssueForm: React.FC<Props> = observer((props) => {
const { prePopulatedData, groupId } = props;
// router
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
// store
const { workspace: workspaceStore, quickAddIssue: quickAddStore } = useMobxStore();
const { projectDetails } = useProjectDetails();
const {
reset,
handleSubmit,
setFocus,
register,
formState: { errors, isSubmitting },
} = useForm<IIssue>({ defaultValues });
// ref
const ref = useRef<HTMLFormElement>(null);
// states
const [isOpen, setIsOpen] = useState(false);
const handleClose = () => setIsOpen(false);
// hooks
useKeypress("Escape", handleClose);
useOutsideClickDetector(ref, handleClose);
const { setToastAlert } = useToast();
// derived values
const workspaceDetail = workspaceStore.getWorkspaceBySlug(workspaceSlug?.toString()!);
useEffect(() => {
setFocus("name");
}, [setFocus, isOpen]);
useEffect(() => {
if (!isOpen) reset({ ...defaultValues });
}, [isOpen, reset]);
useEffect(() => {
if (!errors) return;
Object.keys(errors).forEach((key) => {
const error = errors[key as keyof IIssue];
setToastAlert({
type: "error",
title: "Error!",
message: error?.message?.toString() || "Some error occurred. Please try again.",
});
});
}, [errors, setToastAlert]);
const onSubmitHandler = async (formData: IIssue) => {
if (isSubmitting || !workspaceSlug || !projectId) return;
// resetting the form so that user can add another issue quickly
reset({ ...defaultValues });
const payload = createIssuePayload(workspaceDetail!, projectDetails!, {
...(prePopulatedData ?? {}),
...formData,
labels_list:
formData.labels_list && formData.labels_list?.length !== 0
? formData.labels_list
: prePopulatedData?.labels && prePopulatedData?.labels.toString() !== "none"
? [prePopulatedData.labels as any]
: [],
assignees_list:
formData.assignees_list && formData.assignees_list?.length !== 0
? formData.assignees_list
: prePopulatedData?.assignees && prePopulatedData?.assignees.toString() !== "none"
? [prePopulatedData.assignees as any]
: [],
});
try {
quickAddStore.createIssue(
workspaceSlug.toString(),
projectId.toString(),
{
group_id: groupId ?? null,
sub_group_id: null,
},
payload
);
setToastAlert({
type: "success",
title: "Success!",
message: "Issue created successfully.",
});
} catch (err: any) {
Object.keys(err || {}).forEach((key) => {
const error = err?.[key];
const errorTitle = error ? (Array.isArray(error) ? error.join(", ") : error) : null;
setToastAlert({
type: "error",
title: "Error!",
message: errorTitle || "Some error occurred. Please try again.",
});
});
}
};
return (
<div>
<Transition
show={isOpen}
enter="transition ease-in-out duration-200 transform"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="transition ease-in-out duration-200 transform"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<div>
<form
ref={ref}
onSubmit={handleSubmit(onSubmitHandler)}
className="flex border-[0.5px] border-t-0 border-custom-border-100 px-4 items-center gap-x-5 bg-custom-background-100 shadow-custom-shadow-sm z-10"
>
<Inputs register={register} setFocus={setFocus} projectDetails={projectDetails} />
</form>
</div>
</Transition>
{isOpen && (
<p className="text-xs ml-3 mt-3 italic text-custom-text-200">
Press {"'"}Enter{"'"} to add another issue
</p>
)}
{!isOpen && (
<button
type="button"
className="flex items-center gap-x-[6px] text-custom-primary-100 px-2 py-1 rounded-md"
onClick={() => setIsOpen(true)}
>
<PlusIcon className="h-4 w-4" />
<span className="text-sm font-medium text-custom-primary-100">New Issue</span>
</button>
)}
</div>
);
});

View File

@ -66,6 +66,7 @@ export const ProjectSpreadsheetLayout: React.FC = observer(() => {
handleIssueAction={() => {}} handleIssueAction={() => {}}
handleUpdateIssue={handleUpdateIssue} handleUpdateIssue={handleUpdateIssue}
disableUserActions={false} disableUserActions={false}
enableQuickCreateIssue
/> />
); );
}); });

View File

@ -3,11 +3,7 @@ import { useRouter } from "next/router";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { PlusIcon } from "lucide-react"; import { PlusIcon } from "lucide-react";
// components // components
import { import { SpreadsheetColumnsList, SpreadsheetIssuesColumn, SpreadsheetInlineCreateIssueForm } from "components/issues";
SpreadsheetColumnsList,
// ListInlineCreateIssueForm,
SpreadsheetIssuesColumn,
} from "components/issues";
import { CustomMenu, Spinner } from "@plane/ui"; import { CustomMenu, Spinner } from "@plane/ui";
// types // types
import { import {
@ -31,6 +27,7 @@ type Props = {
handleUpdateIssue: (issue: IIssue, data: Partial<IIssue>) => void; handleUpdateIssue: (issue: IIssue, data: Partial<IIssue>) => void;
openIssuesListModal?: (() => void) | null; openIssuesListModal?: (() => void) | null;
disableUserActions: boolean; disableUserActions: boolean;
enableQuickCreateIssue?: boolean;
}; };
export const SpreadsheetView: React.FC<Props> = observer((props) => { export const SpreadsheetView: React.FC<Props> = observer((props) => {
@ -46,6 +43,7 @@ export const SpreadsheetView: React.FC<Props> = observer((props) => {
handleUpdateIssue, handleUpdateIssue,
openIssuesListModal, openIssuesListModal,
disableUserActions, disableUserActions,
enableQuickCreateIssue,
} = props; } = props;
const [expandedIssues, setExpandedIssues] = useState<string[]>([]); const [expandedIssues, setExpandedIssues] = useState<string[]>([]);
@ -138,17 +136,10 @@ export const SpreadsheetView: React.FC<Props> = observer((props) => {
<div className="border-t border-custom-border-100"> <div className="border-t border-custom-border-100">
<div className="mb-3 z-50 sticky bottom-0 left-0"> <div className="mb-3 z-50 sticky bottom-0 left-0">
{/* <ListInlineCreateIssueForm {enableQuickCreateIssue && <SpreadsheetInlineCreateIssueForm />}
isOpen={isInlineCreateIssueFormOpen}
handleClose={() => setIsInlineCreateIssueFormOpen(false)}
prePopulatedData={{
...(cycleId && { cycle: cycleId.toString() }),
...(moduleId && { module: moduleId.toString() }),
}}
/> */}
</div> </div>
{!disableUserActions && {/* {!disableUserActions &&
!isInlineCreateIssueFormOpen && !isInlineCreateIssueFormOpen &&
(type === "issue" ? ( (type === "issue" ? (
<button <button
@ -180,7 +171,7 @@ export const SpreadsheetView: React.FC<Props> = observer((props) => {
<CustomMenu.MenuItem onClick={openIssuesListModal}>Add an existing issue</CustomMenu.MenuItem> <CustomMenu.MenuItem onClick={openIssuesListModal}>Add an existing issue</CustomMenu.MenuItem>
)} )}
</CustomMenu> </CustomMenu>
))} ))} */}
</div> </div>
</div> </div>
</div> </div>

View File

@ -12,6 +12,7 @@ import { render24HourFormatTime, renderLongDateFormat, timeAgo } from "helpers/d
interface IssueActivityCard { interface IssueActivityCard {
workspaceSlug: string; workspaceSlug: string;
projectId: string; projectId: string;
issueId: string;
user: any; user: any;
issueComments: any; issueComments: any;
issueCommentUpdate: (comment: any) => void; issueCommentUpdate: (comment: any) => void;
@ -24,6 +25,7 @@ export const IssueActivityCard: FC<IssueActivityCard> = (props) => {
const { const {
workspaceSlug, workspaceSlug,
projectId, projectId,
issueId,
user, user,
issueComments, issueComments,
issueCommentUpdate, issueCommentUpdate,
@ -118,6 +120,7 @@ export const IssueActivityCard: FC<IssueActivityCard> = (props) => {
<IssueCommentCard <IssueCommentCard
workspaceSlug={workspaceSlug} workspaceSlug={workspaceSlug}
projectId={projectId} projectId={projectId}
issueId={issueId}
user={user} user={user}
comment={activityItem} comment={activityItem}
onSubmit={issueCommentUpdate} onSubmit={issueCommentUpdate}

View File

@ -23,6 +23,7 @@ type IIssueCommentCard = {
showAccessSpecifier?: boolean; showAccessSpecifier?: boolean;
workspaceSlug: string; workspaceSlug: string;
projectId: string; projectId: string;
issueId: string;
user: any; user: any;
issueCommentReactionCreate: (commentId: string, reaction: string) => void; issueCommentReactionCreate: (commentId: string, reaction: string) => void;
issueCommentReactionRemove: (commentId: string, reaction: string) => void; issueCommentReactionRemove: (commentId: string, reaction: string) => void;
@ -36,6 +37,7 @@ export const IssueCommentCard: React.FC<IIssueCommentCard> = (props) => {
showAccessSpecifier = false, showAccessSpecifier = false,
workspaceSlug, workspaceSlug,
projectId, projectId,
issueId,
user, user,
issueCommentReactionCreate, issueCommentReactionCreate,
issueCommentReactionRemove, issueCommentReactionRemove,
@ -157,6 +159,7 @@ export const IssueCommentCard: React.FC<IIssueCommentCard> = (props) => {
<IssueCommentReaction <IssueCommentReaction
workspaceSlug={workspaceSlug} workspaceSlug={workspaceSlug}
projectId={projectId} projectId={projectId}
issueId={issueId}
user={user} user={user}
comment={comment} comment={comment}
issueCommentReactionCreate={issueCommentReactionCreate} issueCommentReactionCreate={issueCommentReactionCreate}

View File

@ -9,8 +9,9 @@ import { useMobxStore } from "lib/mobx/store-provider";
import { RootStore } from "store/root"; import { RootStore } from "store/root";
interface IIssueCommentReaction { interface IIssueCommentReaction {
workspaceSlug: any; workspaceSlug: string;
projectId: any; projectId: string;
issueId: string;
user: any; user: any;
comment: any; comment: any;
@ -19,7 +20,8 @@ interface IIssueCommentReaction {
} }
export const IssueCommentReaction: FC<IIssueCommentReaction> = observer((props) => { export const IssueCommentReaction: FC<IIssueCommentReaction> = observer((props) => {
const { workspaceSlug, projectId, user, comment, issueCommentReactionCreate, issueCommentReactionRemove } = props; const { workspaceSlug, projectId, issueId, user, comment, issueCommentReactionCreate, issueCommentReactionRemove } =
props;
const { issueDetail: issueDetailStore }: RootStore = useMobxStore(); const { issueDetail: issueDetailStore }: RootStore = useMobxStore();
@ -32,15 +34,18 @@ export const IssueCommentReaction: FC<IIssueCommentReaction> = observer((props)
}; };
useSWR( useSWR(
workspaceSlug && projectId && comment && comment?.id ? `ISSUE+PEEK_OVERVIEW_COMMENT_${comment?.id}` : null, workspaceSlug && projectId && issueId && comment && comment?.id
? `ISSUE+PEEK_OVERVIEW_COMMENT_${comment?.id}`
: null,
() => { () => {
if (workspaceSlug && projectId && comment && comment.id) { if (workspaceSlug && projectId && issueId && comment && comment.id) {
issueDetailStore.fetchIssueCommentReactions(workspaceSlug, projectId, comment?.id); issueDetailStore.fetchIssueCommentReactions(workspaceSlug, projectId, issueId, comment?.id);
} }
} }
); );
const issueReactions = issueDetailStore?.getIssueCommentReactionsByCommentId(comment.id) || []; let issueReactions = issueDetailStore?.getIssueCommentReactions || null;
issueReactions = issueReactions && comment.id ? issueReactions?.[comment.id] : [];
return ( return (
<div> <div>

View File

@ -6,6 +6,7 @@ import { IssueCommentEditor } from "./comment-editor";
interface IIssueComment { interface IIssueComment {
workspaceSlug: string; workspaceSlug: string;
projectId: string; projectId: string;
issueId: string;
user: any; user: any;
issueComments: any; issueComments: any;
issueCommentCreate: (comment: any) => void; issueCommentCreate: (comment: any) => void;
@ -19,6 +20,7 @@ export const IssueComment: FC<IIssueComment> = (props) => {
const { const {
workspaceSlug, workspaceSlug,
projectId, projectId,
issueId,
user, user,
issueComments, issueComments,
issueCommentCreate, issueCommentCreate,
@ -46,6 +48,7 @@ export const IssueComment: FC<IIssueComment> = (props) => {
<IssueActivityCard <IssueActivityCard
workspaceSlug={workspaceSlug} workspaceSlug={workspaceSlug}
projectId={projectId} projectId={projectId}
issueId={issueId}
user={user} user={user}
issueComments={issueComments} issueComments={issueComments}
issueCommentUpdate={issueCommentUpdate} issueCommentUpdate={issueCommentUpdate}

View File

@ -8,38 +8,37 @@ import { IssuePropertyPriority } from "components/issues/issue-layouts/propertie
import { IssuePropertyAssignee } from "components/issues/issue-layouts/properties/assignee"; import { IssuePropertyAssignee } from "components/issues/issue-layouts/properties/assignee";
import { IssuePropertyDate } from "components/issues/issue-layouts/properties/date"; import { IssuePropertyDate } from "components/issues/issue-layouts/properties/date";
// types // types
import { IIssue } from "types"; import { IIssue, IState, IUserLite, TIssuePriorities } from "types";
interface IPeekOverviewProperties { interface IPeekOverviewProperties {
issue: IIssue; issue: IIssue;
issueUpdate: (issue: Partial<IIssue>) => void; issueUpdate: (issue: Partial<IIssue>) => void;
states: IState[] | null;
states: any; members: IUserLite[] | null;
members: any;
priorities: any; priorities: any;
} }
export const PeekOverviewProperties: FC<IPeekOverviewProperties> = (props) => { export const PeekOverviewProperties: FC<IPeekOverviewProperties> = (props) => {
const { issue, issueUpdate, states, members, priorities } = props; const { issue, issueUpdate, states, members, priorities } = props;
const handleState = (_state: string) => { const handleState = (_state: IState) => {
if (issueUpdate) issueUpdate({ ...issue, state: _state }); issueUpdate({ ...issue, state: _state.id });
}; };
const handlePriority = (_priority: any) => { const handlePriority = (_priority: TIssuePriorities) => {
if (issueUpdate) issueUpdate({ ...issue, priority: _priority }); issueUpdate({ ...issue, priority: _priority });
}; };
const handleAssignee = (_assignees: string[]) => { const handleAssignee = (_assignees: string[]) => {
if (issueUpdate) issueUpdate({ ...issue, assignees: _assignees }); issueUpdate({ ...issue, assignees: _assignees });
}; };
const handleStartDate = (_startDate: string) => { const handleStartDate = (_startDate: string) => {
if (issueUpdate) issueUpdate({ ...issue, start_date: _startDate }); issueUpdate({ ...issue, start_date: _startDate });
}; };
const handleTargetDate = (_targetDate: string) => { const handleTargetDate = (_targetDate: string) => {
if (issueUpdate) issueUpdate({ ...issue, target_date: _targetDate }); issueUpdate({ ...issue, target_date: _targetDate });
}; };
return ( return (
@ -54,11 +53,11 @@ export const PeekOverviewProperties: FC<IPeekOverviewProperties> = (props) => {
</div> </div>
<div className="w-full"> <div className="w-full">
<IssuePropertyState <IssuePropertyState
value={issue?.state || null} value={issue?.state_detail || null}
dropdownArrow={false} onChange={handleState}
onChange={(id: string) => handleState(id)} states={states}
disabled={false} disabled={false}
list={states} hideDropdownArrow={true}
/> />
</div> </div>
</div> </div>
@ -74,10 +73,10 @@ export const PeekOverviewProperties: FC<IPeekOverviewProperties> = (props) => {
<div className="w-full"> <div className="w-full">
<IssuePropertyAssignee <IssuePropertyAssignee
value={issue?.assignees || null} value={issue?.assignees || null}
dropdownArrow={false}
onChange={(ids: string[]) => handleAssignee(ids)} onChange={(ids: string[]) => handleAssignee(ids)}
disabled={false} disabled={false}
list={members} hideDropdownArrow={true}
members={members}
/> />
</div> </div>
</div> </div>
@ -93,10 +92,9 @@ export const PeekOverviewProperties: FC<IPeekOverviewProperties> = (props) => {
<div className="w-full"> <div className="w-full">
<IssuePropertyPriority <IssuePropertyPriority
value={issue?.priority || null} value={issue?.priority || null}
dropdownArrow={false} onChange={handlePriority}
onChange={(id: string) => handlePriority(id)}
disabled={false} disabled={false}
list={priorities} hideDropdownArrow={true}
/> />
</div> </div>
</div> </div>

View File

@ -15,7 +15,7 @@ export const IssueReaction: FC<IIssueReaction> = (props) => {
const handleReaction = (reaction: string) => { const handleReaction = (reaction: string) => {
const isReactionAvailable = const isReactionAvailable =
issueReactions[reaction].find((_reaction: any) => _reaction.actor === user?.id) ?? false; issueReactions?.[reaction].find((_reaction: any) => _reaction.actor === user?.id) ?? false;
if (isReactionAvailable) issueReactionRemove(reaction); if (isReactionAvailable) issueReactionRemove(reaction);
else issueReactionCreate(reaction); else issueReactionCreate(reaction);

View File

@ -50,10 +50,10 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
issueDetailStore.removeIssueComment(workspaceSlug, projectId, issueId, commentId); issueDetailStore.removeIssueComment(workspaceSlug, projectId, issueId, commentId);
const issueCommentReactionCreate = (commentId: string, reaction: string) => const issueCommentReactionCreate = (commentId: string, reaction: string) =>
issueDetailStore.creationIssueCommentReaction(workspaceSlug, projectId, commentId, reaction); issueDetailStore.creationIssueCommentReaction(workspaceSlug, projectId, issueId, commentId, reaction);
const issueCommentReactionRemove = (commentId: string, reaction: string) => const issueCommentReactionRemove = (commentId: string, reaction: string) =>
issueDetailStore.removeIssueCommentReaction(workspaceSlug, projectId, commentId, reaction); issueDetailStore.removeIssueCommentReaction(workspaceSlug, projectId, issueId, commentId, reaction);
return ( return (
<IssueView <IssueView

View File

@ -215,6 +215,7 @@ export const IssueView: FC<IIssueView> = observer((props) => {
<IssueComment <IssueComment
workspaceSlug={workspaceSlug} workspaceSlug={workspaceSlug}
projectId={projectId} projectId={projectId}
issueId={issueId}
user={user} user={user}
issueComments={issueComments} issueComments={issueComments}
issueCommentCreate={issueCommentCreate} issueCommentCreate={issueCommentCreate}
@ -242,6 +243,7 @@ export const IssueView: FC<IIssueView> = observer((props) => {
<IssueComment <IssueComment
workspaceSlug={workspaceSlug} workspaceSlug={workspaceSlug}
projectId={projectId} projectId={projectId}
issueId={issueId}
user={user} user={user}
issueComments={issueComments} issueComments={issueComments}
issueCommentCreate={issueCommentCreate} issueCommentCreate={issueCommentCreate}

View File

@ -10,6 +10,8 @@ import { TrackEventService } from "services/track_event.service";
import { ViewDueDateSelect, ViewStartDateSelect } from "components/issues"; import { ViewDueDateSelect, ViewStartDateSelect } from "components/issues";
import { MembersSelect, PrioritySelect } from "components/project"; import { MembersSelect, PrioritySelect } from "components/project";
import { StateSelect } from "components/states"; import { StateSelect } from "components/states";
// helpers
import { getStatesList } from "helpers/state.helper";
// types // types
import { IUser, IIssue, IState } from "types"; import { IUser, IIssue, IState } from "types";
// fetch-keys // fetch-keys
@ -115,6 +117,8 @@ export const IssueProperty: React.FC<IIssueProperty> = observer((props) => {
); );
}; };
const statesList = getStatesList(projectStore.states?.[issue.project]);
return ( return (
<div className="relative flex items-center gap-1"> <div className="relative flex items-center gap-1">
{displayProperties.priority && ( {displayProperties.priority && (
@ -132,7 +136,7 @@ export const IssueProperty: React.FC<IIssueProperty> = observer((props) => {
<div className="flex-shrink-0"> <div className="flex-shrink-0">
<StateSelect <StateSelect
value={issue.state_detail} value={issue.state_detail}
stateGroups={projectStore.states ? projectStore.states[issue.project] : undefined} states={statesList}
onChange={(data) => handleStateChange(data)} onChange={(data) => handleStateChange(data)}
hideDropdownArrow hideDropdownArrow
disabled={!editable} disabled={!editable}

View File

@ -7,3 +7,5 @@ export * from "./modal";
export * from "./modules-list-view"; export * from "./modules-list-view";
export * from "./sidebar"; export * from "./sidebar";
export * from "./module-card-item"; export * from "./module-card-item";
export * from "./module-list-item";
export * from "./module-peek-overview";

View File

@ -10,14 +10,16 @@ import useToast from "hooks/use-toast";
import { CreateUpdateModuleModal, DeleteModuleModal } from "components/modules"; import { CreateUpdateModuleModal, DeleteModuleModal } from "components/modules";
// ui // ui
import { AssigneesList } from "components/ui"; import { AssigneesList } from "components/ui";
import { CustomMenu, Tooltip } from "@plane/ui"; import { CustomMenu, LayersIcon, Tooltip } from "@plane/ui";
// icons // icons
import { CalendarDays, LinkIcon, Pencil, Star, Target, Trash2 } from "lucide-react"; import { Info, LinkIcon, Pencil, Star, Trash2 } from "lucide-react";
// helpers // helpers
import { copyUrlToClipboard, truncateText } from "helpers/string.helper"; import { copyUrlToClipboard } from "helpers/string.helper";
import { renderShortDateWithYearFormat } from "helpers/date-time.helper"; import { renderShortDate, renderShortMonthDate } from "helpers/date-time.helper";
// types // types
import { IModule } from "types"; import { IModule } from "types";
// constants
import { MODULE_STATUS } from "constants/module";
type Props = { type Props = {
module: IModule; module: IModule;
@ -72,9 +74,32 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
}); });
}; };
const openModuleOverview = () => {
const { query } = router;
router.push({
pathname: router.pathname,
query: { ...query, peekModule: module.id },
});
};
const endDate = new Date(module.target_date ?? ""); const endDate = new Date(module.target_date ?? "");
const startDate = new Date(module.start_date ?? ""); const startDate = new Date(module.start_date ?? "");
const lastUpdated = new Date(module.updated_at ?? "");
const areYearsEqual = startDate.getFullYear() === endDate.getFullYear();
const moduleStatus = MODULE_STATUS.find((status) => status.value === module.status);
const issueCount =
module.completed_issues && module.total_issues
? module.total_issues === 0
? "0 Issue"
: module.total_issues === module.completed_issues
? module.total_issues > 1
? `${module.total_issues} Issues`
: `${module.total_issues} Issue`
: `${module.completed_issues}/${module.total_issues} Issues`
: "0 Issue";
return ( return (
<> <>
@ -88,96 +113,142 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
/> />
)} )}
<DeleteModuleModal data={module} isOpen={moduleDeleteModal} onClose={() => setModuleDeleteModal(false)} /> <DeleteModuleModal data={module} isOpen={moduleDeleteModal} onClose={() => setModuleDeleteModal(false)} />
<div className="flex flex-col divide-y divide-custom-border-200 overflow-hidden rounded-[10px] border border-custom-border-200 bg-custom-background-100 text-xs"> <Link href={`/${workspaceSlug}/projects/${module.project}/modules/${module.id}`}>
<div className="p-4"> <a className="flex flex-col justify-between p-4 h-44 w-full min-w-[250px] text-sm rounded bg-custom-background-100 border border-custom-border-100 hover:shadow-md">
<div className="flex w-full flex-col gap-5"> <div>
<div className="flex items-start justify-between gap-2"> <div className="flex items-center justify-between gap-2">
<Tooltip tooltipContent={module.name} position="top-left"> <Tooltip tooltipContent={module.name} position="auto">
<Link href={`/${workspaceSlug}/projects/${module.project}/modules/${module.id}`}> <span className="text-base font-medium truncate">{module.name}</span>
<a className="w-auto max-w-[calc(100%-9rem)]">
<h3 className="truncate break-words text-lg font-semibold text-custom-text-100">
{truncateText(module.name, 75)}
</h3>
</a>
</Link>
</Tooltip> </Tooltip>
<div className="flex items-center gap-2">
{moduleStatus && (
<span
className={`flex items-center justify-center text-xs h-6 w-20 rounded-sm ${moduleStatus.textColor} ${moduleStatus.bgColor}`}
>
{moduleStatus.label}
</span>
)}
<button
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
openModuleOverview();
}}
>
<Info className="h-4 w-4 text-custom-text-400" />
</button>
</div>
</div>
</div>
<div className="flex items-center gap-1"> <div className="flex flex-col gap-3">
<div className="mr-2 flex whitespace-nowrap rounded bg-custom-background-90 px-2.5 py-2 text-custom-text-200"> <div className="flex items-center justify-between">
<span className="capitalize">{module?.status?.replace("-", " ")}</span> <div className="flex items-center gap-1.5 text-custom-text-200">
<LayersIcon className="h-4 w-4 text-custom-text-300" />
<span className="text-xs text-custom-text-300">{issueCount}</span>
</div>
{module.members_detail.length > 0 && (
<Tooltip tooltipContent={`${module.members_detail.length} Members`}>
<div className="flex items-center gap-1 cursor-default">
<AssigneesList users={module.members_detail} length={3} />
</div>
</Tooltip>
)}
</div>
<Tooltip
tooltipContent={isNaN(completionPercentage) ? "0" : `${completionPercentage.toFixed(0)}%`}
position="top-left"
>
<div className="flex items-center w-full">
<div
className="bar relative h-1.5 w-full rounded bg-custom-background-90"
style={{
boxShadow: "1px 1px 4px 0px rgba(161, 169, 191, 0.35) inset",
}}
>
<div
className="absolute top-0 left-0 h-1.5 rounded bg-blue-600 duration-300"
style={{
width: `${isNaN(completionPercentage) ? 0 : completionPercentage.toFixed(0)}%`,
}}
/>
</div> </div>
</div>
</Tooltip>
<div className="flex items-center justify-between">
<span className="text-xs text-custom-text-300">
{areYearsEqual ? renderShortDate(startDate, "_ _") : renderShortMonthDate(startDate, "_ _")} -{" "}
{areYearsEqual ? renderShortDate(endDate, "_ _") : renderShortMonthDate(endDate, "_ _")}
</span>
<div className="flex items-center gap-1.5 z-10">
{module.is_favorite ? ( {module.is_favorite ? (
<button type="button" onClick={handleRemoveFromFavorites}> <button
<Star className="h-4 w-4 text-orange-400" fill="#f6ad55" /> type="button"
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
handleRemoveFromFavorites();
}}
>
<Star className="h-3.5 w-3.5 text-amber-500 fill-current" />
</button> </button>
) : ( ) : (
<button type="button" onClick={handleAddToFavorites}> <button
<Star className="h-4 w-4 " color="rgb(var(--color-text-200))" /> type="button"
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
handleAddToFavorites();
}}
>
<Star className="h-3.5 w-3.5 text-custom-text-200" />
</button> </button>
)} )}
<CustomMenu width="auto" ellipsis className="z-10">
<CustomMenu width="auto" verticalEllipsis placement="bottom-end"> <CustomMenu.MenuItem
<CustomMenu.MenuItem onClick={handleCopyText}> onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setEditModuleModal(true);
}}
>
<span className="flex items-center justify-start gap-2"> <span className="flex items-center justify-start gap-2">
<LinkIcon className="h-3 w-3" strokeWidth={2} /> <Pencil className="h-3 w-3" />
<span>Copy link</span>
</span>
</CustomMenu.MenuItem>
<CustomMenu.MenuItem onClick={() => setEditModuleModal(true)}>
<span className="flex items-center justify-start gap-2">
<Pencil className="h-3 w-3" strokeWidth={2} />
<span>Edit module</span> <span>Edit module</span>
</span> </span>
</CustomMenu.MenuItem> </CustomMenu.MenuItem>
<CustomMenu.MenuItem onClick={() => setModuleDeleteModal(true)}> <CustomMenu.MenuItem
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setModuleDeleteModal(true);
}}
>
<span className="flex items-center justify-start gap-2"> <span className="flex items-center justify-start gap-2">
<Trash2 className="h-3 w-3" strokeWidth={2} /> <Trash2 className="h-3 w-3" />
<span>Delete module</span> <span>Delete module</span>
</span> </span>
</CustomMenu.MenuItem> </CustomMenu.MenuItem>
<CustomMenu.MenuItem
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
handleCopyText();
}}
>
<span className="flex items-center justify-start gap-2">
<LinkIcon className="h-3 w-3" />
<span>Copy module link</span>
</span>
</CustomMenu.MenuItem>
</CustomMenu> </CustomMenu>
</div> </div>
</div> </div>
<div className="grid grid-cols-2 gap-2 text-custom-text-200">
<div className="flex items-start gap-1">
<CalendarDays className="h-4 w-4" />
<span>Start:</span>
<span>{renderShortDateWithYearFormat(startDate, "Not set")}</span>
</div>
<div className="flex items-start gap-1">
<Target className="h-4 w-4" />
<span>End:</span>
<span>{renderShortDateWithYearFormat(endDate, "Not set")}</span>
</div>
</div>
</div> </div>
</div> </a>
<div className="flex h-20 flex-col items-end bg-custom-background-80"> </Link>
<div className="flex w-full items-center justify-between gap-2 justify-self-end p-4 text-custom-text-200">
<span>Progress</span>
<div className="bar relative h-1 w-full rounded bg-custom-background-90">
<div
className="absolute top-0 left-0 h-1 rounded bg-green-500 duration-300"
style={{
width: `${isNaN(completionPercentage) ? 0 : completionPercentage.toFixed(0)}%`,
}}
/>
</div>
<span>{isNaN(completionPercentage) ? 0 : completionPercentage.toFixed(0)}%</span>
</div>
<div className="item-center flex h-full w-full justify-between px-4 pb-4 text-custom-text-200">
<p>
Last updated:
<span className="font-medium">{renderShortDateWithYearFormat(lastUpdated)}</span>
</p>
{module.members_detail.length > 0 && (
<div className="flex items-center gap-1">
<AssigneesList users={module.members_detail} length={4} />
</div>
)}
</div>
</div>
</div>
</> </>
); );
}); });

View File

@ -0,0 +1,242 @@
import React, { useState } from "react";
import Link from "next/link";
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";
// hooks
import useToast from "hooks/use-toast";
// components
import { CreateUpdateModuleModal, DeleteModuleModal } from "components/modules";
// ui
import { AssigneesList } from "components/ui";
import { CircularProgressIndicator, CustomMenu, Tooltip } from "@plane/ui";
// icons
import { Check, Info, LinkIcon, Pencil, Star, Trash2, User2 } from "lucide-react";
// helpers
import { copyUrlToClipboard } from "helpers/string.helper";
import { renderShortDate, renderShortMonthDate } from "helpers/date-time.helper";
// types
import { IModule } from "types";
// constants
import { MODULE_STATUS } from "constants/module";
type Props = {
module: IModule;
};
export const ModuleListItem: React.FC<Props> = observer((props) => {
const { module } = props;
const [editModuleModal, setEditModuleModal] = useState(false);
const [moduleDeleteModal, setModuleDeleteModal] = useState(false);
const router = useRouter();
const { workspaceSlug, projectId } = router.query;
const { setToastAlert } = useToast();
const { module: moduleStore } = useMobxStore();
const completionPercentage = ((module.completed_issues + module.cancelled_issues) / module.total_issues) * 100;
const handleAddToFavorites = () => {
if (!workspaceSlug || !projectId) return;
moduleStore.addModuleToFavorites(workspaceSlug.toString(), projectId.toString(), module.id).catch(() => {
setToastAlert({
type: "error",
title: "Error!",
message: "Couldn't add the module to favorites. Please try again.",
});
});
};
const handleRemoveFromFavorites = () => {
if (!workspaceSlug || !projectId) return;
moduleStore.removeModuleFromFavorites(workspaceSlug.toString(), projectId.toString(), module.id).catch(() => {
setToastAlert({
type: "error",
title: "Error!",
message: "Couldn't remove the module from favorites. Please try again.",
});
});
};
const handleCopyText = () => {
copyUrlToClipboard(`${workspaceSlug}/projects/${projectId}/modules/${module.id}`).then(() => {
setToastAlert({
type: "success",
title: "Link Copied!",
message: "Module link copied to clipboard.",
});
});
};
const endDate = new Date(module.target_date ?? "");
const startDate = new Date(module.start_date ?? "");
const renderDate = module.start_date || module.target_date;
const areYearsEqual = startDate.getFullYear() === endDate.getFullYear();
const moduleStatus = MODULE_STATUS.find((status) => status.value === module.status);
const progress = isNaN(completionPercentage) ? 0 : Math.floor(completionPercentage);
const completedModuleCheck = module.status === "completed" && module.total_issues - module.completed_issues;
const openModuleOverview = () => {
const { query } = router;
router.push({
pathname: router.pathname,
query: { ...query, peekModule: module.id },
});
};
return (
<>
{workspaceSlug && projectId && (
<CreateUpdateModuleModal
isOpen={editModuleModal}
onClose={() => setEditModuleModal(false)}
data={module}
projectId={projectId.toString()}
workspaceSlug={workspaceSlug.toString()}
/>
)}
<DeleteModuleModal data={module} isOpen={moduleDeleteModal} onClose={() => setModuleDeleteModal(false)} />
<Link href={`/${workspaceSlug}/projects/${module.project}/modules/${module.id}`}>
<a className="group flex items-center justify-between gap-5 px-10 py-6 h-16 w-full text-sm bg-custom-background-100 border-b border-custom-border-100 hover:bg-custom-background-90">
<div className="flex items-center gap-3 w-full truncate">
<div className="flex items-center gap-4 truncate">
<span className="flex-shrink-0">
<CircularProgressIndicator size={38} percentage={progress}>
{completedModuleCheck ? (
<span className="text-sm text-custom-primary-100">{`!`}</span>
) : progress === 100 ? (
<Check className="h-3 w-3 text-custom-primary-100 stroke-[2]" />
) : (
<span className="text-xs text-custom-text-300">{`${progress}%`}</span>
)}
</CircularProgressIndicator>
</span>
<Tooltip tooltipContent={module.name} position="auto">
<span className="text-base font-medium truncate">{module.name}</span>
</Tooltip>
</div>
<button
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
openModuleOverview();
}}
className="flex-shrink-0 hidden group-hover:flex z-10"
>
<Info className="h-4 w-4 text-custom-text-400" />
</button>
</div>
<div className="flex items-center gap-2.5 justify-end w-full md:w-auto md:flex-shrink-0 ">
<div className="flex items-center justify-center">
{moduleStatus && (
<span
className={`flex items-center justify-center text-xs h-6 w-20 rounded-sm ${moduleStatus.textColor} ${moduleStatus.bgColor}`}
>
{moduleStatus.label}
</span>
)}
</div>
{renderDate && (
<span className="flex items-center justify-center gap-2 w-28 text-xs text-custom-text-300">
{areYearsEqual ? renderShortDate(startDate, "_ _") : renderShortMonthDate(startDate, "_ _")}
{" - "}
{areYearsEqual ? renderShortDate(endDate, "_ _") : renderShortMonthDate(endDate, "_ _")}
</span>
)}
<Tooltip tooltipContent={`${module.members_detail.length} Members`}>
<div className="flex items-center justify-center gap-1 cursor-default w-16">
{module.members_detail.length > 0 ? (
<AssigneesList users={module.members_detail} length={2} />
) : (
<span className="flex items-end justify-center h-5 w-5 bg-custom-background-80 rounded-full border border-dashed border-custom-text-400">
<User2 className="h-4 w-4 text-custom-text-400" />
</span>
)}
</div>
</Tooltip>
{module.is_favorite ? (
<button
type="button"
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
handleRemoveFromFavorites();
}}
className="z-[1]"
>
<Star className="h-3.5 w-3.5 text-amber-500 fill-current" />
</button>
) : (
<button
type="button"
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
handleAddToFavorites();
}}
className="z-[1]"
>
<Star className="h-3.5 w-3.5 text-custom-text-300" />
</button>
)}
<CustomMenu width="auto" verticalEllipsis buttonClassName="z-[1]">
<CustomMenu.MenuItem
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setEditModuleModal(true);
}}
>
<span className="flex items-center justify-start gap-2">
<Pencil className="h-3 w-3" />
<span>Edit module</span>
</span>
</CustomMenu.MenuItem>
<CustomMenu.MenuItem
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
setModuleDeleteModal(true);
}}
>
<span className="flex items-center justify-start gap-2">
<Trash2 className="h-3 w-3" />
<span>Delete module</span>
</span>
</CustomMenu.MenuItem>
<CustomMenu.MenuItem
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
handleCopyText();
}}
>
<span className="flex items-center justify-start gap-2">
<LinkIcon className="h-3 w-3" />
<span>Copy module link</span>
</span>
</CustomMenu.MenuItem>
</CustomMenu>
</div>
</a>
</Link>
</>
);
});

View File

@ -0,0 +1,55 @@
import React, { useEffect } from "react";
import { useRouter } from "next/router";
// mobx
import { observer } from "mobx-react-lite";
import { useMobxStore } from "lib/mobx/store-provider";
// components
import { ModuleDetailsSidebar } from "./sidebar";
type Props = {
projectId: string;
workspaceSlug: string;
};
export const ModulePeekOverview: React.FC<Props> = observer(({ projectId, workspaceSlug }) => {
const router = useRouter();
const { peekModule } = router.query;
const ref = React.useRef(null);
const { module: moduleStore } = useMobxStore();
const { fetchModuleDetails } = moduleStore;
const handleClose = () => {
delete router.query.peekModule;
router.push({
pathname: router.pathname,
query: { ...router.query },
});
};
useEffect(() => {
if (!peekModule) return;
fetchModuleDetails(workspaceSlug, projectId, peekModule.toString());
}, [fetchModuleDetails, peekModule, projectId, workspaceSlug]);
return (
<>
{peekModule && (
<div
ref={ref}
className="flex flex-col gap-3.5 h-full w-[24rem] z-10 overflow-y-auto border-l border-custom-border-100 bg-custom-sidebar-background-100 px-6 py-3.5 duration-300 flex-shrink-0"
style={{
boxShadow:
"0px 1px 4px 0px rgba(0, 0, 0, 0.06), 0px 2px 4px 0px rgba(16, 24, 40, 0.06), 0px 1px 8px -1px rgba(16, 24, 40, 0.06)",
}}
>
<ModuleDetailsSidebar moduleId={peekModule?.toString() ?? ""} handleClose={handleClose} />
</div>
)}
</>
);
});

View File

@ -1,3 +1,4 @@
import { useRouter } from "next/router";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { Plus } from "lucide-react"; import { Plus } from "lucide-react";
// mobx store // mobx store
@ -5,7 +6,7 @@ import { useMobxStore } from "lib/mobx/store-provider";
// hooks // hooks
import useLocalStorage from "hooks/use-local-storage"; import useLocalStorage from "hooks/use-local-storage";
// components // components
import { ModuleCardItem, ModulesListGanttChartView } from "components/modules"; import { ModuleCardItem, ModuleListItem, ModulePeekOverview, ModulesListGanttChartView } from "components/modules";
import { EmptyState } from "components/common"; import { EmptyState } from "components/common";
// ui // ui
import { Loader } from "@plane/ui"; import { Loader } from "@plane/ui";
@ -13,6 +14,9 @@ import { Loader } from "@plane/ui";
import emptyModule from "public/empty-state/module.svg"; import emptyModule from "public/empty-state/module.svg";
export const ModulesListView: React.FC = observer(() => { export const ModulesListView: React.FC = observer(() => {
const router = useRouter();
const { workspaceSlug, projectId, peekModule } = router.query;
const { module: moduleStore } = useMobxStore(); const { module: moduleStore } = useMobxStore();
const { storedValue: modulesView } = useLocalStorage("modules_view", "grid"); const { storedValue: modulesView } = useLocalStorage("modules_view", "grid");
@ -22,12 +26,12 @@ export const ModulesListView: React.FC = observer(() => {
if (!modulesList) if (!modulesList)
return ( return (
<Loader className="grid grid-cols-3 gap-4 p-8"> <Loader className="grid grid-cols-3 gap-4 p-8">
<Loader.Item height="100px" /> <Loader.Item height="176px" />
<Loader.Item height="100px" /> <Loader.Item height="176px" />
<Loader.Item height="100px" /> <Loader.Item height="176px" />
<Loader.Item height="100px" /> <Loader.Item height="176px" />
<Loader.Item height="100px" /> <Loader.Item height="176px" />
<Loader.Item height="100px" /> <Loader.Item height="176px" />
</Loader> </Loader>
); );
@ -35,12 +39,39 @@ export const ModulesListView: React.FC = observer(() => {
<> <>
{modulesList.length > 0 ? ( {modulesList.length > 0 ? (
<> <>
{modulesView === "list" && (
<div className="h-full overflow-y-auto">
<div className="flex justify-between h-full w-full">
<div className="flex flex-col h-full w-full overflow-y-auto">
{modulesList.map((module) => (
<ModuleListItem key={module.id} module={module} />
))}
</div>
<ModulePeekOverview
projectId={projectId?.toString() ?? ""}
workspaceSlug={workspaceSlug?.toString() ?? ""}
/>
</div>
</div>
)}
{modulesView === "grid" && ( {modulesView === "grid" && (
<div className="h-full overflow-y-auto p-8"> <div className="h-full w-full">
<div className="grid grid-cols-1 gap-9 lg:grid-cols-2 xl:grid-cols-3"> <div className="flex justify-between h-full w-full">
{modulesList.map((module) => ( <div
<ModuleCardItem key={module.id} module={module} /> className={`grid grid-cols-1 gap-6 p-8 h-full w-full overflow-y-auto ${
))} peekModule
? "lg:grid-cols-1 xl:grid-cols-2 3xl:grid-cols-3"
: "lg:grid-cols-2 xl:grid-cols-3 3xl:grid-cols-4"
} auto-rows-max transition-all `}
>
{modulesList.map((module) => (
<ModuleCardItem key={module.id} module={module} />
))}
</div>
<ModulePeekOverview
projectId={projectId?.toString() ?? ""}
workspaceSlug={workspaceSlug?.toString() ?? ""}
/>
</div> </div>
</div> </div>
)} )}

Some files were not shown because too many files have changed in this diff Show More