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

[Feature] Multi-data Source Support for Getting Started #2048

Merged
merged 8 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports[`Log Config component renders empty log config 1`] = `
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction],
"getIsVisible$": [MockFunction],
Expand Down Expand Up @@ -119,6 +120,7 @@ exports[`Log Config component renders empty log config 1`] = `
"setBreadcrumbs": [MockFunction],
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down Expand Up @@ -649,6 +651,7 @@ exports[`Log Config component renders with query 1`] = `
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction],
"getIsVisible$": [MockFunction],
Expand Down Expand Up @@ -752,6 +755,7 @@ exports[`Log Config component renders with query 1`] = `
"setBreadcrumbs": [MockFunction],
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports[`Service Config component renders empty service config 1`] = `
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction],
"getIsVisible$": [MockFunction],
Expand Down Expand Up @@ -119,6 +120,7 @@ exports[`Service Config component renders empty service config 1`] = `
"setBreadcrumbs": [MockFunction],
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down Expand Up @@ -1219,6 +1221,7 @@ exports[`Service Config component renders with one service selected 1`] = `
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction],
"getIsVisible$": [MockFunction],
Expand Down Expand Up @@ -1322,6 +1325,7 @@ exports[`Service Config component renders with one service selected 1`] = `
"setBreadcrumbs": [MockFunction],
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports[`Trace Config component renders empty trace config 1`] = `
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction],
"getIsVisible$": [MockFunction],
Expand Down Expand Up @@ -118,6 +119,7 @@ exports[`Trace Config component renders empty trace config 1`] = `
"setBreadcrumbs": [MockFunction],
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down Expand Up @@ -931,6 +933,7 @@ exports[`Trace Config component renders with one trace selected 1`] = `
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction],
"getIsVisible$": [MockFunction],
Expand Down Expand Up @@ -1034,6 +1037,7 @@ exports[`Trace Config component renders with one trace selected 1`] = `
"setBreadcrumbs": [MockFunction],
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,7 @@ exports[`Panels View Component renders panel view container with visualizations
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction] {
"calls": Array [
Expand Down Expand Up @@ -1285,6 +1286,7 @@ exports[`Panels View Component renders panel view container with visualizations
},
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down Expand Up @@ -2692,6 +2694,7 @@ exports[`Panels View Component renders panel view container with visualizations
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction] {
"calls": Array [
Expand Down Expand Up @@ -3089,6 +3092,7 @@ exports[`Panels View Component renders panel view container with visualizations
},
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down Expand Up @@ -3259,6 +3263,7 @@ exports[`Panels View Component renders panel view container without visualizatio
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction] {
"calls": Array [
Expand Down Expand Up @@ -3545,6 +3550,7 @@ exports[`Panels View Component renders panel view container without visualizatio
},
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down Expand Up @@ -4947,6 +4953,7 @@ exports[`Panels View Component renders panel view container without visualizatio
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction] {
"calls": Array [
Expand Down Expand Up @@ -5233,6 +5240,7 @@ exports[`Panels View Component renders panel view container without visualizatio
},
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports[`Panel Grid Component renders panel grid component with empty visualizat
"getBreadcrumbsEnricher$": [MockFunction],
"getCustomNavLink$": [MockFunction],
"getHeaderComponent": [MockFunction],
"getHeaderVariant$": [MockFunction],
"getHelpExtension$": [MockFunction],
"getIsNavDrawerLocked$": [MockFunction] {
"calls": Array [
Expand Down Expand Up @@ -276,6 +277,7 @@ exports[`Panel Grid Component renders panel grid component with empty visualizat
"setBreadcrumbs": [MockFunction],
"setBreadcrumbsEnricher": [MockFunction],
"setCustomNavLink": [MockFunction],
"setHeaderVariant": [MockFunction],
"setHelpExtension": [MockFunction],
"setHelpSupportUrl": [MockFunction],
"setIsVisible": [MockFunction],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ exports[`Saved query table component Renders saved query table 1`] = `
showLabel={true}
>
<div
className="euiSwitch euiSwitch--compressed"
className="euiSwitch euiSwitch--primary euiSwitch--compressed euiSwitch-isDisabled"
>
<button
aria-checked={false}
Expand Down
22 changes: 14 additions & 8 deletions public/components/getting_started/components/getting_started.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ import { GettingStartedConnectionsHeader } from './getting_started_header';
import { CollectAndShipData } from './getting_started_collectData';
import { QueryAndAnalyze } from './getting_started_queryAndAnalyze';

export const NewGettingStarted = (props: HomeProps) => {
const { chrome } = props;
interface ExtendedHomeProps extends HomeProps {
selectedDataSourceId: string;
selectedDataSourceLabel: string;
}

export const NewGettingStarted = (props: ExtendedHomeProps) => {
const { chrome, selectedDataSourceId, selectedDataSourceLabel } = props;
const [selectedSource, setSelectedSource] = useState('');
const [isPickYourSourceOpen, setIsPickYourSourceOpen] = useState(true);
const [isQueryDataOpen, setIsQueryDataOpen] = useState(false);
const [indexPatterns, setIndexPatterns] = useState<string[]>([]);
const [isSampleDataset, setIsSampleDataset] = useState(false); // New state
const [isSampleDataset, setIsSampleDataset] = useState(false);

useEffect(() => {
chrome.setBreadcrumbs([
Expand All @@ -25,7 +29,7 @@ export const NewGettingStarted = (props: HomeProps) => {
href: '#/',
},
]);
}, []);
}, [chrome]);

const handleSelectSource = (source: string) => {
setSelectedSource(source);
Expand All @@ -42,10 +46,9 @@ export const NewGettingStarted = (props: HomeProps) => {
setIsQueryDataOpen(isOpen);
};

const setQueryDataOpen = (patterns: string[]) => {
const setQueryDataOpen = () => {
setIsPickYourSourceOpen(false);
setIsQueryDataOpen(true);
setIndexPatterns(patterns);
};

const handleCardSelectionChange = (isSample: boolean) => {
Expand All @@ -64,14 +67,17 @@ export const NewGettingStarted = (props: HomeProps) => {
onMoveToQueryData={setQueryDataOpen}
onSelectSource={handleSelectSource}
onCardSelectionChange={handleCardSelectionChange}
selectedDataSourceId={selectedDataSourceId}
selectedDataSourceLabel={selectedDataSourceLabel}
/>
<EuiSpacer size="l" />
{!isSampleDataset && (
<QueryAndAnalyze
isOpen={isQueryDataOpen}
onToggle={toggleQueryData}
selectedTechnology={selectedSource}
indexPatterns={indexPatterns}
selectedDataSourceId={selectedDataSourceId}
selectedDataSourceLabel={selectedDataSourceLabel}
/>
)}
</EuiPageBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
onMoveToQueryData: (indexPatterns: string[]) => void;
onSelectSource: (source: string) => void;
onCardSelectionChange: (isSampleDataset: boolean) => void;
selectedDataSourceId: string;
selectedDataSourceLabel: string;
}

interface CollectorOption {
label: string;
value: string;
}

export const CollectAndShipData: React.FC<CollectAndShipDataProps> = ({
Expand All @@ -48,17 +55,19 @@
onMoveToQueryData,
onSelectSource,
onCardSelectionChange,
selectedDataSourceId,
selectedDataSourceLabel,
}) => {
const [collectionMethod, setCollectionMethod] = useState('');
const [specificMethod, setSpecificMethod] = useState('');
const [_gettingStarted, setGettingStarted] = useState<any>(null);

Check warning on line 63 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const [selectedTabId, setSelectedTabId] = useState('workflow_0');
const [_selectedWorkflow, setSelectedWorkflow] = useState('');
const [workflows, setWorkflows] = useState<any[]>([]);

Check warning on line 66 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const [selectedCard, setSelectedCard] = useState('');
const [collectorOptions, setCollectorOptions] = useState([]);
const [collectorOptions, setCollectorOptions] = useState<CollectorOption[]>([]);

const technologyJsonMap: Record<string, any> = {

Check warning on line 70 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
otel: otelJson,
csv: csvFileJson,
golang: golangClientJson,
Expand Down Expand Up @@ -86,7 +95,7 @@
setGettingStarted(null);
setWorkflows([]);
}
}, [specificMethod]);

Check warning on line 98 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'technologyJsonMap'. Either include it or remove the dependency array

const handleCollectionMethodChange = (value: string) => {
setCollectionMethod(value);
Expand All @@ -109,7 +118,7 @@
}
};

const handleSpecificMethodChange = (selectedOption: any) => {

Check warning on line 121 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
if (!selectedOption) {
return;
}
Expand All @@ -126,7 +135,7 @@
setWorkflows([]);
};

const onTabClick = (tab: any) => {

Check warning on line 138 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const workflowIndex = parseInt(tab.id.split('_')[1], 10);
setSelectedTabId(tab.id);
setSelectedWorkflow(workflows[workflowIndex].name);
Expand Down Expand Up @@ -156,8 +165,8 @@
);
};

const renderSteps = (workflow: any) => {

Check warning on line 168 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const steps = workflow.steps.map((step: any) => ({

Check warning on line 169 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
title: step.name,
children: (
<div>
Expand All @@ -172,7 +181,7 @@
<EuiTitle size="xs">
<h4>Input Parameters:</h4>
</EuiTitle>
{step['input-params'].map((param: any, idx: number) => (

Check warning on line 184 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
<EuiText key={idx}>
<strong>{param.name}:</strong> {param.description} ({param.type})
</EuiText>
Expand Down Expand Up @@ -216,7 +225,7 @@
return <EuiSteps steps={steps} />;
};

const renderSchema = (schemas: any[]) =>

Check warning on line 228 in public/components/getting_started/components/getting_started_collectData.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
schemas.map((schema, idx) => (
<div key={idx}>
<EuiTitle size="s">
Expand Down Expand Up @@ -267,7 +276,7 @@
</EuiListGroup>
<EuiButton
onClick={async () => {
await UploadAssets(specificMethod);
await UploadAssets(specificMethod, selectedDataSourceId, selectedDataSourceLabel);
}}
fill
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,32 @@ import {
import { coreRefs } from '../../../../public/framework/core_refs';
import { fetchDashboardIds, fetchIndexPatternIds } from './utils';

interface Pattern {
id: string;
title: string;
}

interface Dashboard {
id: string;
title: string;
}

interface QueryAndAnalyzeProps {
isOpen: boolean;
onToggle: (isOpen: boolean) => void;
selectedTechnology: string;
indexPatterns: string[];
selectedDataSourceId: string;
selectedDataSourceLabel: string;
}

export const QueryAndAnalyze: React.FC<QueryAndAnalyzeProps> = ({
isOpen,
onToggle,
selectedTechnology,
selectedDataSourceId,
}) => {
const [patternsContent, setPatternsContent] = useState([]);
const [dashboardsContent, setDashboardsContent] = useState([]);
const [patternsContent, setPatternsContent] = useState<Pattern[]>([]);
const [dashboardsContent, setDashboardsContent] = useState<Dashboard[]>([]);

const fetchIndexPatternContent = async () => {
try {
Expand All @@ -47,26 +59,34 @@ export const QueryAndAnalyze: React.FC<QueryAndAnalyzeProps> = ({
const content = await fetchDashboardIds(selectedTechnology);
setDashboardsContent(content.data.length !== 0 ? content.data : []);
} catch (error) {
console.error('Error fetching index patterns:', error);
console.error('Error fetching dashboards:', error);
setDashboardsContent([]);
}
};

const redirectToDashboards = (path: string) => {
coreRefs?.application!.navigateToApp('dashboards', {
path: `#/${path}`,
});
};

useEffect(() => {
if (selectedTechnology !== '') {
fetchIndexPatternContent();
}
}, [selectedTechnology]);
}, [selectedTechnology, selectedDataSourceId]);

const handleIndexPatternClick = (patternId: string) => {
const finalPatternId = selectedDataSourceId
? `mds-${selectedDataSourceId}-objectId-${patternId}`
: patternId;

coreRefs?.application!.navigateToApp('data-explorer', {
path: `discover#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${patternId}',view:discover))&_q=(filters:!(),query:(language:kuery,query:''))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))`,
path: `discover#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(indexPattern:'${finalPatternId}',view:discover))&_q=(filters:!(),query:(language:kuery,query:''))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))`,
});
};

const redirectToDashboards = (dashboardId: string) => {
const finalDashboardId = selectedDataSourceId
? `mds-${selectedDataSourceId}-objectId-${dashboardId}`
: dashboardId;

coreRefs?.application!.navigateToApp('dashboards', {
path: `#/view/${finalDashboardId}`,
});
};

Expand Down Expand Up @@ -111,13 +131,13 @@ export const QueryAndAnalyze: React.FC<QueryAndAnalyzeProps> = ({
<EuiFlexGroup wrap>
{dashboardsContent.length !== 0 &&
dashboardsContent.map((dashboard) => (
<EuiFlexItem style={{ maxWidth: '300px' }}>
<EuiFlexItem key={dashboard.id} style={{ maxWidth: '300px' }}>
<EuiCard
icon={<div />}
title={dashboard.title}
description={`Explore the ${dashboard.title} dashboard`}
onClick={() => {
redirectToDashboards(`/view/${dashboard.id}`);
redirectToDashboards(dashboard.id);
}}
/>
</EuiFlexItem>
Expand Down
Loading
Loading