From 6154be9d20bc63e5357003cc4640fb1495a01d37 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 3 Jan 2021 12:46:49 +0100 Subject: [PATCH] Convert `Acp/Ui/Devtools/Project/Sync` to TypeScript --- .../Core/Acp/Ui/Devtools/Project/Sync.js | 230 +++++++++------- .../Core/Acp/Ui/Devtools/Project/Sync.js | 200 -------------- .../Core/Acp/Ui/Devtools/Project/Sync.ts | 260 ++++++++++++++++++ .../files/ts/WoltLabSuite/Core/Ajax/Data.ts | 17 ++ .../ts/WoltLabSuite/Core/Ajax/Request.ts | 19 +- 5 files changed, 407 insertions(+), 319 deletions(-) delete mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.js create mode 100644 wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.ts diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.js index b571bd770b..e98b833bf9 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.js @@ -1,156 +1,184 @@ -define(['Ajax', 'Dictionary', 'Language', 'Ui/Dialog', 'Ui/Notification'], function (Ajax, Dictionary, Language, UiDialog, UiNotification) { +define(["require", "exports", "tslib", "../../../../Ajax", "../../../../Language", "../../../../Ui/Dialog", "../../../../Ui/Notification"], function (require, exports, tslib_1, Ajax, Language, Dialog_1, UiNotification) { "use strict"; - var _buttons = new Dictionary(); - var _buttonStatus = new Dictionary(); - var _buttonSyncAll = null; - var _container = elById('syncPipMatches'); - var _pips = []; - var _projectId = 0; - var _queue = []; - return { - init: function (projectId) { - _projectId = projectId; - elById('syncShowOnlyMatches').addEventListener('change', function () { - _container.classList.toggle('jsShowOnlyMatches'); + Object.defineProperty(exports, "__esModule", { value: true }); + exports.init = void 0; + Ajax = tslib_1.__importStar(Ajax); + Language = tslib_1.__importStar(Language); + Dialog_1 = tslib_1.__importDefault(Dialog_1); + UiNotification = tslib_1.__importStar(UiNotification); + class AcpUiDevtoolsProjectSync { + constructor(projectId) { + this.buttons = new Map(); + this.buttonStatus = new Map(); + this.buttonSyncAll = undefined; + this.container = document.getElementById("syncPipMatches"); + this.pips = []; + this.queue = []; + this.projectId = projectId; + const restrictedSync = document.getElementById("syncShowOnlyMatches"); + restrictedSync.addEventListener("change", () => { + this.container.classList.toggle("jsShowOnlyMatches"); }); - var existingPips = [], knownPips = [], tmpPips = []; - elBySelAll('.jsHasPipTargets:not(.jsSkipTargetDetection)', _container, (function (pip) { - var pluginName = elData(pip, 'plugin-name'); - var targets = []; - elBySelAll('.jsHasPipTargets[data-plugin-name="' + pluginName + '"] .jsInvokePip', _container, (function (button) { - var target = elData(button, 'target'); + const existingPips = []; + const knownPips = []; + const tmpPips = []; + this.container + .querySelectorAll(".jsHasPipTargets:not(.jsSkipTargetDetection)") + .forEach((pip) => { + const pluginName = pip.dataset.pluginName; + const targets = []; + this.container + .querySelectorAll(`.jsHasPipTargets[data-plugin-name="${pluginName}"] .jsInvokePip`) + .forEach((button) => { + const target = button.dataset.target; targets.push(target); - button.addEventListener('click', (function (event) { + button.addEventListener("click", (event) => { event.preventDefault(); - if (_queue.length > 0) + if (this.queue.length > 0) { return; - this._sync(pluginName, target); - }).bind(this)); - _buttons.set(pluginName + '-' + target, button); - _buttonStatus.set(pluginName + '-' + target, elBySel('.jsHasPipTargets[data-plugin-name="' + pluginName + '"] .jsInvokePipResult[data-target="' + target + '"]', _container)); - }).bind(this)); - var data = { - dependencies: JSON.parse(elData(pip, 'sync-dependencies')), - pluginName: pluginName, - targets: targets + } + this.sync(pluginName, target); + }); + const identifier = this.getButtonIdentifier(pluginName, target); + this.buttons.set(identifier, button); + this.buttonStatus.set(identifier, this.container.querySelector(`.jsHasPipTargets[data-plugin-name="${pluginName}"] .jsInvokePipResult[data-target="${target}"]`)); + }); + const data = { + dependencies: JSON.parse(pip.dataset.syncDependencies), + pluginName, + targets, }; if (data.dependencies.length > 0) { tmpPips.push(data); } else { - _pips.push(data); + this.pips.push(data); knownPips.push(pluginName); } existingPips.push(pluginName); - }).bind(this)); - var resolvedDependency = false; + }); + let resolvedDependency = false; while (tmpPips.length > 0) { resolvedDependency = false; - var openDependencies, item, length = tmpPips.length; - for (var i = 0; i < length; i++) { - item = tmpPips[i]; - openDependencies = item.dependencies.filter(function (dependency) { + tmpPips.forEach((item, index) => { + if (resolvedDependency) { + return; + } + const openDependencies = item.dependencies.filter((dependency) => { // Ignore any dependencies that are not present. if (existingPips.indexOf(dependency) === -1) { - window.console.info('The dependency "' + dependency + '" does not exist and has been ignored.'); + window.console.info(`The dependency "${dependency}" does not exist and has been ignored.`); return false; } - return (knownPips.indexOf(dependency) === -1); + return !knownPips.includes(dependency); }); if (openDependencies.length === 0) { knownPips.push(item.pluginName); - _pips.push(item); - tmpPips.splice(i, 1); + this.pips.push(item); + tmpPips.splice(index, 1); resolvedDependency = true; - break; } - } + }); if (!resolvedDependency) { // We could not resolve any dependency, either because there is no more pip // in `tmpPips` or we're facing a circular dependency. In case there are items // left, we simply append them to the end and hope for the operation to // complete anyway, despite unmatched dependencies. - tmpPips.forEach(function (pip) { - window.console.warn('Unable to resolve dependencies for', pip); - _pips.push(pip); + tmpPips.forEach((pip) => { + window.console.warn("Unable to resolve dependencies for", pip); + this.pips.push(pip); }); break; } } - var syncAll = elCreate('li'); - syncAll.innerHTML = ' ' + Language.get('wcf.acp.devtools.sync.syncAll') + ''; - _buttonSyncAll = syncAll.children[0]; - _buttonSyncAll.addEventListener('click', this._syncAll.bind(this)); - var list = elBySel('.contentHeaderNavigation > ul'); - list.insertBefore(syncAll, list.firstElementChild); - }, - _sync: function (pluginName, target) { - _buttons.get(pluginName + '-' + target).disabled = true; - _buttonStatus.get(pluginName + '-' + target).innerHTML = ''; + const syncAll = document.createElement("li"); + syncAll.innerHTML = ` ${Language.get("wcf.acp.devtools.sync.syncAll")}`; + this.buttonSyncAll = syncAll.children[0]; + this.buttonSyncAll.addEventListener("click", this.syncAll.bind(this)); + const list = document.querySelector(".contentHeaderNavigation > ul"); + list.insertAdjacentElement("afterbegin", syncAll); + } + sync(pluginName, target) { + const identifier = this.getButtonIdentifier(pluginName, target); + this.buttons.get(identifier).disabled = true; + this.buttonStatus.get(identifier).innerHTML = ''; Ajax.api(this, { parameters: { - pluginName: pluginName, - target: target - } + pluginName, + target, + }, }); - }, - _syncAll: function (event) { + } + syncAll(event) { event.preventDefault(); - if (_buttonSyncAll.classList.contains('disabled')) { + if (this.buttonSyncAll.classList.contains("disabled")) { return; } - _buttonSyncAll.classList.add('disabled'); - _queue = []; - _pips.forEach(function (pip) { - pip.targets.forEach(function (target) { - _queue.push([pip.pluginName, target]); + this.buttonSyncAll.classList.add("disabled"); + this.queue = []; + this.pips.forEach((pip) => { + pip.targets.forEach((target) => { + this.queue.push([pip.pluginName, target]); }); }); - this._syncNext(); - }, - _syncNext: function () { - if (_queue.length === 0) { - _buttonSyncAll.classList.remove('disabled'); + this.syncNext(); + } + syncNext() { + if (this.queue.length === 0) { + this.buttonSyncAll.classList.remove("disabled"); UiNotification.show(); return; } - var next = _queue.shift(); - this._sync(next[0], next[1]); - }, - _ajaxSuccess: function (data) { - _buttons.get(data.returnValues.pluginName + '-' + data.returnValues.target).disabled = false; - _buttonStatus.get(data.returnValues.pluginName + '-' + data.returnValues.target).innerHTML = data.returnValues.timeElapsed; - this._syncNext(); - }, - _ajaxFailure: function (data, responseText, xhr, requestData) { - _buttons.get(requestData.parameters.pluginName + '-' + requestData.parameters.target).disabled = false; - var buttonStatus = _buttonStatus.get(requestData.parameters.pluginName + '-' + requestData.parameters.target); - buttonStatus.innerHTML = '' + Language.get('wcf.acp.devtools.sync.status.failure') + ''; - buttonStatus.children[0].addEventListener('click', (function (event) { + const next = this.queue.shift(); + this.sync(next[0], next[1]); + } + getButtonIdentifier(pluginName, target) { + return `${pluginName}-${target}`; + } + _ajaxSuccess(data) { + const identifier = this.getButtonIdentifier(data.returnValues.pluginName, data.returnValues.target); + this.buttons.get(identifier).disabled = false; + this.buttonStatus.get(identifier).innerHTML = data.returnValues.timeElapsed; + this.syncNext(); + } + _ajaxFailure(data, responseText, xhr, requestData) { + const identifier = this.getButtonIdentifier(requestData.parameters.pluginName, requestData.parameters.target); + this.buttons.get(identifier).disabled = false; + const buttonStatus = this.buttonStatus.get(identifier); + buttonStatus.innerHTML = '' + Language.get("wcf.acp.devtools.sync.status.failure") + ""; + buttonStatus.children[0].addEventListener("click", (event) => { event.preventDefault(); - UiDialog.open(this, Ajax.getRequestObject(this).getErrorHtml(data, xhr)); - }).bind(this)); - _buttonSyncAll.classList.remove('disabled'); - }, - _ajaxSetup: function () { + Dialog_1.default.open(this, Ajax.getRequestObject(this).getErrorHtml(data, xhr)); + }); + this.buttonSyncAll.classList.remove("disabled"); + return false; + } + _ajaxSetup() { return { data: { - actionName: 'invoke', - className: 'wcf\\data\\package\\installation\\plugin\\PackageInstallationPluginAction', + actionName: "invoke", + className: "wcf\\data\\package\\installation\\plugin\\PackageInstallationPluginAction", parameters: { - projectID: _projectId - } - } + projectID: this.projectId, + }, + }, }; - }, - _dialogSetup: function () { + } + _dialogSetup() { return { - id: 'devtoolsProjectSyncPipError', + id: "devtoolsProjectSyncPipError", options: { - title: Language.get('wcf.global.error.title') + title: Language.get("wcf.global.error.title"), }, - source: null + source: null, }; } - }; + } + let acpUiDevtoolsProjectSync; + function init(projectId) { + if (!acpUiDevtoolsProjectSync) { + acpUiDevtoolsProjectSync = new AcpUiDevtoolsProjectSync(projectId); + } + } + exports.init = init; }); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.js deleted file mode 100644 index 8f2cb3f5da..0000000000 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.js +++ /dev/null @@ -1,200 +0,0 @@ -define(['Ajax', 'Dictionary', 'Language', 'Ui/Dialog', 'Ui/Notification'], function (Ajax, Dictionary, Language, UiDialog, UiNotification) { - "use strict"; - - var _buttons = new Dictionary(); - var _buttonStatus = new Dictionary(); - var _buttonSyncAll = null; - var _container = elById('syncPipMatches'); - var _pips = []; - var _projectId = 0; - var _queue = []; - - return { - init: function (projectId) { - _projectId = projectId; - - - elById('syncShowOnlyMatches').addEventListener('change', function() { - _container.classList.toggle('jsShowOnlyMatches'); - }); - - var existingPips = [], knownPips = [], tmpPips = []; - elBySelAll('.jsHasPipTargets:not(.jsSkipTargetDetection)', _container, (function (pip) { - var pluginName = elData(pip, 'plugin-name'); - var targets = []; - - elBySelAll('.jsHasPipTargets[data-plugin-name="' + pluginName + '"] .jsInvokePip', _container, (function(button) { - var target = elData(button, 'target'); - targets.push(target); - - button.addEventListener('click', (function(event) { - event.preventDefault(); - - if (_queue.length > 0) return; - - this._sync(pluginName, target); - }).bind(this)); - - _buttons.set(pluginName + '-' + target, button); - _buttonStatus.set(pluginName + '-' + target, elBySel('.jsHasPipTargets[data-plugin-name="' + pluginName + '"] .jsInvokePipResult[data-target="' + target + '"]', _container)); - }).bind(this)); - - var data = { - dependencies: JSON.parse(elData(pip, 'sync-dependencies')), - pluginName: pluginName, - targets: targets - }; - - if (data.dependencies.length > 0) { - tmpPips.push(data); - } - else { - _pips.push(data); - knownPips.push(pluginName); - } - - existingPips.push(pluginName); - }).bind(this)); - - var resolvedDependency = false; - while (tmpPips.length > 0) { - resolvedDependency = false; - - var openDependencies, item, length = tmpPips.length; - for (var i = 0; i < length; i++) { - item = tmpPips[i]; - - openDependencies = item.dependencies.filter(function (dependency) { - // Ignore any dependencies that are not present. - if (existingPips.indexOf(dependency) === -1) { - window.console.info('The dependency "' + dependency + '" does not exist and has been ignored.'); - return false; - } - - return (knownPips.indexOf(dependency) === -1); - }); - - if (openDependencies.length === 0) { - knownPips.push(item.pluginName); - _pips.push(item); - tmpPips.splice(i, 1); - - resolvedDependency = true; - break; - } - } - - if (!resolvedDependency) { - // We could not resolve any dependency, either because there is no more pip - // in `tmpPips` or we're facing a circular dependency. In case there are items - // left, we simply append them to the end and hope for the operation to - // complete anyway, despite unmatched dependencies. - tmpPips.forEach(function(pip) { - window.console.warn('Unable to resolve dependencies for', pip); - - _pips.push(pip); - }); - - break; - } - } - - var syncAll = elCreate('li'); - syncAll.innerHTML = ' ' + Language.get('wcf.acp.devtools.sync.syncAll') + ''; - _buttonSyncAll = syncAll.children[0]; - _buttonSyncAll.addEventListener('click', this._syncAll.bind(this)); - - var list = elBySel('.contentHeaderNavigation > ul'); - list.insertBefore(syncAll, list.firstElementChild); - }, - - _sync: function (pluginName, target) { - _buttons.get(pluginName + '-' + target).disabled = true; - _buttonStatus.get(pluginName + '-' + target).innerHTML = ''; - - Ajax.api(this, { - parameters: { - pluginName: pluginName, - target: target - } - }); - }, - - _syncAll: function (event) { - event.preventDefault(); - - if (_buttonSyncAll.classList.contains('disabled')) { - return; - } - - _buttonSyncAll.classList.add('disabled'); - - _queue = []; - _pips.forEach(function(pip) { - pip.targets.forEach(function (target) { - _queue.push([pip.pluginName, target]); - }); - }); - this._syncNext(); - }, - - _syncNext: function () { - if (_queue.length === 0) { - _buttonSyncAll.classList.remove('disabled'); - - UiNotification.show(); - - return; - } - - var next = _queue.shift(); - this._sync(next[0], next[1]); - }, - - _ajaxSuccess: function(data) { - _buttons.get(data.returnValues.pluginName + '-' + data.returnValues.target).disabled = false; - _buttonStatus.get(data.returnValues.pluginName + '-' + data.returnValues.target).innerHTML = data.returnValues.timeElapsed; - - this._syncNext(); - }, - - _ajaxFailure: function (data, responseText, xhr, requestData) { - _buttons.get(requestData.parameters.pluginName + '-' + requestData.parameters.target).disabled = false; - - var buttonStatus = _buttonStatus.get(requestData.parameters.pluginName + '-' + requestData.parameters.target); - buttonStatus.innerHTML = '' + Language.get('wcf.acp.devtools.sync.status.failure') + ''; - buttonStatus.children[0].addEventListener('click', (function (event) { - event.preventDefault(); - - UiDialog.open( - this, - Ajax.getRequestObject(this).getErrorHtml(data, xhr) - ); - }).bind(this)); - - _buttonSyncAll.classList.remove('disabled'); - }, - - _ajaxSetup: function () { - return { - data: { - actionName: 'invoke', - className: 'wcf\\data\\package\\installation\\plugin\\PackageInstallationPluginAction', - parameters: { - projectID: _projectId - } - } - } - }, - - _dialogSetup: function() { - return { - id: 'devtoolsProjectSyncPipError', - options: { - title: Language.get('wcf.global.error.title') - }, - source: null - } - } - }; -}); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.ts new file mode 100644 index 0000000000..516bb23a51 --- /dev/null +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.ts @@ -0,0 +1,260 @@ +import * as Ajax from "../../../../Ajax"; +import * as Language from "../../../../Language"; +import UiDialog from "../../../../Ui/Dialog"; +import * as UiNotification from "../../../../Ui/Notification"; +import { AjaxCallbackSetup, AjaxResponseException } from "../../../../Ajax/Data"; +import { DialogCallbackSetup } from "../../../../Ui/Dialog/Data"; + +interface PipData { + dependencies: string[]; + pluginName: string; + targets: string[]; +} + +type PendingPip = [string, string]; + +interface AjaxResponse { + returnValues: { + pluginName: string; + target: string; + timeElapsed: string; + }; +} + +interface RequestData { + parameters: { + pluginName: string; + target: string; + }; +} + +class AcpUiDevtoolsProjectSync { + private readonly buttons = new Map(); + private readonly buttonStatus = new Map(); + private buttonSyncAll?: HTMLAnchorElement = undefined; + private readonly container = document.getElementById("syncPipMatches")!; + private readonly pips: PipData[] = []; + private readonly projectId: number; + private queue: PendingPip[] = []; + + constructor(projectId) { + this.projectId = projectId; + + const restrictedSync = document.getElementById("syncShowOnlyMatches") as HTMLInputElement; + restrictedSync.addEventListener("change", () => { + this.container.classList.toggle("jsShowOnlyMatches"); + }); + + const existingPips: string[] = []; + const knownPips: string[] = []; + const tmpPips: PipData[] = []; + this.container + .querySelectorAll(".jsHasPipTargets:not(.jsSkipTargetDetection)") + .forEach((pip: HTMLTableRowElement) => { + const pluginName = pip.dataset.pluginName!; + const targets: string[] = []; + + this.container + .querySelectorAll(`.jsHasPipTargets[data-plugin-name="${pluginName}"] .jsInvokePip`) + .forEach((button: HTMLButtonElement) => { + const target = button.dataset.target!; + targets.push(target); + + button.addEventListener("click", (event) => { + event.preventDefault(); + + if (this.queue.length > 0) { + return; + } + + this.sync(pluginName, target); + }); + + const identifier = this.getButtonIdentifier(pluginName, target); + this.buttons.set(identifier, button); + this.buttonStatus.set( + identifier, + this.container.querySelector( + `.jsHasPipTargets[data-plugin-name="${pluginName}"] .jsInvokePipResult[data-target="${target}"]`, + ) as HTMLElement, + ); + }); + + const data: PipData = { + dependencies: JSON.parse(pip.dataset.syncDependencies!), + pluginName, + targets, + }; + + if (data.dependencies.length > 0) { + tmpPips.push(data); + } else { + this.pips.push(data); + knownPips.push(pluginName); + } + + existingPips.push(pluginName); + }); + + let resolvedDependency = false; + while (tmpPips.length > 0) { + resolvedDependency = false; + + tmpPips.forEach((item, index) => { + if (resolvedDependency) { + return; + } + + const openDependencies = item.dependencies.filter((dependency) => { + // Ignore any dependencies that are not present. + if (existingPips.indexOf(dependency) === -1) { + window.console.info(`The dependency "${dependency}" does not exist and has been ignored.`); + return false; + } + + return !knownPips.includes(dependency); + }); + + if (openDependencies.length === 0) { + knownPips.push(item.pluginName); + this.pips.push(item); + tmpPips.splice(index, 1); + + resolvedDependency = true; + } + }); + + if (!resolvedDependency) { + // We could not resolve any dependency, either because there is no more pip + // in `tmpPips` or we're facing a circular dependency. In case there are items + // left, we simply append them to the end and hope for the operation to + // complete anyway, despite unmatched dependencies. + tmpPips.forEach((pip) => { + window.console.warn("Unable to resolve dependencies for", pip); + + this.pips.push(pip); + }); + + break; + } + } + + const syncAll = document.createElement("li"); + syncAll.innerHTML = ` ${Language.get( + "wcf.acp.devtools.sync.syncAll", + )}`; + this.buttonSyncAll = syncAll.children[0] as HTMLAnchorElement; + this.buttonSyncAll.addEventListener("click", this.syncAll.bind(this)); + + const list = document.querySelector(".contentHeaderNavigation > ul") as HTMLUListElement; + list.insertAdjacentElement("afterbegin", syncAll); + } + + private sync(pluginName: string, target: string): void { + const identifier = this.getButtonIdentifier(pluginName, target); + this.buttons.get(identifier)!.disabled = true; + this.buttonStatus.get(identifier)!.innerHTML = ''; + + Ajax.api(this, { + parameters: { + pluginName, + target, + }, + }); + } + + private syncAll(event: MouseEvent): void { + event.preventDefault(); + + if (this.buttonSyncAll!.classList.contains("disabled")) { + return; + } + + this.buttonSyncAll!.classList.add("disabled"); + + this.queue = []; + this.pips.forEach((pip) => { + pip.targets.forEach((target) => { + this.queue.push([pip.pluginName, target]); + }); + }); + this.syncNext(); + } + + private syncNext(): void { + if (this.queue.length === 0) { + this.buttonSyncAll!.classList.remove("disabled"); + + UiNotification.show(); + + return; + } + + const next = this.queue.shift()!; + this.sync(next[0], next[1]); + } + + private getButtonIdentifier(pluginName: string, target: string): string { + return `${pluginName}-${target}`; + } + + _ajaxSuccess(data: AjaxResponse): void { + const identifier = this.getButtonIdentifier(data.returnValues.pluginName, data.returnValues.target); + this.buttons.get(identifier)!.disabled = false; + this.buttonStatus.get(identifier)!.innerHTML = data.returnValues.timeElapsed; + + this.syncNext(); + } + + _ajaxFailure( + data: AjaxResponseException, + responseText: string, + xhr: XMLHttpRequest, + requestData: RequestData, + ): boolean { + const identifier = this.getButtonIdentifier(requestData.parameters.pluginName, requestData.parameters.target); + this.buttons.get(identifier)!.disabled = false; + + const buttonStatus = this.buttonStatus.get(identifier)!; + buttonStatus.innerHTML = '' + Language.get("wcf.acp.devtools.sync.status.failure") + ""; + buttonStatus.children[0].addEventListener("click", (event) => { + event.preventDefault(); + + UiDialog.open(this, Ajax.getRequestObject(this).getErrorHtml(data, xhr)); + }); + + this.buttonSyncAll!.classList.remove("disabled"); + + return false; + } + + _ajaxSetup(): ReturnType { + return { + data: { + actionName: "invoke", + className: "wcf\\data\\package\\installation\\plugin\\PackageInstallationPluginAction", + parameters: { + projectID: this.projectId, + }, + }, + }; + } + + _dialogSetup(): ReturnType { + return { + id: "devtoolsProjectSyncPipError", + options: { + title: Language.get("wcf.global.error.title"), + }, + source: null, + }; + } +} + +let acpUiDevtoolsProjectSync: AcpUiDevtoolsProjectSync; + +export function init(projectId: number): void { + if (!acpUiDevtoolsProjectSync) { + acpUiDevtoolsProjectSync = new AcpUiDevtoolsProjectSync(projectId); + } +} diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Data.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Data.ts index 738ccb5764..c5fa0b6f1d 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Data.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Data.ts @@ -80,3 +80,20 @@ export interface RequestOptions { callbackObject?: AjaxCallbackObject | null; } + +interface PreviousException { + message: string; + stacktrace: string; +} + +export interface AjaxResponseException extends ResponseData { + exceptionID?: string; + previous: PreviousException[]; + file?: string; + line?: number; + message: string; + returnValues?: { + description?: string; + }; + stacktrace?: string; +} diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Request.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Request.ts index 71fc024db4..366393ebc0 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Request.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Request.ts @@ -11,29 +11,12 @@ */ import * as AjaxStatus from "./Status"; -import { ResponseData, RequestOptions, RequestData } from "./Data"; +import { ResponseData, RequestOptions, RequestData, AjaxResponseException } from "./Data"; import * as Core from "../Core"; import DomChangeListener from "../Dom/Change/Listener"; import DomUtil from "../Dom/Util"; import * as Language from "../Language"; -interface PreviousException { - message: string; - stacktrace: string; -} - -interface AjaxResponseException extends ResponseData { - exceptionID?: string; - previous: PreviousException[]; - file?: string; - line?: number; - message: string; - returnValues?: { - description?: string; - }; - stacktrace?: string; -} - let _didInit = false; let _ignoreAllErrors = false; -- 2.20.1