mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-03 14:22:19 +02:00
move standard user modes to constants
This commit is contained in:
parent
6a2e7c2ab8
commit
c08da6f89c
|
@ -62,16 +62,9 @@ import {computed, defineComponent, nextTick, PropType, ref} from "vue";
|
|||
import type {UserInMessage} from "../../server/models/msg";
|
||||
import type {ClientChan, ClientUser} from "../js/types";
|
||||
import Username from "./Username.vue";
|
||||
import constants from "../js/constants";
|
||||
|
||||
const modes = {
|
||||
"~": "owner",
|
||||
"&": "admin",
|
||||
"!": "admin",
|
||||
"@": "op",
|
||||
"%": "half-op",
|
||||
"+": "voice",
|
||||
"": "normal",
|
||||
};
|
||||
const modes = constants.modeCharToName;
|
||||
|
||||
export default defineComponent({
|
||||
name: "ChatUserList",
|
||||
|
|
|
@ -22,6 +22,7 @@ import eventbus from "../js/eventbus";
|
|||
import colorClass from "../js/helpers/colorClass";
|
||||
import type {ClientChan, ClientNetwork, ClientUser} from "../js/types";
|
||||
import {useStore} from "../js/store";
|
||||
import constants from "../js/constants";
|
||||
|
||||
type UsernameUser = Partial<UserInMessage> & {
|
||||
mode?: string;
|
||||
|
@ -77,18 +78,10 @@ export default defineComponent({
|
|||
|
||||
const store = useStore();
|
||||
|
||||
const userModes = {
|
||||
"~": "owner",
|
||||
"&": "admin",
|
||||
"!": "admin",
|
||||
"@": "op",
|
||||
"%": "half-op",
|
||||
"+": "voice",
|
||||
"": "normal",
|
||||
};
|
||||
const modeName = constants.modeCharToName;
|
||||
|
||||
return {
|
||||
userModes,
|
||||
modeName,
|
||||
mode,
|
||||
nickColor,
|
||||
hover,
|
||||
|
|
|
@ -24,10 +24,19 @@ const timeFormats = {
|
|||
msg12hWithSeconds: "hh:mm:ss A",
|
||||
};
|
||||
|
||||
const modeCharToName = {
|
||||
"~": "owner",
|
||||
"&": "admin",
|
||||
"@": "operator",
|
||||
"%": "half-op",
|
||||
"+": "voice",
|
||||
};
|
||||
|
||||
export default {
|
||||
colorCodeMap,
|
||||
commands: [] as string[],
|
||||
timeFormats,
|
||||
modeCharToName,
|
||||
// Same value as media query in CSS that forces sidebars to become overlays
|
||||
mobileViewportPixels: 768,
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@ import type {ClientChan, ClientNetwork, ClientUser} from "../types";
|
|||
import {switchToChannel} from "../router";
|
||||
import {TypedStore} from "../store";
|
||||
import useCloseChannel from "../hooks/use-close-channel";
|
||||
import constants from "../constants";
|
||||
|
||||
type BaseContextMenuItem = {
|
||||
label: string;
|
||||
|
@ -358,19 +359,11 @@ export function generateUserContextMenu(
|
|||
return items;
|
||||
}
|
||||
|
||||
// Names of the standard modes we are able to change
|
||||
const modeCharToName = {
|
||||
"~": "owner",
|
||||
"&": "admin",
|
||||
"@": "operator",
|
||||
"%": "half-op",
|
||||
"+": "voice",
|
||||
};
|
||||
|
||||
// Labels for the mode changes. For example .rev({mode: "a", symbol: "&"}) => 'Revoke admin (-a)'
|
||||
|
||||
const modeTextTemplate = {
|
||||
revoke(m: {symbol: string; mode: string}) {
|
||||
const name = modeCharToName[m.symbol];
|
||||
const name = constants.modeCharToName[m.symbol];
|
||||
|
||||
if (typeof name !== "string") {
|
||||
return "";
|
||||
|
@ -380,7 +373,7 @@ export function generateUserContextMenu(
|
|||
return res;
|
||||
},
|
||||
give(m: {symbol: string; mode: string}) {
|
||||
const name = modeCharToName[m.symbol];
|
||||
const name = constants.modeCharToName[m.symbol];
|
||||
|
||||
if (typeof name !== "string") {
|
||||
return "";
|
||||
|
|
Loading…
Reference in a new issue