Skip to content

Commit

Permalink
Fix #3682 request to printUrl (#3683)
Browse files Browse the repository at this point in the history
* Fix #3682 request to printUrl

* add test for printingEnabled False

* clean up main.js code
  • Loading branch information
MV88 authored Apr 9, 2019
1 parent 19ddd55 commit 716b6c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion web/client/components/misc/toolbar/ToolbarButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const React = require('react');
const {compose} = require('recompose');
const Message = require('../../I18N/Message');
const { omit } = require('lodash');

const {Button, Glyphicon} = require('react-bootstrap');
const Loader = require('../Loader');
Expand All @@ -28,7 +29,7 @@ const popover = require('../enhancers/popover');
*/

module.exports = compose(tooltip, popover)(({ glyph, loading, text = "", textId, glyphClassName="", loaderProps = {}, ...props} = {}) =>
<Button {...props}>
<Button {...omit(props, ["pullRight"])}>
{glyph && !loading ? <Glyphicon glyph={glyph} className={glyphClassName}/> : null}
{textId ? <Message msgId={textId} /> : text}
{loading ? <Loader className={`ms-loader${props.bsStyle && ' ms-loader-' + props.bsStyle || ''}${props.bsSize && ' ms-loader-' + props.bsSize || ''}`} {...loaderProps}/> : null}
Expand Down
18 changes: 16 additions & 2 deletions web/client/product/__tests__/main-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const expect = require('expect');
const assign = require('object-assign');
const ConfigUtils = require('../../utils/ConfigUtils');

class AppComnponent extends React.Component {
class AppComponent extends React.Component {
render() {
return <div>TEST</div>;
}
Expand All @@ -39,10 +39,11 @@ describe('standard application runner', () => {
it('allows overriding appConfig', (done) => {
const overrideCfg = (config) => {
return assign({}, config, {
appComponent: AppComnponent,
appComponent: AppComponent,
onStoreInit: () => {
setTimeout(() => {
expect(document.body.innerHTML).toContain("TEST");
expect(config.printingEnabled).toBe(true);
done();
}, 0);
}
Expand All @@ -51,4 +52,17 @@ describe('standard application runner', () => {
mainApp({}, {plugins: {}}, overrideCfg);
});

it('check printingEnabled set to false', (done) => {
const overrideCfg = (config) => {
return assign({}, config, {
onStoreInit: () => {
setTimeout(() => {
expect(config.printingEnabled).toBe(false);
done();
}, 0);
}
});
};
mainApp({printingEnabled: false}, {plugins: {}}, overrideCfg);
});
});
4 changes: 2 additions & 2 deletions web/client/product/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = (config, pluginsDef, overrideConfig = cfg => cfg) => {
const {loadAfterThemeSelector} = require('../selectors/config');
const StandardApp = require('../components/app/StandardApp');

const {pages, initialState, storeOpts, appEpics = {}, themeCfg} = config;
const {pages, initialState, storeOpts, appEpics = {}, themeCfg, printingEnabled = true} = config;

const StandardRouter = connect((state) => ({
locale: state.locale || {},
Expand Down Expand Up @@ -52,7 +52,7 @@ module.exports = (config, pluginsDef, overrideConfig = cfg => cfg) => {
pluginsDef,
initialActions,
appComponent: StandardRouter,
printingEnabled: true,
printingEnabled,
themeCfg
});

Expand Down

0 comments on commit 716b6c7

Please sign in to comment.