Skip to content

Commit

Permalink
Themes: Retain filters and query string when activating (Automattic#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham authored May 1, 2017
1 parent c0194f0 commit da71c76
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion client/my-sites/theme/controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export function details( context, next ) {
}

context.primary = <ThemeSheetComponent id={ slug }
section={ section } />;
section={ section }
pathName={ context.pathname } />;
context.secondary = null; // When we're logged in, we need to remove the sidebar.
next();
}
Expand Down
3 changes: 1 addition & 2 deletions client/my-sites/theme/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,7 @@ const ConnectedThemeSheet = connectOptions(
}

return (
<ThemesSiteSelectorModal { ...props }
sourcePath={ `/theme/${ props.id }${ props.section ? '/' + props.section : '' }` }>
<ThemesSiteSelectorModal { ...props }>
<ThemeSheet />
</ThemesSiteSelectorModal>
);
Expand Down
2 changes: 1 addition & 1 deletion client/my-sites/themes/multi-site.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const MultiSiteThemeShowcase = connectOptions(
( props ) => (
<div>
<SidebarNavigation />
<ThemesSiteSelectorModal { ...props } sourcePath="/themes">
<ThemesSiteSelectorModal { ...props }>
<ThemeShowcase
source="showcase"
showUploadButton={ false } />
Expand Down
10 changes: 8 additions & 2 deletions client/my-sites/themes/themes-site-selector-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ThemesSiteSelectorModal = React.createClass( {
defaultOption: OPTION_SHAPE,
secondaryOption: OPTION_SHAPE,
// Will be prepended to site slug for a redirect on selection
sourcePath: PropTypes.string.isRequired,
pathName: PropTypes.string.isRequired,
},

getInitialState() {
Expand All @@ -43,9 +43,15 @@ const ThemesSiteSelectorModal = React.createClass( {
trackAndCallAction( site ) {
const action = this.state.selectedOption.action;
const themeId = this.state.selectedThemeId;
const { search } = this.props;

let redirectTarget = this.props.pathName + '/' + site.slug;
if ( search ) {
redirectTarget += '?s=' + search;
}

trackClick( 'site selector', this.props.name );
page( this.props.sourcePath + '/' + site.slug );
page( redirectTarget );

/**
* Since this implies a route change, defer it in case other state
Expand Down

0 comments on commit da71c76

Please sign in to comment.