Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added endorseEnabled for admin group settings #17

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/language/ar/admin/manage/groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"edit.label-color": "Group Label Color",
"edit.text-color": "Group Text Color",
"edit.show-badge": "Show Badge",
"edit.show-endorse": "Allow Endorse",
"edit.private-details": "If enabled, joining of groups requires approval from a group owner.",
"edit.private-override": "Warning: Private groups is disabled at system level, which overrides this option.",
"edit.disable-join": "Disable join requests",
Expand Down
1 change: 1 addition & 0 deletions public/language/en-GB/groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"details.change-text-colour": "Change Text Colour",
"details.badge-text": "Badge Text",
"details.userTitleEnabled": "Show Badge",
"details.endorseEnabled": "Allow Endorse",
"details.private-help": "If enabled, joining of groups requires approval from a group owner",
"details.hidden": "Hidden",
"details.hidden-help": "If enabled, this group will not be found in the groups listing, and users will have to be invited manually",
Expand Down
4 changes: 4 additions & 0 deletions public/openapi/components/schemas/GroupObject.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ GroupFullObject:
description: Same as userTitle but with translation tokens escaped, used to display raw userTitle in group management
userTitleEnabled:
type: number
endorseEnabled:
type: number
description:
type: string
description: The group description
Expand Down Expand Up @@ -170,6 +172,8 @@ GroupDataObject:
description: Same as userTitle but with translation tokens escaped, used to display raw userTitle in group management
userTitleEnabled:
type: number
endorseEnabled:
type: number
description:
type: string
description: The group description
Expand Down
3 changes: 3 additions & 0 deletions public/openapi/read/admin/manage/groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ get:
type: string
userTitleEnabled:
type: number
endorseEnabled:
type: number
disableJoinRequests:
type: number
disableLeave:
Expand Down Expand Up @@ -88,6 +90,7 @@ get:
- cover:url
- cover:position
- userTitleEnabled
- endorseEnabled
- disableJoinRequests
- disableLeave
- nameEncoded
Expand Down
2 changes: 2 additions & 0 deletions public/openapi/read/groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ get:
type: number
userTitleEnabled:
type: number
endorseEnabled:
type: number
disableJoinRequests:
type: number
disableLeave:
Expand Down
1 change: 1 addition & 0 deletions public/src/admin/manage/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ define('admin/manage/group', [
labelColor: changeGroupLabelColor.val(),
textColor: changeGroupTextColor.val(),
userTitleEnabled: $('#group-userTitleEnabled').is(':checked'),
endorseEnabled: $('#group-endorseEnabled').is(':checked'),
private: $('#group-private').is(':checked'),
hidden: $('#group-hidden').is(':checked'),
memberPostCids: $('#memberPostCids').val(),
Expand Down
1 change: 1 addition & 0 deletions src/groups/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = function (Groups) {
createtime: timestamp,
userTitle: data.userTitle || data.name,
userTitleEnabled: parseInt(data.userTitleEnabled, 10) === 1 ? 1 : 0,
endorseEnabled: parseInt(data.endorseEnabled, 10) === 1 ? 1 : 0,
description: data.description || '',
memberCount: memberCount,
hidden: isHidden ? 1 : 0,
Expand Down
3 changes: 2 additions & 1 deletion src/groups/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const translator = require('../translator');

const intFields = [
'createtime', 'memberCount', 'hidden', 'system', 'private',
'userTitleEnabled', 'disableJoinRequests', 'disableLeave',
'userTitleEnabled', 'disableJoinRequests', 'disableLeave', 'endorseEnabled',
];

module.exports = function (Groups) {
Expand Down Expand Up @@ -71,6 +71,7 @@ function modifyGroup(group, fields) {

escapeGroupData(group);
group.userTitleEnabled = ([null, undefined].includes(group.userTitleEnabled)) ? 1 : group.userTitleEnabled;
group.endorseEnabled = ([null, undefined].includes(group.endorseEnabled)) ? 1 : group.endorseEnabled;
group.labelColor = validator.escape(String(group.labelColor || '#000000'));
group.textColor = validator.escape(String(group.textColor || '#ffffff'));
group.icon = validator.escape(String(group.icon || ''));
Expand Down
6 changes: 5 additions & 1 deletion src/groups/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = function (Groups) {

// Cast some values as bool (if not boolean already)
// 'true' and '1' = true, everything else false
['userTitleEnabled', 'private', 'hidden', 'disableJoinRequests', 'disableLeave'].forEach((prop) => {
['userTitleEnabled', 'private', 'hidden', 'disableJoinRequests', 'disableLeave', 'endorseEnabled'].forEach((prop) => {
if (values.hasOwnProperty(prop) && typeof values[prop] !== 'boolean') {
values[prop] = values[prop] === 'true' || parseInt(values[prop], 10) === 1;
}
Expand All @@ -47,6 +47,10 @@ module.exports = function (Groups) {
payload.userTitleEnabled = values.userTitleEnabled ? '1' : '0';
}

if (values.hasOwnProperty('endorseEnabled')) {
payload.endorseEnabled = values.endorseEnabled ? '1' : '0';
}

if (values.hasOwnProperty('hidden')) {
payload.hidden = values.hidden ? '1' : '0';
}
Expand Down
7 changes: 7 additions & 0 deletions src/views/admin/manage/group.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@
</div>
</div>

<div class="mb-3">
<div class="form-check form-switch">
<input class="form-check-input" id="group-endorseEnabled" name="endorseEnabled" data-property type="checkbox"{{{ if group.endorseEnabled }}} checked{{{ end }}}>
<label class="form-check-label" for="group-endorseEnabled">Allow Endorse</label>
</div>
</div>

<div class="mb-3">
<div class="form-check form-switch">
<input class="form-check-input" id="group-private" name="private" data-property type="checkbox"{{{ if group.private }}} checked{{{ end }}}>
Expand Down