From f26ced97fec0cfe293789e1b881d494228696870 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Sun, 5 Mar 2023 13:21:06 +0200 Subject: [PATCH] feat(webapp): deprecate the subscription from webapp. --- .../src/components/Dashboard/Dashboard.tsx | 11 +- .../components/Dashboard/DashboardBoot.tsx | 10 +- .../Dashboard/DashboardBreadcrumbs.tsx | 39 +++---- .../components/Dashboard/DashboardContent.tsx | 2 +- .../Dashboard/DashboardContentRoute.tsx | 19 +--- .../{ => DashboardTopbar}/DashboardTopbar.tsx | 105 +++--------------- .../Dashboard/DashboardTopbar/_components.tsx | 61 ++++++++++ .../Dashboard/DashboardTopbar/index.ts | 1 + .../src/components/Dashboard/TopbarUser.tsx | 32 ++---- packages/webapp/src/constants/sidebarMenu.tsx | 16 --- .../Dashboard/Sidebar/SidebarContainer.tsx | 9 -- .../Dashboard/Sidebar/SidebarMenu.tsx | 12 +- .../containers/Dashboard/Sidebar/hooks.tsx | 5 +- .../containers/Setup/SetupRightSection.tsx | 1 - packages/webapp/src/routes/register.tsx | 23 ---- 15 files changed, 118 insertions(+), 228 deletions(-) rename packages/webapp/src/components/Dashboard/{ => DashboardTopbar}/DashboardTopbar.tsx (57%) create mode 100644 packages/webapp/src/components/Dashboard/DashboardTopbar/_components.tsx create mode 100644 packages/webapp/src/components/Dashboard/DashboardTopbar/index.ts delete mode 100644 packages/webapp/src/routes/register.tsx diff --git a/packages/webapp/src/components/Dashboard/Dashboard.tsx b/packages/webapp/src/components/Dashboard/Dashboard.tsx index 8371e0fba..2637128cf 100644 --- a/packages/webapp/src/components/Dashboard/Dashboard.tsx +++ b/packages/webapp/src/components/Dashboard/Dashboard.tsx @@ -14,19 +14,16 @@ import GlobalHotkeys from './GlobalHotkeys'; import DashboardProvider from './DashboardProvider'; import DrawersContainer from '@/components/DrawersContainer'; import AlertsContainer from '@/containers/AlertsContainer'; -import EnsureSubscriptionIsActive from '../Guards/EnsureSubscriptionIsActive'; /** * Dashboard preferences. */ function DashboardPreferences() { return ( - - - - - - + + + + ); } diff --git a/packages/webapp/src/components/Dashboard/DashboardBoot.tsx b/packages/webapp/src/components/Dashboard/DashboardBoot.tsx index a3316a7f5..2389cc4a7 100644 --- a/packages/webapp/src/components/Dashboard/DashboardBoot.tsx +++ b/packages/webapp/src/components/Dashboard/DashboardBoot.tsx @@ -7,26 +7,20 @@ import { } from '@/hooks/query'; import { useSplashLoading } from '@/hooks/state'; import { useWatch, useWatchImmediate, useWhen } from '@/hooks'; -import { useSubscription } from '@/hooks/state'; import { setCookie, getCookie } from '@/utils'; /** * Dashboard meta async booting. - * - Fetches the dashboard meta only if the organization subscribe is active. - * - Once the dashboard meta query is loading display dashboard splash screen. + * - Fetches the dashboard meta in booting state. + * - Once the dashboard meta query started loading display dashboard splash screen. */ export function useDashboardMetaBoot() { - const { isSubscriptionActive } = useSubscription(); - const { data: dashboardMeta, isLoading: isDashboardMetaLoading, isSuccess: isDashboardMetaSuccess, } = useDashboardMeta({ keepPreviousData: true, - - // Avoid run the query if the organization subscription is not active. - enabled: isSubscriptionActive, }); const [startLoading, stopLoading] = useSplashLoading(); diff --git a/packages/webapp/src/components/Dashboard/DashboardBreadcrumbs.tsx b/packages/webapp/src/components/Dashboard/DashboardBreadcrumbs.tsx index 38537b2a4..d04144e8e 100644 --- a/packages/webapp/src/components/Dashboard/DashboardBreadcrumbs.tsx +++ b/packages/webapp/src/components/Dashboard/DashboardBreadcrumbs.tsx @@ -1,5 +1,6 @@ // @ts-nocheck import React from 'react'; +import { useHistory } from 'react-router-dom'; import { CollapsibleList, MenuItem, @@ -7,29 +8,29 @@ import { Boundary, } from '@blueprintjs/core'; import withBreadcrumbs from 'react-router-breadcrumbs-hoc'; -import { getDashboardRoutes } from '@/routes/dashboard'; -import { useHistory } from 'react-router-dom'; -function DashboardBreadcrumbs({ breadcrumbs }){ +function DashboardBreadcrumbs({ breadcrumbs }) { const history = useHistory(); - return( + return ( } - collapseFrom={Boundary.START} - visibleItemCount={0}> - { - breadcrumbs.map(({ breadcrumb,match })=>{ - return ( history.push(match.url) } />) - }) - } + className={Classes.BREADCRUMBS} + dropdownTarget={} + collapseFrom={Boundary.START} + visibleItemCount={0} + > + {breadcrumbs.map(({ breadcrumb, match }) => { + return ( + history.push(match.url)} + /> + ); + })} - ) + ); } -export default withBreadcrumbs([])(DashboardBreadcrumbs) +export default withBreadcrumbs([])(DashboardBreadcrumbs); diff --git a/packages/webapp/src/components/Dashboard/DashboardContent.tsx b/packages/webapp/src/components/Dashboard/DashboardContent.tsx index fcdce6195..640bce34b 100644 --- a/packages/webapp/src/components/Dashboard/DashboardContent.tsx +++ b/packages/webapp/src/components/Dashboard/DashboardContent.tsx @@ -1,7 +1,7 @@ // @ts-nocheck import React from 'react'; import { ErrorBoundary } from 'react-error-boundary'; -import DashboardTopbar from '@/components/Dashboard/DashboardTopbar'; +import DashboardTopbar from '@/components/Dashboard/DashboardTopbar/DashboardTopbar'; import DashboardContentRoutes from '@/components/Dashboard/DashboardContentRoute'; import DashboardErrorBoundary from './DashboardErrorBoundary'; diff --git a/packages/webapp/src/components/Dashboard/DashboardContentRoute.tsx b/packages/webapp/src/components/Dashboard/DashboardContentRoute.tsx index cf5ccf4b5..ac23d319a 100644 --- a/packages/webapp/src/components/Dashboard/DashboardContentRoute.tsx +++ b/packages/webapp/src/components/Dashboard/DashboardContentRoute.tsx @@ -3,15 +3,13 @@ import React from 'react'; import { Route, Switch } from 'react-router-dom'; import { getDashboardRoutes } from '@/routes/dashboard'; -import EnsureSubscriptionsIsActive from '../Guards/EnsureSubscriptionsIsActive'; -import EnsureSubscriptionsIsInactive from '../Guards/EnsureSubscriptionsIsInactive'; import DashboardPage from './DashboardPage'; /** * Dashboard inner route content. */ function DashboardContentRouteContent({ route }) { - const content = ( + return ( ); - return route.subscriptionActive ? ( - - ) : route.subscriptionInactive ? ( - - ) : ( - content - ); } /** diff --git a/packages/webapp/src/components/Dashboard/DashboardTopbar.tsx b/packages/webapp/src/components/Dashboard/DashboardTopbar/DashboardTopbar.tsx similarity index 57% rename from packages/webapp/src/components/Dashboard/DashboardTopbar.tsx rename to packages/webapp/src/components/Dashboard/DashboardTopbar/DashboardTopbar.tsx index a7422845e..c9e8e6946 100644 --- a/packages/webapp/src/components/Dashboard/DashboardTopbar.tsx +++ b/packages/webapp/src/components/Dashboard/DashboardTopbar/DashboardTopbar.tsx @@ -10,57 +10,19 @@ import { Tooltip, Position, } from '@blueprintjs/core'; -import { FormattedMessage as T } from '@/components'; +import { FormattedMessage as T, Icon, Hint, If } from '@/components'; import DashboardTopbarUser from '@/components/Dashboard/TopbarUser'; import DashboardBreadcrumbs from '@/components/Dashboard/DashboardBreadcrumbs'; import DashboardBackLink from '@/components/Dashboard/DashboardBackLink'; -import { Icon, Hint, If } from '@/components'; import withUniversalSearchActions from '@/containers/UniversalSearch/withUniversalSearchActions'; import withDashboardActions from '@/containers/Dashboard/withDashboardActions'; import withDashboard from '@/containers/Dashboard/withDashboard'; import QuickNewDropdown from '@/containers/QuickNewDropdown/QuickNewDropdown'; +import { DashboardHamburgerButton, DashboardQuickSearchButton } from './_components'; import { compose } from '@/utils'; -import withSubscriptions from '@/containers/Subscriptions/withSubscriptions'; -import { useGetUniversalSearchTypeOptions } from '@/containers/UniversalSearch/utils'; - -function DashboardTopbarSubscriptionMessage() { - return ( -
- - - -
- ); -} - -function DashboardHamburgerButton({ ...props }) { - return ( -