From 38a1f65646a25a63c6d6729866b6757c2fb04a79 Mon Sep 17 00:00:00 2001 From: Phillip Kelley-Dotson Date: Thu, 15 Apr 2021 22:03:46 -0700 Subject: [PATCH] chore(toggle thumbnails): use localstorage for toggle (#14013) * use localstorage for toggle * fix lint * add check --- superset-frontend/src/views/CRUD/chart/ChartCard.tsx | 8 +++++--- superset-frontend/src/views/CRUD/chart/ChartList.tsx | 8 ++++++++ .../src/views/CRUD/dashboard/DashboardCard.tsx | 9 ++++++--- .../src/views/CRUD/dashboard/DashboardList.tsx | 8 ++++++++ superset-frontend/src/views/CRUD/welcome/ChartTable.tsx | 3 --- .../src/views/CRUD/welcome/DashboardTable.tsx | 2 -- superset-frontend/src/views/CRUD/welcome/Welcome.tsx | 8 +------- 7 files changed, 28 insertions(+), 18 deletions(-) diff --git a/superset-frontend/src/views/CRUD/chart/ChartCard.tsx b/superset-frontend/src/views/CRUD/chart/ChartCard.tsx index c8ce8523b7..cc4f066f95 100644 --- a/superset-frontend/src/views/CRUD/chart/ChartCard.tsx +++ b/superset-frontend/src/views/CRUD/chart/ChartCard.tsx @@ -45,7 +45,6 @@ interface ChartCardProps { chartFilter?: string; userId?: number; showThumbnails?: boolean; - featureFlag?: boolean; } export default function ChartCard({ @@ -62,7 +61,6 @@ export default function ChartCard({ favoriteStatus, chartFilter, userId, - featureFlag, }: ChartCardProps) { const canEdit = hasPerm('can_write'); const canDelete = hasPerm('can_write'); @@ -142,7 +140,11 @@ export default function ChartCard({ : null} + cover={ + !isFeatureEnabled(FeatureFlag.THUMBNAILS) || !showThumbnails ? ( + <> + ) : null + } url={bulkSelectEnabled ? undefined : chart.url} imgURL={chart.thumbnail_url || ''} imgFallbackURL="/static/assets/images/chart-card-fallback.svg" diff --git a/superset-frontend/src/views/CRUD/chart/ChartList.tsx b/superset-frontend/src/views/CRUD/chart/ChartList.tsx index 26edf5abd4..ac46f51299 100644 --- a/superset-frontend/src/views/CRUD/chart/ChartList.tsx +++ b/superset-frontend/src/views/CRUD/chart/ChartList.tsx @@ -46,6 +46,7 @@ import ListView, { SelectOption, FilterOperators, } from 'src/components/ListView'; +import { getFromLocalStorage } from 'src/utils/localStorageHelpers'; import withToasts from 'src/messageToasts/enhancers/withToasts'; import PropertiesModal from 'src/explore/components/PropertiesModal'; import ImportModelsModal from 'src/components/ImportModal/index'; @@ -506,9 +507,16 @@ function ChartList(props: ChartListProps) { ]; function renderCard(chart: Chart) { + const { userId } = props.user; + const userKey = getFromLocalStorage(userId.toString(), null); return ( {dashboard.published ? t('published') : t('draft')} } - cover={!featureFlag || !showThumbnails ? <> : null} + cover={ + !isFeatureEnabled(FeatureFlag.THUMBNAILS) || !showThumbnails ? ( + <> + ) : null + } url={bulkSelectEnabled ? undefined : dashboard.url} imgURL={dashboard.thumbnail_url} imgFallbackURL="/static/assets/images/dashboard-card-fallback.svg" diff --git a/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx b/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx index b9e305a158..91656aca5b 100644 --- a/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx +++ b/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx @@ -34,6 +34,7 @@ import ListView, { Filters, FilterOperators, } from 'src/components/ListView'; +import { getFromLocalStorage } from 'src/utils/localStorageHelpers'; import Owner from 'src/types/Owner'; import withToasts from 'src/messageToasts/enhancers/withToasts'; import FacePile from 'src/components/FacePile'; @@ -452,12 +453,19 @@ function DashboardList(props: DashboardListProps) { ]; function renderCard(dashboard: Dashboard) { + const { userId } = props.user; + const userKey = getFromLocalStorage(userId.toString(), null); return ( ; showThumbnails: boolean; - featureFlag: boolean; } function ChartTable({ @@ -54,7 +53,6 @@ function ChartTable({ addSuccessToast, mine, showThumbnails, - featureFlag, }: ChartTableProps) { const history = useHistory(); const { @@ -186,7 +184,6 @@ function ChartTable({ hasPerm={hasPerm} showThumbnails={showThumbnails} bulkSelectEnabled={bulkSelectEnabled} - featureFlag={featureFlag} refreshData={refreshData} addDangerToast={addDangerToast} addSuccessToast={addSuccessToast} diff --git a/superset-frontend/src/views/CRUD/welcome/DashboardTable.tsx b/superset-frontend/src/views/CRUD/welcome/DashboardTable.tsx index 64d1f8019e..e2a219d75a 100644 --- a/superset-frontend/src/views/CRUD/welcome/DashboardTable.tsx +++ b/superset-frontend/src/views/CRUD/welcome/DashboardTable.tsx @@ -43,7 +43,6 @@ function DashboardTable({ addSuccessToast, mine, showThumbnails, - featureFlag, }: DashboardTableProps) { const history = useHistory(); const { @@ -193,7 +192,6 @@ function DashboardTable({ dashboard={e} hasPerm={hasPerm} bulkSelectEnabled={false} - featureFlag={featureFlag} showThumbnails={showThumbnails} dashboardFilter={dashboardFilter} refreshData={refreshData} diff --git a/superset-frontend/src/views/CRUD/welcome/Welcome.tsx b/superset-frontend/src/views/CRUD/welcome/Welcome.tsx index bb9da4a6a3..a6a7d46bbe 100644 --- a/superset-frontend/src/views/CRUD/welcome/Welcome.tsx +++ b/superset-frontend/src/views/CRUD/welcome/Welcome.tsx @@ -228,7 +228,6 @@ function Welcome({ user, addDangerToast }: WelcomeProps) { user={user} mine={dashboardData} showThumbnails={checked} - featureFlag={isFeatureEnabled(FeatureFlag.THUMBNAILS)} /> )} @@ -248,12 +247,7 @@ function Welcome({ user, addDangerToast }: WelcomeProps) { {!chartData ? ( ) : ( - + )}