mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 01:31:35 +08:00
DEV: add site setting type group_list for a list of groups
Add a js test
This commit is contained in:
@ -0,0 +1,8 @@
|
|||||||
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
@computed()
|
||||||
|
groupChoices() {
|
||||||
|
return this.site.get('groups').map(g => g.name);
|
||||||
|
}
|
||||||
|
});
|
@ -13,7 +13,8 @@ const CUSTOM_TYPES = [
|
|||||||
"uploaded_image_list",
|
"uploaded_image_list",
|
||||||
"compact_list",
|
"compact_list",
|
||||||
"secret_list",
|
"secret_list",
|
||||||
"upload"
|
"upload",
|
||||||
|
"group_list"
|
||||||
];
|
];
|
||||||
|
|
||||||
export default Ember.Mixin.create({
|
export default Ember.Mixin.create({
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
{{list-setting settingValue=value choices=groupChoices settingName=setting.setting}}
|
||||||
|
{{setting-validation-message message=validationMessage}}
|
||||||
|
<div class='desc'>{{{unbound setting.description}}}</div>
|
@ -4106,6 +4106,7 @@ en:
|
|||||||
clear_filter: "Clear"
|
clear_filter: "Clear"
|
||||||
add_url: "add URL"
|
add_url: "add URL"
|
||||||
add_host: "add host"
|
add_host: "add host"
|
||||||
|
add_group: "add group"
|
||||||
uploaded_image_list:
|
uploaded_image_list:
|
||||||
label: "Edit list"
|
label: "Edit list"
|
||||||
empty: "There are no pictures yet. Please upload one."
|
empty: "There are no pictures yet. Please upload one."
|
||||||
|
@ -33,6 +33,7 @@ class SiteSettings::TypeSupervisor
|
|||||||
uploaded_image_list: 17,
|
uploaded_image_list: 17,
|
||||||
upload: 18,
|
upload: 18,
|
||||||
group: 19,
|
group: 19,
|
||||||
|
group_list: 20,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,10 +72,15 @@ describe SiteSettings::TypeSupervisor do
|
|||||||
it "'uploaded_image_list' should be at 17th position" do
|
it "'uploaded_image_list' should be at 17th position" do
|
||||||
expect(SiteSettings::TypeSupervisor.types[:uploaded_image_list]).to eq(17)
|
expect(SiteSettings::TypeSupervisor.types[:uploaded_image_list]).to eq(17)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "'upload' should be at the right position" do
|
it "'upload' should be at the right position" do
|
||||||
expect(SiteSettings::TypeSupervisor.types[:upload]).to eq(18)
|
expect(SiteSettings::TypeSupervisor.types[:upload]).to eq(18)
|
||||||
end
|
end
|
||||||
|
it "'group' should be at the right position" do
|
||||||
|
expect(SiteSettings::TypeSupervisor.types[:group]).to eq(19)
|
||||||
|
end
|
||||||
|
it "'group_list' should be at the right position" do
|
||||||
|
expect(SiteSettings::TypeSupervisor.types[:group_list]).to eq(20)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
import componentTest from "helpers/component-test";
|
||||||
|
|
||||||
|
moduleForComponent("group-list", { integration: true });
|
||||||
|
|
||||||
|
componentTest("default", {
|
||||||
|
template: "{{site-setting setting=setting}}",
|
||||||
|
|
||||||
|
beforeEach() {
|
||||||
|
this.site.groups = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: "Donuts"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: "Cheese cake"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
this.set(
|
||||||
|
"setting",
|
||||||
|
Ember.Object.create({
|
||||||
|
allowsNone: undefined,
|
||||||
|
category: "foo",
|
||||||
|
default: "",
|
||||||
|
description: "Choose groups",
|
||||||
|
overridden: false,
|
||||||
|
placeholder: null,
|
||||||
|
preview: null,
|
||||||
|
secret: false,
|
||||||
|
setting: "foo_bar",
|
||||||
|
type: "group_list",
|
||||||
|
validValues: undefined,
|
||||||
|
value: "Donuts"
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
async test(assert) {
|
||||||
|
const subject = selectKit(".list-setting");
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
subject.header().value(),
|
||||||
|
"Donuts",
|
||||||
|
"it selects the setting's value"
|
||||||
|
);
|
||||||
|
|
||||||
|
await subject.expand();
|
||||||
|
await subject.selectRowByValue("Cheese cake");
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
subject.header().value(),
|
||||||
|
"Donuts,Cheese cake",
|
||||||
|
"it allows to select a setting from the list of choices"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
Reference in New Issue
Block a user