-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WEB-3038]feat: home preferences #6308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
d79b0cc
WIP
sangeethailango 4edfa55
WIP
sangeethailango abb68ff
WIP
sangeethailango f4a1b0f
WIP
sangeethailango 1d147b0
Create home preference if not exist
sangeethailango de5643c
chore: handled the unique state name validation (#6299)
NarayanBavisetti 2eb0aae
fix: changed the response structure (#6301)
NarayanBavisetti 97b569f
[WEB-1964]chore: cycles actions restructuring (#6298)
vamsikrishnamathala e22f5ce
fix: active cycle graph tooltip and endpoint validation (#6306)
anmolsinghbhatia 269ac69
[WEB-2870]feat: language support (#6215)
vamsikrishnamathala 59700c5
feat: introduced stacked bar chart and tree map chart. (#6305)
prateekshourya29 225d131
feat: add issue attachment external endpoint (#6307)
pablohashescobar 73f3151
[PE-97] chore: re-order pages options (#6303)
aaryan610 8d27e54
fix: remove localdb tracing
sriramveeraghanta 1a3479c
[WEB-2937] feat: home recent activies list endpoint (#6295)
sangeethailango 69daabb
fix: remove emoji edit for uneditable pages (#6304)
aaryan610 1b4575e
Merge branch 'preview' of github.com:makeplane/plane into feat-home-w…
sangeethailango 77a2206
Removed duplicate imports
sangeethailango 30434b4
feat: patch api
sangeethailango 3d66618
Merge branch 'preview' into feat-home-widgets
sangeethailango 1d60d14
Enable sort order to be updatable
sangeethailango 739e07a
Merge branch 'preview' into feat-home-widgets
sangeethailango 901164b
Merge branch 'preview' into feat-home-widgets
sangeethailango 6997528
Return key name
sangeethailango ac7c604
Merge branch 'feat-home-widgets' of github.com:makeplane/plane into f…
sriramveeraghanta b9b33ed
Merge branch 'preview' of github.com:makeplane/plane into feat-home-w…
sriramveeraghanta d9c7249
Remove random generation of sort_order
sangeethailango e766e3d
Merge branch 'feat-home-widgets' of github.com:makeplane/plane into f…
sangeethailango 607f2df
Remove name field
sangeethailango File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # Module imports | ||
| from ..base import BaseAPIView | ||
| from plane.db.models.workspace import WorkspaceHomePreference | ||
| from plane.app.permissions import allow_permission, ROLE | ||
| from plane.db.models import Workspace | ||
| from plane.app.serializers.workspace import WorkspaceHomePreferenceSerializer | ||
|
|
||
| # Third party imports | ||
| from rest_framework.response import Response | ||
| from rest_framework import status | ||
|
|
||
|
|
||
| class WorkspacePreferenceViewSet(BaseAPIView): | ||
| model = WorkspaceHomePreference | ||
|
|
||
| def get_serializer_class(self): | ||
| return WorkspaceHomePreferenceSerializer | ||
|
|
||
| @allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST], level="WORKSPACE") | ||
| def get(self, request, slug): | ||
| workspace = Workspace.objects.get(slug=slug) | ||
|
|
||
| get_preference = WorkspaceHomePreference.objects.filter( | ||
| user=request.user, workspace_id=workspace.id | ||
| ) | ||
|
|
||
| create_preference_keys = [] | ||
|
|
||
| keys = [key for key, _ in WorkspaceHomePreference.HomeWidgetKeys.choices] | ||
|
|
||
| for preference in keys: | ||
| if preference not in get_preference.values_list("key", flat=True): | ||
| create_preference_keys.append(preference) | ||
|
|
||
| preference = WorkspaceHomePreference.objects.bulk_create( | ||
| [ | ||
| WorkspaceHomePreference( | ||
| key=key, user=request.user, workspace=workspace | ||
| ) | ||
| for key in create_preference_keys | ||
| ], | ||
| batch_size=10, | ||
| ignore_conflicts=True, | ||
| ) | ||
| preference = WorkspaceHomePreference.objects.filter( | ||
| user=request.user, workspace_id=workspace.id | ||
| ) | ||
|
|
||
| return Response( | ||
| preference.values("key", "is_enabled", "config", "sort_order"), | ||
| status=status.HTTP_200_OK, | ||
| ) | ||
|
|
||
| @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 | ||
| ).first() | ||
|
|
||
| if preference: | ||
| serializer = WorkspaceHomePreferenceSerializer( | ||
| preference, data=request.data, partial=True | ||
| ) | ||
|
|
||
| if serializer.is_valid(): | ||
| serializer.save() | ||
| return Response(serializer.data, status=status.HTTP_200_OK) | ||
| return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
|
|
||
| return Response( | ||
| {"detail": "Preference not found"}, status=status.HTTP_400_BAD_REQUEST | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.