@nuraly/runtime 0.1.7 → 0.1.8
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/README.md +83 -765
- package/components/ui/components/Event/EventValue/EventValue.ts +13 -8
- package/components/ui/components/ToastContainer/ToastContainer.ts +1 -1
- package/components/ui/components/advanced/AIChat/AIChat.ts +1 -2
- package/components/ui/components/advanced/Collapse/Collapse.ts +5 -2
- package/components/ui/components/advanced/Collections/Collections.ts +2 -2
- package/components/ui/components/advanced/MicroApp/MicroApp.ts +3 -11
- package/components/ui/components/advanced/RefComponent/RefComponent.ts +2 -2
- package/components/ui/components/advanced/RichText/RichText.ts +5 -4
- package/components/ui/components/advanced/RichText/RichTextEditor.ts +0 -167
- package/components/ui/components/base/BaseElement/base-change-detection.ts +1 -5
- package/components/ui/components/base/BaseElement.ts +229 -610
- package/components/ui/components/base/FormRegisterable.ts +83 -0
- package/components/ui/components/base/controllers/DragDropController.ts +175 -0
- package/components/ui/components/base/controllers/ErrorController.ts +180 -0
- package/components/ui/components/base/controllers/EventController.ts +112 -0
- package/components/ui/components/base/controllers/InputHandlerController.ts +298 -0
- package/components/ui/components/base/controllers/SelectionController.ts +323 -0
- package/components/ui/components/base/controllers/StyleHandlerController.ts +286 -0
- package/components/ui/components/base/controllers/index.ts +11 -0
- package/components/ui/components/base/mixins/EditorModeMixin.ts +185 -0
- package/components/ui/components/base/mixins/index.ts +6 -0
- package/components/ui/components/base/types/base-element.types.ts +138 -0
- package/components/ui/components/base/types/index.ts +21 -0
- package/components/ui/components/base/utils/event-debouncer.ts +209 -0
- package/components/ui/components/base/utils/index.ts +11 -0
- package/components/ui/components/base/utils/style-cache.ts +94 -0
- package/components/ui/components/display/BoxModel/BoxModel.ts +177 -116
- package/components/ui/components/display/Code/Code.ts +40 -26
- package/components/ui/components/display/Divider/Divider.ts +2 -2
- package/components/ui/components/display/Icon/Icon.ts +2 -3
- package/components/ui/components/display/Image/Image.ts +72 -46
- package/components/ui/components/display/Tag/Tag.ts +2 -3
- package/components/ui/components/display/Video/Video.ts +91 -31
- package/components/ui/components/inputs/Button/Button.ts +2 -2
- package/components/ui/components/inputs/Checkbox/Checkbox.ts +14 -40
- package/components/ui/components/inputs/ColorPicker/colorpicker.ts +3 -4
- package/components/ui/components/inputs/DatePicker/DatePicker.ts +47 -25
- package/components/ui/components/inputs/Dropdown/Dropdown.ts +2 -2
- package/components/ui/components/inputs/Form/Form.style.ts +26 -0
- package/components/ui/components/inputs/Form/Form.ts +352 -0
- package/components/ui/components/inputs/IconPicker/IconPicker.ts +22 -18
- package/components/ui/components/inputs/InsertDropdown/InsertDropdown.ts +0 -20
- package/components/ui/components/inputs/NumberInput/NumberInput.ts +0 -4
- package/components/ui/components/inputs/RadioButton/Radio-button.ts +11 -13
- package/components/ui/components/inputs/Select/Select.ts +38 -24
- package/components/ui/components/inputs/TextInput/TextInput.ts +15 -9
- package/components/ui/components/inputs/Textarea/Textarea.ts +30 -30
- package/components/ui/components/inputs/UsersDropdown/UsersDropdown.ts +1 -1
- package/components/ui/components/layout/Card/Card.ts +112 -10
- package/components/ui/components/layout/Containers/Container.style.ts +18 -0
- package/components/ui/components/layout/Containers/Container.ts +11 -5
- package/components/ui/components/layout/Grid/Col.style.ts +27 -0
- package/components/ui/components/layout/Grid/Col.ts +209 -0
- package/components/ui/components/layout/Grid/Row.style.ts +73 -0
- package/components/ui/components/layout/Grid/Row.ts +166 -0
- package/components/ui/components/layout/Grid/index.ts +7 -0
- package/components/ui/components/layout/Panel/Panel.ts +2 -2
- package/components/ui/components/layout/Tabs/Tabs.ts +0 -1
- package/components/ui/components/navigation/EmbedURL/EmbedURL.ts +62 -26
- package/components/ui/components/navigation/Link/Link.ts +27 -16
- package/components/ui/components/navigation/Menu/Menu.ts +26 -48
- package/components/ui/components/runtime/MicroApp/MicroApp.ts +7 -147
- package/components/ui/components/runtime/MicroApp/MicroAppDataLoader.ts +6 -2
- package/components/ui/components/studio/FunctionsPanel/FunctionsPanel.ts +472 -0
- package/components/ui/components/studio/FunctionsPanel/index.ts +1 -0
- package/components/ui/components/utility/AccessRoles/AccessRoles.style.ts +242 -0
- package/components/ui/components/utility/AccessRoles/AccessRoles.ts +476 -0
- package/components/ui/components/utility/Border/Border.ts +0 -14
- package/components/ui/components/utility/BorderManager/BorderManager.style.ts +237 -0
- package/components/ui/components/utility/BorderManager/BorderManager.ts +503 -0
- package/components/ui/components/utility/BoxShadow/BoxShadow.ts +0 -16
- package/components/ui/components/utility/Document/Document.ts +54 -25
- package/components/ui/components/utility/Export-Import/Export-Import.ts +8 -7
- package/components/ui/components/utility/Handlers/Handlers.ts +14 -17
- package/components/ui/components/utility/ValidationRules/ValidationRules.ts +440 -0
- package/components/ui/components/wrappers/GenerikWrapper/DragWrapper/DragWrapper.ts +1 -0
- package/components/ui/components/wrappers/GenerikWrapper/GenerikWrapper.ts +1 -24
- package/components/ui/nuraly-ui/src/components/badge/badge.style.ts +4 -3
- package/components/ui/nuraly-ui/src/components/datepicker/datepicker.component.ts +2 -0
- package/components/ui/nuraly-ui/src/components/radio-group/radio-group.component.ts +12 -6
- package/components/ui/nuraly-ui/src/components/radio-group/radio-group.style.ts +23 -0
- package/dist/{index-B4yIOSMd.js → BaseElement-BNBn_IJk.js} +2920 -267
- package/dist/{CodeEditor-YsOapSut.js → CodeEditor-Bf4L2rO_.js} +84127 -76319
- package/dist/{CodeEditor-BiNku87K.js → CodeEditor-Cpph-xRc.js} +7 -7
- package/dist/{abap-B2diVmjb.js → abap-D0Neqhq6.js} +91 -1
- package/dist/{apex-3NuJ-nsI.js → apex-B5LhxkeG.js} +18 -1
- package/dist/assets/editor.worker-DcwbJ0PV.js +12 -0
- package/dist/assets/html.worker-BTMxskjR.js +461 -0
- package/dist/assets/json.worker-D3vTGdf_.js +49 -0
- package/dist/assets/ts.worker-BsM1BXac.js +51334 -0
- package/dist/{azcli-XGXuUsMB.js → azcli-BrBH0QTU.js} +1 -1
- package/dist/{bat-B8Vhm634.js → bat-BfzAov64.js} +12 -1
- package/dist/{bicep-Cc8X5S_k.js → bicep-C3bCSWel.js} +1 -1
- package/dist/{cameligo-Bo3wBh9T.js → cameligo-sFL5plcd.js} +13 -1
- package/dist/{clojure-CPoQlpIK.js → clojure-CfeExRz0.js} +14 -1
- package/dist/{coffee-BxvTGz39.js → coffee-Xws5K0WL.js} +11 -1
- package/dist/{cpp-5RpEV7vC.js → cpp-CqOUEpxN.js} +28 -23
- package/dist/{csharp-slXXP3fo.js → csharp-DVLiBOZb.js} +13 -1
- package/dist/{csp-B98p6-gH.js → csp-DVFp9bw5.js} +3 -1
- package/dist/{css-BDsDSAin.js → css-DwARn2R6.js} +8 -1
- package/dist/cssMode-DMsdy1N0.js +1577 -0
- package/dist/{cypher-Dc4IMouD.js → cypher-uY0Mffat.js} +8 -1
- package/dist/{dart-LhvE3yD2.js → dart-D27H-mX_.js} +18 -1
- package/dist/{dockerfile-CwzplJeZ.js → dockerfile-CmV85WZK.js} +5 -1
- package/dist/{ecl-DxW3FiJi.js → ecl--fKn7yzB.js} +9 -1
- package/dist/{elixir-BI40g7TU.js → elixir-DUhH17ON.js} +87 -1
- package/dist/{flow9-tR2v0bGz.js → flow9-B3Dx2LLe.js} +8 -1
- package/dist/{freemarker2-Bfqhwyij.js → freemarker2-D51H9HYi.js} +359 -7
- package/dist/{fsharp-BLAma0OT.js → fsharp-SyqBfUAR.js} +14 -1
- package/dist/{go-nYcD3y4Z.js → go-BbMR2tdT.js} +17 -1
- package/dist/{graphql-Dp1cHWmP.js → graphql-DDJE6tIl.js} +17 -1
- package/dist/{handlebars-DCgKNBmn.js → handlebars-CF6gdAX4.js} +38 -4
- package/dist/{hcl-6NT8Kbna.js → hcl-YBvpaUqf.js} +13 -1
- package/dist/{html-C6wR7sMB.js → html-c2n_zkM3.js} +37 -4
- package/dist/htmlMode-9IJTuZUh.js +1587 -0
- package/dist/{ini-BZCOLrEc.js → ini-Ct73dBtM.js} +10 -1
- package/dist/{java-DAMcfJbX.js → java-C_jlkwoG.js} +18 -1
- package/dist/{javascript-D1L5MTmg.js → javascript-DhEEBMxD.js} +3 -2
- package/dist/jsonMode-CB6k-4rp.js +2002 -0
- package/dist/{julia-CQ46G71H.js → julia-D8WE5U1e.js} +22 -1
- package/dist/{kotlin-CEjVo_6E.js → kotlin-Zy9aq5yB.js} +15 -1
- package/dist/{less-DreV99nP.js → less-sZ0iHtE8.js} +1 -1
- package/dist/{lexon-DBVJhqLb.js → lexon-CsdNL29A.js} +13 -1
- package/dist/{liquid-D_pDYIs1.js → liquid-CwtPiwnW.js} +12 -4
- package/dist/{lua-Dcc_j6L-.js → lua-C2YJo0zw.js} +12 -1
- package/dist/{m3-B9SlZL4n.js → m3-CPLP40SG.js} +7 -1
- package/dist/{markdown-CuGw9_MP.js → markdown-B1mf5e0R.js} +34 -1
- package/dist/{mdx-CKsJ3cF4.js → mdx-LewPRYF8.js} +2 -2
- package/dist/{micro-app-entry-xdTX5-ut.js → micro-app-entry-C3RDIukG.js} +8082 -9628
- package/dist/micro-app.bundle.js +3 -3
- package/dist/micro-app.js +3585 -6759
- package/dist/{mips-BUWqP-OH.js → mips-DA33BZX1.js} +11 -1
- package/dist/{msdax-DtkouYCg.js → msdax-CCYFIQsP.js} +5 -1
- package/dist/{mysql-IkAsWSmF.js → mysql-hjmIjL-D.js} +11 -3
- package/dist/{objective-c-B2-ronfg.js → objective-c-RRCpEmqC.js} +2 -1
- package/dist/{pascal-Bsnz2eJA.js → pascal-CeV8XfxB.js} +13 -1
- package/dist/{pascaligo-D_sMUn0Q.js → pascaligo-IEEGVJAJ.js} +13 -1
- package/dist/{perl-BPzHt9SS.js → perl-B5-QbHq_.js} +34 -1
- package/dist/{pgsql-DlTJB0PD.js → pgsql-s6kqEJmi.js} +14 -4
- package/dist/{php-Dmq5OjwK.js → php-CWWqzOo8.js} +36 -1
- package/dist/{pla-HJcccrBy.js → pla-FSvb_YP_.js} +13 -1
- package/dist/{postiats-OQn6DKv-.js → postiats-DQdscQXO.js} +370 -1
- package/dist/{powerquery-DKaMYC8w.js → powerquery-CtA5JA1I.js} +7 -1
- package/dist/{powershell-DWeJHik1.js → powershell-DglEq96N.js} +13 -1
- package/dist/{protobuf-CBn_IseU.js → protobuf-BSepub3e.js} +5 -1
- package/dist/{pug-BoRpCINl.js → pug-B1847F4G.js} +16 -1
- package/dist/{python-zPpZYwLF.js → python-h5Z2g-yl.js} +59 -11
- package/dist/{qsharp-4rGyVZOw.js → qsharp-D4i0Nqg9.js} +28 -3
- package/dist/{r-DsgLhBOb.js → r-cdRigKxa.js} +5 -1
- package/dist/{razor-B_fCUeGX.js → razor-D5ep1Doy.js} +48 -4
- package/dist/{redis-B2fdL4Bg.js → redis-D9MFxvE8.js} +16 -6
- package/dist/{redshift-DoaeyCkH.js → redshift-CmCnsvL-.js} +13 -4
- package/dist/{restructuredtext-D-6OFBY9.js → restructuredtext-CWy8J51t.js} +19 -1
- package/dist/{ruby-D1DD6baV.js → ruby-WP-c36m5.js} +76 -3
- package/dist/runtime.js +34 -45
- package/dist/{rust-DssUV39M.js → rust-Q9FLdYpu.js} +13 -1
- package/dist/{sb-Dmb6tAdv.js → sb-C54-JBGT.js} +12 -1
- package/dist/{scala-Co3ETaym.js → scala-CzbFImc5.js} +24 -1
- package/dist/{scheme-CMrqXTty.js → scheme-BhfDmYN3.js} +1 -1
- package/dist/{scss-DkGudv8Q.js → scss-CEmiBXpS.js} +25 -1
- package/dist/{shell-BHN2BI4L.js → shell-Bmc1VhG0.js} +4 -1
- package/dist/{solidity-b-R-raGB.js → solidity-C9Q2I8Hh.js} +23 -1
- package/dist/{sophia-Y4GjyxNB.js → sophia-jWa1UyKz.js} +16 -1
- package/dist/{sparql-CDAPZb88.js → sparql-CM7jctbc.js} +15 -1
- package/dist/{sql-DkkpPiUq.js → sql-WzihTkbg.js} +42 -1
- package/dist/{st-CSPV91Ej.js → st-6y7_3aup.js} +8 -1
- package/dist/style.css +1 -1
- package/dist/{swift-DdSC5O48.js → swift-k-0zxG_D.js} +4 -1
- package/dist/{systemverilog-CI03XpAv.js → systemverilog-Pnr5_rIP.js} +29 -3
- package/dist/{tcl-B8DayMSI.js → tcl-fNPXval8.js} +7 -1
- package/dist/tsMode-B_6LiBE1.js +976 -0
- package/dist/{twig-B1AUPVB_.js → twig-L2MkztkV.js} +76 -1
- package/dist/{typescript-DrlYcCUn.js → typescript-BBG0jH4p.js} +23 -2
- package/dist/typespec-Cqqo-3Pt.js +123 -0
- package/dist/{vb-BIC7ccdG.js → vb-B5YC2xN9.js} +15 -1
- package/dist/{wgsl-C9yjop46.js → wgsl-D9BRtftY.js} +26 -1
- package/dist/{xml-BzP9D0eZ.js → xml-DgLB7rE6.js} +8 -2
- package/dist/{yaml-CT7GOvXu.js → yaml-DiI4HpSv.js} +30 -2
- package/handlers/compiler.ts +196 -16
- package/handlers/context-setup.ts +10 -5
- package/handlers/handler-api-factory.ts +358 -0
- package/handlers/handler-api.ts +379 -0
- package/handlers/handler-executor.ts +25 -5
- package/handlers/handler-scope.ts +398 -0
- package/handlers/index.ts +34 -2
- package/handlers/runtime-api/component-properties.ts +0 -8
- package/handlers/runtime-api/index.ts +1 -1
- package/handlers/runtime-api/toast.ts +1 -1
- package/index.ts +14 -115
- package/micro-app/README.md +10 -10
- package/micro-app/state/MicroAppRuntimeContext.ts +1 -28
- package/micro-app-entry.ts +0 -5
- package/package.json +19 -1
- package/redux/actions/application/index.ts +0 -1
- package/redux/actions/component/addComponentAction.ts +15 -4
- package/redux/actions/component/moveDraggedComponent.ts +1 -2
- package/redux/actions/component/update-component-name.ts +1 -1
- package/redux/actions/component/updateComponentAttributes.ts +7 -2
- package/redux/handlers/functions/build-function-handler.ts +11 -3
- package/redux/handlers/functions/deploy-function-handler.ts +11 -3
- package/redux/handlers/functions/invoke-function-handler.ts +11 -3
- package/redux/handlers/functions/load-functions-handler.ts +2 -1
- package/redux/handlers/functions/update-function-handler.ts +2 -1
- package/redux/store/component/component.interface.ts +8 -2
- package/redux/store/component/store.ts +1 -4
- package/state/runtime-context.ts +1 -23
- package/utils/RuntimeContextHelpers.ts +221 -90
- package/utils/change-detection.ts +125 -1
- package/utils/clipboard-utils.ts +18 -8
- package/utils/component-registry.ts +118 -0
- package/utils/index.ts +14 -1
- package/utils/naming-generator.ts +3 -1
- package/utils/randomness.ts +3 -1
- package/utils/register-components.ts +21 -29
- package/utils/render-util.ts +27 -48
- package/utils/toast.ts +97 -0
- package/vite.config.ts +29 -12
- package/components/ui/components/Event/EventAttribute/EventAttribute.style.ts +0 -11
- package/components/ui/components/Event/EventAttribute/EventAttribute.ts +0 -28
- package/components/ui/components/base/BaseElement/calculateStyles.ts +0 -31
- package/components/ui/components/base/BaseElement/drag-events.helpers.ts +0 -71
- package/components/ui/components/base/BaseElement/execute-event.helpers.ts +0 -45
- package/components/ui/components/base/BaseElement/interactions.helpers.ts +0 -14
- package/components/ui/components/wrappers/ComponentTitle/ComponentTitle.ts +0 -95
- package/components/ui/components/wrappers/GenerikWrapper/ResizeWrapper/ResizeWrapper.style.ts +0 -102
- package/components/ui/components/wrappers/GenerikWrapper/ResizeWrapper/ResizeWrapper.ts +0 -258
- package/components/ui/components/wrappers/PreviewWrapper.ts +0 -28
- package/components/ui/components/wrappers/RectangleSelection/RectangleSelection.ts +0 -154
- package/components/ui/nuraly-ui/packages/common/dist/constants/index.d.ts +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/constants/index.js +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/constants.d.ts +0 -17
- package/components/ui/nuraly-ui/packages/common/dist/constants.js +0 -7
- package/components/ui/nuraly-ui/packages/common/dist/controllers/index.d.ts +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/controllers/index.js +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/controllers.d.ts +0 -21
- package/components/ui/nuraly-ui/packages/common/dist/controllers.js +0 -22
- package/components/ui/nuraly-ui/packages/common/dist/index.d.ts +0 -25
- package/components/ui/nuraly-ui/packages/common/dist/index.js +0 -27
- package/components/ui/nuraly-ui/packages/common/dist/mixins/index.d.ts +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/mixins/index.js +0 -3
- package/components/ui/nuraly-ui/packages/common/dist/mixins.d.ts +0 -26
- package/components/ui/nuraly-ui/packages/common/dist/mixins.js +0 -29
- package/components/ui/nuraly-ui/packages/common/dist/shared/base-mixin.d.ts +0 -42
- package/components/ui/nuraly-ui/packages/common/dist/shared/base-mixin.js +0 -38
- package/components/ui/nuraly-ui/packages/common/dist/shared/constants.d.ts +0 -1
- package/components/ui/nuraly-ui/packages/common/dist/shared/constants.js +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/dropdown.controller.d.ts +0 -77
- package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/dropdown.controller.js +0 -341
- package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/dropdown.interface.d.ts +0 -37
- package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/dropdown.interface.js +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/index.d.ts +0 -4
- package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/index.js +0 -4
- package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/theme.controller.d.ts +0 -48
- package/components/ui/nuraly-ui/packages/common/dist/shared/controllers/theme.controller.js +0 -133
- package/components/ui/nuraly-ui/packages/common/dist/shared/dependency-mixin.d.ts +0 -37
- package/components/ui/nuraly-ui/packages/common/dist/shared/dependency-mixin.js +0 -141
- package/components/ui/nuraly-ui/packages/common/dist/shared/event-handler-mixin.d.ts +0 -64
- package/components/ui/nuraly-ui/packages/common/dist/shared/event-handler-mixin.js +0 -95
- package/components/ui/nuraly-ui/packages/common/dist/shared/index.d.ts +0 -13
- package/components/ui/nuraly-ui/packages/common/dist/shared/index.js +0 -17
- package/components/ui/nuraly-ui/packages/common/dist/shared/theme-mixin.d.ts +0 -78
- package/components/ui/nuraly-ui/packages/common/dist/shared/theme-mixin.js +0 -194
- package/components/ui/nuraly-ui/packages/common/dist/shared/themes.d.ts +0 -44
- package/components/ui/nuraly-ui/packages/common/dist/shared/themes.js +0 -85
- package/components/ui/nuraly-ui/packages/common/dist/shared/utils.d.ts +0 -60
- package/components/ui/nuraly-ui/packages/common/dist/shared/utils.js +0 -85
- package/components/ui/nuraly-ui/packages/common/dist/shared/validation.types.d.ts +0 -108
- package/components/ui/nuraly-ui/packages/common/dist/shared/validation.types.js +0 -17
- package/components/ui/nuraly-ui/packages/common/dist/themes/index.d.ts +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/themes/index.js +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/themes.d.ts +0 -22
- package/components/ui/nuraly-ui/packages/common/dist/themes.js +0 -23
- package/components/ui/nuraly-ui/packages/common/dist/utils/index.d.ts +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/utils/index.js +0 -2
- package/components/ui/nuraly-ui/packages/common/dist/utils.d.ts +0 -21
- package/components/ui/nuraly-ui/packages/common/dist/utils.js +0 -22
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/LICENSE +0 -15
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/README.md +0 -294
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/copy/copy-sync.js +0 -171
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/copy/copy.js +0 -175
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/copy/index.js +0 -7
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/empty/index.js +0 -39
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/file.js +0 -66
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/index.js +0 -23
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/link.js +0 -64
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/symlink-paths.js +0 -101
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/symlink-type.js +0 -34
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/ensure/symlink.js +0 -67
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/fs/index.js +0 -146
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/index.js +0 -16
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/json/index.js +0 -16
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/json/jsonfile.js +0 -11
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/json/output-json-sync.js +0 -12
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/json/output-json.js +0 -12
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/mkdirs/index.js +0 -14
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/mkdirs/make-dir.js +0 -27
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/mkdirs/utils.js +0 -21
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/move/index.js +0 -7
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/move/move-sync.js +0 -55
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/move/move.js +0 -59
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/output-file/index.js +0 -31
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/path-exists/index.js +0 -12
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/remove/index.js +0 -17
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/util/async.js +0 -29
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/util/stat.js +0 -159
- package/components/ui/nuraly-ui/packages/forms/node_modules/fs-extra/lib/util/utimes.js +0 -36
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/LICENSE +0 -15
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/README.md +0 -294
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/copy/copy-sync.js +0 -171
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/copy/copy.js +0 -175
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/copy/index.js +0 -7
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/empty/index.js +0 -39
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/file.js +0 -66
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/index.js +0 -23
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/link.js +0 -64
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/symlink-paths.js +0 -101
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/symlink-type.js +0 -34
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/ensure/symlink.js +0 -67
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/fs/index.js +0 -146
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/index.js +0 -16
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/json/index.js +0 -16
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/json/jsonfile.js +0 -11
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/json/output-json-sync.js +0 -12
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/json/output-json.js +0 -12
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/mkdirs/index.js +0 -14
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/mkdirs/make-dir.js +0 -27
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/mkdirs/utils.js +0 -21
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/move/index.js +0 -7
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/move/move-sync.js +0 -55
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/move/move.js +0 -59
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/output-file/index.js +0 -31
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/path-exists/index.js +0 -12
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/remove/index.js +0 -17
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/util/async.js +0 -29
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/util/stat.js +0 -159
- package/components/ui/nuraly-ui/packages/layout/node_modules/fs-extra/lib/util/utimes.js +0 -36
- package/dist/SmartAttributeHandler-C4EliaG0.js +0 -153
- package/dist/SmartAttributeHandler-u-ZHGueR.js +0 -193
- package/dist/assets/editor.worker-C_S4Avdt.js +0 -11
- package/dist/assets/html.worker-DfuQASUV.js +0 -458
- package/dist/assets/json.worker-Cucz4wxY.js +0 -42
- package/dist/assets/ts.worker-Dme6S0YK.js +0 -37021
- package/dist/cssMode-CqMQ6Xsa.js +0 -1443
- package/dist/htmlMode-KglxyZXm.js +0 -1453
- package/dist/jsonMode-B3rqxD-b.js +0 -1863
- package/dist/tsMode-DEiq8fQ0.js +0 -800
- package/redux/actions/application/loadApplicationPermissionAction.ts +0 -10
- package/utils/styleUtil.ts +0 -7
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import type { ComponentElement } from '../../../../../redux/store/component/component.interface.ts';
|
|
2
|
+
import { BaseElementBlock } from '../../base/BaseElement';
|
|
3
|
+
import { html, nothing } from "lit";
|
|
4
|
+
import { customElement, property, state } from "lit/decorators.js";
|
|
5
|
+
import { accessRolesStyles } from './AccessRoles.style';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ResourcePermission interface matching backend model
|
|
9
|
+
*/
|
|
10
|
+
interface _ResourcePermission {
|
|
11
|
+
id?: number;
|
|
12
|
+
resource_id: string;
|
|
13
|
+
resource_type: 'page' | 'component' | 'application';
|
|
14
|
+
grantee_type: 'user' | 'role' | 'public' | 'anonymous';
|
|
15
|
+
grantee_id: string | null;
|
|
16
|
+
permission: 'read' | 'write' | 'delete' | 'share';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* ApplicationRole interface matching backend model
|
|
21
|
+
*/
|
|
22
|
+
interface ApplicationRole {
|
|
23
|
+
id: number;
|
|
24
|
+
application_id: string | null;
|
|
25
|
+
name: string;
|
|
26
|
+
display_name: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
permissions: string[];
|
|
29
|
+
is_system: boolean;
|
|
30
|
+
hierarchy: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* System roles (from backend)
|
|
35
|
+
*/
|
|
36
|
+
const SYSTEM_ROLES: Omit<ApplicationRole, 'id' | 'application_id'>[] = [
|
|
37
|
+
{
|
|
38
|
+
name: 'owner',
|
|
39
|
+
display_name: 'Owner',
|
|
40
|
+
description: 'Full control, delete app, transfer ownership',
|
|
41
|
+
permissions: ['*'],
|
|
42
|
+
is_system: true,
|
|
43
|
+
hierarchy: 100
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'admin',
|
|
47
|
+
display_name: 'Administrator',
|
|
48
|
+
description: 'Manage members, edit app settings',
|
|
49
|
+
permissions: ['application:read', 'application:write', 'page:*', 'component:*', 'member:*'],
|
|
50
|
+
is_system: true,
|
|
51
|
+
hierarchy: 80
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'editor',
|
|
55
|
+
display_name: 'Editor',
|
|
56
|
+
description: 'Create/edit pages & components',
|
|
57
|
+
permissions: ['application:read', 'page:*', 'component:*', 'member:read'],
|
|
58
|
+
is_system: true,
|
|
59
|
+
hierarchy: 60
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'viewer',
|
|
63
|
+
display_name: 'Viewer',
|
|
64
|
+
description: 'Read-only access',
|
|
65
|
+
permissions: ['application:read', 'page:read', 'component:read', 'member:read'],
|
|
66
|
+
is_system: true,
|
|
67
|
+
hierarchy: 40
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const PERMISSION_OPTIONS = [
|
|
72
|
+
{ value: 'read', label: 'View', description: 'Can view the page' },
|
|
73
|
+
{ value: 'write', label: 'Edit', description: 'Can modify the page' },
|
|
74
|
+
{ value: 'delete', label: 'Delete', description: 'Can delete the page' },
|
|
75
|
+
{ value: 'share', label: 'Share', description: 'Can share access with others' }
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* AccessRoles Component
|
|
80
|
+
*
|
|
81
|
+
* A UI component for managing page access control.
|
|
82
|
+
* Displays public/anonymous access toggles and role-based permissions.
|
|
83
|
+
* Emits events for all actions - parent handles API calls.
|
|
84
|
+
*/
|
|
85
|
+
@customElement("access-roles-display")
|
|
86
|
+
export class AccessRolesDisplay extends BaseElementBlock {
|
|
87
|
+
static override styles = [accessRolesStyles];
|
|
88
|
+
|
|
89
|
+
@property({ type: Object })
|
|
90
|
+
component!: ComponentElement;
|
|
91
|
+
|
|
92
|
+
@state()
|
|
93
|
+
private customRoleName: string = '';
|
|
94
|
+
|
|
95
|
+
@state()
|
|
96
|
+
private selectedPermission: string = 'read';
|
|
97
|
+
|
|
98
|
+
@state()
|
|
99
|
+
private initialized: boolean = false;
|
|
100
|
+
|
|
101
|
+
@state()
|
|
102
|
+
private loadedPermissions: {
|
|
103
|
+
is_public: boolean;
|
|
104
|
+
is_anonymous: boolean;
|
|
105
|
+
role_permissions: any[];
|
|
106
|
+
} | null = null;
|
|
107
|
+
|
|
108
|
+
/** Track the last resource_id we loaded permissions for */
|
|
109
|
+
private lastLoadedResourceId: string | null = null;
|
|
110
|
+
|
|
111
|
+
override connectedCallback(): void {
|
|
112
|
+
super.connectedCallback();
|
|
113
|
+
|
|
114
|
+
this.registerCallback('value', (val: any) => {
|
|
115
|
+
if (val?.resource_id && val.resource_id !== this.lastLoadedResourceId) {
|
|
116
|
+
this.lastLoadedResourceId = val.resource_id;
|
|
117
|
+
this.loadPermissions();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
override disconnectedCallback(): void {
|
|
123
|
+
this.unregisterCallback('value');
|
|
124
|
+
super.disconnectedCallback();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Get the value input which contains resource config */
|
|
128
|
+
private getValueInput() {
|
|
129
|
+
return this.inputHandlersValue?.value || this.inputHandlersValue || {};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
override firstUpdated(): void {
|
|
133
|
+
const h = this.getValueInput();
|
|
134
|
+
if (h.resource_id && h.resource_id !== this.lastLoadedResourceId) {
|
|
135
|
+
this.lastLoadedResourceId = h.resource_id;
|
|
136
|
+
void this.loadPermissions();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
requestAnimationFrame(() => {
|
|
140
|
+
this.initialized = true;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private async loadPermissions() {
|
|
145
|
+
const h = this.getValueInput();
|
|
146
|
+
const resourceId = h.resource_id;
|
|
147
|
+
const resourceType = h.resource_type || 'page';
|
|
148
|
+
|
|
149
|
+
if (!resourceId) return;
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
const response = await fetch(`/api/resources/${resourceType}/${resourceId}/permissions`, {
|
|
153
|
+
method: 'GET',
|
|
154
|
+
headers: { 'Content-Type': 'application/json' },
|
|
155
|
+
credentials: 'include'
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
if (!response.ok) return;
|
|
159
|
+
|
|
160
|
+
const permissions = await response.json();
|
|
161
|
+
|
|
162
|
+
if (permissions && Array.isArray(permissions)) {
|
|
163
|
+
const is_public = permissions.some((p: any) => p.granteeType === 'public');
|
|
164
|
+
const is_anonymous = permissions.some((p: any) => p.granteeType === 'anonymous');
|
|
165
|
+
const role_permissions = permissions
|
|
166
|
+
.filter((p: any) => p.granteeType === 'role')
|
|
167
|
+
.map((p: any) => ({
|
|
168
|
+
role_name: p.granteeId,
|
|
169
|
+
permission: p.permission,
|
|
170
|
+
is_system: ['owner', 'admin', 'editor', 'viewer'].includes(p.granteeId)
|
|
171
|
+
}));
|
|
172
|
+
|
|
173
|
+
this.loadedPermissions = { is_public, is_anonymous, role_permissions };
|
|
174
|
+
}
|
|
175
|
+
} catch (error) {
|
|
176
|
+
console.error('Failed to load permissions:', error);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Public method to refresh permissions - called after changes */
|
|
181
|
+
public async refreshPermissions() {
|
|
182
|
+
await this.loadPermissions();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private emitChange(action: string, data: any) {
|
|
186
|
+
// Skip events during initialization to prevent API calls on first render
|
|
187
|
+
if (!this.initialized) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.executeEvent("onChange", new CustomEvent('change'), { action, ...data });
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
private getConfig() {
|
|
194
|
+
const h = this.getValueInput();
|
|
195
|
+
const loaded = this.loadedPermissions;
|
|
196
|
+
const config = {
|
|
197
|
+
resource_type: h.resource_type || 'page',
|
|
198
|
+
resource_id: h.resource_id,
|
|
199
|
+
is_public: loaded?.is_public ?? h.is_public ?? false,
|
|
200
|
+
is_anonymous: loaded?.is_anonymous ?? h.is_anonymous ?? false,
|
|
201
|
+
role_permissions: loaded?.role_permissions ?? h.role_permissions ?? [],
|
|
202
|
+
available_roles: h.available_roles || SYSTEM_ROLES.map((r, i) => ({ ...r, id: i + 1, application_id: null }))
|
|
203
|
+
};
|
|
204
|
+
return config;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
private async handlePublicToggle(checked: boolean) {
|
|
208
|
+
const h = this.getValueInput();
|
|
209
|
+
const resourceId = h.resource_id;
|
|
210
|
+
const resourceType = h.resource_type || 'page';
|
|
211
|
+
|
|
212
|
+
if (!resourceId) return;
|
|
213
|
+
|
|
214
|
+
const baseUrl = `/api/resources/${resourceType}/${resourceId}`;
|
|
215
|
+
// Use full permission format: resourceType:read
|
|
216
|
+
const permission = `${resourceType}:read`;
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
const response = checked
|
|
220
|
+
? await fetch(`${baseUrl}/make-public`, {
|
|
221
|
+
method: 'POST',
|
|
222
|
+
headers: { 'Content-Type': 'application/json' },
|
|
223
|
+
credentials: 'include',
|
|
224
|
+
body: JSON.stringify({ permission })
|
|
225
|
+
})
|
|
226
|
+
: await fetch(`${baseUrl}/make-public`, { method: 'DELETE', credentials: 'include' });
|
|
227
|
+
|
|
228
|
+
if (response.ok) await this.loadPermissions();
|
|
229
|
+
} catch (error) {
|
|
230
|
+
console.error('Failed to toggle public access:', error);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
this.emitChange('toggle_public', { is_public: checked, grantee_type: 'public', permission });
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private async handleAnonymousToggle(checked: boolean) {
|
|
237
|
+
const h = this.getValueInput();
|
|
238
|
+
const resourceId = h.resource_id;
|
|
239
|
+
const resourceType = h.resource_type || 'page';
|
|
240
|
+
|
|
241
|
+
if (!resourceId) return;
|
|
242
|
+
|
|
243
|
+
const baseUrl = `/api/resources/${resourceType}/${resourceId}`;
|
|
244
|
+
// Use full permission format: resourceType:action
|
|
245
|
+
// For functions, grant 'execute' permission; for other resources, grant 'read'
|
|
246
|
+
const action = resourceType === 'function' ? 'execute' : 'read';
|
|
247
|
+
const permission = `${resourceType}:${action}`;
|
|
248
|
+
|
|
249
|
+
try {
|
|
250
|
+
const response = checked
|
|
251
|
+
? await fetch(`${baseUrl}/make-anonymous`, {
|
|
252
|
+
method: 'POST',
|
|
253
|
+
headers: { 'Content-Type': 'application/json' },
|
|
254
|
+
credentials: 'include',
|
|
255
|
+
body: JSON.stringify({ permission })
|
|
256
|
+
})
|
|
257
|
+
: await fetch(`${baseUrl}/make-anonymous`, { method: 'DELETE', credentials: 'include' });
|
|
258
|
+
|
|
259
|
+
if (response.ok) await this.loadPermissions();
|
|
260
|
+
} catch (error) {
|
|
261
|
+
console.error('Failed to toggle anonymous access:', error);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
this.emitChange('toggle_anonymous', { is_anonymous: checked, grantee_type: 'anonymous', permission });
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private async addRolePermission(role: any) {
|
|
268
|
+
const config = this.getConfig();
|
|
269
|
+
if (config.role_permissions.some((rp: any) => rp.role_name === role.name)) return;
|
|
270
|
+
|
|
271
|
+
const h = this.getValueInput();
|
|
272
|
+
const resourceId = h.resource_id;
|
|
273
|
+
const resourceType = h.resource_type || 'page';
|
|
274
|
+
|
|
275
|
+
if (!resourceId) return;
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
await fetch(`/api/resources/${resourceType}/${resourceId}/role-permission`, {
|
|
279
|
+
method: 'POST',
|
|
280
|
+
headers: { 'Content-Type': 'application/json' },
|
|
281
|
+
credentials: 'include',
|
|
282
|
+
body: JSON.stringify({ roleName: role.name, permission: this.selectedPermission })
|
|
283
|
+
});
|
|
284
|
+
await this.loadPermissions();
|
|
285
|
+
} catch (error) {
|
|
286
|
+
console.error('Failed to add role permission:', error);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
this.emitChange('add_role_permission', {
|
|
290
|
+
grantee_type: 'role',
|
|
291
|
+
role_name: role.name,
|
|
292
|
+
role_id: role.id,
|
|
293
|
+
permission: this.selectedPermission,
|
|
294
|
+
is_system: role.is_system
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
private async addCustomRolePermission() {
|
|
299
|
+
if (!this.customRoleName.trim()) return;
|
|
300
|
+
const roleName = this.customRoleName.trim().toLowerCase();
|
|
301
|
+
const config = this.getConfig();
|
|
302
|
+
if (config.role_permissions.some((rp: any) => rp.role_name === roleName)) {
|
|
303
|
+
this.customRoleName = '';
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const h = this.getValueInput();
|
|
308
|
+
const resourceId = h.resource_id;
|
|
309
|
+
const resourceType = h.resource_type || 'page';
|
|
310
|
+
|
|
311
|
+
if (!resourceId) return;
|
|
312
|
+
|
|
313
|
+
try {
|
|
314
|
+
await fetch(`/api/resources/${resourceType}/${resourceId}/role-permission`, {
|
|
315
|
+
method: 'POST',
|
|
316
|
+
headers: { 'Content-Type': 'application/json' },
|
|
317
|
+
credentials: 'include',
|
|
318
|
+
body: JSON.stringify({ roleName, permission: this.selectedPermission })
|
|
319
|
+
});
|
|
320
|
+
await this.loadPermissions();
|
|
321
|
+
} catch (error) {
|
|
322
|
+
console.error('Failed to add custom role permission:', error);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
this.emitChange('add_role_permission', {
|
|
326
|
+
grantee_type: 'role',
|
|
327
|
+
role_name: roleName,
|
|
328
|
+
permission: this.selectedPermission,
|
|
329
|
+
is_system: false
|
|
330
|
+
});
|
|
331
|
+
this.customRoleName = '';
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
private async updateRolePermission(roleName: string, permission: string) {
|
|
335
|
+
const h = this.getValueInput();
|
|
336
|
+
const resourceId = h.resource_id;
|
|
337
|
+
const resourceType = h.resource_type || 'page';
|
|
338
|
+
|
|
339
|
+
if (!resourceId) return;
|
|
340
|
+
|
|
341
|
+
try {
|
|
342
|
+
// Delete existing then add new
|
|
343
|
+
await fetch(`/api/resources/${resourceType}/${resourceId}/role-permission/${encodeURIComponent(roleName)}`, {
|
|
344
|
+
method: 'DELETE',
|
|
345
|
+
credentials: 'include'
|
|
346
|
+
});
|
|
347
|
+
await fetch(`/api/resources/${resourceType}/${resourceId}/role-permission`, {
|
|
348
|
+
method: 'POST',
|
|
349
|
+
headers: { 'Content-Type': 'application/json' },
|
|
350
|
+
credentials: 'include',
|
|
351
|
+
body: JSON.stringify({ roleName, permission })
|
|
352
|
+
});
|
|
353
|
+
await this.loadPermissions();
|
|
354
|
+
} catch (error) {
|
|
355
|
+
console.error('Failed to update role permission:', error);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
this.emitChange('update_role_permission', { role_name: roleName, permission });
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
private async removeRolePermission(roleName: string) {
|
|
362
|
+
const h = this.getValueInput();
|
|
363
|
+
const resourceId = h.resource_id;
|
|
364
|
+
const resourceType = h.resource_type || 'page';
|
|
365
|
+
|
|
366
|
+
if (!resourceId) return;
|
|
367
|
+
|
|
368
|
+
try {
|
|
369
|
+
await fetch(`/api/resources/${resourceType}/${resourceId}/role-permission/${encodeURIComponent(roleName)}`, {
|
|
370
|
+
method: 'DELETE',
|
|
371
|
+
credentials: 'include'
|
|
372
|
+
});
|
|
373
|
+
await this.loadPermissions();
|
|
374
|
+
} catch (error) {
|
|
375
|
+
console.error('Failed to remove role permission:', error);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
this.emitChange('remove_role_permission', { role_name: roleName });
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
private renderAccessSummary() {
|
|
382
|
+
const config = this.getConfig();
|
|
383
|
+
if (config.is_anonymous) {
|
|
384
|
+
return html`<div class="access-summary"><div class="access-summary-title">Anyone can access</div><div class="access-summary-text">This page is accessible to everyone, including users who are not logged in.</div></div>`;
|
|
385
|
+
}
|
|
386
|
+
if (config.is_public) {
|
|
387
|
+
return html`<div class="access-summary"><div class="access-summary-title">Public with link</div><div class="access-summary-text">Anyone with the link can view this page.</div></div>`;
|
|
388
|
+
}
|
|
389
|
+
if (config.role_permissions.length > 0) {
|
|
390
|
+
const roleNames = config.role_permissions.map((rp: any) => rp.role_name).join(', ');
|
|
391
|
+
return html`<div class="access-summary"><div class="access-summary-title">Role-based access</div><div class="access-summary-text">Only users with these roles can access: ${roleNames}</div></div>`;
|
|
392
|
+
}
|
|
393
|
+
return html`<div class="info-box"><div class="info-box-title">Restricted</div><div class="info-box-text">This page is only accessible to application members.</div></div>`;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private renderRoleItem(rp: any) {
|
|
397
|
+
const systemRole = SYSTEM_ROLES.find(r => r.name === rp.role_name);
|
|
398
|
+
return html`
|
|
399
|
+
<div class="role-item">
|
|
400
|
+
<div class="role-info">
|
|
401
|
+
<div class="role-header">
|
|
402
|
+
<span class="role-name-badge ${rp.is_system ? 'system' : 'custom'}">${systemRole?.display_name || rp.role_name}</span>
|
|
403
|
+
<span class="role-type-tag">${rp.is_system ? 'system' : 'custom'}</span>
|
|
404
|
+
</div>
|
|
405
|
+
${systemRole?.description ? html`<div class="role-description">${systemRole.description}</div>` : nothing}
|
|
406
|
+
</div>
|
|
407
|
+
<div class="role-actions">
|
|
408
|
+
<nr-select class="permission-select" size="small" .value=${rp.permission} @nr-change=${(e: CustomEvent) => this.updateRolePermission(rp.role_name, e.detail?.value || 'read')}>
|
|
409
|
+
${PERMISSION_OPTIONS.map(opt => html`<nr-option value="${opt.value}">${opt.label}</nr-option>`)}
|
|
410
|
+
</nr-select>
|
|
411
|
+
<nr-button type="text" size="small" @click=${() => this.removeRolePermission(rp.role_name)}>×</nr-button>
|
|
412
|
+
</div>
|
|
413
|
+
</div>
|
|
414
|
+
`;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
override renderComponent() {
|
|
418
|
+
const config = this.getConfig();
|
|
419
|
+
const addedRoleNames = new Set(config.role_permissions.map((rp: any) => rp.role_name));
|
|
420
|
+
|
|
421
|
+
return html`
|
|
422
|
+
<div class="access-container">
|
|
423
|
+
${this.renderAccessSummary()}
|
|
424
|
+
|
|
425
|
+
<div class="section">
|
|
426
|
+
<div class="section-title">Public Access</div>
|
|
427
|
+
<div class="access-toggle-row ${config.is_anonymous ? 'active' : ''}">
|
|
428
|
+
<div class="toggle-content">
|
|
429
|
+
<div class="toggle-label">Anonymous Access</div>
|
|
430
|
+
<div class="toggle-description">Allow unauthenticated users (no login required)</div>
|
|
431
|
+
</div>
|
|
432
|
+
<nr-checkbox size="small" .checked=${config.is_anonymous} @nr-change=${(e: CustomEvent) => this.handleAnonymousToggle(e.detail?.checked || false)}></nr-checkbox>
|
|
433
|
+
</div>
|
|
434
|
+
<div class="access-toggle-row ${config.is_public && !config.is_anonymous ? 'active' : ''}">
|
|
435
|
+
<div class="toggle-content">
|
|
436
|
+
<div class="toggle-label">Public with Link</div>
|
|
437
|
+
<div class="toggle-description">Anyone with the page link can view</div>
|
|
438
|
+
</div>
|
|
439
|
+
<nr-checkbox size="small" .checked=${config.is_public} .disabled=${config.is_anonymous} @nr-change=${(e: CustomEvent) => this.handlePublicToggle(e.detail?.checked || false)}></nr-checkbox>
|
|
440
|
+
</div>
|
|
441
|
+
</div>
|
|
442
|
+
|
|
443
|
+
<div class="divider"></div>
|
|
444
|
+
|
|
445
|
+
<div class="section">
|
|
446
|
+
<div class="section-title">Role-Based Access</div>
|
|
447
|
+
<p class="info-text" style="margin-bottom: 12px;">Grant access to users based on their application role.</p>
|
|
448
|
+
${config.role_permissions.length > 0 ? html`<div class="roles-list">${config.role_permissions.map((rp: any) => this.renderRoleItem(rp))}</div>` : html`<div class="empty-state">No role-based permissions configured</div>`}
|
|
449
|
+
</div>
|
|
450
|
+
|
|
451
|
+
<div class="divider"></div>
|
|
452
|
+
|
|
453
|
+
<div class="section">
|
|
454
|
+
<div class="section-title">Add Role Permission</div>
|
|
455
|
+
<div class="select-row">
|
|
456
|
+
<span class="select-label">Permission:</span>
|
|
457
|
+
<nr-select size="small" .value=${this.selectedPermission} @nr-change=${(e: CustomEvent) => this.selectedPermission = e.detail?.value || 'read'}>
|
|
458
|
+
${PERMISSION_OPTIONS.map(opt => html`<nr-option value="${opt.value}">${opt.label} - ${opt.description}</nr-option>`)}
|
|
459
|
+
</nr-select>
|
|
460
|
+
</div>
|
|
461
|
+
<div class="section-title" style="margin-top: 12px;">System Roles</div>
|
|
462
|
+
<div class="preset-buttons">
|
|
463
|
+
${SYSTEM_ROLES.filter(role => !addedRoleNames.has(role.name)).map(role => html`<nr-button dashed size="small" @click=${() => this.addRolePermission({ ...role, id: 0, application_id: null })}>+ ${role.display_name}</nr-button>`)}
|
|
464
|
+
${SYSTEM_ROLES.every(role => addedRoleNames.has(role.name)) ? html`<span class="info-text">All system roles added</span>` : nothing}
|
|
465
|
+
</div>
|
|
466
|
+
<div class="section-title" style="margin-top: 12px;">Custom Role</div>
|
|
467
|
+
<div class="custom-role-input">
|
|
468
|
+
<nr-input size="small" .value=${this.customRoleName} placeholder="Enter custom role name..." @nr-input=${(e: CustomEvent) => this.customRoleName = e.detail?.value || ''} @keydown=${(e: KeyboardEvent) => e.key === 'Enter' && this.addCustomRolePermission()}></nr-input>
|
|
469
|
+
<nr-button size="small" @click=${() => this.addCustomRolePermission()}>Add</nr-button>
|
|
470
|
+
</div>
|
|
471
|
+
<p class="info-text">Custom roles must match roles defined in your application.</p>
|
|
472
|
+
</div>
|
|
473
|
+
</div>
|
|
474
|
+
`;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
@@ -5,20 +5,6 @@ import { customElement, property, state } from "lit/decorators.js";
|
|
|
5
5
|
import { executeHandler } from '../../../../../state/runtime-context';
|
|
6
6
|
import { getNestedAttribute } from '../../../../../utils/object.utils.ts';
|
|
7
7
|
import { styleMap } from "lit/directives/style-map.js";
|
|
8
|
-
|
|
9
|
-
// Safely import @nuralyui/slider-input
|
|
10
|
-
try {
|
|
11
|
-
await import("@nuralyui/slider-input");
|
|
12
|
-
} catch (error) {
|
|
13
|
-
console.warn('[@nuralyui/slider-input] Package not found or failed to load.');
|
|
14
|
-
}
|
|
15
|
-
// Safely import @nuralyui/color-picker
|
|
16
|
-
try {
|
|
17
|
-
await import("@nuralyui/color-picker");
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.warn('[@nuralyui/color-picker] Package not found or failed to load.');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
8
|
import {
|
|
23
9
|
SelectTheme,
|
|
24
10
|
SingleButtonTheme,
|