Skip to content

Commit

Permalink
re-check active theme on API failure and throw a confirmation dialogue
Browse files Browse the repository at this point in the history
  • Loading branch information
arunshenoy99 committed Feb 7, 2023
1 parent 367d23d commit 7d1eff1
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useGlobalStylesOutput } from '../../../utils/global-styles/use-global-s
import { GlobalStylesProvider } from '../../LivePreview';
import {
THEME_STATUS_ACTIVE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
} from '../../../../constants';
import Animate from '../../Animate';

Expand Down Expand Up @@ -200,7 +200,7 @@ const DesignColors = () => {
const getColorStylesAndPatterns = async () => {
const colorPalettes = await getThemeColors();
if ( colorPalettes?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
setColorPalettes( colorPalettes?.body );
let selectedColors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { GlobalStylesProvider } from '../../../components/LivePreview';

import {
THEME_STATUS_ACTIVE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
} from '../../../../constants';

const DesignHeaderMenu = () => {
Expand Down Expand Up @@ -48,7 +48,7 @@ const DesignHeaderMenu = () => {
currentStep.patternId
);
if ( headerMenuPreviewResponse?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
setHeaderMenuPreviewData( headerMenuPreviewResponse.body );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getGlobalStyles } from '../../../utils/api/themes';
import { useGlobalStylesOutput } from '../../../utils/global-styles/use-global-styles-output';
import {
THEME_STATUS_ACTIVE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
} from '../../../../constants';
import {
LivePreviewSelectableCard,
Expand Down Expand Up @@ -50,11 +50,11 @@ const DesignThemeStylesPreview = () => {
true
);
if ( patternResponse?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
const globalStylesResponse = await getGlobalStyles( true );
if ( globalStylesResponse?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
setPattern( patternResponse?.body );
setGlobalStyles( globalStylesResponse?.body );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getGlobalStyles, getThemeFonts } from '../../../utils/api/themes';
import { useGlobalStylesOutput } from '../../../utils/global-styles/use-global-styles-output';
import {
THEME_STATUS_ACTIVE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
} from '../../../../constants';

const DesignTypography = () => {
Expand Down Expand Up @@ -41,7 +41,7 @@ const DesignTypography = () => {
const getFontStylesAndPatterns = async () => {
const fontPalettes = await getThemeFonts();
if ( fontPalettes?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
setFontPalettes( fontPalettes?.body );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getGlobalStyles, setGlobalStyles } from '../../../utils/api/themes';
import { useGlobalStylesOutput } from '../../../utils/global-styles/use-global-styles-output';
import {
THEME_STATUS_ACTIVE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
} from '../../../../constants';

/**
Expand Down Expand Up @@ -39,7 +39,7 @@ const GlobalStylesProvider = ( { children } ) => {
const getStylesAndPatterns = async () => {
const globalStyles = await getGlobalStyles();
if ( globalStyles?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
let selectedGlobalStyle;
if ( storedPreviewSettings?.title && storedPreviewSettings?.settings )
Expand Down
4 changes: 2 additions & 2 deletions src/OnboardingSPA/pages/Steps/DesignColors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import {
SIDEBAR_LEARN_MORE,
THEME_STATUS_ACTIVE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
VIEW_DESIGN_COLORS,
} from '../../../../constants';

Expand Down Expand Up @@ -42,7 +42,7 @@ const StepDesignColors = () => {
const getStylesAndPatterns = async () => {
const pattern = await getPatterns( currentStep.patternId, true );
if ( pattern?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
setPattern( pattern?.body );
setIsLoaded( true );
Expand Down
4 changes: 2 additions & 2 deletions src/OnboardingSPA/pages/Steps/DesignHomepageMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import CommonLayout from '../../../components/Layouts/Common';
import {
VIEW_NAV_DESIGN,
THEME_STATUS_ACTIVE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
SIDEBAR_LEARN_MORE,
} from '../../../../constants';
import HeadingWithSubHeading from '../../../components/HeadingWithSubHeading';
Expand Down Expand Up @@ -103,7 +103,7 @@ const StepDesignHomepageMenu = () => {
async function getHomepagePatternsData() {
const homepagePatternData = await getPatterns( currentStep.patternId );
if ( homepagePatternData?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}

setHomepagePattern( refactorPatterns( homepagePatternData ) );
Expand Down
6 changes: 3 additions & 3 deletions src/OnboardingSPA/pages/Steps/DesignThemeStyles/Menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getGlobalStyles } from '../../../../utils/api/themes';
import {
VIEW_NAV_DESIGN,
THEME_STATUS_ACTIVE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
SIDEBAR_LEARN_MORE,
} from '../../../../../constants';
import { DesignStateHandler } from '../../../../components/StateHandlers';
Expand Down Expand Up @@ -69,11 +69,11 @@ const StepDesignThemeStylesMenu = () => {
true
);
if ( patternsResponse?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
const globalStylesResponse = await getGlobalStyles( true );
if ( globalStylesResponse?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
setPattern( patternsResponse?.body );
setGlobalStyles( globalStylesResponse?.body );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import CommonLayout from '../../../../components/Layouts/Common';
import {
VIEW_DESIGN_THEME_STYLES_PREVIEW,
THEME_STATUS_ACTIVE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
SIDEBAR_LEARN_MORE,
} from '../../../../../constants';
import { store as nfdOnboardingStore } from '../../../../store';
Expand Down Expand Up @@ -70,7 +70,7 @@ const StepDesignThemeStylesPreview = () => {
true
);
if ( patternsResponse?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
setPattern( patternsResponse?.body );
setIsLoaded( true );
Expand Down
4 changes: 2 additions & 2 deletions src/OnboardingSPA/pages/Steps/DesignTypography/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { store as nfdOnboardingStore } from '../../../store';
import CommonLayout from '../../../components/Layouts/Common';
import {
SIDEBAR_LEARN_MORE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
VIEW_DESIGN_TYPOGRAPHY,
THEME_STATUS_ACTIVE,
} from '../../../../constants';
Expand Down Expand Up @@ -45,7 +45,7 @@ const StepDesignTypography = () => {
true
);
if ( patternsResponse?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
setPattern( patternsResponse?.body );
setIsLoaded( true );
Expand Down
4 changes: 2 additions & 2 deletions src/OnboardingSPA/pages/Steps/SitePages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import HeadingWithSubHeading from '../../../components/HeadingWithSubHeading';
import { getPatterns } from '../../../utils/api/patterns';
import {
THEME_STATUS_ACTIVE,
THEME_STATUS_FAILURE,
THEME_STATUS_INIT,
SIDEBAR_LEARN_MORE,
VIEW_NAV_DESIGN,
} from '../../../../constants';
Expand Down Expand Up @@ -54,7 +54,7 @@ const StepSitePages = () => {
const getSitePages = async () => {
const sitePagesResponse = await getPatterns( currentStep.patternId );
if ( sitePagesResponse?.error ) {
return updateThemeStatus( THEME_STATUS_FAILURE );
return updateThemeStatus( THEME_STATUS_INIT );
}
if ( sitePagesResponse?.body ) {
setSitePages( sitePagesResponse.body );
Expand Down

0 comments on commit 7d1eff1

Please sign in to comment.