orc-shared 1.5.0-dev.13 → 1.5.0-dev.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports.setRoute = exports.setHrefConfig = exports.setCurrentPrependPath = exports.setClosingTabHandlerActions = exports.removeTab = exports.mapHref = exports.SET_ROUTE = exports.SET_HREF_CONFIG = exports.SET_CURRENT_PREPEND_PATH = exports.SET_CLOSING_TAB_HANDLER_ACTIONS = exports.REMOVE_TAB = exports.MAP_HREF = void 0;
4
+ exports.setRoute = exports.setHrefConfig = exports.setCurrentPrependPath = exports.setClosingTabHandlerActions = exports.removeTab = exports.removeModuleTabs = exports.mapHref = exports.SET_ROUTE = exports.SET_HREF_CONFIG = exports.SET_CURRENT_PREPEND_PATH = exports.SET_CLOSING_TAB_HANDLER_ACTIONS = exports.REMOVE_TAB = exports.REMOVE_MODULE_TABS = exports.MAP_HREF = void 0;
5
5
  (function () {
6
6
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
7
7
  enterModule && enterModule(module);
@@ -57,6 +57,17 @@ var removeTab = function removeTab(module, path) {
57
57
  };
58
58
  };
59
59
  exports.removeTab = removeTab;
60
+ var REMOVE_MODULE_TABS = "REMOVE_MODULE_TABS";
61
+ exports.REMOVE_MODULE_TABS = REMOVE_MODULE_TABS;
62
+ var removeModuleTabs = function removeModuleTabs(module) {
63
+ return {
64
+ type: REMOVE_MODULE_TABS,
65
+ payload: {
66
+ module: module
67
+ }
68
+ };
69
+ };
70
+ exports.removeModuleTabs = removeModuleTabs;
60
71
  var SET_HREF_CONFIG = "SET_HREF_CONFIG";
61
72
  exports.SET_HREF_CONFIG = SET_HREF_CONFIG;
62
73
  var setHrefConfig = function setHrefConfig(prependPath, prependHref, otherConfigs) {
@@ -105,6 +116,8 @@ exports.setClosingTabHandlerActions = setClosingTabHandlerActions;
105
116
  reactHotLoader.register(mapHref, "mapHref", "/home/vsts/work/1/s/src/actions/navigation.js");
106
117
  reactHotLoader.register(REMOVE_TAB, "REMOVE_TAB", "/home/vsts/work/1/s/src/actions/navigation.js");
107
118
  reactHotLoader.register(removeTab, "removeTab", "/home/vsts/work/1/s/src/actions/navigation.js");
119
+ reactHotLoader.register(REMOVE_MODULE_TABS, "REMOVE_MODULE_TABS", "/home/vsts/work/1/s/src/actions/navigation.js");
120
+ reactHotLoader.register(removeModuleTabs, "removeModuleTabs", "/home/vsts/work/1/s/src/actions/navigation.js");
108
121
  reactHotLoader.register(SET_HREF_CONFIG, "SET_HREF_CONFIG", "/home/vsts/work/1/s/src/actions/navigation.js");
109
122
  reactHotLoader.register(setHrefConfig, "setHrefConfig", "/home/vsts/work/1/s/src/actions/navigation.js");
110
123
  reactHotLoader.register(SET_CURRENT_PREPEND_PATH, "SET_CURRENT_PREPEND_PATH", "/home/vsts/work/1/s/src/actions/navigation.js");
@@ -129,6 +142,8 @@ exports.setClosingTabHandlerActions = setClosingTabHandlerActions;
129
142
  reactHotLoader.register(mapHref, "mapHref", "/home/vsts/work/1/s/src/actions/navigation.js");
130
143
  reactHotLoader.register(REMOVE_TAB, "REMOVE_TAB", "/home/vsts/work/1/s/src/actions/navigation.js");
131
144
  reactHotLoader.register(removeTab, "removeTab", "/home/vsts/work/1/s/src/actions/navigation.js");
145
+ reactHotLoader.register(REMOVE_MODULE_TABS, "REMOVE_MODULE_TABS", "/home/vsts/work/1/s/src/actions/navigation.js");
146
+ reactHotLoader.register(removeModuleTabs, "removeModuleTabs", "/home/vsts/work/1/s/src/actions/navigation.js");
132
147
  reactHotLoader.register(SET_HREF_CONFIG, "SET_HREF_CONFIG", "/home/vsts/work/1/s/src/actions/navigation.js");
133
148
  reactHotLoader.register(setHrefConfig, "setHrefConfig", "/home/vsts/work/1/s/src/actions/navigation.js");
134
149
  reactHotLoader.register(SET_CURRENT_PREPEND_PATH, "SET_CURRENT_PREPEND_PATH", "/home/vsts/work/1/s/src/actions/navigation.js");
@@ -5,7 +5,7 @@ exports.default = void 0;
5
5
  var _react = _interopRequireWildcard(require("react"));
6
6
  var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
7
7
  var _propertyValidator = require("../../../utils/propertyValidator");
8
- var _excluded = ["titleValue", "alwaysDisplay"];
8
+ var _excluded = ["titleValue", "alwaysDisplay", "tooltipClasses"];
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
11
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -39,6 +39,7 @@ var withDeferredTooltip = function withDeferredTooltip(Comp) {
39
39
  return __signature__(__signature__(function (_ref) {
40
40
  var titleValue = _ref.titleValue,
41
41
  alwaysDisplay = _ref.alwaysDisplay,
42
+ tooltipClasses = _ref.tooltipClasses,
42
43
  props = _objectWithoutProperties(_ref, _excluded);
43
44
  var _useState = (0, _react.useState)(false),
44
45
  _useState2 = _slicedToArray(_useState, 2),
@@ -62,6 +63,7 @@ var withDeferredTooltip = function withDeferredTooltip(Comp) {
62
63
  if (shouldBeTooltipped === false) return defaultComponent;
63
64
  return /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
64
65
  arrow: true,
66
+ classes: tooltipClasses != null ? tooltipClasses : null,
65
67
  title: titleValue,
66
68
  disableHoverListener: false,
67
69
  disableFocusListener: true,
@@ -83,6 +83,22 @@ var navigationReducer = function navigationReducer(state, action) {
83
83
  s.deleteIn(["tabIndex", remainingSection]);
84
84
  }
85
85
  });
86
+ case _navigation.REMOVE_MODULE_TABS:
87
+ return state.withMutations(function (s) {
88
+ var module = action.payload.module;
89
+ s.deleteIn(["moduleTabs", module]);
90
+ s.deleteIn(["closingTabsHandlerActions", module]);
91
+ s.get("tabIndex").keySeq().forEach(function (key) {
92
+ if (key.startsWith(module)) {
93
+ s.deleteIn(["tabIndex", key]);
94
+ }
95
+ });
96
+ s.get("mappedHrefs").keySeq().forEach(function (key) {
97
+ if (key.startsWith(module)) {
98
+ s.deleteIn(["mappedHrefs", key]);
99
+ }
100
+ });
101
+ });
86
102
  case _navigation.SET_HREF_CONFIG:
87
103
  return state.set("config", _immutable.default.fromJS(action.payload));
88
104
  case _navigation.SET_CURRENT_PREPEND_PATH:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orc-shared",
3
- "version": "1.5.0-dev.13",
3
+ "version": "1.5.0-dev.15",
4
4
  "description": "Shared code for Orckestra applications",
5
5
  "main": "./src/index.js",
6
6
  "exports": {
@@ -25,6 +25,13 @@ export const removeTab = (module, path) => ({
25
25
  payload: { module, path },
26
26
  });
27
27
 
28
+ export const REMOVE_MODULE_TABS = "REMOVE_MODULE_TABS";
29
+
30
+ export const removeModuleTabs = module => ({
31
+ type: REMOVE_MODULE_TABS,
32
+ payload: { module },
33
+ });
34
+
28
35
  export const SET_HREF_CONFIG = "SET_HREF_CONFIG";
29
36
 
30
37
  export const setHrefConfig = (prependPath, prependHref, otherConfigs = {}) => ({
@@ -5,6 +5,8 @@ import {
5
5
  SET_HREF_CONFIG,
6
6
  setClosingTabHandlerActions,
7
7
  SET_CLOSING_TAB_HANDLER_ACTIONS,
8
+ removeModuleTabs,
9
+ REMOVE_MODULE_TABS,
8
10
  } from "./navigation";
9
11
 
10
12
  describe("removeTab", () => {
@@ -18,6 +20,16 @@ describe("removeTab", () => {
18
20
  }));
19
21
  });
20
22
 
23
+ describe("removeModuleTabs", () => {
24
+ it("creates a remove module tabs action", () =>
25
+ expect(removeModuleTabs, "when called with", ["module"], "to equal", {
26
+ type: REMOVE_MODULE_TABS,
27
+ payload: {
28
+ module: "module",
29
+ },
30
+ }));
31
+ });
32
+
21
33
  describe("setHrefConfig", () => {
22
34
  it("set href config action", () =>
23
35
  expect(setHrefConfig, "when called with", ["/:scope/", "/scope/"], "to equal", {
@@ -8,7 +8,7 @@ import { isString, isObject, isStringNullOrWhitespace, isReactComponent } from "
8
8
 
9
9
  const withDeferredTooltip =
10
10
  Comp =>
11
- ({ titleValue, alwaysDisplay, ...props }) => {
11
+ ({ titleValue, alwaysDisplay, tooltipClasses, ...props }) => {
12
12
  const [shouldBeTooltipped, setShouldBeTooltipped] = useState(false);
13
13
 
14
14
  const defaultComponent = <Comp onMouseEnter={event => makeComponentTooltipped(event)} {...props} />;
@@ -32,6 +32,7 @@ const withDeferredTooltip =
32
32
  return (
33
33
  <MuiTooltip
34
34
  arrow
35
+ classes={tooltipClasses ?? null}
35
36
  title={titleValue}
36
37
  disableHoverListener={false}
37
38
  disableFocusListener={true}
@@ -155,4 +155,56 @@ describe("withDeferredTooltip", () => {
155
155
 
156
156
  expect(wrapper.prop("onMouseEnter"), "to be", undefined);
157
157
  });
158
+
159
+ it("Always displays passed title in tooltip with tooltip classes when specified", () => {
160
+ const Wrapper = props => <ComponentToBeTooltipped {...props} />;
161
+
162
+ const TooltippedCompponent = withDeferredTooltip(Wrapper);
163
+
164
+ const mountedTooltippedComponent = shallow(
165
+ <TooltippedCompponent alwaysDisplay titleValue="test" tooltipClasses={{ classTest: "testMyMojo" }} />,
166
+ );
167
+
168
+ const event = {
169
+ target: {
170
+ offsetWidth: 100,
171
+ scrollWidth: 100,
172
+ },
173
+ };
174
+
175
+ mountedTooltippedComponent.find(Wrapper).invoke("onMouseEnter")(event);
176
+
177
+ let expected = (
178
+ <MuiTooltip title="test" classes={{ classTest: "testMyMojo" }}>
179
+ <Wrapper />
180
+ </MuiTooltip>
181
+ );
182
+
183
+ expect(mountedTooltippedComponent.containsMatchingElement(expected), "to be true");
184
+ });
185
+
186
+ it("Always displays passed title in tooltip without tooltip classes when not specified", () => {
187
+ const Wrapper = props => <ComponentToBeTooltipped {...props} />;
188
+
189
+ const TooltippedCompponent = withDeferredTooltip(Wrapper);
190
+
191
+ const mountedTooltippedComponent = shallow(<TooltippedCompponent alwaysDisplay titleValue="test" />);
192
+
193
+ const event = {
194
+ target: {
195
+ offsetWidth: 100,
196
+ scrollWidth: 100,
197
+ },
198
+ };
199
+
200
+ mountedTooltippedComponent.find(Wrapper).invoke("onMouseEnter")(event);
201
+
202
+ let expected = (
203
+ <MuiTooltip title="test" classes={null}>
204
+ <Wrapper />
205
+ </MuiTooltip>
206
+ );
207
+
208
+ expect(mountedTooltippedComponent.containsMatchingElement(expected), "to be true");
209
+ });
158
210
  });
@@ -6,6 +6,7 @@ import {
6
6
  SET_HREF_CONFIG,
7
7
  SET_CURRENT_PREPEND_PATH,
8
8
  SET_CLOSING_TAB_HANDLER_ACTIONS,
9
+ REMOVE_MODULE_TABS,
9
10
  } from "../actions/navigation";
10
11
  import { getAllAfterPrependHref } from "../utils/parseHelper";
11
12
  import { APPLICATION_SCOPE_HAS_CHANGED } from "../actions/scopes";
@@ -73,6 +74,29 @@ const navigationReducer = (state = initialState, action) => {
73
74
  s.deleteIn(["tabIndex", remainingSection]);
74
75
  }
75
76
  });
77
+ case REMOVE_MODULE_TABS:
78
+ return state.withMutations(s => {
79
+ const { module } = action.payload;
80
+
81
+ s.deleteIn(["moduleTabs", module]);
82
+ s.deleteIn(["closingTabsHandlerActions", module]);
83
+
84
+ s.get("tabIndex")
85
+ .keySeq()
86
+ .forEach(key => {
87
+ if (key.startsWith(module)) {
88
+ s.deleteIn(["tabIndex", key]);
89
+ }
90
+ });
91
+
92
+ s.get("mappedHrefs")
93
+ .keySeq()
94
+ .forEach(key => {
95
+ if (key.startsWith(module)) {
96
+ s.deleteIn(["mappedHrefs", key]);
97
+ }
98
+ });
99
+ });
76
100
  case SET_HREF_CONFIG:
77
101
  return state.set("config", Immutable.fromJS(action.payload));
78
102
  case SET_CURRENT_PREPEND_PATH:
@@ -6,6 +6,7 @@ import {
6
6
  setHrefConfig,
7
7
  setCurrentPrependPath,
8
8
  setClosingTabHandlerActions,
9
+ removeModuleTabs,
9
10
  } from "../actions/navigation";
10
11
  import reducer from "./navigation";
11
12
  import { applicationScopeHasChanged } from "../actions/scopes";
@@ -295,6 +296,43 @@ describe("Navigation reducer", () => {
295
296
  });
296
297
  });
297
298
 
299
+ describe("REMOVE_MODULE_TABS", () => {
300
+ it("can remove module tabs", () => {
301
+ const oldState = Immutable.fromJS({
302
+ moduleTabs: { test: ["test/new", "test/old"], another: [1, 2, 3] },
303
+ closingTabsHandlerActions: { test: [0, 1, 2], another: [] },
304
+ tabIndex: { "test/old": {}, "test/new": {}, test: {}, another: {} },
305
+ mappedHrefs: { "test/old": {}, "test/new": {}, test: {}, another2: {} },
306
+ config: { prependPath: "/:scope/" },
307
+ });
308
+ const action = removeModuleTabs("test");
309
+ const newState = reducer(oldState, action);
310
+ return expect(newState, "not to be", oldState).and(
311
+ "to equal",
312
+ Immutable.fromJS({
313
+ moduleTabs: { another: [1, 2, 3] },
314
+ closingTabsHandlerActions: { another: [] },
315
+ tabIndex: { another: {} },
316
+ mappedHrefs: { another2: {} },
317
+ config: { prependPath: "/:scope/" },
318
+ }),
319
+ );
320
+ });
321
+
322
+ it("does nothing if the module to remove is not found", () => {
323
+ const oldState = Immutable.fromJS({
324
+ moduleTabs: { test: ["test/new", "test/old"], another: [1, 2, 3] },
325
+ closingTabsHandlerActions: { test: [0, 1, 2], another: [] },
326
+ tabIndex: { "test/old": {}, "test/new": {}, test: {}, another: {} },
327
+ mappedHrefs: { "test/old": {}, "test/new": {}, test: {}, another2: {} },
328
+ config: { prependPath: "/:scope/" },
329
+ });
330
+ const action = removeModuleTabs("unknown");
331
+ const newState = reducer(oldState, action);
332
+ return expect(newState, "to be", oldState);
333
+ });
334
+ });
335
+
298
336
  describe("SET_HREF_CONFIG", () => {
299
337
  it("update href config in navigation state", () => {
300
338
  const oldState = Immutable.fromJS({