Skip to content

Commit

Permalink
Use HTTP service instead of fetch
Browse files Browse the repository at this point in the history
Signed-off-by: Jialiang Liang <[email protected]>
  • Loading branch information
RyanL1997 committed Dec 11, 2024
1 parent 9f23442 commit e1671ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ export const CreateAcceleration = ({
resetFlyout={resetFlyout}
notifications={notifications}
application={application}
http={http}
/>
</EuiForm>
</EuiFlyoutBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
EuiText,
} from '@elastic/eui';
import React, { useEffect, useState } from 'react';
import { ApplicationStart, NotificationsStart } from 'opensearch-dashboards/public';
import { ApplicationStart, NotificationsStart, HttpStart } from 'opensearch-dashboards/public';
import {
queryWorkbenchPluginCheck,
queryWorkbenchPluginID,
Expand All @@ -28,6 +28,7 @@ interface PreviewSQLDefinitionProps {
resetFlyout: () => void;
notifications: NotificationsStart;
application: ApplicationStart;
http: HttpStart;
}

export const PreviewSQLDefinition = ({
Expand All @@ -36,6 +37,7 @@ export const PreviewSQLDefinition = ({
resetFlyout,
notifications,
application,
http,
}: PreviewSQLDefinitionProps) => {
const [isPreviewStale, setIsPreviewStale] = useState(false);
const [isPreviewTriggered, setIsPreviewTriggered] = useState(false);
Expand All @@ -60,23 +62,10 @@ export const PreviewSQLDefinition = ({
};

const checkIfSQLWorkbenchPluginIsInstalled = () => {
fetch('/api/status', {
headers: {
'Content-Type': 'application/json',
'osd-xsrf': 'true',
'accept-language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,zh-TW;q=0.6',
pragma: 'no-cache',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
},
method: 'GET',
referrerPolicy: 'strict-origin-when-cross-origin',
mode: 'cors',
credentials: 'include',
})
http

Check warning on line 65 in src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_creation/selectors/preview_sql_defintion.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_creation/selectors/preview_sql_defintion.tsx#L65

Added line #L65 was not covered by tests
.get('/api/status')
.then(function (response) {
return response.json();
return response;

Check warning on line 68 in src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_creation/selectors/preview_sql_defintion.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data_source_management/public/components/direct_query_data_sources_components/acceleration_creation/selectors/preview_sql_defintion.tsx#L68

Added line #L68 was not covered by tests
})
.then((data) => {
for (let i = 0; i < data.status.statuses.length; ++i) {
Expand Down

0 comments on commit e1671ed

Please sign in to comment.