D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
cp
/
public
/
javascript
/
components
/
pages
/
VirtualDirectoryPage
/
Filename :
Protection.js
back
Copy
(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/VirtualDirectoryPage/Protection"],{2727:(e,t,i)=>{"use strict";i.r(t),i.d(t,{evictDomainHostingFieldCache:()=>n});const n=(e,t,i)=>{e.modify({id:e.identify({__typename:"Domain",id:btoa(`Domain:${t}`)}),fields:{hosting(e){const t={};for(const n in e)n===i||n.startsWith(`${i}(`)||(t[n]=e[n]);return t}}})}},2728:(e,t,i)=>{"use strict";i.r(t),i.d(t,{evictDomainVirtualDirectoryFieldsCache:()=>n});const n=(e,{domainId:t,fields:i})=>{Object.values(e.extract()).filter((({__typename:e})=>"VirtualDirectory"===e)).filter((({key:e})=>atob(e).split(":")[1]===t)).forEach((t=>{const n=e.identify(t);i.forEach((t=>e.evict({id:n,fieldName:t})))}))}},2729:(e,t,i)=>{"use strict";i.r(t),i.d(t,{evictDomainVirtualDirectoryMimeTypesCache:()=>r});var n=i(2726);const r=(e,t)=>{(0,n.evictDomainVirtualDirectoryFieldsCache)(e,{domainId:t,fields:["mimeType","mimeTypes"]})}},2730:(e,t,i)=>{"use strict";i.r(t),i.d(t,{evictDomainVirtualDirectoryProtectionCache:()=>r});var n=i(2726);const r=(e,t)=>{(0,n.evictDomainVirtualDirectoryFieldsCache)(e,{domainId:t,fields:["content","protectedDirectory"]})}},2726:(e,t,i)=>{"use strict";i.r(t),i.d(t,{evictDomainHostingFieldCache:()=>n.evictDomainHostingFieldCache,evictDomainVirtualDirectoryFieldsCache:()=>r.evictDomainVirtualDirectoryFieldsCache,evictDomainVirtualDirectoryMimeTypesCache:()=>o.evictDomainVirtualDirectoryMimeTypesCache,evictDomainVirtualDirectoryProtectionCache:()=>a.evictDomainVirtualDirectoryProtectionCache,modifyCacheOnProtectedDirectoryAddOrDelete:()=>d.modifyCacheOnProtectedDirectoryAddOrDelete});var n=i(2727),r=i(2728),o=i(2729),a=i(2730),d=i(2731)},2731:(e,t,i)=>{"use strict";i.r(t),i.d(t,{modifyCacheOnProtectedDirectoryAddOrDelete:()=>r});var n=i(2726);const r=(e,t)=>{(0,n.evictDomainHostingFieldCache)(e,t,"protectedDirectories"),(0,n.evictDomainVirtualDirectoryProtectionCache)(e,t)}},2744:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>N});var n=i(285),r=i(596),o=i.n(r),a=i(580),d=i(579),s=i(628),c=i(89),l=i(286),u=i(1101),m=i(594),p=i(536),f=i(1421),y=i(1168),v=i.n(y),D=i(2745),k=i.n(D);const h=c.Locale.getSection("components.lists.ProtectedDirectoryUser"),g=c.Locale.getTranslate("components.lists.ProtectedDirectoryUser"),b=c.Locale.getTranslate("components.buttons"),x=({directoryId:e,protectedDirectory:t,listKey:i,userCreationLink:r,emptyListViewAddon:o=null,toolbarAddon:c=null})=>{const y=(0,a.useLocation)(),D=btoa(`ProtectedDirectory:${e}`),[x,N]=(0,n.useState)([]),[S,P]=(0,n.useState)([]),{queryResult:{refetch:j},listData:T,listProps:I,listInput:V}=(0,u.useGraphQlList)({key:i,onListInputChange:()=>N([]),query:v(),variables:{id:D},extractList:e=>e.protectedDirectory.users}),[L]=(0,s.useMutation)(k(),{refetchQueries:[v()],update:e=>(0,f.evictEntitiesCache)({cache:e,typename:"ProtectedDirectory",ids:[D],fields:["users"]}),awaitRefetchQueries:!0,onCompleted(){(0,p.addToast)({intent:"success",message:h.lmsg("removeSuccess")})},onError({message:e}){(0,p.addToast)({intent:"danger",message:e}),j()}}),w=(0,n.jsx)(l.Button,{icon:"plus",intent:"primary",component:d.Link,to:r,tooltip:(0,n.jsx)(g,{content:"addTooltip",params:{directory:`/${t.path}`}}),"data-type":"protected-directory-user-add",children:(0,n.jsx)(g,{content:"add"})}),C=!!V.searchFilters?.login;return(0,n.jsx)(u.GraphQlList,{rowKey:"id",filtered:C,loadingRows:S,selection:x,onSelectionChange:N,columns:[{key:"login",title:(0,n.jsx)(g,{content:"login"}),sortable:!0,type:"title"},{key:"actions",type:"actions",render:({id:e})=>(0,n.jsx)(l.ListActions,{children:(0,n.jsx)(l.ListAction,{primary:!0,icon:"key",component:d.Link,to:{...y,pathname:`${(0,m.getId)(e)}/password`},children:(0,n.jsx)(g,{content:"changePassword"})})})}],toolbar:(0,n.jsxs)(l.Toolbar,{children:[(0,n.jsx)(l.ToolbarGroup,{title:"",children:w}),(0,n.jsx)(l.ToolbarGroup,{title:"",children:(0,n.jsx)(l.ListOperation,{critical:!0,noSelectionText:h.lmsg("noSelectionText"),confirmationText:()=>h.formatMessage("removeConfirmation",{login:(0,n.jsx)("b",{children:T.nodes.find((({id:e})=>x[0]===e)).login}),count:x.length}),actionButtonText:(0,n.jsx)(b,{content:"yesRemove"}),cancelButtonText:(0,n.jsx)(b,{content:"cancel"}),children:(0,n.jsx)(l.Button,{"data-type":"protected-directory-user-remove",onClick:async()=>{P(x),await L({variables:{ids:x}}),P([])},tooltip:(0,n.jsx)(g,{content:"removeTooltip"}),children:(0,n.jsx)(g,{content:"remove"})})})}),c,(0,n.jsx)(l.ToolbarExpander,{}),(0,n.jsx)(l.ToolbarGroup,{groupable:!1,title:"",children:(0,n.jsx)(u.GraphQlList.SearchBar,{name:"login"})})]}),emptyView:(0,n.jsxs)(n.Fragment,{children:[o,(0,n.jsx)(l.ListEmptyView,{title:(0,n.jsx)(g,{content:"emptyViewTitle"}),actions:w})]}),...I})};x.propTypes={directoryId:o().string.isRequired,protectedDirectory:o().shape({path:o().string.isRequired}).isRequired,listKey:o().string.isRequired,userCreationLink:o().oneOfType([o().string,o().object]).isRequired,toolbarAddon:o().node,emptyListViewAddon:o().node};const N=x},2743:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>n.default});var n=i(2744)},2800:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>g});var n=i(596),r=i.n(n),o=i(628),a=i(580),d=i(286),s=i(89),c=i(536),l=i(594),u=i(2726),m=i(1101),p=i(1179),f=i.n(p),y=i(2801),v=i.n(y),D=i(285);const k=s.Locale.getTranslate("components.pages.VirtualDirectory.Protection.NoProtectionView"),h=({domainId:e,webDirName:t,onProtectError:i,userListKey:n})=>{const r=(0,a.useLocation)(),s=(0,a.useNavigate)(),[p,{loading:y}]=(0,o.useMutation)(v(),{refetchQueries:[f()],awaitRefetchQueries:!0,onCompleted({addProtectedDirectory:{protectedDirectory:e}},{variables:{input:{path:t}}}){(0,c.addToast)({intent:"success",message:(0,D.jsx)(k,{content:"successProtection",params:{path:(0,D.jsx)("b",{children:t})}})}),s({...r,pathname:`./${(0,l.getId)(e.id)}/add-user`})},onError({message:e}){(0,c.addToast)({intent:"danger",message:e}),i()},update(t){(0,u.modifyCacheOnProtectedDirectoryAddOrDelete)(t,e)}});return(0,D.jsx)(d.ListEmptyView,{title:(0,D.jsx)(k,{content:"title"}),actions:(0,D.jsx)(d.Button,{intent:"primary",state:y?"loading":void 0,onClick:()=>p({variables:{domainId:e,input:{path:t||"/",realm:""},protectedDirectoryUserListInput:(0,m.readGraphQlListInputFromStorage)({key:n})}}),"data-cy":"protect",children:(0,D.jsx)(k,{content:"protect"})})})};h.propTypes={domainId:r().number.isRequired,webDirName:r().string.isRequired,onProtectError:r().func.isRequired,userListKey:r().string.isRequired};const g=h},2799:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>k});var n=i(596),r=i.n(n),o=i(579),a=i(580),d=i(586),s=i(286),c=i(89),l=i(594),u=i(2800),m=i(2802),p=i(1179),f=i.n(p),y=i(285);const v=c.Locale.getTranslate("components.pages.VirtualDirectory.Protection"),D=({params:{domainId:e},userListKey:t})=>{const[i]=(0,o.useSearchParams)(),n=i.get("path")||"/",{data:{domain:{hosting:{virtualDirectory:{webDirName:r,protectedDirectory:c,isValidForProtection:p}}}},refetch:D}=(0,d.useQuery)(f(),{variables:{domainId:btoa(`Domain:${e}`),path:n}});return p?c?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(m.default,{domainId:e,directoryId:(0,l.getId)(c.id),protectedDirectory:c,listKey:t}),(0,y.jsx)(a.Outlet,{})]}):(0,y.jsx)(u.default,{domainId:e,webDirName:r,onProtectError:D,userListKey:t}):(0,y.jsx)(s.StatusMessage,{intent:"info",children:(0,y.jsx)(v,{content:"notSupported"})})};D.propTypes={params:r().object.isRequired,userListKey:r().string.isRequired};const k=D},2802:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>u});var n=i(596),r=i.n(n),o=i(580),a=i(286),d=i(2803),s=i(2743),c=(i(2804),i(285));const l=({domainId:e,directoryId:t,protectedDirectory:i,listKey:n})=>{const r=(0,o.useLocation)(),l=(0,c.jsx)(d.default,{domainId:e,directoryId:t});return(0,c.jsx)(s.default,{directoryId:t,protectedDirectory:i,listKey:n,userCreationLink:{...r,pathname:`./${t}/add-user`},toolbarAddon:l,emptyListViewAddon:(0,c.jsx)(a.Toolbar,{className:"virtual-directory-page-protection-users-toolbar",children:l})})};l.propTypes={domainId:r().string.isRequired,directoryId:r().string.isRequired,protectedDirectory:r().shape({path:r().string.isRequired}).isRequired,listKey:r().string.isRequired};const u=l},2803:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>h});var n=i(285),r=i(596),o=i.n(r),a=i(580),d=i(628),s=i(286),c=i(89),l=i(536),u=i(2726),m=i(1179),p=i.n(m),f=i(2732),y=i.n(f);const v=c.Locale.getTranslate("components.pages.VirtualDirectory.Protection"),D=c.Locale.getSection("components.pages.VirtualDirectory.Protection"),k=({domainId:e,directoryId:t})=>{const i=(0,a.useLocation)(),r=(0,a.useNavigate)(),[o,c]=(0,n.useState)(!1),[m,{loading:f}]=(0,d.useMutation)(y(),{refetchQueries:[p()],awaitRefetchQueries:!0,onCompleted(){c(!1)},onError({message:e}){(0,l.addToast)({intent:"danger",message:e})},update(t){(0,u.modifyCacheOnProtectedDirectoryAddOrDelete)(t,e)}});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(s.ToolbarGroup,{title:D.lmsg("tools"),children:[(0,n.jsx)(s.Button,{icon:"lock-open-cross",onClick:()=>c(!0),tooltip:(0,n.jsx)(v,{content:"removeProtectionTooltip"}),"data-cy":"remove-protection",children:(0,n.jsx)(v,{content:"removeProtection"})}),(0,n.jsx)(s.Button,{onClick:()=>r({...i,pathname:`${t}/edit`}),tooltip:(0,n.jsx)(v,{content:"settingsTooltip"}),"data-cy":"protection-settings",children:(0,n.jsx)(v,{content:"settings"})})]}),(0,n.jsx)(s.Dialog,{isOpen:o,onClose:()=>c(!1),size:"xs",buttons:(0,n.jsx)(s.Button,{intent:"danger",onClick:()=>{m({variables:{ids:[btoa(`ProtectedDirectory:${t}`)]}})},state:f?"loading":void 0,"data-cy":"remove-protection-confirm",children:(0,n.jsx)(v,{content:"removeProtection"})}),children:(0,n.jsx)(v,{content:"removeProtectionConfirmation"})})]})};k.propTypes={domainId:o().string.isRequired,directoryId:o().string.isRequired};const h=k},2798:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>n.default});var n=i(2799)},1421:(e,t,i)=>{"use strict";i.r(t),i.d(t,{evictEntitiesCache:()=>n});const n=({cache:e,typename:t,ids:i=[],fields:n=[]})=>{Object.values(e.extract()).filter((({__typename:e,id:n})=>e===t&&(0===i.length||i.includes(n)))).forEach((t=>{n.forEach((i=>e.evict({id:e.identify(t),fieldName:i})))}))}},2745:e=>{var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DeleteProtectedDirectoryUser"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ids"}},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"deleteProtectedDirectoryUser"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"ids"},value:{kind:"Variable",name:{kind:"Name",value:"ids"}}}]}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"ids"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:131}};t.loc.source={body:"mutation DeleteProtectedDirectoryUser($ids: [ID!]!) {\n deleteProtectedDirectoryUser(input: { ids: $ids} ) {\n ids\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,t){if("FragmentSpread"===e.kind)t.add(e.name.value);else if("VariableDefinition"===e.kind){var n=e.type;"NamedType"===n.kind&&t.add(n.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,t)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,t)})),e.definitions&&e.definitions.forEach((function(e){i(e,t)}))}var n={};function r(e,t){for(var i=0;i<e.definitions.length;i++){var n=e.definitions[i];if(n.name&&n.name.value==t)return n}}t.definitions.forEach((function(e){if(e.name){var t=new Set;i(e,t),n[e.name.value]=t}})),e.exports=t,e.exports.DeleteProtectedDirectoryUser=function(e,t){var i={kind:e.kind,definitions:[r(e,t)]};e.hasOwnProperty("loc")&&(i.loc=e.loc);var o=n[t]||new Set,a=new Set,d=new Set;for(o.forEach((function(e){d.add(e)}));d.size>0;){var s=d;d=new Set,s.forEach((function(e){a.has(e)||(a.add(e),(n[e]||new Set).forEach((function(e){d.add(e)})))}))}return a.forEach((function(t){var n=r(e,t);n&&i.definitions.push(n)})),i}(t,"DeleteProtectedDirectoryUser")},2801:(e,t,i)=>{var n={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ProtectVirtualDirectory"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"domainId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"input"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ProtectedDirectoryInput"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"protectedDirectoryUserListInput"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ProtectedDirectoryUserListInput"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"addProtectedDirectory"},arguments:[{kind:"Argument",name:{kind:"Name",value:"domainId"},value:{kind:"Variable",name:{kind:"Name",value:"domainId"}}},{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"input"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"protectedDirectory"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"path"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"users"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"Variable",name:{kind:"Name",value:"protectedDirectoryUserListInput"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ProtectedDirectoryUserListFragment"},directives:[]}]}}]}}]}}]}}],loc:{start:0,end:502}};n.loc.source={body:'#import "queries/ProtectedDirectoryUserListFragment.graphql"\n\nmutation ProtectVirtualDirectory(\n $domainId: ID!,\n $input: ProtectedDirectoryInput!, \n $protectedDirectoryUserListInput: ProtectedDirectoryUserListInput!\n) {\n addProtectedDirectory(domainId: $domainId, input: $input) {\n protectedDirectory {\n id\n path\n users(input: $protectedDirectoryUserListInput) {\n ...ProtectedDirectoryUserListFragment\n }\n }\n }\n}\n',name:"GraphQL request",locationOffset:{line:1,column:1}};var r={};function o(e,t){if("FragmentSpread"===e.kind)t.add(e.name.value);else if("VariableDefinition"===e.kind){var i=e.type;"NamedType"===i.kind&&t.add(i.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){o(e,t)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){o(e,t)})),e.definitions&&e.definitions.forEach((function(e){o(e,t)}))}n.definitions=n.definitions.concat(i(1169).definitions.filter((function(e){if("FragmentDefinition"!==e.kind)return!0;var t=e.name.value;return!r[t]&&(r[t]=!0,!0)})));var a={};function d(e,t){for(var i=0;i<e.definitions.length;i++){var n=e.definitions[i];if(n.name&&n.name.value==t)return n}}n.definitions.forEach((function(e){if(e.name){var t=new Set;o(e,t),a[e.name.value]=t}})),e.exports=n,e.exports.ProtectVirtualDirectory=function(e,t){var i={kind:e.kind,definitions:[d(e,t)]};e.hasOwnProperty("loc")&&(i.loc=e.loc);var n=a[t]||new Set,r=new Set,o=new Set;for(n.forEach((function(e){o.add(e)}));o.size>0;){var s=o;o=new Set,s.forEach((function(e){r.has(e)||(r.add(e),(a[e]||new Set).forEach((function(e){o.add(e)})))}))}return r.forEach((function(t){var n=d(e,t);n&&i.definitions.push(n)})),i}(n,"ProtectVirtualDirectory")},2732:e=>{var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DeleteProtectedDirectory"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ids"}},type:{kind:"NonNullType",type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"deleteProtectedDirectory"},arguments:[{kind:"Argument",name:{kind:"Name",value:"input"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"ids"},value:{kind:"Variable",name:{kind:"Name",value:"ids"}}}]}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"ids"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:123}};t.loc.source={body:"mutation DeleteProtectedDirectory($ids: [ID!]!) {\n deleteProtectedDirectory(input: { ids: $ids} ) {\n ids\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,t){if("FragmentSpread"===e.kind)t.add(e.name.value);else if("VariableDefinition"===e.kind){var n=e.type;"NamedType"===n.kind&&t.add(n.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,t)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,t)})),e.definitions&&e.definitions.forEach((function(e){i(e,t)}))}var n={};function r(e,t){for(var i=0;i<e.definitions.length;i++){var n=e.definitions[i];if(n.name&&n.name.value==t)return n}}t.definitions.forEach((function(e){if(e.name){var t=new Set;i(e,t),n[e.name.value]=t}})),e.exports=t,e.exports.DeleteProtectedDirectory=function(e,t){var i={kind:e.kind,definitions:[r(e,t)]};e.hasOwnProperty("loc")&&(i.loc=e.loc);var o=n[t]||new Set,a=new Set,d=new Set;for(o.forEach((function(e){d.add(e)}));d.size>0;){var s=d;d=new Set,s.forEach((function(e){a.has(e)||(a.add(e),(n[e]||new Set).forEach((function(e){d.add(e)})))}))}return a.forEach((function(t){var n=r(e,t);n&&i.definitions.push(n)})),i}(t,"DeleteProtectedDirectory")},2804:(e,t,i)=>{"use strict";i.r(t)}}]); //# sourceMappingURL=Protection.js.map?b74b52606bbe70ff77e3