TYPO3 v15 dev-main snapshot ()
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
import l from"@typo3/core/ajax/ajax-request.js";import u from"@typo3/core/document-service.js";import o from"@typo3/core/event/regular-event.js";import d from"@typo3/backend/notification.js";import c from"@typo3/backend/modal.js";import{SeverityEnum as f}from"@typo3/backend/enum/severity.js";import{selector as v}from"@typo3/core/literals.js";import{sudoModeInterceptor as m}from"@typo3/backend/security/sudo-mode-interceptor.js";var a;(function(s){s.deactivteProviderButton=".t3js-deactivate-provider-button",s.deactivteMfaButton=".t3js-deactivate-mfa-button",s.providerslist=".t3js-mfa-active-providers-list",s.mfaStatusLabel=".t3js-mfa-status-label"})(a||(a={}));class h{constructor(t,e){this.options=null,this.fullElement=null,this.deactivteProviderButtons=null,this.deactivteMfaButton=null,this.providersList=null,this.mfaStatusLabel=null,this.request=null,this.options=e,u.ready().then(i=>{this.fullElement=i.querySelector(t),this.deactivteProviderButtons=this.fullElement.querySelectorAll(a.deactivteProviderButton),this.deactivteMfaButton=this.fullElement.querySelector(a.deactivteMfaButton),this.providersList=this.fullElement.querySelector(a.providerslist),this.mfaStatusLabel=this.fullElement.parentElement.querySelector(a.mfaStatusLabel),this.registerEvents()})}registerEvents(){new o("click",t=>{t.preventDefault(),this.prepareDeactivateRequest(this.deactivteMfaButton)}).bindTo(this.deactivteMfaButton),this.deactivteProviderButtons.forEach(t=>{new o("click",e=>{e.preventDefault(),this.prepareDeactivateRequest(t)}).bindTo(t)})}prepareDeactivateRequest(t){const e=c.show(t.dataset.confirmationTitle||t.getAttribute("title")||"Deactivate provider(s)",t.dataset.confirmationContent||"Are you sure you want to continue? This action cannot be undone and will be applied immediately!",f.warning,[{text:t.dataset.confirmationCancelText||"Cancel",active:!0,btnClass:"btn-default",name:"cancel"},{text:t.dataset.confirmationDeactivateText||"Deactivate",btnClass:"btn-warning",name:"deactivate",trigger:()=>{this.sendDeactivateRequest(t.dataset.provider)}}]);e.addEventListener("button.clicked",()=>{e.hideModal()})}sendDeactivateRequest(t){this.request instanceof l&&this.request.abort(),this.request=new l(TYPO3.settings.ajaxUrls.mfa).addMiddleware(m),this.request.post({action:"deactivate",provider:t,userId:this.options.userId,tableName:this.options.tableName}).then(async e=>{const i=await e.resolve();if(i.status.length>0&&i.status.forEach(r=>{i.success?d.success(r.title,r.message):d.error(r.title,r.message)}),!i.success)return;if(t===void 0||i.remaining===0){this.deactivateMfa();return}if(this.providersList===null)return;const n=this.providersList.querySelector(v`li#provider-${t}`);if(n===null)return;n.remove(),this.providersList.querySelectorAll("li").length===0&&this.deactivateMfa()}).finally(()=>{this.request=null})}deactivateMfa(){this.deactivteMfaButton.classList.add("disabled"),this.deactivteMfaButton.setAttribute("disabled","disabled"),this.providersList!==null&&this.providersList.remove(),this.mfaStatusLabel!==null&&(this.mfaStatusLabel.innerText=this.mfaStatusLabel.dataset.alternativeLabel,this.mfaStatusLabel.classList.remove("badge-success"),this.mfaStatusLabel.classList.add("badge-danger"))}}export{h as default};
|
||||
Reference in New Issue
Block a user