Skip to content

Commit

Permalink
Show a progress bar while determining which SetupBanner variant to show.
Browse files Browse the repository at this point in the history
  • Loading branch information
techanvil committed Sep 5, 2022
1 parent 551ae68 commit c6db855
Showing 1 changed file with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ import { useTooltipState } from '../../../../../components/AdminMenuTooltip/useT
import { useShowTooltip } from '../../../../../components/AdminMenuTooltip/useShowTooltip';
import { AdminMenuTooltip } from '../../../../../components/AdminMenuTooltip/AdminMenuTooltip';
import { getBannerDismissalExpiryTime } from '../../../utils/banner-dismissal-expiry';
import { Cell, Grid, Row } from '../../../../../material-components';
import ProgressBar from '../../../../../components/ProgressBar';
const { useDispatch, useSelect } = Data;

export default function SetupBanner( { onSubmitSuccess } ) {
Expand All @@ -56,9 +58,27 @@ export default function SetupBanner( { onSubmitSuccess } ) {

const hasExistingProperty = useSelect( ( select ) => {
const accountID = select( MODULES_ANALYTICS ).getAccountID();

const properties =
select( MODULES_ANALYTICS_4 ).getProperties( accountID ) || [];
return properties.length > 0;
select( MODULES_ANALYTICS_4 ).getProperties( accountID );

if ( properties === undefined ) {
return undefined;
}

if ( properties.length === 0 ) {
return false;
}

// Make a call here to ensure getAccounts is resolved before rendering the PropertySelect
// component, to avoid showing a ProgressBar in the PropertySelect.
const accounts = select( MODULES_ANALYTICS ).getAccounts();

if ( accounts === undefined ) {
return undefined;
}

return true;
} );
const existingTag = useSelect( ( select ) =>
select( MODULES_ANALYTICS_4 ).getExistingTag()
Expand Down Expand Up @@ -94,6 +114,18 @@ export default function SetupBanner( { onSubmitSuccess } ) {
ACTIVATION_ACKNOWLEDGEMENT_TOOLTIP_STATE_KEY
);

if ( hasExistingProperty === undefined ) {
return (
<Grid>
<Row>
<Cell>
<ProgressBar />
</Cell>
</Row>
</Grid>
);
}

if ( isTooltipVisible ) {
return (
<Fragment>
Expand Down

0 comments on commit c6db855

Please sign in to comment.