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

This commit is contained in:
Vitor Avila 2024-01-11 16:44:12 -03:00 committed by GitHub
parent 0f8a3b31d3
commit 494068b632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -92,6 +92,14 @@ const editModeOnWithFilterScopesProps = {
},
};
const guestUserProps = {
...createProps(),
dashboardInfo: {
...createProps().dashboardInfo,
userId: undefined,
},
};
function setup(props: HeaderDropdownProps) {
return render(
<div className="dashboard-header">
@ -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

View File

@ -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(),
@ -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}