Skip to content

Commit

Permalink
Add toast message and bug fix trace (#1977)
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Tackett <[email protected]>
Co-authored-by: Adam Tackett <[email protected]>
(cherry picked from commit 8d4ba26)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and Adam Tackett committed Jul 23, 2024
1 parent f90847b commit f1c61c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import nginxJson from '../getting_started_artifacts/nginx/nginx-1.0.0.json';
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 Down Expand Up @@ -267,7 +267,7 @@ export const CollectAndShipData: React.FC<CollectAndShipDataProps> = ({
</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 @@ -66,6 +67,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 @@ -79,7 +81,12 @@ export function DashboardContent(props: DashboardProps) {
}, [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

0 comments on commit f1c61c6

Please sign in to comment.