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

chore(js-ts): Convert SidebarNav to TypeScript #3937

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 @@ -7,6 +7,7 @@
import * as React from 'react';
import { injectIntl } from 'react-intl';
import type { IntlShape } from 'react-intl';
import type { SyntheticEvent } from 'react';
import noop from 'lodash/noop';
import { BoxAiLogo } from '@box/blueprint-web-assets/icons/Logo';
import { Size6 } from '@box/blueprint-web-assets/tokens/tokens';
Expand All @@ -31,26 +32,33 @@ import {
SIDEBAR_VIEW_SKILLS,
} from '../../constants';
import { useFeatureConfig } from '../common/feature-checking';
import type { NavigateOptions, AdditionalSidebarTab } from './flowTypes';
import type { AdditionalSidebarTab } from './types';
import './SidebarNav.scss';

type Props = {
additionalTabs?: Array<AdditionalSidebarTab>,
elementId: string,
fileId: string,
hasActivity: boolean,
hasAdditionalTabs: boolean,
hasBoxAI: boolean,
hasDetails: boolean,
hasDocGen?: boolean,
hasMetadata: boolean,
hasSkills: boolean,
intl: IntlShape,
isOpen?: boolean,
onNavigate?: (SyntheticEvent<>, NavigateOptions) => void,
onPanelChange?: (name: string, isInitialState: boolean) => void,
};
interface Props {
additionalTabs?: AdditionalSidebarTab[];
elementId: string;
fileId: string;
hasActivity: boolean;
hasAdditionalTabs: boolean;
hasBoxAI: boolean;
hasDetails: boolean;
hasDocGen?: boolean;
hasMetadata: boolean;
hasSkills: boolean;
intl: IntlShape;
isOpen?: boolean;
// Note: Original Flow type included NavigateOptions parameter - needs verification
onNavigate?: (event: SyntheticEvent) => void;
onPanelChange?: (name: string, isInitialState: boolean) => void;
}

// Note: The following component props need type verification:
// - SidebarNavButton props and event handlers
// - useFeatureConfig return type
// - AdditionalTabs props
// - SidebarNavSign requirements
// - SidebarToggle props
const SidebarNav = ({
additionalTabs,
elementId,
Expand Down
56 changes: 56 additions & 0 deletions src/elements/content-sidebar/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as React from 'react';
import { UseTargetingApi } from '../../features/targeting/types';

interface ClassificationInfo {
definition?: string;
name: string;
}

interface ContentInsights {
error?: Record<string, unknown>;
graphData: Record<string, unknown>[];
isLoading: boolean;
previousPeriodCount: number;
totalCount: number;
}

interface NavigateOptions {
isToggle?: boolean;
}

interface AdditionalSidebarTabFtuxData {
targetingApi: UseTargetingApi;
text: string;
}

interface AdditionalSidebarTab {
callback: (callbackData: Record<string, unknown>) => void;
ftuxTooltipData?: AdditionalSidebarTabFtuxData;
iconUrl?: string;
id: number;
title: string | null;
icon?: React.ReactNode;
}

interface Translations {
onTranslate?: (data: unknown) => void;
translationEnabled?: boolean;
}

interface FileAccessStats {
comment_count?: number;
download_count?: number;
edit_count?: number;
has_count_overflowed: boolean;
preview_count?: number;
}

export type {
ClassificationInfo,
ContentInsights,
NavigateOptions,
AdditionalSidebarTab,
AdditionalSidebarTabFtuxData,
Translations,
FileAccessStats,
};