Skip to content

Commit

Permalink
#9889: Fix - Unable to export map configuration in context manager (#…
Browse files Browse the repository at this point in the history
…9896) (#9898)

* #9889: Fix - Unable to export map configuration in context manager

* Control added to constant

(cherry picked from commit b3ffd90)
  • Loading branch information
dsuren1 authored Jan 19, 2024
1 parent b1a7b8e commit 2dcde13
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
4 changes: 1 addition & 3 deletions web/client/components/contextcreator/ContextCreator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,7 @@ export default class ContextCreator extends React.Component {
editingAllowedRoles: []
}
}
},
"ContextImport",
"ContextExport"
}
],
ignoreViewerPlugins: false,
allAvailablePlugins: [],
Expand Down
3 changes: 2 additions & 1 deletion web/client/epics/__tests__/contextcreator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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: {
Expand Down
3 changes: 2 additions & 1 deletion web/client/epics/contextcreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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({
Expand Down
8 changes: 5 additions & 3 deletions web/client/plugins/ContextExport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -32,7 +34,7 @@ const mapStateToProps = createSelector(
);

const actions = {
onClose: () => toggleControl("export"),
onClose: () => toggleControl(EXPORT_CONTEXT),
onExport: onContextExport
};

Expand All @@ -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 }) => (
<Button
Expand Down
3 changes: 2 additions & 1 deletion web/client/plugins/__tests__/ContextExport-test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import expect from 'expect';
import { getPluginForTest } from './pluginsTestUtils';

import ContextExport from '../ContextExport';
import { EXPORT_CONTEXT } from '../../utils/ControlUtils';

describe('ContextExport plugin', () => {
beforeEach((done) => {
Expand All @@ -29,7 +30,7 @@ describe('ContextExport plugin', () => {
it('displays the export panel when enabled', () => {
const { Plugin } = getPluginForTest(ContextExport, {
controls: {
"export": {
[EXPORT_CONTEXT]: {
enabled: true
}
}
Expand Down
2 changes: 2 additions & 0 deletions web/client/utils/ControlUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {CHANGE_DRAWING_STATUS} from "../actions/draw";
import {REGISTER_EVENT_LISTENER} from "../actions/map";
import {OPEN_FEATURE_GRID} from "../actions/featuregrid";

export const EXPORT_CONTEXT = "export-context";

/**
* Common part of the workflow that toggles one plugin off when another plugin intend to perform drawing action
* @param action$
Expand Down

0 comments on commit 2dcde13

Please sign in to comment.