mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-04 14:52:19 +02:00
Merge 5210cfe8e0
into 549c445853
This commit is contained in:
commit
18e78587e0
|
@ -400,6 +400,9 @@ the server tab on new connection"
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
<div v-if="disabledReason && disabled" class="disabled-reason">
|
||||||
|
{{ disabledReason }}
|
||||||
|
</div>
|
||||||
<button type="submit" class="btn" :disabled="disabled ? true : false">
|
<button type="submit" class="btn" :disabled="disabled ? true : false">
|
||||||
<template v-if="defaults.uuid">Save network</template>
|
<template v-if="defaults.uuid">Save network</template>
|
||||||
<template v-else>Connect</template>
|
<template v-else>Connect</template>
|
||||||
|
@ -409,7 +412,7 @@ the server tab on new connection"
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style scoped>
|
||||||
#connect .connect-auth {
|
#connect .connect-auth {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
@ -435,6 +438,11 @@ the server tab on new connection"
|
||||||
margin: 0;
|
margin: 0;
|
||||||
user-select: text;
|
user-select: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.disabled-reason {
|
||||||
|
margin-top: 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -464,6 +472,7 @@ export default defineComponent({
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
disabled: Boolean,
|
disabled: Boolean,
|
||||||
|
disabledReason: String,
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<NetworkForm :handle-submit="handleSubmit" :defaults="defaults" :disabled="disabled" />
|
<NetworkForm
|
||||||
|
:disabled-reason="disabledReason"
|
||||||
|
:handle-submit="handleSubmit"
|
||||||
|
:defaults="defaults"
|
||||||
|
:disabled="disabled"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {defineComponent, ref} from "vue";
|
import {defineComponent, onMounted, ref} from "vue";
|
||||||
|
|
||||||
import socket from "../../js/socket";
|
import socket from "../../js/socket";
|
||||||
import {useStore} from "../../js/store";
|
import {useStore} from "../../js/store";
|
||||||
|
@ -21,12 +26,28 @@ export default defineComponent({
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|
||||||
const disabled = ref(false);
|
const disabled = ref(false);
|
||||||
|
const disabledReason = ref("");
|
||||||
|
|
||||||
const handleSubmit = (data: Record<string, any>) => {
|
const handleSubmit = (data: Record<string, any>) => {
|
||||||
disabled.value = true;
|
disabled.value = true;
|
||||||
socket.emit("network:new", data);
|
socket.emit("network:new", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (
|
||||||
|
store.state.serverConfiguration?.lockNetwork &&
|
||||||
|
store.state.serverConfiguration?.allowMultipleSameHostConnections
|
||||||
|
) {
|
||||||
|
if (store.state.networks.length > 0) {
|
||||||
|
disabled.value = true;
|
||||||
|
disabledReason.value = "You have already connected and cannot connect again.";
|
||||||
|
} else {
|
||||||
|
disabled.value = false;
|
||||||
|
disabledReason.value = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const parseOverrideParams = (params?: Record<string, string>) => {
|
const parseOverrideParams = (params?: Record<string, string>) => {
|
||||||
if (!params) {
|
if (!params) {
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -285,6 +285,15 @@ module.exports = {
|
||||||
// This value is set to `false` by default.
|
// This value is set to `false` by default.
|
||||||
lockNetwork: false,
|
lockNetwork: false,
|
||||||
|
|
||||||
|
// ### `sameHostLockedNetworkConnections`
|
||||||
|
//
|
||||||
|
// When set to `true`, users will be able to connect to the configured
|
||||||
|
// network multiple times. This can be useful if you connect to
|
||||||
|
// a bouncer like ZNC. Requires `lockNetwork` to be set to `true`.
|
||||||
|
//
|
||||||
|
// This value is set to `false` by default.
|
||||||
|
allowMultipleSameHostConnections: false,
|
||||||
|
|
||||||
// ## User management
|
// ## User management
|
||||||
|
|
||||||
// ### `messageStorage`
|
// ### `messageStorage`
|
||||||
|
|
|
@ -102,6 +102,7 @@ export type ConfigType = {
|
||||||
leaveMessage: string;
|
leaveMessage: string;
|
||||||
defaults: Defaults;
|
defaults: Defaults;
|
||||||
lockNetwork: boolean;
|
lockNetwork: boolean;
|
||||||
|
allowMultipleSameHostConnections: boolean;
|
||||||
messageStorage: string[];
|
messageStorage: string[];
|
||||||
storagePolicy: StoragePolicy;
|
storagePolicy: StoragePolicy;
|
||||||
useHexIp: boolean;
|
useHexIp: boolean;
|
||||||
|
|
|
@ -47,7 +47,12 @@ type IndexTemplateConfiguration = ServerConfiguration & {
|
||||||
|
|
||||||
export type ClientConfiguration = Pick<
|
export type ClientConfiguration = Pick<
|
||||||
ConfigType,
|
ConfigType,
|
||||||
"public" | "lockNetwork" | "useHexIp" | "prefetch" | "defaults"
|
| "public"
|
||||||
|
| "lockNetwork"
|
||||||
|
| "useHexIp"
|
||||||
|
| "prefetch"
|
||||||
|
| "defaults"
|
||||||
|
| "allowMultipleSameHostConnections"
|
||||||
> & {
|
> & {
|
||||||
fileUpload: boolean;
|
fileUpload: boolean;
|
||||||
ldapEnabled: boolean;
|
ldapEnabled: boolean;
|
||||||
|
@ -479,6 +484,12 @@ function initializeClient(
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("network:new", (data) => {
|
socket.on("network:new", (data) => {
|
||||||
|
if (Config.values.lockNetwork && Config.values.allowMultipleSameHostConnections) {
|
||||||
|
if (client.networks.length > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_.isPlainObject(data)) {
|
if (_.isPlainObject(data)) {
|
||||||
// prevent people from overriding webirc settings
|
// prevent people from overriding webirc settings
|
||||||
data.uuid = null;
|
data.uuid = null;
|
||||||
|
@ -863,6 +874,8 @@ function getClientConfiguration(): ClientConfiguration {
|
||||||
"lockNetwork",
|
"lockNetwork",
|
||||||
"useHexIp",
|
"useHexIp",
|
||||||
"prefetch",
|
"prefetch",
|
||||||
|
"allowMultipleSameHostConnections",
|
||||||
|
// TODO: remove this type cast
|
||||||
]) as ClientConfiguration;
|
]) as ClientConfiguration;
|
||||||
|
|
||||||
config.fileUpload = Config.values.fileUpload.enable;
|
config.fileUpload = Config.values.fileUpload.enable;
|
||||||
|
|
Loading…
Reference in a new issue