;
}
const onSave = (isPreview?: boolean) => {
setHasChanged(false);
if (testId && testId !== 'new') {
uxtestingStore
.updateTest(uxtestingStore.instance!, isPreview)
.then((testId) => {
if (isPreview) {
window.open(
`${uxtestingStore.instance!.startingPath}?oruxt=${testId}`,
'_blank',
'noopener,noreferrer',
);
} else {
toast.success(
t(
'The usability test is now live and accessible to participants.',
),
);
history.push(
withSiteId(usabilityTestingView(testId!.toString()), siteId),
);
}
});
} else {
uxtestingStore.createNewTest(isPreview).then((test) => {
if (isPreview) {
window.open(
`${test.startingPath}?oruxt=${test.testId}`,
'_blank',
'noopener,noreferrer',
);
history.replace(
withSiteId(usabilityTestingEdit(test.testId), siteId),
);
} else {
history.push(withSiteId(usabilityTestingView(test.testId), siteId));
}
});
}
};
const onClose = (confirmed: boolean) => {
if (confirmed) {
uxtestingStore.instance!.setProperty('title', newTestTitle);
uxtestingStore.instance!.setProperty('description', newTestDescription);
}
setNewTestDescription('');
setNewTestTitle('');
setIsModalVisible(false);
};
const onMenuClick = async ({ key }: { key: string }) => {
if (key === '1') {
setNewTestTitle(uxtestingStore.instance!.title);
setNewTestDescription(uxtestingStore.instance!.description);
setIsModalVisible(true);
}
if (key === '2') {
if (
await confirm({
confirmation: t(
'Are you sure you want to delete this usability test? This action cannot be undone.',
),
})
) {
uxtestingStore.deleteTest(testId).then(() => {
history.push(withSiteId(usabilityTesting(), siteId));
});
}
}
};
const isPublished =
uxtestingStore.instance.status !== undefined &&
uxtestingStore.instance.status !== 'preview';
const isStartingPointValid = isValidUrl(uxtestingStore.instance.startingPath);
return (
t('You have unsaved changes. Are you sure you want to leave?')
}
/>
onClose(true)}
onCancel={() => onClose(false)}
footer={
}
>
{t('Title')}
{
setHasChanged(true);
setNewTestTitle(e.target.value);
}}
/>
{t('Test Objective (optional)')}
{
setHasChanged(true);
setNewTestDescription(e.target.value);
}}
placeholder={t(
'Share a brief statement about what you aim to discover through this study.',
)}
/>
{t('Starting point')}
{
setHasChanged(true);
let { value } = e.target;
if (value.startsWith('https://')) {
value = value.replace('https://', '');
}
uxtestingStore.instance!.setProperty(
'startingPath',
`https://${value}`,
);
}}
/>
{uxtestingStore.instance!.startingPath === 'https://' ||
isStartingPointValid ? (
{t('The test will start on this page. A special link from this will be created for you to share with participants only.')}
) : (
{t('Invalid starting point.')}
)}
{t('Introduction and Guidelines for Participants')}
{isOverviewEditing ? (
{
setHasChanged(true);
setGuidelines(e.target.value);
}}
/>
) : (
{uxtestingStore.instance?.guidelines?.length
? uxtestingStore.instance.guidelines
: t(
'Provide an overview of this usability test to and input guidelines that can be of assistance to users at any point during the test.',
)}