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

Display datahub link for datasets with defined URN #177

Merged
merged 12 commits into from
Jul 28, 2022
65 changes: 65 additions & 0 deletions superset-frontend/src/assets/images/icons/datahub.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions superset-frontend/src/components/Icons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const IconFileNames = [
'copy',
'cursor_target',
'database',
'datahub',
'dataset_physical',
'dataset_virtual_greyscale',
'dataset_virtual',
Expand Down
7 changes: 7 additions & 0 deletions superset-frontend/src/dashboard/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import setPeriodicRunner, {
import { options as PeriodicRefreshOptions } from 'src/dashboard/components/RefreshIntervalModal';
import findPermission from 'src/dashboard/util/findPermission';
import { FILTER_BOX_MIGRATION_STATES } from 'src/explore/constants';
import { datahubUrl } from 'src/preamble';
import { DashboardEmbedModal } from '../DashboardEmbedControls';

const propTypes = {
Expand Down Expand Up @@ -563,6 +564,12 @@ class Header extends React.PureComponent {
showTooltip
/>
)}
<a
href={`${datahubUrl}dashboard/urn:li:dashboard:(superset,${dashboardInfo.id})`}
style={{ paddingLeft: '0.5em' }}
>
<Icons.Datahub viewBox="0 0 180 180" />
</a>
</div>

<div className="button-container">
Expand Down
2 changes: 2 additions & 0 deletions superset-frontend/src/preamble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ const getMe = makeApi<void, User>({
endpoint: '/api/v1/me/',
});

export const datahubUrl = bootstrapData?.common?.datahub_url;

/**
* When you re-open the window, we check if you are still logged in.
* If your session expired or you signed out, we'll redirect to login.
Expand Down
21 changes: 21 additions & 0 deletions superset-frontend/src/views/CRUD/data/dataset/DatasetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import ImportModelsModal from 'src/components/ImportModal/index';
import { isFeatureEnabled, FeatureFlag } from 'src/featureFlags';
import WarningIconWithTooltip from 'src/components/WarningIconWithTooltip';
import { isUserAdmin } from 'src/dashboard/util/findPermission';
import { datahubUrl } from 'src/preamble';
import AddDatasetModal from './AddDatasetModal';

import {
Expand Down Expand Up @@ -301,6 +302,26 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
Header: t('Name'),
accessor: 'table_name',
},
{
Cell: ({
row: {
original: { extra },
},
}: any) => {
const parsedExtra = JSON.parse(extra);
if (parsedExtra?.urn) {
return (
<a href={datahubUrl + parsedExtra?.urn}>
<Icons.Datahub viewBox="0 0 180 180" />
</a>
);
}
return null;
},
accessor: 'datahub_link',
disableSortBy: true,
size: 'xs',
},
{
Cell: ({
row: {
Expand Down
2 changes: 2 additions & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,8 @@ def SQL_QUERY_MUTATOR( # pylint: disable=invalid-name,unused-argument
# Set to False to only allow viewing own recent activity
ENABLE_BROAD_ACTIVITY_ACCESS = True

DATAHUB_URL = "https://localhost:9002/"
reesercollins marked this conversation as resolved.
Show resolved Hide resolved

# -------------------------------------------------------------------
# * WARNING: STOP EDITING HERE *
# -------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ def common_bootstrap_payload() -> Dict[str, Any]:
"extra_categorical_color_schemes": conf["EXTRA_CATEGORICAL_COLOR_SCHEMES"],
"theme_overrides": conf["THEME_OVERRIDES"],
"menu_data": menu_data(),
"datahub_url": conf.get("DATAHUB_URL", ""),
}
bootstrap_data.update(conf["COMMON_BOOTSTRAP_OVERRIDES_FUNC"](bootstrap_data))
return bootstrap_data
Expand Down