Skip to content

Commit

Permalink
feat: dashboard widgets (#3362)
Browse files Browse the repository at this point in the history
* fix: created dashboard, widgets and dashboard widget model

* fix: new user home dashboard

* chore: recent projects list

* chore: recent collaborators

* chore: priority order change

* chore: payload changes

* chore: collaborator's active issue count

* chore: all dashboard widgets added with services and typs

* chore: centered metric for pie chart

* chore: widget filters

* chore: created issue filter

* fix: created and assigned issues payload change

* chore: created issue payload change

* fix: date filter change

* chore: implement filters

* fix: added expansion fields

* fix: changed issue structure with relation

* chore: new issues response

* fix: project member fix

* chore: updated issue_relation structure

* chore: code cleanup

* chore: update issues response and added empty states

* fix: button text wrap

* chore: update empty state messages

* fix: filters

* chore: update dark mode empty states

* build-error: Type check in the issue relation service

* fix: issues redirection

* fix: project empty state

* chore: project member active check

* chore: project member check in state and priority

* chore: remove console logs and replace harcoded values with constants

* fix: code refactoring

* fix: key name changed

* refactor: mapping through similar components using an array

* fix: build errors

---------

Co-authored-by: Aaryan Khandelwal <[email protected]>
Co-authored-by: gurusainath <[email protected]>
  • Loading branch information
3 people authored Jan 18, 2024
1 parent a9e2e21 commit 9065b5d
Show file tree
Hide file tree
Showing 123 changed files with 6,789 additions and 848 deletions.
3 changes: 2 additions & 1 deletion apiserver/plane/app/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
IssueRelationSerializer,
RelatedIssueSerializer,
IssuePublicSerializer,
IssueRelationLiteSerializer,
)

from .module import (
Expand Down Expand Up @@ -120,3 +119,5 @@
from .exporter import ExporterHistorySerializer

from .webhook import WebhookSerializer, WebhookLogSerializer

from .dashboard import DashboardSerializer, WidgetSerializer
13 changes: 6 additions & 7 deletions apiserver/plane/app/serializers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def _filter_fields(self, fields):
LabelSerializer,
CycleIssueSerializer,
IssueFlatSerializer,
IssueRelationSerializer,
)

# Expansion mapper
Expand All @@ -78,14 +79,10 @@ def _filter_fields(self, fields):
"labels": LabelSerializer,
"issue_cycle": CycleIssueSerializer,
"parent": IssueSerializer,
"issue_relation": IssueRelationSerializer,
}

self.fields[field] = expansion[field](
many=True
if field
in ["members", "assignees", "labels", "issue_cycle"]
else False
)

self.fields[field] = expansion[field](many=True if field in ["members", "assignees", "labels", "issue_cycle", "issue_relation"] else False)

return self.fields

Expand All @@ -105,6 +102,7 @@ def to_representation(self, instance):
IssueSerializer,
LabelSerializer,
CycleIssueSerializer,
IssueRelationSerializer,
)

# Expansion mapper
Expand All @@ -124,6 +122,7 @@ def to_representation(self, instance):
"labels": LabelSerializer,
"issue_cycle": CycleIssueSerializer,
"parent": IssueSerializer,
"issue_relation": IssueRelationSerializer
}
# Check if field in expansion then expand the field
if expand in expansion:
Expand Down
26 changes: 26 additions & 0 deletions apiserver/plane/app/serializers/dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Module imports
from .base import BaseSerializer
from plane.db.models import Dashboard, Widget

# Third party frameworks
from rest_framework import serializers


class DashboardSerializer(BaseSerializer):
class Meta:
model = Dashboard
fields = "__all__"


class WidgetSerializer(BaseSerializer):
is_visible = serializers.BooleanField(read_only=True)
widget_filters = serializers.JSONField(read_only=True)

class Meta:
model = Widget
fields = [
"id",
"key",
"is_visible",
"widget_filters"
]
36 changes: 15 additions & 21 deletions apiserver/plane/app/serializers/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,31 +293,19 @@ class Meta:
]


class IssueRelationLiteSerializer(DynamicBaseSerializer):
project_id = serializers.PrimaryKeyRelatedField(read_only=True)
class IssueRelationSerializer(BaseSerializer):
id = serializers.UUIDField(source="related_issue.id", read_only=True)
project_id = serializers.PrimaryKeyRelatedField(source="related_issue.project_id", read_only=True)
sequence_id = serializers.IntegerField(source="related_issue.sequence_id", read_only=True)
relation_type = serializers.CharField(read_only=True)

class Meta:
model = Issue
model = IssueRelation
fields = [
"id",
"project_id",
"sequence_id",
]
read_only_fields = [
"workspace",
"project",
]


class IssueRelationSerializer(BaseSerializer):
issue_detail = IssueRelationLiteSerializer(
read_only=True, source="related_issue"
)

class Meta:
model = IssueRelation
fields = [
"issue_detail",
"relation_type",
]
read_only_fields = [
"workspace",
Expand All @@ -326,12 +314,18 @@ class Meta:


class RelatedIssueSerializer(BaseSerializer):
issue_detail = IssueRelationLiteSerializer(read_only=True, source="issue")
id = serializers.UUIDField(source="issue.id", read_only=True)
project_id = serializers.PrimaryKeyRelatedField(source="issue.project_id", read_only=True)
sequence_id = serializers.IntegerField(source="issue.sequence_id", read_only=True)
relation_type = serializers.CharField(read_only=True)

class Meta:
model = IssueRelation
fields = [
"issue_detail",
"id",
"project_id",
"sequence_id",
"relation_type",
]
read_only_fields = [
"workspace",
Expand Down
2 changes: 2 additions & 0 deletions apiserver/plane/app/urls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .authentication import urlpatterns as authentication_urls
from .config import urlpatterns as configuration_urls
from .cycle import urlpatterns as cycle_urls
from .dashboard import urlpatterns as dashboard_urls
from .estimate import urlpatterns as estimate_urls
from .external import urlpatterns as external_urls
from .importer import urlpatterns as importer_urls
Expand All @@ -28,6 +29,7 @@
*authentication_urls,
*configuration_urls,
*cycle_urls,
*dashboard_urls,
*estimate_urls,
*external_urls,
*importer_urls,
Expand Down
23 changes: 23 additions & 0 deletions apiserver/plane/app/urls/dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.urls import path


from plane.app.views import DashboardEndpoint, WidgetsEndpoint


urlpatterns = [
path(
"workspaces/<str:slug>/dashboard/",
DashboardEndpoint.as_view(),
name="dashboard",
),
path(
"workspaces/<str:slug>/dashboard/<uuid:dashboard_id>/",
DashboardEndpoint.as_view(),
name="dashboard",
),
path(
"dashboard/<uuid:dashboard_id>/widgets/<uuid:widget_id>/",
WidgetsEndpoint.as_view(),
name="widgets",
),
]
5 changes: 5 additions & 0 deletions apiserver/plane/app/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,8 @@
WebhookLogsEndpoint,
WebhookSecretRegenerateEndpoint,
)

from .dashboard import (
DashboardEndpoint,
WidgetsEndpoint
)
Loading

0 comments on commit 9065b5d

Please sign in to comment.