@beinformed/ui 1.34.2 → 1.36.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 +20 -0
- package/esm/constants/LayoutHintConfig.js +9 -0
- package/esm/constants/LayoutHintConfig.js.map +1 -1
- package/esm/constants/LayoutHints.js +5 -0
- package/esm/constants/LayoutHints.js.map +1 -1
- package/esm/models/actions/ActionCollection.js +1 -1
- package/esm/models/actions/ActionCollection.js.map +1 -1
- package/esm/models/filters/StringFilterModel.js +3 -2
- package/esm/models/filters/StringFilterModel.js.map +1 -1
- package/esm/models/links/normalizeLinkJSON.js +20 -5
- package/esm/models/links/normalizeLinkJSON.js.map +1 -1
- package/esm/react-server/serverNoSSR.js +4 -0
- package/esm/react-server/serverNoSSR.js.map +1 -1
- package/lib/constants/LayoutHintConfig.js +9 -0
- package/lib/constants/LayoutHintConfig.js.flow +9 -0
- package/lib/constants/LayoutHintConfig.js.map +1 -1
- package/lib/constants/LayoutHints.js +6 -1
- package/lib/constants/LayoutHints.js.flow +5 -0
- package/lib/constants/LayoutHints.js.map +1 -1
- package/lib/hooks/useDeepCompareEffect.js +2 -2
- package/lib/hooks/useDeepCompareEffect.js.map +1 -1
- package/lib/i18n/index.js +2 -2
- package/lib/i18n/index.js.map +1 -1
- package/lib/models/actions/ActionCollection.js +1 -1
- package/lib/models/actions/ActionCollection.js.flow +3 -1
- package/lib/models/actions/ActionCollection.js.map +1 -1
- package/lib/models/application/__tests__/Application.spec.js.flow +1 -1
- package/lib/models/filters/StringFilterModel.js +2 -2
- package/lib/models/filters/StringFilterModel.js.flow +2 -2
- package/lib/models/filters/StringFilterModel.js.map +1 -1
- package/lib/models/index.js +2 -2
- package/lib/models/index.js.map +1 -1
- package/lib/models/links/__tests__/normalizeLinkJSON.spec.js.flow +2 -1
- package/lib/models/links/normalizeLinkJSON.js +19 -5
- package/lib/models/links/normalizeLinkJSON.js.flow +20 -4
- package/lib/models/links/normalizeLinkJSON.js.map +1 -1
- package/lib/models/taskgroup/__tests__/TaskGroupModel.spec.js.flow +17 -0
- package/lib/react-server/serverNoSSR.js +4 -0
- package/lib/react-server/serverNoSSR.js.flow +5 -0
- package/lib/react-server/serverNoSSR.js.map +1 -1
- package/lib/react-server/serverUtil.js +2 -2
- package/lib/react-server/serverUtil.js.map +1 -1
- package/package.json +11 -10
- package/src/constants/LayoutHintConfig.js +9 -0
- package/src/constants/LayoutHints.js +5 -0
- package/src/models/actions/ActionCollection.js +3 -1
- package/src/models/application/__tests__/Application.spec.js +1 -1
- package/src/models/application/__tests__/webappContributions.json +2 -1
- package/src/models/filters/StringFilterModel.js +2 -2
- package/src/models/links/__tests__/normalizeLinkJSON.spec.js +2 -1
- package/src/models/links/normalizeLinkJSON.js +20 -4
- package/src/models/taskgroup/__tests__/TaskGroupModel.spec.js +17 -0
- package/src/models/taskgroup/__tests__/taskgroup.json +25 -0
- package/src/models/taskgroup/__tests__/taskgroupContributions.json +23 -0
- package/src/react-server/serverNoSSR.js +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverUtil.js","names":["_history","require","_objects","_deepmerge","_interopRequireDefault","_configureStore","_Locales","_interopRequireWildcard","_requestInformation","_I18nActions","_Preferences","_Settings","_exceptions","_redux","_i18n","_ModularUIRequest","_getRequireWildcardCache","nodeInterop","_WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","_Object$getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","exports","setI18n","locales","arguments","length","undefined","request","Array","isArray","IllegalArgumentException","mergedLocales","_map","availableLocales","locale","code","customLocale","_find","custLocale","deepmerge","forEach","some","push","enabledLocales","_filter","_context","_includes","getSetting","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWith","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","model","e","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","filteredState","_stringify","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>,\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava,\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getSetting(\"ENABLED_LOCALES\").includes(locale.code),\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`,\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ]),\n );\n } catch (e) {\n // swallow error, in this case we just don't pre-cache the webapplication,\n // which has not much difference for the end user\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object,\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,QAAA,GAAAC,uBAAA,CAAAN,OAAA;AAGA,IAAAO,mBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA;AAQA,IAAAU,SAAA,GAAAV,OAAA;AAEA,IAAAW,WAAA,GAAAX,OAAA;AAEA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,KAAA,GAAAb,OAAA;AAEA,IAAAc,iBAAA,GAAAX,sBAAA,CAAAH,OAAA;AAA6D,SAAAe,yBAAAC,WAAA,eAAAC,QAAA,kCAAAC,iBAAA,OAAAD,QAAA,QAAAE,gBAAA,OAAAF,QAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAV,wBAAAc,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,q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AA;AAEA,MAAMO,UAAU,GAAGA,CACjBC,KAAU,EACVC,IAAY,EACZC,aAAsB,KACX;EACX,MAAMC,KAAK,GAAGH,KAAK,CAACI,YAAY,CAAC,CAAC;EAClC,MAAMC,IAAI,GAAGH,aAAa,GAAG,CAAC,GAAGA,aAAa,CAACI,MAAM,CAACD,IAAI,CAAC,GAAG,EAAE;EAEhE,IAAIH,aAAa,EAAE;IACjB,OAAO;MACL,GAAGA,aAAa,CAACI,MAAM;MACvBH,KAAK;MACLE;IACF,CAAC;EACH;EAEA,OAAO;IACLF,KAAK;IACLE;EACF,CAAC;AACH,CAAC;AAACnF,OAAA,CAAA6E,UAAA,GAAAA,UAAA"}
|
|
1
|
+
{"version":3,"file":"serverUtil.js","names":["_history","require","_objects","_deepmerge","_interopRequireDefault","_configureStore","_Locales","_interopRequireWildcard","_requestInformation","_I18nActions","_Preferences","_Settings","_exceptions","_redux","_i18n","_ModularUIRequest","_getRequireWildcardCache","e","_WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","_Object$getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","exports","setI18n","locales","arguments","length","undefined","request","Array","isArray","IllegalArgumentException","mergedLocales","_map","availableLocales","locale","code","customLocale","_find","custLocale","deepmerge","forEach","some","push","enabledLocales","_filter","_context","_includes","getSetting","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWith","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","key","model","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","filteredState","_stringify","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>,\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava,\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getSetting(\"ENABLED_LOCALES\").includes(locale.code),\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`,\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ]),\n );\n } catch (e) {\n // swallow error, in this case we just don't pre-cache the webapplication,\n // which has not much difference for the end user\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object,\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,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,GAAGA,aAAa,CAACI,MAAM;MACvBH,KAAK;MACLE;IACF,CAAC;EACH;EAEA,OAAO;IACLF,KAAK;IACLE;EACF,CAAC;AACH,CAAC;AAACnF,OAAA,CAAA6E,UAAA,GAAAA,UAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.0",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"styled-components": "^5.0.0"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@babel/runtime-corejs3": "^7.23.
|
|
85
|
+
"@babel/runtime-corejs3": "^7.23.2",
|
|
86
86
|
"big.js": "^6.2.1",
|
|
87
87
|
"date-fns": "^2.30.0",
|
|
88
88
|
"deepmerge": "^4.3.1",
|
|
@@ -99,13 +99,13 @@
|
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
101
|
"@babel/cli": "^7.23.0",
|
|
102
|
-
"@babel/core": "^7.23.
|
|
102
|
+
"@babel/core": "^7.23.2",
|
|
103
103
|
"@babel/eslint-parser": "^7.22.15",
|
|
104
104
|
"@babel/eslint-plugin": "^7.22.10",
|
|
105
105
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
106
106
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
107
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
108
|
-
"@babel/preset-env": "^7.
|
|
107
|
+
"@babel/plugin-transform-runtime": "^7.23.2",
|
|
108
|
+
"@babel/preset-env": "^7.23.2",
|
|
109
109
|
"@babel/preset-flow": "^7.22.15",
|
|
110
110
|
"@babel/preset-react": "^7.22.15",
|
|
111
111
|
"@commitlint/cli": "^17.7.2",
|
|
@@ -115,15 +115,15 @@
|
|
|
115
115
|
"babel-jest": "^29.7.0",
|
|
116
116
|
"babel-plugin-styled-components": "^2.1.4",
|
|
117
117
|
"cherry-pick": "^0.5.0",
|
|
118
|
-
"commit-and-tag-version": "^11.
|
|
118
|
+
"commit-and-tag-version": "^11.3.0",
|
|
119
119
|
"cross-env": "^7.0.3",
|
|
120
120
|
"documentation": "^14.0.2",
|
|
121
|
-
"eslint": "^8.
|
|
121
|
+
"eslint": "^8.52.0",
|
|
122
122
|
"eslint-config-prettier": "^9.0.0",
|
|
123
123
|
"eslint-plugin-babel": "^5.3.1",
|
|
124
|
-
"eslint-plugin-ft-flow": "^3.0.
|
|
125
|
-
"eslint-plugin-import": "^2.
|
|
126
|
-
"eslint-plugin-jest": "^27.4.
|
|
124
|
+
"eslint-plugin-ft-flow": "^3.0.1",
|
|
125
|
+
"eslint-plugin-import": "^2.29.0",
|
|
126
|
+
"eslint-plugin-jest": "^27.4.3",
|
|
127
127
|
"eslint-plugin-jsdoc": "^46.8.2",
|
|
128
128
|
"eslint-plugin-react": "^7.33.2",
|
|
129
129
|
"eslint-plugin-react-hooks": "^4.5.0",
|
|
@@ -131,6 +131,7 @@
|
|
|
131
131
|
"flow-bin": "^0.200.1",
|
|
132
132
|
"flow-copy-source": "^2.0.9",
|
|
133
133
|
"flow-typed": "^3.9.0",
|
|
134
|
+
"hermes-eslint": "^0.17.0",
|
|
134
135
|
"history": "^4.0.0",
|
|
135
136
|
"husky": "^8.0.3",
|
|
136
137
|
"jest": "^29.7.0",
|
|
@@ -158,4 +158,13 @@ export const LayoutHintConfiguration = {
|
|
|
158
158
|
link: "",
|
|
159
159
|
component: ["attribute"],
|
|
160
160
|
},
|
|
161
|
+
HIDE_IN_USER_INTERFACE: {
|
|
162
|
+
hint: "hide-in-user-interface",
|
|
163
|
+
description: {
|
|
164
|
+
NL: "Verberg een link in de user interface.",
|
|
165
|
+
EN: "Hide a link in the user interface.",
|
|
166
|
+
},
|
|
167
|
+
link: "",
|
|
168
|
+
component: ["tab", "taskgroup"],
|
|
169
|
+
},
|
|
161
170
|
};
|
|
@@ -115,6 +115,11 @@ export const CASEVIEW_LINK: string = getHint("CASEVIEW_LINK");
|
|
|
115
115
|
*/
|
|
116
116
|
export const RENDER_SECTION_LABEL = "render-section-label";
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Layout-hint: Hide a link to a component
|
|
120
|
+
*/
|
|
121
|
+
export const HIDE_IN_USER_INTERFACE: string = getHint("HIDE_IN_USER_INTERFACE");
|
|
122
|
+
|
|
118
123
|
/**
|
|
119
124
|
*/
|
|
120
125
|
export const getLayoutHintConfiguration = (): Object => LayoutHintConfiguration;
|
|
@@ -16,7 +16,9 @@ export default class ActionCollection extends BaseCollection<ActionModel> {
|
|
|
16
16
|
const actionModels = [];
|
|
17
17
|
for (const actionData of actions) {
|
|
18
18
|
const actionContribution = actionsContributions.find(
|
|
19
|
-
(actionContribution) =>
|
|
19
|
+
(actionContribution) =>
|
|
20
|
+
actionContribution.name === actionData.name &&
|
|
21
|
+
actionContribution.type !== "service-operation",
|
|
20
22
|
);
|
|
21
23
|
|
|
22
24
|
if (actionContribution) {
|
|
@@ -37,7 +37,7 @@ describe("application", () => {
|
|
|
37
37
|
|
|
38
38
|
expect(application).toBeInstanceOf(ApplicationModel);
|
|
39
39
|
expect(application.label).toBe("Webapp");
|
|
40
|
-
expect(application.tabs.size).toBe(
|
|
40
|
+
expect(application.tabs.size).toBe(3);
|
|
41
41
|
expect(application.getInitialChildModelLinks()).toHaveLength(1);
|
|
42
42
|
expect(application.modelcatalog.label).toBe("Model catalog");
|
|
43
43
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import BaseFilterModel from "./BaseFilterModel";
|
|
3
2
|
|
|
4
3
|
import type { AttributeType, FilterType } from "../types";
|
|
4
|
+
import FilterModel from "./FilterModel";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* StringFilterModel can handle string filters with multiple setting
|
|
8
8
|
*/
|
|
9
|
-
export default class StringFilterModel extends
|
|
9
|
+
export default class StringFilterModel extends FilterModel {
|
|
10
10
|
_isValid: boolean = true;
|
|
11
11
|
_value: string | null;
|
|
12
12
|
_inputvalue: string;
|
|
@@ -93,6 +93,7 @@ describe("normalizeLinkJSON spec", () => {
|
|
|
93
93
|
name: "UTBookPrints",
|
|
94
94
|
label: "UT Book prints",
|
|
95
95
|
resourcetype: "Tab",
|
|
96
|
+
layouthint: ["hide-in-user-interface"],
|
|
96
97
|
},
|
|
97
98
|
{
|
|
98
99
|
name: "UsersAndOrganizations",
|
|
@@ -113,7 +114,7 @@ describe("normalizeLinkJSON spec", () => {
|
|
|
113
114
|
|
|
114
115
|
const output = normalizeLinkJSON(data, contributions);
|
|
115
116
|
|
|
116
|
-
expect(output).toHaveLength(
|
|
117
|
+
expect(output).toHaveLength(11);
|
|
117
118
|
});
|
|
118
119
|
|
|
119
120
|
it("should create an array of link json from caseview links", () => {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// @flow
|
|
2
|
+
import { HIDE_IN_USER_INTERFACE } from "../../constants";
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* Flatten JSON structure into a one dimensional array
|
|
4
6
|
* @private
|
|
5
7
|
*/
|
|
6
8
|
const createLink = (link: Object, linkKey: string) => {
|
|
7
|
-
const newLink = link;
|
|
9
|
+
const newLink = { ...link };
|
|
8
10
|
newLink.group = linkKey;
|
|
11
|
+
newLink.layouthint = link.layouthint ? [...link.layouthint] : [];
|
|
9
12
|
return newLink;
|
|
10
13
|
};
|
|
11
14
|
|
|
@@ -51,6 +54,9 @@ const flattenContributionsJSON = (json: Object) => {
|
|
|
51
54
|
if (!newLink.group) {
|
|
52
55
|
newLink.group = linkKey;
|
|
53
56
|
}
|
|
57
|
+
if (!newLink.layouthint) {
|
|
58
|
+
newLink.layouthint = [];
|
|
59
|
+
}
|
|
54
60
|
|
|
55
61
|
flattenedJSON.push(newLink);
|
|
56
62
|
}
|
|
@@ -90,16 +96,26 @@ const normalizeLinkJSON = (
|
|
|
90
96
|
data: link,
|
|
91
97
|
contributions: flattenedContributions.find(
|
|
92
98
|
(contr) => contr.name === link.name,
|
|
93
|
-
) || {
|
|
99
|
+
) || {
|
|
100
|
+
name: link.name,
|
|
101
|
+
label: link.name ?? "",
|
|
102
|
+
layouthint: link.layouthint ?? [],
|
|
103
|
+
},
|
|
94
104
|
})),
|
|
95
105
|
...filteredContributions.map((link) => ({
|
|
96
106
|
data: {
|
|
97
107
|
...link,
|
|
98
108
|
href: link.href || "",
|
|
99
109
|
},
|
|
100
|
-
contributions: {
|
|
110
|
+
contributions: {
|
|
111
|
+
name: link.name,
|
|
112
|
+
label: link.name ?? "",
|
|
113
|
+
layouthint: link.layouthint,
|
|
114
|
+
},
|
|
101
115
|
})),
|
|
102
|
-
]
|
|
116
|
+
].filter(
|
|
117
|
+
(link) => !link.contributions.layouthint.includes(HIDE_IN_USER_INTERFACE),
|
|
118
|
+
);
|
|
103
119
|
};
|
|
104
120
|
|
|
105
121
|
export default normalizeLinkJSON;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import TaskGroupModel from "../TaskGroupModel";
|
|
2
|
+
import ModularUIResponse from "../../../modularui/ModularUIResponse";
|
|
3
|
+
import mockTaskGroup from "./taskgroup.json";
|
|
4
|
+
import mockTaskGroupContributions from "./taskgroupContributions.json";
|
|
2
5
|
|
|
3
6
|
describe("taskGroupModel", () => {
|
|
4
7
|
it("should be able to create an empty Taskgroup mode", () => {
|
|
@@ -6,4 +9,18 @@ describe("taskGroupModel", () => {
|
|
|
6
9
|
|
|
7
10
|
expect(taskgroup).toBeInstanceOf(TaskGroupModel);
|
|
8
11
|
});
|
|
12
|
+
|
|
13
|
+
it("should create an application object with links an a label on a typical modular ui response", () => {
|
|
14
|
+
const data = ModularUIResponse.create({
|
|
15
|
+
key: "TaskGroup",
|
|
16
|
+
data: mockTaskGroup,
|
|
17
|
+
contributions: mockTaskGroupContributions,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const taskgroup = new TaskGroupModel(data);
|
|
21
|
+
|
|
22
|
+
expect(taskgroup).toBeInstanceOf(TaskGroupModel);
|
|
23
|
+
expect(taskgroup.label).toBe("General tasks");
|
|
24
|
+
expect(taskgroup.actionCollection.size).toBe(2);
|
|
25
|
+
});
|
|
9
26
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"taskgroup": {
|
|
3
|
+
"_links": {
|
|
4
|
+
"self": { "href": "/books/GeneralTasks" },
|
|
5
|
+
"api_doc": { "href": "/api-docs/v3/books/GeneralTasks" },
|
|
6
|
+
"contributions": { "href": "/contributions/books/GeneralTasks" }
|
|
7
|
+
},
|
|
8
|
+
"actions": [
|
|
9
|
+
{
|
|
10
|
+
"name": "CreatePersonRef",
|
|
11
|
+
"method": "POST",
|
|
12
|
+
"href": "/books/GeneralTasks/CreatePersonRef"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "UpdatePasswordOfCurrentUser_ref",
|
|
16
|
+
"method": "POST",
|
|
17
|
+
"href": "/books/GeneralTasks/UpdatePasswordOfCurrentUser_ref"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "ServiceOperation",
|
|
21
|
+
"href": "/service-operation/so/task"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"taskgroup": {
|
|
3
|
+
"label": "General tasks",
|
|
4
|
+
"resourcetype": "TaskGroup",
|
|
5
|
+
"actions": [
|
|
6
|
+
{
|
|
7
|
+
"name": "CreatePersonRef",
|
|
8
|
+
"label": "Create person",
|
|
9
|
+
"type": "form"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "UpdatePasswordOfCurrentUser_ref",
|
|
13
|
+
"label": "Update password of current user",
|
|
14
|
+
"type": "form"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "ServiceOperation",
|
|
18
|
+
"label": "Service Operation",
|
|
19
|
+
"type": "service-operation"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -50,6 +50,11 @@ const serverNoSSR = ({
|
|
|
50
50
|
beforeRenderHooks,
|
|
51
51
|
preloadApplication = true,
|
|
52
52
|
}: serverProps): string => {
|
|
53
|
+
const isPreviewCheck = request.getHeader("X-BI-Preview-Available");
|
|
54
|
+
if (isPreviewCheck) {
|
|
55
|
+
return "<h1>Preview Available</h1>";
|
|
56
|
+
}
|
|
57
|
+
|
|
53
58
|
const UUID = createUUID();
|
|
54
59
|
__webpack_nonce__ = UUID; // NOSONAR
|
|
55
60
|
|