fix(ui): null dereference (#12193)

This commit is contained in:
Aseem Bansal 2024-12-23 21:28:18 +05:30 committed by GitHub
parent d06980f6f3
commit dd23f9e294
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 12 additions and 12 deletions

View File

@ -68,6 +68,6 @@ export function getDatasetName(datainput: any): string {
datainput?.editableProperties?.name || datainput?.editableProperties?.name ||
datainput?.properties?.name || datainput?.properties?.name ||
datainput?.name || datainput?.name ||
datainput?.urn?.split(',').at(1) datainput?.urn?.split(',')?.at(1)
); );
} }

View File

@ -10,9 +10,9 @@ export const filterQueries = (filterText, queries: Query[]) => {
const lowerFilterText = filterText.toLowerCase(); const lowerFilterText = filterText.toLowerCase();
return queries.filter((query) => { return queries.filter((query) => {
return ( return (
query.title?.toLowerCase().includes(lowerFilterText) || query.title?.toLowerCase()?.includes(lowerFilterText) ||
query.description?.toLowerCase().includes(lowerFilterText) || query.description?.toLowerCase()?.includes(lowerFilterText) ||
query.query?.toLowerCase().includes(lowerFilterText) query.query?.toLowerCase()?.includes(lowerFilterText)
); );
}); });
}; };

View File

@ -12,7 +12,7 @@ function matchesTagsOrTermsOrDescription(field: SchemaField, filterText: string,
.toLocaleLowerCase() .toLocaleLowerCase()
.includes(filterText), .includes(filterText),
) || ) ||
field.description?.toLocaleLowerCase().includes(filterText) field.description?.toLocaleLowerCase()?.includes(filterText)
); );
} }

View File

@ -129,7 +129,7 @@ export const ExecutionDetailsModal = ({ urn, open, onClose }: Props) => {
downloadFile(output, `exec-${urn}.log`); downloadFile(output, `exec-${urn}.log`);
}; };
const logs = (showExpandedLogs && output) || output?.split('\n').slice(0, 5).join('\n'); const logs = (showExpandedLogs && output) || output?.split('\n')?.slice(0, 5)?.join('\n');
const result = data?.executionRequest?.result as Partial<ExecutionRequestResult>; const result = data?.executionRequest?.result as Partial<ExecutionRequestResult>;
const status = getIngestionSourceStatus(result); const status = getIngestionSourceStatus(result);
@ -163,7 +163,7 @@ export const ExecutionDetailsModal = ({ urn, open, onClose }: Props) => {
} catch (e) { } catch (e) {
recipeYaml = ''; recipeYaml = '';
} }
const recipe = showExpandedRecipe ? recipeYaml : recipeYaml?.split('\n').slice(0, 5).join('\n'); const recipe = showExpandedRecipe ? recipeYaml : recipeYaml?.split('\n')?.slice(0, 5)?.join('\n');
const areLogsExpandable = output?.split(/\r\n|\r|\n/)?.length > 5; const areLogsExpandable = output?.split(/\r\n|\r|\n/)?.length > 5;
const isRecipeExpandable = recipeYaml?.split(/\r\n|\r|\n/)?.length > 5; const isRecipeExpandable = recipeYaml?.split(/\r\n|\r|\n/)?.length > 5;

View File

@ -124,10 +124,10 @@ function truncate(input, length) {
function getLastTokenOfTitle(title?: string): string { function getLastTokenOfTitle(title?: string): string {
if (!title) return ''; if (!title) return '';
const lastToken = title?.split('.').slice(-1)[0]; const lastToken = title?.split('.')?.slice(-1)?.[0];
// if the last token does not contain any content, the string should not be tokenized on `.` // if the last token does not contain any content, the string should not be tokenized on `.`
if (lastToken.replace(/\s/g, '').length === 0) { if (lastToken?.replace(/\s/g, '')?.length === 0) {
return title; return title;
} }

View File

@ -40,7 +40,7 @@ export const useSearchResult = () => {
}; };
export const useEntityType = () => { export const useEntityType = () => {
return useSearchResultContext()?.searchResult.entity.type; return useSearchResultContext()?.searchResult?.entity?.type;
}; };
export const useMatchedFields = () => { export const useMatchedFields = () => {

View File

@ -42,7 +42,7 @@ const RenderedField = ({
field: MatchedField; field: MatchedField;
}) => { }) => {
const entityRegistry = useEntityRegistry(); const entityRegistry = useEntityRegistry();
const query = useSearchQuery()?.trim().toLowerCase(); const query = useSearchQuery()?.trim()?.toLowerCase();
const customRenderedField = customFieldRenderer?.(field); const customRenderedField = customFieldRenderer?.(field);
if (customRenderedField) return <b>{customRenderedField}</b>; if (customRenderedField) return <b>{customRenderedField}</b>;
if (isHighlightableEntityField(field)) { if (isHighlightableEntityField(field)) {

View File

@ -23,7 +23,7 @@ const SearchTextHighlighter = ({ field, text, enableFullHighlight = false }: Pro
const enableNameHighlight = appConfig.config.visualConfig.searchResult?.enableNameHighlight; const enableNameHighlight = appConfig.config.visualConfig.searchResult?.enableNameHighlight;
const matchedFields = useMatchedFieldsByGroup(field); const matchedFields = useMatchedFieldsByGroup(field);
const hasMatchedField = !!matchedFields?.length; const hasMatchedField = !!matchedFields?.length;
const normalizedSearchQuery = useSearchQuery()?.trim().toLowerCase(); const normalizedSearchQuery = useSearchQuery()?.trim()?.toLowerCase();
const normalizedText = text.trim().toLowerCase(); const normalizedText = text.trim().toLowerCase();
const hasSubstring = hasMatchedField && !!normalizedSearchQuery && normalizedText.includes(normalizedSearchQuery); const hasSubstring = hasMatchedField && !!normalizedSearchQuery && normalizedText.includes(normalizedSearchQuery);
const pattern = enableFullHighlight ? HIGHLIGHT_ALL_PATTERN : undefined; const pattern = enableFullHighlight ? HIGHLIGHT_ALL_PATTERN : undefined;