Skip to content

Commit

Permalink
fix(ui): dereference errors (datahub-project#12034)
Browse files Browse the repository at this point in the history
  • Loading branch information
anshbansal authored Dec 12, 2024
1 parent edca8ea commit 3d75605
Show file tree
Hide file tree
Showing 100 changed files with 165 additions and 160 deletions.
2 changes: 1 addition & 1 deletion datahub-web-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const InnerApp: React.VFC = () => {
<HelmetProvider>
<CustomThemeProvider>
<Helmet>
<title>{useCustomTheme().theme?.content.title}</title>
<title>{useCustomTheme().theme?.content?.title}</title>
</Helmet>
<Router>
<Routes />
Expand Down
4 changes: 2 additions & 2 deletions datahub-web-react/src/app/AdminConsole.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const AdminConsole = (): JSX.Element => {
const [adminConsoleOpen, setAdminConsoleOpen] = useState(false);
const { config } = useAppConfig();

const isAnalyticsEnabled = config?.analyticsConfig.enabled;
const isPoliciesEnabled = config?.policiesConfig.enabled;
const isAnalyticsEnabled = config?.analyticsConfig?.enabled;
const isPoliciesEnabled = config?.policiesConfig?.enabled;

const showAnalytics = (isAnalyticsEnabled && me && me?.platformPrivileges?.viewAnalytics) || false;
const showPolicyBuilder = (isPoliciesEnabled && me && me?.platformPrivileges?.managePolicies) || false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ export const AnalyticsPage = () => {
placeholder="Select a domain"
onChange={onDomainChange}
filterOption={(input, option) =>
option?.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
option?.children?.toLowerCase()?.indexOf(input.toLowerCase()) >= 0
}
>
<Select.Option value="ALL">All</Select.Option>
{domainData?.listDomains?.domains.map((domainChoice) => (
{domainData?.listDomains?.domains?.map((domainChoice) => (
<Select.Option value={domainChoice.urn}>
{domainChoice?.properties?.name}
</Select.Option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default function DomainNode({ domain, numDomainChildren, domainUrnToHide,
const hasDomainChildren = useHasDomainChildren({ domainUrn: domain.urn, numDomainChildren });

const shouldAutoOpen = useMemo(
() => !isInSelectMode && entityData?.parentDomains?.domains.some((parent) => parent.urn === domain.urn),
() => !isInSelectMode && entityData?.parentDomains?.domains?.some((parent) => parent.urn === domain.urn),
[isInSelectMode, entityData, domain.urn],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const useGetEntityByUrl = (externalUrl: string) => {
const getLookupData = () => {
if (!data) return {} as const;

const entities = data.searchAcrossEntities?.searchResults.map((result) => result.entity) ?? [];
const entities = data.searchAcrossEntities?.searchResults?.map((result) => result.entity) ?? [];
const notFound = entities.length === 0;
const foundMultiple = entities.length > 1;
const entity = entities.length === 1 ? entities[0] : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function BusinessAttributeRelatedEntity() {
]) ||
[];

entityData?.isAChildren?.relationships.forEach((businessAttribute) => {
entityData?.isAChildren?.relationships?.forEach((businessAttribute) => {
const childUrn = businessAttribute.entity?.urn;

if (childUrn) {
Expand Down
6 changes: 3 additions & 3 deletions datahub-web-react/src/app/entity/chart/ChartEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ export class ChartEntity implements Entity<Chart> {
component: EmbedTab,
display: {
visible: (_, chart: GetChartQuery) =>
!!chart?.chart?.embed?.renderUrl && chart?.chart?.platform.urn === LOOKER_URN,
!!chart?.chart?.embed?.renderUrl && chart?.chart?.platform?.urn === LOOKER_URN,
enabled: (_, chart: GetChartQuery) =>
!!chart?.chart?.embed?.renderUrl && chart?.chart?.platform.urn === LOOKER_URN,
!!chart?.chart?.embed?.renderUrl && chart?.chart?.platform?.urn === LOOKER_URN,
},
},
{
Expand All @@ -170,7 +170,7 @@ export class ChartEntity implements Entity<Chart> {
name: 'Incidents',
component: IncidentTab,
getDynamicName: (_, chart) => {
const activeIncidentCount = chart?.chart?.activeIncidents.total;
const activeIncidentCount = chart?.chart?.activeIncidents?.total;
return `Incidents${(activeIncidentCount && ` (${activeIncidentCount})`) || ''}`;
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ export class DashboardEntity implements Entity<Dashboard> {
display: {
visible: (_, dashboard: GetDashboardQuery) =>
!!dashboard?.dashboard?.embed?.renderUrl &&
dashboard?.dashboard?.platform.urn === LOOKER_URN,
dashboard?.dashboard?.platform?.urn === LOOKER_URN,
enabled: (_, dashboard: GetDashboardQuery) =>
!!dashboard?.dashboard?.embed?.renderUrl &&
dashboard?.dashboard?.platform.urn === LOOKER_URN,
dashboard?.dashboard?.platform?.urn === LOOKER_URN,
},
},
{
Expand All @@ -170,7 +170,7 @@ export class DashboardEntity implements Entity<Dashboard> {
name: 'Incidents',
component: IncidentTab,
getDynamicName: (_, dashboard) => {
const activeIncidentCount = dashboard?.dashboard?.activeIncidents.total;
const activeIncidentCount = dashboard?.dashboard?.activeIncidents?.total;
return `Incidents${(activeIncidentCount && ` (${activeIncidentCount})`) || ''}`;
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class DataFlowEntity implements Entity<DataFlow> {
name: 'Incidents',
component: IncidentTab,
getDynamicName: (_, dataFlow) => {
const activeIncidentCount = dataFlow?.dataFlow?.activeIncidents.total;
const activeIncidentCount = dataFlow?.dataFlow?.activeIncidents?.total;
return `Incidents${(activeIncidentCount && ` (${activeIncidentCount})`) || ''}`;
},
},
Expand Down
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/entity/dataJob/DataJobEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class DataJobEntity implements Entity<DataJob> {
name: 'Incidents',
component: IncidentTab,
getDynamicName: (_, dataJob) => {
const activeIncidentCount = dataJob?.dataJob?.activeIncidents.total;
const activeIncidentCount = dataJob?.dataJob?.activeIncidents?.total;
return `Incidents${(activeIncidentCount && ` (${activeIncidentCount})`) || ''}`;
},
},
Expand Down
4 changes: 2 additions & 2 deletions datahub-web-react/src/app/entity/dataJob/tabs/RunsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ export const RunsTab = () => {
name: run?.name,
status: run?.state?.[0]?.status,
resultType: run?.state?.[0]?.result?.resultType,
inputs: run?.inputs?.relationships.map((relationship) => relationship.entity),
outputs: run?.outputs?.relationships.map((relationship) => relationship.entity),
inputs: run?.inputs?.relationships?.map((relationship) => relationship.entity),
outputs: run?.outputs?.relationships?.map((relationship) => relationship.entity),
externalUrl: run?.externalUrl,
}));
if (loading) {
Expand Down
2 changes: 1 addition & 1 deletion datahub-web-react/src/app/entity/dataset/DatasetEntity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class DatasetEntity implements Entity<Dataset> {
name: 'Incidents',
component: IncidentTab,
getDynamicName: (_, dataset) => {
const activeIncidentCount = dataset?.dataset?.activeIncidents.total;
const activeIncidentCount = dataset?.dataset?.activeIncidents?.total;
return `Incidents${(activeIncidentCount && ` (${activeIncidentCount})`) || ''}`;
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ export const OperationsTab = () => {
status: run?.state?.[0]?.status,
resultType: run?.state?.[0]?.result?.resultType,
duration: run?.state?.[0]?.durationMillis,
inputs: run?.inputs?.relationships.map((relationship) => relationship.entity),
outputs: run?.outputs?.relationships.map((relationship) => relationship.entity),
inputs: run?.inputs?.relationships?.map((relationship) => relationship.entity),
outputs: run?.outputs?.relationships?.map((relationship) => relationship.entity),
externalUrl: run?.externalUrl,
parentTemplate: run?.parentTemplate?.relationships?.[0]?.entity,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function useSchemaTitleRenderer(
?.filter(
(constraint) =>
(constraint?.sourceFields?.filter(
(sourceField) => sourceField?.fieldPath.trim() === fieldPath.trim(),
(sourceField) => sourceField?.fieldPath?.trim() === fieldPath.trim(),
).length || 0) > 0,
)
.map((constraint) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function convertEditableSchemaMetadataForUpdate(
): EditableSchemaMetadataUpdate {
return {
editableSchemaFieldInfo:
editableSchemaMetadata?.editableSchemaFieldInfo.map((editableSchemaFieldInfo) => ({
editableSchemaMetadata?.editableSchemaFieldInfo?.map((editableSchemaFieldInfo) => ({
fieldPath: editableSchemaFieldInfo?.fieldPath,
description: editableSchemaFieldInfo?.description,
globalTags: { tags: convertTagsForUpdate(editableSchemaFieldInfo?.globalTags?.tags || []) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function DataProductsTab() {
},
});
const totalResults = data?.searchAcrossEntities?.total || 0;
const searchResults = data?.searchAcrossEntities?.searchResults.map((r) => r.entity) || [];
const searchResults = data?.searchAcrossEntities?.searchResults?.map((r) => r.entity) || [];
const dataProducts = [...createdDataProducts, ...searchResults];
const displayedDataProducts = dataProducts
.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ function AddRelatedTermsModal(props: Props) {
const newUrns = [...selectedUrns, urn];
setSelectedUrns(newUrns);
const selectedSearchOption = tagSearchOptions.find((option) => option.props.value === urn);
setSelectedTerms([...selectedTerms, { urn, component: <TermLabel name={selectedSearchOption?.props.name} /> }]);
setSelectedTerms([
...selectedTerms,
{ urn, component: <TermLabel name={selectedSearchOption?.props?.name} /> },
]);
};

// When a Tag or term search result is deselected, remove the urn from the Owners
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function GlossaryRelatedEntity() {
]) ||
[];

entityData?.isAChildren?.relationships.forEach((term) => {
entityData?.isAChildren?.relationships?.forEach((term) => {
const childUrn = term.entity?.urn;

if (childUrn) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ export default function SourcesView() {
features?.reduce((accumulator: Array<Dataset>, feature) => {
if (feature.__typename === 'MLFeature' && feature.properties?.sources) {
// eslint-disable-next-line array-callback-return
feature.properties?.sources.map((source: Dataset | null) => {
feature.properties?.sources?.map((source: Dataset | null) => {
if (source && accumulator.findIndex((dataset) => dataset.urn === source?.urn) === -1) {
accumulator.push(source);
}
});
} else if (feature.__typename === 'MLPrimaryKey' && feature.properties?.sources) {
// eslint-disable-next-line array-callback-return
feature.properties?.sources.map((source: Dataset | null) => {
feature.properties?.sources?.map((source: Dataset | null) => {
if (source && accumulator.findIndex((dataset) => dataset.urn === source?.urn) === -1) {
accumulator.push(source);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function MlModelFeaturesTab() {
const entity = useBaseEntity() as GetMlModelQuery;

const model = entity && entity.mlModel;
const features = model?.features?.relationships.map((relationship) => relationship.entity) as Array<
const features = model?.features?.relationships?.map((relationship) => relationship.entity) as Array<
MlFeature | MlPrimaryKey
>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const OwnershipList = () => {
});
const totalOwnershipTypes = data?.listOwnershipTypes?.total || 0;
const ownershipTypes =
data?.listOwnershipTypes?.ownershipTypes.filter((type) => type.urn !== 'urn:li:ownershipType:none') || [];
data?.listOwnershipTypes?.ownershipTypes?.filter((type) => type.urn !== 'urn:li:ownershipType:none') || [];

const onClickCreateOwnershipType = () => {
setShowOwnershipBuilder(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function filterResultsForMove(entity: Domain, entityUrn: string) {
return (
entity.urn !== entityUrn &&
entity.__typename === 'Domain' &&
!entity.parentDomains?.domains.some((node) => node.urn === entityUrn)
!entity.parentDomains?.domains?.some((node) => node.urn === entityUrn)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function filterResultsForMove(entity: GlossaryNode, entityUrn: string) {
return (
entity.urn !== entityUrn &&
entity.__typename === 'GlossaryNode' &&
!entity.parentNodes?.nodes.some((node) => node.urn === entityUrn)
!entity.parentNodes?.nodes?.some((node) => node.urn === entityUrn)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function useHandleMoveDomainComplete() {
if (!entityData) return;

const domain = entityData as Domain;
const oldParentUrn = domain.parentDomains?.domains.length ? domain.parentDomains.domains[0].urn : undefined;
const oldParentUrn = domain.parentDomains?.domains?.length ? domain.parentDomains.domains[0].urn : undefined;

analytics.event({
type: EventType.MoveDomainEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ describe('siblingUtils', () => {

// merges schema metadata properly by fieldPath
expect(combinedData.dataset.schemaMetadata?.fields).toHaveLength(4);
expect(combinedData.dataset.schemaMetadata?.fields[0].fieldPath).toEqual('new_one');
expect(combinedData.dataset.schemaMetadata?.fields[1].fieldPath).toEqual('DUPLICATE_FIELD');
expect(combinedData.dataset.schemaMetadata?.fields[2].fieldPath).toEqual('user_id');
expect(combinedData.dataset.schemaMetadata?.fields[3].fieldPath).toEqual('user_name');
expect(combinedData.dataset.schemaMetadata?.fields[0]?.fieldPath).toEqual('new_one');
expect(combinedData.dataset.schemaMetadata?.fields[1]?.fieldPath).toEqual('DUPLICATE_FIELD');
expect(combinedData.dataset.schemaMetadata?.fields[2]?.fieldPath).toEqual('user_id');
expect(combinedData.dataset.schemaMetadata?.fields[3]?.fieldPath).toEqual('user_name');

// will overwrite string properties w/ primary
expect(combinedData.dataset.editableProperties.description).toEqual('secondary description');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ export const CreateERModelRelationModal = ({
};

const table1NameBusiness = getDatasetName(table1Dataset);
const table1NameTech = table1Dataset?.name || table1Dataset?.urn.split(',').at(1) || '';
const table1NameTech = table1Dataset?.name || table1Dataset?.urn?.split(',').at(1) || '';
const table2NameBusiness = getDatasetName(table2Dataset);
const table2NameTech = table2Dataset?.name || table2Dataset?.urn.split(',').at(1) || '';
const table2NameTech = table2Dataset?.name || table2Dataset?.urn?.split(',').at(1) || '';

const handleAdd = () => {
const newData: ERModelRelationDataType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ export function getDatasetName(datainput: any): string {
datainput?.editableProperties?.name ||
datainput?.properties?.name ||
datainput?.name ||
datainput?.urn.split(',').at(1)
datainput?.urn?.split(',').at(1)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const EditableCell = ({
<Select
size="large"
className="ermodelrelation-select-selector"
options={tableRecord?.schemaMetadata?.fields.map((result) => ({
options={tableRecord?.schemaMetadata?.fields?.map((result) => ({
value: result.fieldPath,
label: result.fieldPath,
}))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default function ProfileNavBrowsePathV2({ urn, type }: Props) {
{entityRegistry.getDisplayName(EntityType.DataPlatform, entityData.platform)}
</BreadcrumbItem>
)}
{entityData?.browsePathV2?.path.map((pathEntry, index) => (
{entityData?.browsePathV2?.path?.map((pathEntry, index) => (
<BreadcrumbItem
key={pathEntry.name}
disabled={!isBrowsable}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default function SetDataProductModal({
tagRender={tagRender}
onBlur={() => setQuery('')}
>
{data?.searchAcrossEntities?.searchResults.map((result) => (
{data?.searchAcrossEntities?.searchResults?.map((result) => (
<Select.Option value={result.entity.urn} key={result.entity.urn}>
<OptionWrapper>
{entityRegistry.getIcon(EntityType.DataProduct, 12, IconStyleType.ACCENT, 'black')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export default function useGetPromptInfo(formUrn?: string) {
requiredEntityPrompts,
} = getEntityPromptsInfo(prompts, entityData);
const { fieldPrompts, numRequiredFieldPromptsRemaining, numOptionalFieldPromptsRemaining, requiredFieldPrompts } =
getFieldPromptsInfo(prompts, entityData, entityWithSchema?.schemaMetadata?.fields.length || 0, formUrn);
getFieldPromptsInfo(prompts, entityData, entityWithSchema?.schemaMetadata?.fields?.length || 0, formUrn);
// Multiply number of field prompts by number of schema fields for total number of schema field prompts
const totalRequiredSchemaFieldPrompts =
(entityWithSchema?.schemaMetadata?.fields.length || 0) * requiredFieldPrompts.length;
(entityWithSchema?.schemaMetadata?.fields?.length || 0) * requiredFieldPrompts.length;

const numRequiredPromptsRemaining = numRequiredEntityPromptsRemaining + numRequiredFieldPromptsRemaining;
const numOptionalPromptsRemaining = numOptionalEntityPromptsRemaining + numOptionalFieldPromptsRemaining;
Expand Down
Loading

0 comments on commit 3d75605

Please sign in to comment.