diff --git a/apps/studio/components/layouts/AppLayout/AppHeader.tsx b/apps/studio/components/layouts/AppLayout/AppHeader.tsx index fc1e317dd74..a93adbc4a19 100644 --- a/apps/studio/components/layouts/AppLayout/AppHeader.tsx +++ b/apps/studio/components/layouts/AppLayout/AppHeader.tsx @@ -1,11 +1,11 @@ +import { useParams } from 'common' import Link from 'next/link' import { useRouter } from 'next/router' -import { useParams } from 'common' import { useFlag, useSelectedOrganization, useSelectedProject } from 'hooks' import FeedbackDropdown from '../ProjectLayout/LayoutHeader/FeedbackDropdown' import HelpPopover from '../ProjectLayout/LayoutHeader/HelpPopover' -import NotificationsPopover from '../ProjectLayout/LayoutHeader/NotificationsPopover' +import NotificationsPopoverV2 from '../ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover' import BranchDropdown from './BranchDropdown' import EnableBranchingButton from './EnableBranchingButton/EnableBranchingButton' import OrganizationDropdown from './OrganizationDropdown' @@ -13,6 +13,9 @@ import ProjectDropdown from './ProjectDropdown' import SettingsButton from './SettingsButton' import UserSettingsDropdown from './UserSettingsDropdown' +// [Joshen] Just FYI this is only for Nav V2 which is still going through design iteration +// Component is not currently in use + const AppHeader = () => { const router = useRouter() const { ref } = useParams() @@ -47,9 +50,9 @@ const AppHeader = () => {
Help
-Help
+{insertedAt}
-- Your project "{projectName}" has exceeded its limits in the following areas:{' '} - {violationsText}. -
- ) - } else if (notification.data.name === NotificationName.PostgresqlUpgradeAvailable) { - const { upgrade_type, additional } = notification.data - - if (upgrade_type === 'postgresql-server') { - const { version_to } = additional as ServerUpgrade - return ( -- New version of Postgres ({version_to}) is now available for project "{projectName}". -
- ) - } else if (upgrade_type === 'extensions') { - const { name, version_to } = additional as ExtensionsUpgrade - return ( -- New version of "{name}" ({version_to}) is now available for project "{projectName}". -
- ) - } else if (upgrade_type === 'schema-migration') { - const { name, version_to } = additional as ExtensionsUpgrade - return ( -A new schema migration is available for your project "{projectName}".
-{name}
-{version_to}
-- Postgres ({version_to}) has been successfully updated to {version_to} for project " - {projectName}". -
- ) - } else if (upgrade_type === 'extensions') { - const { name, version_to } = additional as ExtensionsUpgrade - return ( -- The extension "{name}" has been successfully updated to {version_to} for project " - {projectName}". -
- ) - } else if (upgrade_type === 'schema-migration') { - const { version_to } = additional - return ( -- The schema migration "{version_to}" has been successfully applied for project " - {projectName}". -
- ) - } - } else if (notification.data.name === NotificationName.ProjectUpdateCompleted) { - const { upgrades } = notification.data - return ( -- The following services have been successfully updated for project "{projectName}": -
-{upgrade.name}
-{upgrade.version_to}
- {upgrade.changelog_link && ( -- Unknown notification type: {notification.notification_name} - Please reach out to support - for more information. -
- ) - } -} - -export const formatNotificationCTAText = (availableActions: Action[]) => { - const [action] = availableActions - if (!action) return - - switch (action.action_type) { - case ActionType.SchedulePostgresRestart: - returnRestart your project to get the latest updates.
- case ActionType.UpgradeProjectToPro: - returnUpgrade your project to ensure continued availability.
- case ActionType.PgBouncerRestart: - returnRestart your connection pooler to get the latest updates.
- case ActionType.MigratePostgresSchema: - if (action.deadline) { - return ( -- This patch will be automatically applied after{' '} - {dayjs(new Date(action.deadline)).format('DD MMM YYYY, HH:mma')} -
- ) - } - default: - return '' - } -} diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx deleted file mode 100644 index 6ca59e7b333..00000000000 --- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopover/index.tsx +++ /dev/null @@ -1,347 +0,0 @@ -import * as Tooltip from '@radix-ui/react-tooltip' -import { - ActionType, - Notification, - NotificationStatus, - PostgresqlUpgradeData, -} from '@supabase/shared-types/out/notifications' -import { useQueryClient } from '@tanstack/react-query' -import dayjs from 'dayjs' -import { useRouter } from 'next/router' -import { Fragment, useState } from 'react' -import { Button, IconArrowRight, IconBell, IconInbox, Popover } from 'ui' - -import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog' -import { useNotificationsQuery } from 'data/notifications/notifications-query' -import { useNotificationsUpdateMutation } from 'data/notifications/notifications-update-mutation' -import { getProjectDetail } from 'data/projects/project-detail-query' -import { useProjectRestartServicesMutation } from 'data/projects/project-restart-services-mutation' -import { ProjectInfo, setProjectPostgrestStatus } from 'data/projects/projects-query' -import { useStore } from 'hooks' -import { delete_, post } from 'lib/common/fetch' -import { API_URL } from 'lib/constants' -import NotificationRow from './NotificationRow' - -interface NotificationsPopoverProps { - alt?: boolean -} - -const NotificationsPopover = ({ alt = false }: NotificationsPopoverProps) => { - const router = useRouter() - const { meta, ui } = useStore() - const queryClient = useQueryClient() - - const { data: notifications } = useNotificationsQuery() - const { mutate: updateNotifications } = useNotificationsUpdateMutation({ - onError: () => console.error('Failed to update notifications'), - }) - - const [projectToRestart, setProjectToRestart] = useStateNotifications
- {/* Area for improvement: Paginate notifications and show in a side panel */} - {/*- See all{' '} - {notifications.length > MAX_NOTIFICATIONS_TO_SHOW && `(${notifications.length})`} -
*/} -No notifications available
-The following schema migration will be applied to the project
-{(targetNotification?.data as any)?.additional?.name}
-{(targetNotification?.data as any)?.additional?.version_to}
-- This change can be rolled back anytime up till{' '} - {dayjs( - new Date(targetNotification?.meta.actions_available?.[0]?.deadline ?? 0) - ).format('DD MMM YYYY, HH:mma ZZ')} - , after which the changes will be finalized and can no longer be undone. -
-The following schema migration will be rolled back for the project
-{(targetNotification?.data as any)?.additional?.name}
-{(targetNotification?.data as any)?.additional?.version_to}
-- This migration however will still be applied and finalized after{' '} - {dayjs( - new Date(targetNotification?.meta.actions_available?.[0]?.deadline ?? 0) - ).format('DD MMM YYYY, HH:mma ZZ')} - , after which the changes can no longer be undone. -
- - } - buttonLabel="Confirm" - buttonLoadingLabel="Confirm" - onSelectCancel={() => setProjectToRollbackMigration(undefined)} - onSelectConfirm={onConfirmProjectRollbackMigration} - /> - > - ) -} - -export default NotificationsPopover diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx index a255fb4cc62..b3c47c85b3a 100644 --- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx +++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx @@ -65,7 +65,7 @@ const NotificationsPopoverV2 = () => { projects: snap.filterProjects, }, }) - const { data: summary, isSuccess: isSuccessSummary } = useNotificationsSummaryQuery() + const { data: summary } = useNotificationsSummaryQuery() const { mutate: updateNotifications } = useNotificationsV2UpdateMutation() const { mutate: archiveAllNotifications, isLoading: isArchiving } = useNotificationsArchiveAllMutation({ @@ -84,192 +84,188 @@ const NotificationsPopoverV2 = () => { } return ( -{summary?.unread_count}
-Notifications
-- {activeTab === 'archived' - ? `No archived notifications${ - snap.numFiltersApplied > 0 - ? ` based on the ${snap.numFiltersApplied} filter${ - snap.numFiltersApplied > 1 ? 's' : '' - } applied` - : '' - }` - : snap.numFiltersApplied > 0 - ? `No notifications based on the ${snap.numFiltersApplied} filter${ - snap.numFiltersApplied > 1 ? 's' : '' - } applied` - : 'All caught up'} -
-- {activeTab === 'archived' - ? 'Notifications that you have previously archived will be shown here' - : 'You will be notified here for any notices on your organizations and projects'} -
-{summary?.unread_count}
+Notifications
++ {activeTab === 'archived' + ? `No archived notifications${ + snap.numFiltersApplied > 0 + ? ` based on the ${snap.numFiltersApplied} filter${ + snap.numFiltersApplied > 1 ? 's' : '' + } applied` + : '' + }` + : snap.numFiltersApplied > 0 + ? `No notifications based on the ${snap.numFiltersApplied} filter${ + snap.numFiltersApplied > 1 ? 's' : '' + } applied` + : 'All caught up'} +
++ {activeTab === 'archived' + ? 'Notifications that you have previously archived will be shown here' + : 'You will be notified here for any notices on your organizations and projects'} +
+