Skip to content

Commit

Permalink
fix: don't show metadata for embedded dashboards (#30875)
Browse files Browse the repository at this point in the history
  • Loading branch information
sadpandajoe authored Nov 12, 2024
1 parent c2885a1 commit ac3a10d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
45 changes: 45 additions & 0 deletions superset-frontend/src/dashboard/components/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,48 @@ test('should render an extension component if one is supplied', () => {
screen.getByText('dashboard.nav.right extension component'),
).toBeInTheDocument();
});

test('should NOT render MetadataBar when in edit mode', () => {
const mockedProps = {
...createProps(),
editMode: true,
dashboardInfo: {
...createProps().dashboardInfo,
userId: '123',
},
};
setup(mockedProps);
expect(
screen.queryByText(mockedProps.dashboardInfo.changed_on_delta_humanized),
).not.toBeInTheDocument();
});

test('should NOT render MetadataBar when embedded', () => {
const mockedProps = {
...createProps(),
editMode: false,
dashboardInfo: {
...createProps().dashboardInfo,
userId: undefined,
},
};
setup(mockedProps);
expect(
screen.queryByText(mockedProps.dashboardInfo.changed_on_delta_humanized),
).not.toBeInTheDocument();
});

test('should render MetadataBar when not in edit mode and not embedded', () => {
const mockedProps = {
...createProps(),
editMode: false,
dashboardInfo: {
...createProps().dashboardInfo,
userId: '123',
},
};
setup(mockedProps);
expect(
screen.getByText(mockedProps.dashboardInfo.changed_on_delta_humanized),
).toBeInTheDocument();
});
3 changes: 2 additions & 1 deletion superset-frontend/src/dashboard/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ class Header extends PureComponent {
const refreshWarning =
dashboardInfo.common?.conf
?.SUPERSET_DASHBOARD_PERIODICAL_REFRESH_WARNING_MESSAGE;
const isEmbedded = !dashboardInfo?.userId;

const handleOnPropertiesChange = updates => {
const { dashboardInfoChanged, dashboardTitleChanged } = this.props;
Expand Down Expand Up @@ -553,7 +554,7 @@ class Header extends PureComponent {
visible={!editMode}
/>
),
!editMode && (
!editMode && !isEmbedded && (
<MetadataBar
items={this.getMetadataItems()}
tooltipPlacement="bottom"
Expand Down

0 comments on commit ac3a10d

Please # to comment.