Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Component from "@glimmer/component";
import { trustHTML } from "@ember/template";
import { i18n } from "discourse-i18n";

export default class SetChatbotUpsert extends Component {
static shouldRender(args, context) {
return context.siteSettings.enable_simplified_category_creation;
}

get additionalPromptLabel() {
return trustHTML(i18n("chatbot.category.auto_response_additional_prompt"));
}

<template>
{{#let @outletArgs.form as |form|}}
<form.Section @title={{i18n "chatbot.category.settings_label"}}>
<form.Object @name="custom_fields" as |customFields|>
<customFields.Field
@name="chatbot_auto_response_additional_prompt"
@title={{this.additionalPromptLabel}}
@type="textarea"
as |field|
>
<field.Control />
</customFields.Field>
</form.Object>
</form.Section>
{{/let}}
</template>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { trustHTML } from "@ember/template";
import { i18n } from "discourse-i18n";

export default class SetChatbot extends Component {
static shouldRender(args, context) {
return !context.siteSettings.enable_simplified_category_creation;
}

constructor() {
super(...arguments);
this.args.outletArgs.category.custom_fields ||= {};
Expand Down
2 changes: 1 addition & 1 deletion plugin.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# name: discourse-chatbot
# about: a plugin that allows you to have a conversation with a configurable chatbot in Chat, Topics and Private Messages
# version: 1.7.4
# version: 1.7.5
# authors: merefield
# url: https://github.com/merefield/discourse-chatbot

Expand Down
31 changes: 31 additions & 0 deletions spec/system/category_chatbot_settings_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Category chatbot settings" do
fab!(:admin)
fab!(:category, :category_with_definition)

let(:category_page) { PageObjects::Pages::Category.new }

before do
SiteSetting.chatbot_enabled = true
SiteSetting.enable_simplified_category_creation = true

sign_in(admin)
end

it "saves chatbot custom fields from the simplified category settings form" do
category_page.visit_settings(category)

find(
".form-kit__field[data-name='custom_fields.chatbot_auto_response_additional_prompt']",
).find(".form-kit__control-textarea").fill_in(with: "Use the category-specific response tone.")

category_page.save_settings

expect(category.reload.custom_fields["chatbot_auto_response_additional_prompt"]).to eq(
"Use the category-specific response tone.",
)
end
end
Loading