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

report: save to trace-cafe storage for auth-less permalinks #15620

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6982,9 +6982,9 @@
"crcLongestDurationLabel": "Maximum critical path latency:",
"dropdownCopyJSON": "Copy JSON",
"dropdownDarkTheme": "Toggle Dark Theme",
"dropdownGetPermalink": "Get Permalink",
"dropdownPrintExpanded": "Print Expanded",
"dropdownPrintSummary": "Print Summary",
"dropdownSaveGist": "Save as Gist",
"dropdownSaveHTML": "Save as HTML",
"dropdownSaveJSON": "Save as JSON",
"dropdownViewer": "Open in Viewer",
Expand Down Expand Up @@ -11822,9 +11822,9 @@
"crcLongestDurationLabel": "Maximum critical path latency:",
"dropdownCopyJSON": "Copy JSON",
"dropdownDarkTheme": "Toggle Dark Theme",
"dropdownGetPermalink": "Get Permalink",
"dropdownPrintExpanded": "Print Expanded",
"dropdownPrintSummary": "Print Summary",
"dropdownSaveGist": "Save as Gist",
"dropdownSaveHTML": "Save as HTML",
"dropdownSaveJSON": "Save as JSON",
"dropdownViewer": "Open in Viewer",
Expand Down Expand Up @@ -16818,9 +16818,9 @@
"crcLongestDurationLabel": "Maximum critical path latency:",
"dropdownCopyJSON": "Copy JSON",
"dropdownDarkTheme": "Toggle Dark Theme",
"dropdownGetPermalink": "Get Permalink",
"dropdownPrintExpanded": "Print Expanded",
"dropdownPrintSummary": "Print Summary",
"dropdownSaveGist": "Save as Gist",
"dropdownSaveHTML": "Save as HTML",
"dropdownSaveJSON": "Save as JSON",
"dropdownViewer": "Open in Viewer",
Expand Down Expand Up @@ -24589,9 +24589,9 @@
"crcLongestDurationLabel": "Maximum critical path latency:",
"dropdownCopyJSON": "Copy JSON",
"dropdownDarkTheme": "Toggle Dark Theme",
"dropdownGetPermalink": "Get Permalink",
"dropdownPrintExpanded": "Print Expanded",
"dropdownPrintSummary": "Print Summary",
"dropdownSaveGist": "Save as Gist",
"dropdownSaveHTML": "Save as HTML",
"dropdownSaveJSON": "Save as JSON",
"dropdownViewer": "Open in Viewer",
Expand Down
2 changes: 1 addition & 1 deletion core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -9264,9 +9264,9 @@
"crcLongestDurationLabel": "Maximum critical path latency:",
"dropdownCopyJSON": "Copy JSON",
"dropdownDarkTheme": "Toggle Dark Theme",
"dropdownGetPermalink": "Get Permalink",
"dropdownPrintExpanded": "Print Expanded",
"dropdownPrintSummary": "Print Summary",
"dropdownSaveGist": "Save as Gist",
"dropdownSaveHTML": "Save as HTML",
"dropdownSaveJSON": "Save as JSON",
"dropdownViewer": "Open in Viewer",
Expand Down
8 changes: 4 additions & 4 deletions flow-report/src/topbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const Topbar: FunctionComponent<{onMenuClick: JSX.MouseEventHandler<HTMLButtonEl
const flowResult = useFlowResult();
const strings = useLocalizedStrings();
const [showHelpDialog, setShowHelpDialog] = useState(false);
const {getReportHtml, saveAsGist} = useOptions();
const {getReportHtml, uploadForPermalink} = useOptions();

return (
<div className="Topbar">
Expand All @@ -74,11 +74,11 @@ const Topbar: FunctionComponent<{onMenuClick: JSX.MouseEventHandler<HTMLButtonEl
>{strings.save}</TopbarButton>
}
{
saveAsGist &&
uploadForPermalink &&
<TopbarButton
onClick={() => saveAsGist(flowResult)}
onClick={() => uploadForPermalink(flowResult)}
label="Button that saves the report to a gist"
>{strings.dropdownSaveGist}</TopbarButton>
>{strings.dropdownGetPermalink}</TopbarButton>
}
<div style={{flexGrow: 1}} />
<TopbarButton
Expand Down
10 changes: 5 additions & 5 deletions flow-report/test/topbar-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ it('save button opens save dialog for HTML file', async () => {
);
});

it('provides save as gist option if defined', async () => {
const saveAsGist = jestMock.fn();
options = {saveAsGist};
it('provides permalink option if defined', async () => {
const uploadForPermalink = jestMock.fn();
options = {uploadForPermalink};
const root = render(<Topbar onMenuClick={() => {}}/>, {wrapper});

const saveButton = root.getByText('Save as Gist');
const saveButton = root.getByText('Get Permalink');
saveButton.click();

expect(saveAsGist).toHaveBeenCalledWith(flowResult);
expect(uploadForPermalink).toHaveBeenCalledWith(flowResult);
});

it('toggles help dialog', async () => {
Expand Down
2 changes: 1 addition & 1 deletion flow-report/types/flow-report.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ declare global {

export interface FlowReportOptions {
getReportHtml?: (flowResult: FlowResult_) => string;
saveAsGist?: (flowResult: FlowResult_) => void;
uploadForPermalink?: (flowResult: FlowResult_) => void;
}

export interface HashState {
Expand Down
6 changes: 3 additions & 3 deletions report/assets/templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@
background-color: var(--color-gray-200);
outline: none;
}
/* save-gist option hidden in report. */
.lh-tools__dropdown a[data-action='save-gist'] {
/* upload-for-permalink option hidden in report. */
.lh-tools__dropdown a[data-action='upload-for-permalink'] {
display: none;
}

Expand Down Expand Up @@ -350,7 +350,7 @@
<a role="menuitem" tabindex="-1" href="#" class="lh-report-icon lh-report-icon--download lh-hidden" data-i18n="dropdownSaveHTML" data-action="save-html"></a>
<a role="menuitem" tabindex="-1" href="#" class="lh-report-icon lh-report-icon--download" data-i18n="dropdownSaveJSON" data-action="save-json"></a>
<a role="menuitem" tabindex="-1" href="#" class="lh-report-icon lh-report-icon--open" data-i18n="dropdownViewer" data-action="open-viewer"></a>
<a role="menuitem" tabindex="-1" href="#" class="lh-report-icon lh-report-icon--open" data-i18n="dropdownSaveGist" data-action="save-gist"></a>
<a role="menuitem" tabindex="-1" href="#" class="lh-report-icon lh-report-icon--open" data-i18n="dropdownGetPermalink" data-action="upload-for-permalink"></a>
<!-- Only enabled if Options.onViewTrace is set and we are on simulated throttling. -->
<a role="menuitem" tabindex="-1" href="#" class="lh-report-icon lh-report-icon--open lh-hidden" data-i18n="dropdownViewUnthrottledTrace" data-action="view-unthrottled-trace"></a>
<a role="menuitem" tabindex="-1" href="#" class="lh-report-icon lh-report-icon--dark" data-i18n="dropdownDarkTheme" data-action="toggle-dark"></a>
Expand Down
6 changes: 3 additions & 3 deletions report/renderer/components.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions report/renderer/drop-down-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ export class DropDownMenu {
return false;
}

// 'Save as Gist' option may be disabled.
// 'Get Permalink' option may be disabled.
if (node.hasAttribute('disabled')) {
return false;
}

// 'Save as Gist' option may have display none.
// 'Get Permalink' option may have display none.
if (window.getComputedStyle(node).display === 'none') {
return false;
}
Expand Down
5 changes: 3 additions & 2 deletions report/renderer/report-ui-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,11 @@ export class ReportUIFeatures {

/**
* Save json as a gist. Unimplemented in base UI features.
* TODO: i think it can be in base now..
*/
saveAsGist() {
uploadForPermalink() {
// TODO ?
throw new Error('Cannot save as gist from base report');
throw new Error('Cannot Get Permalink from base report');
}

_enableFireworks() {
Expand Down
4 changes: 2 additions & 2 deletions report/renderer/report-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ const UIStrings = {
dropdownSaveJSON: 'Save as JSON',
/** Option in a dropdown menu that opens the current report in the Lighthouse Viewer Application. */
dropdownViewer: 'Open in Viewer',
/** Option in a dropdown menu that saves the current report as a new GitHub Gist. */
dropdownSaveGist: 'Save as Gist',
/** Option in a dropdown menu that gets a permalink URL for the current report. */
dropdownGetPermalink: 'Get Permalink',
/** Option in a dropdown menu that toggles the themeing of the report between Light(default) and Dark themes. */
dropdownDarkTheme: 'Toggle Dark Theme',
/** Option in a dropdown menu that opens the trace of the page without throttling. "Unthrottled" can be replaced with "Original". */
Expand Down
4 changes: 2 additions & 2 deletions report/renderer/topbar-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ export class TopbarFeatures {
}
break;
}
case 'save-gist': {
this._reportUIFeatures.saveAsGist();
case 'upload-for-permalink': {
this._reportUIFeatures.uploadForPermalink();
break;
}
case 'toggle-dark': {
Expand Down
3 changes: 0 additions & 3 deletions shared/localization/locales/ar-XB.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions shared/localization/locales/ar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions shared/localization/locales/bg.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions shared/localization/locales/ca.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions shared/localization/locales/cs.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions shared/localization/locales/da.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions shared/localization/locales/de.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions shared/localization/locales/el.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions shared/localization/locales/en-GB.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.