Skip to content

Commit 9d53cde

Browse files
committed
Set experimental property in ui if url parameter passed
1 parent 2728dcf commit 9d53cde

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/actions/applicationLoaded.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import {createAction} from 'redux-actions';
22

33
export default createAction(
44
'APPLICATION_LOADED',
5-
(gistId = null) => ({gistId}),
5+
(gistId = null, isExperimental = false) => ({gistId, isExperimental}),
66
);

src/components/Workspace.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,14 @@ class Workspace extends React.Component {
117117

118118
componentWillMount() {
119119
let gistId;
120+
let isExperimental = false;
120121
if (location.search) {
121122
const query = qs.parse(location.search.slice(1));
122123
gistId = query.gist;
124+
isExperimental = Object.keys(query).includes('experimental');
123125
}
124126
history.replaceState({}, '', location.pathname);
125-
this.props.dispatch(applicationLoaded(gistId));
127+
this.props.dispatch(applicationLoaded(gistId, isExperimental));
126128
this._listenForAuthChange();
127129
startSessionHeartbeat();
128130
}

src/reducers/ui.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ export default function ui(stateIn, action) {
165165
case 'REFRESH_PREVIEW':
166166
return state.set('lastRefreshTimestamp', action.payload.timestamp);
167167

168+
case 'APPLICATION_LOADED':
169+
if (action.payload.isExperimental) {
170+
return state.set('experimental', true);
171+
}
172+
return state.set('experimental', false);
173+
168174
default:
169175
return state;
170176
}

test/unit/reducers/ui.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from '../../../src/actions/clients';
2626
import {EmptyGistError} from '../../../src/clients/gists';
2727
import {userLoggedOut} from '../../../src/actions/user';
28+
import {applicationLoaded} from '../../../src/actions/';
2829

2930
const initialState = Immutable.fromJS({
3031
editors: {
@@ -246,3 +247,19 @@ test('refreshPreview', reducerTest(
246247
partial(refreshPreview, 1),
247248
initialState.set('lastRefreshTimestamp', 1),
248249
));
250+
251+
test('applicationLoaded', (t) => {
252+
t.test('isExperimental = true', reducerTest(
253+
reducer,
254+
initialState,
255+
partial(applicationLoaded, null, true),
256+
initialState.set('experimental', true),
257+
));
258+
259+
t.test('isExperimental = false', reducerTest(
260+
reducer,
261+
initialState,
262+
partial(applicationLoaded, null, false),
263+
initialState.set('experimental', false),
264+
));
265+
});

0 commit comments

Comments
 (0)