Skip to content

Commit

Permalink
fix: get diagnostics data for different project not work (microsoft#6004
Browse files Browse the repository at this point in the history
)
  • Loading branch information
alanlong9278 authored Mar 1, 2021
1 parent 6d289f6 commit e9d91d1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
4 changes: 1 addition & 3 deletions Composer/packages/client/src/components/NavTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,10 @@ export interface INavTreeItem {
interface INavTreeProps {
navLinks: INavTreeItem[];
regionName: string;
onLinkClick?: (item: INavTreeItem) => void;
}

const NavTree: React.FC<INavTreeProps> = (props) => {
const { navLinks, regionName, onLinkClick } = props;
const { navLinks, regionName } = props;

const onRenderOverflowButton = (isSelected: boolean, item) => (
menuItems: IOverflowSetItemProps[] | undefined
Expand Down Expand Up @@ -133,7 +132,6 @@ const NavTree: React.FC<INavTreeProps> = (props) => {
text={item.name}
onClick={(e) => {
e.preventDefault();
onLinkClick?.(item);
navigateTo(item.url);
}}
/>
Expand Down
6 changes: 2 additions & 4 deletions Composer/packages/client/src/components/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ const Page: React.FC<IPageProps> = (props) => {
const {
title,
navLinks,
navLinkClick,
toolbarItems,
onRenderHeaderContent,
children,
Expand All @@ -143,7 +142,7 @@ const Page: React.FC<IPageProps> = (props) => {
fileId,
} = props;

const { setPageElementState, setCurrentProjectId } = useRecoilValue(dispatcherState);
const { setPageElementState } = useRecoilValue(dispatcherState);

const onMeasuredSizesChanged = (sizes: SplitMeasuredSizes) => {
setPageElementState(pageMode, { leftSplitWidth: sizes.primary });
Expand Down Expand Up @@ -206,12 +205,11 @@ const Page: React.FC<IPageProps> = (props) => {
luFileId: pageMode === 'language-understanding' && fileId ? fileId : undefined,
}}
onSelect={(link) => {
setCurrentProjectId(link.skillId ? link.skillId : link.projectId);
navigateTo(buildURL(pageMode, link));
}}
/>
) : (
<NavTree navLinks={navLinks as INavTreeItem[]} regionName={navRegionName} onLinkClick={navLinkClick} />
<NavTree navLinks={navLinks as INavTreeItem[]} regionName={navRegionName} />
)}
<div
aria-label={mainRegionName}
Expand Down
10 changes: 3 additions & 7 deletions Composer/packages/client/src/pages/diagnostics/Diagnostics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import { useRecoilValue, useSetRecoilState } from 'recoil';

import { Page } from '../../components/Page';
import { diagnosticNavLinksSelector } from '../../recoilModel/selectors/diagnosticsPageSelector';
import { dispatcherState, exportSkillModalInfoState } from '../../recoilModel';
import { exportSkillModalInfoState } from '../../recoilModel';
import { navigateTo } from '../../utils/navigation';
import { INavTreeItem } from '../../components/NavTree';

import { DiagnosticsTable } from './DiagnosticsTable';
import { DiagnosticFilter } from './DiagnosticFilter';
Expand All @@ -22,7 +21,7 @@ const Diagnostics: React.FC<RouteComponentProps<{ projectId: string; skillId: st
const [showType, setShowType] = useState('');
const setExportSkillModalInfo = useSetRecoilState(exportSkillModalInfoState);
const navLinks = useRecoilValue(diagnosticNavLinksSelector);
const { setCurrentProjectId } = useRecoilValue(dispatcherState);
const projectId = (props.skillId ?? props.projectId) as string;

const handleItemClick = (item: IDiagnosticInfo) => {
navigateTo(item.getUrl());
Expand All @@ -39,17 +38,14 @@ const Diagnostics: React.FC<RouteComponentProps<{ projectId: string; skillId: st
<Page
data-testid="LUPage"
mainRegionName={formatMessage('Diagnostic List')}
navLinkClick={(item: INavTreeItem) => {
setCurrentProjectId(item.id);
}}
navLinks={navLinks}
navRegionName={formatMessage('Diagnostics Pane')}
pageMode={'diagnostics'}
title={formatMessage('Diagnostics')}
toolbarItems={[]}
onRenderHeaderContent={onRenderHeaderContent}
>
<DiagnosticsTable showType={showType} onItemClick={handleItemClick} />
<DiagnosticsTable projectId={projectId} showType={showType} onItemClick={handleItemClick} />
</Page>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { useMemo, useState } from 'react';
import formatMessage from 'format-message';
import { RouteComponentProps } from '@reach/router';
import { css } from '@emotion/core';
import { useRecoilValue } from 'recoil';

import { Pagination } from '../../components/Pagination';
import { useDiagnosticsData } from '../design/DebugPanel/TabExtensions/DiagnosticsTab/useDiagnostics';
import { diagnosticsSelectorFamily } from '../../recoilModel';

import { DiagnosticList } from './DiagnosticList';
import { IDiagnosticInfo } from './types';
Expand All @@ -33,15 +34,16 @@ const tableView = css`

// -------------------- Diagnosticist -------------------- //
export interface IDiagnosticListProps extends RouteComponentProps {
projectId: string;
showType: string;
onItemClick: (item: IDiagnosticInfo) => void;
}

const itemCount = 10;

export const DiagnosticsTable: React.FC<IDiagnosticListProps> = (props) => {
const { onItemClick, showType } = props;
const diagnostics = useDiagnosticsData();
const { onItemClick, projectId, showType } = props;
const diagnostics = useRecoilValue(diagnosticsSelectorFamily(projectId));
const availableDiagnostics = showType ? diagnostics.filter((x) => x.severity === showType) : diagnostics;
const [pageIndex, setPageIndex] = useState<number>(1);

Expand Down

0 comments on commit e9d91d1

Please sign in to comment.