Skip to content

Commit 1c59ed1

Browse files
authored
chore: display prompt error message (#32016)
1 parent ade5d03 commit 1c59ed1

File tree

3 files changed

+81
-10
lines changed

3 files changed

+81
-10
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<template>
2+
<div class="max-h-[700px] w-[912px] overflow-auto bg-gray-1000 rounded mx-auto ring-[#9095AD40] ring-4 relative">
3+
<div class="px-[24px] py-[12px] flex items-center justify-between border-b border-gray-900">
4+
<div class="flex items-center gap-2">
5+
<span class="text-white text-sm">cy.prompt</span>
6+
<div class="w-[32px] h-[1px] bg-gray-900" />
7+
<span class="text-gray-300 text-sm">Get code</span>
8+
</div>
9+
<IconActionDeleteLarge
10+
stroke-color="gray-400"
11+
class="cursor-pointer"
12+
data-cy="close-modal-button"
13+
@click="onClose"
14+
/>
15+
</div>
16+
<div
17+
class="flex flex-col items-center justify-center h-[272px] p-[24px] gap-[24px]"
18+
data-cy="error-message"
19+
>
20+
<IconTechnologyDashboardFail
21+
size="48"
22+
stroke-color="gray-500"
23+
fill-color="gray-900"
24+
/>
25+
<div class="flex flex-col gap-[4px] text-center">
26+
<span class="text-white">Something went wrong</span>
27+
<span class="text-gray-200 text-sm">
28+
There was a problem with loading the prompt code. Our team has been
29+
notified. If the problem persists, please try again later.
30+
</span>
31+
</div>
32+
</div>
33+
34+
<div class="px-[24px] py-[12px] mt-[12px] border-t border-gray-900 bg-gray-950">
35+
<Button
36+
data-cy="close-modal-button"
37+
@click="onClose"
38+
>
39+
Close
40+
</Button>
41+
</div>
42+
</div>
43+
</template>
44+
45+
<script setup lang="ts">
46+
import {
47+
IconActionDeleteLarge,
48+
IconTechnologyDashboardFail,
49+
} from '@cypress-design/vue-icon'
50+
import Button from '@cypress-design/vue-button'
51+
52+
defineProps<{
53+
onClose: () => void
54+
}>()
55+
</script>

packages/app/src/prompt/PromptGetCodeModal.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
>
99
<div class="flex min-h-screen items-center justify-center">
1010
<DialogOverlay class="bg-gray-800 opacity-90 fixed sm:inset-0" />
11-
<div ref="container" />
11+
<PromptErrorMessage
12+
v-if="hasError"
13+
:on-close="closeModal"
14+
/>
15+
<div
16+
v-else
17+
ref="container"
18+
/>
1219
</div>
1320
</Dialog>
1421
</template>
@@ -19,6 +26,7 @@ import { init, loadRemote } from '@module-federation/runtime'
1926
import { ref, onMounted, onBeforeUnmount } from 'vue'
2027
import type { CyPromptAppDefaultShape, GetCodeModalContentsShape } from './prompt-app-types'
2128
import { usePromptStore } from '../store/prompt-store'
29+
import PromptErrorMessage from './PromptErrorMessage.vue'
2230
2331
interface CyPromptApp { default: CyPromptAppDefaultShape }
2432
@@ -44,13 +52,13 @@ const closeModal = () => {
4452
}
4553
4654
const container = ref<HTMLDivElement | null>(null)
47-
const error = ref<string | null>(null)
55+
const hasError = ref<boolean>(false)
4856
const ReactGetCodeModalContents = ref<GetCodeModalContentsShape | null>(null)
4957
const containerReactRootMap = new WeakMap<HTMLElement, Root>()
5058
const promptStore = usePromptStore()
5159
5260
const maybeRenderReactComponent = () => {
53-
if (!ReactGetCodeModalContents.value || !!error.value || !container.value) {
61+
if (!ReactGetCodeModalContents.value || !!hasError.value || !container.value) {
5462
return
5563
}
5664
@@ -122,15 +130,15 @@ init({
122130
// means that the bundle has been downloaded
123131
loadRemote<CyPromptApp>('cy-prompt').then((module) => {
124132
if (!module?.default) {
125-
error.value = 'The panel was not loaded successfully'
133+
hasError.value = true
126134
127135
return
128136
}
129137
130138
ReactGetCodeModalContents.value = module.default.GetCodeModalContents
131139
maybeRenderReactComponent()
132140
}).catch((e) => {
133-
error.value = e.message
141+
hasError.value = true
134142
})
135143
136144
</script>

packages/app/src/prompt/PromptMoreInfoNeededModal.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
>
99
<div class="flex min-h-screen items-center justify-center">
1010
<DialogOverlay class="bg-gray-800 opacity-90 fixed sm:inset-0" />
11-
<div ref="container" />
11+
<PromptErrorMessage
12+
v-if="hasError"
13+
:on-close="closeModal"
14+
/>
15+
<div
16+
v-else
17+
ref="container"
18+
/>
1219
</div>
1320
</Dialog>
1421
</template>
@@ -19,6 +26,7 @@ import { init, loadRemote } from '@module-federation/runtime'
1926
import { ref, onMounted, onBeforeUnmount } from 'vue'
2027
import type { CyPromptAppDefaultShape, MoreInfoNeededModalContentsShape } from './prompt-app-types'
2128
import { usePromptStore } from '../store/prompt-store'
29+
import PromptErrorMessage from './PromptErrorMessage.vue'
2230
2331
interface CyPromptApp { default: CyPromptAppDefaultShape }
2432
@@ -44,13 +52,13 @@ const closeModal = () => {
4452
}
4553
4654
const container = ref<HTMLDivElement | null>(null)
47-
const error = ref<string | null>(null)
55+
const hasError = ref<boolean>(false)
4856
const ReactMoreInfoNeededModalContents = ref<MoreInfoNeededModalContentsShape | null>(null)
4957
const containerReactRootMap = new WeakMap<HTMLElement, Root>()
5058
const promptStore = usePromptStore()
5159
5260
const maybeRenderReactComponent = () => {
53-
if (!ReactMoreInfoNeededModalContents.value || !!error.value || !container.value) {
61+
if (!ReactMoreInfoNeededModalContents.value || !!hasError.value || !container.value) {
5462
return
5563
}
5664
@@ -124,15 +132,15 @@ init({
124132
// means that the bundle has been downloaded
125133
loadRemote<CyPromptApp>('cy-prompt').then((module) => {
126134
if (!module?.default) {
127-
error.value = 'The panel was not loaded successfully'
135+
hasError.value = true
128136
129137
return
130138
}
131139
132140
ReactMoreInfoNeededModalContents.value = module.default.MoreInfoNeededModalContents
133141
maybeRenderReactComponent()
134142
}).catch((e) => {
135-
error.value = e.message
143+
hasError.value = true
136144
})
137145
138146
</script>

0 commit comments

Comments
 (0)