From d047f5e6d2715ad1555d1d6014ef2959b4ba647c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:13:44 +0300 Subject: [PATCH] Chore (URL): CNX-9018 Do not add model from multi model urls - warn user and return - otherwise add --- ui/src/components/dialogs/CreateStreamDialog.vue | 7 +++++++ ui/src/utils/streamWrapper.js | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/src/components/dialogs/CreateStreamDialog.vue b/ui/src/components/dialogs/CreateStreamDialog.vue index 86298d6f..4101b166 100644 --- a/ui/src/components/dialogs/CreateStreamDialog.vue +++ b/ui/src/components/dialogs/CreateStreamDialog.vue @@ -206,6 +206,13 @@ export default { async getStream(){ try { const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl) + const match = streamWrapper.matchUrl(this.createStreamByIdText) + if (match.groups.additionalModels !== undefined){ + this.$eventHub.$emit('error', { + text: 'Multi-model URLs are not supported!\nTry to select just one single model in the web app and paste that in.', + }) + return + } let res = await this.$apollo.query({ query: gql` query Stream($id: String!){ diff --git a/ui/src/utils/streamWrapper.js b/ui/src/utils/streamWrapper.js index 1a3d2e3b..92a596be 100644 --- a/ui/src/utils/streamWrapper.js +++ b/ui/src/utils/streamWrapper.js @@ -17,9 +17,13 @@ export class StreamWrapper { } } - checkIsFE2(streamUrl){ + matchUrl(streamUrl){ const fe2UrlRegex = /\/projects\/(?[\w\d]+)(?:\/models\/(?[\w\d]+(?:@[\w\d]+)?)(?:,(?[\w\d]+(?:@[\w\d]+)?))*)?/ - const match = fe2UrlRegex.exec(streamUrl); + return fe2UrlRegex.exec(streamUrl); + } + + checkIsFE2(streamUrl){ + const match = this.matchUrl(streamUrl) return match !== null; }