Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove enable_simplified_category_creation old code (#40108)

Martin Brennand41418ec0111
diff --git a/app/assets/stylesheets/common/base/_index.scss b/app/assets/stylesheets/common/base/_index.scss
index 8876d5027c7..665f65dff49 100644
--- a/app/assets/stylesheets/common/base/_index.scss
+++ b/app/assets/stylesheets/common/base/_index.scss
@@ -18,7 +18,6 @@
@import "directory";
@import "discourse";
@import "edit-category";
-@import "uc-simplified-category-setup-edit-categories";
@import "edit-topic-timer-modal";
@import "embedded-posts";
@import "ember-select";
diff --git a/app/assets/stylesheets/common/base/edit-category.scss b/app/assets/stylesheets/common/base/edit-category.scss
index 23dc3b986ff..7bc10ee2aa9 100644
--- a/app/assets/stylesheets/common/base/edit-category.scss
+++ b/app/assets/stylesheets/common/base/edit-category.scss
@@ -5,12 +5,10 @@ $category-settings-width: string.unquote("min(600px, 90%)");
$number-input-width: 75px;
div.edit-category {
- display: grid;
- grid-template-columns: 1fr 5fr;
- grid-template-rows: auto auto auto;
- row-gap: 1em;
- column-gap: 1.5em;
- grid-template-areas: "header header" "sidebar content" "sidebar warning" "sidebar footer";
+ display: block;
+ max-width: 75ch;
+ width: 100%;
+ margin: 0 auto;
@include viewport.until(sm) {
display: block;
@@ -313,6 +311,270 @@ div.edit-category {
}
}
+.category-permissions-table {
+ --permission-table-max-width: var(--form-kit-max-input);
+ width: 100%;
+}
+
+div.edit-category {
+ .d-page-header__title-row {
+ line-height: var(--line-height-medium);
+ gap: var(--space-4);
+ }
+
+ .edit-category-tab-security {
+ .alert {
+ --permission-table-max-width: var(--form-kit-max-input);
+ }
+ }
+
+ .edit-category-tab:not(.edit-category-tab-general) {
+ .form-kit__container-optional {
+ display: none;
+ }
+ }
+
+ h1 {
+ font-size: var(--font-up-3);
+ }
+
+ .form-kit__field-toggle {
+ flex-direction: column;
+ width: 100%;
+ gap: 0.5em;
+ align-items: start;
+
+ .form-kit__container-content {
+ align-items: flex-start;
+ }
+ }
+
+ .form-kit__conditional-display-content {
+ // prevent content shift when changing style options
+ min-height: 2.6em;
+
+ &:has(.badge-category__wrapper) {
+ justify-content: center;
+ }
+ }
+
+ .--radio-cards {
+ .form-kit__container-title {
+ max-width: var(--form-kit-max-input);
+ width: 100%;
+ }
+
+ .form-kit__conditional-display-content {
+ .form-kit__container {
+ flex-direction: column;
+ }
+ }
+ }
+
+ .select-kit.multi-select.group-chooser {
+ max-width: var(--form-kit-max-input);
+ width: 100%;
+ }
+
+ .edit-category-tab-settings label,
+ .edit-category-tab-tags label,
+ .edit-category-tab-settings input[type="text"],
+ .edit-category-tab-settings .select-kit,
+ .edit-category-tab-tags input[type="text"],
+ .edit-category-tab-tags .select-kit {
+ width: 100%;
+ max-width: var(--form-kit-max-input);
+ }
+
+ .add-required-tag-group {
+ align-self: start;
+ }
+
+ #control-icon,
+ #control-emoji {
+ &.form-kit__field .form-kit__container-content {
+ width: auto;
+ }
+ }
+
+ .edit-category-title-bar {
+ box-sizing: border-box;
+ width: 100%;
+ flex-wrap: wrap;
+ }
+
+ .edit-category-title {
+ flex: 1 1 auto;
+
+ h2 {
+ margin-top: 0;
+ }
+
+ .btn-back {
+ margin-top: -0.5em;
+ margin-left: -0.5em;
+ margin-bottom: 0.5em;
+ }
+ }
+
+ .edit-category-nav {
+ border-bottom: 1px solid var(--content-border-color);
+ }
+
+ .edit-category-page-header {
+ margin-bottom: 1.5em;
+ }
+
+ .edit-category-content {
+ grid-area: unset;
+ }
+
+ .edit-category-type-schema-fields {
+ display: contents;
+
+ &.--site-settings-only > .form-kit__section.emphasis {
+ border: none;
+ padding: 0;
+ }
+
+ .--dependent {
+ display: flex;
+ gap: 0.75em;
+ }
+
+ .--dependent-border {
+ flex: 0 0 1lh;
+ border-right: 3px solid var(--primary-low);
+ }
+
+ .--dependent-fields {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 1em;
+ }
+ }
+}
+
+.edit-category-title-text {
+ display: flex;
+ flex-direction: column;
+ margin: 0;
+
+ .edit-category-static-title {
+ transition: font-size 0.2s ease-in-out;
+ }
+
+ &:has(.badge-category__wrapper) {
+ .edit-category-static-title {
+ position: absolute;
+ font-size: var(--font-down-3);
+ }
+ }
+
+ .badge-category__wrapper {
+ font-weight: normal;
+ font-size: var(--font-up-2);
+ margin-top: var(--space-5);
+ }
+}
+
+div.edit-category {
+ .form-kit__errors-summary {
+ width: 100%;
+ max-width: var(--form-kit-max-input);
+ margin-top: var(--space-4);
+
+ + .form-kit__section.edit-category-content {
+ margin-top: 0;
+ }
+ }
+
+ .form-kit__conditional-display {
+ .form-kit__container-content:has(.is-disabled) {
+ // select-kit has pointer-events disabled, so we need to style the parent
+ cursor: not-allowed;
+ }
+ }
+
+ .edit-category-footer {
+ padding: 0;
+ margin-bottom: var(--space-4);
+ }
+
+ .edit-category-tab-localizations {
+ .btn-default {
+ align-self: start;
+ }
+ }
+
+ .admin-changes-banner {
+ max-width: var(--form-kit-max-input);
+ flex-direction: row-reverse;
+ align-items: center;
+
+ .controls {
+ flex-direction: row-reverse;
+ margin-right: auto;
+ }
+ }
+}
+
+#main-outlet:has(.edit-category) + .powered-by-discourse {
+ display: none; // hide for now due to alignment
+}
+
+.edit-category-description-container {
+ .readonly-field {
+ width: 100%;
+ font-size: var(--font-down-1);
+ color: var(--primary-high);
+
+ > :first-child {
+ margin-top: 0;
+ }
+
+ > :last-child {
+ margin-bottom: 0;
+ }
+ }
+
+ .description-content {
+ &.--collapsed {
+ max-height: calc(4 * 1.5em);
+ overflow: hidden;
+ position: relative;
+
+ &.--overflowing::after {
+ content: "";
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ height: 1.5em;
+ background: linear-gradient(transparent, var(--secondary, white));
+ pointer-events: none;
+ }
+ }
+ }
+
+ .description-actions {
+ width: 100%;
+ display: flex;
+ align-items: center;
+ gap: var(--space-2);
+ margin-top: var(--space-2);
+
+ .toggle-description {
+ color: var(--primary-medium);
+
+ &:hover {
+ color: var(--primary-high);
+ }
+ }
+ }
+}
+
.category-permissions-table {
max-width: var(--permission-table-max-width);
margin-bottom: 0;
diff --git a/app/assets/stylesheets/common/base/uc-simplified-category-setup-edit-categories.scss b/app/assets/stylesheets/common/base/uc-simplified-category-setup-edit-categories.scss
deleted file mode 100644
index 23f663ab208..00000000000
--- a/app/assets/stylesheets/common/base/uc-simplified-category-setup-edit-categories.scss
+++ /dev/null
@@ -1,270 +0,0 @@
-@use "lib/viewport";
-
-.uc-enable-simplified-category-creation {
- .d-page-header__title-row {
- line-height: var(--line-height-medium);
- gap: var(--space-4);
- }
-
- .edit-category-tab-security {
- .alert {
- --permission-table-max-width: var(--form-kit-max-input);
- }
- }
-
- .edit-category-tab:not(.edit-category-tab-general) {
- .form-kit__container-optional {
- display: none;
- }
- }
-
- .category-permissions-table {
- --permission-table-max-width: var(--form-kit-max-input);
- width: 100%;
- }
-
- div.edit-category {
- display: block;
- max-width: 75ch;
- width: 100%;
- margin: 0 auto;
-
- h1 {
- font-size: var(--font-up-3);
- }
-
- .form-kit__field-toggle {
- flex-direction: column;
- width: 100%;
- gap: 0.5em;
- align-items: start;
-
- .form-kit__container-content {
- align-items: flex-start;
- }
- }
-
- .form-kit__conditional-display-content {
- // prevent content shift when changing style options
- min-height: 2.6em;
-
- &:has(.badge-category__wrapper) {
- justify-content: center;
- }
- }
-
- .--radio-cards {
- .form-kit__container-title {
- max-width: var(--form-kit-max-input);
- width: 100%;
- }
-
- .form-kit__conditional-display-content {
- .form-kit__container {
- flex-direction: column;
- }
- }
- }
-
- .select-kit.multi-select.group-chooser {
- max-width: var(--form-kit-max-input);
- width: 100%;
- }
-
- .edit-category-tab-settings label,
- .edit-category-tab-tags label,
- .edit-category-tab-settings input[type="text"],
- .edit-category-tab-settings .select-kit,
- .edit-category-tab-tags input[type="text"],
- .edit-category-tab-tags .select-kit {
- width: 100%;
- max-width: var(--form-kit-max-input);
- }
-
- .add-required-tag-group {
- align-self: start;
- }
-
- #control-icon,
- #control-emoji {
- &.form-kit__field .form-kit__container-content {
- width: auto;
- }
- }
-
- .edit-category-title-bar {
- box-sizing: border-box;
- width: 100%;
- flex-wrap: wrap;
- }
-
- .edit-category-title {
- flex: 1 1 auto;
-
- h2 {
- margin-top: 0;
- }
-
- .btn-back {
- margin-top: -0.5em;
- margin-left: -0.5em;
- margin-bottom: 0.5em;
- }
- }
-
- .edit-category-nav {
- border-bottom: 1px solid var(--content-border-color);
- }
-
- .edit-category-page-header {
- margin-bottom: 1.5em;
- }
-
- .edit-category-content {
- grid-area: unset;
- }
-
- .edit-category-type-schema-fields {
- display: contents;
-
- &.--site-settings-only > .form-kit__section.emphasis {
- border: none;
- padding: 0;
- }
-
- .--dependent {
- display: flex;
- gap: 0.75em;
- }
-
- .--dependent-border {
- flex: 0 0 1lh;
- border-right: 3px solid var(--primary-low);
- }
-
- .--dependent-fields {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 1em;
- }
- }
- }
-
- .edit-category-title-text {
- display: flex;
- flex-direction: column;
- margin: 0;
-
- .edit-category-static-title {
- transition: font-size 0.2s ease-in-out;
- }
-
- &:has(.badge-category__wrapper) {
- .edit-category-static-title {
- position: absolute;
- font-size: var(--font-down-3);
- }
- }
-
- .badge-category__wrapper {
- font-weight: normal;
- font-size: var(--font-up-2);
- margin-top: var(--space-5);
- }
- }
-
- .form-kit__errors-summary {
- width: 100%;
- max-width: var(--form-kit-max-input);
- margin-top: var(--space-4);
-
- + .form-kit__section.edit-category-content {
- margin-top: 0;
- }
- }
-
- .form-kit__conditional-display {
- .form-kit__container-content:has(.is-disabled) {
- // select-kit has pointer-events disabled, so we need to style the parent
- cursor: not-allowed;
- }
- }
-
- .edit-category .edit-category-footer {
- padding: 0;
- margin-bottom: var(--space-4);
- }
-
- .edit-category-tab-localizations {
- .btn-default {
- align-self: start;
- }
- }
-
- #main-outlet:has(.edit-category) + .powered-by-discourse {
- display: none; // hide for now due to alignment
- }
-
- .admin-changes-banner {
- max-width: var(--form-kit-max-input);
- flex-direction: row-reverse;
- align-items: center;
-
- .controls {
- flex-direction: row-reverse;
- margin-right: auto;
- }
- }
-}
-
-.edit-category-description-container {
- .readonly-field {
- width: 100%;
- font-size: var(--font-down-1);
- color: var(--primary-high);
-
- > :first-child {
- margin-top: 0;
- }
-
- > :last-child {
- margin-bottom: 0;
- }
- }
-
- .description-content {
- &.--collapsed {
- max-height: calc(4 * 1.5em);
- overflow: hidden;
- position: relative;
-
- &.--overflowing::after {
- content: "";
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- height: 1.5em;
- background: linear-gradient(transparent, var(--secondary, white));
- pointer-events: none;
- }
- }
- }
-
- .description-actions {
- width: 100%;
- display: flex;
- align-items: center;
- gap: var(--space-2);
- margin-top: var(--space-2);
-
- .toggle-description {
- color: var(--primary-medium);
-
- &:hover {
- color: var(--primary-high);
- }
- }
- }
-}
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index 7ba236ae44b..e8c803be49a 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -183,8 +183,7 @@ class CategoriesController < ApplicationController
if @category.save
@category.move_to(position.to_i) if position
- if category_type.present? &&
- UpcomingChanges.enabled_for_user?(:enable_simplified_category_creation, current_user)
+ if category_type.present?
type_class = Categories::TypeRegistry.get(category_type.to_sym)
allowed_setting_keys = type_class&.configuration_schema_keys(:category_settings) || []
type_settings = params[:category_type_settings]&.slice(*allowed_setting_keys)&.permit!
@@ -242,13 +241,10 @@ class CategoriesController < ApplicationController
# Handles adding or removing category types registered by plugins
# based on the multi-type selector in the General tab for categories.
- if UpcomingChanges.enabled_for_user?(:enable_simplified_category_creation, current_user)
- manage_category_types(cat, pending_custom_fields || {})
- cat.reload
- end
+ manage_category_types(cat, pending_custom_fields || {})
+ cat.reload
- if UpcomingChanges.enabled_for_user?(:enable_simplified_category_creation, current_user) &&
- params[:category_type_settings].present?
+ if params[:category_type_settings].present?
# Re-run configure_category for each matching type so per-type
# category_settings (e.g. events_calendar_default_view) are persisted on
# edit, not just on create. Each type only sees its own keys so it
diff --git a/app/models/category.rb b/app/models/category.rb
index 6348c0f344a..dcffe902497 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -332,7 +332,6 @@ class Category < ActiveRecord::Base
end
def category_types
- return {} if !SiteSetting.enable_simplified_category_creation
Categories::TypeRegistry
.all
.values
diff --git a/app/serializers/category_serializer.rb b/app/serializers/category_serializer.rb
index 2096ab4919a..2c055433291 100644
--- a/app/serializers/category_serializer.rb
+++ b/app/serializers/category_serializer.rb
@@ -87,12 +87,16 @@ class CategorySerializer < SiteCategorySerializer
end
end
+ def can_edit_category?
+ scope && scope.can_edit?(object)
+ end
+
def include_group_permissions?
- scope&.can_edit?(object)
+ can_edit_category?
end
def include_available_groups?
- scope && scope.can_edit?(object)
+ can_edit_category?
end
def available_groups
@@ -120,15 +124,15 @@ class CategorySerializer < SiteCategorySerializer
end
def include_cannot_delete_reason?
- !include_can_delete? && scope && scope.can_edit?(object)
+ !include_can_delete? && can_edit_category?
end
def include_email_in?
- scope && scope.can_edit?(object)
+ can_edit_category?
end
def include_email_in_allow_strangers?
- scope && scope.can_edit?(object)
+ can_edit_category?
end
def include_notification_level?
@@ -158,13 +162,19 @@ class CategorySerializer < SiteCategorySerializer
category_description
end
+ def include_category_types?
+ can_edit_category?
+ end
+
def category_types
- return {} if !SiteSetting.enable_simplified_category_creation
object.category_types
end
+ def include_category_type_settings?
+ can_edit_category?
+ end
+
def category_type_settings
- return {} if !SiteSetting.enable_simplified_category_creation
Categories::TypeRegistry
.all
.values
@@ -174,8 +184,11 @@ class CategorySerializer < SiteCategorySerializer
end
end
+ def include_available_category_types?
+ can_edit_category?
+ end
+
def available_category_types
- return [] if !SiteSetting.enable_simplified_category_creation
Categories::TypeRegistry.list(only_visible: true)
end
end
diff --git a/frontend/discourse/admin/components/changes-banner.gjs b/frontend/discourse/admin/components/changes-banner.gjs
index d799c1f00b6..61a270b37b8 100644
--- a/frontend/discourse/admin/components/changes-banner.gjs
+++ b/frontend/discourse/admin/components/changes-banner.gjs
@@ -52,6 +52,7 @@ export default class ChangesBanner extends Component {
/>
<DButton
class="btn-primary btn-small"
+ @id={{@saveButtonId}}
@action={{this.save}}
@isLoading={{this.isSaving}}
@translatedLabel={{@saveLabel}}
diff --git a/frontend/discourse/admin/components/edit-category-general.gjs b/frontend/discourse/admin/components/edit-category-general.gjs
deleted file mode 100644
index 68d367b9b71..00000000000
--- a/frontend/discourse/admin/components/edit-category-general.gjs
+++ /dev/null
@@ -1,387 +0,0 @@
-import Component from "@glimmer/component";
-import { cached } from "@glimmer/tracking";
-import { hash } from "@ember/helper";
-import { action } from "@ember/object";
-import { service } from "@ember/service";
-import { trustHTML } from "@ember/template";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import lazyHash from "discourse/helpers/lazy-hash";
-import { uniqueItemsFromArray } from "discourse/lib/array-tools";
-import {
- CATEGORY_STYLE_TYPES,
- CATEGORY_TEXT_COLORS,
-} from "discourse/lib/constants";
-import getURL from "discourse/lib/get-url";
-import Category from "discourse/models/category";
-import CategoryChooser from "discourse/select-kit/components/category-chooser";
-import { eq } from "discourse/truth-helpers";
-import DDecoratedHtml from "discourse/ui-kit/d-decorated-html";
-import dCategoryBadge from "discourse/ui-kit/helpers/d-category-badge";
-import { categoryBadgeHTML } from "discourse/ui-kit/helpers/d-category-link";
-import { i18n } from "discourse-i18n";
-
-export default class EditCategoryGeneral extends Component {
- @service site;
- @service siteSettings;
-
- uncategorizedSiteSettingLink = getURL(
- "/admin/site_settings/category/all_results?filter=allow_uncategorized_topics"
- );
- customizeTextContentLink = getURL(
- "/admin/customize/site_texts?q=uncategorized"
- );
-
- get styleTypes() {
- return Object.keys(CATEGORY_STYLE_TYPES).map((key) => ({
- id: key,
- name: i18n(`category.styles.options.${key}`),
- }));
- }
-
- get showWarning() {
- return this.args.category.isUncategorizedCategory;
- }
-
- @cached
- get backgroundColors() {
- const categories = this.site.get("categoriesList");
- return uniqueItemsFromArray(
- this.siteSettings.category_colors
- .split("|")
- .filter(Boolean)
- .map((i) => i.toUpperCase())
- .concat(categories.map((c) => c.color.toUpperCase()))
- );
- }
-
- @cached
- get usedBackgroundColors() {
- const categories = this.site.get("categoriesList");
- const categoryId = this.args.category.id;
- const categoryColor = this.args.category.color;
-
- // if editing a category, don't include its color:
- return categories
- .map((c) => {
- return categoryId &&
- categoryColor.toUpperCase() === c.color.toUpperCase()
- ? null
- : c.color.toUpperCase();
- })
- .filter((item) => item != null);
- }
-
- @cached
- get parentCategories() {
- return this.site
- .get("categoriesList")
- .filter((c) => c.level + 1 < this.siteSettings.max_category_nesting);
- }
-
- @action
- categoryBadgePreview(transientData) {
- const category = this.args.category;
-
- const previewCategory = Category.create({
- id: category.id,
- name: transientData.name || i18n("category.untitled"),
- color: transientData.color,
- text_color: transientData.text_color,
- parent_category_id: parseInt(category.get("parent_category_id"), 10),
- read_restricted: category.get("read_restricted"),
- });
-
- return categoryBadgeHTML(previewCategory, {
- link: false,
- previewColor: true,
- styleType: transientData.style_type,
- emoji: transientData.emoji,
- icon: transientData.icon,
- });
- }
-
- // We can change the parent if there are no children
- @cached
- get subCategories() {
- if (this.args.category.isNew) {
- return null;
- }
- return Category.list().filter(
- (category) => category.get("parent_category_id") === this.args.category.id
- );
- }
-
- @cached
- get showDescription() {
- const category = this.args.category;
- return (
- !category.isUncategorizedCategory && category.id && category.topic_url
- );
- }
-
- @action
- showCategoryTopic() {
- window.open(this.args.category.get("topic_url"), "_blank").focus();
- }
-
- @action
- setBackgroundColor(value, { set }) {
- const color = value?.replace(/^#/, "") ?? "";
-
- set("color", color);
-
- const whiteDiff = this.colorDifference(color, CATEGORY_TEXT_COLORS[0]);
- const blackDiff = this.colorDifference(color, CATEGORY_TEXT_COLORS[1]);
- const colorIndex = whiteDiff > blackDiff ? 0 : 1;
-
- set("text_color", CATEGORY_TEXT_COLORS[colorIndex]);
- }
-
- @action
- colorDifference(color1, color2) {
- const r1 = parseInt(color1.substr(0, 2), 16);
- const g1 = parseInt(color1.substr(2, 2), 16);
- const b1 = parseInt(color1.substr(4, 2), 16);
-
- const r2 = parseInt(color2.substr(0, 2), 16);
- const g2 = parseInt(color2.substr(2, 2), 16);
- const b2 = parseInt(color2.substr(4, 2), 16);
-
- const rDiff = Math.max(r1, r2) - Math.min(r1, r2);
- const gDiff = Math.max(g1, g2) - Math.min(g1, g2);
- const bDiff = Math.max(b1, b2) - Math.min(b1, b2);
-
- return rDiff + gDiff + bDiff;
- }
-
- @action
- validateColor(name, color, { addError }) {
- color = color.trim();
-
- let title;
- if (name === "color") {
- title = i18n("category.background_color");
- } else if (name === "text_color") {
- title = i18n("category.foreground_color");
- } else {
- throw new Error(`unknown title for category attribute ${name}`);
- }
-
- if (!color) {
- addError(name, {
- title,
- message: i18n("category.color_validations.cant_be_empty"),
- });
- return;
- }
-
- if (color.length !== 3 && color.length !== 6) {
- addError(name, {
- title,
- message: i18n("category.color_validations.incorrect_length"),
- });
- return;
- }
-
- if (!/^[0-9A-Fa-f]+$/.test(color)) {
- addError(name, {
- title,
- message: i18n("category.color_validations.non_hexdecimal"),
- });
- }
- }
-
- get categoryDescription() {
- if (this.args.category.description) {
- return trustHTML(this.args.category.description);
- }
-
- return trustHTML(i18n("category.no_description"));
- }
-
- get canSelectParentCategory() {
- return !this.args.category.isUncategorizedCategory;
- }
-
- get panelClass() {
- const isActive = this.args.selectedTab === "general" ? "active" : "";
- return `edit-category-tab edit-category-tab-general ${isActive}`;
- }
-
- <template>
- <div class={{this.panelClass}}>
- {{#if this.showWarning}}
- <@form.Alert @type="warning" @icon="triangle-exclamation">
- {{trustHTML
- (i18n
- "category.uncategorized_general_warning"
- settingLink=this.uncategorizedSiteSettingLink
- customizeLink=this.customizeTextContentLink
- )
- }}
- </@form.Alert>
- {{/if}}
-
- <PluginOutlet
- @name="category-name-fields-details"
- @outletArgs={{lazyHash form=@form category=@category}}
- >
- {{#unless @category.isUncategorizedCategory}}
- <@form.Field
- @name="name"
- @title={{i18n "category.name"}}
- @format="large"
- @validation="required"
- @type="input"
- as |field|
- >
- <field.Control
- placeholder={{i18n "category.name_placeholder"}}
- @maxlength="50"
- class="category-name"
- />
- </@form.Field>
- {{/unless}}
-
- <@form.Field
- @name="slug"
- @title={{i18n "category.slug"}}
- @format="large"
- @type="input"
- as |field|
- >
- <field.Control
- placeholder={{i18n "category.slug_placeholder"}}
- @maxlength="255"
- />
- </@form.Field>
- </PluginOutlet>
-
- {{#if this.canSelectParentCategory}}
- <@form.Field
- @name="parent_category_id"
- @title={{i18n "category.parent"}}
- @format="large"
- class="parent-category"
- @type="custom"
- as |field|
- >
- <field.Control>
- <CategoryChooser
- @value={{@transientData.parent_category_id}}
- @allowSubCategories={{true}}
- @allowRestrictedCategories={{true}}
- @onChange={{field.set}}
- @options={{hash
- allowUncategorized=false
- autoInsertNoneItem=true
- none=true
- }}
- />
- </field.Control>
- </@form.Field>
- {{/if}}
-
- {{#if this.subCategories}}
- <@form.Container @title={{i18n "categories.subcategories"}}>
- {{#each this.subCategories as |s|}}
- {{dCategoryBadge s hideParent="true"}}
- {{/each}}
- </@form.Container>
- {{/if}}
-
- {{#if this.showDescription}}
- <@form.Section @title={{i18n "category.description"}}>
- <DDecoratedHtml
- @html={{this.categoryDescription}}
- @className="readonly-field"
- />
-
- {{#if @category.topic_url}}
- <@form.Container>
- <@form.Button
- @action={{this.showCategoryTopic}}
- @icon="pencil"
- @label="category.change_in_category_topic"
- class="btn-default edit-category-description"
- />
- </@form.Container>
- {{/if}}
- </@form.Section>
- {{/if}}
-
- <@form.Section @title={{i18n "category.style"}} class="category-style">
- <@form.Field
- @name="style_type"
- @title={{i18n "category.styles.type"}}
- @format="large"
- @validation="required"
- @type="select"
- as |field|
- >
- {{trustHTML (this.categoryBadgePreview @transientData)}}
- <field.Control as |select|>
- {{#each this.styleTypes as |styleType|}}
- <select.Option @value={{styleType.id}}>
- {{styleType.name}}
- </select.Option>
- {{/each}}
- </field.Control>
- </@form.Field>
-
- {{#if (eq @transientData.style_type "emoji")}}
- <@form.Field
- @name="emoji"
- @title={{i18n "category.styles.emoji"}}
- @format="small"
- @validation="required"
- @type="emoji"
- as |field|
- >
- <field.Control />
- </@form.Field>
- {{else if (eq @transientData.style_type "icon")}}
- <@form.Field
- @name="icon"
- @title={{i18n "category.styles.icon"}}
- @format="small"
- @validation="required"
- @type="icon"
- as |field|
- >
- <field.Control />
- </@form.Field>
- {{/if}}
-
- <@form.Field
- @name="color"
- @title={{i18n "category.background_color"}}
- @format="full"
- @validate={{this.validateColor}}
- @validation="required"
- @onSet={{this.setBackgroundColor}}
- @type="color"
- as |field|
- >
- <field.Control
- @colors={{this.backgroundColors}}
- @usedColors={{this.usedBackgroundColors}}
- />
- </@form.Field>
-
- <@form.Field
- @name="text_color"
- @title={{i18n "category.foreground_color"}}
- @format="full"
- @validate={{this.validateColor}}
- @validation="required"
- @type="color"
- as |field|
- >
- <field.Control @colors={{CATEGORY_TEXT_COLORS}} />
- </@form.Field>
- </@form.Section>
- </div>
- </template>
-}
diff --git a/frontend/discourse/admin/components/edit-category-images.gjs b/frontend/discourse/admin/components/edit-category-images.gjs
deleted file mode 100644
index ad341272006..00000000000
--- a/frontend/discourse/admin/components/edit-category-images.gjs
+++ /dev/null
@@ -1,147 +0,0 @@
-import EmberObject, { action, computed } from "@ember/object";
-import { buildCategoryPanel } from "discourse/admin/components/edit-category-panel";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import UppyImageUploader from "discourse/components/uppy-image-uploader";
-import lazyHash from "discourse/helpers/lazy-hash";
-import { i18n } from "discourse-i18n";
-
-export default class EditCategoryImages extends buildCategoryPanel("images") {
- @computed("category.uploaded_background.url")
- get backgroundImageUrl() {
- return this.category?.uploaded_background?.url || "";
- }
-
- @computed("category.uploaded_background_dark.url")
- get backgroundDarkImageUrl() {
- return this.category?.uploaded_background_dark?.url || "";
- }
-
- @computed("category.uploaded_logo.url")
- get logoImageUrl() {
- return this.category?.uploaded_logo?.url || "";
- }
-
- @computed("category.uploaded_logo_dark.url")
- get logoImageDarkUrl() {
- return this.category?.uploaded_logo_dark?.url || "";
- }
-
- @action
- logoUploadDone(upload) {
- this._setFromUpload("category.uploaded_logo", upload);
- }
-
- @action
- logoUploadDeleted() {
- this._deleteUpload("category.uploaded_logo");
- }
-
- @action
- logoDarkUploadDone(upload) {
- this._setFromUpload("category.uploaded_logo_dark", upload);
- }
-
- @action
- logoDarkUploadDeleted() {
- this._deleteUpload("category.uploaded_logo_dark");
- }
-
- @action
- backgroundUploadDone(upload) {
- this._setFromUpload("category.uploaded_background", upload);
- }
-
- @action
- backgroundUploadDeleted() {
- this._deleteUpload("category.uploaded_background");
- }
-
- @action
- backgroundDarkUploadDone(upload) {
- this._setFromUpload("category.uploaded_background_dark", upload);
- }
-
- @action
- backgroundDarkUploadDeleted() {
- this._deleteUpload("category.uploaded_background_dark");
- }
-
- _deleteUpload(path) {
- this.set(
- path,
- EmberObject.create({
- id: null,
- url: null,
- })
- );
- }
-
- _setFromUpload(path, upload) {
- this.set(
- path,
- EmberObject.create({
- url: upload.url,
- id: upload.id,
- })
- );
- }
-
- <template>
- <section class="field category-logo">
- <label>{{i18n "category.logo"}}</label>
- <UppyImageUploader
- @imageUrl={{this.logoImageUrl}}
- @onUploadDone={{this.logoUploadDone}}
- @onUploadDeleted={{this.logoUploadDeleted}}
- @type="category_logo"
- @id="category-logo-uploader"
- class="no-repeat contain-image"
- />
- <div class="category-logo-description">
- {{i18n "category.logo_description"}}
- </div>
- </section>
-
- <section class="field category-logo">
- <label>{{i18n "category.logo_dark"}}</label>
- <UppyImageUploader
- @imageUrl={{this.logoImageDarkUrl}}
- @onUploadDone={{this.logoDarkUploadDone}}
- @onUploadDeleted={{this.logoDarkUploadDeleted}}
- @type="category_logo_dark"
- @id="category-dark-logo-uploader"
- class="no-repeat contain-image"
- />
- <div class="category-logo-description">
- {{i18n "category.logo_description"}}
- </div>
- </section>
-
- <section class="field category-background-image">
- <label>{{i18n "category.background_image"}}</label>
- <UppyImageUploader
- @imageUrl={{this.backgroundImageUrl}}
- @onUploadDone={{this.backgroundUploadDone}}
- @onUploadDeleted={{this.backgroundUploadDeleted}}
- @type="category_background"
- @id="category-background-uploader"
- />
- </section>
-
- <section class="field category-background-image">
- <label>{{i18n "category.background_image_dark"}}</label>
- <UppyImageUploader
- @imageUrl={{this.backgroundDarkImageUrl}}
- @onUploadDone={{this.backgroundDarkUploadDone}}
- @onUploadDeleted={{this.backgroundDarkUploadDeleted}}
- @type="category_background_dark"
- @id="category-dark-background-uploader"
- />
- </section>
-
- <PluginOutlet
- @name="category-custom-images"
- @outletArgs={{lazyHash category=this.category}}
- />
- </template>
-}
diff --git a/frontend/discourse/admin/components/edit-category-security.gjs b/frontend/discourse/admin/components/edit-category-security.gjs
deleted file mode 100644
index f99c21e4c63..00000000000
--- a/frontend/discourse/admin/components/edit-category-security.gjs
+++ /dev/null
@@ -1,161 +0,0 @@
-import { tracked } from "@glimmer/tracking";
-import { hash } from "@ember/helper";
-import { action } from "@ember/object";
-import { dependentKeyCompat } from "@ember/object/compat";
-import { service } from "@ember/service";
-import { buildCategoryPanel } from "discourse/admin/components/edit-category-panel";
-import CategoryPermissionRow from "discourse/components/category-permission-row";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import lazyHash from "discourse/helpers/lazy-hash";
-import { AUTO_GROUPS } from "discourse/lib/constants";
-import PermissionType from "discourse/models/permission-type";
-import ComboBox from "discourse/select-kit/components/combo-box";
-import { i18n } from "discourse-i18n";
-
-export default class EditCategorySecurity extends buildCategoryPanel(
- "security"
-) {
- @service site;
-
- @tracked selectedGroup = null;
-
- @dependentKeyCompat
- get noGroupSelected() {
- return !this.selectedGroup;
- }
-
- get everyonePermission() {
- return this.category.permissions.find(
- (p) => p.group_id === AUTO_GROUPS.everyone.id
- );
- }
-
- get everyoneGrantedFull() {
- return (
- this.everyonePermission &&
- this.everyonePermission.permission_type === PermissionType.FULL
- );
- }
-
- get minimumPermission() {
- return this.everyonePermission
- ? this.everyonePermission.permission_type
- : PermissionType.READONLY;
- }
-
- @action
- onSelectGroup(group_name) {
- const group = this.site.groups.find((g) => g.name === group_name);
- this.category.addPermission({
- group_name,
- group_id: group?.id,
- permission_type: this.minimumPermission,
- });
- }
-
- @action
- onChangeEveryonePermission(everyonePermissionType) {
- this.category.permissions.forEach((permission, idx) => {
- if (permission.group_id === AUTO_GROUPS.everyone.id) {
- return;
- }
-
- if (everyonePermissionType < permission.permission_type) {
- this.category.set(
- `permissions.${idx}.permission_type`,
- everyonePermissionType
- );
- }
- });
- }
-
- <template>
- <section class="field">
- {{#if this.category.is_special}}
- {{#if this.category.isUncategorizedCategory}}
- <p class="warning">{{i18n
- "category.uncategorized_security_warning"
- }}</p>
- {{else}}
- <p class="warning">{{i18n "category.special_warning"}}</p>
- {{/if}}
- {{/if}}
-
- {{#unless this.category.is_special}}
- <div class="category-permissions-table">
- <div class="permission-row row-header">
- <span class="group-name">{{i18n
- "category.permissions.group"
- }}</span>
- <span class="options">
- <span class="cell">{{i18n "category.permissions.see"}}</span>
- <span class="cell">{{i18n "category.permissions.reply"}}</span>
- <span class="cell">{{i18n "category.permissions.create"}}</span>
- <span class="cell"></span>
- </span>
- </div>
- {{#each this.category.permissions as |p|}}
- <CategoryPermissionRow
- @groupId={{p.group_id}}
- @groupName={{p.group_name}}
- @type={{p.permission_type}}
- @category={{this.category}}
- @everyonePermission={{this.everyonePermission}}
- @onChangeEveryonePermission={{this.onChangeEveryonePermission}}
- />
- {{/each}}
-
- {{#unless this.category.permissions}}
- <div class="permission-row row-empty">
- {{i18n "category.permissions.no_groups_selected"}}
- </div>
- {{/unless}}
- </div>
-
- <PluginOutlet
- @name="category-security-permissions-add-group"
- @outletArgs={{lazyHash
- category=this.category
- availableGroups=this.category.availableGroups
- onSelectGroup=this.onSelectGroup
- }}
- @defaultGlimmer={{true}}
- >
- {{#if this.category.availableGroups}}
- <div class="add-group">
- <span class="group-name">
- <ComboBox
- @content={{this.category.availableGroups}}
- @onChange={{this.onSelectGroup}}
- @value={{null}}
- @valueProperty={{null}}
- @nameProperty={{null}}
- @options={{hash none="category.security_add_group"}}
- class="available-groups"
- />
- </span>
- </div>
- {{/if}}
-
- <@form.Alert @type="warning">
- {{#if this.everyoneGrantedFull}}
- {{i18n
- "category.permissions.everyone_full_access"
- everyone_group=this.everyonePermission.group_name
- }}
- {{else}}
- {{i18n "category.permissions.specific_groups_have_access"}}
- {{/if}}
- </@form.Alert>
- </PluginOutlet>
- {{/unless}}
- </section>
-
- <section>
- <PluginOutlet
- @name="category-custom-security"
- @outletArgs={{lazyHash category=this.category}}
- />
- </section>
- </template>
-}
diff --git a/frontend/discourse/admin/components/edit-category-settings.gjs b/frontend/discourse/admin/components/edit-category-settings.gjs
deleted file mode 100644
index 9a943e0f8a6..00000000000
--- a/frontend/discourse/admin/components/edit-category-settings.gjs
+++ /dev/null
@@ -1,706 +0,0 @@
-import { Input } from "@ember/component";
-import { fn, hash } from "@ember/helper";
-import { on } from "@ember/modifier";
-import { action, computed } from "@ember/object";
-import { trustHTML } from "@ember/template";
-import { isEmpty } from "@ember/utils";
-import { buildCategoryPanel } from "discourse/admin/components/edit-category-panel";
-import PluginOutlet from "discourse/components/plugin-outlet";
-import lazyHash from "discourse/helpers/lazy-hash";
-import withEventValue from "discourse/helpers/with-event-value";
-import {
- POSTING_REVIEW_GROUP_BASED_MODES,
- SEARCH_PRIORITIES,
-} from "discourse/lib/constants";
-import getUrl from "discourse/lib/get-url";
-import { applyMutableValueTransformer } from "discourse/lib/transformer";
-import ComboBox from "discourse/select-kit/components/combo-box";
-import GroupChooser from "discourse/select-kit/components/group-chooser";
-import DRelativeTimePicker from "discourse/ui-kit/d-relative-time-picker";
-import DTextField from "discourse/ui-kit/d-text-field";
-import dIcon from "discourse/ui-kit/helpers/d-icon";
-import { i18n } from "discourse-i18n";
-
-export default class EditCategorySettings extends buildCategoryPanel(
- "settings"
-) {
- @computed("siteSettings.email_in")
- get emailInEnabled() {
- return this.siteSettings.email_in;
- }
-
- @computed("siteSettings.fixed_category_positions")
- get showPositionInput() {
- return this.siteSettings.fixed_category_positions;
- }
-
- @computed("category.show_subcategory_list", "isParentCategory")
- get showSubcategoryListStyle() {
- return this.category?.show_subcategory_list && this.isParentCategory;
- }
-
- @computed("category.sort_order")
- get isDefaultSortOrder() {
- return isEmpty(this.category?.sort_order);
- }
-
- @computed(
- "category.isParent",
- "category.parent_category_id",
- "transientData.parent_category_id"
- )
- get isParentCategory() {
- return (
- this.category?.isParent ||
- !(
- this.category?.parent_category_id ||
- this.transientData?.parent_category_id
- )
- );
- }
-
- @computed
- get availableSubcategoryListStyles() {
- return [
- { name: i18n("category.subcategory_list_styles.rows"), value: "rows" },
- {
- name: i18n(
- "category.subcategory_list_styles.rows_with_featured_topics"
- ),
- value: "rows_with_featured_topics",
- },
- {
- name: i18n("category.subcategory_list_styles.boxes"),
- value: "boxes",
- },
- {
- name: i18n(
- "category.subcategory_list_styles.boxes_with_featured_topics"
- ),
- value: "boxes_with_featured_topics",
- },
- ];
- }
-
- @computed("category.id", "category.custom_fields")
- get availableViews() {
- const views = [
- { name: i18n("filters.hot.title"), value: "hot" },
- { name: i18n("filters.latest.title"), value: "latest" },
- { name: i18n("filters.top.title"), value: "top" },
- ];
-
- const context = {
- categoryId: this.category?.id,
- customFields: this.category?.custom_fields,
- };
-
- return applyMutableValueTransformer(
- "category-available-views",
- views,
- context
- );
- }
-
- @computed
- get availableTopPeriods() {
- return ["all", "yearly", "quarterly", "monthly", "weekly", "daily"].map(
- (p) => {
- return { name: i18n(`filters.top.${p}.title`), value: p };
- }
- );
- }
-
- @computed
- get availableListFilters() {
- return ["all", "none"].map((p) => {
- return { name: i18n(`category.list_filters.${p}`), value: p };
- });
- }
-
- @computed
- get searchPrioritiesOptions() {
- const options = [];
-
- Object.entries(SEARCH_PRIORITIES).forEach((entry) => {
- const [name, value] = entry;
-
- options.push({
- name: i18n(`category.search_priority.options.${name}`),
- value,
- });
- });
-
- return options;
- }
-
- @computed
- get availableSorts() {
- return applyMutableValueTransformer("category-sort-orders", [
- "likes",
- "op_likes",
- "views",
- "posts",
- "activity",
- "posters",
- "category",
- "created",
- ])
- .map((s) => ({ name: i18n("category.sort_options." + s), value: s }))
- .sort((a, b) => a.name.localeCompare(b.name));
- }
-
- @computed("category.sort_ascending")
- get sortAscendingOption() {
- if (this.category?.sort_ascending === "false") {
- return false;
- }
- if (this.category?.sort_ascending === "true") {
- return true;
- }
- return this.category?.sort_ascending;
- }
-
- @computed
- get sortAscendingOptions() {
- return [
- { name: i18n("category.sort_ascending"), value: true },
- { name: i18n("category.sort_descending"), value: false },
- ];
- }
-
- @computed
- get hiddenRelativeIntervals() {
- return ["mins"];
- }
-
- @action
- onAutoCloseDurationChange(minutes) {
- let hours = minutes ? minutes / 60 : null;
- this.set("category.auto_close_hours", hours);
- }
-
- @action
- onDefaultSlowModeDurationChange(minutes) {
- let seconds = minutes ? minutes * 60 : null;
- this.set("category.default_slow_mode_seconds", seconds);
- }
-
- @action
- onCategoryModeratingGroupsChange(groupIds) {
- this.set("category.moderating_group_ids", groupIds);
- }
-
- @action
- onFormCheckboxChange(field, event) {
- this.form.set(field, event.target.checked);
- }
-
- @computed
- get postingReviewModeOptions() {
- return [
- {
- name: i18n("category.posting_review_modes.no_one"),
- value: "no_one",
- },
- {
- name: i18n("category.posting_review_modes.everyone"),
- value: "everyone",
- },
- {
- name: i18n("category.posting_review_modes.everyone_except"),
- value: "everyone_except",
- },
- {
- name: i18n("category.posting_review_modes.no_one_except"),
- value: "no_one_except",
- },
- ];
- }
-
- @computed("category.category_setting.topic_posting_review_mode")
- get topicModeRequiresGroups() {
- return POSTING_REVIEW_GROUP_BASED_MODES.includes(
- this.category?.category_setting?.topic_posting_review_mode
- );
- }
-
- @computed("category.category_setting.reply_posting_review_mode")
- get replyModeRequiresGroups() {
- return POSTING_REVIEW_GROUP_BASED_MODES.includes(
- this.category?.category_setting?.reply_posting_review_mode
- );
- }
-
- @action
- onTopicPostingReviewModeChange(value) {
- this.set("category.category_setting.topic_posting_review_mode", value);
- if (!POSTING_REVIEW_GROUP_BASED_MODES.includes(value)) {
- this.set("category.topic_posting_review_group_ids", []);
- }
- }
-
- @action
- onReplyPostingReviewModeChange(value) {
- this.set("category.category_setting.reply_posting_review_mode", value);
- if (!POSTING_REVIEW_GROUP_BASED_MODES.includes(value)) {
- this.set("category.reply_posting_review_group_ids", []);
- }
- }
-
- @action
- onTopicPostingReviewGroupsChange(groupIds) {
- this.set("category.topic_posting_review_group_ids", groupIds);
- }
-
- @action
- onReplyPostingReviewGroupsChange(groupIds) {
- this.set("category.reply_posting_review_group_ids", groupIds);
- }
-
- <template>
- <section>
- {{#if this.showPositionInput}}
- <section class="field position-fields">
- <label for="category-position">
- {{i18n "category.position"}}
- </label>
- <input
- {{on "input" (withEventValue (fn (mut this.category.position)))}}
- value={{this.category.position}}
- type="number"
- min="0"
- id="category-position"
- class="position-input"
- />
- </section>
- {{/if}}
-
- {{#unless this.showPositionInput}}
- <section class="field position-disabled">
- {{trustHTML
- (i18n
- "category.position_disabled"
- url=(getUrl
- "/admin/site_settings/category/all_results?filter=fixed_category_positions"
- )
- )
- }}
- </section>
- {{/unless}}
-
- <section class="field num-featured-topics">
- <label for="category-number-featured-topics">
- {{#if this.category.parent_category_id}}
- {{i18n "category.subcategory_num_featured_topics"}}
- {{else}}
- {{i18n "category.num_featured_topics"}}
- {{/if}}
- </label>
- <input
- {{on
- "input"
- (withEventValue (fn (mut this.category.num_featured_topics)))
- }}
- value={{this.category.num_featured_topics}}
- type="number"
- min="1"
- id="category-number-featured-topics"
- />
- </section>
-
- <section class="field search-priority">
- <label>
- {{i18n "category.search_priority.label"}}
- </label>
- <div class="controls">
- <ComboBox
- @valueProperty="value"
- @id="category-search-priority"
- @content={{this.searchPrioritiesOptions}}
- @value={{this.category.search_priority}}
- @onChange={{fn (mut this.category.search_priority)}}
- @options={{hash placementStrategy="absolute"}}
- />
- </div>
- </section>
-
- {{#if this.siteSettings.enable_badges}}
- <section class="field allow-badges">
- <label class="checkbox-label">
- <Input @type="checkbox" @checked={{this.category.allow_badges}} />
- {{i18n "category.allow_badges_label"}}
- </label>
- </section>
- {{/if}}
-
- {{#if this.siteSettings.topic_featured_link_enabled}}
- <section class="field topic-featured-link-allowed">
- <div class="allowed-topic-featured-link-category">
- <label class="checkbox-label">
- <Input
- @type="checkbox"
- @checked={{this.category.topic_featured_link_allowed}}
- />
- {{i18n "category.topic_featured_link_allowed"}}
- </label>
- </div>
- </section>
- {{/if}}
-
- <section class="field navigate-to-first-post-after-read">
- <label class="checkbox-label">
- <Input
- @type="checkbox"
- @checked={{this.category.navigate_to_first_post_after_read}}
- />
- {{i18n "category.navigate_to_first_post_after_read"}}
- </label>
- </section>
-
- <section class="field all-topics-wiki">
- <label class="checkbox-label">
- <Input @type="checkbox" @checked={{this.category.all_topics_wiki}} />
- {{i18n "category.all_topics_wiki"}}
- </label>
- </section>
-
- <section class="field allow-unlimited-owner-edits-on-first-post">
- <label class="checkbox-label">
- <Input
- @type="checkbox"
- @checked={{this.category.allow_unlimited_owner_edits_on_first_post}}
- />
- {{i18n "category.allow_unlimited_owner_edits_on_first_post"}}
- </label>
- </section>
- </section>
-
- <section>
- <h3>{{i18n "category.settings_sections.moderation"}}</h3>
- {{#if this.siteSettings.enable_category_group_moderation}}
- <section class="field reviewable-by-group">
- <label>{{i18n "category.reviewable_by_group"}}</label>
- <GroupChooser
- @content={{this.site.groups}}
- @value={{this.category.moderating_group_ids}}
- @onChange={{this.onCategoryModeratingGroupsChange}}
- />
- </section>
- {{/if}}
-
- <section class="field topic-posting-review-mode">
- <label>{{i18n "category.require_topic_approval_for"}}</label>
- <div class="controls">
- <ComboBox
- @valueProperty="value"
- @content={{this.postingReviewModeOptions}}
- @value={{this.category.category_setting.topic_posting_review_mode}}
- @onChange={{this.onTopicPostingReviewModeChange}}
- @options={{hash placementStrategy="absolute"}}
- />
- </div>
- {{#if this.topicModeRequiresGroups}}
- <GroupChooser
- class="posting-review-group-chooser"
- @content={{this.site.groups}}
- @value={{this.category.topic_posting_review_group_ids}}
- @onChange={{this.onTopicPostingReviewGroupsChange}}
- @options={{hash none="category.posting_review_groups_placeholder"}}
- />
- {{/if}}
- </section>
-
- <section class="field reply-posting-review-mode">
- <label>{{i18n "category.require_reply_approval_for"}}</label>
- <div class="controls">
- <ComboBox
- @valueProperty="value"
- @content={{this.postingReviewModeOptions}}
- @value={{this.category.category_setting.reply_posting_review_mode}}
- @onChange={{this.onReplyPostingReviewModeChange}}
- @options={{hash placementStrategy="absolute"}}
- />
- </div>
- {{#if this.replyModeRequiresGroups}}
- <GroupChooser
- class="posting-review-group-chooser"
- @content={{this.site.groups}}
- @value={{this.category.reply_posting_review_group_ids}}
- @onChange={{this.onReplyPostingReviewGroupsChange}}
- @options={{hash none="category.posting_review_groups_placeholder"}}
- />
- {{/if}}
- </section>
-
- <section class="field default-slow-mode">
- <div class="control-group">
- <label for="category-default-slow-mode">
- {{i18n "category.default_slow_mode"}}
- </label>
- <div class="category-default-slow-mode-seconds">
- <DRelativeTimePicker
- @id="category-default-slow-mode"
- @durationMinutes={{this.category.defaultSlowModeMinutes}}
- @onChange={{this.onDefaultSlowModeDurationChange}}
- />
- </div>
- </div>
- </section>
-
- <section class="field auto-close">
- <div class="control-group">
- <label for="topic-auto-close">
- {{i18n "topic.auto_close.label"}}
- </label>
- <div class="category-topic-auto-close-hours">
- <DRelativeTimePicker
- @id="topic-auto-close"
- @durationHours={{this.category.auto_close_hours}}
- @hiddenIntervals={{this.hiddenRelativeIntervals}}
- @onChange={{this.onAutoCloseDurationChange}}
- />
- </div>
- <label class="checkbox-label">
- <Input
- @type="checkbox"
- @checked={{this.category.auto_close_based_on_last_post}}
- />
- {{i18n "topic.auto_close.based_on_last_post"}}
- </label>
- </div>
- </section>
-
- <section class="field num-auto-bump-daily">
- <label for="category-number-daily-bump">
- {{i18n "category.num_auto_bump_daily"}}
- </label>
- <input
- {{on
- "input"
- (withEventValue
- (fn (mut this.category.category_setting.num_auto_bump_daily))
- )
- }}
- value={{this.category.category_setting.num_auto_bump_daily}}
- type="number"
- min="0"
- id="category-number-daily-bump"
- />
- </section>
-
- <section class="field auto-bump-cooldown-days">
- <label for="category-auto-bump-cooldown-days">
- {{i18n "category.auto_bump_cooldown_days"}}
- </label>
- <input
- {{on
- "input"
- (withEventValue
- (fn (mut this.category.category_setting.auto_bump_cooldown_days))
- )
- }}
- value={{this.category.category_setting.auto_bump_cooldown_days}}
- type="number"
- min="0"
- id="category-auto-bump-cooldown-days"
- />
- </section>
- </section>
-
- <section>
- <h3>{{i18n "category.settings_sections.appearance"}}</h3>
-
- <section class="field default-view-field">
- <label>
- {{i18n "category.default_view"}}
- </label>
- <div class="controls">
- <ComboBox
- @valueProperty="value"
- @id="category-default-view"
- @content={{this.availableViews}}
- @value={{this.category.default_view}}
- @options={{hash placementStrategy="absolute"}}
- />
- </div>
- </section>
-
- <section class="field default-top-period-field">
- <label>
- {{i18n "category.default_top_period"}}
- </label>
- <div class="controls">
- <ComboBox
- @valueProperty="value"
- @id="category-default-period"
- @content={{this.availableTopPeriods}}
- @value={{this.category.default_top_period}}
- @options={{hash placementStrategy="absolute"}}
- />
- </div>
- </section>
-
- <section class="field sort-order">
- <label>
- {{i18n "category.sort_order"}}
- </label>
- <div class="controls">
- <ComboBox
- @valueProperty="value"
- @content={{this.availableSorts}}
- @value={{this.category.sort_order}}
- @options={{hash none="category.sort_options.default"}}
- @onChange={{fn (mut this.category.sort_order)}}
- />
- {{#unless this.isDefaultSortOrder}}
- <ComboBox
- @valueProperty="value"
- @content={{this.sortAscendingOptions}}
- @value={{this.sortAscendingOption}}
- @options={{hash
- none="category.sort_options.default"
- placementStrategy="absolute"
- }}
- @onChange={{fn (mut this.category.sort_ascending)}}
- />
- {{/unless}}
- </div>
- </section>
-
- <section class="field default-filter">
- <label>
- {{i18n "category.default_list_filter"}}
- </label>
- <div class="controls">
- <ComboBox
- @id="category-default-filter"
- @valueProperty="value"
- @content={{this.availableListFilters}}
- @value={{this.category.default_list_filter}}
- />
- </div>
- </section>
-
- {{#if this.isParentCategory}}
- <section class="field show-subcategory-list-field">
- <label class="checkbox-label">
- <Input
- @type="checkbox"
- @checked={{this.category.show_subcategory_list}}
- />
- {{i18n "category.show_subcategory_list"}}
- </label>
- </section>
- {{/if}}
-
- {{#if this.showSubcategoryListStyle}}
- <section class="field subcategory-list-style-field">
- <label>
- {{i18n "category.subcategory_list_style"}}
- </label>
- <ComboBox
- @valueProperty="value"
- @id="subcategory-list-style"
- @content={{this.availableSubcategoryListStyles}}
- @value={{this.category.subcategory_list_style}}
- @options={{hash placementStrategy="absolute"}}
- />
- </section>
- {{/if}}
-
- <section class="field category-read-only-banner">
- <label for="read-only-message">{{i18n
- "category.read_only_banner"
- }}</label>
- <DTextField
- @valueProperty="value"
- @id="read-only-message"
- @value={{this.category.read_only_banner}}
- @options={{hash placementStrategy="absolute"}}
- />
- </section>
- </section>
-
- <section>
- <h3>{{i18n "category.settings_sections.email"}}</h3>
-
- {{#if this.emailInEnabled}}
- <section class="field category-email-in">
- <label for="category-email-in">
- {{dIcon "envelope"}}
- {{i18n "category.email_in"}}
- </label>
- <input
- type="text"
- id="category-email-in"
- class="email-in"
- value={{this.transientData.email_in}}
- {{on "input" (withEventValue (fn this.form.set "email_in"))}}
- />
- </section>
-
- <section class="field email-in-allow-strangers">
- <label class="checkbox-label">
- <input
- type="checkbox"
- checked={{this.transientData.email_in_allow_strangers}}
- {{on
- "change"
- (fn this.onFormCheckboxChange "email_in_allow_strangers")
- }}
- />
- {{i18n "category.email_in_allow_strangers"}}
- </label>
- </section>
-
- <section class="field mailinglist-mirror">
- <label class="checkbox-label">
- <input
- type="checkbox"
- checked={{this.transientData.mailinglist_mirror}}
- {{on
- "change"
- (fn this.onFormCheckboxChange "mailinglist_mirror")
- }}
- />
- {{i18n "category.mailinglist_mirror"}}
- </label>
- </section>
-
- <span>
- <PluginOutlet
- @name="category-email-in"
- @connectorTagName="div"
- @outletArgs={{lazyHash category=this.category form=this.form}}
- />
- </span>
- {{/if}}
-
- {{#unless this.emailInEnabled}}
- <section class="field email-in-disabled">
- {{trustHTML
- (i18n
- "category.email_in_disabled"
- setting_url=(getUrl
- "/admin/site_settings/category/all_results?filter=email_in"
- )
- )
- }}
- </section>
- {{/unless}}
- </section>
-
- <section>
- <PluginOutlet
- @name="category-custom-settings"
- @outletArgs={{lazyHash
- category=this.category
- form=this.form
- transientData=this.transientData
- registerValidator=this.registerValidator
- }}
- />
- </section>
- </template>
-}
diff --git a/frontend/discourse/admin/components/edit-category-tags.gjs b/frontend/discourse/admin/components/edit-category-tags.gjs
deleted file mode 100644
index c36f23f285f..00000000000
--- a/frontend/discourse/admin/components/edit-category-tags.gjs
+++ /dev/null
@@ -1,157 +0,0 @@
-import { Input } from "@ember/component";
-import { array, fn, hash } from "@ember/helper";
-import { action, computed, set } from "@ember/object";
-import { LinkTo } from "@ember/routing";
-import { isEmpty } from "@ember/utils";
-import { buildCategoryPanel } from "discourse/admin/components/edit-category-panel";
-import { removeValueFromArray } from "discourse/lib/array-tools";
-import TagChooser from "discourse/select-kit/components/tag-chooser";
-import TagGroupChooser from "discourse/select-kit/components/tag-group-chooser";
-import DButton from "discourse/ui-kit/d-button";
-import DTextField from "discourse/ui-kit/d-text-field";
-import { i18n } from "discourse-i18n";
-
-export default class EditCategoryTags extends buildCategoryPanel("tags") {
- @computed("category.allowed_tags.length")
- get allowedTagsEmpty() {
- return isEmpty(this.category?.allowed_tags);
- }
-
- @computed("category.allowed_tag_groups.length")
- get allowedTagGroupsEmpty() {
- return isEmpty(this.category?.allowed_tag_groups);
- }
-
- @computed("allowedTagsEmpty", "allowedTagGroupsEmpty")
- get disableAllowGlobalTags() {
- return this.allowedTagsEmpty && this.allowedTagGroupsEmpty;
- }
-
- @action
- onTagGroupChange(rtg, valueArray) {
- // A little strange, but we're using a multi-select component
- // to select a single tag group. This action takes the array
- // and extracts the first value in it.
- set(rtg, "name", valueArray[0]);
- }
-
- @action
- addRequiredTagGroup() {
- this.category.required_tag_groups.push({
- min_count: 1,
- });
- }
-
- @action
- deleteRequiredTagGroup(rtg) {
- removeValueFromArray(this.category.required_tag_groups, rtg);
- }
-
- @action
- onAllowedTagsChange(items) {
- set(this.category, "allowed_tags", items);
- }
-
- <template>
- <section class="field minimum-required-tags">
- <label for="category-minimum-tags">
- {{i18n "category.minimum_required_tags"}}
- </label>
- <DTextField
- @value={{this.category.minimum_required_tags}}
- @id="category-minimum-tags"
- @type="number"
- @min="0"
- />
- </section>
- <section class="field allowed-tags">
- <label>
- {{#if this.category.id}}
- {{i18n "category.tags_allowed_tags" categoryName=this.category.name}}
- {{else}}
- {{i18n "category.tags_allowed_tags_new_category"}}
- {{/if}}
- </label>
- <TagChooser
- @id="category-allowed-tags"
- @tags={{this.category.allowed_tags}}
- @everyTag={{true}}
- @excludeSynonyms={{true}}
- @unlimitedTagCount={{true}}
- @onChange={{this.onAllowedTagsChange}}
- @options={{hash filterPlaceholder="category.tags_placeholder"}}
- />
- </section>
-
- <section class="field allowed-tag-groups">
- <label>
- {{#if this.category.id}}
- {{i18n
- "category.tags_allowed_tag_groups"
- categoryName=this.category.name
- }}
- {{else}}
- {{i18n "category.tags_allowed_tag_groups_new_category"}}
- {{/if}}
- </label>
- <TagGroupChooser
- @id="category-allowed-tag-groups"
- @tagGroups={{this.category.allowed_tag_groups}}
- @onChange={{fn (mut this.category.allowed_tag_groups)}}
- />
- <LinkTo @route="tagGroups" class="manage-tag-groups">{{i18n
- "category.manage_tag_groups_link"
- }}</LinkTo>
- </section>
-
- <section class="field allow-global-tags">
- <label>
- <Input
- @type="checkbox"
- @checked={{this.category.allow_global_tags}}
- id="allow_global_tags"
- disabled={{this.disableAllowGlobalTags}}
- />
- {{i18n "category.allow_global_tags_label"}}
- </label>
- </section>
-
- <section class="field tags-tab-description">
- {{i18n "category.tags_tab_description"}}
- </section>
-
- <section class="field required-tag-group-description">
- {{i18n "category.required_tag_group.description"}}
- </section>
-
- <section class="field with-items">
- <section class="field-item required-tag-groups">
- {{#each this.category.required_tag_groups as |rtg|}}
- <div class="required-tag-group-row">
- <DTextField @value={{rtg.min_count}} @type="number" @min="1" />
- <TagGroupChooser
- @tagGroups={{if rtg.name (array rtg.name) (array)}}
- @onChange={{fn this.onTagGroupChange rtg}}
- @options={{hash
- maximum=1
- filterPlaceholder="category.required_tag_group.placeholder"
- }}
- />
- <DButton
- @label="category.required_tag_group.delete"
- @action={{fn this.deleteRequiredTagGroup rtg}}
- @icon="trash-can"
- class="delete-required-tag-group"
- />
- </div>
- {{/each}}
- <DButton
- @label="category.required_tag_group.add"
- @action={{this.addRequiredTagGroup}}
- @icon="plus"
- class="btn-default add-required-tag-group"
- />
- </section>
- </section>
- </template>
-}
diff --git a/frontend/discourse/admin/components/upsert-category/general.gjs b/frontend/discourse/admin/components/upsert-category/general.gjs
index fa2d7ff1251..a9dc4f1a54e 100644
--- a/frontend/discourse/admin/components/upsert-category/general.gjs
+++ b/frontend/discourse/admin/components/upsert-category/general.gjs
@@ -780,7 +780,9 @@ export default class UpsertCategoryGeneral extends Component {
<Content @name="square">
{{trustHTML
(dCategoryBadge
- (this.buildTransientModel @transientData) styleType="square"
+ (this.buildTransientModel @transientData)
+ styleType="square"
+ previewColor=true
)
}}
</Content>
diff --git a/frontend/discourse/admin/controllers/edit-category/tabs.js b/frontend/discourse/admin/controllers/edit-category/tabs.js
index f5ec11794a7..01792d5ce33 100644
--- a/frontend/discourse/admin/controllers/edit-category/tabs.js
+++ b/frontend/discourse/admin/controllers/edit-category/tabs.js
@@ -13,29 +13,6 @@ import { defaultHomepage } from "discourse/lib/utilities";
import Category from "discourse/models/category";
import { i18n } from "discourse-i18n";
-// Only fields managed through FormKit in the legacy edit-category flow.
-// Other legacy tab components (settings, tags, etc.) write directly to the model.
-const LEGACY_FORMKIT_FIELDS = [
- "name",
- "slug",
- "parent_category_id",
- "color",
- "text_color",
- "style_type",
- "emoji",
- "icon",
- "locale",
- "localizations",
- "email_in",
- "email_in_enabled",
- "email_in_allow_strangers",
- "mailinglist_mirror",
- "topic_template",
- "topic_title_placeholder",
- "form_template_ids",
-];
-
-// All fields managed through FormKit in the simplified creation flow.
const SIMPLIFIED_FIELD_LIST = [
"name",
"slug",
@@ -130,57 +107,48 @@ export default class EditCategoryTabsController extends Controller {
@action
initFormData() {
- const enableSimplifiedCategoryCreation =
- this.siteSettings.enable_simplified_category_creation;
- const data = getProperties(
- this.model,
- ...(enableSimplifiedCategoryCreation
- ? SIMPLIFIED_FIELD_LIST
- : LEGACY_FORMKIT_FIELDS)
- );
+ const data = getProperties(this.model, ...SIMPLIFIED_FIELD_LIST);
if (this.siteSettings.content_localization_enabled && !data.locale) {
data.locale = this.siteSettings.default_locale;
}
- if (enableSimplifiedCategoryCreation) {
- if (!this.model.styleType) {
- data.style_type = "icon";
- }
+ if (!this.model.styleType) {
+ data.style_type = "icon";
+ }
- data.required_tag_groups = Array.from(
- data.required_tag_groups ?? [],
- (rtg) => ({ ...rtg })
+ data.required_tag_groups = Array.from(
+ data.required_tag_groups ?? [],
+ (rtg) => ({
+ ...rtg,
+ })
+ );
+ data.category_setting = { ...(this.model.category_setting ?? {}) };
+ data.custom_fields = { ...(this.model.custom_fields ?? {}) };
+
+ data.category_type_site_settings = {};
+ data.category_type_settings = {
+ ...(this.model.category_type_settings ?? {}),
+ };
+ data.category_types = Object.keys(this.model.categoryTypes ?? {});
+
+ Object.values(this.model.categoryTypes ?? {}).forEach((categoryType) => {
+ categoryType.configuration_schema.category_custom_fields?.forEach(
+ (field) => {
+ data.custom_fields[field.key] ??= field.default;
+ }
);
- data.category_setting = { ...(this.model.category_setting ?? {}) };
- data.custom_fields = { ...(this.model.custom_fields ?? {}) };
-
- data.category_type_site_settings = {};
- data.category_type_settings = {
- ...(this.model.category_type_settings ?? {}),
- };
- data.category_types = Object.keys(this.model.categoryTypes ?? {});
-
- Object.values(this.model.categoryTypes ?? {}).forEach((categoryType) => {
- categoryType.configuration_schema.category_custom_fields?.forEach(
- (field) => {
- data.custom_fields[field.key] ??= field.default;
- }
- );
- categoryType.configuration_schema.category_settings?.forEach(
- (field) => {
- data.category_type_settings[field.key] ??= field.default;
- }
- );
+ categoryType.configuration_schema.category_settings?.forEach((field) => {
+ data.category_type_settings[field.key] ??= field.default;
+ });
- categoryType.configuration_schema.site_settings?.forEach((setting) => {
- data.category_type_site_settings[setting.key] = this.model.id
- ? setting.current
- : setting.default;
- });
+ categoryType.configuration_schema.site_settings?.forEach((setting) => {
+ data.category_type_site_settings[setting.key] = this.model.id
+ ? setting.current
+ : setting.default;
});
- }
+ });
this.formData = data;
}
@@ -232,12 +200,15 @@ export default class EditCategoryTabsController extends Controller {
@action
setSelectedTab(tab) {
+ if (tab !== "general") {
+ this.showAdvancedTabs = true;
+ }
+
if (this.selectedTab === tab) {
return;
}
this.selectedTab = tab;
- this.showAdvancedTabs = this.showAdvancedTabs || tab !== "general";
}
/**
@@ -253,10 +224,6 @@ export default class EditCategoryTabsController extends Controller {
*/
@action
validateForm(data, { addError, removeError }) {
- if (!this.siteSettings.enable_simplified_category_creation) {
- return;
- }
-
for (const validator of this.validators) {
validator(data, { addError, removeError });
}
@@ -391,20 +358,18 @@ export default class EditCategoryTabsController extends Controller {
return;
}
- if (this.siteSettings.enable_simplified_category_creation) {
- const newTypes = Object.keys(result.category.category_types ?? {});
- const typeWasAdded = newTypes.some((t) => !previousTypes.has(t));
- if (typeWasAdded) {
- if (this.model.id) {
- window.location.reload();
- } else {
- window.location = this.router.urlFor(
- "editCategory",
- Category.slugFor(updatedModel)
- );
- }
- return;
+ const newTypes = Object.keys(result.category.category_types ?? {});
+ const typeWasAdded = newTypes.some((t) => !previousTypes.has(t));
+ if (typeWasAdded) {
+ if (this.model.id) {
+ window.location.reload();
+ } else {
+ window.location = this.router.urlFor(
+ "editCategory",
+ Category.slugFor(updatedModel)
+ );
}
+ return;
}
this.set("saving", false);
diff --git a/frontend/discourse/admin/routes/new-category/index.js b/frontend/discourse/admin/routes/new-category/index.js
index 1f9aa4394c0..5611f60ebf4 100644
--- a/frontend/discourse/admin/routes/new-category/index.js
+++ b/frontend/discourse/admin/routes/new-category/index.js
@@ -6,10 +6,7 @@ export default class NewCategoryIndex extends DiscourseRoute {
@service router;
beforeModel() {
- if (
- this.categoryTypeChooser.isEnabled &&
- !this.categoryTypeChooser.hasCompletedSetup
- ) {
+ if (!this.categoryTypeChooser.hasCompletedSetup) {
this.router.replaceWith("newCategory.setup");
} else {
this.router.replaceWith("newCategory.tabs", "general");
diff --git a/frontend/discourse/admin/routes/new-category/setup.js b/frontend/discourse/admin/routes/new-category/setup.js
index 9f6dd4c9ff4..30d0bf8db6a 100644
--- a/frontend/discourse/admin/routes/new-category/setup.js
+++ b/frontend/discourse/admin/routes/new-category/setup.js
@@ -7,12 +7,6 @@ export default class NewCategorySetup extends DiscourseRoute {
@service categoryTypeChooser;
@service router;
- beforeModel() {
- if (!this.categoryTypeChooser.isEnabled) {
- this.router.replaceWith("newCategory");
- }
- }
-
async model() {
return await ajax("/categories/types");
}
diff --git a/frontend/discourse/admin/routes/new-category/tabs.js b/frontend/discourse/admin/routes/new-category/tabs.js
index e9c33f1178e..e650918ab65 100644
--- a/frontend/discourse/admin/routes/new-category/tabs.js
+++ b/frontend/discourse/admin/routes/new-category/tabs.js
@@ -10,10 +10,7 @@ export default class NewCategoryTabs extends DiscourseRoute {
templateName = "edit-category.tabs";
beforeModel() {
- if (
- this.categoryTypeChooser.isEnabled &&
- !this.categoryTypeChooser.hasCompletedSetup
- ) {
+ if (!this.categoryTypeChooser.hasCompletedSetup) {
this.router.replaceWith("newCategory.setup");
}
}
diff --git a/frontend/discourse/admin/templates/edit-category/tabs-horizontal.gjs b/frontend/discourse/admin/templates/edit-category/tabs-horizontal.gjs
index 184851a0822..694a73ea5b9 100644
--- a/frontend/discourse/admin/templates/edit-category/tabs-horizontal.gjs
+++ b/frontend/discourse/admin/templates/edit-category/tabs-horizontal.gjs
@@ -21,7 +21,7 @@ export default class EditCategoryTabsHorizontalTemplate extends Component {
}
get dynamicCategoryTypeTabs() {
- return Object.values(this.args.controller.model.categoryTypes).filter(
+ return Object.values(this.args.controller.model.categoryTypes ?? {}).filter(
(type) => type.id !== "discussion" && type.visible
);
}
diff --git a/frontend/discourse/admin/templates/edit-category/tabs-vertical.gjs b/frontend/discourse/admin/templates/edit-category/tabs-vertical.gjs
deleted file mode 100644
index ea350f1d026..00000000000
--- a/frontend/discourse/admin/templates/edit-category/tabs-vertical.gjs
+++ /dev/null
@@ -1,92 +0,0 @@
-import EditCategoryTab from "discourse/admin/components/edit-category-tab";
-import BreadCrumbs from "discourse/components/bread-crumbs";
-import { and } from "discourse/truth-helpers";
-import DButton from "discourse/ui-kit/d-button";
-
-const EditCategoryTabsVerticalTemplate = <template>
- <div class="edit-category-title-bar">
- <div class="edit-category-title">
- <h2 class="edit-category-title-text">
- <span
- class="edit-category-static-title"
- >{{@controller.baseTitle}}</span>
- <span class="edit-category-preview-badge">
- {{#if @controller.showPreviewBadge}}
- {{@controller.previewBadge}}
- {{/if}}
- </span>
- </h2>
- {{#if @controller.model.id}}
- <BreadCrumbs
- @categories={{@controller.breadcrumbCategories}}
- @category={{@controller.model}}
- @noSubcategories={{@controller.model.noSubcategories}}
- @editingCategory={{true}}
- @editingCategoryTab={{@controller.selectedTab}}
- />
- {{/if}}
- </div>
- {{#if (and @controller.site.desktopView @controller.model.id)}}
- <DButton
- @action={{@controller.goBack}}
- @label="category.back"
- @icon="angle-left"
- class="category-back"
- />
- {{/if}}
- </div>
-
- <div class="edit-category-nav">
- <ul class="nav nav-stacked">
- <EditCategoryTab
- @panels={{@controller.panels}}
- @selectedTab={{@controller.selectedTab}}
- @params={{@controller.parentParams}}
- @tab="general"
- />
- <EditCategoryTab
- @panels={{@controller.panels}}
- @selectedTab={{@controller.selectedTab}}
- @params={{@controller.parentParams}}
- @tab="security"
- />
- <EditCategoryTab
- @panels={{@controller.panels}}
- @selectedTab={{@controller.selectedTab}}
- @params={{@controller.parentParams}}
- @tab="settings"
- />
- <EditCategoryTab
- @panels={{@controller.panels}}
- @selectedTab={{@controller.selectedTab}}
- @params={{@controller.parentParams}}
- @tab="images"
- />
- <EditCategoryTab
- @panels={{@controller.panels}}
- @selectedTab={{@controller.selectedTab}}
- @params={{@controller.parentParams}}
- @tab="topic-template"
- />
- {{#if @controller.siteSettings.tagging_enabled}}
- <EditCategoryTab
- @panels={{@controller.panels}}
- @selectedTab={{@controller.selectedTab}}
- @params={{@controller.parentParams}}
- @tab="tags"
- />
- {{/if}}
-
- {{#if @controller.siteSettings.content_localization_enabled}}
- <EditCategoryTab
- @panels={{@controller.panels}}
- @selectedTab={{@controller.selectedTab}}
- @params={{@controller.parentParams}}
- @tab="localizations"
- />
- {{/if}}
- </ul>
- </div>
-</template>;
-
-export default EditCategoryTabsVerticalTemplate;
diff --git a/frontend/discourse/admin/templates/edit-category/tabs.gjs b/frontend/discourse/admin/templates/edit-category/tabs.gjs
index fffa9b20b9c..ad1dacbd9f8 100644
--- a/frontend/discourse/admin/templates/edit-category/tabs.gjs
+++ b/frontend/discourse/admin/templates/edit-category/tabs.gjs
@@ -2,12 +2,7 @@ import Component from "@glimmer/component";
import { concat } from "@ember/helper";
import { trustHTML } from "@ember/template";
import ChangesBanner from "discourse/admin/components/changes-banner";
-import EditCategoryGeneral from "discourse/admin/components/edit-category-general";
-import EditCategoryImages from "discourse/admin/components/edit-category-images";
import EditCategoryLocalizations from "discourse/admin/components/edit-category-localizations";
-import EditCategorySecurity from "discourse/admin/components/edit-category-security";
-import EditCategorySettings from "discourse/admin/components/edit-category-settings";
-import EditCategoryTags from "discourse/admin/components/edit-category-tags";
import EditCategoryTopicTemplate from "discourse/admin/components/edit-category-topic-template";
import UpsertCategoryAppearance from "discourse/admin/components/upsert-category/appearance";
import UpsertCategoryGeneral from "discourse/admin/components/upsert-category/general";
@@ -16,7 +11,6 @@ import UpsertCategorySecurity from "discourse/admin/components/upsert-category/s
import UpsertCategorySettings from "discourse/admin/components/upsert-category/settings";
import UpsertCategoryTags from "discourse/admin/components/upsert-category/tags";
import EditCategoryTabsHorizontal from "discourse/admin/templates/edit-category/tabs-horizontal";
-import EditCategoryTabsVertical from "discourse/admin/templates/edit-category/tabs-vertical";
import EditCategoryTypeSchemaFields from "discourse/components/edit-category-type-schema-fields";
import Form from "discourse/components/form";
import { bind } from "discourse/lib/decorators";
@@ -25,17 +19,6 @@ import { or } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";
const TAB_COMPONENTS = {
- general: EditCategoryGeneral,
- security: EditCategorySecurity,
- settings: EditCategorySettings,
- images: EditCategoryImages,
- "topic-template": EditCategoryTopicTemplate,
- tags: EditCategoryTags,
- localizations: EditCategoryLocalizations,
-};
-
-// Gated behind the enable_simplified_category_creation upcoming change
-const TAB_COMPONENTS_V2 = {
general: UpsertCategoryGeneral,
security: UpsertCategorySecurity,
settings: UpsertCategorySettings,
@@ -58,12 +41,11 @@ const UnknownCategoryType = <template>
export default class Tabs extends Component {
@bind
- componentFor(name, useSimplified) {
+ componentFor(name) {
name = name.replace("edit-category-", "");
- const components = useSimplified ? TAB_COMPONENTS_V2 : TAB_COMPONENTS;
- if (components[name]) {
- return components[name];
+ if (TAB_COMPONENTS[name]) {
+ return TAB_COMPONENTS[name];
}
// Shows additional tabs manually registered by plugins
@@ -73,7 +55,7 @@ export default class Tabs extends Component {
}
// Used to show category type specific tabs. Types may be registered by plugins.
- if (this.args.controller.model.categoryTypes[name]) {
+ if (this.args.controller.model.categoryTypes?.[name]) {
return EditCategoryTypeSchemaFields;
}
@@ -82,14 +64,10 @@ export default class Tabs extends Component {
<template>
<div class="edit-category {{if @controller.expandedMenu 'expanded-menu'}}">
- {{#if @controller.siteSettings.enable_simplified_category_creation}}
- <EditCategoryTabsHorizontal
- @controller={{@controller}}
- class="edit-category-page-header"
- />
- {{else}}
- <EditCategoryTabsVertical @controller={{@controller}} />
- {{/if}}
+ <EditCategoryTabsHorizontal
+ @controller={{@controller}}
+ class="edit-category-page-header"
+ />
<Form
@data={{@controller.formData}}
@@ -103,45 +81,23 @@ export default class Tabs extends Component {
<form.Section
class="edit-category-content edit-category-tab-{{@controller.selectedTab}}"
>
- {{#if @controller.siteSettings.enable_simplified_category_creation}}
- {{#let
- (this.componentFor
- (concat "edit-category-" @controller.selectedTab)
- @controller.siteSettings.enable_simplified_category_creation
- )
- as |Tab|
- }}
- <Tab
- @selectedTab={{@controller.selectedTab}}
- @categoryType={{@controller.selectedTab}}
- @category={{@controller.model}}
- @registerValidator={{@controller.registerValidator}}
- @registerAfterReset={{@controller.registerAfterReset}}
- @transientData={{transientData}}
- @form={{form}}
- @setSelectedTab={{@controller.setSelectedTab}}
- />
- {{/let}}
- {{else}}
- {{#each @controller.panels as |tabName|}}
- {{#let
- (this.componentFor
- tabName
- @controller.siteSettings.enable_simplified_category_creation
- )
- as |Tab|
- }}
- <Tab
- @selectedTab={{@controller.selectedTab}}
- @category={{@controller.model}}
- @registerValidator={{@controller.registerValidator}}
- @registerAfterReset={{@controller.registerAfterReset}}
- @transientData={{transientData}}
- @form={{form}}
- />
- {{/let}}
- {{/each}}
- {{/if}}
+ {{#let
+ (this.componentFor
+ (concat "edit-category-" @controller.selectedTab)
+ )
+ as |Tab|
+ }}
+ <Tab
+ @selectedTab={{@controller.selectedTab}}
+ @categoryType={{@controller.selectedTab}}
+ @category={{@controller.model}}
+ @registerValidator={{@controller.registerValidator}}
+ @registerAfterReset={{@controller.registerAfterReset}}
+ @transientData={{transientData}}
+ @form={{form}}
+ @setSelectedTab={{@controller.setSelectedTab}}
+ />
+ {{/let}}
</form.Section>
{{#if @controller.showDeleteReason}}
@@ -150,65 +106,40 @@ export default class Tabs extends Component {
</form.Alert>
{{/if}}
- {{#if @controller.siteSettings.enable_simplified_category_creation}}
- {{#if (or @controller.model.can_delete @controller.model.id)}}
- <form.Actions class="edit-category-footer">
- {{#if @controller.model.can_delete}}
- <form.Button
- @action={{@controller.deleteCategory}}
- @icon="trash-can"
- @label="category.delete"
- class="btn-danger btn-small"
- />
- {{else}}
- <form.Button
- @action={{@controller.toggleDeleteTooltip}}
- @icon="circle-question"
- @label="category.delete"
- class="btn-default btn-small"
- />
- {{/if}}
- </form.Actions>
- {{/if}}
- {{else}}
+ {{#if (or @controller.model.can_delete @controller.model.id)}}
<form.Actions class="edit-category-footer">
- <form.Submit @label={{@controller.saveLabel}} id="save-category" />
-
{{#if @controller.model.can_delete}}
<form.Button
- @disabled={{@controller.deleteDisabled}}
@action={{@controller.deleteCategory}}
@icon="trash-can"
@label="category.delete"
- class="btn-danger"
+ class="btn-danger btn-small"
/>
- {{else if @controller.model.id}}
+ {{else}}
<form.Button
- @disabled={{@controller.deleteDisabled}}
@action={{@controller.toggleDeleteTooltip}}
@icon="circle-question"
@label="category.delete"
- class="btn-default"
+ class="btn-default btn-small"
/>
{{/if}}
</form.Actions>
{{/if}}
</Form>
- {{#if @controller.siteSettings.enable_simplified_category_creation}}
- {{#if (or @controller.model.isNew @controller.isFormDirty)}}
- <ChangesBanner
- @bannerLabel={{i18n "category.unsaved_changes"}}
- @saveLabel={{if
- @controller.model.id
- (i18n "category.save")
- (i18n "category.create_category")
- }}
- @discardLabel={{i18n "form_kit.reset"}}
- @save={{@controller.formApi.submit}}
- @discard={{@controller.formApi.reset}}
- />
- {{/if}}
+ {{#if (or @controller.model.isNew @controller.isFormDirty)}}
+ <ChangesBanner
+ @bannerLabel={{i18n "category.unsaved_changes"}}
+ @saveLabel={{if
+ @controller.model.id
+ (i18n "category.save")
+ (i18n "category.create_category")
+ }}
+ @saveButtonId="save-category"
+ @discardLabel={{i18n "form_kit.reset"}}
+ @save={{@controller.formApi.submit}}
+ @discard={{@controller.formApi.reset}}
+ />
{{/if}}
</div>
</template>
diff --git a/frontend/discourse/app/connectors/category-custom-settings/nested-replies-settings-upsert.gjs b/frontend/discourse/app/connectors/category-custom-settings/nested-replies-settings-upsert.gjs
index 8b06115a4d1..b9dcabca755 100644
--- a/frontend/discourse/app/connectors/category-custom-settings/nested-replies-settings-upsert.gjs
+++ b/frontend/discourse/app/connectors/category-custom-settings/nested-replies-settings-upsert.gjs
@@ -4,10 +4,7 @@ import { i18n } from "discourse-i18n";
export default class NestedRepliesSettingsUpsert extends Component {
static shouldRender(args, context) {
- return (
- context.siteSettings.nested_replies_enabled &&
- context.siteSettings.enable_simplified_category_creation
- );
+ return context.siteSettings.nested_replies_enabled;
}
get enabled() {
diff --git a/frontend/discourse/app/connectors/category-custom-settings/nested-replies-settings.gjs b/frontend/discourse/app/connectors/category-custom-settings/nested-replies-settings.gjs
deleted file mode 100644
index e768acec0a3..00000000000
--- a/frontend/discourse/app/connectors/category-custom-settings/nested-replies-settings.gjs
+++ /dev/null
@@ -1,27 +0,0 @@
-import Component from "@glimmer/component";
-import { Input } from "@ember/component";
-import { i18n } from "discourse-i18n";
-
-export default class NestedRepliesSettings extends Component {
- static shouldRender(args, context) {
- return (
- context.siteSettings.nested_replies_enabled &&
- !context.siteSettings.enable_simplified_category_creation
- );
- }
-
- <template>
- <section class="field">
- <h3>{{i18n "nested_replies.nested_view"}}</h3>
- <div class="enable-nested-replies-default">
- <label class="checkbox-label">
- <Input
- @type="checkbox"
- @checked={{@outletArgs.category.category_setting.nested_replies_default}}
- />
- {{i18n "nested_replies.category_settings.default_nested_view"}}
- </label>
- </div>
- </section>
- </template>
-}
diff --git a/frontend/discourse/app/lib/on-before-category-types-change.js b/frontend/discourse/app/lib/on-before-category-types-change.js
index 354bea35298..8e27eeaf6c0 100644
--- a/frontend/discourse/app/lib/on-before-category-types-change.js
+++ b/frontend/discourse/app/lib/on-before-category-types-change.js
@@ -15,9 +15,8 @@ const callbacks = [];
/**
* Registers a callback to run when the user changes category type selection in the
- * simplified category editor (upsert "general" tab). When `enable_simplified_category_creation` is
- * on, the callback runs in registration order. If any callback’s resolved value is falsy, the new
- * selection is not applied.
+ * category editor's General tab. Callbacks run in registration order. If any
+ * callback’s resolved value is falsy, the new selection is not applied.
*
* The callback may be `async` (e.g. to show a modal and await the result). Return a **truthy**
* value to allow the change, or a **falsy** value to block it. On thrown errors, the change is
diff --git a/frontend/discourse/app/lib/plugin-api.gjs b/frontend/discourse/app/lib/plugin-api.gjs
index 887a52b265e..11580208537 100644
--- a/frontend/discourse/app/lib/plugin-api.gjs
+++ b/frontend/discourse/app/lib/plugin-api.gjs
@@ -3338,9 +3338,6 @@ class _PluginApi {
/**
* Registers a custom tab for the category edit page.
- * Only available when the `enable_simplified_category_creation`
- * site setting is enabled, this will not work for the legacy
- * category edit page.
*
* ```
* api.registerEditCategoryTab({
@@ -3364,8 +3361,7 @@ class _PluginApi {
/**
* Register a callback that runs when the user changes category type selection in the
- * **simplified** category editor (General tab) when `enable_simplified_category_creation` is
- * enabled. It does not run on the legacy category editor.
+ * category editor's General tab.
*
* Callbacks run in order. Each may be `async`. The change applies only if every callback
* returns a **truthy** value; a **falsy** return blocks the new selection. If a callback
diff --git a/frontend/discourse/app/services/category-type-chooser.js b/frontend/discourse/app/services/category-type-chooser.js
index 32df5cd4c25..00e183687aa 100644
--- a/frontend/discourse/app/services/category-type-chooser.js
+++ b/frontend/discourse/app/services/category-type-chooser.js
@@ -2,16 +2,11 @@ import Service, { service } from "@ember/service";
export default class CategoryTypeChooser extends Service {
@service router;
- @service siteSettings;
_selection = null;
_setupComplete = false;
_allTypes = null;
- get isEnabled() {
- return this.siteSettings.enable_simplified_category_creation;
- }
-
get hasCompletedSetup() {
return this._selection !== null || this._setupComplete;
}
@@ -47,15 +42,6 @@ export default class CategoryTypeChooser extends Service {
}
createCategory() {
- if (this.isEnabled) {
- this.router.transitionTo("newCategory.setup");
- return;
- }
-
- if (this.router.currentRouteName === "newCategory.index") {
- this.router.refresh();
- } else {
- this.router.transitionTo("newCategory");
- }
+ this.router.transitionTo("newCategory.setup");
}
}
diff --git a/frontend/discourse/app/ui-kit/helpers/d-category-badge.js b/frontend/discourse/app/ui-kit/helpers/d-category-badge.js
index 610fb28e251..28808784f61 100644
--- a/frontend/discourse/app/ui-kit/helpers/d-category-badge.js
+++ b/frontend/discourse/app/ui-kit/helpers/d-category-badge.js
@@ -6,6 +6,10 @@ export default function dCategoryBadge(cat, options = {}) {
hideParent: options.hideParent,
allowUncategorized: options.allowUncategorized,
categoryStyle: options.categoryStyle,
+ styleType: options.styleType,
+ icon: options.icon,
+ emoji: options.emoji,
+ previewColor: options.previewColor,
link: isPresent(options.link) ? options.link : false,
});
}
diff --git a/frontend/discourse/tests/acceptance/category-edit-security-test.js b/frontend/discourse/tests/acceptance/category-edit-security-test.js
index 37f88c2b42c..e91acf6d0b0 100644
--- a/frontend/discourse/tests/acceptance/category-edit-security-test.js
+++ b/frontend/discourse/tests/acceptance/category-edit-security-test.js
@@ -1,7 +1,7 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
+import formKit from "discourse/tests/helpers/form-kit-helper";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
-import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n";
acceptance("Category Edit - Security", function (needs) {
@@ -15,23 +15,19 @@ acceptance("Category Edit - Security", function (needs) {
});
test("removing a permission", async function (assert) {
- const availableGroups = selectKit(".available-groups");
-
await visit("/c/bug/edit/security");
- await availableGroups.expand();
- assert.false(
- availableGroups.rowByValue("everyone").exists(),
- "everyone is already used and is not in the available groups"
- );
+ assert
+ .dom(".available-groups option[value='0']")
+ .doesNotExist(
+ "everyone is already used and is not in the available groups"
+ );
await click(".row-body .remove-permission");
- await availableGroups.expand();
- assert.true(
- availableGroups.rowByValue("everyone").exists(),
- "everyone has been removed and appears in the available groups"
- );
+ assert
+ .dom(".available-groups option[value='0']")
+ .exists("everyone has been removed and appears in the available groups");
assert
.dom(".row-empty")
.hasText(
@@ -41,12 +37,9 @@ acceptance("Category Edit - Security", function (needs) {
});
test("adding a permission", async function (assert) {
- const availableGroups = selectKit(".available-groups");
-
await visit("/c/bug/edit/security");
- await availableGroups.expand();
- await availableGroups.selectRowByValue("staff");
+ await formKit().field("security_add_group_id").select("3");
assert.dom("[data-group-name='staff'] .group-name-link").hasText("staff");
assert
@@ -58,8 +51,6 @@ acceptance("Category Edit - Security", function (needs) {
});
test("adding a previously removed permission", async function (assert) {
- const availableGroups = selectKit(".available-groups");
-
await visit("/c/bug/edit/security");
await click(".row-body .remove-permission");
@@ -67,8 +58,7 @@ acceptance("Category Edit - Security", function (needs) {
.dom(".row-body")
.doesNotExist("removes the permission from the list");
- await availableGroups.expand();
- await availableGroups.selectRowByValue("everyone");
+ await formKit().field("security_add_group_id").select("0");
assert.dom(".row-body").exists("adds back the permission to the list");
@@ -81,8 +71,6 @@ acceptance("Category Edit - Security", function (needs) {
});
test("editing permissions", async function (assert) {
- const availableGroups = selectKit(".available-groups");
-
await visit("/c/bug/edit/security");
assert
@@ -91,8 +79,7 @@ acceptance("Category Edit - Security", function (needs) {
)
.exists({ count: 2 }, "everyone has full permissions by default");
- await availableGroups.expand();
- await availableGroups.selectRowByValue("staff");
+ await formKit().field("security_add_group_id").select("3");
assert
.dom(
diff --git a/frontend/discourse/tests/acceptance/category-edit-settings-test.js b/frontend/discourse/tests/acceptance/category-edit-settings-test.js
index bdaf37ae67f..6367a22485e 100644
--- a/frontend/discourse/tests/acceptance/category-edit-settings-test.js
+++ b/frontend/discourse/tests/acceptance/category-edit-settings-test.js
@@ -26,7 +26,7 @@ acceptance("Category Edit - Settings", function (needs) {
});
test("values updating while switching the category", async function (assert) {
- await visit("/c/uncategorized/edit/settings");
+ await visit("/c/uncategorized/edit/moderation");
assert
.dom("input#category-default-slow-mode")
diff --git a/frontend/discourse/tests/acceptance/category-edit-test.js b/frontend/discourse/tests/acceptance/category-edit-test.js
index 800053e7b40..90da3efbe1f 100644
--- a/frontend/discourse/tests/acceptance/category-edit-test.js
+++ b/frontend/discourse/tests/acceptance/category-edit-test.js
@@ -3,10 +3,19 @@ import { test } from "qunit";
import sinon from "sinon";
import DiscourseURL from "discourse/lib/url";
import pretender from "discourse/tests/helpers/create-pretender";
+import formKit from "discourse/tests/helpers/form-kit-helper";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { i18n } from "discourse-i18n";
+function latestCategorySavePayload() {
+ const request = pretender.handledRequests.findLast(
+ ({ method, requestBody }) => method === "PUT" && requestBody
+ );
+
+ return JSON.parse(request.requestBody);
+}
+
acceptance("Category Edit", function (needs) {
needs.user();
needs.settings({ email_in: true, tagging_enabled: true });
@@ -24,12 +33,14 @@ acceptance("Category Edit", function (needs) {
assert.dom(".category-breadcrumb .badge-category").hasText("bug");
assert.dom(".badge-category__wrapper .badge-category").hasText("bug");
await fillIn("input.category-name", "testing");
- assert.dom(".category-style .badge-category__name").hasText("testing");
+ assert
+ .dom(".edit-category-tab-general .badge-category__name")
+ .hasText("testing");
- await click(".edit-category-topic-template a");
+ await visit("/c/bug/edit/topic-template");
await fillIn(".d-editor-input", "this is the new topic template");
- await click("#save-category");
+ await click(".admin-changes-banner .btn-primary");
assert.strictEqual(
currentURL(),
"/c/bug/edit/topic-template",
@@ -37,11 +48,9 @@ acceptance("Category Edit", function (needs) {
);
await visit("/c/bug/edit/settings");
- const searchPriorityChooser = selectKit("#category-search-priority");
- await searchPriorityChooser.expand();
- await searchPriorityChooser.selectRowByValue(1);
+ await formKit().field("search_priority").select(1);
- await click("#save-category");
+ await click(".admin-changes-banner .btn-primary");
assert.strictEqual(
currentURL(),
"/c/bug/edit/settings",
@@ -60,69 +69,56 @@ acceptance("Category Edit", function (needs) {
test("Editing required tag groups", async function (assert) {
await visit("/c/bug/edit/tags");
- assert.dom(".minimum-required-tags").exists();
+ assert.dom("#category-minimum-tags").exists();
- assert.dom(".required-tag-groups").exists();
- assert.dom(".required-tag-group-row").doesNotExist();
+ assert.dom(".form-kit__collection").doesNotExist();
await click(".add-required-tag-group");
- assert.dom(".required-tag-group-row").exists({ count: 1 });
+ assert.dom(".form-kit__collection .form-kit__row").exists({ count: 1 });
await click(".add-required-tag-group");
- assert.dom(".required-tag-group-row").exists({ count: 2 });
+ assert.dom(".form-kit__collection .form-kit__row").exists({ count: 2 });
await click(".delete-required-tag-group");
- assert.dom(".required-tag-group-row").exists({ count: 1 });
+ assert.dom(".form-kit__collection .form-kit__row").exists({ count: 1 });
const tagGroupChooser = selectKit(
- ".required-tag-group-row .tag-group-chooser"
+ ".form-kit__collection .form-kit__row .tag-group-chooser"
);
await tagGroupChooser.expand();
await tagGroupChooser.selectRowByValue("TagGroup1");
- await click("#save-category");
- assert.dom(".required-tag-group-row").exists({ count: 1 });
+ await click(".admin-changes-banner .btn-primary");
+ assert.dom(".form-kit__collection .form-kit__row").exists({ count: 1 });
await click(".delete-required-tag-group");
- assert.dom(".required-tag-group-row").doesNotExist();
+ assert.dom(".form-kit__collection").doesNotExist();
- await click("#save-category");
- assert.dom(".required-tag-group-row").doesNotExist();
+ assert
+ .dom(".admin-changes-banner")
+ .exists("save banner stays visible when collection is emptied");
});
test("Editing allowed tags and tag groups", async function (assert) {
await visit("/c/bug/edit/tags");
- const allowedTagChooser = selectKit("#category-allowed-tags");
- await allowedTagChooser.expand();
- await allowedTagChooser.selectRowByName("monkey");
-
- await allowedTagChooser.collapse();
- const allowedTagGroupChooser = selectKit("#category-allowed-tag-groups");
- await allowedTagGroupChooser.expand();
- await allowedTagGroupChooser.selectRowByValue("TagGroup1");
+ await formKit().field("allowed_tags").selectByName("monkey");
+ await formKit().control("#category-allowed-tag-groups").select("TagGroup1");
- await click("#save-category");
+ await click(".admin-changes-banner .btn-primary");
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
+ const payload = latestCategorySavePayload();
assert.deepEqual(payload.allowed_tags, ["monkey"]);
assert.deepEqual(payload.allowed_tag_groups, ["TagGroup1"]);
- await allowedTagChooser.expand();
- await allowedTagChooser.deselectItemByName("monkey");
-
- await allowedTagGroupChooser.expand();
- await allowedTagGroupChooser.deselectItemByValue("TagGroup1");
+ await formKit().field("allowed_tags").deselectByName("monkey");
+ await formKit()
+ .control("#category-allowed-tag-groups")
+ .deselectByValue("TagGroup1");
- await click("#save-category");
+ await click(".admin-changes-banner .btn-primary");
- const removePayload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
+ const removePayload = latestCategorySavePayload();
assert.deepEqual(removePayload.allowed_tags, []);
assert.deepEqual(removePayload.allowed_tag_groups, []);
});
@@ -138,7 +134,7 @@ acceptance("Category Edit", function (needs) {
await categoryChooser.expand();
const names = [...categoryChooser.rows()].map((row) => row.dataset.name);
- assert.true(names.includes("(no category)"));
+ assert.true(Boolean(categoryChooser.clearButton()));
assert.false(names.includes("Uncategorized"));
});
@@ -153,7 +149,7 @@ acceptance("Category Edit", function (needs) {
await categoryChooser.expand();
const names = [...categoryChooser.rows()].map((row) => row.dataset.name);
- assert.true(names.includes("(no category)"));
+ assert.true(Boolean(categoryChooser.clearButton()));
assert.false(names.includes("Uncategorized"));
});
@@ -178,8 +174,10 @@ acceptance("Category Edit", function (needs) {
test("Error Saving", async function (assert) {
await visit("/c/bug/edit/settings");
- await fillIn(".email-in", "[email protected]");
- await click("#save-category");
+
+ // eslint-disable-next-line ember/require-valid-css-selector-in-test-helpers -- FormKit fillIn(value), not Ember fillIn(selector)
+ await formKit().field("email_in").fillIn("[email protected]");
+ await click(".admin-changes-banner .btn-primary");
assert.dom(".dialog-body").hasText(
i18n("generic_error_with_reason", {
@@ -192,13 +190,15 @@ acceptance("Category Edit", function (needs) {
});
test("Nested subcategory error when saving", async function (assert) {
+ this.siteSettings.max_category_nesting = 3;
+
await visit("/c/bug/edit");
const categoryChooser = selectKit(".category-chooser.single-select");
await categoryChooser.expand();
await categoryChooser.selectRowByValue(1002);
- await click("#save-category");
+ await click(".admin-changes-banner .btn-primary");
assert.dom(".dialog-body").hasText(
i18n("generic_error_with_reason", {
@@ -219,16 +219,16 @@ acceptance("Category Edit", function (needs) {
});
test("Subcategory list settings", async function (assert) {
- await visit("/c/bug/edit/settings");
+ await visit("/c/bug/edit/images");
assert
- .dom(".subcategory-list-style-field")
+ .dom("[data-name='subcategory_list_style']")
.doesNotExist("subcategory list style isn't visible by default");
- await click(".show-subcategory-list-field input[type=checkbox]");
+ await formKit().field("show_subcategory_list").toggle();
assert
- .dom(".subcategory-list-style-field")
+ .dom("[data-name='subcategory_list_style']")
.exists(
"subcategory list style is shown if show subcategory list is checked"
);
@@ -241,13 +241,13 @@ acceptance("Category Edit", function (needs) {
await categoryChooser.expand();
await categoryChooser.selectRowByValue(3);
- await visit("/c/bug/edit/settings");
+ await visit("/c/bug/edit/images");
assert
- .dom(".show-subcategory-list-field")
+ .dom("[data-name='show_subcategory_list']")
.doesNotExist("show subcategory list isn't visible for child categories");
assert
- .dom(".subcategory-list-style-field")
+ .dom("[data-name='subcategory_list_style']")
.doesNotExist(
"subcategory list style isn't visible for child categories"
);
@@ -258,7 +258,6 @@ acceptance(
"Category Edit - parent category permission inheritance",
function (needs) {
needs.user();
- needs.settings({ enable_simplified_category_creation: true });
needs.pretender((server, helper) => {
// Sub-category with only moderator permissions
server.get("/c/restricted-group/find_by_slug.json", () =>
@@ -440,10 +439,7 @@ acceptance(
await click(".admin-changes-banner .btn-primary");
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
+ const payload = latestCategorySavePayload();
assert.deepEqual(payload.permissions, { moderators: 1 });
});
@@ -456,10 +452,7 @@ acceptance(
await click(".admin-changes-banner .btn-primary");
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
+ const payload = latestCategorySavePayload();
assert.deepEqual(payload.permissions, { custom_group: 1 });
});
@@ -472,10 +465,7 @@ acceptance(
await click(".admin-changes-banner .btn-primary");
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
+ const payload = latestCategorySavePayload();
assert.deepEqual(payload.permissions, { moderators: 1 });
});
@@ -491,10 +481,7 @@ acceptance(
await click(".admin-changes-banner .btn-primary");
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
+ const payload = latestCategorySavePayload();
assert.deepEqual(payload.permissions, { moderators: 1 });
});
@@ -507,10 +494,7 @@ acceptance(
await click(".admin-changes-banner .btn-primary");
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
+ const payload = latestCategorySavePayload();
assert.deepEqual(payload.permissions, { everyone: 3, staff: 1 });
});
@@ -523,10 +507,7 @@ acceptance(
await click(".admin-changes-banner .btn-primary");
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
+ const payload = latestCategorySavePayload();
assert.deepEqual(payload.permissions, { custom_group: 1 });
});
}
diff --git a/frontend/discourse/tests/acceptance/category-new-test.js b/frontend/discourse/tests/acceptance/category-new-test.js
index ae727b4d952..e66cf3c9dcc 100644
--- a/frontend/discourse/tests/acceptance/category-new-test.js
+++ b/frontend/discourse/tests/acceptance/category-new-test.js
@@ -52,21 +52,21 @@ acceptance("Category New", function (needs) {
await fillIn("input.category-name", "testing");
assert.dom(".badge-category").hasText("testing");
- await click(".edit-category-nav .edit-category-topic-template a");
+ if (!document.querySelector(".edit-category-topic-template")) {
+ await click(".category-show-advanced-tabs-toggle");
+ }
+
assert
- .dom(".edit-category-tab-topic-template.active")
+ .dom(".edit-category-topic-template")
.exists("it can switch to the topic template tab");
- await click(".edit-category-nav .edit-category-tags a");
- await click("button.add-required-tag-group");
+ assert.dom(".edit-category-tags").exists("it can switch to the tags tab");
+ await click(".edit-category-tags a");
+ await click(".add-required-tag-group");
- const tagSelector = selectKit(
- ".required-tag-group-row .select-kit.tag-group-chooser"
- );
- await tagSelector.expand();
- await tagSelector.selectRowByValue("TagGroup1");
+ await formKit().field("required_tag_groups.0.name").select("TagGroup1");
- await click("#save-category");
+ await click(".admin-changes-banner .btn-primary");
assert.strictEqual(
currentURL(),
@@ -74,13 +74,15 @@ acceptance("Category New", function (needs) {
"it transitions to the category edit route"
);
- await click(".edit-category-nav .edit-category-tags a");
+ await visit("/c/testing/edit/tags");
- assert
- .dom(".required-tag-group-row .select-kit-header[data-value='TagGroup1']")
- .exists("shows saved required tag group");
+ assert.strictEqual(
+ formKit().field("required_tag_groups.0.name").value(),
+ "TagGroup1",
+ "shows saved required tag group"
+ );
- assert.dom(".edit-category-title h2").hasText(
+ assert.dom(".d-page-header__title").hasText(
i18n("category.edit_dialog_title", {
categoryName: "testing",
})
@@ -93,16 +95,11 @@ acceptance("Category New", function (needs) {
await click(".edit-category-settings a");
assert
- .dom("#category-search-priority")
+ .form()
+ .field("search_priority")
.exists("it can switch to the settings tab");
sinon.stub(DiscourseURL, "routeTo");
-
- await click(".category-back");
- assert.true(
- DiscourseURL.routeTo.calledWith("/c/testing/11"),
- "back routing works"
- );
});
test("Specifying a parent category", async function (assert) {
@@ -123,9 +120,6 @@ acceptance("Category New", function (needs) {
acceptance("Category type setup page", function (needs) {
needs.user({ admin: true, can_create_category: true });
- needs.settings({
- enable_simplified_category_creation: true,
- });
needs.pretender((server, helper) => {
server.get("/categories/types", () => {
return helper.response(200, {
@@ -195,6 +189,8 @@ acceptance("Category text color", function (needs) {
test("Category text color is set based on contrast", async function (assert) {
await visit("/new-category");
+ await click(".category-show-advanced-tabs-toggle");
+ await click(".edit-category-images a");
assert.strictEqual(
formKit().field("text_color").value(),
@@ -202,8 +198,10 @@ acceptance("Category text color", function (needs) {
"has the default text color"
);
+ await click(".edit-category-general a");
await fillIn("input.category-name", "testing");
await formKit().field("color").fillIn("EEEEEE");
+ await click(".edit-category-images a");
assert.strictEqual(
formKit().field("text_color").value(),
@@ -218,9 +216,10 @@ acceptance("New category preview", function (needs) {
test("Category badge color appears and updates", async function (assert) {
await visit("/new-category");
+ await click(".form-kit__control-radio[value='square']");
let previewBadgeColor = document
- .querySelector(".category-style .badge-category")
+ .querySelector(".edit-category-tab-general .badge-category")
.style.getPropertyValue("--category-badge-color")
.trim();
@@ -229,7 +228,7 @@ acceptance("New category preview", function (needs) {
await formKit().field("color").fillIn("FF00FF");
previewBadgeColor = document
- .querySelector(".category-style .badge-category")
+ .querySelector(".edit-category-tab-general .badge-category")
.style.getPropertyValue("--category-badge-color")
.trim();
diff --git a/frontend/discourse/tests/acceptance/edit-category-plugin-api-test.gjs b/frontend/discourse/tests/acceptance/edit-category-plugin-api-test.gjs
index b07cdf85d58..f17557754b0 100644
--- a/frontend/discourse/tests/acceptance/edit-category-plugin-api-test.gjs
+++ b/frontend/discourse/tests/acceptance/edit-category-plugin-api-test.gjs
@@ -13,7 +13,6 @@ import { eq } from "discourse/truth-helpers";
acceptance("Edit Category - Plugin Tab API", function (needs) {
needs.user();
- needs.settings({ enable_simplified_category_creation: true });
test("registerEditCategoryTab adds a tab that renders", async function (assert) {
withPluginApi((api) => {
diff --git a/frontend/discourse/tests/acceptance/edit-category-topic-template-test.js b/frontend/discourse/tests/acceptance/edit-category-topic-template-test.js
index 3d319c3ef7f..fbb798b5ceb 100644
--- a/frontend/discourse/tests/acceptance/edit-category-topic-template-test.js
+++ b/frontend/discourse/tests/acceptance/edit-category-topic-template-test.js
@@ -3,130 +3,24 @@ import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
-acceptance(
- "Admin - Edit category topic template with simplified category creation",
- function (needs) {
- let putData;
-
- needs.user({ admin: true });
- needs.settings({
- enable_simplified_category_creation: true,
- enable_form_templates: true,
- });
-
- needs.pretender((server, helper) => {
- server.get("/form-templates.json", () => {
- return helper.response(200, {
- form_templates: [
- { id: 1, name: "Template 1" },
- { id: 2, name: "Template 2" },
- ],
- });
- });
-
- server.get("/c/bug/find_by_slug.json", () => {
- return helper.response(200, {
- category: {
- id: 11,
- name: "bug",
- slug: "bug",
- can_edit: true,
- category_type_site_settings: {},
- permissions: [],
- },
- });
- });
-
- server.put("/categories/:id", (request) => {
- putData = JSON.parse(request.requestBody);
- return helper.response(200, {
- category: {
- id: request.params.id,
- name: "bug",
- can_edit: true,
- category_type_site_settings: {},
- ...putData,
- permissions: [],
- },
- });
- });
- });
-
- test("Changing topic template shows the unsaved changes banner", async function (assert) {
- putData = null;
- await visit("/c/bug/edit/topic-template");
-
- await fillIn(".d-editor-input", "New topic template content");
-
- assert
- .dom(".admin-changes-banner")
- .exists("banner is shown after changing topic template");
-
- await click(".admin-changes-banner .btn-primary");
-
- assert.strictEqual(
- putData.topic_template,
- "New topic template content",
- "it sends the updated topic template"
- );
- });
-
- test("Changing topic title placeholder saves correctly", async function (assert) {
- putData = null;
- await visit("/c/bug/edit/topic-template");
-
- await fillIn("#category-topic-title-placeholder", "Enter a bug title");
-
- assert
- .dom(".admin-changes-banner")
- .exists("banner is shown after changing topic title placeholder");
-
- await click(".admin-changes-banner .btn-primary");
-
- assert.strictEqual(
- putData.topic_title_placeholder,
- "Enter a bug title",
- "it sends the updated topic title placeholder"
- );
- });
-
- test("Selecting a form template shows the unsaved changes banner", async function (assert) {
- putData = null;
- await visit("/c/bug/edit/topic-template");
-
- await click(".toggle-template-type");
-
- const formTemplateChooser = selectKit(".form-template-chooser");
- await formTemplateChooser.expand();
- await formTemplateChooser.selectRowByValue(1);
-
- assert
- .dom(".admin-changes-banner")
- .exists("banner is shown after selecting a form template");
-
- await click(".admin-changes-banner .btn-primary");
-
- assert.deepEqual(
- putData.form_template_ids,
- [1],
- "it sends the updated form template ids"
- );
- assert
- .dom(".admin-changes-banner")
- .doesNotExist("banner is gone after saving");
- });
- }
-);
-
-acceptance("Admin - Legacy edit category topic template", function (needs) {
+acceptance("Admin - Edit category topic template", function (needs) {
let putData;
needs.user({ admin: true });
needs.settings({
- enable_simplified_category_creation: false,
+ enable_form_templates: true,
});
needs.pretender((server, helper) => {
+ server.get("/form-templates.json", () => {
+ return helper.response(200, {
+ form_templates: [
+ { id: 1, name: "Template 1" },
+ { id: 2, name: "Template 2" },
+ ],
+ });
+ });
+
server.get("/c/bug/find_by_slug.json", () => {
return helper.response(200, {
category: {
@@ -134,8 +28,6 @@ acceptance("Admin - Legacy edit category topic template", function (needs) {
name: "bug",
slug: "bug",
can_edit: true,
- topic_template: "Existing template content",
- topic_title_placeholder: "Existing placeholder",
category_type_site_settings: {},
permissions: [],
},
@@ -157,25 +49,22 @@ acceptance("Admin - Legacy edit category topic template", function (needs) {
});
});
- test("Changing topic template saves correctly", async function (assert) {
+ test("Changing topic template shows the unsaved changes banner", async function (assert) {
putData = null;
await visit("/c/bug/edit/topic-template");
- assert
- .dom(".d-editor-input")
- .hasValue(
- "Existing template content",
- "it loads the existing template content"
- );
+ await fillIn(".d-editor-input", "New topic template content");
- await fillIn(".d-editor-input", "Legacy flow template content");
+ assert
+ .dom(".admin-changes-banner")
+ .exists("banner is shown after changing topic template");
- await click("#save-category");
+ await click(".admin-changes-banner .btn-primary");
assert.strictEqual(
putData.topic_template,
- "Legacy flow template content",
- "it sends the updated topic template in legacy flow"
+ "New topic template content",
+ "it sends the updated topic template"
);
});
@@ -183,21 +72,44 @@ acceptance("Admin - Legacy edit category topic template", function (needs) {
putData = null;
await visit("/c/bug/edit/topic-template");
- assert
- .dom("#category-topic-title-placeholder")
- .hasValue(
- "Existing placeholder",
- "it loads the existing topic title placeholder"
- );
+ await fillIn("#category-topic-title-placeholder", "Enter a bug title");
- await fillIn("#category-topic-title-placeholder", "Legacy placeholder");
+ assert
+ .dom(".admin-changes-banner")
+ .exists("banner is shown after changing topic title placeholder");
- await click("#save-category");
+ await click(".admin-changes-banner .btn-primary");
assert.strictEqual(
putData.topic_title_placeholder,
- "Legacy placeholder",
- "it sends the updated topic title placeholder in legacy flow"
+ "Enter a bug title",
+ "it sends the updated topic title placeholder"
);
});
+
+ test("Selecting a form template shows the unsaved changes banner", async function (assert) {
+ putData = null;
+ await visit("/c/bug/edit/topic-template");
+
+ await click(".toggle-template-type");
+
+ const formTemplateChooser = selectKit(".form-template-chooser");
+ await formTemplateChooser.expand();
+ await formTemplateChooser.selectRowByValue(1);
+
+ assert
+ .dom(".admin-changes-banner")
+ .exists("banner is shown after selecting a form template");
+
+ await click(".admin-changes-banner .btn-primary");
+
+ assert.deepEqual(
+ putData.form_template_ids,
+ [1],
+ "it sends the updated form template ids"
+ );
+ assert
+ .dom(".admin-changes-banner")
+ .doesNotExist("banner is gone after saving");
+ });
});
diff --git a/frontend/discourse/tests/fixtures/category-fixtures.js b/frontend/discourse/tests/fixtures/category-fixtures.js
index d7179c553d4..66ea1d2509a 100644
--- a/frontend/discourse/tests/fixtures/category-fixtures.js
+++ b/frontend/discourse/tests/fixtures/category-fixtures.js
@@ -32,6 +32,7 @@ const categoryFixtures = {
],
auto_close_hours: null,
auto_close_based_on_last_post: false,
+ search_priority: 0,
group_permissions: [
{ permission_type: 1, group_name: "everyone", group_id: 0 },
],
diff --git a/frontend/discourse/tests/helpers/create-pretender.js b/frontend/discourse/tests/helpers/create-pretender.js
index 6f61244b4d1..3140699dac0 100644
--- a/frontend/discourse/tests/helpers/create-pretender.js
+++ b/frontend/discourse/tests/helpers/create-pretender.js
@@ -591,6 +591,41 @@ export function applyDefaultHandlers() {
response(fixturesByUrl["/c/2481/show.json"])
);
+ pretender.get("/c/:category_id/show.json", (request) => {
+ const fixture = fixturesByUrl[request.url];
+
+ if (fixture) {
+ return response(fixture);
+ }
+
+ const categoryId = parseInt(request.params.category_id, 10);
+ const siteCategory = fixturesByUrl["site.json"].site.categories.find(
+ (category) => category.id === categoryId
+ );
+
+ if (!siteCategory) {
+ return response(404, { errors: ["category not found"] });
+ }
+
+ const category = cloneJSON(siteCategory);
+
+ category.available_groups ||= ["admins", "everyone", "moderators", "staff"];
+ category.group_permissions ||= [
+ { permission_type: 1, group_name: "everyone", group_id: 0 },
+ ];
+ category.custom_fields ||= {};
+ category.category_types ||= {
+ discussion: {
+ id: "discussion",
+ name: "Discussion",
+ configuration_schema: {},
+ },
+ };
+ category.available_category_types ||= [];
+
+ return response({ category });
+ });
+
pretender.put("/categories/:category_id", (request) => {
const category = JSON.parse(request.requestBody);
category.id = parseInt(request.params.category_id, 10);
@@ -629,6 +664,25 @@ export function applyDefaultHandlers() {
response(fixturesByUrl["/c/11/show.json"])
);
+ pretender.get("/categories/types", () =>
+ response({
+ types: [
+ {
+ id: "discussion",
+ name: "Discussion",
+ title: "discussion",
+ icon: "comments",
+ description: "General discussion",
+ configuration_schema: {},
+ available: true,
+ },
+ ],
+ counts: {
+ discussion: 1,
+ },
+ })
+ );
+
pretender.get("/categories/find", () => {
return response({
categories: fixturesByUrl["site.json"].site.categories,
diff --git a/frontend/discourse/tests/helpers/form-kit-assertions.js b/frontend/discourse/tests/helpers/form-kit-assertions.js
index cba34e7e5fd..1afdf4901d8 100644
--- a/frontend/discourse/tests/helpers/form-kit-assertions.js
+++ b/frontend/discourse/tests/helpers/form-kit-assertions.js
@@ -42,10 +42,32 @@ class FieldHelper {
this.context = context;
}
+ get resolvedControlType() {
+ const type = this.element.dataset.controlType;
+
+ if (type !== "custom") {
+ return type;
+ }
+
+ if (this.element.querySelector(".form-kit__control-custom .multi-select")) {
+ return "multi-select";
+ }
+
+ if (
+ this.element.querySelector(
+ ".form-kit__control-custom .tag-chooser, .form-kit__control-custom .tag-group-chooser, .form-kit__control-tag-chooser"
+ )
+ ) {
+ return "tag-chooser";
+ }
+
+ return type;
+ }
+
get value() {
this.context.dom(this.element).exists(`field '${this.name}' exists`);
- switch (this.element.dataset.controlType) {
+ switch (this.resolvedControlType) {
case "image": {
return this.element
.querySelector(".form-kit__control-image a.lightbox")
@@ -112,6 +134,9 @@ class FieldHelper {
`Calendar is a complex type, value can't be check from UI components`
);
}
+ case "tag-chooser": {
+ return this.element.querySelector(".select-kit-header")?.dataset?.value;
+ }
}
}
diff --git a/frontend/discourse/tests/helpers/form-kit-helper.js b/frontend/discourse/tests/helpers/form-kit-helper.js
index 4f6c9f89710..2220b2ae444 100644
--- a/frontend/discourse/tests/helpers/form-kit-helper.js
+++ b/frontend/discourse/tests/helpers/form-kit-helper.js
@@ -1,5 +1,6 @@
import { click, fillIn, triggerEvent, waitFor } from "@ember/test-helpers";
import { query } from "discourse/tests/helpers/qunit-helpers";
+import selectKit from "discourse/tests/helpers/select-kit-helper";
class Field {
constructor(selector) {
@@ -14,6 +15,61 @@ class Field {
return this.element.dataset.controlType;
}
+ get resolvedControlType() {
+ const type = this.controlType;
+
+ if (type && type !== "custom") {
+ return type;
+ }
+
+ if (type === "custom") {
+ if (
+ this.element.querySelector(".form-kit__control-custom .multi-select")
+ ) {
+ return "multi-select";
+ }
+
+ if (
+ this.element.querySelector(
+ ".form-kit__control-custom .tag-chooser, .form-kit__control-custom .tag-group-chooser, .form-kit__control-tag-chooser"
+ )
+ ) {
+ return "tag-chooser";
+ }
+
+ throw new Error("Unknown custom control");
+ }
+
+ if (this.element.classList.contains("select-kit")) {
+ return "tag-chooser";
+ }
+
+ throw new Error("Unknown field control");
+ }
+
+ get tagChooserSelector() {
+ if (this.element.dataset.name) {
+ return `[data-name="${this.element.dataset.name}"] .select-kit`;
+ }
+
+ const multiSelect = this.element.querySelector(
+ ".form-kit__control-custom .multi-select"
+ );
+ if (multiSelect?.id) {
+ return `#${multiSelect.id}`;
+ }
+
+ if (this.element.id && this.element.classList.contains("select-kit")) {
+ return `#${this.element.id}`;
+ }
+
+ throw new Error("Unable to resolve tag chooser selector");
+ }
+
+ get tagChooserKit() {
+ return selectKit(this.tagChooserSelector);
+ }
+
/**
* For elements that have a single input element, this returns that element.
*
@@ -44,7 +100,7 @@ class Field {
}
value() {
- switch (this.controlType) {
+ switch (this.resolvedControlType) {
case "input-number":
return parseInt(this.inputElement.value, 10);
// String-based controls fall through to return raw value
@@ -66,6 +122,10 @@ class Field {
this.element.querySelector(".d-icon-grid-picker")?.dataset?.value ||
null
);
+ case "tag-chooser":
+ return this.element.querySelector(".select-kit-header")?.dataset?.value;
+ case "multi-select":
+ return this.element.querySelector(".select-kit-header")?.dataset?.value;
default:
throw new Error(`Unsupported control type: ${this.controlType}`);
}
@@ -175,7 +235,24 @@ class Field {
}
async select(value) {
- switch (this.element.dataset.controlType) {
+ switch (this.resolvedControlType) {
+ case "multi-select": {
+ const multiSelect = this.element.querySelector(
+ ".form-kit__control-custom .multi-select"
+ );
+ const kit = selectKit(`#${multiSelect.id}`);
+ await kit.expand();
+ await kit.selectRowByValue(value);
+ await kit.collapse();
+ break;
+ }
+ case "tag-chooser": {
+ const kit = this.tagChooserKit;
+ await kit.expand();
+ await kit.selectRowByValue(value);
+ await kit.collapse();
+ break;
+ }
case "icon":
await click(".d-icon-grid-picker-trigger");
await waitFor(`[data-icon-id="${value}"]`);
@@ -217,6 +294,39 @@ class Field {
}
}
+ async selectByName(name) {
+ if (this.resolvedControlType !== "tag-chooser") {
+ throw new Error(`Unsupported control type: ${this.resolvedControlType}`);
+ }
+
+ const kit = this.tagChooserKit;
+ await kit.expand();
+ await kit.selectRowByName(name);
+ await kit.collapse();
+ }
+
+ async deselectByName(name) {
+ if (this.resolvedControlType !== "tag-chooser") {
+ throw new Error(`Unsupported control type: ${this.resolvedControlType}`);
+ }
+
+ const kit = this.tagChooserKit;
+ await kit.expand();
+ await kit.deselectItemByName(name);
+ await kit.collapse();
+ }
+
+ async deselectByValue(value) {
+ if (this.resolvedControlType !== "tag-chooser") {
+ throw new Error(`Unsupported control type: ${this.resolvedControlType}`);
+ }
+
+ const kit = this.tagChooserKit;
+ await kit.expand();
+ await kit.deselectItemByValue(value);
+ await kit.collapse();
+ }
+
/**
* Triggers any event on the input element of the field.
*
@@ -255,6 +365,10 @@ class Form {
return new Field(fieldElement);
}
+ control(selector) {
+ return new Field(query(selector));
+ }
+
hasField(name) {
return !!this.element.querySelector(`[data-name="${name}"]`);
}
@@ -274,6 +388,10 @@ export default function form(selector = "form") {
return helper.field(name);
},
+ control(controlSelector) {
+ return helper.control(controlSelector);
+ },
+
hasField(name) {
return helper.hasField(name);
},
diff --git a/frontend/discourse/tests/unit/controllers/edit-category-tabs-test.js b/frontend/discourse/tests/unit/controllers/edit-category-tabs-test.js
index a78d1523e89..f9fe6a2dd9c 100644
--- a/frontend/discourse/tests/unit/controllers/edit-category-tabs-test.js
+++ b/frontend/discourse/tests/unit/controllers/edit-category-tabs-test.js
@@ -34,9 +34,6 @@ module("Unit | Controller | edit-category-tabs", function (hooks) {
});
test("validateForm delegates to registered validators", function (assert) {
- this.controller.siteSettings = {
- enable_simplified_category_creation: true,
- };
this.controller.selectedTab = "general";
const validatorLog = [];
@@ -71,9 +68,6 @@ module("Unit | Controller | edit-category-tabs", function (hooks) {
});
test("validateForm passes removeError to validators", function (assert) {
- this.controller.siteSettings = {
- enable_simplified_category_creation: true,
- };
this.controller.selectedTab = "general";
let removedField;
diff --git a/plugins/chat/assets/javascripts/discourse/initializers/chat-category-tab.js b/plugins/chat/assets/javascripts/discourse/initializers/chat-category-tab.js
index 5db4b06b301..d203f1b6b37 100644
--- a/plugins/chat/assets/javascripts/discourse/initializers/chat-category-tab.js
+++ b/plugins/chat/assets/javascripts/discourse/initializers/chat-category-tab.js
@@ -12,9 +12,7 @@ export default {
name: i18n("chat.edit_category.tab_title"),
component: CategoryChat,
condition: ({ category, siteSettings }) =>
- siteSettings.chat_enabled &&
- category.id &&
- siteSettings.enable_simplified_category_creation,
+ siteSettings.chat_enabled && category.id,
});
});
},
diff --git a/plugins/chat/spec/system/admin/category_channel_list_spec.rb b/plugins/chat/spec/system/admin/category_channel_list_spec.rb
index 715f4091516..b36964d2c5b 100644
--- a/plugins/chat/spec/system/admin/category_channel_list_spec.rb
+++ b/plugins/chat/spec/system/admin/category_channel_list_spec.rb
@@ -8,8 +8,6 @@ RSpec.describe "Admin category channels list" do
fab!(:channel_3, :chat_channel)
before do
- # We are only showing the Chat tab on the new category UI, not the old one
- SiteSetting.enable_simplified_category_creation = true
chat_system_bootstrap
sign_in(current_user)
end
diff --git a/plugins/discourse-assign/assets/javascripts/discourse/connectors/category-custom-settings/assign-settings-upsert.gjs b/plugins/discourse-assign/assets/javascripts/discourse/connectors/category-custom-settings/assign-settings-upsert.gjs
index f11acef0abc..8cbe689565e 100644
--- a/plugins/discourse-assign/assets/javascripts/discourse/connectors/category-custom-settings/assign-settings-upsert.gjs
+++ b/plugins/discourse-assign/assets/javascripts/discourse/connectors/category-custom-settings/assign-settings-upsert.gjs
@@ -3,10 +3,6 @@ import { action } from "@ember/object";
import { i18n } from "discourse-i18n";
export default class AssignSettingsUpsert extends Component {
- static shouldRender(args, context) {
- return context.siteSettings.enable_simplified_category_creation;
- }
-
get enableUnassignedFilter() {
const value =
this.args.outletArgs.transientData?.custom_fields
diff --git a/plugins/discourse-assign/assets/javascripts/discourse/connectors/category-custom-settings/assign-settings.gjs b/plugins/discourse-assign/assets/javascripts/discourse/connectors/category-custom-settings/assign-settings.gjs
deleted file mode 100644
index 001818d388c..00000000000
--- a/plugins/discourse-assign/assets/javascripts/discourse/connectors/category-custom-settings/assign-settings.gjs
+++ /dev/null
@@ -1,42 +0,0 @@
-/* eslint-disable ember/no-classic-components */
-import Component, { Input } from "@ember/component";
-import { on } from "@ember/modifier";
-import { action } from "@ember/object";
-import { tagName } from "@ember-decorators/component";
-import { i18n } from "discourse-i18n";
-
-@tagName("")
-export default class AssignSettings extends Component {
- static shouldRender(args, context) {
- return !context.siteSettings.enable_simplified_category_creation;
- }
-
- @action
- onChangeSetting(event) {
- this.set(
- "outletArgs.category.custom_fields.enable_unassigned_filter",
- event.target.checked ? "true" : "false"
- );
- }
-
- <template>
- <div class="assign-settings" ...attributes>
- <h3>{{i18n "discourse_assign.assign.title"}}</h3>
-
- <section class="field">
- <div class="enable-accepted-answer">
- <label class="checkbox-label">
- <Input
- @type="checkbox"
- @checked={{readonly
- this.outletArgs.category.enable_unassigned_filter
- }}
- {{on "change" this.onChangeSetting}}
- />
- {{i18n "discourse_assign.add_unassigned_filter"}}
- </label>
- </div>
- </section>
- </div>
- </template>
-}
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/connectors/category-custom-settings/show-event-category-sorting-settings.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/connectors/category-custom-settings/show-event-category-sorting-settings.gjs
index f5803185ac8..c2db6214f60 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/connectors/category-custom-settings/show-event-category-sorting-settings.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/connectors/category-custom-settings/show-event-category-sorting-settings.gjs
@@ -1,6 +1,4 @@
import Component from "@glimmer/component";
-import { on } from "@ember/modifier";
-import { action } from "@ember/object";
import { service } from "@ember/service";
import { i18n } from "discourse-i18n";
@@ -14,102 +12,44 @@ export default class ShowEventCategorySortingSettings extends Component {
);
}
- @action
- onChangeSortByEventStartDate(event) {
- this.args.outletArgs.category.set(
- "custom_fields.sort_topics_by_event_start_date",
- event.target.checked
- );
- }
-
- @action
- onChangeDisableTopicResorting(event) {
- this.args.outletArgs.category.set(
- "custom_fields.disable_topic_resorting",
- event.target.checked
- );
- }
-
<template>
{{#if this.showSection}}
- {{#if this.siteSettings.enable_simplified_category_creation}}
- <@outletArgs.form.Section
- @title={{i18n
- "discourse_post_event.category.settings_sections.event_sorting"
- }}
- class="category-custom-settings-outlet show-event-category-sorting-settings"
- >
- <@outletArgs.form.Object @name="custom_fields" as |object|>
- {{#if
- this.siteSettings.sort_categories_by_event_start_date_enabled
- }}
- <object.Field
- @name="sort_topics_by_event_start_date"
- @title={{i18n
- "discourse_post_event.category.sort_topics_by_event_start_date"
- }}
- @format="max"
- @type="checkbox"
- as |field|
- >
- <field.Control />
- </object.Field>
- {{/if}}
-
- {{#if this.siteSettings.disable_resorting_on_categories_enabled}}
- <object.Field
- @name="disable_topic_resorting"
- @title={{i18n
- "discourse_post_event.category.disable_topic_resorting"
- }}
- @format="max"
- @type="checkbox"
- as |field|
- >
- <field.Control />
- </object.Field>
- {{/if}}
- </@outletArgs.form.Object>
- </@outletArgs.form.Section>
- {{else}}
- <div
- class="category-custom-settings-outlet show-event-category-sorting-settings"
- >
- <h3>{{i18n
- "discourse_post_event.category.settings_sections.event_sorting"
- }}</h3>
-
+ <@outletArgs.form.Section
+ @title={{i18n
+ "discourse_post_event.category.settings_sections.event_sorting"
+ }}
+ class="category-custom-settings-outlet show-event-category-sorting-settings"
+ >
+ <@outletArgs.form.Object @name="custom_fields" as |object|>
{{#if this.siteSettings.sort_categories_by_event_start_date_enabled}}
- <section class="field">
- <label class="checkbox-label">
- <input
- id="sort-topics-by-event-start-date"
- type="checkbox"
- checked={{@outletArgs.category.custom_fields.sort_topics_by_event_start_date}}
- {{on "change" this.onChangeSortByEventStartDate}}
- />
- {{i18n
- "discourse_post_event.category.sort_topics_by_event_start_date"
- }}
- </label>
- </section>
+ <object.Field
+ @name="sort_topics_by_event_start_date"
+ @title={{i18n
+ "discourse_post_event.category.sort_topics_by_event_start_date"
+ }}
+ @format="max"
+ @type="checkbox"
+ as |field|
+ >
+ <field.Control />
+ </object.Field>
{{/if}}
{{#if this.siteSettings.disable_resorting_on_categories_enabled}}
- <section class="field">
- <label class="checkbox-label">
- <input
- id="disable-topic-resorting"
- type="checkbox"
- checked={{@outletArgs.category.custom_fields.disable_topic_resorting}}
- {{on "change" this.onChangeDisableTopicResorting}}
- />
- {{i18n "discourse_post_event.category.disable_topic_resorting"}}
- </label>
- </section>
+ <object.Field
+ @name="disable_topic_resorting"
+ @title={{i18n
+ "discourse_post_event.category.disable_topic_resorting"
+ }}
+ @format="max"
+ @type="checkbox"
+ as |field|
+ >
+ <field.Control />
+ </object.Field>
{{/if}}
- </div>
- {{/if}}
+ </@outletArgs.form.Object>
+ </@outletArgs.form.Section>
{{/if}}
</template>
}
diff --git a/plugins/discourse-calendar/spec/requests/categories_controller_spec.rb b/plugins/discourse-calendar/spec/requests/categories_controller_spec.rb
index 22612ff88a9..1f8e8972139 100644
--- a/plugins/discourse-calendar/spec/requests/categories_controller_spec.rb
+++ b/plugins/discourse-calendar/spec/requests/categories_controller_spec.rb
@@ -5,7 +5,6 @@ describe CategoriesController do
fab!(:category)
before do
- SiteSetting.enable_simplified_category_creation = true
SiteSetting.enable_events_category_type_setup = true
SiteSetting.calendar_enabled = true
SiteSetting.discourse_post_event_enabled = true
diff --git a/plugins/discourse-calendar/spec/system/events_category_type_setup_spec.rb b/plugins/discourse-calendar/spec/system/events_category_type_setup_spec.rb
index d7e129a4687..653527c379b 100644
--- a/plugins/discourse-calendar/spec/system/events_category_type_setup_spec.rb
+++ b/plugins/discourse-calendar/spec/system/events_category_type_setup_spec.rb
@@ -9,7 +9,6 @@ RSpec.describe "Events Category Type Setup" do
let(:toast) { PageObjects::Components::Toasts.new }
before do
- SiteSetting.enable_simplified_category_creation = true
SiteSetting.enable_events_category_type_setup = true
SiteSetting.calendar_enabled = true
SiteSetting.discourse_post_event_enabled = true
diff --git a/plugins/discourse-post-voting/assets/javascripts/discourse/connectors/category-custom-settings/post-voting-category-settings.gjs b/plugins/discourse-post-voting/assets/javascripts/discourse/connectors/category-custom-settings/post-voting-category-settings.gjs
index f65b218cfb5..eb292399006 100644
--- a/plugins/discourse-post-voting/assets/javascripts/discourse/connectors/category-custom-settings/post-voting-category-settings.gjs
+++ b/plugins/discourse-post-voting/assets/javascripts/discourse/connectors/category-custom-settings/post-voting-category-settings.gjs
@@ -1,82 +1,30 @@
-import Component from "@glimmer/component";
-import { on } from "@ember/modifier";
-import { action } from "@ember/object";
-import { service } from "@ember/service";
import { i18n } from "discourse-i18n";
-export default class PostVotingCategorySettings extends Component {
- @service siteSettings;
-
- @action
- onChangeCreateAsPostVotingDefault(event) {
- this.args.outletArgs.category.set(
- "custom_fields.create_as_post_voting_default",
- event.target.checked
- );
- }
-
- @action
- onChangeOnlyPostVotingInThisCategory(event) {
- this.args.outletArgs.category.set(
- "custom_fields.only_post_voting_in_this_category",
- event.target.checked
- );
- }
-
- <template>
- {{#if this.siteSettings.enable_simplified_category_creation}}
- <@outletArgs.form.Section
- @title={{i18n "category.post_voting_settings_heading"}}
- class="category-custom-settings-outlet post-voting-category-settings"
+export default <template>
+ <@outletArgs.form.Section
+ @title={{i18n "category.post_voting_settings_heading"}}
+ class="category-custom-settings-outlet post-voting-category-settings"
+ >
+ <@outletArgs.form.Object @name="custom_fields" as |object|>
+ <object.Field
+ @name="create_as_post_voting_default"
+ @title={{i18n "category.create_as_post_voting_default"}}
+ @format="max"
+ @type="checkbox"
+ as |field|
>
- <@outletArgs.form.Object @name="custom_fields" as |object|>
- <object.Field
- @name="create_as_post_voting_default"
- @title={{i18n "category.create_as_post_voting_default"}}
- @format="max"
- @type="checkbox"
- as |field|
- >
- <field.Control />
- </object.Field>
+ <field.Control />
+ </object.Field>
- <object.Field
- @name="only_post_voting_in_this_category"
- @title={{i18n "category.only_post_voting_in_this_category"}}
- @format="max"
- @type="checkbox"
- as |field|
- >
- <field.Control />
- </object.Field>
- </@outletArgs.form.Object>
- </@outletArgs.form.Section>
- {{else}}
- <div
- class="category-custom-settings-outlet post-voting-category-settings"
+ <object.Field
+ @name="only_post_voting_in_this_category"
+ @title={{i18n "category.only_post_voting_in_this_category"}}
+ @format="max"
+ @type="checkbox"
+ as |field|
>
- <h3>{{i18n "category.post_voting_settings_heading"}}</h3>
- <section class="field">
- <label class="checkbox-label">
- <input
- id="create-as-post-voting-default"
- type="checkbox"
- checked={{@outletArgs.category.custom_fields.create_as_post_voting_default}}
- {{on "change" this.onChangeCreateAsPostVotingDefault}}
- />
- {{i18n "category.create_as_post_voting_default"}}
- </label>
- <label class="checkbox-label">
- <input
- id="only-post-voting-in-this-category"
- type="checkbox"
- checked={{@outletArgs.category.custom_fields.only_post_voting_in_this_category}}
- {{on "change" this.onChangeOnlyPostVotingInThisCategory}}
- />
- {{i18n "category.only_post_voting_in_this_category"}}
- </label>
- </section>
- </div>
- {{/if}}
- </template>
-}
+ <field.Control />
+ </object.Field>
+ </@outletArgs.form.Object>
+ </@outletArgs.form.Section>
+</template>
diff --git a/plugins/discourse-post-voting/test/javascripts/acceptance/category-edit-test.js b/plugins/discourse-post-voting/test/javascripts/acceptance/category-edit-test.js
index 765d6e4c621..c797d9abc58 100644
--- a/plugins/discourse-post-voting/test/javascripts/acceptance/category-edit-test.js
+++ b/plugins/discourse-post-voting/test/javascripts/acceptance/category-edit-test.js
@@ -1,35 +1,42 @@
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import pretender from "discourse/tests/helpers/create-pretender";
+import formKit from "discourse/tests/helpers/form-kit-helper";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
+function latestCategorySavePayload() {
+ const request = pretender.handledRequests.findLast(
+ ({ method, requestBody }) => method === "PUT" && requestBody
+ );
+
+ return JSON.parse(request.requestBody);
+}
+
acceptance("Category Edit", function (needs) {
needs.user();
needs.settings({ post_voting_enabled: true });
test("Editing the category to create_as_post_voting_default", async function (assert) {
await visit("/c/bug/edit/settings");
- await click("#create-as-post-voting-default");
+ await formKit()
+ .field("custom_fields.create_as_post_voting_default")
+ .toggle();
- await click("#save-category");
+ await click(".admin-changes-banner .btn-primary");
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
+ const payload = latestCategorySavePayload();
assert.true(payload.custom_fields.create_as_post_voting_default);
});
test("Editing the category to only_post_voting_in_this_category", async function (assert) {
await visit("/c/bug/edit/settings");
- await click("#only-post-voting-in-this-category");
+ await formKit()
+ .field("custom_fields.only_post_voting_in_this_category")
+ .toggle();
- await click("#save-category");
+ await click(".admin-changes-banner .btn-primary");
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
+ const payload = latestCategorySavePayload();
assert.true(payload.custom_fields.only_post_voting_in_this_category);
});
});
diff --git a/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings-upsert.gjs b/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings-upsert.gjs
deleted file mode 100644
index 666bb27776d..00000000000
--- a/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings-upsert.gjs
+++ /dev/null
@@ -1,104 +0,0 @@
-import Component from "@glimmer/component";
-import { action } from "@ember/object";
-import { service } from "@ember/service";
-import { i18n } from "discourse-i18n";
-
-export default class SolvedSettingsUpsert extends Component {
- static shouldRender(args, context) {
- // NOTE: There is a separate Support tab when the solved plugin
- // is enabled for a category. In future, we may want to get rid
- // of this component entirely and just rely on the schema defined
- // in Categories::Types::Support.
- return (
- context.siteSettings.enable_simplified_category_creation &&
- (!args.category?.isType("support") ||
- !context.siteSettings.enable_support_category_type_setup)
- );
- }
-
- @service siteSettings;
-
- get enableAcceptedAnswers() {
- const value =
- this.args.outletArgs.transientData?.custom_fields
- ?.enable_accepted_answers;
- return value?.toString() === "true";
- }
-
- get notifyOnStaffAcceptSolved() {
- const value =
- this.args.outletArgs.transientData?.custom_fields
- ?.notify_on_staff_accept_solved;
- return value?.toString() !== "false";
- }
-
- get emptyBoxOnUnsolved() {
- const value =
- this.args.outletArgs.transientData?.custom_fields?.empty_box_on_unsolved;
- return value?.toString() !== "false";
- }
-
- @action
- async onToggleAcceptedAnswers(_, { set, name }) {
- await set(name, this.enableAcceptedAnswers ? "false" : "true");
- }
-
- @action
- async onToggleNotifyOnStaffAcceptSolved(_, { set, name }) {
- await set(name, this.notifyOnStaffAcceptSolved ? "false" : "true");
- }
-
- @action
- async onToggleEmptyBoxOnUnsolved(_, { set, name }) {
- await set(name, this.emptyBoxOnUnsolved ? "false" : "true");
- }
-
- <template>
- {{#let @outletArgs.form as |form|}}
- <form.Section @title={{i18n "solved.title"}}>
- <form.Object @name="custom_fields" as |customFields|>
- {{#unless this.siteSettings.allow_solved_on_all_topics}}
- <customFields.Field
- @name="enable_accepted_answers"
- @title={{i18n "solved.allow_accepted_answers"}}
- @onSet={{this.onToggleAcceptedAnswers}}
- @type="checkbox"
- as |field|
- >
- <field.Control checked={{this.enableAcceptedAnswers}} />
- </customFields.Field>
- {{/unless}}
-
- <customFields.Field
- @name="solved_topics_auto_close_hours"
- @title={{i18n "solved.solved_topics_auto_close_hours"}}
- @type="input-number"
- as |field|
- >
- <field.Control min="0" />
- </customFields.Field>
-
- <customFields.Field
- @name="notify_on_staff_accept_solved"
- @title={{i18n "solved.notify_on_staff_accept_solved"}}
- @onSet={{this.onToggleNotifyOnStaffAcceptSolved}}
- @type="checkbox"
- as |field|
- >
- <field.Control checked={{this.notifyOnStaffAcceptSolved}} />
- </customFields.Field>
-
- <customFields.Field
- @name="empty_box_on_unsolved"
- @title={{i18n "solved.empty_box_on_unsolved"}}
- @onSet={{this.onToggleEmptyBoxOnUnsolved}}
- @type="checkbox"
- as |field|
- >
- <field.Control checked={{this.emptyBoxOnUnsolved}} />
- </customFields.Field>
- </form.Object>
- </form.Section>
- {{/let}}
- </template>
-}
diff --git a/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.gjs b/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.gjs
deleted file mode 100644
index 56b1b8f4dab..00000000000
--- a/plugins/discourse-solved/assets/javascripts/discourse/connectors/category-custom-settings/solved-settings.gjs
+++ /dev/null
@@ -1,130 +0,0 @@
-import Component from "@glimmer/component";
-import { tracked } from "@glimmer/tracking";
-import { on } from "@ember/modifier";
-import { action } from "@ember/object";
-import { service } from "@ember/service";
-import withEventValue from "discourse/helpers/with-event-value";
-import { i18n } from "discourse-i18n";
-
-export default class SolvedSettings extends Component {
- static shouldRender(args, context) {
- return !context.siteSettings.enable_simplified_category_creation;
- }
-
- @service siteSettings;
-
- @tracked
- enableAcceptedAnswers =
- this.args.outletArgs.category.custom_fields.enable_accepted_answers ===
- "true";
-
- @tracked
- notifyOnStaffAcceptSolved =
- this.args.outletArgs.category.custom_fields
- ?.notify_on_staff_accept_solved !== "false";
-
- @tracked
- emptyBoxOnUnsolved =
- this.args.outletArgs.category.custom_fields?.empty_box_on_unsolved !==
- "false";
-
- get customFields() {
- return this.args.outletArgs.category.custom_fields;
- }
-
- @action
- onChangeSetting(value) {
- this.enableAcceptedAnswers = value;
- this.customFields.enable_accepted_answers = value ? "true" : "false";
- }
-
- @action
- onChangeNotifyOnStaffAcceptSolved(value) {
- this.notifyOnStaffAcceptSolved = value;
- this.customFields.notify_on_staff_accept_solved = value ? "true" : "false";
- }
-
- @action
- onChangeEmptyBoxOnUnsolved(value) {
- this.emptyBoxOnUnsolved = value;
- this.customFields.empty_box_on_unsolved = value ? "true" : "false";
- }
-
- @action
- onChangeAutoCloseHours(value) {
- this.customFields.solved_topics_auto_close_hours = value;
- }
-
- <template>
- <div class="category-custom-settings-outlet solved-settings" ...attributes>
- <h3>{{i18n "solved.title"}}</h3>
-
- {{#unless this.siteSettings.allow_solved_on_all_topics}}
- <section class="field">
- <div class="enable-accepted-answer">
- <label class="checkbox-label">
- <input
- {{on
- "change"
- (withEventValue this.onChangeSetting "target.checked")
- }}
- checked={{this.enableAcceptedAnswers}}
- type="checkbox"
- />
- {{i18n "solved.allow_accepted_answers"}}
- </label>
- </div>
- </section>
- {{/unless}}
-
- <section class="field auto-close-solved-topics">
- <label for="auto-close-solved-topics">
- {{i18n "solved.solved_topics_auto_close_hours"}}
- </label>
- <input
- {{on "input" (withEventValue this.onChangeAutoCloseHours)}}
- value={{@outletArgs.category.custom_fields.solved_topics_auto_close_hours}}
- type="number"
- min="0"
- id="auto-close-solved-topics"
- />
- </section>
-
- <section class="field">
- <div class="notify-on-staff-accept-solved">
- <label class="checkbox-label">
- <input
- {{on
- "change"
- (withEventValue
- this.onChangeNotifyOnStaffAcceptSolved "target.checked"
- )
- }}
- checked={{this.notifyOnStaffAcceptSolved}}
- type="checkbox"
- />
- {{i18n "solved.notify_on_staff_accept_solved"}}
- </label>
- </div>
- </section>
-
- <section class="field">
- <div class="empty-box-on-unsolved">
- <label class="checkbox-label">
- <input
- {{on
- "change"
- (withEventValue
- this.onChangeEmptyBoxOnUnsolved "target.checked"
- )
- }}
- checked={{this.emptyBoxOnUnsolved}}
- type="checkbox"
- />
- {{i18n "solved.empty_box_on_unsolved"}}
- </label>
- </div>
- </section>
- </div>
- </template>
-}
diff --git a/plugins/discourse-solved/assets/javascripts/discourse/initializers/extend-for-solved-button.gjs b/plugins/discourse-solved/assets/javascripts/discourse/initializers/extend-for-solved-button.gjs
index 2ed2c526346..d3a3ac3a1b7 100644
--- a/plugins/discourse-solved/assets/javascripts/discourse/initializers/extend-for-solved-button.gjs
+++ b/plugins/discourse-solved/assets/javascripts/discourse/initializers/extend-for-solved-button.gjs
@@ -20,7 +20,6 @@ function topicHasSolvedEnabled(topic) {
return true;
}
- // TODO: change to category.isType("support") once enable_simplified_category_creation is permanent
const category = Category.findById(topic.category_id);
if (category?.custom_fields?.enable_accepted_answers === "true") {
return true;
diff --git a/plugins/discourse-solved/spec/requests/categories_controller_spec.rb b/plugins/discourse-solved/spec/requests/categories_controller_spec.rb
index 4fa623d7cf9..ec288a73de5 100644
--- a/plugins/discourse-solved/spec/requests/categories_controller_spec.rb
+++ b/plugins/discourse-solved/spec/requests/categories_controller_spec.rb
@@ -6,7 +6,6 @@ RSpec.describe CategoriesController do
before do
sign_in(admin)
- SiteSetting.enable_simplified_category_creation = true
SiteSetting.enable_support_category_type_setup = true
end
diff --git a/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb b/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb
index f39233da479..9174c800bfa 100644
--- a/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb
+++ b/plugins/discourse-solved/spec/system/support_category_type_setup_spec.rb
@@ -11,7 +11,6 @@ RSpec.describe "Support Category Type Setup" do
let(:toast) { PageObjects::Components::Toasts.new }
before do
- SiteSetting.enable_simplified_category_creation = true
SiteSetting.enable_support_category_type_setup = true
sign_in(admin)
end
diff --git a/plugins/discourse-topic-voting/assets/javascripts/discourse/connectors/category-custom-settings/feature-voting-settings-upsert.gjs b/plugins/discourse-topic-voting/assets/javascripts/discourse/connectors/category-custom-settings/feature-voting-settings-upsert.gjs
deleted file mode 100644
index 93baf62405d..00000000000
--- a/plugins/discourse-topic-voting/assets/javascripts/discourse/connectors/category-custom-settings/feature-voting-settings-upsert.gjs
+++ /dev/null
@@ -1,47 +0,0 @@
-import Component from "@glimmer/component";
-import { action } from "@ember/object";
-import { i18n } from "discourse-i18n";
-
-export default class FeatureVotingSettingsUpsert extends Component {
- static shouldRender(args, context) {
- if (!context.siteSettings.enable_simplified_category_creation) {
- return false;
- }
-
- const handledByIdeasTab =
- args.category?.isType("ideas") &&
- context.siteSettings.enable_ideas_category_type_setup;
-
- return !handledByIdeasTab;
- }
-
- get enableTopicVoting() {
- const value =
- this.args.outletArgs.transientData?.custom_fields?.enable_topic_voting;
- return value?.toString() === "true";
- }
-
- @action
- async onToggleTopicVoting(_, { set, name }) {
- await set(name, this.enableTopicVoting ? "false" : "true");
- }
-
- <template>
- {{#let @outletArgs.form as |form|}}
- <form.Section @title={{i18n "topic_voting.title"}}>
- <form.Object @name="custom_fields" as |customFields|>
- <customFields.Field
- @name="enable_topic_voting"
- @title={{i18n "topic_voting.allow_topic_voting"}}
- @onSet={{this.onToggleTopicVoting}}
- @type="checkbox"
- @format="full"
- as |field|
- >
- <field.Control checked={{this.enableTopicVoting}} />
- </customFields.Field>
- </form.Object>
- </form.Section>
- {{/let}}
- </template>
-}
diff --git a/plugins/discourse-topic-voting/assets/javascripts/discourse/connectors/category-custom-settings/feature-voting-settings.gjs b/plugins/discourse-topic-voting/assets/javascripts/discourse/connectors/category-custom-settings/feature-voting-settings.gjs
deleted file mode 100644
index 4644f133563..00000000000
--- a/plugins/discourse-topic-voting/assets/javascripts/discourse/connectors/category-custom-settings/feature-voting-settings.gjs
+++ /dev/null
@@ -1,24 +0,0 @@
-import Component from "@glimmer/component";
-import { Input } from "@ember/component";
-import { i18n } from "discourse-i18n";
-
-export default class FeatureVotingSettings extends Component {
- static shouldRender(args, context) {
- return !context.siteSettings.enable_simplified_category_creation;
- }
-
- <template>
- <section class="field">
- <h3>{{i18n "topic_voting.title"}}</h3>
- <div class="enable-topic-voting">
- <label class="checkbox-label">
- <Input
- @type="checkbox"
- @checked={{@outletArgs.category.custom_fields.enable_topic_voting}}
- />
- {{i18n "topic_voting.allow_topic_voting"}}
- </label>
- </div>
- </section>
- </template>
-}
diff --git a/plugins/discourse-topic-voting/spec/requests/categories_controller_spec.rb b/plugins/discourse-topic-voting/spec/requests/categories_controller_spec.rb
index 37192869486..2661f7a3230 100644
--- a/plugins/discourse-topic-voting/spec/requests/categories_controller_spec.rb
+++ b/plugins/discourse-topic-voting/spec/requests/categories_controller_spec.rb
@@ -40,14 +40,10 @@ describe CategoriesController do
describe "#update" do
before do
Category.reset_voting_cache
- SiteSetting.enable_simplified_category_creation = true
SiteSetting.enable_ideas_category_type_setup = true
end
- after do
- SiteSetting.enable_simplified_category_creation = false
- SiteSetting.enable_ideas_category_type_setup = false
- end
+ after { SiteSetting.enable_ideas_category_type_setup = false }
it "can add the ideas type to the category" do
expect(Category.can_vote?(category.id)).to eq(false)
diff --git a/plugins/discourse-topic-voting/spec/system/ideas_category_type_setup_spec.rb b/plugins/discourse-topic-voting/spec/system/ideas_category_type_setup_spec.rb
index 2728eccb18f..87ba45a9810 100644
--- a/plugins/discourse-topic-voting/spec/system/ideas_category_type_setup_spec.rb
+++ b/plugins/discourse-topic-voting/spec/system/ideas_category_type_setup_spec.rb
@@ -11,7 +11,6 @@ RSpec.describe "Ideas Category Type Setup" do
let(:toast) { PageObjects::Components::Toasts.new }
before do
- SiteSetting.enable_simplified_category_creation = true
SiteSetting.enable_ideas_category_type_setup = true
sign_in(admin)
end
diff --git a/plugins/discourse-topic-voting/test/javascripts/acceptance/category-edit-test.js b/plugins/discourse-topic-voting/test/javascripts/acceptance/category-edit-test.js
deleted file mode 100644
index 1c2154ba5b2..00000000000
--- a/plugins/discourse-topic-voting/test/javascripts/acceptance/category-edit-test.js
+++ /dev/null
@@ -1,58 +0,0 @@
-import { click, visit } from "@ember/test-helpers";
-import { test } from "qunit";
-import pretender from "discourse/tests/helpers/create-pretender";
-import { acceptance } from "discourse/tests/helpers/qunit-helpers";
-
-acceptance("Category Edit | Topic Voting", function (needs) {
- needs.user();
- needs.settings({ topic_voting_enabled: true });
-
- test("Enabling topic voting sends boolean true", async function (assert) {
- await visit("/c/bug/edit/settings");
- await click(".enable-topic-voting input[type='checkbox']");
- await click("#save-category");
-
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
- assert.true(
- payload.custom_fields.enable_topic_voting,
- "enable_topic_voting should be boolean true"
- );
- });
-
- test("Disabling topic voting sends boolean false", async function (assert) {
- await visit("/c/bug/edit/settings");
-
- // twice to toggle false
- await click(".enable-topic-voting input[type='checkbox']");
- await click(".enable-topic-voting input[type='checkbox']");
-
- await click("#save-category");
-
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
- assert.false(
- payload.custom_fields.enable_topic_voting,
- "enable_topic_voting should be boolean false"
- );
- });
-
- test("Modifying other settings does not include enable_topic_voting", async function (assert) {
- await visit("/c/bug/edit/settings");
- await click("#save-category");
-
- const payload = JSON.parse(
- pretender.handledRequests[pretender.handledRequests.length - 1]
- .requestBody
- );
- assert.strictEqual(
- payload.custom_fields?.enable_topic_voting,
- undefined,
- "enable_topic_voting should not be in payload when not modified"
- );
- });
-});
diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rb
index 82d822019b1..e467829caed 100644
--- a/spec/requests/categories_controller_spec.rb
+++ b/spec/requests/categories_controller_spec.rb
@@ -611,8 +611,6 @@ RSpec.describe CategoriesController do
end
describe "when category_type is provided" do
- before { SiteSetting.enable_simplified_category_creation = true }
-
it "creates a category with the category type" do
post "/categories.json", params: { name: "Test Category", category_type: "discussion" }
@@ -1283,8 +1281,6 @@ RSpec.describe CategoriesController do
end
context "when category_type_site_settings are provided" do
- before { SiteSetting.enable_simplified_category_creation = true }
-
it "can set site_settings for the category type when they match the schema" do
Categories::Types::Discussion.stubs(:configuration_schema).returns(
{ site_settings: { max_category_nesting: 2 } },
diff --git a/spec/serializers/category_serializer_spec.rb b/spec/serializers/category_serializer_spec.rb
index 0ab27cd0246..8f51e24a73e 100644
--- a/spec/serializers/category_serializer_spec.rb
+++ b/spec/serializers/category_serializer_spec.rb
@@ -361,7 +361,6 @@ RSpec.describe CategorySerializer do
end
before do
- SiteSetting.enable_simplified_category_creation = true
Categories::TypeRegistry.stubs(:all).returns(a: type_a, b: type_b, off: non_matching_type)
end
diff --git a/spec/services/categories/types/base_spec.rb b/spec/services/categories/types/base_spec.rb
index c84a6e85b09..767ac0c4d1b 100644
--- a/spec/services/categories/types/base_spec.rb
+++ b/spec/services/categories/types/base_spec.rb
@@ -352,7 +352,6 @@ RSpec.describe Categories::Types::Base do
end
Categories::TypeRegistry.register(test_type, plugin_identifier: "test")
- SiteSetting.enable_simplified_category_creation = true
expect { category.category_type_site_setting_names }.not_to raise_error
ensure
diff --git a/spec/system/simplified_category_creation_spec.rb b/spec/system/simplified_category_creation_spec.rb
index 9a9f875a197..0efc4ca2cfe 100644
--- a/spec/system/simplified_category_creation_spec.rb
+++ b/spec/system/simplified_category_creation_spec.rb
@@ -11,10 +11,7 @@ describe "Simplified Category Creation" do
let(:category_permission_row) { PageObjects::Components::CategoryPermissionRow.new }
let(:toasts) { PageObjects::Components::Toasts.new }
- before do
- SiteSetting.enable_simplified_category_creation = true
- sign_in(admin)
- end
+ before { sign_in(admin) }
describe "Selecting category type when setting up a new category" do
it "automatically skips category type selection when only one type (discussion) is available" do