mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-09 08:40:29 +03:00
* WIP - add room settings dialog * join rule setting - WIP * show emojis & stickers in room settings - WIP * restyle join rule switcher * Merge branch 'dev' into new-room-settings * add join rule hook * open room settings from global state * open new room settings from all places * rearrange settings menu item * add option for creating new image pack * room devtools - WIP * render room state events as list * add option to open state event * add option to edit state event * refactor text area code editor into hook * add option to send message and state event * add cutout card component * add hook for room account data * display room account data - WIP * refactor global account data editor component * add account data editor in room * fix font style in devtool * show state events in compact form * add option to delete room image pack * add server badge component * add member tile component * render members in room settings * add search in room settings member * add option to reset member search * add filter in room members * fix member virtual item key * remove color from serve badge in room members * show room in settings * fix loading indicator position * power level tags in room setting - WIP * generate fallback tag in backward compatible way * add color picker * add powers editor - WIP * add props to stop adding emoji to recent usage * add beta feature notice badge * add types for power level tag icon * refactor image pack rooms code to hook * option for adding new power levels tags * remove console log * refactor power icon * add option to edit power level tags * remove power level from powers pill * fix power level labels * add option to delete power levels * fix long power level name shrinks power integer * room permissions - WIP * add power level selector component * add room permissions * move user default permission setting to other group * add power permission peek menu * fix weigh of power switch text * hide above for max power in permission switcher * improve beta badge description * render room profile in room settings * add option to edit room profile * make room topic input text area * add option to enable room encryption in room settings * add option to change message history visibility * add option to change join rule * add option for addresses in room settings * close encryption dialog after enabling
218 lines
4.6 KiB
TypeScript
218 lines
4.6 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { PermissionLocation } from '../../../hooks/usePowerLevels';
|
|
import { MessageEvent, StateEvent } from '../../../../types/matrix/room';
|
|
|
|
export type PermissionItem = {
|
|
location: PermissionLocation;
|
|
name: string;
|
|
description?: string;
|
|
};
|
|
|
|
export type PermissionGroup = {
|
|
name: string;
|
|
items: PermissionItem[];
|
|
};
|
|
|
|
export const usePermissionGroups = (): PermissionGroup[] => {
|
|
const groups: PermissionGroup[] = useMemo(() => {
|
|
const messagesGroup: PermissionGroup = {
|
|
name: 'Messages',
|
|
items: [
|
|
{
|
|
location: {
|
|
key: MessageEvent.RoomMessage,
|
|
},
|
|
name: 'Send Messages',
|
|
},
|
|
{
|
|
location: {
|
|
key: MessageEvent.Sticker,
|
|
},
|
|
name: 'Send Stickers',
|
|
},
|
|
{
|
|
location: {
|
|
key: MessageEvent.Reaction,
|
|
},
|
|
name: 'Send Reactions',
|
|
},
|
|
{
|
|
location: {
|
|
notification: true,
|
|
key: 'room',
|
|
},
|
|
name: 'Ping @room',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomPinnedEvents,
|
|
},
|
|
name: 'Pin Messages',
|
|
},
|
|
{
|
|
location: {},
|
|
name: 'Other Message Events',
|
|
},
|
|
],
|
|
};
|
|
|
|
const moderationGroup: PermissionGroup = {
|
|
name: 'Moderation',
|
|
items: [
|
|
{
|
|
location: {
|
|
action: true,
|
|
key: 'invite',
|
|
},
|
|
name: 'Invite',
|
|
},
|
|
{
|
|
location: {
|
|
action: true,
|
|
key: 'kick',
|
|
},
|
|
name: 'Kick',
|
|
},
|
|
{
|
|
location: {
|
|
action: true,
|
|
key: 'ban',
|
|
},
|
|
name: 'Ban',
|
|
},
|
|
{
|
|
location: {
|
|
action: true,
|
|
key: 'redact',
|
|
},
|
|
name: 'Delete Others Messages',
|
|
},
|
|
{
|
|
location: {
|
|
key: MessageEvent.RoomRedaction,
|
|
},
|
|
name: 'Delete Self Messages',
|
|
},
|
|
],
|
|
};
|
|
|
|
const roomOverviewGroup: PermissionGroup = {
|
|
name: 'Room Overview',
|
|
items: [
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomAvatar,
|
|
},
|
|
name: 'Room Avatar',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomName,
|
|
},
|
|
name: 'Room Name',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomTopic,
|
|
},
|
|
name: 'Room Topic',
|
|
},
|
|
],
|
|
};
|
|
|
|
const roomSettingsGroup: PermissionGroup = {
|
|
name: 'Settings',
|
|
items: [
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomJoinRules,
|
|
},
|
|
name: 'Change Room Access',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomCanonicalAlias,
|
|
},
|
|
name: 'Publish Address',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomPowerLevels,
|
|
},
|
|
name: 'Change All Permission',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.PowerLevelTags,
|
|
},
|
|
name: 'Edit Power Levels',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomEncryption,
|
|
},
|
|
name: 'Enable Encryption',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomHistoryVisibility,
|
|
},
|
|
name: 'History Visibility',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomTombstone,
|
|
},
|
|
name: 'Upgrade Room',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
},
|
|
name: 'Other Settings',
|
|
},
|
|
],
|
|
};
|
|
|
|
const otherSettingsGroup: PermissionGroup = {
|
|
name: 'Other',
|
|
items: [
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: StateEvent.RoomServerAcl,
|
|
},
|
|
name: 'Change Server ACLs',
|
|
},
|
|
{
|
|
location: {
|
|
state: true,
|
|
key: 'im.vector.modular.widgets',
|
|
},
|
|
name: 'Modify Widgets',
|
|
},
|
|
],
|
|
};
|
|
|
|
return [
|
|
messagesGroup,
|
|
moderationGroup,
|
|
roomOverviewGroup,
|
|
roomSettingsGroup,
|
|
otherSettingsGroup,
|
|
];
|
|
}, []);
|
|
|
|
return groups;
|
|
};
|