Skip to content

Commit

Permalink
Use standalone mode to determine of report is running
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje committed Nov 20, 2023
1 parent 9346f27 commit daca59f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,10 @@ test('Add extension to SliceHeader', () => {
expect(screen.getByText('This is an extension')).toBeInTheDocument();
});

test('Do not display slice header controls if user is a bot', () => {
Object.defineProperty(window.navigator, 'webdriver', {
test('Do not display slice header controls in reports', () => {
Object.defineProperty(window, 'location', {
get() {
return true;
return { search: 'standalone=3' };
},
});
const props = createProps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ import SliceHeaderControls, {
} from 'src/dashboard/components/SliceHeaderControls';
import FiltersBadge from 'src/dashboard/components/FiltersBadge';
import Icons from 'src/components/Icons';
import { getUrlParam } from 'src/utils/urlUtils';
import { URL_PARAMS } from 'src/constants';
import { RootState } from 'src/dashboard/types';
import { getSliceHeaderTooltip } from 'src/dashboard/util/getSliceHeaderTooltip';
import { DashboardStandaloneMode } from 'src/dashboard/util/constants';
import { DashboardPageIdContext } from 'src/dashboard/containers/DashboardPage';
import { isCurrentUserBot } from 'src/utils/isBot';

const extensionsRegistry = getExtensionsRegistry();

Expand Down Expand Up @@ -177,6 +179,9 @@ const SliceHeader: FC<SliceHeaderProps> = ({
({ dashboardInfo }) => dashboardInfo.crossFiltersEnabled,
);

const standaloneMode = getUrlParam(URL_PARAMS.standalone);
const isReport = standaloneMode === DashboardStandaloneMode.REPORT;

const canExplore = !editMode && supersetCanExplore;

useEffect(() => {
Expand Down Expand Up @@ -241,7 +246,7 @@ const SliceHeader: FC<SliceHeaderProps> = ({
)}
</div>
<div className="header-controls">
{!editMode && !isCurrentUserBot() && (
{!editMode && !isReport && (
<>
{SliceHeaderExtension && (
<SliceHeaderExtension
Expand Down

0 comments on commit daca59f

Please sign in to comment.