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

fix(embedded): Hide dashboard fullscreen option for embedded context #26412

Merged
merged 2 commits into from
Jan 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ const editModeOnWithFilterScopesProps = {
},
};

const guestUserProps = {
...createProps(),
dashboardInfo: {
...createProps().dashboardInfo,
userId: undefined,
},
};

function setup(props: HeaderDropdownProps) {
return render(
<div className="dashboard-header">
Expand Down Expand Up @@ -134,6 +142,14 @@ test('should render the menu items in edit mode', async () => {
expect(screen.getByText('Download')).toBeInTheDocument();
});

test('should render the menu items in Embedded mode', async () => {
setup(guestUserProps);
expect(screen.getAllByRole('menuitem')).toHaveLength(3);
expect(screen.getByText('Refresh dashboard')).toBeInTheDocument();
expect(screen.getByText('Download')).toBeInTheDocument();
expect(screen.getByText('Set auto-refresh interval')).toBeInTheDocument();
});

describe('with native filters feature flag disabled', () => {
beforeAll(() => {
isFeatureEnabledMock = jest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ class HeaderActionsDropdown extends React.PureComponent {
const emailSubject = `${emailTitle} ${dashboardTitle}`;
const emailBody = t('Check out this dashboard: ');

const isEmbedded = !dashboardInfo?.userId;

const url = getDashboardUrl({
pathname: window.location.pathname,
filters: getActiveFilters(),
Expand All @@ -237,7 +239,7 @@ class HeaderActionsDropdown extends React.PureComponent {
{t('Refresh dashboard')}
</Menu.Item>
)}
{!editMode && (
{!editMode && !isEmbedded && (
<Menu.Item
key={MENU_KEYS.TOGGLE_FULLSCREEN}
onClick={this.handleMenuClick}
Expand Down
Loading