Skip to content

Commit

Permalink
fix(embedded): Hide dashboard fullscreen option for embedded context (#…
Browse files Browse the repository at this point in the history
…26412)

(cherry picked from commit 494068b)
  • Loading branch information
Vitor-Avila authored and michael-s-molina committed Jan 18, 2024
1 parent bd60b05 commit 21ba6ca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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 @@ -133,6 +141,14 @@ test('should render the menu items in edit mode', async () => {
expect(screen.getByText('Edit CSS')).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 @@ -236,6 +236,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 @@ -257,7 +259,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

0 comments on commit 21ba6ca

Please sign in to comment.