Search: Fix strict null errors (#23804)

This commit is contained in:
Alex Khomenko 2020-04-23 10:55:10 +03:00 committed by GitHub
parent c0fe565499
commit 906cc6d317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 16 deletions

View File

@ -8,7 +8,7 @@ const searchSrv = new SearchSrv();
export interface Props {
onChange: (sortValue: SelectableValue) => void;
value?: SelectableValue;
value?: SelectableValue | null;
placeholder?: string;
}

View File

@ -25,17 +25,19 @@ interface Props {
query: DashboardQuery;
showStarredFilter?: boolean;
hideSelectedTags?: boolean;
hideLayout?: boolean;
}
export const ActionRow: FC<Props> = ({
layout,
onLayoutChange,
onSortChange,
onStarredFilterChange,
onStarredFilterChange = () => {},
onTagFilterChange,
query,
showStarredFilter,
hideSelectedTags,
hideLayout,
}) => {
const theme = useTheme();
const styles = getStyles(theme);
@ -43,7 +45,7 @@ export const ActionRow: FC<Props> = ({
return (
<div className={styles.actionRow}>
<HorizontalGroup spacing="md" width="100%">
{layout ? <RadioButtonGroup options={layoutOptions} onChange={onLayoutChange} value={layout} /> : null}
{!hideLayout ? <RadioButtonGroup options={layoutOptions} onChange={onLayoutChange} value={layout} /> : null}
<SortPicker onChange={onSortChange} value={query.sort} />
</HorizontalGroup>
<HorizontalGroup spacing="md" justify="space-between">

View File

@ -154,7 +154,8 @@ export const ManageDashboards: FC<Props> = memo(({ folderId, folderUid }) => {
onSortChange={onSortChange}
onTagFilterChange={onTagFilterChange}
query={query}
layout={!folderUid && layout}
layout={layout}
hideLayout={!!folderUid}
onLayoutChange={onLayoutChange}
/>
)}

View File

@ -12,14 +12,15 @@ export interface Props {
canDelete?: boolean;
canMove?: boolean;
deleteItem: () => void;
hideLayout?: boolean;
layout: string;
moveTo: () => void;
onLayoutChange: Dispatch<SetStateAction<string>>;
onSortChange: onSelectChange;
onStarredFilterChange: onSelectChange;
onTagFilterChange: onSelectChange;
onToggleAllChecked: () => void;
query: DashboardQuery;
onSortChange: onSelectChange;
onLayoutChange: Dispatch<SetStateAction<string>>;
layout: string;
}
export const SearchResultsFilter: FC<Props> = ({
@ -27,14 +28,15 @@ export const SearchResultsFilter: FC<Props> = ({
canDelete,
canMove,
deleteItem,
hideLayout,
layout,
moveTo,
onToggleAllChecked,
onLayoutChange,
onSortChange,
onStarredFilterChange,
onTagFilterChange,
onToggleAllChecked,
query,
onSortChange,
layout,
onLayoutChange,
}) => {
const showActions = canDelete || canMove;
const theme = useTheme();
@ -56,6 +58,7 @@ export const SearchResultsFilter: FC<Props> = ({
<ActionRow
{...{
layout,
hideLayout,
onLayoutChange,
onSortChange,
onStarredFilterChange,

View File

@ -46,7 +46,7 @@ export const useSearchQuery = (queryParams: Partial<DashboardQuery>) => {
dispatch({ type: TOGGLE_STARRED, payload: filter.value });
};
const onSortChange = (sort: SelectableValue) => {
const onSortChange = (sort: SelectableValue | null) => {
dispatch({ type: TOGGLE_SORT, payload: sort });
};

View File

@ -41,16 +41,16 @@ export const loadFolderPage = (uid: string, activeChildId: string) => {
navModel.main.text = folderTitle;
const dashTab = navModel.main.children.find((child: any) => child.id === 'manage-folder-dashboards');
dashTab.url = folderUrl;
dashTab!.url = folderUrl;
if (folder.canAdmin) {
const permTab = navModel.main.children.find((child: any) => child.id === 'manage-folder-permissions');
permTab.url = folderUrl + '/permissions';
permTab!.url = folderUrl + '/permissions';
const settingsTab = navModel.main.children.find((child: any) => child.id === 'manage-folder-settings');
settingsTab.url = folderUrl + '/settings';
settingsTab!.url = folderUrl + '/settings';
} else {
navModel.main.children = [dashTab];
navModel.main.children = [dashTab!];
}
return { folder, model: navModel };