From c441f8a1ec83dee654cd64e418090f1fe1dfc137 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Thu, 7 Dec 2023 10:35:25 +0100 Subject: [PATCH] fix(ui) uxt fixes --- .../components/UsabilityTesting/SidePanel.tsx | 6 +++--- .../components/UsabilityTesting/TestEdit.tsx | 20 +++++++++++++++---- .../UsabilityTesting/UsabilityTesting.tsx | 10 +++++----- frontend/app/utils/index.ts | 4 +++- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/frontend/app/components/UsabilityTesting/SidePanel.tsx b/frontend/app/components/UsabilityTesting/SidePanel.tsx index 17c766bbc..e6f798b90 100644 --- a/frontend/app/components/UsabilityTesting/SidePanel.tsx +++ b/frontend/app/components/UsabilityTesting/SidePanel.tsx @@ -4,7 +4,7 @@ import { observer } from 'mobx-react-lite'; import { Typography, Switch, Button, Space, Tooltip } from 'antd'; import { ExportOutlined } from '@ant-design/icons'; -const SidePanel = observer(({ onSave, onPreview, taskLen }: any) => { +const SidePanel = observer(({ onSave, onPreview, taskLen, isStartingPointValid }: any) => { const { uxtestingStore } = useStore(); return (
@@ -38,14 +38,14 @@ const SidePanel = observer(({ onSave, onPreview, taskLen }: any) => {
- - diff --git a/frontend/app/components/UsabilityTesting/TestEdit.tsx b/frontend/app/components/UsabilityTesting/TestEdit.tsx index bc9d3da78..6cfa67326 100644 --- a/frontend/app/components/UsabilityTesting/TestEdit.tsx +++ b/frontend/app/components/UsabilityTesting/TestEdit.tsx @@ -1,4 +1,5 @@ import { Button, Input, Typography, Dropdown, Modal } from 'antd'; +import { isValidUrl } from 'App/utils'; import React from 'react'; import { withSiteId, @@ -16,7 +17,7 @@ import { confirm } from 'UI'; import StepsModal from './StepsModal'; import SidePanel from './SidePanel'; import usePageTitle from 'App/hooks/usePageTitle'; -import { toast } from 'react-toastify' +import { toast } from 'react-toastify'; const menuItems = [ { @@ -119,6 +120,8 @@ function TestEdit() { const isPublished = uxtestingStore.instance.status !== undefined && uxtestingStore.instance.status !== 'preview'; + const isStartingPointValid = isValidUrl(uxtestingStore.instance.startingPath); + return (
{ setHasChanged(true); if (!e.target.value.startsWith('https://')) { - e.target.value = 'https://' + e.target.value; + e.target.value = 'https://'; } uxtestingStore.instance!.setProperty('startingPath', e.target.value); }} /> - Test will begin on this page. + {uxtestingStore.instance!.startingPath === 'https://' || isStartingPointValid ? ( + Test will begin on this page. + ) : ( + Starting point URL is invalid. + )}
@@ -381,6 +388,7 @@ function TestEdit() {
onSave(false)} onPreview={() => onSave(true)} @@ -404,7 +412,11 @@ export function Step({ hover?: boolean; }) { return ( -
+
{ind + 1}
diff --git a/frontend/app/components/UsabilityTesting/UsabilityTesting.tsx b/frontend/app/components/UsabilityTesting/UsabilityTesting.tsx index 839621d95..11ba2e859 100644 --- a/frontend/app/components/UsabilityTesting/UsabilityTesting.tsx +++ b/frontend/app/components/UsabilityTesting/UsabilityTesting.tsx @@ -95,7 +95,7 @@ function TestsTable() { /> Test Objective (optional) setNewTestDescription(e.target.value)} placeholder="Share a brief statement about what you aim to discover through this study." @@ -175,10 +175,10 @@ function TestsTable() { } const statusMap = { - preview: "Preview", - 'in-progress': "In progress", - paused: "Paused", - closed: "Completed", + preview: "Draft", + 'in-progress': "Ongoing", + paused: "On Hold", + closed: "Closed", } function Row({ test, siteId }: { test: UxTListEntry, siteId: string }) { diff --git a/frontend/app/utils/index.ts b/frontend/app/utils/index.ts index 3b9f2d3ea..bb7d32e3a 100644 --- a/frontend/app/utils/index.ts +++ b/frontend/app/utils/index.ts @@ -464,4 +464,6 @@ export const checkParam = (paramName: string, storageKey?: string, search?: stri } return existsAndTrue; -}; \ No newline at end of file +}; + +export const isValidUrl = (url) => /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/.test(url); \ No newline at end of file