Skip to content

Commit a4ae0de

Browse files
author
Ives van Hoorne
committed
Add condition
1 parent 6d6b1c0 commit a4ae0de

File tree

6 files changed

+39
-6
lines changed

6 files changed

+39
-6
lines changed

src/app/containers/Preferences/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ const ContentContainer = styled.div`
3535

3636
type Props = {
3737
user: CurrentUser,
38+
integrationsEnabled: boolean,
3839
};
3940

4041
const mapStateToProps = state => ({
4142
user: currentUserSelector(state),
43+
integrationsEnabled: state.features.integrations,
4244
});
4345
class Preferences extends React.PureComponent {
4446
props: Props;
@@ -70,7 +72,8 @@ class Preferences extends React.PureComponent {
7072
icon: <BrowserIcon />,
7173
content: <PreviewSettings />,
7274
},
73-
signedIn && {
75+
signedIn &&
76+
this.props.integrationsEnabled && {
7477
title: 'Integrations',
7578
icon: <IntegrationIcon />,
7679
content: <Integrations />,

src/app/pages/Sandbox/Editor/Content/Header/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ type Props = {
9999
modalActions: typeof modalActionCreators,
100100
user: CurrentUser,
101101
canSave: boolean,
102+
integrationsEnabled: boolean,
102103
};
103104

104105
export default class Header extends React.PureComponent<Props> {
@@ -230,7 +231,8 @@ export default class Header extends React.PureComponent<Props> {
230231
/>
231232
<Action title="Download" Icon={Download} onClick={this.zipSandbox} />
232233
{user.jwt &&
233-
sandbox.owned && (
234+
sandbox.owned &&
235+
this.props.integrationsEnabled && (
234236
<Action
235237
title="Deploy"
236238
Icon={NowIcon}

src/app/pages/Sandbox/Editor/Content/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ type Props = {
5353
userActions: typeof userActionCreators,
5454
modalActions: typeof modalActionCreators,
5555
previewApiActions: typeof previewApiActionCreators,
56+
integrationsEnabled: boolean,
5657
};
5758

5859
type State = {
@@ -71,11 +72,13 @@ const mapStateToProps = createSelector(
7172
currentUserSelector,
7273
modulesFromSandboxSelector,
7374
directoriesFromSandboxSelector,
74-
(preferences, user, modules, directories) => ({
75+
state => state.features.integrations,
76+
(preferences, user, modules, directories, integrationsEnabled) => ({
7577
preferences,
7678
user,
7779
modules,
7880
directories,
81+
integrationsEnabled,
7982
})
8083
);
8184
const mapDispatchToProps = dispatch => ({
@@ -224,6 +227,7 @@ class EditorPreview extends React.PureComponent<Props, State> {
224227
workspaceHidden={workspaceHidden}
225228
toggleWorkspace={toggleWorkspace}
226229
canSave={notSynced}
230+
integrationsEnabled={this.props.integrationsEnabled}
227231
/>
228232
<SplitPane
229233
onDragStarted={this.startResizing}

src/app/store/features/reducer.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// @flow
2+
3+
type State = {
4+
integrations: boolean,
5+
};
6+
7+
const initialState = {
8+
integrations: false,
9+
};
10+
11+
export default function reducer(
12+
state: State = initialState,
13+
action: Object
14+
): State {
15+
switch (action.type) {
16+
case 'ENABLE_INTEGRATIONS':
17+
return {
18+
...state,
19+
integrations: true,
20+
};
21+
default:
22+
return state;
23+
}
24+
}

src/app/store/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export default history => {
2222
composeEnhancers(applyMiddleware(thunk, routerMiddleware(history)))
2323
);
2424

25-
if (process.env.NODE_ENV === 'development') {
26-
window.store = store;
27-
}
25+
window.store = store;
2826

2927
return store;
3028
};

src/app/store/root-reducer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import notificationsReducer from './notifications/reducer';
99
import preferencesReducer from './preferences/reducer';
1010
import userReducer from './user/reducer';
1111
import connectionStatusReducer from './connection/reducer';
12+
import featuresReducer from './features/reducer';
1213

1314
export default combineReducers({
1415
entities: entityReducer,
1516
contextMenu: contextMenuReducer,
1617
connectionStatus: connectionStatusReducer,
18+
features: featuresReducer,
1719
modal: modalReducer,
1820
notifications: notificationsReducer,
1921
preferences: preferencesReducer,

0 commit comments

Comments
 (0)