wip
This commit is contained in:
parent
397744dc72
commit
188f122315
7 changed files with 40 additions and 9 deletions
|
|
@ -101,3 +101,17 @@ export function observeCanManageChannelMembers(database: Database, channelId: st
|
|||
distinctUntilChanged(),
|
||||
);
|
||||
}
|
||||
|
||||
export function observeCanManageChannelSettings(database: Database, channelId: string, user: UserModel) {
|
||||
return observeChannel(database, channelId).pipe(
|
||||
switchMap((c) => {
|
||||
if (!c || c.deleteAt !== 0 || isDMorGM(c)) {
|
||||
return of$(false);
|
||||
}
|
||||
|
||||
const permission = c.type === General.OPEN_CHANNEL ? Permissions.MANAGE_PUBLIC_CHANNEL_PROPERTIES : Permissions.MANAGE_PRIVATE_CHANNEL_PROPERTIES;
|
||||
return observePermissionForChannel(database, c, user, permission, true);
|
||||
}),
|
||||
distinctUntilChanged(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,14 +74,20 @@ const PublicOrPrivateChannel = ({channel, creator, roles, theme}: Props) => {
|
|||
}, []);
|
||||
|
||||
const canManagePeople = useMemo(() => {
|
||||
if (channel.deleteAt !== 0) {
|
||||
return false;
|
||||
}
|
||||
const permission = channel.type === General.OPEN_CHANNEL ? Permissions.MANAGE_PUBLIC_CHANNEL_MEMBERS : Permissions.MANAGE_PRIVATE_CHANNEL_MEMBERS;
|
||||
return hasPermission(roles, permission);
|
||||
}, [channel.type, roles]);
|
||||
}, [channel.type, roles, channel.deleteAt]);
|
||||
|
||||
const canSetHeader = useMemo(() => {
|
||||
if (channel.deleteAt !== 0) {
|
||||
return false;
|
||||
}
|
||||
const permission = channel.type === General.OPEN_CHANNEL ? Permissions.MANAGE_PUBLIC_CHANNEL_PROPERTIES : Permissions.MANAGE_PRIVATE_CHANNEL_PROPERTIES;
|
||||
return hasPermission(roles, permission);
|
||||
}, [channel.type, roles]);
|
||||
}, [channel.type, roles, channel.deleteAt]);
|
||||
|
||||
const createdBy = useMemo(() => {
|
||||
const id = channel.type === General.OPEN_CHANNEL ? t('intro.public_channel') : t('intro.private_channel');
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ type Props = {
|
|||
canEnableDisableCalls: boolean;
|
||||
isCallsEnabledInChannel: boolean;
|
||||
canManageMembers: boolean;
|
||||
canManageSettings: boolean;
|
||||
}
|
||||
|
||||
const edges: Edge[] = ['bottom', 'left', 'right'];
|
||||
|
|
@ -57,6 +58,7 @@ const ChannelInfo = ({
|
|||
canEnableDisableCalls,
|
||||
isCallsEnabledInChannel,
|
||||
canManageMembers,
|
||||
canManageSettings,
|
||||
}: Props) => {
|
||||
const theme = useTheme();
|
||||
const serverUrl = useServerUrl();
|
||||
|
|
@ -103,6 +105,7 @@ const ChannelInfo = ({
|
|||
type={type}
|
||||
callsEnabled={callsAvailable}
|
||||
canManageMembers={canManageMembers}
|
||||
canManageSettings={canManageSettings}
|
||||
/>
|
||||
<View style={styles.separator}/>
|
||||
{canEnableDisableCalls &&
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {observeIsCallsEnabledInChannel} from '@calls/observers';
|
|||
import {observeCallsConfig} from '@calls/state';
|
||||
import {withServerUrl} from '@context/server';
|
||||
import {observeCurrentChannel} from '@queries/servers/channel';
|
||||
import {observeCanManageChannelMembers} from '@queries/servers/role';
|
||||
import {observeCanManageChannelMembers, observeCanManageChannelSettings} from '@queries/servers/role';
|
||||
import {
|
||||
observeConfigValue,
|
||||
observeCurrentChannelId,
|
||||
|
|
@ -105,11 +105,19 @@ const enhanced = withObservables([], ({serverUrl, database}: Props) => {
|
|||
switchMap(([u, cId]) => (u ? observeCanManageChannelMembers(database, cId, u) : of$(false))),
|
||||
distinctUntilChanged(),
|
||||
);
|
||||
|
||||
const canManageSettings = currentUser.pipe(
|
||||
combineLatestWith(channelId),
|
||||
switchMap(([u, cId]) => (u ? observeCanManageChannelSettings(database, cId, u) : of$(false))),
|
||||
distinctUntilChanged(),
|
||||
);
|
||||
|
||||
return {
|
||||
type,
|
||||
canEnableDisableCalls,
|
||||
isCallsEnabledInChannel,
|
||||
canManageMembers,
|
||||
canManageSettings,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ type Props = {
|
|||
type?: ChannelType;
|
||||
callsEnabled: boolean;
|
||||
canManageMembers: boolean;
|
||||
canManageSettings: boolean;
|
||||
}
|
||||
|
||||
const Options = ({
|
||||
|
|
@ -27,6 +28,7 @@ const Options = ({
|
|||
type,
|
||||
callsEnabled,
|
||||
canManageMembers,
|
||||
canManageSettings,
|
||||
}: Props) => {
|
||||
const isDMorGM = isTypeDMorGM(type);
|
||||
|
||||
|
|
@ -50,7 +52,7 @@ const Options = ({
|
|||
testID='channel_info.options.copy_channel_link.option'
|
||||
/>
|
||||
}
|
||||
{type !== General.DM_CHANNEL && type !== General.GM_CHANNEL &&
|
||||
{canManageSettings &&
|
||||
<EditChannel channelId={channelId}/>
|
||||
}
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -231,9 +231,7 @@ export default function ChannelInfoForm({
|
|||
const spaceOnTop = otherElementsSize - scrollPosition - AUTOCOMPLETE_ADJUST;
|
||||
const spaceOnBottom = (workingSpace + scrollPosition) - (otherElementsSize + headerFieldHeight + BOTTOM_AUTOCOMPLETE_SEPARATION);
|
||||
|
||||
const autocompletePosition = spaceOnBottom > spaceOnTop ?
|
||||
(otherElementsSize + headerFieldHeight) - scrollPosition :
|
||||
(workingSpace + scrollPosition + AUTOCOMPLETE_ADJUST + keyboardOverlap) - otherElementsSize;
|
||||
const autocompletePosition = spaceOnBottom > spaceOnTop ? (otherElementsSize + headerFieldHeight) - scrollPosition : (workingSpace + scrollPosition + AUTOCOMPLETE_ADJUST + keyboardOverlap) - otherElementsSize;
|
||||
const autocompleteAvailableSpace = spaceOnBottom > spaceOnTop ? spaceOnBottom : spaceOnTop;
|
||||
const growDown = spaceOnBottom > spaceOnTop;
|
||||
|
||||
|
|
|
|||
|
|
@ -206,8 +206,8 @@ const CreateOrEditChannel = ({
|
|||
id: channel.id,
|
||||
type: channel.type,
|
||||
display_name: isDirect(channel) ? channel.displayName : displayName,
|
||||
purpose,
|
||||
header,
|
||||
purpose: isDirect(channel) ? null : purpose,
|
||||
header: isDirect(channel) ? null : header,
|
||||
} as Channel;
|
||||
|
||||
setCanSave(false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue