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