Skip to content

Commit

Permalink
Search dashboard: add scaffolding for Record Meter (#22497)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Herve <jeremy@jeremy.hu>
  • Loading branch information
bluefuton and jeherve authored Feb 3, 2022
1 parent ff4490a commit 1557a93
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Search Dashboard: add scaffolding for new record meter
2 changes: 1 addition & 1 deletion projects/packages/search/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"link-template": "https://github.com/Automattic/jetpack-search/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-master": "0.6.x-dev"
"dev-master": "0.7.x-dev"
},
"version-constants": {
"JETPACK_SEARCH_PKG__VERSION": "search.php"
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetpack-search",
"version": "0.6.1-alpha",
"version": "0.7.0-alpha",
"description": "Package for Jetpack Search products",
"main": "main.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/search/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Automattic\Jetpack\Search;

define( 'JETPACK_SEARCH_PKG__VERSION', '0.6.1-alpha' );
define( 'JETPACK_SEARCH_PKG__VERSION', '0.7.0-alpha' );
define( 'JETPACK_SEARCH_PKG__DIR', __DIR__ . '/' );
define( 'JETPACK_SEARCH_PKG__SLUG', 'search' );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Initial_State {
protected $connection_manager;

/**
* Search Moduel Control
* Search Module Control
*
* @var Module_Control
*/
Expand Down Expand Up @@ -81,6 +81,8 @@ public function get_initial_state() {
'search' => $this->module_control->is_active(),
'instant_search_enabled' => $this->module_control->is_instant_search_enabled(),
),
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
'features' => array_map( 'sanitize_text_field', explode( ',', $_GET['features'] ) ),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ModuleControl from 'components/module-control';
import MockedSearch from 'components/mocked-search';
import { STORE_ID } from 'store';
import NoticesList from 'components/global-notices';
import RecordMeter from 'components/record-meter';

import 'scss/rna-styles.scss';
import './style.scss';
Expand Down Expand Up @@ -169,6 +170,10 @@ export default function SearchDashboard() {
);
};

const isRecordMeterEnabled = useSelect( select =>
select( STORE_ID ).isFeatureEnabled( 'record-meter' )
);

return (
<div className="jp-search-dashboard-page">
{ isLoading && (
Expand All @@ -179,6 +184,7 @@ export default function SearchDashboard() {
{ renderHeader() }
{ renderMockedSearchInterface() }
{ renderModuleControl() }
{ isRecordMeterEnabled && <RecordMeter /> }
{ renderFooter() }
</Fragment>
) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* External dependencies
*/
import React from 'react';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import './style.scss';

/**
* Generate Record Meter showing how many records the user has indexed
*
* @returns {React.Component} RecordMeter React component
*/
export default function RecordMeter() {
return (
<div className="jp-search-record-meter jp-search-dashboard-wrap">
<div className="jp-search-dashboard-row">
<div className="jp-search-record-meter__title lg-col-span-8 md-col-span-6 sm-col-span-4">
<h2>{ __( 'Your search records', 'jetpack-search-pkg' ) }</h2>
</div>
<div className="lg-col-span-2 md-col-span-1 sm-col-span-0"></div>
</div>
</div>
);
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const features = ( state = [] ) => {
return state;
};

export default features;
2 changes: 2 additions & 0 deletions projects/packages/search/src/dashboard/store/reducer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import siteData from './site-data';
import userData from './user-data';
import jetpackSettings from './jetpack-settings';
import sitePlan from './site-plan';
import features from './feature';
import notices from 'components/global-notices/store/reducer';

const reducer = combineReducers( {
siteData,
jetpackSettings,
sitePlan,
userData,
features,
notices,
} );

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const featureSelectors = {
isFeatureEnabled: ( state, feature ) => {
return Array.isArray( state.features ) && state.features.includes( feature );
},
};

export default featureSelectors;
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import jetpackSettingSelectors from './jetpack-settings';
import sitePlanSelectors from './site-plan';
import userDataSelectors from './user-data';
import noticeSelectors from 'components/global-notices/store/selectors';
import featureSelectors from './feature';

const selectors = {
...siteDataSelectors,
...jetpackSettingSelectors,
...sitePlanSelectors,
...userDataSelectors,
...noticeSelectors,
...featureSelectors,
};

export default selectors;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

Updated package dependencies.
2 changes: 1 addition & 1 deletion projects/plugins/jetpack/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"automattic/jetpack-plugins-installer": "0.1.x-dev",
"automattic/jetpack-redirect": "1.7.x-dev",
"automattic/jetpack-roles": "1.4.x-dev",
"automattic/jetpack-search": "0.6.x-dev",
"automattic/jetpack-search": "0.7.x-dev",
"automattic/jetpack-status": "1.10.x-dev",
"automattic/jetpack-sync": "1.29.x-dev",
"automattic/jetpack-terms-of-service": "1.9.x-dev",
Expand Down
6 changes: 3 additions & 3 deletions projects/plugins/jetpack/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1557a93

Please sign in to comment.