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

[Backport 2.16] [Bugfix] Add toast message for getting started / Fix Nav Bug for Traces #1979

Merged
merged 1 commit into from
Jul 23, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import javaJson from '../getting_started_artifacts/java_client/java_client-1.0.0.json';

import { IntegrationCards } from './getting_started_integrationCards';
import { uploadAssets } from './utils';
import { UploadAssets } from './utils';

interface CollectAndShipDataProps {
isOpen: boolean;
Expand All @@ -51,14 +51,14 @@
}) => {
const [collectionMethod, setCollectionMethod] = useState('');
const [specificMethod, setSpecificMethod] = useState('');
const [_gettingStarted, setGettingStarted] = useState<any>(null);

Check warning on line 54 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 57 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 technologyJsonMap: Record<string, any> = {

Check warning on line 61 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 +86,7 @@
setGettingStarted(null);
setWorkflows([]);
}
}, [specificMethod]);

Check warning on line 89 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 +109,7 @@
}
};

const handleSpecificMethodChange = (selectedOption: any) => {

Check warning on line 112 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 +126,7 @@
setWorkflows([]);
};

const onTabClick = (tab: any) => {

Check warning on line 129 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 +156,8 @@
);
};

const renderSteps = (workflow: any) => {

Check warning on line 159 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 160 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 +172,7 @@
<EuiTitle size="xs">
<h4>Input Parameters:</h4>
</EuiTitle>
{step['input-params'].map((param: any, idx: number) => (

Check warning on line 175 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 +216,7 @@
return <EuiSteps steps={steps} />;
};

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

Check warning on line 219 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 +267,7 @@
</EuiListGroup>
<EuiButton
onClick={async () => {
await uploadAssets(specificMethod);
await UploadAssets(specificMethod);
}}
fill
>
Expand Down
7 changes: 5 additions & 2 deletions public/components/getting_started/components/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { coreRefs } from '../../../framework/core_refs';
import { uploadBundle } from '../../integrations/components/upload_flyout';
import { useToast } from '../../../../public/components/common/toast';

const fetchAssets = async (tutorialId: string, assetFilter?: 'dashboards' | 'indexPatterns') => {
const assetFilterParam = assetFilter ? `${assetFilter}/` : '';
Expand All @@ -20,7 +21,8 @@ const fetchAssets = async (tutorialId: string, assetFilter?: 'dashboards' | 'ind
return responeData;
};

export const uploadAssets = async (tutorialId: string) => {
export const UploadAssets = async (tutorialId: string) => {
const { setToast } = useToast();
try {
const responeData = await fetchAssets(tutorialId);

Expand All @@ -31,10 +33,11 @@ export const uploadAssets = async (tutorialId: string) => {
if (error) {
console.error(error.message);
} else {
console.log('Bundle uploaded successfully');
setToast('Created saved object assets successfully', 'success');
}
} catch (err) {
console.error(err.message);
setToast('Failed to create saved object assets', 'danger');
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import { DashboardProps } from './dashboard';
import { DashboardTable } from './dashboard_table';
import { TopGroupsPage } from './top_groups_page';
import { coreRefs } from '../../../../../public/framework/core_refs';

export function DashboardContent(props: DashboardProps) {
const {
Expand All @@ -46,7 +47,7 @@
filters,
setStartTime,
setEndTime,
setQuery,

Check failure on line 50 in public/components/trace_analytics/components/dashboard/dashboard_content.tsx

View workflow job for this annotation

GitHub Actions / Lint

'setQuery' is assigned a value but never used. Allowed unused vars must match /^_/u
setFilters,
mode,
dataPrepperIndicesExist,
Expand All @@ -61,11 +62,12 @@
const [throughputPltItems, setThroughputPltItems] = useState({ items: [], fixedInterval: '1h' });
const [errorRatePltItems, setErrorRatePltItems] = useState({ items: [], fixedInterval: '1h' });
const [percentileMap, setPercentileMap] = useState<{ [traceGroup: string]: number[] }>({});
const [filteredService, setFilteredService] = useState('');

Check failure on line 65 in public/components/trace_analytics/components/dashboard/dashboard_content.tsx

View workflow job for this annotation

GitHub Actions / Lint

'filteredService' is assigned a value but never used. Allowed unused vars must match /^_/u

Check failure on line 65 in public/components/trace_analytics/components/dashboard/dashboard_content.tsx

View workflow job for this annotation

GitHub Actions / Lint

'setFilteredService' is assigned a value but never used. Allowed unused vars must match /^_/u
const [redirect, setRedirect] = useState(true);
const [loading, setLoading] = useState(false);
const [showTimeoutToast, setShowTimeoutToast] = useState(false);
const { setToast } = useToast();
const isNavGroupEnabled = coreRefs?.chrome?.navGroup.getNavGroupEnabled();

useEffect(() => {
if (showTimeoutToast === true && (!toasts || toasts.length === 0)) {
Expand All @@ -79,7 +81,12 @@
}, [showTimeoutToast]);

useEffect(() => {
chrome.setBreadcrumbs([parentBreadcrumb, ...childBreadcrumbs]);
if (isNavGroupEnabled) {
chrome.setBreadcrumbs([...childBreadcrumbs]);
} else {
chrome.setBreadcrumbs([parentBreadcrumb, ...childBreadcrumbs]);
}

const validFilters = getValidFilterFields(mode, page, attributesFilterFields);
setFilters([
...filters.map((filter) => ({
Expand Down
Loading