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

[Bugfix] Add toast message for getting started / Fix Nav Bug for Traces #1977

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 { ThroughputPlt } from '../common/plots/throughput_plt';
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 Down Expand Up @@ -64,6 +65,7 @@ export function DashboardContent(props: DashboardProps) {
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 @@ -77,7 +79,12 @@ export function DashboardContent(props: DashboardProps) {
}, [showTimeoutToast]);

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

Comment on lines +82 to +87
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we try using

useEffect(() => {
       setNavBreadCrumbs([], [parentBreadcrumb, ...childBreadcrumbs]);
    }, [isNavGroupEnabled])

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not work unfortunately.
Screenshot 2024-07-23 at 2 59 58 PM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, can we please track this in an issue. Cause ideally we would want to keep functions re-used across components.

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