/* * 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{AbstractInteractableModule as v}from"@typo3/install/module/abstract-interactable-module.js";import I from"@typo3/backend/modal.js";import k from"@typo3/backend/notification.js";import d from"@typo3/core/ajax/ajax-request.js";import a from"@typo3/install/router.js";import u from"@typo3/core/event/regular-event.js";import"@typo3/backend/element/icon-element.js";var o;(function(r){r.checkButton=".t3js-referenceIndex-check",r.updateButton=".t3js-referenceIndex-update",r.resultContainer=".t3js-referenceIndex-result"})(o||(o={}));class y extends v{initialize(t){super.initialize(t),this.loadContent(),new u("click",e=>{e.preventDefault(),this.check()}).delegateTo(t,o.checkButton),new u("click",e=>{e.preventDefault(),this.update()}).delegateTo(t,o.updateButton)}loadContent(){const t=this.getModalBody();new d(a.getUrl("referenceIndex")).get({cache:"no-cache"}).then(async e=>{const n=await e.resolve();n.success===!0&&n.html!==void 0&&(t.innerHTML=n.html,n.buttons!==void 0&&I.setButtons(n.buttons))},e=>{a.handleAjaxError(e,t)})}check(){this.processReferenceIndex(!0)}update(){this.processReferenceIndex(!1)}processReferenceIndex(t){this.setModalButtonsState(!1);const e=this.getModalBody(),n=e.querySelector(o.resultContainer),f=this.renderProgressBar(n,{label:t?"Checking reference index...":"Updating reference index..."});new d(a.getUrl()).post({install:{action:"referenceIndexUpdate",token:this.getModuleContent().dataset.referenceIndexToken,checkOnly:t?"1":"0"}}).then(async l=>{const s=await l.resolve();if(f.remove(),s.success===!0&&s.result&&n){const c=s.result.errors&&s.result.errors.length>0,h=c?"warning":"success",p=c?"actions-exclamation":"actions-check",m=s.result.resultText||(c?"Issues Found":"Reference index is up to date");let i="";c?i=``:i="Index integrity is perfect.";const x=`
${m}
${i}
`;n.innerHTML=x}else k.error("Something went wrong","The request was not processed successfully. Please check the browser's console and TYPO3's log.")},l=>{a.handleAjaxError(l,e)}).finally(()=>{this.setModalButtonsState(!0)})}}var w=new y;export{w as default};