|
1 | 1 | import { acceptHMRUpdate, defineStore, storeToRefs } from "pinia"; |
2 | | -import { computed, reactive, Ref, ref } from "vue"; |
| 2 | +import { computed, reactive, Ref, ref, watch } from "vue"; |
3 | 3 | import Header from "@/resources/Header"; |
4 | 4 | import type EndpointDetails from "@/resources/EndpointDetails"; |
5 | 5 | import { FailedMessage, ExceptionDetails, FailedMessageStatus } from "@/resources/FailedMessage"; |
6 | | -import { useEditRetryStore } from "@/stores/EditRetryStore"; |
7 | 6 | import { useConfigurationStore } from "@/stores/ConfigurationStore"; |
8 | 7 | import Message, { MessageStatus } from "@/resources/Message"; |
9 | 8 | import moment from "moment/moment"; |
10 | 9 | import { parse, stringify } from "lossless-json"; |
11 | 10 | import xmlFormat from "xml-formatter"; |
12 | 11 | import { DataContainer } from "./DataContainer"; |
13 | 12 | import { useServiceControlStore } from "./ServiceControlStore"; |
| 13 | +import { EditAndRetryConfig } from "@/resources/Configuration"; |
14 | 14 | import EditRetryResponse from "@/resources/EditRetryResponse"; |
15 | 15 | import { EditedMessage } from "@/resources/EditMessage"; |
16 | 16 | import useEnvironmentAndVersionsAutoRefresh from "@/composables/useEnvironmentAndVersionsAutoRefresh"; |
@@ -65,22 +65,28 @@ export const useMessageStore = defineStore("MessageStore", () => { |
65 | 65 | const headers = ref<DataContainer<Header[]>>({ data: [] }); |
66 | 66 | const body = ref<DataContainer<{ value?: string; content_type?: string; no_content?: boolean }>>({ data: {} }); |
67 | 67 | const state = reactive<DataContainer<Model>>({ data: { failure_metadata: {}, failure_status: {}, dialog_status: {}, invoked_saga: {} } }); |
| 68 | + const edit_and_retry_config = ref<EditAndRetryConfig>({ enabled: false, locked_headers: [], sensitive_headers: [] }); |
| 69 | + const conversationData = ref<DataContainer<Message[]>>({ data: [] }); |
| 70 | + |
68 | 71 | const editRetryResponse = ref<EditRetryResponse | null>(null); |
69 | 72 | let bodyLoadedId = ""; |
70 | 73 | let conversationLoadedId = ""; |
71 | | - const conversationData = ref<DataContainer<Message[]>>({ data: [] }); |
72 | | - const editRetryStore = useEditRetryStore(); |
| 74 | + |
73 | 75 | const configStore = useConfigurationStore(); |
74 | 76 | const serviceControlStore = useServiceControlStore(); |
| 77 | + const { serviceControlUrl } = storeToRefs(serviceControlStore); |
75 | 78 | const { store: environmentStore } = useEnvironmentAndVersionsAutoRefresh(); |
76 | 79 | const areSimpleHeadersSupported = environmentStore.serviceControlIsGreaterThan("5.2.0"); |
77 | 80 |
|
78 | | - const { config: edit_and_retry_config } = storeToRefs(editRetryStore); |
79 | 81 | const { configuration } = storeToRefs(configStore); |
80 | 82 | const error_retention_period = computed(() => moment.duration(configuration.value?.data_retention?.error_retention_period).asHours()); |
81 | 83 |
|
82 | | - // eslint-disable-next-line promise/catch-or-return,promise/prefer-await-to-then,promise/valid-params |
83 | | - Promise.all([editRetryStore.loadConfig(), configStore.refresh()]).then(); |
| 84 | + watch(serviceControlUrl, loadConfig, { immediate: true }); |
| 85 | + async function loadConfig() { |
| 86 | + if (!serviceControlUrl.value) return; |
| 87 | + const [, data] = await serviceControlStore.fetchTypedFromServiceControl<EditAndRetryConfig>("edit/config"); |
| 88 | + edit_and_retry_config.value = data; |
| 89 | + } |
84 | 90 |
|
85 | 91 | function reset() { |
86 | 92 | state.data = { failure_metadata: {}, failure_status: {}, dialog_status: {}, invoked_saga: {} }; |
|
0 commit comments