plugin-workflow-portainer 0.0.0-stage → 0.1.1

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.
Files changed (98) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +31 -3
  3. package/client-v2.js +1 -0
  4. package/client.js +1 -0
  5. package/dist/client/127.5012da93825a6e5c.js +10 -0
  6. package/dist/client/57.ace9538136438718.js +10 -0
  7. package/dist/client/65.ec4a55173511c06d.js +10 -0
  8. package/dist/client/660.546c702d1ddf7eff.js +10 -0
  9. package/dist/client/index.js +10 -0
  10. package/dist/client-v2/127.0ec4dce7b13750e9.js +10 -0
  11. package/dist/client-v2/57.e7cfc50fb651ac14.js +10 -0
  12. package/dist/client-v2/65.9c745ea32ac96e98.js +10 -0
  13. package/dist/client-v2/660.29ae3c3b4040039d.js +10 -0
  14. package/dist/client-v2/index.js +10 -0
  15. package/dist/externalVersion.js +20 -0
  16. package/dist/index.js +48 -0
  17. package/dist/locale/en-US.json +151 -0
  18. package/dist/locale/vi-VN.json +151 -0
  19. package/dist/locale/zh-CN.json +151 -0
  20. package/dist/node_modules/joi/dist/joi-browser.min.js +1 -0
  21. package/dist/node_modules/joi/lib/annotate.js +175 -0
  22. package/dist/node_modules/joi/lib/base.js +1069 -0
  23. package/dist/node_modules/joi/lib/cache.js +143 -0
  24. package/dist/node_modules/joi/lib/common.js +216 -0
  25. package/dist/node_modules/joi/lib/compile.js +283 -0
  26. package/dist/node_modules/joi/lib/errors.js +271 -0
  27. package/dist/node_modules/joi/lib/extend.js +312 -0
  28. package/dist/node_modules/joi/lib/index.d.ts +2365 -0
  29. package/dist/node_modules/joi/lib/index.js +1 -0
  30. package/dist/node_modules/joi/lib/manifest.js +476 -0
  31. package/dist/node_modules/joi/lib/messages.js +207 -0
  32. package/dist/node_modules/joi/lib/modify.js +267 -0
  33. package/dist/node_modules/joi/lib/ref.js +414 -0
  34. package/dist/node_modules/joi/lib/schemas.js +302 -0
  35. package/dist/node_modules/joi/lib/state.js +166 -0
  36. package/dist/node_modules/joi/lib/template.js +463 -0
  37. package/dist/node_modules/joi/lib/trace.js +346 -0
  38. package/dist/node_modules/joi/lib/types/alternatives.js +364 -0
  39. package/dist/node_modules/joi/lib/types/any.js +174 -0
  40. package/dist/node_modules/joi/lib/types/array.js +809 -0
  41. package/dist/node_modules/joi/lib/types/binary.js +100 -0
  42. package/dist/node_modules/joi/lib/types/boolean.js +150 -0
  43. package/dist/node_modules/joi/lib/types/date.js +233 -0
  44. package/dist/node_modules/joi/lib/types/function.js +93 -0
  45. package/dist/node_modules/joi/lib/types/keys.js +1084 -0
  46. package/dist/node_modules/joi/lib/types/link.js +184 -0
  47. package/dist/node_modules/joi/lib/types/number.js +363 -0
  48. package/dist/node_modules/joi/lib/types/object.js +22 -0
  49. package/dist/node_modules/joi/lib/types/string.js +850 -0
  50. package/dist/node_modules/joi/lib/types/symbol.js +102 -0
  51. package/dist/node_modules/joi/lib/validator.js +750 -0
  52. package/dist/node_modules/joi/lib/values.js +263 -0
  53. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.d.ts +60 -0
  54. package/dist/node_modules/joi/node_modules/@hapi/topo/lib/index.js +225 -0
  55. package/dist/node_modules/joi/node_modules/@hapi/topo/package.json +30 -0
  56. package/dist/node_modules/joi/package.json +1 -0
  57. package/dist/server/actions/portainer.js +192 -0
  58. package/dist/server/collections/portainer-instances.js +54 -0
  59. package/dist/server/index.js +54 -0
  60. package/dist/server/instructions/PortainerStackControlInstruction.js +156 -0
  61. package/dist/server/instructions/PortainerStackRedeployInstruction.js +254 -0
  62. package/dist/server/instructions/helpers.js +211 -0
  63. package/dist/server/plugin.js +170 -0
  64. package/dist/server/services/PortainerClient.js +497 -0
  65. package/dist/shared/collection.js +57 -0
  66. package/dist/shared/constants.js +66 -0
  67. package/dist/shared/env.js +221 -0
  68. package/dist/shared/types.js +24 -0
  69. package/package.json +50 -4
  70. package/server.js +1 -0
  71. package/src/client/index.tsx +50 -0
  72. package/src/client/instructions.tsx +76 -0
  73. package/src/client-v2/__tests__/workflow-registration.test.tsx +132 -0
  74. package/src/client-v2/components/ControlFieldset.tsx +46 -0
  75. package/src/client-v2/components/PortainerEnvEditor.tsx +223 -0
  76. package/src/client-v2/components/PortainerSettingsPage.tsx +671 -0
  77. package/src/client-v2/components/PortainerTargetFields.tsx +317 -0
  78. package/src/client-v2/components/RedeployFieldset.tsx +123 -0
  79. package/src/client-v2/index.tsx +50 -0
  80. package/src/client-v2/instructions.tsx +162 -0
  81. package/src/client-v2/locale.ts +24 -0
  82. package/src/index.ts +11 -0
  83. package/src/locale/en-US.json +151 -0
  84. package/src/locale/vi-VN.json +151 -0
  85. package/src/locale/zh-CN.json +151 -0
  86. package/src/server/__tests__/portainer-workflow.test.ts +455 -0
  87. package/src/server/actions/portainer.ts +196 -0
  88. package/src/server/collections/portainer-instances.ts +34 -0
  89. package/src/server/index.ts +13 -0
  90. package/src/server/instructions/PortainerStackControlInstruction.ts +139 -0
  91. package/src/server/instructions/PortainerStackRedeployInstruction.ts +255 -0
  92. package/src/server/instructions/helpers.ts +237 -0
  93. package/src/server/plugin.ts +167 -0
  94. package/src/server/services/PortainerClient.ts +589 -0
  95. package/src/shared/collection.ts +32 -0
  96. package/src/shared/constants.ts +25 -0
  97. package/src/shared/env.ts +228 -0
  98. package/src/shared/types.ts +105 -0
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (ii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -1,3 +1,31 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # plugin-workflow-portainer
2
+
3
+ NocoBase 2.x workflow integration (`client` v1, `client-v2`, and `server`) for orchestrating CI/CD builds, redeployments, and lifecycle controls on **Portainer** environments and stacks.
4
+
5
+ ## Features
6
+
7
+ - **Portainer Instance Management (`portainerInstances`)**:
8
+ - Store Portainer URLs and Personal Access Tokens (`X-API-Key`) encrypted at rest (`aesEncryptor`) and masked in API responses.
9
+ - Test connectivity (`GET /api/status` & `GET /api/endpoints`) and browse Environments + Stacks directly from Plugin Settings.
10
+ - Optional self-signed TLS support (`:9443`) and fallback Git credentials.
11
+ - **Workflow Node: `Run / Redeploy Stack` (`portainer-stack-redeploy`)**:
12
+ - Select **Portainer Instance → Environment (`endpointId`) → Stack (`stackId`)** via live cascading dropdowns or bind dynamic workflow variables (`{{...}}`).
13
+ - **Git-backed Stacks**: Triggers `PUT /api/stacks/{id}/git/redeploy?endpointId={endpointId}`, preserving existing Portainer `GitCredentialID` / repository settings while allowing optional branch/tag overrides (`gitReference`).
14
+ - **Separate Compose Deploy Stacks**: Automatically detects non-Git stacks, fetches `GET /api/stacks/{id}/file`, and updates via `PUT /api/stacks/{id}?endpointId={endpointId}` with optional `repullImage` and `prune` flags.
15
+ - **Stack Webhooks**: Supports triggering `/api/stacks/webhooks/{token}?tag=...` without exposing `X-API-Key`.
16
+ - **Full Environment Variable Control**: `Merge & override` (preserving existing Portainer Stack `Env` keys) or `Replace all`, one-click **Load Env from Stack**, Key–Value pairs with `Secret` log redaction, multi-line `.env` input, and dynamic JSON variables.
17
+ - **Asynchronous Settlement**: Runs as a non-blocking background workflow job and polls asynchronous Portainer deployments (`Status = 3` Deploying → `1` Active / `4` Error) before advancing downstream nodes.
18
+ - **Workflow Node: `Control / Inspect Stack` (`portainer-stack-control`)**:
19
+ - Supports **Inspect Stack & Health** (container running/total counts and Docker health states), **Start Stack**, and **Stop Stack**.
20
+
21
+ ## Build & Test
22
+
23
+ ```powershell
24
+ yarn test packages/plugins/plugin-workflow-portainer/src/server/__tests__/portainer-workflow.test.ts --run
25
+ yarn test packages/plugins/plugin-workflow-portainer/src/client-v2/__tests__/workflow-registration.test.tsx --run
26
+ yarn nocobase build plugin-workflow-portainer --no-dts
27
+ ```
28
+
29
+ ## License
30
+
31
+ Apache-2.0
package/client-v2.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client-v2/index.js');
package/client.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client/index.js');
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_workflow_portainer=self.webpackChunkplugin_workflow_portainer||[]).push([["127"],{42:function(e,t,n){n.d(t,{R:function(){return h},a:function(){return v}});var r=n(375),a=n(485),l=n(197),o=n(59),u=n(155),i=n.n(u),c=n(249),s=n(515);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r,a,l,o){try{var u=e[l](o),i=u.value}catch(e){n(e);return}u.done?t(i):Promise.resolve(i).then(r,a)}function m(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){d(l,r,a,o,u,"next",e)}function u(e){d(l,r,a,o,u,"throw",e)}o(void 0)})}}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,u=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){u=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(u)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(o,"next",{value:i(0)}),u(o,"throw",{value:i(1)}),u(o,"return",{value:i(2)}),"function"==typeof Symbol&&u(o,Symbol.iterator,{value:function(){return this}}),o;function i(u){return function(i){var c=[u,i];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function v(){var e=(0,s.kj)(),t=(0,a.useApp)().apiClient,n=p((0,u.useState)([]),2),r=n[0],f=n[1],d=p((0,u.useState)(!1),2),v=d[0],h=d[1],y=(0,u.useCallback)(function(){return m(function(){var e,n;return b(this,function(r){switch(r.label){case 0:h(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,t.request({url:"".concat(c.Yk,":listInstances"),method:"get"})];case 2:return f(Array.isArray(null==(n=r.sent())||null==(e=n.data)?void 0:e.data)?n.data.data:[]),[3,5];case 3:return r.sent(),f([]),[3,5];case 4:return h(!1),[7];case 5:return[2]}})})()},[t]);(0,u.useEffect)(function(){y()},[y]);var g=(0,u.useMemo)(function(){return r.map(function(t){return{value:t.id,label:t.isDefault?"".concat(t.name," (").concat(e("Default"),")"):t.name}})},[r,e]);return i().createElement(o.Form.Item,{name:["config","instanceId"],label:e("Portainer instance"),extra:e("Leave empty to use the default enabled Portainer instance, or bind a workflow variable.")},i().createElement(l.WorkflowVariableWrapper,{render:function(t){var n=t.value,r=t.onChange;return i().createElement(o.Select,{allowClear:!0,loading:v,value:"number"==typeof n?n:n?Number(n):void 0,onChange:function(e){return null==r?void 0:r("number"==typeof e?e:null)},options:g,placeholder:e("Default Portainer instance"),style:{width:"100%"}})}}))}function h(e){var t,n,f=e.onStackContextChange,d=(0,s.kj)(),h=(0,a.useApp)().apiClient,y=o.Form.useFormInstance(),g=o.Form.useWatch(["config","instanceId"],y),k=o.Form.useWatch(["config","endpointId"],y),w=o.Form.useWatch(["config","stackId"],y),E=(0,l.isWorkflowVariableValue)(g),S=(0,l.isWorkflowVariableValue)(k),I=(0,l.isWorkflowVariableValue)(w),C=E||null==g||""===g?void 0:Number(g),P=S||null==k||""===k?void 0:Number(k),j=I||null==w||""===w?void 0:Number(w),A=p((0,u.useState)([]),2),F=A[0],O=A[1],x=p((0,u.useState)([]),2),W=x[0],N=x[1],V=p((0,u.useState)(!1),2),D=V[0],R=V[1],T=p((0,u.useState)(!1),2),G=T[0],L=T[1],M=(0,u.useCallback)(function(){return m(function(){var e,t;return b(this,function(n){switch(n.label){case 0:if(E)return O([]),[2];R(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,h.request({url:"".concat(c.Yk,":listEndpoints"),method:"get",params:C?{instanceId:C}:{}})];case 2:return O(Array.isArray(null==(t=n.sent())||null==(e=t.data)?void 0:e.data)?t.data.data:[]),[3,5];case 3:return n.sent(),O([]),[3,5];case 4:return R(!1),[7];case 5:return[2]}})})()},[h,E,C]),q=(0,u.useCallback)(function(){return m(function(){var e,t;return b(this,function(n){switch(n.label){case 0:if(E||S)return N([]),[2];L(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,h.request({url:"".concat(c.Yk,":listStacks"),method:"get",params:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},C?{instanceId:C}:{},P?{endpointId:P}:{})})];case 2:return N(Array.isArray(null==(t=n.sent())||null==(e=t.data)?void 0:e.data)?t.data.data:[]),[3,5];case 3:return n.sent(),N([]),[3,5];case 4:return L(!1),[7];case 5:return[2]}})})()},[h,S,E,P,C]);(0,u.useEffect)(function(){M()},[M]),(0,u.useEffect)(function(){q()},[q]);var _=(0,u.useMemo)(function(){return j?W.find(function(e){return e.id===j}):void 0},[j,W]);(0,u.useEffect)(function(){null==f||f({instanceId:E?void 0:C,stack:I?void 0:_})},[E,C,f,_,I]);var U=(0,u.useMemo)(function(){return F.map(function(e){return{value:e.id,searchLabel:"".concat(e.name," ").concat(e.id),label:i().createElement(o.Flex,{align:"center",justify:"space-between",gap:"small"},i().createElement("span",null,e.name," (#",e.id,")"),i().createElement(o.Tag,{color:1===e.status?"success":"default",style:{marginInlineEnd:0}},1===e.status?d("Up"):d("Down")))}})},[F,d]),Y=(0,u.useMemo)(function(){return W.map(function(e){var t;return{value:e.id,searchLabel:"".concat(e.name," ").concat(e.id," ").concat(null!=(t=e.gitReference)?t:""),label:i().createElement(o.Flex,{align:"center",justify:"space-between",gap:"small"},i().createElement("span",null,e.name," (#",e.id,")"),i().createElement("span",null,i().createElement(o.Tag,{color:e.isGitStack?"processing":"purple"},e.isGitStack?d("Git Stack"):d("Compose")),e.gitReference?i().createElement(o.Tag,{style:{marginInlineEnd:0}},e.gitReference.replace(/^refs\/heads\//,"")):null))}})},[W,d]);return i().createElement(i().Fragment,null,i().createElement(v,null),i().createElement(o.Form.Item,{name:["config","endpointId"],label:d("Environment (Endpoint)"),extra:d("Select a Portainer environment or bind a dynamic endpointId variable.")},i().createElement(l.WorkflowVariableWrapper,{render:function(e){var t=e.value,n=e.onChange;return E?i().createElement(o.InputNumber,{min:1,value:"number"==typeof t?t:t?Number(t):void 0,onChange:function(e){return null==n?void 0:n("number"==typeof e?e:null)},placeholder:d("Endpoint ID (e.g. 1)"),style:{width:"100%"}}):i().createElement(o.Flex,{gap:"small",style:{width:"100%"}},i().createElement(o.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"searchLabel",loading:D,value:"number"==typeof t?t:t?Number(t):void 0,onChange:function(e){return null==n?void 0:n("number"==typeof e?e:null)},options:U,placeholder:d("Auto-resolve from Stack or select environment"),style:{flex:1,minWidth:0}}),i().createElement(o.Button,{htmlType:"button","aria-label":d("Refresh Portainer environments"),icon:i().createElement(r.ReloadOutlined,null),loading:D,onClick:function(){M(),q()}}))}})),i().createElement(o.Form.Item,{name:["config","stackId"],label:d("Target Stack"),rules:[{required:!0,message:d("Please select a Stack or bind a Stack ID variable")}],extra:(null==_?void 0:_.isGitStack)?"".concat(d("Connected Git repository"),": ").concat(null!=(t=_.gitRepoUrl)?t:"-"," (").concat(null!=(n=_.gitReference)?n:"refs/heads/main",")"):d("Choose the Portainer Stack to control or bind a stackId variable from upstream data.")},i().createElement(l.WorkflowVariableWrapper,{render:function(e){var t=e.value,n=e.onChange;return E||S?i().createElement(o.InputNumber,{min:1,value:"number"==typeof t?t:t?Number(t):void 0,onChange:function(e){return null==n?void 0:n("number"==typeof e?e:null)},placeholder:d("Stack ID (e.g. 12)"),style:{width:"100%"}}):i().createElement(o.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"searchLabel",loading:G,value:"number"==typeof t?t:t?Number(t):void 0,onChange:function(e){var t="number"==typeof e?e:null;if(null==n||n(t),t&&!P){var r=W.find(function(e){return e.id===t});(null==r?void 0:r.endpointId)&&y.setFieldValue(["config","endpointId"],r.endpointId)}},options:Y,placeholder:d("Select Portainer Stack"),style:{width:"100%"}})}})))}}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_workflow_portainer=self.webpackChunkplugin_workflow_portainer||[]).push([["57"],{632:function(e,t,r){r.d(t,{RedeployFieldset:function(){return y}});var n=r(197),a=r(59),l=r(155),o=r.n(l),i=r(249),c=r(515),u=r(375),m=r(485);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,l,o){try{var i=e[l](o),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,a)}function p(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(e,t)}}function b(e){var t,r,b=e.stackContext,d=(0,c.kj)(),v=(0,m.useApp)().apiClient,y=a.Form.useFormInstance(),g=function(e){if(Array.isArray(e))return e}(t=(0,l.useState)(!1))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a=[],l=!0,o=!1;try{for(n=n.call(e);!(l=(t=n.next()).done)&&(a.push(t.value),2!==a.length);l=!0);}catch(e){o=!0,r=e}finally{try{l||null==n.return||n.return()}finally{if(o)throw r}}return a}}(t)||p(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),h=g[0],k=g[1],E=!!(null==b||null==(r=b.stack)?void 0:r.id);return o().createElement(o().Fragment,null,o().createElement(a.Form.Item,{name:["config","envStrategy"],label:d("Environment merge strategy"),initialValue:"merge",extra:d("Merge keeps existing Portainer Stack variables intact and overrides matching keys; Replace overwrites the entire Stack Env list.")},o().createElement(a.Radio.Group,{options:[{value:"merge",label:d("Merge & override existing Stack Env")},{value:"replace",label:d("Replace all Stack Env")}]})),o().createElement(a.Form.Item,{label:o().createElement(a.Flex,{align:"center",justify:"space-between",gap:"middle",style:{width:"100%"}},o().createElement("span",null,d("Environment variables (Key-Value)")),E?o().createElement(a.Button,{size:"small",htmlType:"button",icon:o().createElement(u.CloudDownloadOutlined,null),loading:h,onClick:function(){var e;return(e=function(){var e,t,r,n,l,o,c,u,m,f,g,h,E,w,S,I,x,A,O,F;return function(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&u[0]?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,n=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],n=0}finally{r=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(P){var j,C;switch(P.label){case 0:if(!(t=null==b||null==(e=b.stack)?void 0:e.id))return[2];k(!0),P.label=1;case 1:return P.trys.push([1,3,4,5]),[4,v.request({url:"".concat(i.Yk,":getStackDetail"),method:"get",params:(j=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},(null==b?void 0:b.instanceId)?{instanceId:b.instanceId}:{}),C=C={stackId:t,includeValues:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(j,Object.getOwnPropertyDescriptors(C)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(C)).forEach(function(e){Object.defineProperty(j,e,Object.getOwnPropertyDescriptor(C,e))}),j)})];case 2:c=Array.isArray(null==(o=P.sent())||null==(l=o.data)||null==(n=l.data)?void 0:n.env)?o.data.data.env:[],m=new Set((u=null!=(r=y.getFieldValue(["config","envPairs"]))?r:[]).map(function(e){var t;return String(null!=(t=null==e?void 0:e.name)?t:"").trim()}).filter(Boolean)),f=0,g=0,h=function(e){if(Array.isArray(e))return s(e)}(u)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(u)||p(u)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),E=!0,w=!1,S=void 0;try{for(I=c[Symbol.iterator]();!(E=(x=I.next()).done);E=!0)if(A=x.value,!(!(F=String(null!=(O=A.name)?O:"").trim())||m.has(F))){if(A.sensitive){g+=1;continue}h.push({name:F,value:A.value,secret:!1}),m.add(F),f+=1}}catch(e){w=!0,S=e}finally{try{E||null==I.return||I.return()}finally{if(w)throw S}}return y.setFieldValue(["config","envPairs"],h),g>0?a.message.info(d("Loaded {{count}} variables ({{sensitive}} sensitive keys stay preserved on Portainer in Merge mode)",{count:f,sensitive:g})):a.message.success(d("Loaded {{count}} variables from Portainer Stack",{count:f})),[3,5];case 3:return P.sent(),a.message.error(d("Failed to load environment variables from Portainer Stack")),[3,5];case 4:return k(!1),[7];case 5:return[2]}})},function(){var t=this,r=arguments;return new Promise(function(n,a){var l=e.apply(t,r);function o(e){f(l,n,a,o,i,"next",e)}function i(e){f(l,n,a,o,i,"throw",e)}o(void 0)})})()}},d("Load Env from Stack")):null),extra:d("Add variables such as IMAGE_TAG or runtime settings. Mark sensitive values as Secret to redact them in workflow execution logs.")},o().createElement(a.Form.List,{name:["config","envPairs"]},function(e,t){var r=t.add,l=t.remove;return o().createElement(a.Space,{direction:"vertical",style:{display:"flex"}},e.map(function(e,t){var r,i=String(null!=(r=y.getFieldValue(["config","envPairs",e.name,"name"]))?r:"").trim(),c=i?"".concat(d("Delete environment variable")," ").concat(i):"".concat(d("Delete environment variable")," #").concat(t+1);return o().createElement(a.Flex,{key:e.key,align:"center",gap:"small",wrap:"wrap",style:{width:"100%"}},o().createElement(a.Form.Item,{name:[e.name,"name"],style:{flex:"1 1 160px",marginBottom:0}},o().createElement(a.Input,{placeholder:"IMAGE_TAG",autoCorrect:"off",autoCapitalize:"none",spellCheck:!1})),o().createElement(a.Form.Item,{name:[e.name,"value"],style:{flex:"2 1 220px",marginBottom:0}},o().createElement(n.WorkflowVariableInput,{placeholder:d("Value or {{variable}}")})),o().createElement(a.Form.Item,{name:[e.name,"secret"],valuePropName:"checked",initialValue:!1,style:{marginBottom:0}},o().createElement(a.Checkbox,null,d("Secret"))),o().createElement(a.Button,{htmlType:"button","aria-label":c,icon:o().createElement(u.DeleteOutlined,null),onClick:function(){return l(e.name)}}))}),o().createElement(a.Button,{htmlType:"button",icon:o().createElement(u.PlusOutlined,null),onClick:function(){return r({name:"",value:"",secret:!1})},style:{width:"100%"}},d("Add environment variable")))})),o().createElement(a.Collapse,{size:"small",style:{marginBottom:16},items:[{key:"bulk-env",label:d("Bulk .env text & dynamic JSON environment"),children:o().createElement(o().Fragment,null,o().createElement(a.Form.Item,{name:["config","envText"],label:d("Bulk .env format"),extra:d("Enter KEY=VALUE lines. Supports upstream workflow variables.")},o().createElement(n.WorkflowVariableTextArea,{autoSize:{minRows:3,maxRows:8},placeholder:"IMAGE_TAG=v1.0.0\nNODE_ENV=production"})),o().createElement(a.Form.Item,{name:["config","dynamicEnv"],label:d("Dynamic environment JSON / variable"),extra:d('Pass a JSON object {"KEY":"VAL"}, an array [{"name":"KEY","value":"VAL"}], or a workflow variable from a build catalog record.'),style:{marginBottom:0}},o().createElement(n.WorkflowVariableJsonTextArea,{autoSize:{minRows:2,maxRows:6},placeholder:'{"IMAGE_TAG": "{{$context.data.imageTag}}"}'})))}]}))}var d=r(42);function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function y(){var e,t,r,u=(0,c.kj)(),m=a.Form.useFormInstance(),s=null!=(t=a.Form.useWatch(["config","mode"],m))?t:"stack",f=function(e){if(Array.isArray(e))return e}(e=(0,l.useState)({}))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a=[],l=!0,o=!1;try{for(n=n.call(e);!(l=(t=n.next()).done)&&(a.push(t.value),2!==a.length);l=!0);}catch(e){o=!0,r=e}finally{try{l||null==n.return||n.return()}finally{if(o)throw r}}return a}}(e)||function(e){if(e){if("string"==typeof e)return v(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return v(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=f[0],y=f[1];return o().createElement(o().Fragment,null,o().createElement(a.Form.Item,{name:["config","mode"],label:u("Execution mode"),initialValue:"stack",extra:u("Use Stack API to control Environment, Stack, Git branch, and full Env variables; use Stack Webhook when triggering an unauthenticated Portainer webhook UUID.")},o().createElement(a.Radio.Group,{options:[{value:"stack",label:u("Stack API (Git / Compose)")},{value:"webhook",label:u("Stack Webhook")}]})),"webhook"===s?o().createElement(o().Fragment,null,o().createElement(d.a,null),o().createElement(a.Form.Item,{name:["config","webhookId"],label:u("Stack Webhook token"),rules:[{required:!0,message:u("Webhook token is required")}],extra:u("The UUID at the end of /api/stacks/webhooks/<token>.")},o().createElement(n.WorkflowVariableInput,{placeholder:"638e6967-ef77-4906-8af8-236800621360"})),o().createElement(a.Form.Item,{name:["config","webhookTag"],label:u("Image tag override (optional)"),extra:u("Appends ?tag=<value> when triggering a Portainer Stack webhook.")},o().createElement(n.WorkflowVariableInput,{placeholder:"latest"}))):o().createElement(o().Fragment,null,o().createElement(d.R,{onStackContextChange:y}),o().createElement(a.Form.Item,{name:["config","gitReference"],label:u("Git branch / tag override (optional)"),extra:u("Leave empty to keep the Git reference already configured on Portainer (e.g. refs/heads/main), or pass a branch/tag such as main or refs/tags/v1.2.0.")},o().createElement(n.WorkflowVariableInput,{placeholder:(null==(r=p.stack)?void 0:r.gitReference)||"refs/heads/main"})),o().createElement(a.Form.Item,{name:["config","repullImage"],valuePropName:"checked",initialValue:!1,extra:u("Enable when deploying a separate Stack so Portainer pulls the newly built image from your registry.")},o().createElement(a.Checkbox,null,u("Force pull / repull latest images"))),o().createElement(a.Form.Item,{name:["config","prune"],valuePropName:"checked",initialValue:!1},o().createElement(a.Checkbox,null,u("Prune orphan services on redeploy"))),o().createElement(b,{stackContext:p})),o().createElement(a.Form.Item,{name:["config","timeoutMs"],label:u("Request timeout"),initialValue:i.t1,extra:u("Increase timeout for Stacks that run long Dockerfile builds during git/redeploy.")},o().createElement(n.WorkflowVariableWrapper,{render:function(e){var t=e.value,r=e.onChange;return o().createElement(a.InputNumber,{min:i.SU,max:i.mn,step:5e3,addonAfter:u("ms"),value:"number"==typeof t?t:t?Number(t):i.t1,onChange:function(e){return null==r?void 0:r("number"==typeof e?e:null)},style:{width:"100%"}})}})),o().createElement(a.Form.Item,{name:["config","ignoreFail"],valuePropName:"checked",initialValue:!1},o().createElement(a.Checkbox,null,u("Ignore failed execution and continue workflow"))))}}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_workflow_portainer=self.webpackChunkplugin_workflow_portainer||[]).push([["65"],{168:function(e,t,n){n.r(t),n.d(t,{PortainerSettingsPage:function(){return h}});var r=n(375),a=n(485),l=n(59),o=n(155),c=n.n(o),s=n(249),i=n(515);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,a,l,o){try{var c=e[l](o),s=c.value}catch(e){n(e);return}c.done?t(s):Promise.resolve(s).then(r,a)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){m(l,r,a,o,c,"next",e)}function c(e){m(l,r,a,o,c,"throw",e)}o(void 0)})}}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,c=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){c=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(c)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(o,"next",{value:s(0)}),c(o,"throw",{value:s(1)}),c(o,"return",{value:s(2)}),"function"==typeof Symbol&&c(o,Symbol.iterator,{value:function(){return this}}),o;function s(c){return function(s){var i=[c,s];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return l.label++,{value:i[1],done:!1};case 5:l.label++,r=i[1],i=[0];continue;case 7:i=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){l=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){l.label=i[1];break}if(6===i[0]&&l.label<a[1]){l.label=a[1],a=i;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(i);break}a[2]&&l.ops.pop(),l.trys.pop();continue}i=t.call(e,l)}catch(e){i=[6,e],r=0}finally{n=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}function h(){var e=(0,i.kj)(),t=(0,a.useApp)().apiClient,n=f(l.Form.useForm(),1)[0],u=f((0,o.useState)([]),2),m=u[0],h=u[1],b=f((0,o.useState)(!1),2),g=b[0],E=b[1],v=f((0,o.useState)(!1),2),k=v[0],w=v[1],C=f((0,o.useState)(null),2),S=C[0],I=C[1],P=f((0,o.useState)(!1),2),T=P[0],O=P[1],A=f((0,o.useState)(!1),2),x=A[0],F=A[1],B=f((0,o.useState)(null),2),D=B[0],j=B[1],U=f((0,o.useState)(null),2),z=U[0],q=U[1],G=f((0,o.useState)([]),2),R=G[0],N=G[1],K=f((0,o.useState)(void 0),2),L=K[0],M=K[1],V=f((0,o.useState)([]),2),Z=V[0],_=V[1],Y=f((0,o.useState)(!1),2),H=Y[0],X=Y[1],Q=(0,o.useCallback)(function(){return d(function(){var n,r;return y(this,function(a){switch(a.label){case 0:E(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,t.request({url:"".concat(s.Z3,":list"),method:"get",params:{pageSize:100,sort:["-isDefault","id"]}})];case 2:return h(Array.isArray(null==(r=a.sent())||null==(n=r.data)?void 0:n.data)?r.data.data:[]),[3,5];case 3:return a.sent(),l.message.error(e("Failed to load Portainer instances")),[3,5];case 4:return E(!1),[7];case 5:return[2]}})})()},[t,e]);(0,o.useEffect)(function(){Q()},[Q]);var W=function(e){var t,r,a;I(e),n.setFieldsValue({name:e.name,baseUrl:e.baseUrl,apiKey:e.apiKey||s.Q6,gitCredentialId:null!=(t=e.gitCredentialId)?t:void 0,gitUsername:null!=(r=e.gitUsername)?r:"",gitAccessToken:e.gitAccessToken||"",allowInsecureTls:!!e.allowInsecureTls,defaultTimeoutMs:null!=(a=e.defaultTimeoutMs)?a:s.t1,isDefault:!!e.isDefault,enabled:!1!==e.enabled}),w(!0)},$=(0,o.useCallback)(function(n,r){return d(function(){var a,o,c,i,u;return y(this,function(m){switch(m.label){case 0:X(!0),m.label=1;case 1:return m.trys.push([1,3,4,5]),[4,Promise.all([t.request({url:"".concat(s.Yk,":listEndpoints"),method:"get",params:{instanceId:n}}),t.request({url:"".concat(s.Yk,":listStacks"),method:"get",params:p({instanceId:n},r?{endpointId:r}:{})})])];case 2:return i=(c=f.apply(void 0,[m.sent(),2]))[0],u=c[1],N(Array.isArray(null==i||null==(a=i.data)?void 0:a.data)?i.data.data:[]),_(Array.isArray(null==u||null==(o=u.data)?void 0:o.data)?u.data.data:[]),[3,5];case 3:return m.sent(),l.message.error(e("Failed to load environments and stacks from Portainer")),[3,5];case 4:return X(!1),[7];case 5:return[2]}})})()},[t,e]),J=function(e){q(e),M(void 0),$(e.id,void 0)},ee=[{title:e("Name"),dataIndex:"name",key:"name",render:function(t,n){return c().createElement(l.Space,null,c().createElement(l.Typography.Text,{strong:!0},t),n.isDefault?c().createElement(l.Tag,{color:"blue"},e("Default")):null)}},{title:e("Base URL"),dataIndex:"baseUrl",key:"baseUrl",render:function(e){return c().createElement(l.Typography.Text,{code:!0},e)}},{title:e("Health & Version"),key:"health",render:function(t,n){return n.lastHealthStatus?"ok"===n.lastHealthStatus?c().createElement(l.Space,{size:"small"},c().createElement(l.Tag,{color:"success",icon:c().createElement(r.CheckCircleOutlined,null)},e("Connected")),n.lastVersion?c().createElement(l.Typography.Text,{type:"secondary"},"v",n.lastVersion):null):c().createElement(l.Tag,{color:"error"},e("Unreachable")):c().createElement(l.Tag,null,e("Not tested"))}},{title:e("Enabled"),dataIndex:"enabled",key:"enabled",width:100,render:function(n,r){return c().createElement(l.Switch,{checked:!1!==n,"aria-label":"".concat(e("Toggle Portainer instance")," ").concat(r.name),onChange:function(n){d(function(){return y(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,t.request({url:"".concat(s.Z3,":update"),method:"post",params:{filterByTk:r.id},data:{enabled:n}})];case 1:return a.sent(),[4,Q()];case 2:return a.sent(),[3,4];case 3:return a.sent(),l.message.error(e("Failed to update status")),[3,4];case 4:return[2]}})})()}})}},{title:e("Actions"),key:"actions",width:300,render:function(n,a){return c().createElement(l.Space,{size:"small",wrap:!0},c().createElement(l.Button,{size:"small",htmlType:"button",icon:c().createElement(r.ApiOutlined,null),loading:D===a.id,"aria-label":"".concat(e("Test connection")," ").concat(a.name),onClick:function(){d(function(){var n,r,o,c,i;return y(this,function(u){switch(u.label){case 0:j(a.id),u.label=1;case 1:return u.trys.push([1,4,6,7]),[4,t.request({url:"".concat(s.Yk,":testConnection"),method:"post",params:{filterByTk:a.id}})];case 2:return i=null==(c=u.sent())||null==(o=c.data)?void 0:o.data,l.message.success(e("Connected to Portainer v{{version}} ({{count}} environments found)",{version:null!=(n=null==i?void 0:i.version)?n:"unknown",count:null!=(r=null==i?void 0:i.endpointCount)?r:0})),[4,Q()];case 3:case 5:return u.sent(),[3,7];case 4:return u.sent(),l.message.error(e("Connection test failed")),[4,Q()];case 6:return j(null),[7];case 7:return[2]}})})()}},e("Test")),c().createElement(l.Button,{size:"small",htmlType:"button",icon:c().createElement(r.AppstoreOutlined,null),"aria-label":"".concat(e("Browse Stacks")," ").concat(a.name),onClick:function(){return J(a)}},e("Stacks")),c().createElement(l.Button,{size:"small",htmlType:"button",icon:c().createElement(r.EditOutlined,null),"aria-label":"".concat(e("Edit Portainer instance")," ").concat(a.name),onClick:function(){return W(a)}}),c().createElement(l.Popconfirm,{title:e("Delete this Portainer instance?"),onConfirm:function(){return d(function(){return y(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,t.request({url:"".concat(s.Z3,":destroy"),method:"post",params:{filterByTk:a.id}})];case 1:return n.sent(),l.message.success(e("Portainer instance deleted")),[4,Q()];case 2:return n.sent(),[3,4];case 3:return n.sent(),l.message.error(e("Failed to delete Portainer instance")),[3,4];case 4:return[2]}})})()}},c().createElement(l.Button,{size:"small",danger:!0,htmlType:"button",icon:c().createElement(r.DeleteOutlined,null),"aria-label":"".concat(e("Delete Portainer instance")," ").concat(a.name)})))}}],et=[{title:e("ID"),dataIndex:"id",key:"id",width:72},{title:e("Stack Name"),dataIndex:"name",key:"name",render:function(e){return c().createElement(l.Typography.Text,{strong:!0},e)}},{title:e("Endpoint"),dataIndex:"endpointId",key:"endpointId",width:130,render:function(e){var t=R.find(function(t){return t.id===e});return t?"".concat(t.name," (#").concat(e,")"):"#".concat(e)}},{title:e("Source"),key:"source",render:function(t,n){return c().createElement(l.Space,{size:"small",wrap:!0},c().createElement(l.Tag,{color:n.isGitStack?"processing":"purple"},n.isGitStack?e("Git Stack"):e("Compose")),n.gitReference?c().createElement(l.Typography.Text,{code:!0},n.gitReference):null)}},{title:e("Status"),dataIndex:"status",key:"status",width:110,render:function(t){return 3===t?c().createElement(l.Tag,{color:"processing"},e("Deploying")):4===t?c().createElement(l.Tag,{color:"error"},e("Error")):c().createElement(l.Tag,{color:1===t?"success":"default"},1===t?e("Active"):e("Inactive"))}},{title:e("Env Vars"),dataIndex:"envCount",key:"envCount",width:90}];return c().createElement(l.Card,{title:e("Portainer Instances"),extra:c().createElement(l.Space,null,c().createElement(l.Button,{htmlType:"button",icon:c().createElement(r.ReloadOutlined,null),loading:g,onClick:function(){Q()}},e("Refresh")),c().createElement(l.Button,{type:"primary",htmlType:"button",icon:c().createElement(r.PlusOutlined,null),onClick:function(){I(null),n.resetFields(),n.setFieldsValue({defaultTimeoutMs:s.t1,allowInsecureTls:!1,isDefault:0===m.length,enabled:!0}),w(!0)}},e("Add Portainer instance")))},c().createElement(l.Alert,{type:"info",showIcon:!0,style:{marginBottom:16},message:e("Configure Portainer servers with an Access Token (X-API-Key). Workflow nodes can select Environments and Stacks directly or receive dynamic IDs and Env variables from upstream build catalogs.")}),c().createElement(l.Table,{rowKey:"id",loading:g,dataSource:m,columns:ee,pagination:!1}),c().createElement(l.Modal,{open:k,title:S?e("Edit Portainer instance"):e("Add Portainer instance"),onCancel:function(){return w(!1)},destroyOnClose:!0,width:620,footer:c().createElement(l.Flex,{justify:"space-between",align:"center"},c().createElement(l.Button,{htmlType:"button",icon:c().createElement(r.ApiOutlined,null),loading:x,onClick:function(){d(function(){var r,a,o,c,i,u;return y(this,function(m){switch(m.label){case 0:if(!(r=n.getFieldsValue()).baseUrl)return l.message.warning(e("Please enter a Portainer base URL first")),[2];F(!0),m.label=1;case 1:var d,f;return m.trys.push([1,3,4,5]),[4,t.request({url:"".concat(s.Yk,":testConnectionDraft"),method:"post",data:(d=p({},r),f=f={id:null==S?void 0:S.id},Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(f)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(f)).forEach(function(e){Object.defineProperty(d,e,Object.getOwnPropertyDescriptor(f,e))}),d)})];case 2:return u=null==(i=m.sent())||null==(c=i.data)?void 0:c.data,l.message.success(e("Connected to Portainer v{{version}} ({{count}} environments found)",{version:null!=(a=null==u?void 0:u.version)?a:"unknown",count:null!=(o=null==u?void 0:u.endpointCount)?o:0})),[3,5];case 3:return m.sent(),l.message.error(e("Connection test failed. Check URL, API key, and TLS settings.")),[3,5];case 4:return F(!1),[7];case 5:return[2]}})})()}},e("Test connection")),c().createElement(l.Space,null,c().createElement(l.Button,{htmlType:"button",onClick:function(){return w(!1)}},e("Cancel")),c().createElement(l.Button,{type:"primary",htmlType:"button",loading:T,onClick:function(){d(function(){var r,a,o;return y(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),[4,n.validateFields()];case 1:return r=c.sent(),[3,3];case 2:return c.sent(),[2];case 3:O(!0),c.label=4;case 4:if(c.trys.push([4,10,11,12]),!S)return[3,6];return[4,t.request({url:"".concat(s.Z3,":update"),method:"post",params:{filterByTk:S.id},data:r})];case 5:return c.sent(),l.message.success(e("Portainer instance updated")),[3,8];case 6:return[4,t.request({url:"".concat(s.Z3,":create"),method:"post",data:r})];case 7:c.sent(),l.message.success(e("Portainer instance created")),c.label=8;case 8:return w(!1),[4,Q()];case 9:return c.sent(),[3,12];case 10:var i,u;return i=a=c.sent(),o=(null!=(u=Error)&&"u">typeof Symbol&&u[Symbol.hasInstance]?!!u[Symbol.hasInstance](i):i instanceof u)?a.message:e("Failed to save Portainer instance"),l.message.error(o),[3,12];case 11:return O(!1),[7];case 12:return[2]}})})()}},e("Save"))))},c().createElement(l.Form,{form:n,layout:"vertical"},c().createElement(l.Form.Item,{name:"name",label:e("Instance name"),rules:[{required:!0,message:e("Instance name is required")}]},c().createElement(l.Input,{placeholder:"Portainer Production"})),c().createElement(l.Form.Item,{name:"baseUrl",label:e("Portainer base URL"),rules:[{required:!0,message:e("Base URL is required")}],extra:e("Example: https://portainer.internal:9443")},c().createElement(l.Input,{placeholder:"https://portainer.example.com:9443",autoCorrect:"off",autoCapitalize:"none",spellCheck:!1})),c().createElement(l.Form.Item,{name:"apiKey",label:e("Portainer API key (X-API-Key)"),rules:[{required:!S,message:e("API key is required")}],extra:e("Generated under Portainer -> My account -> Access tokens. Encrypted at rest.")},c().createElement(l.Input.Password,{placeholder:"ptr_...",autoComplete:"new-password",autoCorrect:"off",autoCapitalize:"none",spellCheck:!1})),c().createElement(l.Flex,{gap:"middle",wrap:"wrap"},c().createElement(l.Form.Item,{name:"defaultTimeoutMs",label:e("Default build/redeploy timeout (ms)"),style:{flex:"1 1 240px"}},c().createElement(l.InputNumber,{min:s.SU,max:s.mn,step:5e3,style:{width:"100%"}}))),c().createElement(l.Space,{size:"large",wrap:!0,style:{marginBottom:16}},c().createElement(l.Form.Item,{name:"isDefault",valuePropName:"checked",style:{marginBottom:0}},c().createElement(l.Checkbox,null,e("Set as default instance"))),c().createElement(l.Form.Item,{name:"allowInsecureTls",valuePropName:"checked",style:{marginBottom:0}},c().createElement(l.Checkbox,null,e("Allow self-signed TLS certificate (:9443)"))),c().createElement(l.Form.Item,{name:"enabled",valuePropName:"checked",style:{marginBottom:0}},c().createElement(l.Checkbox,null,e("Enabled")))),c().createElement(l.Collapse,{size:"small",items:[{key:"git-fallback",label:e("Optional Git authentication fallback (when Stack has no saved GitCredentialID)"),children:c().createElement(c().Fragment,null,c().createElement(l.Form.Item,{name:"gitCredentialId",label:e("Portainer saved Git Credential ID (optional)"),extra:e("Automatically detected from each Git Stack when present; set here only to supply a default ID.")},c().createElement(l.InputNumber,{min:1,style:{width:"100%"}})),c().createElement(l.Form.Item,{name:"gitUsername",label:e("Fallback Git username (optional)")},c().createElement(l.Input,{autoCorrect:"off",autoCapitalize:"none",spellCheck:!1,placeholder:"oauth2"})),c().createElement(l.Form.Item,{name:"gitAccessToken",label:e("Fallback Git Personal Access Token (optional)"),style:{marginBottom:0}},c().createElement(l.Input.Password,{autoComplete:"new-password",autoCorrect:"off",autoCapitalize:"none",spellCheck:!1})))}]}))),c().createElement(l.Drawer,{open:!!z,title:z?"".concat(e("Portainer Stacks")," — ").concat(z.name):e("Portainer Stacks"),onClose:function(){return q(null)},width:780},c().createElement(l.Flex,{gap:"small",align:"center",style:{marginBottom:16}},c().createElement(l.Select,{allowClear:!0,style:{width:280},placeholder:e("All environments (Endpoints)"),value:L,options:R.map(function(e){return{value:e.id,label:"".concat(e.name," (#").concat(e.id,")")}}),onChange:function(e){M(e),z&&$(z.id,e)}}),c().createElement(l.Button,{htmlType:"button",icon:c().createElement(r.ReloadOutlined,null),loading:H,onClick:function(){z&&$(z.id,L)}},e("Refresh"))),c().createElement(l.Table,{rowKey:"id",size:"small",loading:H,dataSource:Z,columns:et,pagination:{pageSize:15}})))}t.default=h}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_workflow_portainer=self.webpackChunkplugin_workflow_portainer||[]).push([["660"],{943:function(e,t,n){n.d(t,{ControlFieldset:function(){return i}});var a=n(59),l=n(155),r=n.n(l),o=n(515),c=n(42);function i(){var e=(0,o.kj)();return r().createElement(r().Fragment,null,r().createElement(a.Form.Item,{name:["config","action"],label:e("Stack operation"),initialValue:"inspect",extra:e("Inspect retrieves Stack status, current Env keys, and container health without restarting services; Start and Stop control the Stack lifecycle.")},r().createElement(a.Radio.Group,{options:[{value:"inspect",label:e("Inspect Stack & Health")},{value:"start",label:e("Start Stack")},{value:"stop",label:e("Stop Stack")}]})),r().createElement(c.R,null),r().createElement(a.Form.Item,{name:["config","ignoreFail"],valuePropName:"checked",initialValue:!1},r().createElement(a.Checkbox,null,e("Ignore failed execution and continue workflow"))))}}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("@nocobase/plugin-workflow/client-v2"),require("@nocobase/client"),require("antd"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client")):"function"==typeof define&&define.amd?define("plugin-workflow-portainer",["@nocobase/client-v2","react","@nocobase/plugin-workflow/client-v2","@nocobase/client","antd","@ant-design/icons","@nocobase/plugin-workflow/client"],t):"object"==typeof exports?exports["plugin-workflow-portainer"]=t(require("@nocobase/client-v2"),require("react"),require("@nocobase/plugin-workflow/client-v2"),require("@nocobase/client"),require("antd"),require("@ant-design/icons"),require("@nocobase/plugin-workflow/client")):e["plugin-workflow-portainer"]=t(e["@nocobase/client-v2"],e.react,e["@nocobase/plugin-workflow/client-v2"],e["@nocobase/client"],e.antd,e["@ant-design/icons"],e["@nocobase/plugin-workflow/client"])}(self,function(e,t,n,r,o,i,a){return function(){"use strict";var u,c,l,f={515:function(e,t,n){n.d(t,{MZ:function(){return a},kj:function(){return u}});var r=n(485),o=n(155),i=n(249).kc,a=function(e){return'{{t("'.concat(e,'", { ns: "').concat(i,'" })}}')};function u(){var e=(0,r.useApp)();return(0,o.useCallback)(function(t,n){return e.i18n.t(t,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({ns:[i,"client"]},n))},[e.i18n])}},249:function(e,t,n){n.d(t,{DQ:function(){return u},Q6:function(){return l},SU:function(){return s},Yk:function(){return i},Z3:function(){return o},fD:function(){return c},im:function(){return a},kc:function(){return r},mn:function(){return p},t1:function(){return f}});var r="plugin-workflow-portainer",o="portainerInstances",i="portainerWorkflow",a="pm.plugin-workflow-portainer",u="portainer",c={redeploy:"portainer-stack-redeploy",control:"portainer-stack-control"},l="••••••••",f=6e5,s=1e3,p=36e5},375:function(e){e.exports=i},342:function(e){e.exports=r},485:function(t){t.exports=e},990:function(e){e.exports=a},197:function(e){e.exports=n},59:function(e){e.exports=o},155:function(e){e.exports=t}},s={};function p(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return f[e](n,n.exports,p),n.exports}p.m=f,p.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return p.d(t,{a:t}),t},p.d=function(e,t){for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.f={},p.e=function(e){return Promise.all(Object.keys(p.f).reduce(function(t,n){return p.f[n](e,t),t},[]))},p.u=function(e){return""+e+"."+({127:"5012da93825a6e5c",57:"ace9538136438718",65:"ec4a55173511c06d",660:"546c702d1ddf7eff"})[e]+".js"},p.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),p.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},d={},p.l=function(e,t,n,r){if(d[e])return void d[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var c=a[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="plugin-workflow-portainer:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,p.nc&&o.setAttribute("nonce",p.nc),o.setAttribute("data-rspack","plugin-workflow-portainer:"+n),o.src=e),d[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(f);var r=d[e];if(delete d[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=l.bind(null,o.onerror),o.onload=l.bind(null,o.onload),i&&document.head.appendChild(o)},p.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},p.g.importScripts&&(b=p.g.location+"");var d,b,y=p.g.document;if(!b&&y&&(y.currentScript&&"SCRIPT"===y.currentScript.tagName.toUpperCase()&&(b=y.currentScript.src),!b)){var g=y.getElementsByTagName("script");if(g.length)for(var v=g.length-1;v>-1&&(!b||!/^http(s?):/.test(b));)b=g[v--].src}if(!b)throw Error("Automatic publicPath is not supported in this browser");p.p=b.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),u={889:0},p.f.j=function(e,t){var n=p.o(u,e)?u[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=u[e]=[t,r]});t.push(n[2]=r);var o=p.p+p.u(e),i=Error();p.l(o,function(t){if(p.o(u,e)&&(0!==(n=u[e])&&(u[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},c=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],c=0;if(o.some(function(e){return 0!==u[e]})){for(n in i)p.o(i,n)&&(p.m[n]=i[n]);a&&a(p)}for(e&&e(t);c<o.length;c++)r=o[c],p.o(u,r)&&u[r]&&u[r][0](),u[r]=0},(l=self.webpackChunkplugin_workflow_portainer=self.webpackChunkplugin_workflow_portainer||[]).forEach(c.bind(null,0)),l.push=c.bind(null,l.push.bind(l));var m={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/plugin-workflow-portainer/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/plugin-workflow-portainer/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",u=a.indexOf(i);e=u>=0?a.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/plugin-workflow-portainer/dist/client/"}p.p=e}(),!function(){p.r(m),p.d(m,{PluginWorkflowPortainerClient:function(){return I},default:function(){return T}});var e=p(342),t=p(155),n=p.n(t),r=p(249),o={name:r.Z3,title:"Portainer Instances",hidden:!0,fields:[{name:"id",type:"bigInt",autoIncrement:!0,primaryKey:!0},{name:"name",type:"string"},{name:"baseUrl",type:"string"},{name:"apiKey",type:"text"},{name:"gitUsername",type:"string"},{name:"gitAccessToken",type:"text"},{name:"gitCredentialId",type:"integer"},{name:"allowInsecureTls",type:"boolean",defaultValue:!1},{name:"defaultTimeoutMs",type:"integer",defaultValue:r.t1},{name:"isDefault",type:"boolean",defaultValue:!1},{name:"enabled",type:"boolean",defaultValue:!0},{name:"lastHealthStatus",type:"string"},{name:"lastVersion",type:"string"},{name:"lastCheckedAt",type:"date"}]},i=p(375),a=p(990),u=p(197),c=p(515);function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){l(e,t,n[t])})}return e}function s(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function d(e,t,n){var r,o,i;return l(i={},null!=(r=e.value)?r:u.defaultFieldNames.value,t),l(i,null!=(o=e.label)?o:u.defaultFieldNames.label,n),i}function b(e,t,n){return t=w(t),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e,S()?Reflect.construct(t,n||[],w(e).constructor):t.apply(e,n))}function y(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function g(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function v(e,t,n){return t&&g(e.prototype,t),n&&g(e,n),e}function h(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function k(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&O(e,t)}function O(e,t){return(O=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(S=function(){return!!e})()}var j=function(e){function t(){var e;return y(this,t),e=b(this,t,arguments),h(e,"type",r.fD.redeploy),h(e,"title",(0,c.MZ)("Run / Redeploy Stack")),h(e,"description",(0,c.MZ)("Pull Git changes, build compose services, or redeploy a Portainer Stack with full environment variable control.")),h(e,"group",r.DQ),h(e,"icon",n().createElement(i.CloudUploadOutlined,null)),h(e,"testable",!0),h(e,"FieldsetLoader",function(){return Promise.all([p.e("127"),p.e("57")]).then(p.bind(p,632)).then(function(e){return{default:e.RedeployFieldset}})}),e}return k(t,e),v(t,[{key:"createDefaultConfig",value:function(){return{mode:"stack",envStrategy:"merge",repullImage:!1,prune:!1,envPairs:[],timeoutMs:r.t1,ignoreFail:!1}}},{key:"useVariables",value:function(e,t){return function(e){var t,n=e.key,r=e.title,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.fieldNames,a=void 0===i?u.defaultFieldNames:i,p=null!=(t=a.children)?t:u.defaultFieldNames.children;return s(f({},d(a,n,r)),l({},p,[d(a,"ok",(0,c.MZ)("Succeeded")),d(a,"stackId",(0,c.MZ)("Stack ID")),d(a,"stackName",(0,c.MZ)("Stack name")),d(a,"endpointId",(0,c.MZ)("Environment (Endpoint) ID")),d(a,"stackType",(0,c.MZ)("Stack type")),d(a,"stackStatus",(0,c.MZ)("Stack status")),d(a,"gitReference",(0,c.MZ)("Git reference")),d(a,"appliedEnv",(0,c.MZ)("Applied environment (masked)")),d(a,"appliedEnvCount",(0,c.MZ)("Applied variable count")),d(a,"healthy",(0,c.MZ)("Containers healthy")),d(a,"runningCount",(0,c.MZ)("Running containers")),d(a,"totalCount",(0,c.MZ)("Total containers")),d(a,"durationMs",(0,c.MZ)("Duration (ms)")),d(a,"startedAt",(0,c.MZ)("Started at")),d(a,"finishedAt",(0,c.MZ)("Finished at")),d(a,"errorMessage",(0,c.MZ)("Error message"))]))}(e,t)}}]),t}(a.Instruction),M=function(e){function t(){var e;return y(this,t),e=b(this,t,arguments),h(e,"type",r.fD.control),h(e,"title",(0,c.MZ)("Control / Inspect Stack")),h(e,"description",(0,c.MZ)("Inspect Stack container health, start, or stop a Portainer Stack in an environment.")),h(e,"group",r.DQ),h(e,"icon",n().createElement(i.ClusterOutlined,null)),h(e,"testable",!0),h(e,"FieldsetLoader",function(){return Promise.all([p.e("127"),p.e("660")]).then(p.bind(p,943)).then(function(e){return{default:e.ControlFieldset}})}),e}return k(t,e),v(t,[{key:"createDefaultConfig",value:function(){return{action:"inspect",ignoreFail:!1}}},{key:"useVariables",value:function(e,t){return function(e){var t,n=e.key,r=e.title,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=o.fieldNames,a=void 0===i?u.defaultFieldNames:i,p=null!=(t=a.children)?t:u.defaultFieldNames.children;return s(f({},d(a,n,r)),l({},p,[d(a,"ok",(0,c.MZ)("Succeeded")),d(a,"action",(0,c.MZ)("Executed action")),d(a,"stackId",(0,c.MZ)("Stack ID")),d(a,"stackName",(0,c.MZ)("Stack name")),d(a,"endpointId",(0,c.MZ)("Environment (Endpoint) ID")),d(a,"stackType",(0,c.MZ)("Stack type")),d(a,"stackStatus",(0,c.MZ)("Stack status")),d(a,"gitReference",(0,c.MZ)("Git reference")),d(a,"healthy",(0,c.MZ)("Stack healthy")),d(a,"runningCount",(0,c.MZ)("Running containers")),d(a,"totalCount",(0,c.MZ)("Total containers")),d(a,"currentEnv",(0,c.MZ)("Current environment (masked)")),d(a,"durationMs",(0,c.MZ)("Duration (ms)")),d(a,"errorMessage",(0,c.MZ)("Error message"))]))}(e,t)}}]),t}(a.Instruction);function P(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function _(e,t,n){return(_=x()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&E(o,n.prototype),o}).apply(null,arguments)}function Z(e){return(Z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function C(e){var t="function"==typeof Map?new Map:void 0;return(C=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return _(e,arguments,Z(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),E(n,e)})(e)}function x(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(x=function(){return!!e})()}var D=n().lazy(function(){return p.e("65").then(p.bind(p,168))}),I=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=Z(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,x()?Reflect.construct(e,t||[],Z(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&E(n,e),t=[{key:"load",value:function(){var e;return(e=function(){var e,t,n;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var l=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(i){var a,u,l;return(e=this.app.dataSourceManager.getDataSource("main"))&&((t=function(){e.collectionManager.getCollection(o.name)||e.collectionManager.addCollections([o])})(),e.addReloadCallback(t)),(n=this.app.pm.get("workflow")||this.app.pm.get("@nocobase/plugin-workflow"))&&(null==(a=n.registerInstructionGroup)||a.call(n,r.DQ,{key:r.DQ,label:(0,c.MZ)("Portainer")}),null==(u=n.registerInstruction)||u.call(n,r.fD.redeploy,j),null==(l=n.registerInstruction)||l.call(n,r.fD.control,M)),this.app.pluginSettingsManager.add("workflow-portainer",{title:this.t("Portainer Workflows"),icon:"CloudServerOutlined",Component:D,aclSnippet:r.im}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){P(i,r,o,a,u,"next",e)}function u(e){P(i,r,o,a,u,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(C(e.Plugin)),T=I}(),m}()});
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_workflow_portainer_client_v2=self.webpackChunkplugin_workflow_portainer_client_v2||[]).push([["127"],{42:function(e,t,n){n.d(t,{R:function(){return h},a:function(){return v}});var r=n(375),a=n(485),l=n(197),o=n(59),u=n(155),i=n.n(u),c=n(249),s=n(515);function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function d(e,t,n,r,a,l,o){try{var u=e[l](o),i=u.value}catch(e){n(e);return}u.done?t(i):Promise.resolve(i).then(r,a)}function m(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){d(l,r,a,o,u,"next",e)}function u(e){d(l,r,a,o,u,"throw",e)}o(void 0)})}}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,u=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){u=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(u)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(o,"next",{value:i(0)}),u(o,"throw",{value:i(1)}),u(o,"return",{value:i(2)}),"function"==typeof Symbol&&u(o,Symbol.iterator,{value:function(){return this}}),o;function i(u){return function(i){var c=[u,i];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&c[0]?r.return:c[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,c[1])).done)return a;switch(r=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){l.label=c[1];break}if(6===c[0]&&l.label<a[1]){l.label=a[1],a=c;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(c);break}a[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function v(){var e=(0,s.kj)(),t=(0,a.useApp)().apiClient,n=p((0,u.useState)([]),2),r=n[0],f=n[1],d=p((0,u.useState)(!1),2),v=d[0],h=d[1],y=(0,u.useCallback)(function(){return m(function(){var e,n;return b(this,function(r){switch(r.label){case 0:h(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,t.request({url:"".concat(c.Yk,":listInstances"),method:"get"})];case 2:return f(Array.isArray(null==(n=r.sent())||null==(e=n.data)?void 0:e.data)?n.data.data:[]),[3,5];case 3:return r.sent(),f([]),[3,5];case 4:return h(!1),[7];case 5:return[2]}})})()},[t]);(0,u.useEffect)(function(){y()},[y]);var g=(0,u.useMemo)(function(){return r.map(function(t){return{value:t.id,label:t.isDefault?"".concat(t.name," (").concat(e("Default"),")"):t.name}})},[r,e]);return i().createElement(o.Form.Item,{name:["config","instanceId"],label:e("Portainer instance"),extra:e("Leave empty to use the default enabled Portainer instance, or bind a workflow variable.")},i().createElement(l.WorkflowVariableWrapper,{render:function(t){var n=t.value,r=t.onChange;return i().createElement(o.Select,{allowClear:!0,loading:v,value:"number"==typeof n?n:n?Number(n):void 0,onChange:function(e){return null==r?void 0:r("number"==typeof e?e:null)},options:g,placeholder:e("Default Portainer instance"),style:{width:"100%"}})}}))}function h(e){var t,n,f=e.onStackContextChange,d=(0,s.kj)(),h=(0,a.useApp)().apiClient,y=o.Form.useFormInstance(),g=o.Form.useWatch(["config","instanceId"],y),k=o.Form.useWatch(["config","endpointId"],y),w=o.Form.useWatch(["config","stackId"],y),E=(0,l.isWorkflowVariableValue)(g),S=(0,l.isWorkflowVariableValue)(k),I=(0,l.isWorkflowVariableValue)(w),C=E||null==g||""===g?void 0:Number(g),P=S||null==k||""===k?void 0:Number(k),j=I||null==w||""===w?void 0:Number(w),A=p((0,u.useState)([]),2),F=A[0],O=A[1],x=p((0,u.useState)([]),2),W=x[0],N=x[1],V=p((0,u.useState)(!1),2),D=V[0],R=V[1],_=p((0,u.useState)(!1),2),T=_[0],G=_[1],L=(0,u.useCallback)(function(){return m(function(){var e,t;return b(this,function(n){switch(n.label){case 0:if(E)return O([]),[2];R(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,h.request({url:"".concat(c.Yk,":listEndpoints"),method:"get",params:C?{instanceId:C}:{}})];case 2:return O(Array.isArray(null==(t=n.sent())||null==(e=t.data)?void 0:e.data)?t.data.data:[]),[3,5];case 3:return n.sent(),O([]),[3,5];case 4:return R(!1),[7];case 5:return[2]}})})()},[h,E,C]),M=(0,u.useCallback)(function(){return m(function(){var e,t;return b(this,function(n){switch(n.label){case 0:if(E||S)return N([]),[2];G(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,h.request({url:"".concat(c.Yk,":listStacks"),method:"get",params:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},C?{instanceId:C}:{},P?{endpointId:P}:{})})];case 2:return N(Array.isArray(null==(t=n.sent())||null==(e=t.data)?void 0:e.data)?t.data.data:[]),[3,5];case 3:return n.sent(),N([]),[3,5];case 4:return G(!1),[7];case 5:return[2]}})})()},[h,S,E,P,C]);(0,u.useEffect)(function(){L()},[L]),(0,u.useEffect)(function(){M()},[M]);var q=(0,u.useMemo)(function(){return j?W.find(function(e){return e.id===j}):void 0},[j,W]);(0,u.useEffect)(function(){null==f||f({instanceId:E?void 0:C,stack:I?void 0:q})},[E,C,f,q,I]);var U=(0,u.useMemo)(function(){return F.map(function(e){return{value:e.id,searchLabel:"".concat(e.name," ").concat(e.id),label:i().createElement(o.Flex,{align:"center",justify:"space-between",gap:"small"},i().createElement("span",null,e.name," (#",e.id,")"),i().createElement(o.Tag,{color:1===e.status?"success":"default",style:{marginInlineEnd:0}},1===e.status?d("Up"):d("Down")))}})},[F,d]),Y=(0,u.useMemo)(function(){return W.map(function(e){var t;return{value:e.id,searchLabel:"".concat(e.name," ").concat(e.id," ").concat(null!=(t=e.gitReference)?t:""),label:i().createElement(o.Flex,{align:"center",justify:"space-between",gap:"small"},i().createElement("span",null,e.name," (#",e.id,")"),i().createElement("span",null,i().createElement(o.Tag,{color:e.isGitStack?"processing":"purple"},e.isGitStack?d("Git Stack"):d("Compose")),e.gitReference?i().createElement(o.Tag,{style:{marginInlineEnd:0}},e.gitReference.replace(/^refs\/heads\//,"")):null))}})},[W,d]);return i().createElement(i().Fragment,null,i().createElement(v,null),i().createElement(o.Form.Item,{name:["config","endpointId"],label:d("Environment (Endpoint)"),extra:d("Select a Portainer environment or bind a dynamic endpointId variable.")},i().createElement(l.WorkflowVariableWrapper,{render:function(e){var t=e.value,n=e.onChange;return E?i().createElement(o.InputNumber,{min:1,value:"number"==typeof t?t:t?Number(t):void 0,onChange:function(e){return null==n?void 0:n("number"==typeof e?e:null)},placeholder:d("Endpoint ID (e.g. 1)"),style:{width:"100%"}}):i().createElement(o.Flex,{gap:"small",style:{width:"100%"}},i().createElement(o.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"searchLabel",loading:D,value:"number"==typeof t?t:t?Number(t):void 0,onChange:function(e){return null==n?void 0:n("number"==typeof e?e:null)},options:U,placeholder:d("Auto-resolve from Stack or select environment"),style:{flex:1,minWidth:0}}),i().createElement(o.Button,{htmlType:"button","aria-label":d("Refresh Portainer environments"),icon:i().createElement(r.ReloadOutlined,null),loading:D,onClick:function(){L(),M()}}))}})),i().createElement(o.Form.Item,{name:["config","stackId"],label:d("Target Stack"),rules:[{required:!0,message:d("Please select a Stack or bind a Stack ID variable")}],extra:(null==q?void 0:q.isGitStack)?"".concat(d("Connected Git repository"),": ").concat(null!=(t=q.gitRepoUrl)?t:"-"," (").concat(null!=(n=q.gitReference)?n:"refs/heads/main",")"):d("Choose the Portainer Stack to control or bind a stackId variable from upstream data.")},i().createElement(l.WorkflowVariableWrapper,{render:function(e){var t=e.value,n=e.onChange;return E||S?i().createElement(o.InputNumber,{min:1,value:"number"==typeof t?t:t?Number(t):void 0,onChange:function(e){return null==n?void 0:n("number"==typeof e?e:null)},placeholder:d("Stack ID (e.g. 12)"),style:{width:"100%"}}):i().createElement(o.Select,{allowClear:!0,showSearch:!0,optionFilterProp:"searchLabel",loading:T,value:"number"==typeof t?t:t?Number(t):void 0,onChange:function(e){var t="number"==typeof e?e:null;if(null==n||n(t),t&&!P){var r=W.find(function(e){return e.id===t});(null==r?void 0:r.endpointId)&&y.setFieldValue(["config","endpointId"],r.endpointId)}},options:Y,placeholder:d("Select Portainer Stack"),style:{width:"100%"}})}})))}}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_workflow_portainer_client_v2=self.webpackChunkplugin_workflow_portainer_client_v2||[]).push([["57"],{632:function(e,t,r){r.d(t,{RedeployFieldset:function(){return y}});var n=r(197),a=r(59),l=r(155),o=r.n(l),i=r(249),c=r(515),u=r(375),m=r(485);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t,r,n,a,l,o){try{var i=e[l](o),c=i.value}catch(e){r(e);return}i.done?t(c):Promise.resolve(c).then(n,a)}function p(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(e,t)}}function b(e){var t,r,b=e.stackContext,d=(0,c.kj)(),v=(0,m.useApp)().apiClient,y=a.Form.useFormInstance(),g=function(e){if(Array.isArray(e))return e}(t=(0,l.useState)(!1))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a=[],l=!0,o=!1;try{for(n=n.call(e);!(l=(t=n.next()).done)&&(a.push(t.value),2!==a.length);l=!0);}catch(e){o=!0,r=e}finally{try{l||null==n.return||n.return()}finally{if(o)throw r}}return a}}(t)||p(t,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),h=g[0],k=g[1],E=!!(null==b||null==(r=b.stack)?void 0:r.id);return o().createElement(o().Fragment,null,o().createElement(a.Form.Item,{name:["config","envStrategy"],label:d("Environment merge strategy"),initialValue:"merge",extra:d("Merge keeps existing Portainer Stack variables intact and overrides matching keys; Replace overwrites the entire Stack Env list.")},o().createElement(a.Radio.Group,{options:[{value:"merge",label:d("Merge & override existing Stack Env")},{value:"replace",label:d("Replace all Stack Env")}]})),o().createElement(a.Form.Item,{label:o().createElement(a.Flex,{align:"center",justify:"space-between",gap:"middle",style:{width:"100%"}},o().createElement("span",null,d("Environment variables (Key-Value)")),E?o().createElement(a.Button,{size:"small",htmlType:"button",icon:o().createElement(u.CloudDownloadOutlined,null),loading:h,onClick:function(){var e;return(e=function(){var e,t,r,n,l,o,c,u,m,f,g,h,E,w,S,I,x,A,O,F;return function(e,t){var r,n,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(o,"next",{value:c(0)}),i(o,"throw",{value:c(1)}),i(o,"return",{value:c(2)}),"function"==typeof Symbol&&i(o,Symbol.iterator,{value:function(){return this}}),o;function c(i){return function(c){var u=[i,c];if(r)throw TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&u[0]?n.return:u[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,u[1])).done)return a;switch(n=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,n=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){l.label=u[1];break}if(6===u[0]&&l.label<a[1]){l.label=a[1],a=u;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(u);break}a[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],n=0}finally{r=a=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(P){var j,C;switch(P.label){case 0:if(!(t=null==b||null==(e=b.stack)?void 0:e.id))return[2];k(!0),P.label=1;case 1:return P.trys.push([1,3,4,5]),[4,v.request({url:"".concat(i.Yk,":getStackDetail"),method:"get",params:(j=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},(null==b?void 0:b.instanceId)?{instanceId:b.instanceId}:{}),C=C={stackId:t,includeValues:!0},Object.getOwnPropertyDescriptors?Object.defineProperties(j,Object.getOwnPropertyDescriptors(C)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(C)).forEach(function(e){Object.defineProperty(j,e,Object.getOwnPropertyDescriptor(C,e))}),j)})];case 2:c=Array.isArray(null==(o=P.sent())||null==(l=o.data)||null==(n=l.data)?void 0:n.env)?o.data.data.env:[],m=new Set((u=null!=(r=y.getFieldValue(["config","envPairs"]))?r:[]).map(function(e){var t;return String(null!=(t=null==e?void 0:e.name)?t:"").trim()}).filter(Boolean)),f=0,g=0,h=function(e){if(Array.isArray(e))return s(e)}(u)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(u)||p(u)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),E=!0,w=!1,S=void 0;try{for(I=c[Symbol.iterator]();!(E=(x=I.next()).done);E=!0)if(A=x.value,!(!(F=String(null!=(O=A.name)?O:"").trim())||m.has(F))){if(A.sensitive){g+=1;continue}h.push({name:F,value:A.value,secret:!1}),m.add(F),f+=1}}catch(e){w=!0,S=e}finally{try{E||null==I.return||I.return()}finally{if(w)throw S}}return y.setFieldValue(["config","envPairs"],h),g>0?a.message.info(d("Loaded {{count}} variables ({{sensitive}} sensitive keys stay preserved on Portainer in Merge mode)",{count:f,sensitive:g})):a.message.success(d("Loaded {{count}} variables from Portainer Stack",{count:f})),[3,5];case 3:return P.sent(),a.message.error(d("Failed to load environment variables from Portainer Stack")),[3,5];case 4:return k(!1),[7];case 5:return[2]}})},function(){var t=this,r=arguments;return new Promise(function(n,a){var l=e.apply(t,r);function o(e){f(l,n,a,o,i,"next",e)}function i(e){f(l,n,a,o,i,"throw",e)}o(void 0)})})()}},d("Load Env from Stack")):null),extra:d("Add variables such as IMAGE_TAG or runtime settings. Mark sensitive values as Secret to redact them in workflow execution logs.")},o().createElement(a.Form.List,{name:["config","envPairs"]},function(e,t){var r=t.add,l=t.remove;return o().createElement(a.Space,{direction:"vertical",style:{display:"flex"}},e.map(function(e,t){var r,i=String(null!=(r=y.getFieldValue(["config","envPairs",e.name,"name"]))?r:"").trim(),c=i?"".concat(d("Delete environment variable")," ").concat(i):"".concat(d("Delete environment variable")," #").concat(t+1);return o().createElement(a.Flex,{key:e.key,align:"center",gap:"small",wrap:"wrap",style:{width:"100%"}},o().createElement(a.Form.Item,{name:[e.name,"name"],style:{flex:"1 1 160px",marginBottom:0}},o().createElement(a.Input,{placeholder:"IMAGE_TAG",autoCorrect:"off",autoCapitalize:"none",spellCheck:!1})),o().createElement(a.Form.Item,{name:[e.name,"value"],style:{flex:"2 1 220px",marginBottom:0}},o().createElement(n.WorkflowVariableInput,{placeholder:d("Value or {{variable}}")})),o().createElement(a.Form.Item,{name:[e.name,"secret"],valuePropName:"checked",initialValue:!1,style:{marginBottom:0}},o().createElement(a.Checkbox,null,d("Secret"))),o().createElement(a.Button,{htmlType:"button","aria-label":c,icon:o().createElement(u.DeleteOutlined,null),onClick:function(){return l(e.name)}}))}),o().createElement(a.Button,{htmlType:"button",icon:o().createElement(u.PlusOutlined,null),onClick:function(){return r({name:"",value:"",secret:!1})},style:{width:"100%"}},d("Add environment variable")))})),o().createElement(a.Collapse,{size:"small",style:{marginBottom:16},items:[{key:"bulk-env",label:d("Bulk .env text & dynamic JSON environment"),children:o().createElement(o().Fragment,null,o().createElement(a.Form.Item,{name:["config","envText"],label:d("Bulk .env format"),extra:d("Enter KEY=VALUE lines. Supports upstream workflow variables.")},o().createElement(n.WorkflowVariableTextArea,{autoSize:{minRows:3,maxRows:8},placeholder:"IMAGE_TAG=v1.0.0\nNODE_ENV=production"})),o().createElement(a.Form.Item,{name:["config","dynamicEnv"],label:d("Dynamic environment JSON / variable"),extra:d('Pass a JSON object {"KEY":"VAL"}, an array [{"name":"KEY","value":"VAL"}], or a workflow variable from a build catalog record.'),style:{marginBottom:0}},o().createElement(n.WorkflowVariableJsonTextArea,{autoSize:{minRows:2,maxRows:6},placeholder:'{"IMAGE_TAG": "{{$context.data.imageTag}}"}'})))}]}))}var d=r(42);function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function y(){var e,t,r,u=(0,c.kj)(),m=a.Form.useFormInstance(),s=null!=(t=a.Form.useWatch(["config","mode"],m))?t:"stack",f=function(e){if(Array.isArray(e))return e}(e=(0,l.useState)({}))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var a=[],l=!0,o=!1;try{for(n=n.call(e);!(l=(t=n.next()).done)&&(a.push(t.value),2!==a.length);l=!0);}catch(e){o=!0,r=e}finally{try{l||null==n.return||n.return()}finally{if(o)throw r}}return a}}(e)||function(e){if(e){if("string"==typeof e)return v(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return v(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=f[0],y=f[1];return o().createElement(o().Fragment,null,o().createElement(a.Form.Item,{name:["config","mode"],label:u("Execution mode"),initialValue:"stack",extra:u("Use Stack API to control Environment, Stack, Git branch, and full Env variables; use Stack Webhook when triggering an unauthenticated Portainer webhook UUID.")},o().createElement(a.Radio.Group,{options:[{value:"stack",label:u("Stack API (Git / Compose)")},{value:"webhook",label:u("Stack Webhook")}]})),"webhook"===s?o().createElement(o().Fragment,null,o().createElement(d.a,null),o().createElement(a.Form.Item,{name:["config","webhookId"],label:u("Stack Webhook token"),rules:[{required:!0,message:u("Webhook token is required")}],extra:u("The UUID at the end of /api/stacks/webhooks/<token>.")},o().createElement(n.WorkflowVariableInput,{placeholder:"638e6967-ef77-4906-8af8-236800621360"})),o().createElement(a.Form.Item,{name:["config","webhookTag"],label:u("Image tag override (optional)"),extra:u("Appends ?tag=<value> when triggering a Portainer Stack webhook.")},o().createElement(n.WorkflowVariableInput,{placeholder:"latest"}))):o().createElement(o().Fragment,null,o().createElement(d.R,{onStackContextChange:y}),o().createElement(a.Form.Item,{name:["config","gitReference"],label:u("Git branch / tag override (optional)"),extra:u("Leave empty to keep the Git reference already configured on Portainer (e.g. refs/heads/main), or pass a branch/tag such as main or refs/tags/v1.2.0.")},o().createElement(n.WorkflowVariableInput,{placeholder:(null==(r=p.stack)?void 0:r.gitReference)||"refs/heads/main"})),o().createElement(a.Form.Item,{name:["config","repullImage"],valuePropName:"checked",initialValue:!1,extra:u("Enable when deploying a separate Stack so Portainer pulls the newly built image from your registry.")},o().createElement(a.Checkbox,null,u("Force pull / repull latest images"))),o().createElement(a.Form.Item,{name:["config","prune"],valuePropName:"checked",initialValue:!1},o().createElement(a.Checkbox,null,u("Prune orphan services on redeploy"))),o().createElement(b,{stackContext:p})),o().createElement(a.Form.Item,{name:["config","timeoutMs"],label:u("Request timeout"),initialValue:i.t1,extra:u("Increase timeout for Stacks that run long Dockerfile builds during git/redeploy.")},o().createElement(n.WorkflowVariableWrapper,{render:function(e){var t=e.value,r=e.onChange;return o().createElement(a.InputNumber,{min:i.SU,max:i.mn,step:5e3,addonAfter:u("ms"),value:"number"==typeof t?t:t?Number(t):i.t1,onChange:function(e){return null==r?void 0:r("number"==typeof e?e:null)},style:{width:"100%"}})}})),o().createElement(a.Form.Item,{name:["config","ignoreFail"],valuePropName:"checked",initialValue:!1},o().createElement(a.Checkbox,null,u("Ignore failed execution and continue workflow"))))}}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_workflow_portainer_client_v2=self.webpackChunkplugin_workflow_portainer_client_v2||[]).push([["65"],{168:function(e,t,n){n.d(t,{PortainerSettingsPage:function(){return h}});var r=n(375),a=n(485),l=n(59),o=n(155),c=n.n(o),s=n(249),i=n(515);function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e,t,n,r,a,l,o){try{var c=e[l](o),s=c.value}catch(e){n(e);return}c.done?t(s):Promise.resolve(s).then(r,a)}function d(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){m(l,r,a,o,c,"next",e)}function c(e){m(l,r,a,o,c,"throw",e)}o(void 0)})}}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function f(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],o=!0,c=!1;try{for(a=a.call(e);!(o=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);o=!0);}catch(e){c=!0,r=e}finally{try{o||null==a.return||a.return()}finally{if(c)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(o,"next",{value:s(0)}),c(o,"throw",{value:s(1)}),c(o,"return",{value:s(2)}),"function"==typeof Symbol&&c(o,Symbol.iterator,{value:function(){return this}}),o;function s(c){return function(s){var i=[c,s];if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return l.label++,{value:i[1],done:!1};case 5:l.label++,r=i[1],i=[0];continue;case 7:i=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===i[0]||2===i[0])){l=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){l.label=i[1];break}if(6===i[0]&&l.label<a[1]){l.label=a[1],a=i;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(i);break}a[2]&&l.ops.pop(),l.trys.pop();continue}i=t.call(e,l)}catch(e){i=[6,e],r=0}finally{n=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}function h(){var e=(0,i.kj)(),t=(0,a.useApp)().apiClient,n=f(l.Form.useForm(),1)[0],u=f((0,o.useState)([]),2),m=u[0],h=u[1],b=f((0,o.useState)(!1),2),g=b[0],E=b[1],v=f((0,o.useState)(!1),2),k=v[0],w=v[1],C=f((0,o.useState)(null),2),S=C[0],I=C[1],P=f((0,o.useState)(!1),2),T=P[0],O=P[1],A=f((0,o.useState)(!1),2),x=A[0],F=A[1],B=f((0,o.useState)(null),2),D=B[0],j=B[1],U=f((0,o.useState)(null),2),z=U[0],q=U[1],G=f((0,o.useState)([]),2),R=G[0],_=G[1],N=f((0,o.useState)(void 0),2),K=N[0],L=N[1],M=f((0,o.useState)([]),2),V=M[0],Z=M[1],Y=f((0,o.useState)(!1),2),H=Y[0],X=Y[1],Q=(0,o.useCallback)(function(){return d(function(){var n,r;return y(this,function(a){switch(a.label){case 0:E(!0),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,t.request({url:"".concat(s.Z3,":list"),method:"get",params:{pageSize:100,sort:["-isDefault","id"]}})];case 2:return h(Array.isArray(null==(r=a.sent())||null==(n=r.data)?void 0:n.data)?r.data.data:[]),[3,5];case 3:return a.sent(),l.message.error(e("Failed to load Portainer instances")),[3,5];case 4:return E(!1),[7];case 5:return[2]}})})()},[t,e]);(0,o.useEffect)(function(){Q()},[Q]);var W=function(e){var t,r,a;I(e),n.setFieldsValue({name:e.name,baseUrl:e.baseUrl,apiKey:e.apiKey||s.Q6,gitCredentialId:null!=(t=e.gitCredentialId)?t:void 0,gitUsername:null!=(r=e.gitUsername)?r:"",gitAccessToken:e.gitAccessToken||"",allowInsecureTls:!!e.allowInsecureTls,defaultTimeoutMs:null!=(a=e.defaultTimeoutMs)?a:s.t1,isDefault:!!e.isDefault,enabled:!1!==e.enabled}),w(!0)},$=(0,o.useCallback)(function(n,r){return d(function(){var a,o,c,i,u;return y(this,function(m){switch(m.label){case 0:X(!0),m.label=1;case 1:return m.trys.push([1,3,4,5]),[4,Promise.all([t.request({url:"".concat(s.Yk,":listEndpoints"),method:"get",params:{instanceId:n}}),t.request({url:"".concat(s.Yk,":listStacks"),method:"get",params:p({instanceId:n},r?{endpointId:r}:{})})])];case 2:return i=(c=f.apply(void 0,[m.sent(),2]))[0],u=c[1],_(Array.isArray(null==i||null==(a=i.data)?void 0:a.data)?i.data.data:[]),Z(Array.isArray(null==u||null==(o=u.data)?void 0:o.data)?u.data.data:[]),[3,5];case 3:return m.sent(),l.message.error(e("Failed to load environments and stacks from Portainer")),[3,5];case 4:return X(!1),[7];case 5:return[2]}})})()},[t,e]),J=function(e){q(e),L(void 0),$(e.id,void 0)},ee=[{title:e("Name"),dataIndex:"name",key:"name",render:function(t,n){return c().createElement(l.Space,null,c().createElement(l.Typography.Text,{strong:!0},t),n.isDefault?c().createElement(l.Tag,{color:"blue"},e("Default")):null)}},{title:e("Base URL"),dataIndex:"baseUrl",key:"baseUrl",render:function(e){return c().createElement(l.Typography.Text,{code:!0},e)}},{title:e("Health & Version"),key:"health",render:function(t,n){return n.lastHealthStatus?"ok"===n.lastHealthStatus?c().createElement(l.Space,{size:"small"},c().createElement(l.Tag,{color:"success",icon:c().createElement(r.CheckCircleOutlined,null)},e("Connected")),n.lastVersion?c().createElement(l.Typography.Text,{type:"secondary"},"v",n.lastVersion):null):c().createElement(l.Tag,{color:"error"},e("Unreachable")):c().createElement(l.Tag,null,e("Not tested"))}},{title:e("Enabled"),dataIndex:"enabled",key:"enabled",width:100,render:function(n,r){return c().createElement(l.Switch,{checked:!1!==n,"aria-label":"".concat(e("Toggle Portainer instance")," ").concat(r.name),onChange:function(n){d(function(){return y(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,t.request({url:"".concat(s.Z3,":update"),method:"post",params:{filterByTk:r.id},data:{enabled:n}})];case 1:return a.sent(),[4,Q()];case 2:return a.sent(),[3,4];case 3:return a.sent(),l.message.error(e("Failed to update status")),[3,4];case 4:return[2]}})})()}})}},{title:e("Actions"),key:"actions",width:300,render:function(n,a){return c().createElement(l.Space,{size:"small",wrap:!0},c().createElement(l.Button,{size:"small",htmlType:"button",icon:c().createElement(r.ApiOutlined,null),loading:D===a.id,"aria-label":"".concat(e("Test connection")," ").concat(a.name),onClick:function(){d(function(){var n,r,o,c,i;return y(this,function(u){switch(u.label){case 0:j(a.id),u.label=1;case 1:return u.trys.push([1,4,6,7]),[4,t.request({url:"".concat(s.Yk,":testConnection"),method:"post",params:{filterByTk:a.id}})];case 2:return i=null==(c=u.sent())||null==(o=c.data)?void 0:o.data,l.message.success(e("Connected to Portainer v{{version}} ({{count}} environments found)",{version:null!=(n=null==i?void 0:i.version)?n:"unknown",count:null!=(r=null==i?void 0:i.endpointCount)?r:0})),[4,Q()];case 3:case 5:return u.sent(),[3,7];case 4:return u.sent(),l.message.error(e("Connection test failed")),[4,Q()];case 6:return j(null),[7];case 7:return[2]}})})()}},e("Test")),c().createElement(l.Button,{size:"small",htmlType:"button",icon:c().createElement(r.AppstoreOutlined,null),"aria-label":"".concat(e("Browse Stacks")," ").concat(a.name),onClick:function(){return J(a)}},e("Stacks")),c().createElement(l.Button,{size:"small",htmlType:"button",icon:c().createElement(r.EditOutlined,null),"aria-label":"".concat(e("Edit Portainer instance")," ").concat(a.name),onClick:function(){return W(a)}}),c().createElement(l.Popconfirm,{title:e("Delete this Portainer instance?"),onConfirm:function(){return d(function(){return y(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,t.request({url:"".concat(s.Z3,":destroy"),method:"post",params:{filterByTk:a.id}})];case 1:return n.sent(),l.message.success(e("Portainer instance deleted")),[4,Q()];case 2:return n.sent(),[3,4];case 3:return n.sent(),l.message.error(e("Failed to delete Portainer instance")),[3,4];case 4:return[2]}})})()}},c().createElement(l.Button,{size:"small",danger:!0,htmlType:"button",icon:c().createElement(r.DeleteOutlined,null),"aria-label":"".concat(e("Delete Portainer instance")," ").concat(a.name)})))}}],et=[{title:e("ID"),dataIndex:"id",key:"id",width:72},{title:e("Stack Name"),dataIndex:"name",key:"name",render:function(e){return c().createElement(l.Typography.Text,{strong:!0},e)}},{title:e("Endpoint"),dataIndex:"endpointId",key:"endpointId",width:130,render:function(e){var t=R.find(function(t){return t.id===e});return t?"".concat(t.name," (#").concat(e,")"):"#".concat(e)}},{title:e("Source"),key:"source",render:function(t,n){return c().createElement(l.Space,{size:"small",wrap:!0},c().createElement(l.Tag,{color:n.isGitStack?"processing":"purple"},n.isGitStack?e("Git Stack"):e("Compose")),n.gitReference?c().createElement(l.Typography.Text,{code:!0},n.gitReference):null)}},{title:e("Status"),dataIndex:"status",key:"status",width:110,render:function(t){return 3===t?c().createElement(l.Tag,{color:"processing"},e("Deploying")):4===t?c().createElement(l.Tag,{color:"error"},e("Error")):c().createElement(l.Tag,{color:1===t?"success":"default"},1===t?e("Active"):e("Inactive"))}},{title:e("Env Vars"),dataIndex:"envCount",key:"envCount",width:90}];return c().createElement(l.Card,{title:e("Portainer Instances"),extra:c().createElement(l.Space,null,c().createElement(l.Button,{htmlType:"button",icon:c().createElement(r.ReloadOutlined,null),loading:g,onClick:function(){Q()}},e("Refresh")),c().createElement(l.Button,{type:"primary",htmlType:"button",icon:c().createElement(r.PlusOutlined,null),onClick:function(){I(null),n.resetFields(),n.setFieldsValue({defaultTimeoutMs:s.t1,allowInsecureTls:!1,isDefault:0===m.length,enabled:!0}),w(!0)}},e("Add Portainer instance")))},c().createElement(l.Alert,{type:"info",showIcon:!0,style:{marginBottom:16},message:e("Configure Portainer servers with an Access Token (X-API-Key). Workflow nodes can select Environments and Stacks directly or receive dynamic IDs and Env variables from upstream build catalogs.")}),c().createElement(l.Table,{rowKey:"id",loading:g,dataSource:m,columns:ee,pagination:!1}),c().createElement(l.Modal,{open:k,title:S?e("Edit Portainer instance"):e("Add Portainer instance"),onCancel:function(){return w(!1)},destroyOnClose:!0,width:620,footer:c().createElement(l.Flex,{justify:"space-between",align:"center"},c().createElement(l.Button,{htmlType:"button",icon:c().createElement(r.ApiOutlined,null),loading:x,onClick:function(){d(function(){var r,a,o,c,i,u;return y(this,function(m){switch(m.label){case 0:if(!(r=n.getFieldsValue()).baseUrl)return l.message.warning(e("Please enter a Portainer base URL first")),[2];F(!0),m.label=1;case 1:var d,f;return m.trys.push([1,3,4,5]),[4,t.request({url:"".concat(s.Yk,":testConnectionDraft"),method:"post",data:(d=p({},r),f=f={id:null==S?void 0:S.id},Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(f)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(f)).forEach(function(e){Object.defineProperty(d,e,Object.getOwnPropertyDescriptor(f,e))}),d)})];case 2:return u=null==(i=m.sent())||null==(c=i.data)?void 0:c.data,l.message.success(e("Connected to Portainer v{{version}} ({{count}} environments found)",{version:null!=(a=null==u?void 0:u.version)?a:"unknown",count:null!=(o=null==u?void 0:u.endpointCount)?o:0})),[3,5];case 3:return m.sent(),l.message.error(e("Connection test failed. Check URL, API key, and TLS settings.")),[3,5];case 4:return F(!1),[7];case 5:return[2]}})})()}},e("Test connection")),c().createElement(l.Space,null,c().createElement(l.Button,{htmlType:"button",onClick:function(){return w(!1)}},e("Cancel")),c().createElement(l.Button,{type:"primary",htmlType:"button",loading:T,onClick:function(){d(function(){var r,a,o;return y(this,function(c){switch(c.label){case 0:return c.trys.push([0,2,,3]),[4,n.validateFields()];case 1:return r=c.sent(),[3,3];case 2:return c.sent(),[2];case 3:O(!0),c.label=4;case 4:if(c.trys.push([4,10,11,12]),!S)return[3,6];return[4,t.request({url:"".concat(s.Z3,":update"),method:"post",params:{filterByTk:S.id},data:r})];case 5:return c.sent(),l.message.success(e("Portainer instance updated")),[3,8];case 6:return[4,t.request({url:"".concat(s.Z3,":create"),method:"post",data:r})];case 7:c.sent(),l.message.success(e("Portainer instance created")),c.label=8;case 8:return w(!1),[4,Q()];case 9:return c.sent(),[3,12];case 10:var i,u;return i=a=c.sent(),o=(null!=(u=Error)&&"u">typeof Symbol&&u[Symbol.hasInstance]?!!u[Symbol.hasInstance](i):i instanceof u)?a.message:e("Failed to save Portainer instance"),l.message.error(o),[3,12];case 11:return O(!1),[7];case 12:return[2]}})})()}},e("Save"))))},c().createElement(l.Form,{form:n,layout:"vertical"},c().createElement(l.Form.Item,{name:"name",label:e("Instance name"),rules:[{required:!0,message:e("Instance name is required")}]},c().createElement(l.Input,{placeholder:"Portainer Production"})),c().createElement(l.Form.Item,{name:"baseUrl",label:e("Portainer base URL"),rules:[{required:!0,message:e("Base URL is required")}],extra:e("Example: https://portainer.internal:9443")},c().createElement(l.Input,{placeholder:"https://portainer.example.com:9443",autoCorrect:"off",autoCapitalize:"none",spellCheck:!1})),c().createElement(l.Form.Item,{name:"apiKey",label:e("Portainer API key (X-API-Key)"),rules:[{required:!S,message:e("API key is required")}],extra:e("Generated under Portainer -> My account -> Access tokens. Encrypted at rest.")},c().createElement(l.Input.Password,{placeholder:"ptr_...",autoComplete:"new-password",autoCorrect:"off",autoCapitalize:"none",spellCheck:!1})),c().createElement(l.Flex,{gap:"middle",wrap:"wrap"},c().createElement(l.Form.Item,{name:"defaultTimeoutMs",label:e("Default build/redeploy timeout (ms)"),style:{flex:"1 1 240px"}},c().createElement(l.InputNumber,{min:s.SU,max:s.mn,step:5e3,style:{width:"100%"}}))),c().createElement(l.Space,{size:"large",wrap:!0,style:{marginBottom:16}},c().createElement(l.Form.Item,{name:"isDefault",valuePropName:"checked",style:{marginBottom:0}},c().createElement(l.Checkbox,null,e("Set as default instance"))),c().createElement(l.Form.Item,{name:"allowInsecureTls",valuePropName:"checked",style:{marginBottom:0}},c().createElement(l.Checkbox,null,e("Allow self-signed TLS certificate (:9443)"))),c().createElement(l.Form.Item,{name:"enabled",valuePropName:"checked",style:{marginBottom:0}},c().createElement(l.Checkbox,null,e("Enabled")))),c().createElement(l.Collapse,{size:"small",items:[{key:"git-fallback",label:e("Optional Git authentication fallback (when Stack has no saved GitCredentialID)"),children:c().createElement(c().Fragment,null,c().createElement(l.Form.Item,{name:"gitCredentialId",label:e("Portainer saved Git Credential ID (optional)"),extra:e("Automatically detected from each Git Stack when present; set here only to supply a default ID.")},c().createElement(l.InputNumber,{min:1,style:{width:"100%"}})),c().createElement(l.Form.Item,{name:"gitUsername",label:e("Fallback Git username (optional)")},c().createElement(l.Input,{autoCorrect:"off",autoCapitalize:"none",spellCheck:!1,placeholder:"oauth2"})),c().createElement(l.Form.Item,{name:"gitAccessToken",label:e("Fallback Git Personal Access Token (optional)"),style:{marginBottom:0}},c().createElement(l.Input.Password,{autoComplete:"new-password",autoCorrect:"off",autoCapitalize:"none",spellCheck:!1})))}]}))),c().createElement(l.Drawer,{open:!!z,title:z?"".concat(e("Portainer Stacks")," — ").concat(z.name):e("Portainer Stacks"),onClose:function(){return q(null)},width:780},c().createElement(l.Flex,{gap:"small",align:"center",style:{marginBottom:16}},c().createElement(l.Select,{allowClear:!0,style:{width:280},placeholder:e("All environments (Endpoints)"),value:K,options:R.map(function(e){return{value:e.id,label:"".concat(e.name," (#").concat(e.id,")")}}),onChange:function(e){L(e),z&&$(z.id,e)}}),c().createElement(l.Button,{htmlType:"button",icon:c().createElement(r.ReloadOutlined,null),loading:H,onClick:function(){z&&$(z.id,K)}},e("Refresh"))),c().createElement(l.Table,{rowKey:"id",size:"small",loading:H,dataSource:V,columns:et,pagination:{pageSize:15}})))}}}]);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunkplugin_workflow_portainer_client_v2=self.webpackChunkplugin_workflow_portainer_client_v2||[]).push([["660"],{943:function(e,t,n){n.d(t,{ControlFieldset:function(){return i}});var a=n(59),l=n(155),r=n.n(l),c=n(515),o=n(42);function i(){var e=(0,c.kj)();return r().createElement(r().Fragment,null,r().createElement(a.Form.Item,{name:["config","action"],label:e("Stack operation"),initialValue:"inspect",extra:e("Inspect retrieves Stack status, current Env keys, and container health without restarting services; Start and Stop control the Stack lifecycle.")},r().createElement(a.Radio.Group,{options:[{value:"inspect",label:e("Inspect Stack & Health")},{value:"start",label:e("Start Stack")},{value:"stop",label:e("Stop Stack")}]})),r().createElement(o.R,null),r().createElement(a.Form.Item,{name:["config","ignoreFail"],valuePropName:"checked",initialValue:!1},r().createElement(a.Checkbox,null,e("Ignore failed execution and continue workflow"))))}}}]);