Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding prompt when datasource is not compatible #608

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions public/pages/workflows/new_workflow/new_workflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
EuiFlexGroup,
EuiCompressedFieldSearch,
EuiLoadingSpinner,
EuiEmptyPrompt,
EuiButton,
} from '@elastic/eui';
import { useSelector } from 'react-redux';
import { UseCase } from './use_case';
Expand All @@ -27,7 +29,11 @@ import {
searchConnectors,
} from '../../../store';
import { enrichPresetWorkflowWithUiMetadata } from './utils';
import { getDataSourceId, isDataSourceReady } from '../../../utils';
import {
getDataSourceId,
isDataSourceReady,
getAppBasePath,
} from '../../../utils';
import { getDataSourceEnabled } from '../../../services';
import semver from 'semver';
import { DataSourceAttributes } from '../../../../../../src/plugins/data_source/common/data_sources';
Expand Down Expand Up @@ -118,6 +124,9 @@ export function NewWorkflow(props: NewWorkflowProps) {
WorkflowTemplate[]
>([]);
const [isVersionLoading, setIsVersionLoading] = useState(false);
const [isDataSourceIncompatible, setIsDataSourceIncompatible] = useState(
false
);

// search bar state
const [searchQuery, setSearchQuery] = useState<string>('');
Expand Down Expand Up @@ -159,16 +168,19 @@ export function NewWorkflow(props: NewWorkflowProps) {
setAllWorkflows(enrichedWorkflows);
setFilteredWorkflows(enrichedWorkflows);
setIsVersionLoading(false);
setIsDataSourceIncompatible(false);
return;
}

if (!dataSourceId) {
setAllWorkflows([]);
setFilteredWorkflows([]);
setIsVersionLoading(true);
setIsVersionLoading(false);
setIsDataSourceIncompatible(true);
return;
}

setIsDataSourceIncompatible(false);
setIsVersionLoading(true);

const version = await getEffectiveVersion(dataSourceId);
Expand Down Expand Up @@ -219,6 +231,23 @@ export function NewWorkflow(props: NewWorkflowProps) {
<EuiLoadingSpinner size="xl" />
</EuiFlexItem>
</EuiFlexGroup>
) : isDataSourceIncompatible ? (
<EuiEmptyPrompt
title={<h2>Incompatible data source</h2>}
body={
<p>{`No compatible data source available.
Add a compatible data source.`}</p>
}
actions={
<EuiButton
color="primary"
fill
href={`${getAppBasePath()}/app/management/opensearch-dashboards/dataSources`}
>
Manage data sources
</EuiButton>
}
/>
) : (
<EuiFlexGrid columns={3} gutterSize="l">
{filteredWorkflows.map((workflow: Workflow, index) => {
Expand Down
5 changes: 5 additions & 0 deletions public/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ export const BREADCRUMBS = Object.freeze({
});

export const USE_NEW_HOME_PAGE = getUISettings().get('home:useNewHomePage');

export const getAppBasePath = () => {
const currentPath = window.location.pathname;
return currentPath.substring(0, currentPath.indexOf('/app/'));
};
Loading