Skip to content

Commit

Permalink
fixes red screen on topic click and fixes reload on permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmullen authored and davelandry committed Jul 2, 2019
1 parent 2b99ad5 commit 77beaff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
9 changes: 0 additions & 9 deletions packages/cms/app/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ export default function RouteCreate() {
return (
<Route path="/" component={App} history={browserHistory}>
<IndexRoute component={Builder} />
<Route path="/:pid/:tid" component={Builder} />
<Route path="/:pid" component={Builder} />

{/*
<Route path="/cms-profile/:profileSlug" component={Builder} />
<Route path="/cms-profile/:profileSlug/:topicSlug" component={Builder} />
<Route path="/cms-story/:storySlug" component={Builder} />
<Route path="/cms-story/:storySlug/:storytopicSlug" component={Builder} />
*/}
<Route path="/profile/:slug/:id" component={Profile} />
<Route path="/profile/:slug/:id/:slug2/:id2" component={Profile} />
<Route path="/profile/:slug/:id/:slug2/:id2/:slug3/:id3" component={Profile} />
Expand Down
10 changes: 5 additions & 5 deletions packages/cms/src/Builder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class Builder extends Component {
}

componentDidMount() {
const {isEnabled, env, params} = this.props;
const {pid, tid} = params;
const {isEnabled, env, location} = this.props;
const {pid, tid} = location.query;
// The CMS is only accessible on localhost/dev. Redirect the user to root otherwise.
if (!isEnabled && typeof window !== "undefined" && window.location.pathname !== "/") window.location = "/";
const pathObj = {
Expand Down Expand Up @@ -85,9 +85,9 @@ class Builder extends Component {
const diffTopic = String(pathObj.topic) !== String(this.state.pathObj.topic);
if (diffProfile || diffTopic) {
const {router} = this.props;
let url = `/${pathObj.profile}`;
if (pathObj.topic) url += `/${pathObj.topic}`;
// router.replace(url);
let url = `?profile=${pathObj.profile}`;
if (pathObj.topic) url += `&topic=${pathObj.topic}`;
router.replace(url);
this.setState({pathObj});
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cms/src/profile/ProfileBuilder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ class ProfileBuilder extends Component {
const {localeDefault} = this.props;
const formatters = this.context.formatters[localeDefault];
const {stripHTML} = formatters;
const variables = variablesHash[currentPid] && variablesHash[currentPid][localeDefault] ? deepClone(variablesHash[currentPid][localeDefault]) : null;
const variables = variablesHash[currentPid] && variablesHash[currentPid][localeDefault] ? deepClone(variablesHash[currentPid][localeDefault]) : {};
str = this.decode(stripHTML(str));
str = varSwapRecursive({str, selectors}, formatters, variables, query).str;
return str;
Expand Down

0 comments on commit 77beaff

Please sign in to comment.