Skip to content

Commit

Permalink
Merge branch 'preview' into fix/upgrade-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Palanikannan1437 committed Jan 15, 2025
2 parents 88c7424 + 9d71568 commit 4eaf34d
Show file tree
Hide file tree
Showing 161 changed files with 2,201 additions and 2,229 deletions.
3 changes: 0 additions & 3 deletions admin/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ module.exports = {
root: true,
extends: ["@plane/eslint-config/next.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
};
2 changes: 1 addition & 1 deletion admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
},
"devDependencies": {
"@plane/eslint-config": "*",
"@plane/tailwind-config": "*",
"@plane/typescript-config": "*",
"@types/node": "18.16.1",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.2.18",
"@types/uuid": "^9.0.8",
"@types/zxcvbn": "^4.4.4",
"tailwind-config-custom": "*",
"typescript": "5.3.3"
}
}
3 changes: 2 additions & 1 deletion admin/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const sharedConfig = require("tailwind-config-custom/tailwind.config.js");
/* eslint-disable @typescript-eslint/no-require-imports */
const sharedConfig = require("@plane/tailwind-config/tailwind.config.js");

module.exports = {
presets: [sharedConfig],
Expand Down
6 changes: 3 additions & 3 deletions apiserver/plane/app/serializers/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Module imports
from .base import BaseSerializer
from plane.db.models import Dashboard, Widget
from plane.db.models import DeprecatedDashboard, DeprecatedWidget

# Third party frameworks
from rest_framework import serializers


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


Expand All @@ -17,5 +17,5 @@ class WidgetSerializer(BaseSerializer):
widget_filters = serializers.JSONField(read_only=True)

class Meta:
model = Widget
model = DeprecatedWidget
fields = ["id", "key", "is_visible", "widget_filters"]
9 changes: 5 additions & 4 deletions apiserver/plane/app/serializers/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ class Meta:
fields = ["id", "name", "logo_props", "project_members", "identifier"]

def get_project_members(self, obj):
members = ProjectMember.objects.filter(project_id=obj.id).values_list(
"member", flat=True
)
members = ProjectMember.objects.filter(
project_id=obj.id, member__is_bot=False, is_active=True
).values_list("member", flat=True)

return members


Expand Down Expand Up @@ -248,7 +249,7 @@ class WorkspaceHomePreferenceSerializer(BaseSerializer):
class Meta:
model = WorkspaceHomePreference
fields = ["key", "is_enabled", "sort_order"]
read_only_fields = ["worspace", "created_by", "update_by"]
read_only_fields = ["workspace", "created_by", "updated_by"]


class StickySerializer(BaseSerializer):
Expand Down
6 changes: 3 additions & 3 deletions apiserver/plane/app/urls/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
WorkspaceDraftIssueViewSet,
QuickLinkViewSet,
UserRecentVisitViewSet,
WorkspacePreferenceViewSet,
WorkspaceHomePreferenceViewSet,
WorkspaceStickyViewSet,
)

Expand Down Expand Up @@ -233,12 +233,12 @@
# Widgets
path(
"workspaces/<str:slug>/home-preferences/",
WorkspacePreferenceViewSet.as_view(),
WorkspaceHomePreferenceViewSet.as_view(),
name="workspace-home-preference",
),
path(
"workspaces/<str:slug>/home-preferences/<str:key>/",
WorkspacePreferenceViewSet.as_view(),
WorkspaceHomePreferenceViewSet.as_view(),
name="workspace-home-preference",
),
path(
Expand Down
3 changes: 2 additions & 1 deletion apiserver/plane/app/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@

from .workspace.draft import WorkspaceDraftIssueViewSet

from .workspace.preference import WorkspacePreferenceViewSet
from .workspace.home import WorkspaceHomePreferenceViewSet

from .workspace.favorite import (
WorkspaceFavoriteEndpoint,
WorkspaceFavoriteGroupEndpoint,
Expand Down
26 changes: 13 additions & 13 deletions apiserver/plane/app/views/dashboard/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
WidgetSerializer,
)
from plane.db.models import (
Dashboard,
DashboardWidget,
DeprecatedDashboard,
DeprecatedDashboardWidget,
Issue,
IssueActivity,
FileAsset,
IssueLink,
IssueRelation,
Project,
Widget,
DeprecatedWidget,
WorkspaceMember,
CycleIssue,
)
Expand Down Expand Up @@ -687,7 +687,7 @@ def get(self, request, slug, dashboard_id=None):
if not dashboard_id:
dashboard_type = request.GET.get("dashboard_type", None)
if dashboard_type == "home":
dashboard, created = Dashboard.objects.get_or_create(
dashboard, created = DeprecatedDashboard.objects.get_or_create(
type_identifier=dashboard_type,
owned_by=request.user,
is_default=True,
Expand All @@ -707,24 +707,24 @@ def get(self, request, slug, dashboard_id=None):

updated_dashboard_widgets = []
for widget_key in widgets_to_fetch:
widget = Widget.objects.filter(key=widget_key).values_list(
"id", flat=True
)
widget = DeprecatedWidget.objects.filter(
key=widget_key
).values_list("id", flat=True)
if widget:
updated_dashboard_widgets.append(
DashboardWidget(
DeprecatedDashboardWidget(
widget_id=widget, dashboard_id=dashboard.id
)
)

DashboardWidget.objects.bulk_create(
DeprecatedDashboardWidget.objects.bulk_create(
updated_dashboard_widgets, batch_size=100
)

widgets = (
Widget.objects.annotate(
DeprecatedWidget.objects.annotate(
is_visible=Exists(
DashboardWidget.objects.filter(
DeprecatedDashboardWidget.objects.filter(
widget_id=OuterRef("pk"),
dashboard_id=dashboard.id,
is_visible=True,
Expand All @@ -733,7 +733,7 @@ def get(self, request, slug, dashboard_id=None):
)
.annotate(
dashboard_filters=Subquery(
DashboardWidget.objects.filter(
DeprecatedDashboardWidget.objects.filter(
widget_id=OuterRef("pk"),
dashboard_id=dashboard.id,
filters__isnull=False,
Expand Down Expand Up @@ -792,7 +792,7 @@ def get(self, request, slug, dashboard_id=None):

class WidgetsEndpoint(BaseAPIView):
def patch(self, request, dashboard_id, widget_id):
dashboard_widget = DashboardWidget.objects.filter(
dashboard_widget = DeprecatedDashboardWidget.objects.filter(
widget_id=widget_id, dashboard_id=dashboard_id
).first()
dashboard_widget.is_visible = request.data.get(
Expand Down
2 changes: 2 additions & 0 deletions apiserver/plane/app/views/page/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ def post(self, request, slug, project_id, page_id):
page.name = f"{page.name} (Copy)"
page.description_binary = None
page.owned_by = request.user
page.created_by = request.user
page.updated_by = request.user
page.save()

for project_id in project_ids:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
from plane.db.models import Workspace
from plane.app.serializers.workspace import WorkspaceHomePreferenceSerializer

# Django imports

from django.db.models import Count


# Third party imports
from rest_framework.response import Response
from rest_framework import status


class WorkspacePreferenceViewSet(BaseAPIView):
class WorkspaceHomePreferenceViewSet(BaseAPIView):
model = WorkspaceHomePreference

def get_serializer_class(self):
Expand Down Expand Up @@ -72,7 +67,7 @@ def get(self, request, slug):
@allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST], level="WORKSPACE")
def patch(self, request, slug, key):
preference = WorkspaceHomePreference.objects.filter(
key=key, workspace__slug=slug
key=key, workspace__slug=slug, user=request.user
).first()

if preference:
Expand Down
14 changes: 6 additions & 8 deletions apiserver/plane/bgtasks/workspace_invitation_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@


@shared_task
def workspace_invitation(email, workspace_id, token, current_site, invitor):
def workspace_invitation(email, workspace_id, token, current_site, inviter):
try:
user = User.objects.get(email=invitor)
user = User.objects.get(email=inviter)

workspace = Workspace.objects.get(pk=workspace_id)
workspace_member_invite = WorkspaceMemberInvite.objects.get(
token=token, email=email
)

# Relative link
relative_link = f"/workspace-invitations/?invitation_id={workspace_member_invite.id}&email={email}&slug={workspace.slug}"
relative_link = f"/workspace-invitations/?invitation_id={workspace_member_invite.id}&email={email}&slug={workspace.slug}" # noqa: E501

# The complete url including the domain
abs_url = str(current_site) + relative_link
Expand All @@ -42,7 +42,7 @@ def workspace_invitation(email, workspace_id, token, current_site, invitor):
) = get_email_configuration()

# Subject of the email
subject = f"{user.first_name or user.display_name or user.email} has invited you to join them in {workspace.name} on Plane"
subject = f"{user.first_name or user.display_name or user.email} has invited you to join them in {workspace.name} on Plane" # noqa: E501

context = {
"email": email,
Expand Down Expand Up @@ -78,11 +78,9 @@ def workspace_invitation(email, workspace_id, token, current_site, invitor):
)
msg.attach_alternative(html_content, "text/html")
msg.send()
logging.getLogger("plane").info("Email sent succesfully")

logging.getLogger("plane").info("Email sent successfully")
return
except (Workspace.DoesNotExist, WorkspaceMemberInvite.DoesNotExist) as e:
log_exception(e)
except (Workspace.DoesNotExist, WorkspaceMemberInvite.DoesNotExist):
return
except Exception as e:
log_exception(e)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Generated by Django 4.2.17 on 2025-01-09 14:43

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

dependencies = [
('db', '0089_workspacehomepreference_and_more'),
]

operations = [
migrations.RenameModel(
old_name='Dashboard',
new_name='DeprecatedDashboard',
),
migrations.RenameModel(
old_name='DashboardWidget',
new_name='DeprecatedDashboardWidget',
),
migrations.RenameModel(
old_name='Widget',
new_name='DeprecatedWidget',
),
migrations.AlterModelOptions(
name='deprecateddashboard',
options={'ordering': ('-created_at',), 'verbose_name': 'DeprecatedDashboard', 'verbose_name_plural': 'DeprecatedDashboards'},
),
migrations.AlterModelOptions(
name='deprecateddashboardwidget',
options={'ordering': ('-created_at',), 'verbose_name': 'Deprecated Dashboard Widget', 'verbose_name_plural': 'Deprecated Dashboard Widgets'},
),
migrations.AlterModelOptions(
name='deprecatedwidget',
options={'ordering': ('-created_at',), 'verbose_name': 'DeprecatedWidget', 'verbose_name_plural': 'DeprecatedWidgets'},
),
migrations.AlterField(
model_name='workspacehomepreference',
name='sort_order',
field=models.FloatField(default=65535),
),
migrations.AlterModelTable(
name='deprecateddashboard',
table='deprecated_dashboards',
),
migrations.AlterModelTable(
name='deprecateddashboardwidget',
table='deprecated_dashboard_widgets',
),
migrations.AlterModelTable(
name='deprecatedwidget',
table='deprecated_widgets',
),
migrations.CreateModel(
name='WorkspaceUserPreference',
fields=[
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Last Modified At')),
('deleted_at', models.DateTimeField(blank=True, null=True, verbose_name='Deleted At')),
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
('key', models.CharField(max_length=255)),
('is_pinned', models.BooleanField(default=False)),
('sort_order', models.FloatField(default=65535)),
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL, verbose_name='Created By')),
('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_updated_by', to=settings.AUTH_USER_MODEL, verbose_name='Last Modified By')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_user_preferences', to=settings.AUTH_USER_MODEL)),
('workspace', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_user_preferences', to='db.workspace')),
],
options={
'verbose_name': 'Workspace User Preference',
'verbose_name_plural': 'Workspace User Preferences',
'db_table': 'workspace_user_preferences',
'ordering': ('-created_at',),
},
),
migrations.AddConstraint(
model_name='workspaceuserpreference',
constraint=models.UniqueConstraint(condition=models.Q(('deleted_at__isnull', True)), fields=('workspace', 'user', 'key'), name='workspace_user_preferences_unique_workspace_user_key_when_deleted_at_null'),
),
migrations.AlterUniqueTogether(
name='workspaceuserpreference',
unique_together={('workspace', 'user', 'key', 'deleted_at')},
),
]
2 changes: 1 addition & 1 deletion apiserver/plane/db/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .asset import FileAsset
from .base import BaseModel
from .cycle import Cycle, CycleIssue, CycleUserProperties
from .dashboard import Dashboard, DashboardWidget, Widget
from .dashboard import DeprecatedDashboard, DeprecatedDashboardWidget, DeprecatedWidget
from .deploy_board import DeployBoard
from .draft import (
DraftIssue,
Expand Down
Loading

0 comments on commit 4eaf34d

Please sign in to comment.