Compare commits
1
Commits
@@ -476,77 +476,82 @@ function UsersSection({
|
|||||||
title="People"
|
title="People"
|
||||||
subtitle="Manage who can access this server."
|
subtitle="Manage who can access this server."
|
||||||
>
|
>
|
||||||
{users.map((user, index) => (
|
<View style={styles.userList}>
|
||||||
<View key={user._id}>
|
{users.map((user, index) => (
|
||||||
{index > 0 ? (
|
<View
|
||||||
<View
|
key={user._id}
|
||||||
style={[styles.divider, { backgroundColor: colors.border }]}
|
style={[
|
||||||
/>
|
styles.userBlock,
|
||||||
) : null}
|
index > 0
|
||||||
<View style={styles.userRow}>
|
? [styles.userBlockSpaced, { borderTopColor: colors.border }]
|
||||||
<ProfileAvatar user={user} size={44} />
|
: null,
|
||||||
<View style={styles.userCopy}>
|
]}
|
||||||
<View style={styles.userNameRow}>
|
>
|
||||||
|
<View style={styles.userRow}>
|
||||||
|
<ProfileAvatar user={user} size={44} />
|
||||||
|
<View style={styles.userCopy}>
|
||||||
|
<View style={styles.userNameRow}>
|
||||||
|
<Text
|
||||||
|
style={[styles.userName, { color: colors.foreground }]}
|
||||||
|
numberOfLines={1}
|
||||||
|
>
|
||||||
|
{user.name}
|
||||||
|
</Text>
|
||||||
|
{user.isAdmin ? (
|
||||||
|
<View
|
||||||
|
style={[styles.badge, { backgroundColor: colors.muted }]}
|
||||||
|
>
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
styles.badgeText,
|
||||||
|
{ color: colors.mutedForeground },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
Admin
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
</View>
|
||||||
<Text
|
<Text
|
||||||
style={[styles.userName, { color: colors.foreground }]}
|
style={{ color: colors.mutedForeground }}
|
||||||
numberOfLines={1}
|
numberOfLines={1}
|
||||||
>
|
>
|
||||||
{user.name}
|
{user.email}
|
||||||
</Text>
|
</Text>
|
||||||
{user.isAdmin ? (
|
|
||||||
<View
|
|
||||||
style={[styles.badge, { backgroundColor: colors.muted }]}
|
|
||||||
>
|
|
||||||
<Text
|
|
||||||
style={[
|
|
||||||
styles.badgeText,
|
|
||||||
{ color: colors.mutedForeground },
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
Admin
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
) : null}
|
|
||||||
</View>
|
</View>
|
||||||
<Text
|
|
||||||
style={{ color: colors.mutedForeground }}
|
|
||||||
numberOfLines={1}
|
|
||||||
>
|
|
||||||
{user.email}
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
|
{user._id !== currentUserId ? (
|
||||||
|
<View style={styles.userActions}>
|
||||||
|
<Button
|
||||||
|
title={user.isAdmin ? "Remove Admin" : "Make Admin"}
|
||||||
|
variant="secondary"
|
||||||
|
onPress={() =>
|
||||||
|
void setAdmin({
|
||||||
|
userId: user._id,
|
||||||
|
isAdmin: !user.isAdmin,
|
||||||
|
}).then(
|
||||||
|
() => showSuccess("Updated permissions"),
|
||||||
|
(error: Error) => showError(error.message)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
style={styles.userActionButton}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
title="Delete"
|
||||||
|
variant="destructive"
|
||||||
|
onPress={() =>
|
||||||
|
void deleteUserMutation({ userId: user._id }).then(
|
||||||
|
() => showSuccess("User deleted"),
|
||||||
|
(error: Error) => showError(error.message)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
style={styles.userActionButton}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
{user._id !== currentUserId ? (
|
))}
|
||||||
<View style={styles.userActions}>
|
</View>
|
||||||
<Button
|
|
||||||
title={user.isAdmin ? "Remove Admin" : "Make Admin"}
|
|
||||||
variant="secondary"
|
|
||||||
onPress={() =>
|
|
||||||
void setAdmin({
|
|
||||||
userId: user._id,
|
|
||||||
isAdmin: !user.isAdmin,
|
|
||||||
}).then(
|
|
||||||
() => showSuccess("Updated permissions"),
|
|
||||||
(error: Error) => showError(error.message)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
style={styles.userActionButton}
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
title="Delete"
|
|
||||||
variant="destructive"
|
|
||||||
onPress={() =>
|
|
||||||
void deleteUserMutation({ userId: user._id }).then(
|
|
||||||
() => showSuccess("User deleted"),
|
|
||||||
(error: Error) => showError(error.message)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
style={styles.userActionButton}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
) : null}
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</SettingsCard>
|
</SettingsCard>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
@@ -833,6 +838,16 @@ const styles = StyleSheet.create({
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: spacing.md,
|
gap: spacing.md,
|
||||||
},
|
},
|
||||||
|
userList: {
|
||||||
|
gap: spacing.lg,
|
||||||
|
},
|
||||||
|
userBlock: {
|
||||||
|
gap: spacing.md,
|
||||||
|
},
|
||||||
|
userBlockSpaced: {
|
||||||
|
paddingTop: spacing.lg,
|
||||||
|
borderTopWidth: StyleSheet.hairlineWidth,
|
||||||
|
},
|
||||||
userRow: {
|
userRow: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
@@ -855,7 +870,6 @@ const styles = StyleSheet.create({
|
|||||||
userActions: {
|
userActions: {
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
gap: spacing.sm,
|
gap: spacing.sm,
|
||||||
marginTop: spacing.md,
|
|
||||||
},
|
},
|
||||||
userActionButton: {
|
userActionButton: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|||||||
Reference in new issue
Block a user