From ecdd1f1d03d65598e6e18a8d05ffe1f26f697958 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Thu, 20 Jul 2023 17:24:17 +0530 Subject: [PATCH] promote: develop to stage-release (#1594) * fix: onboarding invitations overflow (#1575) * fix: onboarding invitations overflow * fix: user avatar in the notification card * style: update graph grid color * fix: no 'Create by me' label coming up (#1573) * feat: added new issue subscriber table * dev: notification model * feat: added CRUD operation for issue subscriber * Revert "feat: added CRUD operation for issue subscriber" This reverts commit b22e0625768f0b096b5898936ace76d6882b0736. * feat: added CRUD operation for issue subscriber * dev: notification models and operations * dev: remove delete endpoint response data * dev: notification endpoints and fix bg worker for saving notifications * feat: added list and unsubscribe function in issue subscriber * dev: filter by snoozed and response update for list and permissions * dev: update issue notifications * dev: notification segregation * dev: update notifications * dev: notification filtering * dev: add issue name in notifications * dev: notification new endpoints * fix: pushing local settings * feat: notification workflow setup and made basic UI * style: improved UX with toast alerts and other interactions refactor: changed classnames according to new theme structure, changed all icons to material icons * feat: showing un-read notification count * feat: not showing 'subscribe' button on issue created by user & assigned to user not showing 'Create by you' for view & guest of the workspace * fix: 'read' -> 'unread' heading, my issue wrong filter * feat: made snooze dropdown & modal feat: switched to calendar * fix: minor ui fixes * feat: snooze modal date/time select * fix: params for read/un-read notification * style: snooze notification modal * fix: no label for 'Create by me' * fix: no label for 'Create by me' * fix: removed console log * fix: tooltip going behind popover --------- Co-authored-by: NarayanBavisetti Co-authored-by: pablohashescobar Co-authored-by: Aaryan Khandelwal * style: tooltip on notification header actions (#1577) * style: tooltip on notification header * chore: update tooltip content --------- Co-authored-by: Aaryan Khandelwal * fix: user migrations for back population (#1578) * fix: total notifications count (#1579) * fix: notification card (#1583) * feat: add new icons package (#1586) * feat: add material icons package * chore: replace issue view icons * chore: notification ordering (#1584) * fix: uuid error when cycle and module updates (#1585) * refactor: height of popover & api fetch call (#1587) * fix: snooze dropdown overflow (#1588) * fix: notification subscribe endpoint (#1593) * refactor: height of popover & api fetch call * fix: notification subscribe endpoint * chore: notification empty state overflow (#1592) * chore: notification empty state overflow * fix: white logo * fix: custom theme default values * fix: custom theme default values * fix: issues count to remove archived issues (#1591) * dev: background migration for user custom themes (#1590) --------- Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: NarayanBavisetti Co-authored-by: pablohashescobar Co-authored-by: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Co-authored-by: gurusainath --- apiserver/plane/api/views/notification.py | 3 ++ .../db/migrations/0038_auto_20230720_1505.py | 35 +++++++++++++++++++ .../core/theme/custom-theme-selector.tsx | 2 +- .../components/core/theme/theme-switch.tsx | 17 ++++++++- .../notifications/notification-popover.tsx | 2 +- apps/app/contexts/theme.context.tsx | 7 +++- .../use-issue-notification-subscription.tsx | 29 ++++++++++----- .../me/profile/preferences.tsx | 17 ++++++++- .../white-horizontal-with-blue-logo.svg | 10 +++--- apps/app/services/notifications.service.ts | 8 ++--- 10 files changed, 105 insertions(+), 25 deletions(-) create mode 100644 apiserver/plane/db/migrations/0038_auto_20230720_1505.py diff --git a/apiserver/plane/api/views/notification.py b/apiserver/plane/api/views/notification.py index f0c8e05d5..b7f5bd335 100644 --- a/apiserver/plane/api/views/notification.py +++ b/apiserver/plane/api/views/notification.py @@ -214,6 +214,7 @@ class UnreadNotificationEndpoint(BaseAPIView): workspace__slug=slug, receiver_id=request.user.id, read_at__isnull=True, + archived_at__isnull=True, entity_identifier__in=IssueSubscriber.objects.filter( workspace__slug=slug, subscriber_id=request.user.id ).values_list("issue_id", flat=True), @@ -224,6 +225,7 @@ class UnreadNotificationEndpoint(BaseAPIView): workspace__slug=slug, receiver_id=request.user.id, read_at__isnull=True, + archived_at__isnull=True, entity_identifier__in=IssueAssignee.objects.filter( workspace__slug=slug, assignee_id=request.user.id ).values_list("issue_id", flat=True), @@ -234,6 +236,7 @@ class UnreadNotificationEndpoint(BaseAPIView): workspace__slug=slug, receiver_id=request.user.id, read_at__isnull=True, + archived_at__isnull=True, entity_identifier__in=Issue.objects.filter( workspace__slug=slug, created_by=request.user ).values_list("pk", flat=True), diff --git a/apiserver/plane/db/migrations/0038_auto_20230720_1505.py b/apiserver/plane/db/migrations/0038_auto_20230720_1505.py new file mode 100644 index 000000000..1f5c63a89 --- /dev/null +++ b/apiserver/plane/db/migrations/0038_auto_20230720_1505.py @@ -0,0 +1,35 @@ +# Generated by Django 4.2.3 on 2023-07-20 09:35 + +from django.db import migrations, models + + +def restructure_theming(apps, schema_editor): + Model = apps.get_model("db", "User") + updated_user = [] + for obj in Model.objects.exclude(theme={}).all(): + current_theme = obj.theme + updated_theme = { + "primary": current_theme.get("accent", ""), + "background": current_theme.get("bgBase", ""), + "sidebarBackground": current_theme.get("sidebar", ""), + "text": current_theme.get("textBase", ""), + "sidebarText": current_theme.get("textBase", ""), + "palette": f"""{current_theme.get("bgBase","")},{current_theme.get("textBase", "")},{current_theme.get("accent", "")},{current_theme.get("sidebar","")},{current_theme.get("textBase", "")}""", + "darkPalette": current_theme.get("darkPalette", "") + } + obj.theme = updated_theme + updated_user.append(obj) + + Model.objects.bulk_update( + updated_user, ["theme"], batch_size=100 + ) + + +class Migration(migrations.Migration): + dependencies = [ + ("db", "0037_issue_archived_at_project_archive_in_and_more"), + ] + + operations = [ + migrations.RunPython(restructure_theming) + ] diff --git a/apps/app/components/core/theme/custom-theme-selector.tsx b/apps/app/components/core/theme/custom-theme-selector.tsx index 5f36115f8..40450ee2c 100644 --- a/apps/app/components/core/theme/custom-theme-selector.tsx +++ b/apps/app/components/core/theme/custom-theme-selector.tsx @@ -69,8 +69,8 @@ export const CustomThemeSelector: React.FC = ({ preLoadedData }) => { return { ...prevData, ...res }; }, false); - applyTheme(payload.palette, darkPalette); setTheme("custom"); + applyTheme(payload.palette, darkPalette); }) .catch((err) => console.log(err)); }; diff --git a/apps/app/components/core/theme/theme-switch.tsx b/apps/app/components/core/theme/theme-switch.tsx index 8929015ee..39b570bc5 100644 --- a/apps/app/components/core/theme/theme-switch.tsx +++ b/apps/app/components/core/theme/theme-switch.tsx @@ -71,7 +71,21 @@ export const ThemeSwitch: React.FC = ({ } onChange={({ value, type }: { value: string; type: string }) => { if (value === "custom") { - if (user?.theme.palette) setPreLoadedData(user.theme); + if (user?.theme.palette) { + setPreLoadedData({ + background: user.theme.background !== "" ? user.theme.background : "#0d101b", + text: user.theme.text !== "" ? user.theme.text : "#c5c5c5", + primary: user.theme.primary !== "" ? user.theme.primary : "#3f76ff", + sidebarBackground: + user.theme.sidebarBackground !== "" ? user.theme.sidebarBackground : "#0d101b", + sidebarText: user.theme.sidebarText !== "" ? user.theme.sidebarText : "#c5c5c5", + darkPalette: false, + palette: + user.theme.palette !== ",,,," + ? user.theme.palette + : "#0d101b,#c5c5c5,#3f76ff,#0d101b,#c5c5c5", + }); + } if (!customThemeSelectorOptions) setCustomThemeSelectorOptions(true); } else { @@ -87,6 +101,7 @@ export const ThemeSwitch: React.FC = ({ document.documentElement.style.removeProperty(`--color-sidebar-border-${i}`); } } + setTheme(value); document.documentElement.style.setProperty("color-scheme", type); }} diff --git a/apps/app/components/notifications/notification-popover.tsx b/apps/app/components/notifications/notification-popover.tsx index a8652e7ff..255d8af04 100644 --- a/apps/app/components/notifications/notification-popover.tsx +++ b/apps/app/components/notifications/notification-popover.tsx @@ -274,7 +274,7 @@ export const NotificationPopover = () => { ))} ) : ( -
+
= ({ const theme = localStorage.getItem("theme"); if (theme && theme === "custom") { if (user && user.theme.palette) { - applyTheme(user.theme.palette, user.theme.darkPalette); + applyTheme( + user.theme.palette !== ",,,," + ? user.theme.palette + : "#0d101b,#c5c5c5,#3f76ff,#0d101b,#c5c5c5", + user.theme.darkPalette + ); } } }, [user]); diff --git a/apps/app/hooks/use-issue-notification-subscription.tsx b/apps/app/hooks/use-issue-notification-subscription.tsx index 2abe353b0..a118bdf6a 100644 --- a/apps/app/hooks/use-issue-notification-subscription.tsx +++ b/apps/app/hooks/use-issue-notification-subscription.tsx @@ -31,11 +31,18 @@ const useUserIssueNotificationSubscription = ( const handleUnsubscribe = useCallback(() => { if (!workspaceSlug || !projectId || !issueId) return; + mutate( + { + subscribed: false, + }, + false + ); + userNotificationServices .unsubscribeFromIssueNotifications( - workspaceSlug as string, - projectId as string, - issueId as string + workspaceSlug.toString(), + projectId.toString(), + issueId.toString() ) .then(() => { mutate({ @@ -47,14 +54,18 @@ const useUserIssueNotificationSubscription = ( const handleSubscribe = useCallback(() => { if (!workspaceSlug || !projectId || !issueId || !user) return; + mutate( + { + subscribed: true, + }, + false + ); + userNotificationServices .subscribeToIssueNotifications( - workspaceSlug as string, - projectId as string, - issueId as string, - { - subscriber: user.id, - } + workspaceSlug.toString(), + projectId.toString(), + issueId.toString() ) .then(() => { mutate({ diff --git a/apps/app/pages/[workspaceSlug]/me/profile/preferences.tsx b/apps/app/pages/[workspaceSlug]/me/profile/preferences.tsx index 64b598f7f..605131aa4 100644 --- a/apps/app/pages/[workspaceSlug]/me/profile/preferences.tsx +++ b/apps/app/pages/[workspaceSlug]/me/profile/preferences.tsx @@ -22,7 +22,22 @@ const ProfilePreferences = () => { useEffect(() => { if (theme === "custom") { - if (myProfile?.theme.palette) setPreLoadedData(myProfile.theme); + if (myProfile?.theme.palette) + setPreLoadedData({ + background: myProfile.theme.background !== "" ? myProfile.theme.background : "#0d101b", + text: myProfile.theme.text !== "" ? myProfile.theme.text : "#c5c5c5", + primary: myProfile.theme.primary !== "" ? myProfile.theme.primary : "#3f76ff", + sidebarBackground: + myProfile.theme.sidebarBackground !== "" + ? myProfile.theme.sidebarBackground + : "#0d101b", + sidebarText: myProfile.theme.sidebarText !== "" ? myProfile.theme.sidebarText : "#c5c5c5", + darkPalette: false, + palette: + myProfile.theme.palette !== ",,,," + ? myProfile.theme.palette + : "#0d101b,#c5c5c5,#3f76ff,#0d101b,#c5c5c5", + }); if (!customThemeSelectorOptions) setCustomThemeSelectorOptions(true); } }, [myProfile, theme, customThemeSelectorOptions]); diff --git a/apps/app/public/plane-logos/white-horizontal-with-blue-logo.svg b/apps/app/public/plane-logos/white-horizontal-with-blue-logo.svg index d8cc6f4ef..1f09cc34a 100644 --- a/apps/app/public/plane-logos/white-horizontal-with-blue-logo.svg +++ b/apps/app/public/plane-logos/white-horizontal-with-blue-logo.svg @@ -1,10 +1,10 @@ - - - - - + + + + + diff --git a/apps/app/services/notifications.service.ts b/apps/app/services/notifications.service.ts index 412b03988..6c6bec62d 100644 --- a/apps/app/services/notifications.service.ts +++ b/apps/app/services/notifications.service.ts @@ -111,14 +111,10 @@ class UserNotificationsServices extends APIService { async subscribeToIssueNotifications( workspaceSlug: string, projectId: string, - issueId: string, - data: { - subscriber: string; - } + issueId: string ): Promise { return this.post( - `/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/issue-subscribers/`, - data + `/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/subscribe/` ) .then((response) => response?.data) .catch((error) => {