Skip to content

Commit

Permalink
Added building and access via webapp to the Storybook design inventor…
Browse files Browse the repository at this point in the history
…y (Part 2)

Now do the redirect in App.jsx.
New https requests will be intercepted before they get to the React Router, and the DOM window.location.hrf and if pointed at /storybook will be reset to the desired /storybook/index.html

Works fine locally (as did the prior approach), we will see how it does on the production servers.

Implements https://wevoteusa.atlassian.net/browse/WV-206
  • Loading branch information
SailingSteve committed Feb 16, 2024
1 parent 13284df commit 7f1f25e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
File renamed without changes.
8 changes: 6 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { isCordova, isWebApp } from './js/common/utils/isCordovaOrWebApp';
import { renderLog } from './js/common/utils/logging';
import Header from './js/components/Navigation/Header';
import HeaderBarSuspense from './js/components/Navigation/HeaderBarSuspense';
import StorybookRedirect from './js/components/Widgets/StorybookRedirect';
import webAppConfig from './js/config';
import VoterStore from './js/stores/VoterStore';
import initializeFacebookSDK from './js/utils/initializeFacebookSDK';
Expand Down Expand Up @@ -363,6 +362,12 @@ class App extends Component {
The props.match.path shows exactly which route string from this file, was selected by the <Switch>
*/

if (window.location.href.endsWith('/storybook')) {
const destinationHref = `${window.location.href}-static/index.html?path=/docs/design-system--docs`;
console.log('Storybook redirect from: ', window.location.href, ' to: ', destinationHref);
window.location.href = destinationHref;
}

return (
<>
{enableFullStory && <FullStory org={webAppConfig.FULL_STORY_ORG} />}
Expand Down Expand Up @@ -551,7 +556,6 @@ class App extends Component {
<Route path="/sign_in_email/:email_secret_key" component={SignInEmailProcess} />
<Route path="/setupaccount/:set_up_page" exact component={SetUpAccountRoot} />
<Route path="/setupaccount" exact><SetUpAccountRoot /></Route>
<Route path="/storybook"><StorybookRedirect /></Route>
<Route path="/squads" exact><Squads /></Route>
<Route exact path="/start-a-campaign"><CampaignStartIntro /></Route>
<Route path="/terms" component={TermsOfService} />
Expand Down
12 changes: 0 additions & 12 deletions src/js/components/Widgets/StorybookRedirect.jsx

This file was deleted.

3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ module.exports = (env, argv) => ({
to: 'img/',
globOptions: { ignore: ['**/DO-NOT-BUNDLE/**']},
},
{ from: 'storybook-static', to: './storybook' },
{ from: 'node/STORYBOOK-README.TXT', to: './storybook-static/STORYBOOK-README.TXT' },
{ from: 'storybook-static', to: './storybook-static' },
],
}),
new MomentLocalesPlugin(),
Expand Down

0 comments on commit 7f1f25e

Please sign in to comment.