diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2025-09-13 21:00:33 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-13 21:00:33 +0900 |
| commit | d4654dd7bd5bf1c7faa74ed89f592448c0076be8 (patch) | |
| tree | b4f51e86f174717fef469fbedca48faa2a55e841 /packages/frontend/src/pages/admin/roles.editor.vue | |
| parent | fix(deps): update dependency vite [security] (#16535) (diff) | |
| download | misskey-d4654dd7bd5bf1c7faa74ed89f592448c0076be8.tar.gz misskey-d4654dd7bd5bf1c7faa74ed89f592448c0076be8.tar.bz2 misskey-d4654dd7bd5bf1c7faa74ed89f592448c0076be8.zip | |
refactor(frontend): os.select, MkSelectのitem指定をオブジェクトによる定義に統一し、型を狭める (#16475)
* refactor(frontend): MkSelectのitem指定をオブジェクトによる定義に統一
* fix
* spdx
* fix
* fix os.select
* fix lint
* add comment
* fix
* fix: os.select対応漏れを修正
* fix
* fix
* fix: MkSelectのmodelに対する型チェックを厳格化
* fix
* fix
* fix
* Update packages/frontend/src/components/MkEmbedCodeGenDialog.vue
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
* fix
* fix types
* fix
* fix
* Update packages/frontend/src/pages/admin/roles.editor.vue
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
* fix: MkSelectに直接配列を指定している場合に正常に型が解決されるように
---------
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/pages/admin/roles.editor.vue')
| -rw-r--r-- | packages/frontend/src/pages/admin/roles.editor.vue | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/packages/frontend/src/pages/admin/roles.editor.vue b/packages/frontend/src/pages/admin/roles.editor.vue index 66004a44bb..e10eb1163e 100644 --- a/packages/frontend/src/pages/admin/roles.editor.vue +++ b/packages/frontend/src/pages/admin/roles.editor.vue @@ -30,19 +30,14 @@ SPDX-License-Identifier: AGPL-3.0-only <template #caption>{{ i18n.ts._role.descriptionOfDisplayOrder }}</template> </MkInput> - <MkSelect v-model="rolePermission" :readonly="readonly"> + <MkSelect v-model="rolePermission" :items="rolePermissionDef" :readonly="readonly"> <template #label><i class="ti ti-shield-lock"></i> {{ i18n.ts._role.permission }}</template> <template #caption><div v-html="i18n.ts._role.descriptionOfPermission.replaceAll('\n', '<br>')"></div></template> - <option value="normal">{{ i18n.ts.normalUser }}</option> - <option value="moderator">{{ i18n.ts.moderator }}</option> - <option value="administrator">{{ i18n.ts.administrator }}</option> </MkSelect> - <MkSelect v-model="role.target" :readonly="readonly"> + <MkSelect v-model="role.target" :items="[{ label: i18n.ts._role.manual, value: 'manual' }, { label: i18n.ts._role.conditional, value: 'conditional' }]" :readonly="readonly"> <template #label><i class="ti ti-users"></i> {{ i18n.ts._role.assignTarget }}</template> <template #caption><div v-html="i18n.ts._role.descriptionOfAssignTarget.replaceAll('\n', '<br>')"></div></template> - <option value="manual">{{ i18n.ts._role.manual }}</option> - <option value="conditional">{{ i18n.ts._role.conditional }}</option> </MkSelect> <MkFolder v-if="role.target === 'conditional'" defaultOpen> @@ -176,11 +171,17 @@ SPDX-License-Identifier: AGPL-3.0-only <MkSwitch v-model="role.policies.chatAvailability.useDefault" :readonly="readonly"> <template #label>{{ i18n.ts._role.useBaseValue }}</template> </MkSwitch> - <MkSelect v-model="role.policies.chatAvailability.value" :disabled="role.policies.chatAvailability.useDefault" :readonly="readonly"> + <MkSelect + v-model="role.policies.chatAvailability.value" + :items="[ + { label: i18n.ts.enabled, value: 'available' }, + { label: i18n.ts.readonly, value: 'readonly' }, + { label: i18n.ts.disabled, value: 'unavailable' }, + ]" + :disabled="role.policies.chatAvailability.useDefault" + :readonly="readonly" + > <template #label>{{ i18n.ts.enable }}</template> - <option value="available">{{ i18n.ts.enabled }}</option> - <option value="readonly">{{ i18n.ts.readonly }}</option> - <option value="unavailable">{{ i18n.ts.disabled }}</option> </MkSelect> <MkRange v-model="role.policies.chatAvailability.priority" :min="0" :max="2" :step="1" easing :textConverter="(v) => v === 0 ? i18n.ts._role._priority.low : v === 1 ? i18n.ts._role._priority.middle : v === 2 ? i18n.ts._role._priority.high : ''"> <template #label>{{ i18n.ts._role.priority }}</template> @@ -841,6 +842,7 @@ import FormSlot from '@/components/form/slot.vue'; import { i18n } from '@/i18n.js'; import { instance } from '@/instance.js'; import { deepClone } from '@/utility/clone.js'; +import type { MkSelectItem, GetMkSelectValueTypesFromDef } from '@/components/MkSelect.vue'; const emit = defineEmits<{ (ev: 'update:modelValue', v: any): void; @@ -870,11 +872,17 @@ function updateAvatarDecorationLimit(value: string | number) { role.value.policies.avatarDecorationLimit.value = limited; } -const rolePermission = computed({ +const rolePermissionDef = [ + { label: i18n.ts.normalUser, value: 'normal' }, + { label: i18n.ts.moderator, value: 'moderator' }, + { label: i18n.ts.administrator, value: 'administrator' }, +] as const satisfies MkSelectItem[]; + +const rolePermission = computed<GetMkSelectValueTypesFromDef<typeof rolePermissionDef>>({ get: () => role.value.isAdministrator ? 'administrator' : role.value.isModerator ? 'moderator' : 'normal', set: (val) => { - role.value.isAdministrator = val === 'administrator'; - role.value.isModerator = val === 'moderator'; + role.value.isAdministrator = (val === 'administrator'); + role.value.isModerator = (val === 'moderator'); }, }); |