@beinformed/ui 1.56.0 → 1.57.0-contextpath.0
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.
- package/CHANGELOG.md +19 -0
- package/esm/constants/Settings.js +4 -1
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js +3 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +11 -1
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/hooks/useModularUIModel.js +36 -25
- package/esm/hooks/useModularUIModel.js.map +1 -1
- package/esm/models/actions/ActionCollection.js +2 -2
- package/esm/models/actions/ActionCollection.js.map +1 -1
- package/esm/models/actions/ActionModel.js +27 -8
- package/esm/models/actions/ActionModel.js.map +1 -1
- package/esm/models/application/ApplicationModel.js +1 -1
- package/esm/models/application/ApplicationModel.js.map +1 -1
- package/esm/models/base/ResourceModel.js +25 -3
- package/esm/models/base/ResourceModel.js.map +1 -1
- package/esm/models/caseview/CaseViewModel.js +2 -2
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.js +1 -0
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.js +2 -1
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/content/ContentIndexModel.js +2 -2
- package/esm/models/content/ContentIndexModel.js.map +1 -1
- package/esm/models/content/ContentLinkModel.js +2 -0
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/SectionModel.js +1 -0
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/detail/DetailModel.js +1 -1
- package/esm/models/detail/DetailModel.js.map +1 -1
- package/esm/models/error/ErrorResponse.js +2 -0
- package/esm/models/error/ErrorResponse.js.map +1 -1
- package/esm/models/form/FormModel.js +1 -1
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/href/Href.js +50 -3
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/href/ListHref.js +1 -1
- package/esm/models/href/ListHref.js.map +1 -1
- package/esm/models/links/LinkCollection.js +3 -1
- package/esm/models/links/LinkCollection.js.map +1 -1
- package/esm/models/links/LinkModel.js +10 -9
- package/esm/models/links/LinkModel.js.map +1 -1
- package/esm/models/list/ListItemModel.js +3 -1
- package/esm/models/list/ListItemModel.js.map +1 -1
- package/esm/models/list/ListModel.js +1 -1
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/panels/GroupingPanelModel.js +1 -1
- package/esm/models/panels/GroupingPanelModel.js.map +1 -1
- package/esm/models/tab/TabModel.js +2 -2
- package/esm/models/tab/TabModel.js.map +1 -1
- package/esm/models/taskgroup/TaskGroupModel.js +4 -2
- package/esm/models/taskgroup/TaskGroupModel.js.map +1 -1
- package/esm/modularui/Authenticate.js +2 -1
- package/esm/modularui/Authenticate.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +43 -7
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/modularui/ModularUIResponse.js +31 -0
- package/esm/modularui/ModularUIResponse.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +3 -1
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js +6 -0
- package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/actions/Application.js +2 -0
- package/esm/redux/actions/Application.js.map +1 -1
- package/esm/redux/connectors/PanelRenderer.js +2 -0
- package/esm/redux/connectors/PanelRenderer.js.map +1 -1
- package/esm/utils/fetch/types.js.map +1 -1
- package/esm/utils/helpers/checkResource.js +2 -0
- package/esm/utils/helpers/checkResource.js.map +1 -1
- package/lib/constants/Settings.js +4 -1
- package/lib/constants/Settings.js.flow +2 -2
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/useForm.js +3 -1
- package/lib/hooks/useForm.js.flow +2 -0
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +11 -1
- package/lib/hooks/useModularUIBasic.js.flow +14 -0
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/hooks/useModularUIModel.js +36 -24
- package/lib/hooks/useModularUIModel.js.flow +58 -11
- package/lib/hooks/useModularUIModel.js.map +1 -1
- package/lib/models/actions/ActionCollection.js +2 -2
- package/lib/models/actions/ActionCollection.js.flow +14 -2
- package/lib/models/actions/ActionCollection.js.map +1 -1
- package/lib/models/actions/ActionModel.js +31 -12
- package/lib/models/actions/ActionModel.js.flow +38 -16
- package/lib/models/actions/ActionModel.js.map +1 -1
- package/lib/models/application/ApplicationModel.js +1 -1
- package/lib/models/application/ApplicationModel.js.flow +7 -1
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/models/base/ResourceModel.js +24 -3
- package/lib/models/base/ResourceModel.js.flow +35 -10
- package/lib/models/base/ResourceModel.js.map +1 -1
- package/lib/models/caseview/CaseViewModel.js +2 -2
- package/lib/models/caseview/CaseViewModel.js.flow +3 -1
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js +1 -0
- package/lib/models/concepts/ConceptLinkModel.js.flow +1 -0
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js +2 -1
- package/lib/models/concepts/SourceReferenceModel.js.flow +2 -1
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentIndexModel.js +2 -2
- package/lib/models/content/ContentIndexModel.js.flow +2 -2
- package/lib/models/content/ContentIndexModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.js +2 -0
- package/lib/models/content/ContentLinkModel.js.flow +2 -0
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/SectionModel.js +1 -0
- package/lib/models/content/SectionModel.js.flow +1 -0
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/detail/DetailModel.js +1 -1
- package/lib/models/detail/DetailModel.js.flow +2 -0
- package/lib/models/detail/DetailModel.js.map +1 -1
- package/lib/models/error/ErrorResponse.js +2 -0
- package/lib/models/error/ErrorResponse.js.flow +2 -0
- package/lib/models/error/ErrorResponse.js.map +1 -1
- package/lib/models/form/FormModel.js +1 -1
- package/lib/models/form/FormModel.js.flow +1 -1
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/href/Href.js +50 -3
- package/lib/models/href/Href.js.flow +58 -3
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/href/ListHref.js +1 -1
- package/lib/models/href/ListHref.js.flow +1 -1
- package/lib/models/href/ListHref.js.map +1 -1
- package/lib/models/links/LinkCollection.js +3 -1
- package/lib/models/links/LinkCollection.js.flow +8 -2
- package/lib/models/links/LinkCollection.js.map +1 -1
- package/lib/models/links/LinkModel.js +10 -9
- package/lib/models/links/LinkModel.js.flow +24 -16
- package/lib/models/links/LinkModel.js.map +1 -1
- package/lib/models/list/ListItemModel.js +3 -1
- package/lib/models/list/ListItemModel.js.flow +4 -0
- package/lib/models/list/ListItemModel.js.map +1 -1
- package/lib/models/list/ListModel.js +1 -1
- package/lib/models/list/ListModel.js.flow +6 -1
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/panels/GroupingPanelModel.js +1 -1
- package/lib/models/panels/GroupingPanelModel.js.flow +2 -0
- package/lib/models/panels/GroupingPanelModel.js.map +1 -1
- package/lib/models/tab/TabModel.js +2 -2
- package/lib/models/tab/TabModel.js.flow +4 -0
- package/lib/models/tab/TabModel.js.map +1 -1
- package/lib/models/taskgroup/TaskGroupModel.js +4 -2
- package/lib/models/taskgroup/TaskGroupModel.js.flow +6 -0
- package/lib/models/taskgroup/TaskGroupModel.js.map +1 -1
- package/lib/modularui/Authenticate.js +2 -1
- package/lib/modularui/Authenticate.js.flow +2 -1
- package/lib/modularui/Authenticate.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +43 -7
- package/lib/modularui/ModularUIRequest.js.flow +49 -8
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/modularui/ModularUIResponse.js +31 -0
- package/lib/modularui/ModularUIResponse.js.flow +35 -0
- package/lib/modularui/ModularUIResponse.js.map +1 -1
- package/lib/modularui/__tests__/CustomContextPath.spec.js.flow +61 -0
- package/lib/redux/_modularui/ModularUIActions.js +3 -1
- package/lib/redux/_modularui/ModularUIActions.js.flow +6 -1
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js +6 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.flow +10 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/lib/redux/_modularui/types.js.flow +2 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/actions/Application.js +2 -0
- package/lib/redux/actions/Application.js.flow +1 -0
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/connectors/PanelRenderer.js +2 -0
- package/lib/redux/connectors/PanelRenderer.js.flow +1 -0
- package/lib/redux/connectors/PanelRenderer.js.map +1 -1
- package/lib/utils/fetch/types.js.flow +2 -0
- package/lib/utils/fetch/types.js.map +1 -1
- package/lib/utils/helpers/checkResource.js +2 -0
- package/lib/utils/helpers/checkResource.js.flow +2 -0
- package/lib/utils/helpers/checkResource.js.map +1 -1
- package/package.json +1 -1
- package/src/constants/Settings.js +2 -2
- package/src/hooks/useForm.js +2 -0
- package/src/hooks/useModularUIBasic.js +14 -0
- package/src/hooks/useModularUIModel.js +58 -11
- package/src/models/actions/ActionCollection.js +14 -2
- package/src/models/actions/ActionModel.js +38 -16
- package/src/models/application/ApplicationModel.js +7 -1
- package/src/models/base/ResourceModel.js +35 -10
- package/src/models/caseview/CaseViewModel.js +3 -1
- package/src/models/concepts/ConceptLinkModel.js +1 -0
- package/src/models/concepts/SourceReferenceModel.js +2 -1
- package/src/models/content/ContentIndexModel.js +2 -2
- package/src/models/content/ContentLinkModel.js +2 -0
- package/src/models/content/SectionModel.js +1 -0
- package/src/models/detail/DetailModel.js +2 -0
- package/src/models/error/ErrorResponse.js +2 -0
- package/src/models/form/FormModel.js +1 -1
- package/src/models/href/Href.js +58 -3
- package/src/models/href/ListHref.js +1 -1
- package/src/models/links/LinkCollection.js +8 -2
- package/src/models/links/LinkModel.js +24 -16
- package/src/models/list/ListItemModel.js +4 -0
- package/src/models/list/ListModel.js +6 -1
- package/src/models/panels/GroupingPanelModel.js +2 -0
- package/src/models/tab/TabModel.js +4 -0
- package/src/models/taskgroup/TaskGroupModel.js +6 -0
- package/src/modularui/Authenticate.js +2 -1
- package/src/modularui/ModularUIRequest.js +49 -8
- package/src/modularui/ModularUIResponse.js +35 -0
- package/src/modularui/__tests__/CustomContextPath.spec.js +61 -0
- package/src/modularui/__tests__/contributions.json +312 -0
- package/src/modularui/__tests__/data.json +263 -0
- package/src/redux/_modularui/ModularUIActions.js +6 -1
- package/src/redux/_modularui/ModularUIMiddleware.js +10 -0
- package/src/redux/_modularui/types.js +2 -0
- package/src/redux/actions/Application.js +1 -0
- package/src/redux/connectors/PanelRenderer.js +1 -0
- package/src/utils/fetch/types.js +2 -0
- package/src/utils/helpers/checkResource.js +2 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import xhrMock from "xhr-mock";
|
|
2
|
+
|
|
3
|
+
import ModularUIRequest from "../ModularUIRequest";
|
|
4
|
+
|
|
5
|
+
import dataJSON from "./data.json";
|
|
6
|
+
import contributionsJSON from "./contributions.json";
|
|
7
|
+
|
|
8
|
+
import ApplicationModel from "../../models/application/ApplicationModel";
|
|
9
|
+
|
|
10
|
+
const JSON_TYPE = "application/json";
|
|
11
|
+
|
|
12
|
+
describe("modularUIRequest", () => {
|
|
13
|
+
// replace the real XHR object with the mock XHR object before each test
|
|
14
|
+
// eslint-disable-next-line jest/no-hooks
|
|
15
|
+
beforeEach(() => xhrMock.setup());
|
|
16
|
+
|
|
17
|
+
// put the real XHR object back and clear the mocks after each test
|
|
18
|
+
// eslint-disable-next-line jest/no-hooks
|
|
19
|
+
afterEach(() => xhrMock.teardown());
|
|
20
|
+
|
|
21
|
+
it("creates a model from a response with custom origin and contextPath", async () => {
|
|
22
|
+
expect.assertions(12);
|
|
23
|
+
xhrMock.get("http://www.example.com/custom-path/", (req, res) => {
|
|
24
|
+
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
25
|
+
expect(req.header("Content-Type")).toBe(JSON_TYPE);
|
|
26
|
+
expect(req.header("accept-language")).toBe("en");
|
|
27
|
+
|
|
28
|
+
return res.status(200).body(dataJSON);
|
|
29
|
+
});
|
|
30
|
+
xhrMock.get(
|
|
31
|
+
"http://www.example.com/custom-path/contributions/",
|
|
32
|
+
(req, res) => {
|
|
33
|
+
expect(req.header("accept")).toBe(JSON_TYPE);
|
|
34
|
+
expect(req.header("Content-Type")).toBe(JSON_TYPE);
|
|
35
|
+
expect(req.header("accept-language")).toBe("en");
|
|
36
|
+
|
|
37
|
+
return res.status(200).body(contributionsJSON);
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const request = new ModularUIRequest("/", {
|
|
42
|
+
origin: "http://www.example.com",
|
|
43
|
+
contextPath: "/custom-path",
|
|
44
|
+
childmodels: false,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const model = await request.fetch();
|
|
48
|
+
expect(model).toBeInstanceOf(ApplicationModel);
|
|
49
|
+
expect(model.origin).toBe("http://www.example.com");
|
|
50
|
+
expect(model.contextPath).toBe("/custom-path");
|
|
51
|
+
expect(model.selfhref.absolutehref).toBe(
|
|
52
|
+
"http://www.example.com/custom-path/",
|
|
53
|
+
);
|
|
54
|
+
expect(model.modelcatalog.href.absolutehref).toBe(
|
|
55
|
+
"http://www.example.com/custom-path/modelcatalog",
|
|
56
|
+
);
|
|
57
|
+
expect(model.tabs.first.href.absolutehref).toBe(
|
|
58
|
+
"http://www.example.com/custom-path/books",
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -92,7 +92,9 @@ const loadModelSuccessAction = (key, model, updateHandler) => {
|
|
|
92
92
|
const loadModel = (key, href, options) => ({
|
|
93
93
|
type: "MODULARUI/FETCH",
|
|
94
94
|
payload: {
|
|
95
|
-
|
|
95
|
+
origin: options?.origin,
|
|
96
|
+
contextPath: options?.contextPath,
|
|
97
|
+
href: href instanceof _Href.default ? href : new _Href.default(href, "", options?.origin, options?.contextPath),
|
|
96
98
|
method: options?.method ?? _Constants.HTTP_METHODS.GET,
|
|
97
99
|
data: options?.data,
|
|
98
100
|
locale: options?.locale ?? "en",
|
|
@@ -109,7 +109,12 @@ export const loadModel = (
|
|
|
109
109
|
): ModularUIAction => ({
|
|
110
110
|
type: "MODULARUI/FETCH",
|
|
111
111
|
payload: {
|
|
112
|
-
|
|
112
|
+
origin: options?.origin,
|
|
113
|
+
contextPath: options?.contextPath,
|
|
114
|
+
href:
|
|
115
|
+
href instanceof Href
|
|
116
|
+
? href
|
|
117
|
+
: new Href(href, "", options?.origin, options?.contextPath),
|
|
113
118
|
method: options?.method ?? HTTP_METHODS.GET,
|
|
114
119
|
data: options?.data,
|
|
115
120
|
locale: options?.locale ?? "en",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIActions.js","names":["_Constants","require","_Href","_interopRequireDefault","_ErrorResponse","_ProgressIndicator","_Error","setModel","key","model","connectKey","type","payload","exports","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","Href","method","HTTP_METHODS","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","LOADING","startProgress","loadModelPromise","_promise","default","resolve","then","response","FINISHED","finishProgress","catch","handleError","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n
|
|
1
|
+
{"version":3,"file":"ModularUIActions.js","names":["_Constants","require","_Href","_interopRequireDefault","_ErrorResponse","_ProgressIndicator","_Error","setModel","key","model","connectKey","type","payload","exports","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","origin","contextPath","Href","method","HTTP_METHODS","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","LOADING","startProgress","loadModelPromise","_promise","default","resolve","then","response","FINISHED","finishProgress","catch","handleError","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n origin: options?.origin,\n contextPath: options?.contextPath,\n href:\n href instanceof Href\n ? href\n : new Href(href, \"\", options?.origin, options?.contextPath),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAmBA;AACA;AACO,MAAMM,QAAQ,GAAGA,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AADAI,OAAA,CAAAN,QAAA,GAAAA,QAAA;AAEO,MAAMO,UAAU,GACrBC,MAAqD,KAChC;EACrBJ,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEG;AACX,CAAC,CAAC;;AAEF;AACA;AADAF,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAEO,MAAME,WAAW,GAAIP,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,E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GH,QAAQ,CAACzB,SAAS,CAAChB,GAAG,EAAEiB,IAAI,EAAEC,OAAO,CAAC,CAAC;EAEhE,OAAO2B,QAAA,CAAAC,OAAA,CAAQC,OAAO,CAACH,gBAAgB,CAAC,CACrCI,IAAI,CAAEC,QAAQ,IAAK;IAClB,IAAIA,QAAQ,EAAE9C,IAAI,KAAK,iBAAiB,EAAE;MACxCsC,QAAQ,CAAC7B,YAAY,CAACZ,GAAG,EAAEsC,2BAAgB,CAACY,QAAQ,CAAC,CAAC;IACxD;IAEA,OAAOT,QAAQ,CAAC,IAAAU,iCAAc,EAAC,CAAC,CAAC;EACnC,CAAC,CAAC,CACDC,KAAK,CAAEnB,KAAK,IAAKQ,QAAQ,CAAC,IAAAY,kBAAW,EAACpB,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AADA5B,OAAA,CAAAmC,aAAA,GAAAA,aAAA;AAEO,MAAMc,WAAW,GAAGA,CACzBrD,KAAqB,EACrBiB,OAAiC,KAEjCsB,aAAa,CAACvC,KAAK,CAACC,UAAU,EAAED,KAAK,CAACsD,QAAQ,EAAE;EAC9C,GAAGrC,OAAO;EACVsC,QAAQ,EAAE;AACZ,CAAC,CAAC;AAACnD,OAAA,CAAAiD,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -22,6 +22,12 @@ const createRequest = modularui => {
|
|
|
22
22
|
isReload: modularui.isReload,
|
|
23
23
|
cache: modularui.cache
|
|
24
24
|
});
|
|
25
|
+
if (modularui.origin) {
|
|
26
|
+
request.origin = modularui.origin;
|
|
27
|
+
}
|
|
28
|
+
if (modularui.contextPath) {
|
|
29
|
+
request.contextPath = modularui.contextPath;
|
|
30
|
+
}
|
|
25
31
|
if (modularui.targetModel) {
|
|
26
32
|
request.targetModel = modularui.targetModel;
|
|
27
33
|
request.forceTargetModel = modularui.forceTargetModel ?? false;
|
|
@@ -19,6 +19,8 @@ import type { ModularUIAction, SuccessAction, ErrorAction } from "./types";
|
|
|
19
19
|
import type { TargetModel } from "../../modularui/types";
|
|
20
20
|
|
|
21
21
|
type RequestOptions = {
|
|
22
|
+
origin?: string,
|
|
23
|
+
contextPath?: string,
|
|
22
24
|
href: Href,
|
|
23
25
|
method?: $Keys<typeof HTTP_METHODS>,
|
|
24
26
|
data?: any,
|
|
@@ -43,6 +45,14 @@ const createRequest = (modularui: RequestOptions): ModularUIRequest => {
|
|
|
43
45
|
cache: modularui.cache,
|
|
44
46
|
});
|
|
45
47
|
|
|
48
|
+
if (modularui.origin) {
|
|
49
|
+
request.origin = modularui.origin;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (modularui.contextPath) {
|
|
53
|
+
request.contextPath = modularui.contextPath;
|
|
54
|
+
}
|
|
55
|
+
|
|
46
56
|
if (modularui.targetModel) {
|
|
47
57
|
request.targetModel = modularui.targetModel;
|
|
48
58
|
request.forceTargetModel = modularui.forceTargetModel ?? false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIMiddleware.js","names":["_ModularUIRequest","_interopRequireDefault","require","_Constants","_ProgressIndicator","_Error","createRequest","modularui","request","ModularUIRequest","href","method","HTTP_METHODS","GET","data","locale","childmodels","isReload","cache","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_promise","default","then","result","catch","error","handleError","Error","finishProgress","errorHandler","errorAction","err","errorResult","handleFetch","action","startProgress","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n","exports"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n });\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next,\n );\n }\n\n return next(action);\n };\n"],"mappings":";;;;;;;;AACA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;
|
|
1
|
+
{"version":3,"file":"ModularUIMiddleware.js","names":["_ModularUIRequest","_interopRequireDefault","require","_Constants","_ProgressIndicator","_Error","createRequest","modularui","request","ModularUIRequest","href","method","HTTP_METHODS","GET","data","locale","childmodels","isReload","cache","origin","contextPath","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_promise","default","then","result","catch","error","handleError","Error","finishProgress","errorHandler","errorAction","err","errorResult","handleFetch","action","startProgress","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n","exports"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n });\n\n if (modularui.origin) {\n request.origin = modularui.origin;\n }\n\n if (modularui.contextPath) {\n request.contextPath = modularui.contextPath;\n }\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next,\n );\n }\n\n return next(action);\n };\n"],"mappings":";;;;;;;;AACA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AA4BA;AACA;AACA;AACA,MAAMI,aAAa,GAAIC,SAAyB,IAAuB;EACrE,MAAMC,OAAO,GAAG,IAAIC,yBAAgB,CAACF,SAAS,CAACG,IAAI,EAAE;IACnDC,MAAM,EAAEJ,SAAS,CAACI,MAAM,IAAIC,uBAAY,CAACC,GAAG;IAC5CC,IAAI,EAAEP,SAAS,CAACO,IAAI,IAAI,CAAC,CAAC;IAC1BC,MAAM,EAAER,SAAS,CAACQ,MAAM;IACxBC,WAAW,EAAET,SAAS,CAACS,WAAW,IAAI,IAAI;IAC1CC,QAAQ,EAAEV,SAAS,CAACU,QAAQ;IAC5BC,KAAK,EAAEX,SAAS,CAACW;EACnB,CAAC,CAAC;EAEF,IAAIX,SAAS,CAACY,MAAM,EAAE;IACpBX,OAAO,CAACW,MAAM,GAAGZ,SAAS,CAACY,MAAM;EACnC;EAEA,IAAIZ,SAAS,CAACa,WAAW,EAAE;IACzBZ,OAAO,CA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ux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel,\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException,\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n successAction: (\n model: ModularUIModel,\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel,\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException,\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n successAction: (\n model: ModularUIModel,\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
|
|
@@ -15,6 +15,8 @@ const reloadApplication = () => (dispatch, getState) => {
|
|
|
15
15
|
for (const key of allKeys) {
|
|
16
16
|
dispatch((0, _ModularUIActions.removeModelByKey)(key));
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
// TODO SBO: origin and context
|
|
18
20
|
const modelKey = `application(/)(${(0, _i18n.getLocale)(getState())})`;
|
|
19
21
|
return dispatch((0, _ModularUIActions.loadModularUI)(modelKey, new _models.Href("/", "Application"), {
|
|
20
22
|
targetModel: _models.ApplicationModel
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Application.js","names":["_ModularUIActions","require","_ModularUISelectors","_models","_i18n","reloadApplication","dispatch","getState","allKeys","allKeysByHref","key","removeModelByKey","modelKey","getLocale","loadModularUI","Href","targetModel","ApplicationModel","exports"],"sources":["../../../src/redux/actions/Application.js"],"sourcesContent":["// @flow\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../_modularui/ModularUIActions\";\nimport { allKeysByHref } from \"../_modularui/ModularUISelectors\";\nimport { ApplicationModel, Href } from \"../../models\";\nimport { getLocale } from \"../selectors/i18n\";\n\nimport type { Dispatch, GetState, ThunkAction } from \"../types\";\n\n/**\n */\nexport const reloadApplication =\n (): ThunkAction => (dispatch: Dispatch, getState: GetState) => {\n const allKeys = allKeysByHref(getState(), \"/\");\n for (const key of allKeys) {\n dispatch(removeModelByKey(key));\n }\n\n const modelKey = `application(/)(${getLocale(getState())})`;\n return dispatch(\n loadModularUI(modelKey, new Href(\"/\", \"Application\"), {\n targetModel: ApplicationModel,\n }),\n );\n };\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAIA;AACA;AACO,MAAMI,iBAAiB,GAC5BA,CAAA,KAAmB,CAACC,QAAkB,EAAEC,QAAkB,KAAK;EAC7D,MAAMC,OAAO,GAAG,IAAAC,iCAAa,EAACF,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAC9C,KAAK,MAAMG,GAAG,IAAIF,OAAO,EAAE;IACzBF,QAAQ,CAAC,IAAAK,kCAAgB,EAACD,GAAG,CAAC,CAAC;EACjC;
|
|
1
|
+
{"version":3,"file":"Application.js","names":["_ModularUIActions","require","_ModularUISelectors","_models","_i18n","reloadApplication","dispatch","getState","allKeys","allKeysByHref","key","removeModelByKey","modelKey","getLocale","loadModularUI","Href","targetModel","ApplicationModel","exports"],"sources":["../../../src/redux/actions/Application.js"],"sourcesContent":["// @flow\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../_modularui/ModularUIActions\";\nimport { allKeysByHref } from \"../_modularui/ModularUISelectors\";\nimport { ApplicationModel, Href } from \"../../models\";\nimport { getLocale } from \"../selectors/i18n\";\n\nimport type { Dispatch, GetState, ThunkAction } from \"../types\";\n\n/**\n */\nexport const reloadApplication =\n (): ThunkAction => (dispatch: Dispatch, getState: GetState) => {\n const allKeys = allKeysByHref(getState(), \"/\");\n for (const key of allKeys) {\n dispatch(removeModelByKey(key));\n }\n\n // TODO SBO: origin and context\n const modelKey = `application(/)(${getLocale(getState())})`;\n return dispatch(\n loadModularUI(modelKey, new Href(\"/\", \"Application\"), {\n targetModel: ApplicationModel,\n }),\n );\n };\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAIA;AACA;AACO,MAAMI,iBAAiB,GAC5BA,CAAA,KAAmB,CAACC,QAAkB,EAAEC,QAAkB,KAAK;EAC7D,MAAMC,OAAO,GAAG,IAAAC,iCAAa,EAACF,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAC9C,KAAK,MAAMG,GAAG,IAAIF,OAAO,EAAE;IACzBF,QAAQ,CAAC,IAAAK,kCAAgB,EAACD,GAAG,CAAC,CAAC;EACjC;;EAEA;EACA,MAAME,QAAQ,GAAG,kBAAkB,IAAAC,eAAS,EAACN,QAAQ,CAAC,CAAC,CAAC,GAAG;EAC3D,OAAOD,QAAQ,CACb,IAAAQ,+BAAa,EAACF,QAAQ,EAAE,IAAIG,YAAI,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE;IACpDC,WAAW,EAAEC;EACf,CAAC,CACH,CAAC;AACH,CAAC;AAACC,OAAA,CAAAb,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -18,6 +18,8 @@ const connectPanel = exports.connectPanel = (0, _ModularUIConnector.default)("Pa
|
|
|
18
18
|
if (!href && !match) {
|
|
19
19
|
throw new Error("Cannot determine panel url because of missing href and match");
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
// TODO SBO: origin and context?
|
|
21
23
|
const panelHref = href ? new _Href.default(href) : new _Href.default(match.url);
|
|
22
24
|
if (match && match.isExact) {
|
|
23
25
|
panelHref.addParametersFromString(querystring);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelRenderer.js","names":["_ModularUIConnector","_interopRequireDefault","require","_Href","connectPanel","exports","modularui","_ref","href","match","querystring","Error","panelHref","Href","url","isExact","addParametersFromString","propName"],"sources":["../../../src/redux/connectors/PanelRenderer.js"],"sourcesContent":["// @flow\nimport modularui from \"../_modularui/ModularUIConnector\";\nimport Href from \"../../models/href/Href\";\n\nimport type { ModularUIConnector } from \"../_modularui/types\";\n\n/**\n */\nexport const connectPanel: ModularUIConnector = modularui(\n \"PanelRenderer\",\n ({ href, match, querystring = \"\" }) => {\n if (!href && !match) {\n throw new Error(\n \"Cannot determine panel url because of missing href and match\",\n );\n }\n\n const panelHref = href ? new Href(href) : new Href(match.url);\n\n if (match && match.isExact) {\n panelHref.addParametersFromString(querystring);\n }\n\n return panelHref;\n },\n {\n propName: \"panel\",\n },\n);\n"],"mappings":";;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAIA;AACA;AACO,MAAME,YAAgC,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAAE,2BAAS,EACvD,eAAe,EACfC,IAAA,IAAuC;EAAA,IAAtC;IAAEC,IAAI;IAAEC,KAAK;IAAEC,WAAW,GAAG;EAAG,CAAC,GAAAH,IAAA;EAChC,IAAI,CAACC,IAAI,IAAI,CAACC,KAAK,EAAE;IACnB,MAAM,IAAIE,KAAK,CACb,8DACF,CAAC;EACH;
|
|
1
|
+
{"version":3,"file":"PanelRenderer.js","names":["_ModularUIConnector","_interopRequireDefault","require","_Href","connectPanel","exports","modularui","_ref","href","match","querystring","Error","panelHref","Href","url","isExact","addParametersFromString","propName"],"sources":["../../../src/redux/connectors/PanelRenderer.js"],"sourcesContent":["// @flow\nimport modularui from \"../_modularui/ModularUIConnector\";\nimport Href from \"../../models/href/Href\";\n\nimport type { ModularUIConnector } from \"../_modularui/types\";\n\n/**\n */\nexport const connectPanel: ModularUIConnector = modularui(\n \"PanelRenderer\",\n ({ href, match, querystring = \"\" }) => {\n if (!href && !match) {\n throw new Error(\n \"Cannot determine panel url because of missing href and match\",\n );\n }\n\n // TODO SBO: origin and context?\n const panelHref = href ? new Href(href) : new Href(match.url);\n\n if (match && match.isExact) {\n panelHref.addParametersFromString(querystring);\n }\n\n return panelHref;\n },\n {\n propName: \"panel\",\n },\n);\n"],"mappings":";;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAIA;AACA;AACO,MAAME,YAAgC,GAAAC,OAAA,CAAAD,YAAA,GAAG,IAAAE,2BAAS,EACvD,eAAe,EACfC,IAAA,IAAuC;EAAA,IAAtC;IAAEC,IAAI;IAAEC,KAAK;IAAEC,WAAW,GAAG;EAAG,CAAC,GAAAH,IAAA;EAChC,IAAI,CAACC,IAAI,IAAI,CAACC,KAAK,EAAE;IACnB,MAAM,IAAIE,KAAK,CACb,8DACF,CAAC;EACH;;EAEA;EACA,MAAMC,SAAS,GAAGJ,IAAI,GAAG,IAAIK,aAAI,CAACL,IAAI,CAAC,GAAG,IAAIK,aAAI,CAACJ,KAAK,CAACK,GAAG,CAAC;EAE7D,IAAIL,KAAK,IAAIA,KAAK,CAACM,OAAO,EAAE;IAC1BH,SAAS,CAACI,uBAAuB,CAACN,WAAW,CAAC;EAChD;EAEA,OAAOE,SAAS;AAClB,CAAC,EACD;EACEK,QAAQ,EAAE;AACZ,CACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/fetch/types.js"],"sourcesContent":["// @flow\nimport typeof { HTTP_METHODS } from \"../../constants/Constants\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\nexport type RequestURLOptions = {\n url: string,\n};\n\nexport type RequestBaseOptions = {\n method?: $Keys<HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n responseType?: string,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n includeContext?: boolean,\n locale?: string,\n cache?: boolean,\n isReload?: boolean,\n};\n\nexport type RequestOptions = { ...RequestURLOptions, ...RequestBaseOptions };\n\nexport type UpdateHandler = (newModel: ModularUIModel) => ModularUIModel;\nexport type RequestModularUIOptions = {\n ...RequestBaseOptions,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n updateHandler?: UpdateHandler | void,\n childmodels?: boolean,\n isValidationRequest?: boolean,\n removeOnUnmount?: boolean,\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/fetch/types.js"],"sourcesContent":["// @flow\nimport typeof { HTTP_METHODS } from \"../../constants/Constants\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\nexport type RequestURLOptions = {\n url: string,\n};\n\nexport type RequestBaseOptions = {\n origin?: string,\n contextPath?: string,\n method?: $Keys<HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n responseType?: string,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n includeContext?: boolean,\n locale?: string,\n cache?: boolean,\n isReload?: boolean,\n};\n\nexport type RequestOptions = { ...RequestURLOptions, ...RequestBaseOptions };\n\nexport type UpdateHandler = (newModel: ModularUIModel) => ModularUIModel;\nexport type RequestModularUIOptions = {\n ...RequestBaseOptions,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n updateHandler?: UpdateHandler | void,\n childmodels?: boolean,\n isValidationRequest?: boolean,\n removeOnUnmount?: boolean,\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -15,6 +15,7 @@ var _Href = _interopRequireDefault(require("../../models/href/Href"));
|
|
|
15
15
|
* @returns {boolean}
|
|
16
16
|
*/
|
|
17
17
|
const resourceExists = url => {
|
|
18
|
+
// TODO SBO: origin and context?
|
|
18
19
|
const fullUrl = new _Href.default(url).absolutehref;
|
|
19
20
|
const xhr = new XMLHttpRequest();
|
|
20
21
|
xhr.open("HEAD", fullUrl, false);
|
|
@@ -32,6 +33,7 @@ const resourceExists = url => {
|
|
|
32
33
|
*/
|
|
33
34
|
exports.resourceExists = resourceExists;
|
|
34
35
|
const resourceRedirectsToSecureLogin = url => {
|
|
36
|
+
// TODO SBO: origin and context?
|
|
35
37
|
const fullUrl = new _Href.default(url).absolutehref;
|
|
36
38
|
const xhr = new XMLHttpRequest();
|
|
37
39
|
xhr.open("HEAD", fullUrl, false);
|
|
@@ -9,6 +9,7 @@ import Href from "../../models/href/Href";
|
|
|
9
9
|
* @returns {boolean}
|
|
10
10
|
*/
|
|
11
11
|
export const resourceExists = (url: string | Href): boolean => {
|
|
12
|
+
// TODO SBO: origin and context?
|
|
12
13
|
const fullUrl = new Href(url).absolutehref;
|
|
13
14
|
|
|
14
15
|
const xhr = new XMLHttpRequest();
|
|
@@ -28,6 +29,7 @@ export const resourceExists = (url: string | Href): boolean => {
|
|
|
28
29
|
* @returns {boolean}
|
|
29
30
|
*/
|
|
30
31
|
export const resourceRedirectsToSecureLogin = (url: string | Href): boolean => {
|
|
32
|
+
// TODO SBO: origin and context?
|
|
31
33
|
const fullUrl = new Href(url).absolutehref;
|
|
32
34
|
|
|
33
35
|
const xhr = new XMLHttpRequest();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkResource.js","names":["_Href","_interopRequireDefault","require","resourceExists","url","fullUrl","Href","absolutehref","xhr","XMLHttpRequest","open","setRequestHeader","send","status","exports","resourceRedirectsToSecureLogin","responseURL","_endsWith","default","call"],"sources":["../../../src/utils/helpers/checkResource.js"],"sourcesContent":["// @flow\nimport Href from \"../../models/href/Href\";\n\n/**\n * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)\n * When the resource returns a 404, the resource does not exists and the method returns false\n *\n * @param url\n * @returns {boolean}\n */\nexport const resourceExists = (url: string | Href): boolean => {\n const fullUrl = new Href(url).absolutehref;\n\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", fullUrl, false);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.setRequestHeader(\"X-Requested-With\", \"XMLHttpRequest\");\n\n xhr.send();\n\n return xhr.status !== 404;\n};\n\n/**\n * Indicates if a request to the given url resuls in a redirect to /secureRedirect\n * @param url\n * @returns {boolean}\n */\nexport const resourceRedirectsToSecureLogin = (url: string | Href): boolean => {\n const fullUrl = new Href(url).absolutehref;\n\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", fullUrl, false);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.setRequestHeader(\"X-Requested-With\", \"XMLHttpRequest\");\n xhr.send();\n\n const responseURL = xhr.responseURL ?? \"\";\n\n return xhr.status === 400 && responseURL.endsWith(\"/secureLogin\");\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAIC,GAAkB,IAAc;EAC7D,MAAMC,OAAO,GAAG,IAAIC,aAAI,CAACF,GAAG,CAAC,CAACG,YAAY;EAE1C,MAAMC,GAAG,GAAG,IAAIC,cAAc,CAAC,CAAC;EAChCD,GAAG,CAACE,IAAI,CAAC,MAAM,EAAEL,OAAO,EAAE,KAAK,CAAC;EAChCG,GAAG,CAACG,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,CAAC;EAClDH,GAAG,CAACG,gBAAgB,CAAC,cAAc,EAAE,kBAAkB,CAAC;EACxDH,GAAG,CAACG,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;EAE1DH,GAAG,CAACI,IAAI,CAAC,CAAC;EAEV,OAAOJ,GAAG,CAACK,MAAM,KAAK,GAAG;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAX,cAAA,GAAAA,cAAA;AAKO,MAAMY,8BAA8B,GAAIX,GAAkB,IAAc;EAC7E,MAAMC,OAAO,GAAG,IAAIC,aAAI,CAACF,GAAG,CAAC,CAACG,YAAY;EAE1C,MAAMC,GAAG,GAAG,IAAIC,cAAc,CAAC,CAAC;EAChCD,GAAG,CAACE,IAAI,CAAC,MAAM,EAAEL,OAAO,EAAE,KAAK,CAAC;EAChCG,GAAG,CAACG,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,CAAC;EAClDH,GAAG,CAACG,gBAAgB,CAAC,cAAc,EAAE,kBAAkB,CAAC;EACxDH,GAAG,CAACG,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;EAC1DH,GAAG,CAACI,IAAI,CAAC,CAAC;EAEV,MAAMI,WAAW,GAAGR,GAAG,CAACQ,WAAW,IAAI,EAAE;EAEzC,OAAOR,GAAG,CAACK,MAAM,KAAK,GAAG,IAAI,IAAAI,SAAA,CAAAC,OAAA,EAAAF,WAAW,EAAAG,IAAA,CAAXH,WAAW,EAAU,cAAc,CAAC;AACnE,CAAC;AAACF,OAAA,CAAAC,8BAAA,GAAAA,8BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"checkResource.js","names":["_Href","_interopRequireDefault","require","resourceExists","url","fullUrl","Href","absolutehref","xhr","XMLHttpRequest","open","setRequestHeader","send","status","exports","resourceRedirectsToSecureLogin","responseURL","_endsWith","default","call"],"sources":["../../../src/utils/helpers/checkResource.js"],"sourcesContent":["// @flow\nimport Href from \"../../models/href/Href\";\n\n/**\n * Checks if a given url to a modular ui resource exists using a HEAD request to the resource (synchronous)\n * When the resource returns a 404, the resource does not exists and the method returns false\n *\n * @param url\n * @returns {boolean}\n */\nexport const resourceExists = (url: string | Href): boolean => {\n // TODO SBO: origin and context?\n const fullUrl = new Href(url).absolutehref;\n\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", fullUrl, false);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.setRequestHeader(\"X-Requested-With\", \"XMLHttpRequest\");\n\n xhr.send();\n\n return xhr.status !== 404;\n};\n\n/**\n * Indicates if a request to the given url resuls in a redirect to /secureRedirect\n * @param url\n * @returns {boolean}\n */\nexport const resourceRedirectsToSecureLogin = (url: string | Href): boolean => {\n // TODO SBO: origin and context?\n const fullUrl = new Href(url).absolutehref;\n\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", fullUrl, false);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.setRequestHeader(\"X-Requested-With\", \"XMLHttpRequest\");\n xhr.send();\n\n const responseURL = xhr.responseURL ?? \"\";\n\n return xhr.status === 400 && responseURL.endsWith(\"/secureLogin\");\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,cAAc,GAAIC,GAAkB,IAAc;EAC7D;EACA,MAAMC,OAAO,GAAG,IAAIC,aAAI,CAACF,GAAG,CAAC,CAACG,YAAY;EAE1C,MAAMC,GAAG,GAAG,IAAIC,cAAc,CAAC,CAAC;EAChCD,GAAG,CAACE,IAAI,CAAC,MAAM,EAAEL,OAAO,EAAE,KAAK,CAAC;EAChCG,GAAG,CAACG,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,CAAC;EAClDH,GAAG,CAACG,gBAAgB,CAAC,cAAc,EAAE,kBAAkB,CAAC;EACxDH,GAAG,CAACG,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;EAE1DH,GAAG,CAACI,IAAI,CAAC,CAAC;EAEV,OAAOJ,GAAG,CAACK,MAAM,KAAK,GAAG;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAC,OAAA,CAAAX,cAAA,GAAAA,cAAA;AAKO,MAAMY,8BAA8B,GAAIX,GAAkB,IAAc;EAC7E;EACA,MAAMC,OAAO,GAAG,IAAIC,aAAI,CAACF,GAAG,CAAC,CAACG,YAAY;EAE1C,MAAMC,GAAG,GAAG,IAAIC,cAAc,CAAC,CAAC;EAChCD,GAAG,CAACE,IAAI,CAAC,MAAM,EAAEL,OAAO,EAAE,KAAK,CAAC;EAChCG,GAAG,CAACG,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,CAAC;EAClDH,GAAG,CAACG,gBAAgB,CAAC,cAAc,EAAE,kBAAkB,CAAC;EACxDH,GAAG,CAACG,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;EAC1DH,GAAG,CAACI,IAAI,CAAC,CAAC;EAEV,MAAMI,WAAW,GAAGR,GAAG,CAACQ,WAAW,IAAI,EAAE;EAEzC,OAAOR,GAAG,CAACK,MAAM,KAAK,GAAG,IAAI,IAAAI,SAAA,CAAAC,OAAA,EAAAF,WAAW,EAAAG,IAAA,CAAXH,WAAW,EAAU,cAAc,CAAC;AACnE,CAAC;AAACF,OAAA,CAAAC,8BAAA,GAAAA,8BAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -194,8 +194,8 @@ export const loginType = (): string =>
|
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
196
|
*/
|
|
197
|
-
export const loginPath = (): string =>
|
|
198
|
-
getSetting(LOGIN_PATH_SETTING,
|
|
197
|
+
export const loginPath = (clientName: string = "FormClient"): string =>
|
|
198
|
+
getSetting(LOGIN_PATH_SETTING, `/callback?client_name=${clientName}`);
|
|
199
199
|
/**
|
|
200
200
|
*/
|
|
201
201
|
export const loginUsernameField = (): string =>
|
package/src/hooks/useForm.js
CHANGED
|
@@ -11,6 +11,8 @@ export type UseModularUIBasicOptions<T: ModularUIModel> = {
|
|
|
11
11
|
expectedModels?: Array<string>,
|
|
12
12
|
targetModel?: Class<T> | Array<Class<T>>,
|
|
13
13
|
forceTargetModel?: boolean,
|
|
14
|
+
origin?: string,
|
|
15
|
+
contextPath?: string,
|
|
14
16
|
cache?: boolean,
|
|
15
17
|
};
|
|
16
18
|
|
|
@@ -23,6 +25,8 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
23
25
|
expectedModels: [],
|
|
24
26
|
targetModel: undefined,
|
|
25
27
|
forceTargetModel: false,
|
|
28
|
+
origin: undefined,
|
|
29
|
+
contextPath: undefined,
|
|
26
30
|
},
|
|
27
31
|
): T | null => {
|
|
28
32
|
const location = useLocation();
|
|
@@ -31,6 +35,8 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
31
35
|
targetModel: undefined,
|
|
32
36
|
forceTargetModel: undefined,
|
|
33
37
|
isReload: false,
|
|
38
|
+
origin: undefined,
|
|
39
|
+
contextPath: undefined,
|
|
34
40
|
cache: false,
|
|
35
41
|
};
|
|
36
42
|
if (options.targetModel) {
|
|
@@ -47,6 +53,14 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
47
53
|
useModularUIOptions.isReload = true;
|
|
48
54
|
}
|
|
49
55
|
|
|
56
|
+
if (options.origin) {
|
|
57
|
+
useModularUIOptions.origin = options.origin;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (options.contextPath) {
|
|
61
|
+
useModularUIOptions.contextPath = options.contextPath;
|
|
62
|
+
}
|
|
63
|
+
|
|
50
64
|
// $FlowFixMe[incompatible-call]
|
|
51
65
|
const modularUI = useModularUI(key, href, useModularUIOptions);
|
|
52
66
|
|
|
@@ -11,103 +11,150 @@ import UserProfileModel from "../models/user/UserProfileModel";
|
|
|
11
11
|
|
|
12
12
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
13
13
|
|
|
14
|
+
type HookOptions = {
|
|
15
|
+
origin?: string,
|
|
16
|
+
contextPath?: string,
|
|
17
|
+
};
|
|
18
|
+
|
|
14
19
|
/**
|
|
15
20
|
* Load application
|
|
16
21
|
*/
|
|
17
|
-
export const useApplication = (
|
|
22
|
+
export const useApplication = (
|
|
23
|
+
options?: HookOptions,
|
|
24
|
+
): ApplicationModel | null =>
|
|
18
25
|
useModularUIBasic("application", "/", {
|
|
19
26
|
expectedModels: ["Application"],
|
|
20
27
|
targetModel: ApplicationModel,
|
|
28
|
+
...options,
|
|
21
29
|
});
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
32
|
* Load a tab by href
|
|
25
33
|
*/
|
|
26
|
-
export const useTab = (href: string): TabModel | null =>
|
|
34
|
+
export const useTab = (href: string, options?: HookOptions): TabModel | null =>
|
|
27
35
|
useModularUIBasic("tab", href, {
|
|
28
36
|
expectedModels: ["Tab"],
|
|
29
37
|
targetModel: TabModel,
|
|
38
|
+
...options,
|
|
30
39
|
});
|
|
31
40
|
|
|
32
41
|
/**
|
|
33
42
|
* Load caseview by href
|
|
34
43
|
*/
|
|
35
|
-
export const useCaseView = (
|
|
44
|
+
export const useCaseView = (
|
|
45
|
+
href: string,
|
|
46
|
+
options?: HookOptions,
|
|
47
|
+
): CaseViewModel | null =>
|
|
36
48
|
useModularUIBasic("caseview", href, {
|
|
37
49
|
expectedModels: ["CaseView"],
|
|
38
50
|
targetModel: CaseViewModel,
|
|
51
|
+
...options,
|
|
39
52
|
});
|
|
40
53
|
|
|
41
54
|
/**
|
|
42
55
|
*/
|
|
43
56
|
export const usePanel = (
|
|
44
57
|
href: string,
|
|
58
|
+
options?: HookOptions,
|
|
45
59
|
): ListModel | GroupingPanelModel | DetailModel | null =>
|
|
46
60
|
useModularUIBasic("panel", href, {
|
|
47
61
|
expectedModels: ["List", "GroupingPanel", "Detail"],
|
|
62
|
+
...options,
|
|
48
63
|
});
|
|
49
64
|
|
|
50
65
|
/**
|
|
51
66
|
*/
|
|
52
|
-
export const useList = (
|
|
67
|
+
export const useList = (
|
|
68
|
+
href: string,
|
|
69
|
+
options?: HookOptions,
|
|
70
|
+
): ListModel | null =>
|
|
53
71
|
useModularUIBasic("list", href, {
|
|
54
72
|
expectedModels: ["List"],
|
|
55
73
|
targetModel: ListModel,
|
|
74
|
+
...options,
|
|
56
75
|
});
|
|
57
76
|
|
|
58
77
|
/**
|
|
59
78
|
*/
|
|
60
|
-
export const useListOrDetail = (
|
|
79
|
+
export const useListOrDetail = (
|
|
80
|
+
href: string,
|
|
81
|
+
options?: HookOptions,
|
|
82
|
+
): ListModel | DetailModel | null =>
|
|
61
83
|
useModularUIBasic("list", href, {
|
|
62
84
|
expectedModels: ["List", "Detail"],
|
|
63
85
|
targetModel: [ListModel, DetailModel],
|
|
86
|
+
...options,
|
|
64
87
|
});
|
|
65
88
|
|
|
66
89
|
/**
|
|
67
90
|
*/
|
|
68
|
-
export const useListDetail = (
|
|
91
|
+
export const useListDetail = (
|
|
92
|
+
href: string,
|
|
93
|
+
options?: HookOptions,
|
|
94
|
+
): ListDetailModel | null =>
|
|
69
95
|
useModularUIBasic("listdetail", href, {
|
|
70
96
|
expectedModels: ["ListDetail"],
|
|
71
97
|
targetModel: ListDetailModel,
|
|
72
98
|
forceTargetModel: true,
|
|
99
|
+
...options,
|
|
73
100
|
});
|
|
74
101
|
|
|
75
102
|
/**
|
|
76
103
|
*/
|
|
77
|
-
export const useGroupingPanel = (
|
|
104
|
+
export const useGroupingPanel = (
|
|
105
|
+
href: string,
|
|
106
|
+
options?: HookOptions,
|
|
107
|
+
): GroupingPanelModel | null =>
|
|
78
108
|
useModularUIBasic("groupingpanel", href, {
|
|
79
109
|
expectedModels: ["GroupingPanel"],
|
|
80
110
|
targetModel: GroupingPanelModel,
|
|
111
|
+
...options,
|
|
81
112
|
});
|
|
82
113
|
|
|
83
114
|
/**
|
|
84
115
|
*/
|
|
85
|
-
export const useDetailPanel = (
|
|
116
|
+
export const useDetailPanel = (
|
|
117
|
+
href: string,
|
|
118
|
+
options?: HookOptions,
|
|
119
|
+
): DetailModel | null =>
|
|
86
120
|
useModularUIBasic("detailpanel", href, {
|
|
87
121
|
expectedModels: ["Detail"],
|
|
88
122
|
targetModel: DetailModel,
|
|
123
|
+
...options,
|
|
89
124
|
});
|
|
90
125
|
|
|
91
126
|
/**
|
|
92
127
|
*/
|
|
93
|
-
export const useQuicksearch = (
|
|
128
|
+
export const useQuicksearch = (
|
|
129
|
+
href: string,
|
|
130
|
+
options?: HookOptions,
|
|
131
|
+
): CaseSearchModel | null =>
|
|
94
132
|
useModularUIBasic("quicksearch", href, {
|
|
95
133
|
expectedModels: ["CaseSearch"],
|
|
96
134
|
targetModel: CaseSearchModel,
|
|
135
|
+
...options,
|
|
97
136
|
});
|
|
98
137
|
|
|
99
138
|
/**
|
|
100
139
|
*/
|
|
101
|
-
export const useSearch = (
|
|
140
|
+
export const useSearch = (
|
|
141
|
+
href: string,
|
|
142
|
+
options?: HookOptions,
|
|
143
|
+
): CaseSearchModel | null =>
|
|
102
144
|
useModularUIBasic("search", href, {
|
|
103
145
|
expectedModels: ["CaseSearch"],
|
|
104
146
|
targetModel: CaseSearchModel,
|
|
147
|
+
...options,
|
|
105
148
|
});
|
|
106
149
|
|
|
107
150
|
/**
|
|
108
151
|
*/
|
|
109
|
-
export const useUserProfile = (
|
|
152
|
+
export const useUserProfile = (
|
|
153
|
+
href: string,
|
|
154
|
+
options?: HookOptions,
|
|
155
|
+
): UserProfileModel | null =>
|
|
110
156
|
useModularUIBasic("userprofile", href, {
|
|
111
157
|
expectedModels: ["UserProfile"],
|
|
112
158
|
targetModel: UserProfileModel,
|
|
159
|
+
...options,
|
|
113
160
|
});
|