Skip to content

Commit

Permalink
ロールのユーザーリストを非公開にできるように (#10987)
Browse files Browse the repository at this point in the history
* ロールのユーザーリストを非公開にできるように

* Changelog update
  • Loading branch information
nenohi authored Jun 10, 2023
1 parent f696279 commit f3a16bc
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
-
-->
## 13.x.x (unreleased)

### General
- ロールが付与されているユーザーリストを非公開にできるように

### Client
-

### Server
-


## 13.13.1

Expand Down
2 changes: 2 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,8 @@ export interface Locale {
"isConditionalRole": string;
"isPublic": string;
"descriptionOfIsPublic": string;
"isPublicUsers": string;
"descriptionOfIsPublicUsers": string;
"options": string;
"policies": string;
"baseRole": string;
Expand Down
4 changes: 3 additions & 1 deletion locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,9 @@ _role:
condition: "条件"
isConditionalRole: "これはコンディショナルロールです。"
isPublic: "ロールを公開"
descriptionOfIsPublic: "ロールにアサインされたユーザーを誰でも見ることができます。また、ユーザーのプロフィールでこのロールが表示されます。"
descriptionOfIsPublic: "ユーザーのプロフィールでこのロールが表示されます。"
isPublicUsers: "ユーザーリストを公開"
descriptionOfIsPublicUsers: "ロールにアサインされたユーザーのリストを誰でも見ることができます。"
options: "オプション"
policies: "ポリシー"
baseRole: "ベースロール"
Expand Down
11 changes: 11 additions & 0 deletions packages/backend/migration/1686381571997-roleuserhidden.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export class roleuserhidden1686381571997 {
name = 'roleuserhidden1686381571997'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "role" ADD "isPublicUsers" boolean NOT NULL DEFAULT true`);
}

async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "role" DROP COLUMN "isPublicUsers"`);
}
}
5 changes: 5 additions & 0 deletions packages/backend/src/models/entities/Role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ export class Role {
})
public displayOrder: number;

@Column('boolean', {
default: true,
})
public isPublicUsers: boolean;

@Column('jsonb', {
default: { },
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const paramDef = {
isModerator: { type: 'boolean' },
isAdministrator: { type: 'boolean' },
isExplorable: { type: 'boolean', default: false }, // optional for backward compatibility
isPublicUsers: { type: 'boolean', default: true }, // optional for backward compatibility
asBadge: { type: 'boolean' },
canEditMembersByModerator: { type: 'boolean' },
displayOrder: { type: 'number' },
Expand Down Expand Up @@ -78,6 +79,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
isAdministrator: ps.isAdministrator,
isModerator: ps.isModerator,
isExplorable: ps.isExplorable,
isPublicUsers: ps.isPublicUsers,
asBadge: ps.asBadge,
canEditMembersByModerator: ps.canEditMembersByModerator,
displayOrder: ps.displayOrder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const paramDef = {
isModerator: { type: 'boolean' },
isAdministrator: { type: 'boolean' },
isExplorable: { type: 'boolean' },
isPublicUsers: { type: 'boolean' },
asBadge: { type: 'boolean' },
canEditMembersByModerator: { type: 'boolean' },
displayOrder: { type: 'number' },
Expand Down Expand Up @@ -87,6 +88,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
isModerator: ps.isModerator,
isAdministrator: ps.isAdministrator,
isExplorable: ps.isExplorable,
isPublicUsers: ps.isPublicUsers,
asBadge: ps.asBadge,
canEditMembersByModerator: ps.canEditMembersByModerator,
displayOrder: ps.displayOrder,
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/server/api/endpoints/roles/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (role == null) {
throw new ApiError(meta.errors.noSuchRole);
}
if (!role.isPublicUsers) {
return [];
}

const query = this.queryService.makePaginationQuery(this.roleAssignmentsRepository.createQueryBuilder('assign'), ps.sinceId, ps.untilId)
.andWhere('assign.roleId = :roleId', { roleId: role.id })
Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/pages/admin/roles.editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
<template #caption>{{ i18n.ts._role.descriptionOfIsExplorable }}</template>
</MkSwitch>

<MkSwitch v-model="role.isPublicUsers" :readonly="readonly">
<template #label>{{ i18n.ts._role.isPublicUsers }}</template>
<template #caption>{{ i18n.ts._role.descriptionOfIsPublicUsers }}</template>
</MkSwitch>

<FormSlot>
<template #label><i class="ti ti-license"></i> {{ i18n.ts._role.policies }}</template>
<div class="_gaps_s">
Expand Down Expand Up @@ -501,6 +506,7 @@ const save = throttle(100, () => {
isModerator: role.isModerator,
isPublic: role.isPublic,
isExplorable: role.isExplorable,
isPublicUsers: role.isPublicUsers,
asBadge: role.asBadge,
canEditMembersByModerator: role.canEditMembersByModerator,
policies: role.policies,
Expand Down

0 comments on commit f3a16bc

Please sign in to comment.