From 2dcde13ff4b46378f339159ef2906b0d20fa72c6 Mon Sep 17 00:00:00 2001 From: Suren Date: Fri, 19 Jan 2024 20:17:55 +0530 Subject: [PATCH] #9889: Fix - Unable to export map configuration in context manager (#9896) (#9898) * #9889: Fix - Unable to export map configuration in context manager * Control added to constant (cherry picked from commit b3ffd90bdb0914e43dcdfbefa11acb2f4a748cea) --- web/client/components/contextcreator/ContextCreator.jsx | 4 +--- web/client/epics/__tests__/contextcreator-test.js | 3 ++- web/client/epics/contextcreator.js | 3 ++- web/client/plugins/ContextExport.jsx | 8 +++++--- web/client/plugins/__tests__/ContextExport-test.jsx | 3 ++- web/client/utils/ControlUtils.js | 2 ++ 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/web/client/components/contextcreator/ContextCreator.jsx b/web/client/components/contextcreator/ContextCreator.jsx index 2a0dce3be5..f3c92fa151 100644 --- a/web/client/components/contextcreator/ContextCreator.jsx +++ b/web/client/components/contextcreator/ContextCreator.jsx @@ -245,9 +245,7 @@ export default class ContextCreator extends React.Component { editingAllowedRoles: [] } } - }, - "ContextImport", - "ContextExport" + } ], ignoreViewerPlugins: false, allAvailablePlugins: [], diff --git a/web/client/epics/__tests__/contextcreator-test.js b/web/client/epics/__tests__/contextcreator-test.js index 8b2ab5589a..e464c78b6a 100644 --- a/web/client/epics/__tests__/contextcreator-test.js +++ b/web/client/epics/__tests__/contextcreator-test.js @@ -69,6 +69,7 @@ import { import axios from "../../libs/ajax"; import MockAdapter from "axios-mock-adapter"; import {TOGGLE_CONTROL} from "../../actions/controls"; +import { EXPORT_CONTEXT } from '../../utils/ControlUtils'; describe('contextcreator epics', () => { let mockAxios; @@ -965,7 +966,7 @@ describe('contextcreator epics', () => { it('exportContextEpic, export context with plugins and themes', (done) => { testEpic(exportContextEpic, 1, onContextExport('file.json'), ([a]) => { expect(a.type).toEqual(TOGGLE_CONTROL); - expect(a.control).toEqual("export"); + expect(a.control).toEqual(EXPORT_CONTEXT); done(); }, { map: { diff --git a/web/client/epics/contextcreator.js b/web/client/epics/contextcreator.js index 2d975f6a53..d2ae4b21d1 100644 --- a/web/client/epics/contextcreator.js +++ b/web/client/epics/contextcreator.js @@ -41,6 +41,7 @@ import { upload, uninstall } from '../api/plugins'; import { download, readJson } from "../utils/FileUtils"; import { toggleControl } from "../actions/controls"; import { mapSelector } from "../selectors/map"; +import { EXPORT_CONTEXT } from '../utils/ControlUtils'; const saveContextErrorStatusToMessage = (status) => { switch (status) { @@ -922,7 +923,7 @@ export const exportContextEpic = (action$, { getState }) => "application/json" ]) .do((downloadArgs) => download(...downloadArgs)) - .map(() => toggleControl("export")) + .map(() => toggleControl(EXPORT_CONTEXT)) .catch(() => Rx.Observable.of( error({ diff --git a/web/client/plugins/ContextExport.jsx b/web/client/plugins/ContextExport.jsx index c579591058..d463691219 100644 --- a/web/client/plugins/ContextExport.jsx +++ b/web/client/plugins/ContextExport.jsx @@ -20,7 +20,9 @@ import { onContextExport } from "../actions/contextcreator"; import { toggleControl } from "../actions/controls"; import Message from "../components/I18N/Message"; import Button from "../components/misc/Button"; -const isEnabled = createControlEnabledSelector("export"); +import { EXPORT_CONTEXT } from "../utils/ControlUtils"; + +const isEnabled = createControlEnabledSelector(EXPORT_CONTEXT); const mapStateToProps = createSelector( isEnabled, @@ -32,7 +34,7 @@ const mapStateToProps = createSelector( ); const actions = { - onClose: () => toggleControl("export"), + onClose: () => toggleControl(EXPORT_CONTEXT), onExport: onContextExport }; @@ -58,7 +60,7 @@ const ExportComponent = connect(mapStateToProps, actions)(Component); const ExportButton = connect( createSelector(resourceSelector, (resource) => ({ resource })), { - onExport: () => toggleControl("export") + onExport: () => toggleControl(EXPORT_CONTEXT) } )(({ resource, onExport }) => (