Skip to content

Commit

Permalink
Widget Visibility: switch to using shared js package utility (#22741)
Browse files Browse the repository at this point in the history
In #22527, I copied over a utility function that we used in the block bundle to use in the Widget visibility bundle. However, starting in #22733, that utility function is now part of an external js package that we can use in the Widget visiblity bundle. Let's do that and save some duplication!
  • Loading branch information
jeherve authored Feb 8, 2022
1 parent 998e620 commit 2786f82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Widget Visibility: switch to using shared js package utility instead of built-in site type check.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
/**
* WordPress dependencies
* External dependencies
*/
import { Fragment, useCallback, useMemo } from '@wordpress/element';
import { BaseControl, Button, SelectControl, ToggleControl } from '@wordpress/components';
import { __, _x } from '@wordpress/i18n';
import { InspectorAdvancedControls } from '@wordpress/block-editor'; // eslint-disable-line import/no-unresolved
import { createHigherOrderComponent } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';
import { isSimpleSite } from '@automattic/jetpack-shared-extension-utils';

/**
* Internal dependencies
*/
import analytics from '../../../_inc/client/lib/analytics';

/* global widget_conditions_data */
Expand Down Expand Up @@ -124,17 +129,6 @@ const buildOptions = ( options, level = 0 ) =>
return acc.concat( [ newItem ] );
}, [] );

/**
* Get the site type.
*
* @return {string} - jetpack, atomic, or simple.
*/
const getSiteType = () => {
return 'object' === typeof window && typeof window._currentSiteType === 'string'
? window._currentSiteType
: 'jetpack';
};

const VisibilityRule = props => {
const { rule, onDelete, setMajor, setMinor } = props;

Expand All @@ -158,7 +152,7 @@ const VisibilityRule = props => {
{ label: __( 'Category', 'jetpack' ), value: 'category' },
{ label: __( 'Author', 'jetpack' ), value: 'author' },
]
.concat( 'simple' === getSiteType() ? [] : optionsDisabledOnWpcom )
.concat( isSimpleSite() ? [] : optionsDisabledOnWpcom )
.concat( [
{ label: __( 'Tag', 'jetpack' ), value: 'tag' },
{ label: __( 'Date', 'jetpack' ), value: 'date' },
Expand Down

0 comments on commit 2786f82

Please sign in to comment.