Fixed some minor permission related ui issues
This commit is contained in:
parent
4394d36383
commit
7f6af3c304
4 changed files with 55 additions and 47 deletions
|
@ -2,6 +2,8 @@
|
||||||
* **12.03.21**
|
* **12.03.21**
|
||||||
- Added a new video spotlight mode which allows showing multiple videos at the same time as well as
|
- Added a new video spotlight mode which allows showing multiple videos at the same time as well as
|
||||||
dragging and resizing them
|
dragging and resizing them
|
||||||
|
- Fixed a minor bug within the permission editor
|
||||||
|
- Fixed the creation of channel groups
|
||||||
|
|
||||||
* **20.02.21**
|
* **20.02.21**
|
||||||
- Improved the browser IPC module
|
- Improved the browser IPC module
|
||||||
|
|
|
@ -328,13 +328,13 @@ function initializeGroupCreateController(connection: ConnectionHandler, events:
|
||||||
let promise: Promise<CommandResult>;
|
let promise: Promise<CommandResult>;
|
||||||
if(event.source <= 0) {
|
if(event.source <= 0) {
|
||||||
/* real group create */
|
/* real group create */
|
||||||
promise = connection.serverConnection.send_command("servergroupadd", {
|
promise = connection.serverConnection.send_command(target + "groupadd", {
|
||||||
name: event.name,
|
name: event.name,
|
||||||
type: event.target === "query" ? 2 : event.target === "template" ? 0 : 1
|
type: event.target === "query" ? 2 : event.target === "template" ? 0 : 1
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
/* group copy */
|
/* group copy */
|
||||||
promise = connection.serverConnection.send_command("servergroupcopy", {
|
promise = connection.serverConnection.send_command(target + "groupcopy", {
|
||||||
ssgid: event.source,
|
ssgid: event.source,
|
||||||
name: event.name,
|
name: event.name,
|
||||||
type: event.target === "query" ? 2 : event.target === "template" ? 0 : 1
|
type: event.target === "query" ? 2 : event.target === "template" ? 0 : 1
|
||||||
|
|
|
@ -104,7 +104,7 @@ export interface PermissionModalEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
action_set_permission_editor_subject: {
|
action_set_permission_editor_subject: {
|
||||||
mode: PermissionEditorSubject;
|
mode: PermissionEditorSubject | undefined;
|
||||||
|
|
||||||
groupId?: number;
|
groupId?: number;
|
||||||
channelId?: number;
|
channelId?: number;
|
||||||
|
@ -160,42 +160,27 @@ export interface PermissionModalEvents {
|
||||||
query_groups: {
|
query_groups: {
|
||||||
target: "server" | "channel",
|
target: "server" | "channel",
|
||||||
},
|
},
|
||||||
query_groups_result: {
|
|
||||||
target: "server" | "channel",
|
|
||||||
groups: GroupProperties[]
|
|
||||||
},
|
|
||||||
query_group_clients: {
|
query_group_clients: {
|
||||||
id: number
|
id: number
|
||||||
},
|
},
|
||||||
query_group_clients_result: {
|
|
||||||
id: number,
|
|
||||||
status: "success" | "error" | "no-permissions",
|
|
||||||
error?: string;
|
|
||||||
clients?: {
|
|
||||||
name: string;
|
|
||||||
databaseId: number;
|
|
||||||
uniqueId: string;
|
|
||||||
}[]
|
|
||||||
},
|
|
||||||
|
|
||||||
query_channels: {},
|
query_channels: {},
|
||||||
query_channels_result: {
|
query_client_permissions: {},
|
||||||
channels: ChannelInfo[]
|
|
||||||
}
|
|
||||||
|
|
||||||
query_client_permissions: {}, /* will cause the notify_client_permissions */
|
|
||||||
query_client_info: {
|
query_client_info: {
|
||||||
client: number | string; /* client database id or unique id */
|
client: number | string; /* client database id or unique id */
|
||||||
},
|
},
|
||||||
query_client_info_result: {
|
|
||||||
|
|
||||||
|
notify_channels: {
|
||||||
|
channels: ChannelInfo[]
|
||||||
|
},
|
||||||
|
notify_client_info: {
|
||||||
client: number | string;
|
client: number | string;
|
||||||
state: "success" | "error" | "no-such-client" | "no-permission";
|
state: "success" | "error" | "no-such-client" | "no-permission";
|
||||||
|
|
||||||
error?: string;
|
error?: string;
|
||||||
info?: { name: string, uniqueId: string, databaseId: number },
|
info?: { name: string, uniqueId: string, databaseId: number },
|
||||||
failedPermission?: string;
|
failedPermission?: string;
|
||||||
}
|
},
|
||||||
|
|
||||||
notify_group_updated: {
|
notify_group_updated: {
|
||||||
target: "server" | "channel";
|
target: "server" | "channel";
|
||||||
id: number;
|
id: number;
|
||||||
|
@ -210,8 +195,21 @@ export interface PermissionModalEvents {
|
||||||
target: "server" | "channel";
|
target: "server" | "channel";
|
||||||
groups: number[]
|
groups: number[]
|
||||||
},
|
},
|
||||||
|
notify_group_clients: {
|
||||||
notify_groups_reset: {}
|
id: number,
|
||||||
|
status: "success" | "error" | "no-permissions",
|
||||||
|
error?: string;
|
||||||
|
clients?: {
|
||||||
|
name: string;
|
||||||
|
databaseId: number;
|
||||||
|
uniqueId: string;
|
||||||
|
}[]
|
||||||
|
},
|
||||||
|
notify_groups_reset: {},
|
||||||
|
notify_groups: {
|
||||||
|
target: "server" | "channel",
|
||||||
|
groups: GroupProperties[]
|
||||||
|
},
|
||||||
|
|
||||||
notify_client_permissions: {
|
notify_client_permissions: {
|
||||||
permissionModifyPower: number;
|
permissionModifyPower: number;
|
||||||
|
@ -417,7 +415,7 @@ const stringifyError = error => {
|
||||||
function initializePermissionModalController(connection: ConnectionHandler, events: Registry<PermissionModalEvents>) {
|
function initializePermissionModalController(connection: ConnectionHandler, events: Registry<PermissionModalEvents>) {
|
||||||
events.on("query_groups", event => {
|
events.on("query_groups", event => {
|
||||||
const groups = event.target === "server" ? connection.groups.serverGroups : connection.groups.channelGroups;
|
const groups = event.target === "server" ? connection.groups.serverGroups : connection.groups.channelGroups;
|
||||||
events.fire_react("query_groups_result", {
|
events.fire_react("notify_groups", {
|
||||||
target: event.target, groups: groups.map(group => {
|
target: event.target, groups: groups.map(group => {
|
||||||
return {
|
return {
|
||||||
id: group.id,
|
id: group.id,
|
||||||
|
@ -613,6 +611,14 @@ function initializePermissionModalController(connection: ConnectionHandler, even
|
||||||
clientPermissionList: connection.permissions.neededPermission(PermissionType.B_VIRTUALSERVER_CLIENT_PERMISSION_LIST).granted(1),
|
clientPermissionList: connection.permissions.neededPermission(PermissionType.B_VIRTUALSERVER_CLIENT_PERMISSION_LIST).granted(1),
|
||||||
clientChannelPermissionList: connection.permissions.neededPermission(PermissionType.B_VIRTUALSERVER_CHANNELCLIENT_PERMISSION_LIST).granted(1),
|
clientChannelPermissionList: connection.permissions.neededPermission(PermissionType.B_VIRTUALSERVER_CHANNELCLIENT_PERMISSION_LIST).granted(1),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* Update the permission subject (we may now have or not have any more the permissions to edit him) */
|
||||||
|
events.fire("action_set_permission_editor_subject", {
|
||||||
|
channelId: undefined,
|
||||||
|
clientDatabaseId: undefined,
|
||||||
|
groupId: undefined,
|
||||||
|
mode: undefined
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
events.on("query_client_permissions", () => sendClientPermissions());
|
events.on("query_client_permissions", () => sendClientPermissions());
|
||||||
|
@ -621,7 +627,7 @@ function initializePermissionModalController(connection: ConnectionHandler, even
|
||||||
|
|
||||||
events.on("query_group_clients", event => {
|
events.on("query_group_clients", event => {
|
||||||
connection.serverConnection.command_helper.requestClientsByServerGroup(event.id).then(clients => {
|
connection.serverConnection.command_helper.requestClientsByServerGroup(event.id).then(clients => {
|
||||||
events.fire("query_group_clients_result", {
|
events.fire("notify_group_clients", {
|
||||||
id: event.id, status: "success", clients: clients.map(e => {
|
id: event.id, status: "success", clients: clients.map(e => {
|
||||||
return {
|
return {
|
||||||
name: e.client_nickname,
|
name: e.client_nickname,
|
||||||
|
@ -632,12 +638,12 @@ function initializePermissionModalController(connection: ConnectionHandler, even
|
||||||
});
|
});
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error instanceof CommandResult && error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS) {
|
if (error instanceof CommandResult && error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS) {
|
||||||
events.fire("query_group_clients_result", {id: event.id, status: "no-permissions"});
|
events.fire("notify_group_clients", {id: event.id, status: "no-permissions"});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logWarn(LogCategory.PERMISSIONS, tr("Failed to request server group client list: %o"), error);
|
logWarn(LogCategory.PERMISSIONS, tr("Failed to request server group client list: %o"), error);
|
||||||
events.fire("query_group_clients_result", {id: event.id, status: "error", error: stringifyError(error)});
|
events.fire("notify_group_clients", {id: event.id, status: "error", error: stringifyError(error)});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -713,7 +719,7 @@ function initializePermissionModalController(connection: ConnectionHandler, even
|
||||||
}));
|
}));
|
||||||
|
|
||||||
events.on("query_channels", () => {
|
events.on("query_channels", () => {
|
||||||
events.fire_react("query_channels_result", {
|
events.fire_react("notify_channels", {
|
||||||
channels: connection.channelTree.channelsOrdered().map(e => {
|
channels: connection.channelTree.channelsOrdered().map(e => {
|
||||||
return {
|
return {
|
||||||
id: e.channelId,
|
id: e.channelId,
|
||||||
|
@ -734,13 +740,13 @@ function initializePermissionModalController(connection: ConnectionHandler, even
|
||||||
}
|
}
|
||||||
promise.then(result => {
|
promise.then(result => {
|
||||||
if (result.length === 0) {
|
if (result.length === 0) {
|
||||||
events.fire("query_client_info_result", {
|
events.fire("notify_client_info", {
|
||||||
client: event.client,
|
client: event.client,
|
||||||
state: "no-such-client"
|
state: "no-such-client"
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
events.fire("query_client_info_result", {
|
events.fire("notify_client_info", {
|
||||||
client: event.client,
|
client: event.client,
|
||||||
state: "success",
|
state: "success",
|
||||||
info: {
|
info: {
|
||||||
|
@ -751,7 +757,7 @@ function initializePermissionModalController(connection: ConnectionHandler, even
|
||||||
});
|
});
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error instanceof CommandResult) {
|
if (error instanceof CommandResult) {
|
||||||
events.fire("query_client_info_result", {
|
events.fire("notify_client_info", {
|
||||||
client: event.client,
|
client: event.client,
|
||||||
state: "no-permission",
|
state: "no-permission",
|
||||||
failedPermission: connection.permissions.resolveInfo(parseInt(error.json["failed_permid"]))?.name || tr("unknwon")
|
failedPermission: connection.permissions.resolveInfo(parseInt(error.json["failed_permid"]))?.name || tr("unknwon")
|
||||||
|
@ -760,7 +766,7 @@ function initializePermissionModalController(connection: ConnectionHandler, even
|
||||||
}
|
}
|
||||||
|
|
||||||
logWarn(LogCategory.PERMISSIONS, tr("Failed to query client info for %o: %o"), event.client, error);
|
logWarn(LogCategory.PERMISSIONS, tr("Failed to query client info for %o: %o"), event.client, error);
|
||||||
events.fire("query_client_info_result", {
|
events.fire("notify_client_info", {
|
||||||
client: event.client,
|
client: event.client,
|
||||||
state: "error",
|
state: "error",
|
||||||
error: stringifyError(error)
|
error: stringifyError(error)
|
||||||
|
@ -849,7 +855,7 @@ function initializePermissionEditor(connection: ConnectionHandler, modalEvents:
|
||||||
clientDatabaseId = typeof event.clientDatabaseId === "number" ? event.clientDatabaseId : clientDatabaseId;
|
clientDatabaseId = typeof event.clientDatabaseId === "number" ? event.clientDatabaseId : clientDatabaseId;
|
||||||
groupId = typeof event.groupId === "number" ? event.groupId : groupId;
|
groupId = typeof event.groupId === "number" ? event.groupId : groupId;
|
||||||
|
|
||||||
mode = event.mode;
|
mode = event.mode || mode;
|
||||||
|
|
||||||
let editorMode: "unset" | "normal" = "unset";
|
let editorMode: "unset" | "normal" = "unset";
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
|
|
|
@ -323,8 +323,8 @@ class GroupsList extends React.Component<{ connection: ConnectionHandler, events
|
||||||
this.groups.splice(0, this.groups.length);
|
this.groups.splice(0, this.groups.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler<PermissionModalEvents>("query_groups_result")
|
@EventHandler<PermissionModalEvents>("notify_groups")
|
||||||
private handleQueryResult(event: PermissionModalEvents["query_groups_result"]) {
|
private handleQueryResult(event: PermissionModalEvents["notify_groups"]) {
|
||||||
if (event.target !== this.props.target)
|
if (event.target !== this.props.target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -585,8 +585,8 @@ class ServerClientList extends React.Component<{ connection: ConnectionHandler,
|
||||||
this.setState({state: "loading"});
|
this.setState({state: "loading"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler<PermissionModalEvents>("query_group_clients_result")
|
@EventHandler<PermissionModalEvents>("notify_group_clients")
|
||||||
private handleQueryClientsResult(event: PermissionModalEvents["query_group_clients_result"]) {
|
private handleQueryClientsResult(event: PermissionModalEvents["notify_group_clients"]) {
|
||||||
if (event.id !== this.state.selectedGroupId)
|
if (event.id !== this.state.selectedGroupId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -642,8 +642,8 @@ class ServerClientList extends React.Component<{ connection: ConnectionHandler,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler<PermissionModalEvents>("query_groups_result")
|
@EventHandler<PermissionModalEvents>("notify_groups")
|
||||||
private handleQueryResult(event: PermissionModalEvents["query_groups_result"]) {
|
private handleQueryResult(event: PermissionModalEvents["notify_groups"]) {
|
||||||
if (event.target !== "server")
|
if (event.target !== "server")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -862,8 +862,8 @@ class ChannelList extends React.Component<{ connection: ConnectionHandler, event
|
||||||
this.props.events.fire("query_channels");
|
this.props.events.fire("query_channels");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler<PermissionModalEvents>("query_channels_result")
|
@EventHandler<PermissionModalEvents>("notify_channels")
|
||||||
private handleQueryChannelsResult(event: PermissionModalEvents["query_channels_result"]) {
|
private handleQueryChannelsResult(event: PermissionModalEvents["notify_channels"]) {
|
||||||
this.channels = event.channels.slice(0);
|
this.channels = event.channels.slice(0);
|
||||||
if (this.channels.length > 0 && this.channels.findIndex(e => e.id === this.state.selectedChanelId) === -1)
|
if (this.channels.length > 0 && this.channels.findIndex(e => e.id === this.state.selectedChanelId) === -1)
|
||||||
this.setState({selectedChanelId: this.channels[0].id});
|
this.setState({selectedChanelId: this.channels[0].id});
|
||||||
|
@ -988,7 +988,7 @@ const ClientSelect = (props: { events: Registry<PermissionModalEvents>, tabTarge
|
||||||
props.events.fire("action_set_permission_editor_subject", {mode: props.tabTarget, clientDatabaseId: 0});
|
props.events.fire("action_set_permission_editor_subject", {mode: props.tabTarget, clientDatabaseId: 0});
|
||||||
});
|
});
|
||||||
|
|
||||||
props.events.reactUse("query_client_info_result", event => {
|
props.events.reactUse("notify_client_info", event => {
|
||||||
if (event.client !== clientIdentifier)
|
if (event.client !== clientIdentifier)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue