Skip to content

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

FIX: missing default notification level on group creation (#11512)

Penar Musaraj9870a0b6a1ba
diff --git a/app/assets/javascripts/discourse/app/components/groups-form-interaction-fields.js b/app/assets/javascripts/discourse/app/components/groups-form-interaction-fields.js
index ca271caa980..b0638657866 100644
--- a/app/assets/javascripts/discourse/app/components/groups-form-interaction-fields.js
+++ b/app/assets/javascripts/discourse/app/components/groups-form-interaction-fields.js
@@ -1,5 +1,6 @@
import Component from "@ember/component";
import I18n from "I18n";
+import { NotificationLevels } from "discourse/lib/notification-levels";
import discourseComputed from "discourse-common/utils/decorators";
import { or } from "@ember/object/computed";
@@ -46,6 +47,8 @@ export default Component.extend({
{ name: I18n.t("groups.alias_levels.owners_mods_and_admins"), value: 4 },
{ name: I18n.t("groups.alias_levels.everyone"), value: 99 },
];
+
+ this.watchingNotificationLevel = NotificationLevels.WATCHING;
},
membersVisibilityLevel: or(
@@ -63,6 +66,11 @@ export default Component.extend({
"aliasLevelOptions.firstObject.value"
),
+ defaultNotificationLevel: or(
+ "model.default_notification_level",
+ "watchingNotificationLevel"
+ ),
+
@discourseComputed(
"siteSettings.email_in",
"model.automatic",
diff --git a/app/assets/javascripts/discourse/app/templates/components/groups-form-interaction-fields.hbs b/app/assets/javascripts/discourse/app/templates/components/groups-form-interaction-fields.hbs
index 12bcf7b1373..82725adc49c 100644
--- a/app/assets/javascripts/discourse/app/templates/components/groups-form-interaction-fields.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/groups-form-interaction-fields.hbs
@@ -94,10 +94,11 @@
<label>{{i18n "groups.notification_level"}}</label>
{{notifications-button
- value=model.default_notification_level
+ value=defaultNotificationLevel
class="groups-form-default-notification-level"
options=(hash
i18nPrefix="groups.notifications"
)
+ onChange=(action (mut model.default_notification_level))
}}
</div>
diff --git a/app/assets/javascripts/discourse/tests/acceptance/groups-new-test.js b/app/assets/javascripts/discourse/tests/acceptance/groups-new-test.js
index 1b020084b36..421add93b56 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/groups-new-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/groups-new-test.js
@@ -74,5 +74,12 @@ acceptance("New Group - Authenticated", function (needs) {
0,
"it should disable the membership requests checkbox"
);
+
+ assert.ok(
+ queryAll(".groups-form-default-notification-level .selected-name .name")
+ .text()
+ .trim() === I18n.t("groups.notifications.watching.title"),
+ "it has a default selection for notification level"
+ );
});
});