@nocobase/plugin-environment-variables 2.1.31 → 2.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-v2/500.04c8b5dd30a40c2c.js +10 -0
- package/dist/client-v2/index.js +1 -1
- package/dist/client-v2/pages/EnvironmentPage.d.ts +14 -0
- package/dist/externalVersion.js +7 -7
- package/dist/server/plugin.d.ts +2 -0
- package/dist/server/plugin.js +28 -3
- package/package.json +2 -2
- package/dist/client-v2/500.b1becd4d3744e64d.js +0 -10
|
@@ -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.webpackChunk_nocobase_plugin_environment_variables_client_v2=self.webpackChunk_nocobase_plugin_environment_variables_client_v2||[]).push([["500"],{527:function(e,t,n){n.r(t),n.d(t,{VariableForm:function(){return R},default:function(){return $},BulkImportForm:function(){return q}});var r=n(375),a=n(477),l=n(485),o=n(694),u=n(768),i=n(625),c=n(59),s=n(992),m=n(230),f=n(155),p=n.n(f),d=/^[A-Za-z][A-Za-z0-9_]*$/;function b(){var e=(0,o.useFlowEngine)();return function(t,n){return e.context.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:["@nocobase/plugin-environment-variables","client"]},n))}}var v=function(e){var t=e.value,n=e.onChange;return p().createElement(c.Input,{style:{minWidth:160},value:null!=t?t:"",onChange:function(e){return n(e.target.value)},placeholder:""})},y=function(e){var t=e.value,n=e.onChange,r=b(),a=(0,f.useMemo)(function(){return[{value:"default",label:r("Plain text")},{value:"secret",label:r("Encrypted")}]},[r]);return p().createElement(c.Select,{mode:"tags",style:{minWidth:200},value:Array.isArray(t)?t:null!=t?[t]:[],onChange:function(e){return n(e)},options:a})},h=function(){var e=b();return(0,f.useMemo)(function(){return[{name:"name",title:e("Name"),operators:[{value:"$includes",label:e("contains")},{value:"$notIncludes",label:e("does not contain")},{value:"$eq",label:e("is")},{value:"$ne",label:e("is not")}],ValueComponent:v},{name:"type",title:e("Type"),operators:[{value:"$match",label:e("is")},{value:"$notMatch",label:e("is not")}],ValueComponent:y},{name:"value",title:e("Value"),operators:[{value:"$includes",label:e("contains")},{value:"$notIncludes",label:e("does not contain")},{value:"$eq",label:e("is")},{value:"$ne",label:e("is not")}],ValueComponent:v}]},[e])},E=(0,o.observer)(function(e){var t,n,r=e.value,a=h(),l=a.find(function(e){return e.name===r.path}),o=null!=(t=null==l?void 0:l.operators)?t:[],u=null!=(n=null==l?void 0:l.ValueComponent)?n:v,i=b(),s=(0,f.useMemo)(function(){return a.map(function(e){return{value:e.name,label:e.title}})},[a]);return p().createElement(c.Space,{style:{flex:1},wrap:!0},p().createElement(c.Select,{style:{minWidth:120},placeholder:i("Select field"),value:r.path||void 0,options:s,onChange:function(e){var t,n,l=a.find(function(t){return t.name===e});r.path=e,r.operator=null!=(t=null==l||null==(n=l.operators[0])?void 0:n.value)?t:"",r.value=""}}),p().createElement(c.Select,{style:{minWidth:120},placeholder:i("Comparison"),value:r.operator||void 0,options:o,onChange:function(e){r.operator=e}}),p().createElement(u,{value:r.value,operator:r.operator,onChange:function(e){r.value=e}}))},{displayName:"EnvVariableFilterItem"});function g(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 w(e){if(Array.isArray(e))return e}function k(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 C(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function o(e){k(l,r,a,o,u,"next",e)}function u(e){k(l,r,a,o,u,"throw",e)}o(void 0)})}}function S(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function O(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function A(e,t){return w(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)||x(e,t)||O()}function F(e){return function(e){if(Array.isArray(e))return g(e)}(e)||S(e)||x(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t){if(e){if("string"==typeof e)return g(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 g(e,t)}}function I(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 j(){var e,t,n=(e=["\n display: inline-flex;\n align-items: center;\n gap: 8px;\n margin-left: -8px;\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return j=function(){return n},n}function V(e){if(Array.isArray(e)&&e.length){var t=e[0];if("string"==typeof t)return t;if((void 0===t?"undefined":t&&"u">typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)=="object"&&null!==t&&"message"in t)return"string"==typeof t.message?t.message:void 0}}var B=(0,a.css)(j());function P(e,t){return e.trim().split("\n").map(function(e){var n,r=w(n=e.split("="))||S(n)||x(n)||O(),a=r[0],l=r.slice(1);return(null==a?void 0:a.trim())?{name:a.trim(),value:l.join("=").trim(),type:t}:null}).filter(function(e){return null!=e})}function T(e){var t=e.value,n=e.onSubmit,a=e.onReset,o=b(),u=A((0,f.useState)(!1),2),i=u[0],s=u[1],m=(0,f.useMemo)(function(){return{model:{translate:function(e){return o(e)},dispatchEvent:function(e){"submit"===e?(n(),s(!1)):"reset"===e&&a()}}}},[o,n,a]),d=Array.isArray(t.items)&&t.items.length>0;return p().createElement(c.Popover,{open:i,onOpenChange:s,trigger:"click",placement:"bottomLeft",content:p().createElement("div",{style:{minWidth:480}},p().createElement(l.FilterContent,{value:t,ctx:m,FilterItem:E}))},p().createElement(c.Button,{icon:p().createElement(r.FilterOutlined,null),type:d?"primary":"default"},o("Filter")))}function R(e){var t=e.mode,n=e.initialValues,a=e.onSubmitted,l=e.title,u=b(),i=(0,o.useFlowContext)(),s=(0,o.useFlowView)(),m=c.App.useApp().notification,v=A(c.Form.useForm(),1)[0],y=A((0,f.useState)(!1),2),h=y[0],E=y[1],g=(0,f.useCallback)(function(){return C(function(){var e,r;return I(this,function(l){switch(l.label){case 0:return[4,v.validateFields()];case 1:e=l.sent(),E(!0),l.label=2;case 2:l.trys.push([2,,11,12]),l.label=3;case 3:if(l.trys.push([3,8,,9]),"create"!==t)return[3,5];return[4,i.api.request({url:"environmentVariables:create",method:"post",data:e})];case 4:return l.sent(),[3,7];case 5:return[4,i.api.request({url:"environmentVariables:update",method:"post",params:{filterByTk:null==n?void 0:n.name},data:e})];case 6:l.sent(),l.label=7;case 7:return[3,9];case 8:return r=l.sent(),m.error({message:V(i.api.toErrMessages(r))||u("Operation failed")}),[2];case 9:return a(),[4,s.close()];case 10:return l.sent(),[3,12];case 11:return E(!1),[7];case 12:return[2]}})})()},[i.api,v,null==n?void 0:n.name,t,m,a,u,s]);return p().createElement("div",null,s.Header?p().createElement(s.Header,{title:p().createElement("span",{className:B},p().createElement(c.Button,{type:"text",size:"small",icon:p().createElement(r.CloseOutlined,null),onClick:function(){return C(function(){return I(this,function(e){switch(e.label){case 0:return[4,s.close()];case 1:return e.sent(),[2]}})})()}}),p().createElement("span",null,l))}):null,p().createElement("div",null,p().createElement(c.Form,{form:v,layout:"vertical",initialValues: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}({type:"default"},n)},p().createElement(c.Form.Item,{name:"name",label:"".concat(u("Name")," :"),rules:[{required:!0,message:u("The field value is required")},{pattern:d,message:u("Only letters, numbers and underscores are allowed, and it must start with a letter.")}]},p().createElement(c.Input,{disabled:"edit"===t})),p().createElement(c.Form.Item,{name:"type",label:"".concat(u("Type")," :"),rules:[{required:!0,message:u("The field value is required")}]},p().createElement(c.Radio.Group,{options:[{value:"default",label:u("Plain text")},{value:"secret",label:u("Encrypted")}]})),p().createElement(c.Form.Item,{name:"value",label:"".concat(u("Value")," :"),rules:[{required:!0,message:u("The field value is required")}]},p().createElement(c.Input.TextArea,{autoSize:{minRows:3}})))),s.Footer?p().createElement(s.Footer,null,p().createElement(c.Space,null,p().createElement(c.Button,{onClick:function(){return C(function(){return I(this,function(e){return[2,s.close()]})})()}},u("Cancel")),p().createElement(c.Button,{type:"primary",loading:h,onClick:g},u("Submit")))):null)}function q(e){var t=e.onSubmitted,n=b(),a=(0,o.useFlowContext)(),l=(0,o.useFlowView)(),u=c.App.useApp().notification,i=A(c.Form.useForm(),1)[0],s=A((0,f.useState)(!1),2),m=s[0],d=s[1],v=(0,f.useCallback)(function(){return C(function(){var e,r,o;return I(this,function(c){switch(c.label){case 0:return[4,i.validateFields()];case 1:if((r=F(P((e=c.sent()).variables||"","default")).concat(F(P(e.secret||"","secret")))).length)return[3,3];return[4,l.close()];case 2:return c.sent(),[2];case 3:d(!0),c.label=4;case 4:c.trys.push([4,,10,11]),c.label=5;case 5:return c.trys.push([5,7,,8]),[4,a.api.request({url:"environmentVariables:create",method:"post",data:r})];case 6:return c.sent(),[3,8];case 7:return o=c.sent(),u.error({message:V(a.api.toErrMessages(o))||n("Operation failed")}),[2];case 8:return t(),[4,l.close()];case 9:return c.sent(),[3,11];case 10:return d(!1),[7];case 11:return[2]}})})()},[a.api,i,u,t,n,l]);return p().createElement("div",null,l.Header?p().createElement(l.Header,{title:p().createElement("span",{className:B},p().createElement(c.Button,{type:"text",size:"small",icon:p().createElement(r.CloseOutlined,null),onClick:function(){return C(function(){return I(this,function(e){switch(e.label){case 0:return[4,l.close()];case 1:return e.sent(),[2]}})})()}}),p().createElement("span",null,n("Bulk import")))}):null,p().createElement("div",null,p().createElement(c.Form,{form:i,layout:"vertical"},p().createElement(c.Form.Item,{name:"variables",label:"".concat(n("Plain text")," :")},p().createElement(c.Input.TextArea,{autoSize:{minRows:8,maxRows:16},placeholder:"FOO=aaa\nBAR=bbb"})),p().createElement(c.Form.Item,{name:"secret",label:"".concat(n("Encrypted")," :")},p().createElement(c.Input.TextArea,{autoSize:{minRows:8,maxRows:16},placeholder:"FOO=aaa\nBAR=bbb"})))),l.Footer?p().createElement(l.Footer,null,p().createElement(c.Space,null,p().createElement(c.Button,{onClick:function(){return C(function(){return I(this,function(e){return[2,l.close()]})})()}},n("Cancel")),p().createElement(c.Button,{type:"primary",loading:m,onClick:v},n("Submit")))):null)}var $=(0,m.observer)(function(){var e,t=b(),n=(0,o.useFlowContext)();(0,o.useFlowView)();var a=c.theme.useToken().token,m=c.App.useApp().modal,d=(0,f.useMemo)(function(){return n.api.resource("environmentVariables")},[n.api]),v=(0,f.useRef)((0,s.observable)({logic:"$and",items:[]})),y=A((0,f.useState)(void 0),2),h=y[0],E=y[1],g=A((0,f.useState)([]),2),w=g[0],k=g[1],S=(0,i.useRequest)(function(){return C(function(){var e;return I(this,function(t){switch(t.label){case 0:return[4,n.api.request({url:"environmentVariables",method:"get",params:{paginate:!1,filter:h},skipNotify:!0})];case 1:return[2,null==(e=t.sent())?void 0:e.data]}})})()},{refreshDeps:[h]}),O=S.data,F=S.loading,x=(0,f.useMemo)(function(){var e=null==O?void 0:O.data;return Array.isArray(e)?e:[]},[O]),j=(0,f.useCallback)(function(){E((0,u.transformFilter)(v.current))},[]),V=(0,f.useCallback)(function(){v.current.logic="$and",v.current.items.splice(0,v.current.items.length),E(void 0)},[]),B=(0,f.useCallback)(function(){S.refresh()},[S]),P=(0,f.useCallback)(function(e){m.confirm({title:t("Delete variable"),content:t("Are you sure you want to delete it?"),onOk:function(){return C(function(){return I(this,function(t){switch(t.label){case 0:return[4,d.destroy({filterByTk:e})];case 1:return t.sent(),k([]),S.refresh(),[2]}})})()}})},[m,d,t,S]),$=(0,f.useCallback)(function(e,r){var a="".concat("create"===e?t("Add variable"):t("Edit"));n.viewer.drawer({width:"50%",content:function(){return p().createElement(R,{mode:e,initialValues:r,onSubmitted:function(){return S.refresh()},title:a})}})},[n.viewer,t,S]),M=(0,f.useCallback)(function(){n.viewer.drawer({width:"50%",content:function(){return p().createElement(q,{onSubmitted:function(){return S.refresh()}})}})},[n.viewer,S]),_=(0,f.useMemo)(function(){return[{title:t("Name"),dataIndex:"name",ellipsis:!0},{title:t("Type"),dataIndex:"type",render:function(e){return"secret"===e?p().createElement(c.Tag,{color:"red"},t("Encrypted")):p().createElement(c.Tag,{color:"green"},t("Plain text"))}},{title:t("Value"),ellipsis:!0,render:function(e){return"default"===e.type?e.value:"******"}},{title:t("Actions"),width:200,render:function(e){return p().createElement(c.Space,null,p().createElement("a",{onClick:function(){return $("edit",e)}},t("Edit")),p().createElement("a",{onClick:function(){return P(e.name)}},t("Delete")))}}]},[P,$,t]),D=null==O||null==(e=O.meta)?void 0:e.updated;return p().createElement("div",null,D?p().createElement(c.Alert,{type:"warning",style:{marginBottom:a.marginMD,alignItems:"center"},description:p().createElement("div",null,t("Variables and secrets have been updated. A restart is required for the changes to take effect.")),action:p().createElement(c.Button,{size:"middle",type:"primary",onClick:function(){return C(function(){return I(this,function(e){switch(e.label){case 0:return[4,n.api.resource("app").refresh()];case 1:return e.sent(),[2]}})})()}},t("Restart now"))}):null,p().createElement(c.Card,null,p().createElement(c.Flex,{justify:"space-between",style:{marginBottom:a.marginMD}},p().createElement(T,{value:v.current,onSubmit:j,onReset:V}),p().createElement(c.Space,null,p().createElement(c.Button,{icon:p().createElement(r.ReloadOutlined,null),onClick:B},t("Refresh")),p().createElement(c.Button,{icon:p().createElement(r.DeleteOutlined,null),disabled:!w.length,onClick:function(){return P(w)}},t("Delete")),p().createElement(c.Dropdown,{menu:{onClick:function(e){"variable"===e.key?$("create"):"bulk"===e.key&&M()},items:[{key:"variable",label:t("Add variable")},{type:"divider"},{key:"bulk",label:t("Bulk import")}]}},p().createElement(c.Button,{type:"primary",icon:p().createElement(r.PlusOutlined,null)},t("Add new")," ",p().createElement(r.DownOutlined,null))))),p().createElement(l.Table,{rowKey:"name",loading:F,dataSource:x,columns:_,pagination:!1,rowSelection:{selectedRowKeys:w,onChange:function(e){return k(e)}}})))})}}]);
|
package/dist/client-v2/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/reactive"),require("react"),require("antd"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/utils/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-environment-variables/client-v2",["ahooks","@emotion/css","@nocobase/client-v2","@formily/reactive","react","antd","@formily/react","@ant-design/icons","@nocobase/flow-engine","@nocobase/utils/client"],t):"object"==typeof exports?exports["@nocobase/plugin-environment-variables/client-v2"]=t(require("ahooks"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/reactive"),require("react"),require("antd"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/utils/client")):e["@nocobase/plugin-environment-variables/client-v2"]=t(e.ahooks,e["@emotion/css"],e["@nocobase/client-v2"],e["@formily/reactive"],e.react,e.antd,e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e["@nocobase/utils/client"])}(self,function(e,t,n,r,o,i,a,u,c,l){return function(){"use strict";var s,f,p,b={375:function(e){e.exports=u},477:function(e){e.exports=t},230:function(e){e.exports=a},992:function(e){e.exports=r},485:function(e){e.exports=n},694:function(e){e.exports=c},768:function(e){e.exports=l},625:function(t){t.exports=e},59:function(e){e.exports=i},155:function(e){e.exports=o}},v={};function d(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return b[e](n,n.exports,d),n.exports}d.m=b,d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.f={},d.e=function(e){return Promise.all(Object.keys(d.f).reduce(function(t,n){return d.f[n](e,t),t},[]))},d.u=function(e){return""+e+".b1becd4d3744e64d.js"},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},y={},d.l=function(e,t,n,r){if(y[e])return void y[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")=="@nocobase/plugin-environment-variables/client-v2:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,d.nc&&o.setAttribute("nonce",d.nc),o.setAttribute("data-rspack","@nocobase/plugin-environment-variables/client-v2:"+n),o.src=e),y[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=y[e];if(delete y[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=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)},d.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.g.importScripts&&(h=d.g.location+"");var y,h,m=d.g.document;if(!h&&m&&(m.currentScript&&"SCRIPT"===m.currentScript.tagName.toUpperCase()&&(h=m.currentScript.src),!h)){var g=m.getElementsByTagName("script");if(g.length)for(var w=g.length-1;w>-1&&(!h||!/^http(s?):/.test(h));)h=g[w--].src}if(!h)throw Error("Automatic publicPath is not supported in this browser");d.p=h.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s={889:0},d.f.j=function(e,t){var n=d.o(s,e)?s[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=s[e]=[t,r]});t.push(n[2]=r);var o=d.p+d.u(e),i=Error();d.l(o,function(t){if(d.o(s,e)&&(0!==(n=s[e])&&(s[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)}},f=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==s[e]})){for(n in i)d.o(i,n)&&(d.m[n]=i[n]);a&&a(d)}for(e&&e(t);u<o.length;u++)r=o[u],d.o(s,r)&&s[r]&&s[r][0](),s[r]=0},(p=self.webpackChunk_nocobase_plugin_environment_variables_client_v2=self.webpackChunk_nocobase_plugin_environment_variables_client_v2||[]).forEach(f.bind(null,0)),p.push=f.bind(null,p.push.bind(p));var _={};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/@nocobase/plugin-environment-variables/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-environment-variables/dist/client-v2/")}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/@nocobase/plugin-environment-variables/dist/client-v2/"}d.p=e}(),!function(){d.r(_),d.d(_,{default:function(){return f}});var e=d(485);function t(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 n(e){return function(){var n=this,r=arguments;return new Promise(function(o,i){var a=e.apply(n,r);function u(e){t(a,o,i,u,c,"next",e)}function c(e){t(a,o,i,u,c,"throw",e)}u(void 0)})}}function r(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}}}}function o(e){return n(function(){var t,n,o;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.request({url:"environmentVariables?paginate=false",skipNotify:!0})];case 1:return[2,Array.isArray(o=null==(n=r.sent())||null==(t=n.data)?void 0:t.data)?o:[]];case 2:return r.sent(),[2,[]];case 3:return[2]}})})()}function i(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 a(e,t,n){return(a=s()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=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 a(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}var f=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function a(){var e,t;if(!(this instanceof a))throw TypeError("Cannot call a class as a function");return e=a,t=arguments,e=u(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,s()?Reflect.construct(e,t||[],u(this).constructor):e.apply(this,t))}return a.prototype=Object.create(e&&e.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),e&&c(a,e),t=[{key:"load",value:function(){var e;return(e=function(){var e,t;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,c;return e=this,t=this.t("Variables and secrets"),this.pluginSettingsManager.addMenuItem({key:"environment",title:t,icon:"TableOutlined",aclSnippet:"pm.environment-variables"}),this.pluginSettingsManager.addPageTabItem({menuKey:"environment",key:"index",title:t,componentLoader:function(){return d.e("500").then(d.bind(d,527))}}),a=this.flowEngine.context,u=this.app.apiClient,c=function(t){return e.t(t)},a.defineProperty("$env",{get:function(){return n(function(){return r(this,function(e){switch(e.label){case 0:return[4,o(u)];case 1:return[2,Object.fromEntries(e.sent().map(function(e){return[e.name,e.value]}))]}})})()},meta:{type:"object",title:String(c("Variables and secrets")),properties:function(){return n(function(){var e,t,n,i,a,c,l,s;return r(this,function(r){switch(r.label){case 0:return[4,o(u)];case 1:e=r.sent(),t={},n=!0,i=!1,a=void 0;try{for(c=e[Symbol.iterator]();!(n=(l=c.next()).done);n=!0)t[(s=l.value).name]={type:"secret"===s.type?"string":s.type||"string",title:s.name}}catch(e){i=!0,a=e}finally{try{n||null==c.return||c.return()}finally{if(i)throw a}}return[2,t]}})})()}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function u(e){i(a,r,o,u,c,"next",e)}function c(e){i(a,r,o,u,c,"throw",e)}u(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)}}(a.prototype,t),a}(l(e.Plugin))}(),_}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/reactive"),require("react"),require("antd"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/utils/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-environment-variables/client-v2",["ahooks","@emotion/css","@nocobase/client-v2","@formily/reactive","react","antd","@formily/react","@ant-design/icons","@nocobase/flow-engine","@nocobase/utils/client"],t):"object"==typeof exports?exports["@nocobase/plugin-environment-variables/client-v2"]=t(require("ahooks"),require("@emotion/css"),require("@nocobase/client-v2"),require("@formily/reactive"),require("react"),require("antd"),require("@formily/react"),require("@ant-design/icons"),require("@nocobase/flow-engine"),require("@nocobase/utils/client")):e["@nocobase/plugin-environment-variables/client-v2"]=t(e.ahooks,e["@emotion/css"],e["@nocobase/client-v2"],e["@formily/reactive"],e.react,e.antd,e["@formily/react"],e["@ant-design/icons"],e["@nocobase/flow-engine"],e["@nocobase/utils/client"])}(self,function(e,t,n,r,o,i,a,u,c,l){return function(){"use strict";var s,f,p,b={375:function(e){e.exports=u},477:function(e){e.exports=t},230:function(e){e.exports=a},992:function(e){e.exports=r},485:function(e){e.exports=n},694:function(e){e.exports=c},768:function(e){e.exports=l},625:function(t){t.exports=e},59:function(e){e.exports=i},155:function(e){e.exports=o}},v={};function d(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return b[e](n,n.exports,d),n.exports}d.m=b,d.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return d.d(t,{a:t}),t},d.d=function(e,t){for(var n in t)d.o(t,n)&&!d.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},d.f={},d.e=function(e){return Promise.all(Object.keys(d.f).reduce(function(t,n){return d.f[n](e,t),t},[]))},d.u=function(e){return""+e+".04c8b5dd30a40c2c.js"},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),d.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},y={},d.l=function(e,t,n,r){if(y[e])return void y[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")=="@nocobase/plugin-environment-variables/client-v2:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,d.nc&&o.setAttribute("nonce",d.nc),o.setAttribute("data-rspack","@nocobase/plugin-environment-variables/client-v2:"+n),o.src=e),y[e]=[t];var l=function(t,n){o.onerror=o.onload=null,clearTimeout(s);var r=y[e];if(delete y[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},s=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)},d.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},d.g.importScripts&&(h=d.g.location+"");var y,h,m=d.g.document;if(!h&&m&&(m.currentScript&&"SCRIPT"===m.currentScript.tagName.toUpperCase()&&(h=m.currentScript.src),!h)){var g=m.getElementsByTagName("script");if(g.length)for(var w=g.length-1;w>-1&&(!h||!/^http(s?):/.test(h));)h=g[w--].src}if(!h)throw Error("Automatic publicPath is not supported in this browser");d.p=h.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s={889:0},d.f.j=function(e,t){var n=d.o(s,e)?s[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=s[e]=[t,r]});t.push(n[2]=r);var o=d.p+d.u(e),i=Error();d.l(o,function(t){if(d.o(s,e)&&(0!==(n=s[e])&&(s[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)}},f=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==s[e]})){for(n in i)d.o(i,n)&&(d.m[n]=i[n]);a&&a(d)}for(e&&e(t);u<o.length;u++)r=o[u],d.o(s,r)&&s[r]&&s[r][0](),s[r]=0},(p=self.webpackChunk_nocobase_plugin_environment_variables_client_v2=self.webpackChunk_nocobase_plugin_environment_variables_client_v2||[]).forEach(f.bind(null,0)),p.push=f.bind(null,p.push.bind(p));var _={};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/@nocobase/plugin-environment-variables/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-environment-variables/dist/client-v2/")}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/@nocobase/plugin-environment-variables/dist/client-v2/"}d.p=e}(),!function(){d.r(_),d.d(_,{default:function(){return f}});var e=d(485);function t(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 n(e){return function(){var n=this,r=arguments;return new Promise(function(o,i){var a=e.apply(n,r);function u(e){t(a,o,i,u,c,"next",e)}function c(e){t(a,o,i,u,c,"throw",e)}u(void 0)})}}function r(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}}}}function o(e){return n(function(){var t,n,o;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.request({url:"environmentVariables?paginate=false",skipNotify:!0})];case 1:return[2,Array.isArray(o=null==(n=r.sent())||null==(t=n.data)?void 0:t.data)?o:[]];case 2:return r.sent(),[2,[]];case 3:return[2]}})})()}function i(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 a(e,t,n){return(a=s()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&c(o,n.prototype),o}).apply(null,arguments)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=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 a(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function s(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(s=function(){return!!e})()}var f=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function a(){var e,t;if(!(this instanceof a))throw TypeError("Cannot call a class as a function");return e=a,t=arguments,e=u(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,s()?Reflect.construct(e,t||[],u(this).constructor):e.apply(this,t))}return a.prototype=Object.create(e&&e.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),e&&c(a,e),t=[{key:"load",value:function(){var e;return(e=function(){var e,t;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,c;return e=this,t=this.t("Variables and secrets"),this.pluginSettingsManager.addMenuItem({key:"environment",title:t,icon:"TableOutlined",aclSnippet:"pm.environment-variables"}),this.pluginSettingsManager.addPageTabItem({menuKey:"environment",key:"index",title:t,componentLoader:function(){return d.e("500").then(d.bind(d,527))}}),a=this.flowEngine.context,u=this.app.apiClient,c=function(t){return e.t(t)},a.defineProperty("$env",{get:function(){return n(function(){return r(this,function(e){switch(e.label){case 0:return[4,o(u)];case 1:return[2,Object.fromEntries(e.sent().map(function(e){return[e.name,e.value]}))]}})})()},meta:{type:"object",title:String(c("Variables and secrets")),properties:function(){return n(function(){var e,t,n,i,a,c,l,s;return r(this,function(r){switch(r.label){case 0:return[4,o(u)];case 1:e=r.sent(),t={},n=!0,i=!1,a=void 0;try{for(c=e[Symbol.iterator]();!(n=(l=c.next()).done);n=!0)t[(s=l.value).name]={type:"secret"===s.type?"string":s.type||"string",title:s.name}}catch(e){i=!0,a=e}finally{try{n||null==c.return||c.return()}finally{if(i)throw a}}return[2,t]}})})()}}}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function u(e){i(a,r,o,u,c,"next",e)}function c(e){i(a,r,o,u,c,"throw",e)}u(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)}}(a.prototype,t),a}(l(e.Plugin))}(),_}()});
|
|
@@ -7,5 +7,19 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
|
+
type EnvVariable = {
|
|
11
|
+
name: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
type: 'default' | 'secret';
|
|
14
|
+
};
|
|
10
15
|
declare const EnvironmentPage: React.FC;
|
|
16
|
+
export declare function VariableForm(props: {
|
|
17
|
+
mode: 'create' | 'edit';
|
|
18
|
+
initialValues?: EnvVariable;
|
|
19
|
+
onSubmitted: () => void;
|
|
20
|
+
title: string;
|
|
21
|
+
}): React.JSX.Element;
|
|
22
|
+
export declare function BulkImportForm(props: {
|
|
23
|
+
onSubmitted: () => void;
|
|
24
|
+
}): React.JSX.Element;
|
|
11
25
|
export default EnvironmentPage;
|
package/dist/externalVersion.js
CHANGED
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/flow-engine": "2.1.
|
|
12
|
-
"@nocobase/client": "2.1.
|
|
11
|
+
"@nocobase/flow-engine": "2.1.32",
|
|
12
|
+
"@nocobase/client": "2.1.32",
|
|
13
13
|
"react": "18.2.0",
|
|
14
|
-
"@nocobase/client-v2": "2.1.
|
|
15
|
-
"@nocobase/
|
|
14
|
+
"@nocobase/client-v2": "2.1.32",
|
|
15
|
+
"@nocobase/database": "2.1.32",
|
|
16
|
+
"@nocobase/server": "2.1.32",
|
|
16
17
|
"@ant-design/icons": "5.6.1",
|
|
17
18
|
"@formily/antd-v5": "1.2.3",
|
|
18
19
|
"@formily/core": "2.3.7",
|
|
@@ -21,8 +22,7 @@ module.exports = {
|
|
|
21
22
|
"antd": "5.24.2",
|
|
22
23
|
"react-i18next": "11.18.6",
|
|
23
24
|
"@emotion/css": "11.13.0",
|
|
24
|
-
"@nocobase/utils": "2.1.
|
|
25
|
+
"@nocobase/utils": "2.1.32",
|
|
25
26
|
"ahooks": "3.7.8",
|
|
26
|
-
"@formily/reactive": "2.3.7"
|
|
27
|
-
"@nocobase/database": "2.1.31"
|
|
27
|
+
"@formily/reactive": "2.3.7"
|
|
28
28
|
};
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import type { Filter } from '@nocobase/database';
|
|
9
10
|
import { Plugin } from '@nocobase/server';
|
|
11
|
+
export declare function restrictValueFilterToPlainText(filter?: Filter): Filter | undefined;
|
|
10
12
|
export declare class PluginEnvironmentVariablesServer extends Plugin {
|
|
11
13
|
updated: boolean;
|
|
12
14
|
get aesEncryptor(): import("@nocobase/server").AesEncryptor;
|
package/dist/server/plugin.js
CHANGED
|
@@ -27,10 +27,33 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
27
27
|
var plugin_exports = {};
|
|
28
28
|
__export(plugin_exports, {
|
|
29
29
|
PluginEnvironmentVariablesServer: () => PluginEnvironmentVariablesServer,
|
|
30
|
-
default: () => plugin_default
|
|
30
|
+
default: () => plugin_default,
|
|
31
|
+
restrictValueFilterToPlainText: () => restrictValueFilterToPlainText
|
|
31
32
|
});
|
|
32
33
|
module.exports = __toCommonJS(plugin_exports);
|
|
33
34
|
var import_server = require("@nocobase/server");
|
|
35
|
+
const FILTER_LOGIC_OPERATORS = ["$and", "$or"];
|
|
36
|
+
function containsValueFilter(filter) {
|
|
37
|
+
if (!filter || typeof filter !== "object" || Array.isArray(filter)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const condition = filter;
|
|
41
|
+
if (Object.prototype.hasOwnProperty.call(condition, "value")) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return FILTER_LOGIC_OPERATORS.some((operator) => {
|
|
45
|
+
const items = condition[operator];
|
|
46
|
+
return Array.isArray(items) && items.some(containsValueFilter);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function restrictValueFilterToPlainText(filter) {
|
|
50
|
+
if (!filter || !containsValueFilter(filter)) {
|
|
51
|
+
return filter;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
$and: [filter, { type: { $eq: "default" } }]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
34
57
|
class PluginEnvironmentVariablesServer extends import_server.Plugin {
|
|
35
58
|
updated = false;
|
|
36
59
|
get aesEncryptor() {
|
|
@@ -140,9 +163,10 @@ class PluginEnvironmentVariablesServer extends import_server.Plugin {
|
|
|
140
163
|
});
|
|
141
164
|
this.app.resourceManager.registerActionHandler("environmentVariables:list", async (ctx, next) => {
|
|
142
165
|
const repository = this.db.getRepository("environmentVariables");
|
|
166
|
+
const filter = restrictValueFilterToPlainText(ctx.action.params.filter);
|
|
143
167
|
const items = await repository.find({
|
|
144
168
|
sort: "name",
|
|
145
|
-
filter
|
|
169
|
+
filter
|
|
146
170
|
});
|
|
147
171
|
for (const model of items) {
|
|
148
172
|
if (model.type === "secret") {
|
|
@@ -199,5 +223,6 @@ class PluginEnvironmentVariablesServer extends import_server.Plugin {
|
|
|
199
223
|
var plugin_default = PluginEnvironmentVariablesServer;
|
|
200
224
|
// Annotate the CommonJS export names for ESM import in node:
|
|
201
225
|
0 && (module.exports = {
|
|
202
|
-
PluginEnvironmentVariablesServer
|
|
226
|
+
PluginEnvironmentVariablesServer,
|
|
227
|
+
restrictValueFilterToPlainText
|
|
203
228
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-environment-variables",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.32",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@nocobase/client": "2.x",
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"System management"
|
|
22
22
|
],
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "737a1324f650d7bc66594203b68eb0180553a551"
|
|
25
25
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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.webpackChunk_nocobase_plugin_environment_variables_client_v2=self.webpackChunk_nocobase_plugin_environment_variables_client_v2||[]).push([["500"],{527:function(e,t,n){n.r(t),n.d(t,{default:function(){return q}});var r=n(375),a=n(477),l=n(485),u=n(694),o=n(768),i=n(625),c=n(59),s=n(992),m=n(230),f=n(155),d=n.n(f),p=/^[A-Za-z][A-Za-z0-9_]*$/;function v(){var e=(0,u.useFlowEngine)();return function(t,n){return e.context.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:["@nocobase/plugin-environment-variables","client"]},n))}}var b=function(e){var t=e.value,n=e.onChange;return d().createElement(c.Input,{style:{minWidth:160},value:null!=t?t:"",onChange:function(e){return n(e.target.value)},placeholder:""})},y=function(e){var t=e.value,n=e.onChange,r=v(),a=(0,f.useMemo)(function(){return[{value:"default",label:r("Plain text")},{value:"secret",label:r("Encrypted")}]},[r]);return d().createElement(c.Select,{mode:"tags",style:{minWidth:200},value:Array.isArray(t)?t:null!=t?[t]:[],onChange:function(e){return n(e)},options:a})},h=function(){var e=v();return(0,f.useMemo)(function(){return[{name:"name",title:e("Name"),operators:[{value:"$includes",label:e("contains")},{value:"$notIncludes",label:e("does not contain")},{value:"$eq",label:e("is")},{value:"$ne",label:e("is not")}],ValueComponent:b},{name:"type",title:e("Type"),operators:[{value:"$match",label:e("is")},{value:"$notMatch",label:e("is not")}],ValueComponent:y},{name:"value",title:e("Value"),operators:[{value:"$includes",label:e("contains")},{value:"$notIncludes",label:e("does not contain")},{value:"$eq",label:e("is")},{value:"$ne",label:e("is not")}],ValueComponent:b}]},[e])},E=(0,u.observer)(function(e){var t,n,r=e.value,a=h(),l=a.find(function(e){return e.name===r.path}),u=null!=(t=null==l?void 0:l.operators)?t:[],o=null!=(n=null==l?void 0:l.ValueComponent)?n:b,i=v(),s=(0,f.useMemo)(function(){return a.map(function(e){return{value:e.name,label:e.title}})},[a]);return d().createElement(c.Space,{style:{flex:1},wrap:!0},d().createElement(c.Select,{style:{minWidth:120},placeholder:i("Select field"),value:r.path||void 0,options:s,onChange:function(e){var t,n,l=a.find(function(t){return t.name===e});r.path=e,r.operator=null!=(t=null==l||null==(n=l.operators[0])?void 0:n.value)?t:"",r.value=""}}),d().createElement(c.Select,{style:{minWidth:120},placeholder:i("Comparison"),value:r.operator||void 0,options:u,onChange:function(e){r.operator=e}}),d().createElement(o,{value:r.value,operator:r.operator,onChange:function(e){r.value=e}}))},{displayName:"EnvVariableFilterItem"});function g(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 w(e){if(Array.isArray(e))return e}function k(e,t,n,r,a,l,u){try{var o=e[l](u),i=o.value}catch(e){n(e);return}o.done?t(i):Promise.resolve(i).then(r,a)}function C(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var l=e.apply(t,n);function u(e){k(l,r,a,u,o,"next",e)}function o(e){k(l,r,a,u,o,"throw",e)}u(void 0)})}}function S(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function O(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function F(e,t){return w(e)||function(e,t){var n,r,a=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var l=[],u=!0,o=!1;try{for(a=a.call(e);!(u=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);u=!0);}catch(e){o=!0,r=e}finally{try{u||null==a.return||a.return()}finally{if(o)throw r}}return l}}(e,t)||x(e,t)||O()}function A(e){return function(e){if(Array.isArray(e))return g(e)}(e)||S(e)||x(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e,t){if(e){if("string"==typeof e)return g(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 g(e,t)}}function I(e,t){var n,r,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),o=Object.defineProperty;return o(u,"next",{value:i(0)}),o(u,"throw",{value:i(1)}),o(u,"return",{value:i(2)}),"function"==typeof Symbol&&o(u,Symbol.iterator,{value:function(){return this}}),u;function i(o){return function(i){var c=[o,i];if(n)throw TypeError("Generator is already executing.");for(;u&&(u=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 j(){var e,t,n=(e=["\n display: inline-flex;\n align-items: center;\n gap: 8px;\n margin-left: -8px;\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return j=function(){return n},n}var V=(0,a.css)(j());function B(e,t){return e.trim().split("\n").map(function(e){var n,r=w(n=e.split("="))||S(n)||x(n)||O(),a=r[0],l=r.slice(1);return(null==a?void 0:a.trim())?{name:a.trim(),value:l.join("=").trim(),type:t}:null}).filter(function(e){return null!=e})}function P(e){var t=e.value,n=e.onSubmit,a=e.onReset,u=v(),o=F((0,f.useState)(!1),2),i=o[0],s=o[1],m=(0,f.useMemo)(function(){return{model:{translate:function(e){return u(e)},dispatchEvent:function(e){"submit"===e?(n(),s(!1)):"reset"===e&&a()}}}},[u,n,a]),p=Array.isArray(t.items)&&t.items.length>0;return d().createElement(c.Popover,{open:i,onOpenChange:s,trigger:"click",placement:"bottomLeft",content:d().createElement("div",{style:{minWidth:480}},d().createElement(l.FilterContent,{value:t,ctx:m,FilterItem:E}))},d().createElement(c.Button,{icon:d().createElement(r.FilterOutlined,null),type:p?"primary":"default"},u("Filter")))}function T(e){var t=e.mode,n=e.initialValues,a=e.onSubmitted,l=e.title,o=v(),i=(0,u.useFlowContext)(),s=(0,u.useFlowView)(),m=F(c.Form.useForm(),1)[0],b=F((0,f.useState)(!1),2),y=b[0],h=b[1],E=(0,f.useCallback)(function(){return C(function(){var e;return I(this,function(r){switch(r.label){case 0:return[4,m.validateFields()];case 1:e=r.sent(),h(!0),r.label=2;case 2:if(r.trys.push([2,,8,9]),"create"!==t)return[3,4];return[4,i.api.request({url:"environmentVariables:create",method:"post",data:e})];case 3:return r.sent(),[3,6];case 4:return[4,i.api.request({url:"environmentVariables:update",method:"post",params:{filterByTk:null==n?void 0:n.name},data:e})];case 5:r.sent(),r.label=6;case 6:return a(),[4,s.close()];case 7:return r.sent(),[3,9];case 8:return h(!1),[7];case 9:return[2]}})})()},[i.api,m,null==n?void 0:n.name,t,a,s]);return d().createElement("div",null,s.Header?d().createElement(s.Header,{title:d().createElement("span",{className:V},d().createElement(c.Button,{type:"text",size:"small",icon:d().createElement(r.CloseOutlined,null),onClick:function(){return C(function(){return I(this,function(e){switch(e.label){case 0:return[4,s.close()];case 1:return e.sent(),[2]}})})()}}),d().createElement("span",null,l))}):null,d().createElement("div",null,d().createElement(c.Form,{form:m,layout:"vertical",initialValues: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}({type:"default"},n)},d().createElement(c.Form.Item,{name:"name",label:"".concat(o("Name")," :"),rules:[{required:!0,message:o("The field value is required")},{pattern:p,message:o("Only letters, numbers and underscores are allowed, and it must start with a letter.")}]},d().createElement(c.Input,{disabled:"edit"===t})),d().createElement(c.Form.Item,{name:"type",label:"".concat(o("Type")," :"),rules:[{required:!0,message:o("The field value is required")}]},d().createElement(c.Radio.Group,{options:[{value:"default",label:o("Plain text")},{value:"secret",label:o("Encrypted")}]})),d().createElement(c.Form.Item,{name:"value",label:"".concat(o("Value")," :"),rules:[{required:!0,message:o("The field value is required")}]},d().createElement(c.Input.TextArea,{autoSize:{minRows:3}})))),s.Footer?d().createElement(s.Footer,null,d().createElement(c.Space,null,d().createElement(c.Button,{onClick:function(){return C(function(){return I(this,function(e){return[2,s.close()]})})()}},o("Cancel")),d().createElement(c.Button,{type:"primary",loading:y,onClick:E},o("Submit")))):null)}function R(e){var t=e.onSubmitted,n=v(),a=(0,u.useFlowContext)(),l=(0,u.useFlowView)(),o=F(c.Form.useForm(),1)[0],i=F((0,f.useState)(!1),2),s=i[0],m=i[1],p=(0,f.useCallback)(function(){return C(function(){var e,n;return I(this,function(r){switch(r.label){case 0:return[4,o.validateFields()];case 1:if((n=A(B((e=r.sent()).variables||"","default")).concat(A(B(e.secret||"","secret")))).length)return[3,3];return[4,l.close()];case 2:return r.sent(),[2];case 3:m(!0),r.label=4;case 4:return r.trys.push([4,,7,8]),[4,a.api.request({url:"environmentVariables:create",method:"post",data:n})];case 5:return r.sent(),t(),[4,l.close()];case 6:return r.sent(),[3,8];case 7:return m(!1),[7];case 8:return[2]}})})()},[a.api,o,t,l]);return d().createElement("div",null,l.Header?d().createElement(l.Header,{title:d().createElement("span",{className:V},d().createElement(c.Button,{type:"text",size:"small",icon:d().createElement(r.CloseOutlined,null),onClick:function(){return C(function(){return I(this,function(e){switch(e.label){case 0:return[4,l.close()];case 1:return e.sent(),[2]}})})()}}),d().createElement("span",null,n("Bulk import")))}):null,d().createElement("div",null,d().createElement(c.Form,{form:o,layout:"vertical"},d().createElement(c.Form.Item,{name:"variables",label:"".concat(n("Plain text")," :")},d().createElement(c.Input.TextArea,{autoSize:{minRows:8,maxRows:16},placeholder:"FOO=aaa\nBAR=bbb"})),d().createElement(c.Form.Item,{name:"secret",label:"".concat(n("Encrypted")," :")},d().createElement(c.Input.TextArea,{autoSize:{minRows:8,maxRows:16},placeholder:"FOO=aaa\nBAR=bbb"})))),l.Footer?d().createElement(l.Footer,null,d().createElement(c.Space,null,d().createElement(c.Button,{onClick:function(){return C(function(){return I(this,function(e){return[2,l.close()]})})()}},n("Cancel")),d().createElement(c.Button,{type:"primary",loading:s,onClick:p},n("Submit")))):null)}var q=(0,m.observer)(function(){var e,t=v(),n=(0,u.useFlowContext)();(0,u.useFlowView)();var a=c.theme.useToken().token,m=c.App.useApp().modal,p=(0,f.useMemo)(function(){return n.api.resource("environmentVariables")},[n.api]),b=(0,f.useRef)((0,s.observable)({logic:"$and",items:[]})),y=F((0,f.useState)(void 0),2),h=y[0],E=y[1],g=F((0,f.useState)([]),2),w=g[0],k=g[1],S=(0,i.useRequest)(function(){return C(function(){var e;return I(this,function(t){switch(t.label){case 0:return[4,n.api.request({url:"environmentVariables",method:"get",params:{paginate:!1,filter:h},skipNotify:!0})];case 1:return[2,null==(e=t.sent())?void 0:e.data]}})})()},{refreshDeps:[h]}),O=S.data,A=S.loading,x=(0,f.useMemo)(function(){var e=null==O?void 0:O.data;return Array.isArray(e)?e:[]},[O]),j=(0,f.useCallback)(function(){E((0,o.transformFilter)(b.current))},[]),V=(0,f.useCallback)(function(){b.current.logic="$and",b.current.items.splice(0,b.current.items.length),E(void 0)},[]),B=(0,f.useCallback)(function(){S.refresh()},[S]),q=(0,f.useCallback)(function(e){m.confirm({title:t("Delete variable"),content:t("Are you sure you want to delete it?"),onOk:function(){return C(function(){return I(this,function(t){switch(t.label){case 0:return[4,p.destroy({filterByTk:e})];case 1:return t.sent(),k([]),S.refresh(),[2]}})})()}})},[m,p,t,S]),$=(0,f.useCallback)(function(e,r){var a="".concat("create"===e?t("Add variable"):t("Edit"));n.viewer.drawer({width:"50%",content:function(){return d().createElement(T,{mode:e,initialValues:r,onSubmitted:function(){return S.refresh()},title:a})}})},[n.viewer,t,S]),_=(0,f.useCallback)(function(){n.viewer.drawer({width:"50%",content:function(){return d().createElement(R,{onSubmitted:function(){return S.refresh()}})}})},[n.viewer,S]),D=(0,f.useMemo)(function(){return[{title:t("Name"),dataIndex:"name",ellipsis:!0},{title:t("Type"),dataIndex:"type",render:function(e){return"secret"===e?d().createElement(c.Tag,{color:"red"},t("Encrypted")):d().createElement(c.Tag,{color:"green"},t("Plain text"))}},{title:t("Value"),ellipsis:!0,render:function(e){return"default"===e.type?e.value:"******"}},{title:t("Actions"),width:200,render:function(e){return d().createElement(c.Space,null,d().createElement("a",{onClick:function(){return $("edit",e)}},t("Edit")),d().createElement("a",{onClick:function(){return q(e.name)}},t("Delete")))}}]},[q,$,t]),M=null==O||null==(e=O.meta)?void 0:e.updated;return d().createElement("div",null,M?d().createElement(c.Alert,{type:"warning",style:{marginBottom:a.marginMD,alignItems:"center"},description:d().createElement("div",null,t("Variables and secrets have been updated. A restart is required for the changes to take effect.")),action:d().createElement(c.Button,{size:"middle",type:"primary",onClick:function(){return C(function(){return I(this,function(e){switch(e.label){case 0:return[4,n.api.resource("app").refresh()];case 1:return e.sent(),[2]}})})()}},t("Restart now"))}):null,d().createElement(c.Card,null,d().createElement(c.Flex,{justify:"space-between",style:{marginBottom:a.marginMD}},d().createElement(P,{value:b.current,onSubmit:j,onReset:V}),d().createElement(c.Space,null,d().createElement(c.Button,{icon:d().createElement(r.ReloadOutlined,null),onClick:B},t("Refresh")),d().createElement(c.Button,{icon:d().createElement(r.DeleteOutlined,null),disabled:!w.length,onClick:function(){return q(w)}},t("Delete")),d().createElement(c.Dropdown,{menu:{onClick:function(e){"variable"===e.key?$("create"):"bulk"===e.key&&_()},items:[{key:"variable",label:t("Add variable")},{type:"divider"},{key:"bulk",label:t("Bulk import")}]}},d().createElement(c.Button,{type:"primary",icon:d().createElement(r.PlusOutlined,null)},t("Add new")," ",d().createElement(r.DownOutlined,null))))),d().createElement(l.Table,{rowKey:"name",loading:A,dataSource:x,columns:D,pagination:!1,rowSelection:{selectedRowKeys:w,onChange:function(e){return k(e)}}})))})}}]);
|