Skip to content

Commit

Permalink
feat(Export): Disable export to flame graph.com (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
grafakus authored Nov 13, 2024
1 parent 9527644 commit e631055
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 62 deletions.
25 changes: 0 additions & 25 deletions e2e/tests/settings-view/settings-view.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ test.describe('Plugin Settings', () => {
await expect(flamegraphSettings).toBeVisible();
await expect(flamegraphSettings.getByText('Collapsed flame graphs')).toBeVisible();
await expect(flamegraphSettings.getByText('Maximum number of nodes')).toBeVisible();

const exportSettings = settingsPage.getExportSettings();

await expect(exportSettings).toBeVisible();
await expect(exportSettings.getByText('Enable flamegraph.com')).toBeVisible();
});

test.describe('Flame graph settings', () => {
Expand Down Expand Up @@ -60,24 +55,4 @@ test.describe('Plugin Settings', () => {
});
});
});

test.describe('Export settings', () => {
test('Can be modified', async ({ settingsPage, exploreProfilesPage }) => {
await settingsPage.getEnableFlamegraphDotComCheckbox().click();
await settingsPage.getSaveSettingsButton().click();
await expect(settingsPage.getSuccessAlertDialog()).toBeVisible();

// flame graph
await exploreProfilesPage.goto(ExplorationType.FlameGraph);
await exploreProfilesPage.getExportDataButton().click();

await expect(exploreProfilesPage.getByText('flamegraph.com (public URL)')).not.toBeVisible();

// diff flame graph
await exploreProfilesPage.goto(ExplorationType.DiffFlameGraph, EXPLORE_PROFILES_DIFF_RANGES_URL_PARAMS);
await exploreProfilesPage.getExportDataButton().click();

await expect(exploreProfilesPage.getByText('flamegraph.com (public URL)')).not.toBeVisible();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export class SceneExportMenu extends SceneObjectBase<SceneExportMenuState> {
};

static Component = ({ model, query, timeRange }: SceneComponentProps<SceneExportMenu> & ExtraProps) => {
const { data, actions } = model.useSceneExportMenu({ query, timeRange });
const { actions } = model.useSceneExportMenu({ query, timeRange });

return (
<Dropdown
Expand All @@ -181,9 +181,6 @@ export class SceneExportMenu extends SceneObjectBase<SceneExportMenuState> {
<Menu.Item label="png" onClick={actions.downloadPng} />
<Menu.Item label="json" onClick={actions.downloadJson} />
<Menu.Item label="pprof" onClick={actions.downloadPprof} />
{data.shouldDisplayFlamegraphDotCom && (
<Menu.Item label="flamegraph.com (public URL)" onClick={actions.uploadToFlamegraphDotCom} />
)}
</Menu>
}
>
Expand Down
28 changes: 0 additions & 28 deletions src/pages/SettingsView/SettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,34 +47,6 @@ export function SettingsView() {
</InlineField>
</InlineFieldRow>
</FieldSet>
<FieldSet label="Export" data-testid="export-settings">
<InlineFieldRow>
<InlineField
label="Enable flamegraph.com"
labelWidth={24}
tooltip={
<div className={styles.tooltip}>
<p>
When enabled, this option allows users to export profiles to{' '}
<a href="https://flamegraph.com/" target="_blank" rel="noreferrer noopener">
flamegraph.com
</a>{' '}
and share interactive flamegraphs via <em>a public URL</em>.
</p>
<p>Disable this option if data privacy is a concern.</p>
</div>
}
interactive
>
<InlineSwitch
label="Toggle export to flamegraph.com"
name="export-flamegraph-com"
value={data.enableFlameGraphDotComExport}
onChange={actions.toggleEnableFlameGraphDotComExport}
/>
</InlineField>
</InlineFieldRow>
</FieldSet>
<FieldSet label="Function details" data-testid="function-details-settings">
<InlineFieldRow>
<InlineField
Expand Down
6 changes: 1 addition & 5 deletions src/shared/components/FlameGraph/components/ExportMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ import { useExportMenu } from './domain/useExportMenu';
import { ExportDataProps } from './ExportData';

export function ExportMenu(props: ExportDataProps) {
const { data, actions } = useExportMenu(props);
const { actions } = useExportMenu(props);

return (
<Menu>
<Menu.Item label="png" onClick={actions.downloadPng} />
<Menu.Item label="json" onClick={actions.downloadJson} />
{/* no pprof export, as the underlying API only accepts a single query (see PprofApiClient) */}
{data.shouldDisplayFlamegraphDotCom && (
<Menu.Item label="flamegraph.com (public URL)" onClick={actions.uploadToFlamegraphDotCom} />
)}
</Menu>
);
}

1 comment on commit e631055

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit test coverage

Lines Statements Branches Functions
Coverage: 13%
13.63% (544/3989) 10.42% (147/1410) 9.89% (125/1263)

Please sign in to comment.