Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions javascripts/discourse/components/custom-new-topic-button.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,26 @@ export default class CustomNewTopicButton extends Component {
return this.filteredSetting?.icon;
}

get customRedirectUrl() {
return this.filteredSetting?.custom_redirect_url;
}

@action
customCreateTopic() {
this.composer.open({
action: Composer.CREATE_TOPIC,
draftKey: Composer.NEW_TOPIC_KEY,
categoryId: this.args.category?.id,
tags: Array.isArray(this.args.tag)
? this.args.tag.map((tag) => tag.id)
: this.args.tag
if (this.customRedirectUrl) {
window.location.href = this.customRedirectUrl;
} else {
this.composer.open({
action: Composer.CREATE_TOPIC,
draftKey: Composer.NEW_TOPIC_KEY,
categoryId: this.args.category?.id,
tags: Array.isArray(this.args.tag)
? this.args.tag.map((tag) => tag.id)
: this.args.tag
? [this.args.tag.id]
: [],
});
});
}
}

<template>
Expand Down
4 changes: 4 additions & 0 deletions settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ custom_new_topic_text:
"type": "string",
"description": "New Topic button"
},
"custom_redirect_url": {
"type": "string",
"description": "Custom URL for the New Topic button"
},
"composer_action_text": {
"type": "string",
"description": "Composer action name (Create a new topic by default)"
Expand Down