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

feat: Add optional configuration to disable Lineage list view links #1958

Merged
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
4 changes: 4 additions & 0 deletions frontend/amundsen_application/static/css/_list-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@
cursor: pointer;
z-index: 1;
}

&.is-disabled {
pointer-events: none;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface TableListItemProps {
table: TableResource;
logging: LoggingParams;
tableHighlights: HighlightedTable;
disabled?: boolean;
}

export const getLink = (table, logging) =>
Expand All @@ -34,8 +35,9 @@ const TableListItem: React.FC<TableListItemProps> = ({
table,
logging,
tableHighlights,
disabled,
}) => (
<li className="list-group-item clickable">
<li className={`list-group-item ${disabled ? 'is-disabled' : 'clickable'}`}>
<Link
className="resource-list-item table-list-item"
to={getLink(table, logging)}
Expand Down
13 changes: 13 additions & 0 deletions frontend/amundsen_application/static/js/config/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,17 @@ interface FeatureLineageConfig {
inAppListEnabled: boolean;
}

/**
* TableLineageDisableAppListLinksConfig - maps table fields to regular expressions
* for matching and disabling list links if they don't match
*/
interface TableLineageDisableAppListLinksConfig {
database?: RegExp;
cluster?: RegExp;
schema?: RegExp;
table?: RegExp;
}

/**
* TableLineageConfig - Customize the "Table Lineage" links of the "Table Details" page.
* This feature is intended to link to an external lineage provider.
Expand All @@ -347,6 +358,7 @@ interface FeatureLineageConfig {
* isEnabled - Whether to show or hide this section
* urlGenerator - Generate a URL to the third party lineage website
* inAppListEnabled - Enable the in app Upstream/Downstream tabs for table lineage. Requires backend support.
* disableAppListLinks - Set up table field based regular expression rules to disable lineage list view links.
*/
interface TableLineageConfig {
iconPath: string;
Expand All @@ -360,6 +372,7 @@ interface TableLineageConfig {
externalEnabled: boolean;
inAppListEnabled: boolean;
inAppPageEnabled: boolean;
disableAppListLinks?: TableLineageDisableAppListLinksConfig;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright Contributors to the Amundsen project.
// SPDX-License-Identifier: Apache-2.0

import * as React from 'react';
import { shallow } from 'enzyme';
import LineageList, { LineageListProps } from './index';

const setup = (propOverrides?: Partial<LineageListProps>) => {
const props: LineageListProps = {
items: [
{
badges: [],
cluster: 'gold',
database: 'hive',
key: 'hive://gold.test_schema/test_table1',
level: 0,
name: 'test_table1',
parent: null,
schema: 'test_schema',
source: 'hive',
usage: 0,
},
],
direction: 'both',
...propOverrides,
};
const wrapper = shallow<typeof LineageList>(<LineageList {...props} />);

return {
props,
wrapper,
};
};

describe('LineageList', () => {
it('should render a link', () => {
const { wrapper } = setup();
expect(wrapper.find('a').exists).toBeTruthy();
});

it('should have a disabled link', () => {
const { wrapper } = setup();
jest.mock('./index', () => ({
isTableLinkDisabled: jest.fn().mockReturnValueOnce(true),
}));
expect(wrapper.find('is-disabled').exists).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import * as React from 'react';

import AppConfig from 'config/config';
import { ResourceType, TableResource } from 'interfaces/Resources';
import { LineageItem } from 'interfaces/Lineage';
import TableListItem from 'components/ResourceListItem/TableListItem';
Expand All @@ -13,6 +14,17 @@ export interface LineageListProps {
direction: string;
}

const isTableLinkDisabled = (table: LineageItem) => {
const config = AppConfig.tableLineage;
let disabled = false;
if (config.disableAppListLinks) {
disabled = Object.keys(config.disableAppListLinks).some(
(key) => config.disableAppListLinks![key].test(table[key]) === false
);
}
return disabled;
};

const LineageList: React.FC<LineageListProps> = ({
items,
direction,
Expand All @@ -34,9 +46,11 @@ const LineageList: React.FC<LineageListProps> = ({
logging={logging}
key={`lineage-item::${index}`}
tableHighlights={getHighlightedTableMetadata(tableResource)}
disabled={isTableLinkDisabled(table)}
/>
);
})}
</div>
);

export default LineageList;