Skip to content

Commit 998df9b

Browse files
committed
Migrate WCF.Conversation.Leave to typescript
1 parent fdd9208 commit 998df9b

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

files/js/WCF.Conversation.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,12 @@ WCF.Conversation.InlineEditor = WCF.InlineEditor.extend({
505505
break;
506506

507507
case 'leave':
508-
new WCF.Conversation.Leave([ $('#' + elementID).data('conversationID') ], this._environment);
508+
require(["WoltLabSuite/Core/Conversation/Component/Leave"], ({ openDialog }) => {
509+
openDialog(
510+
elData(elById(elementID), "conversation-leave-form-link"),
511+
this._environment,
512+
);
513+
});
509514
break;
510515

511516
case 'edit':
@@ -567,6 +572,8 @@ WCF.Conversation.InlineEditor = WCF.InlineEditor.extend({
567572
* Provides a dialog for leaving or restoring conversation.
568573
*
569574
* @param array<integer> conversationIDs
575+
*
576+
* @deprecated 6.2 use `WoltLabSuite/Core/Conversation/Component/Leave` instead
570577
*/
571578
WCF.Conversation.Leave = Class.extend({
572579
/**

files/js/WoltLabSuite/Core/Conversation/Component/Leave.js

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Handles the leave conversation action.
3+
*
4+
* @author Olaf Braun
5+
* @copyright 2001-2025 WoltLab GmbH
6+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
7+
* @since 6.2
8+
*/
9+
10+
import { dialogFactory } from "WoltLabSuite/Core/Component/Dialog";
11+
12+
type Environment = "conversation" | "";
13+
14+
interface FormResult {
15+
redirectURL: string;
16+
}
17+
18+
export async function openDialog(actionLink: string, environment: Environment) {
19+
const result = await dialogFactory().usingFormBuilder().fromEndpoint<FormResult>(actionLink);
20+
if (result.ok) {
21+
if (environment === "conversation") {
22+
window.location.href = result.result.redirectURL;
23+
} else {
24+
window.location.reload();
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)