Skip to content

Commit

Permalink
always show datasources via pplservice
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <dxho@amazon.com>
  • Loading branch information
derek-ho committed Sep 15, 2023
1 parent 4f7d999 commit 011308f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import React, { useEffect, useState } from 'react';
import { NoAccess } from './no_access';
import { DATACONNECTIONS_BASE } from '../../../../common/constants/shared';
import { coreRefs } from '../../../../public/framework/core_refs';

interface DatasourceDetails {
allowedRoles: string[];
Expand All @@ -31,13 +32,14 @@ interface DatasourceDetails {
}

export const DataConnection = (props: any) => {
const { dataSource, http } = props;
const { dataSource } = props;
const [datasourceDetails, setDatasourceDetails] = useState<DatasourceDetails>({
allowedRoles: [],
name: '',
cluster: '',
});
const [hasAccess, setHasAccess] = useState(true);
const { http } = coreRefs;

useEffect(() => {
http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import React, { useEffect, useState } from 'react';
import { DataConnectionsHeader } from './data_connections_header';
import { HomeProps } from '../home';
import { DataConnectionsDescription } from './manage_data_connections_description';
import { DATACONNECTIONS_BASE } from '../../../../common/constants/shared';
import { ChromeStart } from '../../../../../../src/core/public';
import { NoAccess } from './no_access';

interface DataConnection {
connectionType: 'OPENSEARCH' | 'SPARK';
Expand All @@ -47,20 +45,13 @@ export const ManageDataConnectionsTable = (props: HomeProps) => {
}, [chrome]);

async function handleDataRequest() {
http
.get(`${DATACONNECTIONS_BASE}`)
.then((dataconnections) =>
setData(
dataconnections.map((x: any) => {
return { name: x.name, connectionType: x.connector };
})
)
pplService!.fetch({ query: 'show datasources', format: 'jdbc' }).then((dataconnections) =>
setData(
dataconnections.jsonData.map((x: any) => {
return { name: x.DATASOURCE_NAME, connectionType: x.CONNECTOR_TYPE };
})
)
.catch((err) => {
if (err.body.statusCode === 403) {
setHasAccess(false);
}
});
);
}

const icon = (record: DataConnection) => {
Expand Down Expand Up @@ -144,17 +135,6 @@ export const ManageDataConnectionsTable = (props: HomeProps) => {
return { connectionType, name, data: { name, connectionType } };
});

if (!hasAccess) {
return (
<EuiPage>
<EuiPageBody component="div">
<DataConnectionsHeader />
<NoAccess />
</EuiPageBody>
</EuiPage>
);
}

return (
<EuiPage>
<EuiPageBody component="div">
Expand Down
13 changes: 1 addition & 12 deletions public/components/data_connections/components/no_access.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import {
EuiButton,
EuiEmptyPrompt,
EuiLink,
EuiPage,
EuiPageHeader,
EuiPageHeaderSection,
EuiPanel,
EuiSpacer,
EuiText,
EuiTitle,
} from '@elastic/eui';
import { EuiButton, EuiEmptyPrompt, EuiPage, EuiPanel, EuiText } from '@elastic/eui';
import _ from 'lodash';
import React from 'react';
import { OPENSEARCH_DOCUMENTATION_URL } from '../../../../common/constants/data_connections';
Expand Down

0 comments on commit 011308f

Please sign in to comment.