UX: Hide admin header for edit/new webhook (#30194)

In this PR, we added functionality to hide the admin header for edit/new actions - https://github.com/discourse/discourse/pull/30175

To make it work properly, we have to rename `show` to `edit` which is also a more accurate name.
This commit is contained in:
Krzysztof Kotlarek 2024-12-12 10:49:17 +11:00 committed by GitHub
parent 203f93bcaf
commit 8bd55c35fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 17 additions and 8 deletions

View File

@ -88,7 +88,7 @@ export default class AdminChatIncomingWebhooksList extends Component {
>
<div class="d-admin-row__controls-options">
<LinkTo
@route="adminPlugins.show.discourse-chat-incoming-webhooks.show"
@route="adminPlugins.show.discourse-chat-incoming-webhooks.edit"
@model={{webhook.id}}
class="btn btn-small admin-chat-incoming-webhooks-edit"
>{{i18n "chat.incoming_webhooks.edit"}}</LinkTo>

View File

@ -70,7 +70,7 @@ export default class ChatIncomingWebhookEditForm extends Component {
this.router
.transitionTo(
"adminPlugins.show.discourse-chat-incoming-webhooks.show",
"adminPlugins.show.discourse-chat-incoming-webhooks.edit",
webhook
)
.then(() => {

View File

@ -5,7 +5,7 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
import DiscourseRoute from "discourse/routes/discourse";
import ChatChannel from "discourse/plugins/chat/discourse/models/chat-channel";
export default class DiscourseChatIncomingWebhooksShow extends DiscourseRoute {
export default class DiscourseChatIncomingWebhooksEdit extends DiscourseRoute {
@service currentUser;
async model(params) {
@ -14,7 +14,9 @@ export default class DiscourseChatIncomingWebhooksShow extends DiscourseRoute {
}
try {
const model = await ajax(`/admin/plugins/chat/hooks/${params.id}.json`);
const model = await ajax(
`/admin/plugins/chat/hooks/${params.id}/edit.json`
);
model.webhook = EmberObject.create(model.webhook);
model.webhook.chat_channel = ChatChannel.create(

View File

@ -16,7 +16,7 @@ module Chat
)
end
def show
def edit
webhook =
Chat::IncomingWebhook.includes(:chat_channel).find(params[:incoming_chat_webhook_id])
render_serialized(

View File

@ -7,7 +7,7 @@ export default {
{ path: "hooks" },
function () {
this.route("new");
this.route("show", { path: "/:id" });
this.route("edit", { path: "/:id/edit" });
}
);
},

View File

@ -409,8 +409,8 @@ after_initialize do
:constraints => StaffConstraint.new
get "/admin/plugins/chat/hooks/new" => "chat/admin/incoming_webhooks#new",
:constraints => StaffConstraint.new
get "/admin/plugins/chat/hooks/:incoming_chat_webhook_id" =>
"chat/admin/incoming_webhooks#show",
get "/admin/plugins/chat/hooks/:incoming_chat_webhook_id/edit" =>
"chat/admin/incoming_webhooks#edit",
:constraints => StaffConstraint.new
delete "/admin/plugins/chat/hooks/:incoming_chat_webhook_id" =>
"chat/admin/incoming_webhooks#destroy",

View File

@ -6,6 +6,7 @@ describe "Admin Chat Incoming Webhooks", type: :system do
let(:dialog) { PageObjects::Components::Dialog.new }
let(:admin_incoming_webhooks_page) { PageObjects::Pages::AdminIncomingWebhooks.new }
let(:admin_header) { PageObjects::Components::AdminHeader.new }
before do
chat_system_bootstrap(current_user)
@ -14,7 +15,13 @@ describe "Admin Chat Incoming Webhooks", type: :system do
it "can create incoming webhooks" do
admin_incoming_webhooks_page.visit
expect(admin_header).to be_visible
admin_incoming_webhooks_page.click_new
expect(admin_header).to be_hidden
admin_incoming_webhooks_page.form.field("name").fill_in("Test webhook")
admin_incoming_webhooks_page.form.field("description").fill_in("Some test content")
admin_incoming_webhooks_page.form.field("username").fill_in("system")