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 all 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 @@ -6984,9 +6984,9 @@
"dropdownDarkTheme": "Toggle Dark Theme",
"dropdownPrintExpanded": "Print Expanded",
"dropdownPrintSummary": "Print Summary",
"dropdownSaveGist": "Save as Gist",
"dropdownSaveHTML": "Save as HTML",
"dropdownSaveJSON": "Save as JSON",
"dropdownShareableURL": "Upload for Shareable URL",
"dropdownViewer": "Open in Viewer",
"dropdownViewUnthrottledTrace": "View Unthrottled Trace",
"errorLabel": "Error!",
Expand Down Expand Up @@ -11824,9 +11824,9 @@
"dropdownDarkTheme": "Toggle Dark Theme",
"dropdownPrintExpanded": "Print Expanded",
"dropdownPrintSummary": "Print Summary",
"dropdownSaveGist": "Save as Gist",
"dropdownSaveHTML": "Save as HTML",
"dropdownSaveJSON": "Save as JSON",
"dropdownShareableURL": "Upload for Shareable URL",
"dropdownViewer": "Open in Viewer",
"dropdownViewUnthrottledTrace": "View Unthrottled Trace",
"errorLabel": "Error!",
Expand Down Expand Up @@ -16820,9 +16820,9 @@
"dropdownDarkTheme": "Toggle Dark Theme",
"dropdownPrintExpanded": "Print Expanded",
"dropdownPrintSummary": "Print Summary",
"dropdownSaveGist": "Save as Gist",
"dropdownSaveHTML": "Save as HTML",
"dropdownSaveJSON": "Save as JSON",
"dropdownShareableURL": "Upload for Shareable URL",
"dropdownViewer": "Open in Viewer",
"dropdownViewUnthrottledTrace": "View Unthrottled Trace",
"errorLabel": "Error!",
Expand Down Expand Up @@ -24591,9 +24591,9 @@
"dropdownDarkTheme": "Toggle Dark Theme",
"dropdownPrintExpanded": "Print Expanded",
"dropdownPrintSummary": "Print Summary",
"dropdownSaveGist": "Save as Gist",
"dropdownSaveHTML": "Save as HTML",
"dropdownSaveJSON": "Save as JSON",
"dropdownShareableURL": "Upload for Shareable URL",
"dropdownViewer": "Open in Viewer",
"dropdownViewUnthrottledTrace": "View Unthrottled Trace",
"errorLabel": "Error!",
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 @@ -9266,9 +9266,9 @@
"dropdownDarkTheme": "Toggle Dark Theme",
"dropdownPrintExpanded": "Print Expanded",
"dropdownPrintSummary": "Print Summary",
"dropdownSaveGist": "Save as Gist",
"dropdownSaveHTML": "Save as HTML",
"dropdownSaveJSON": "Save as JSON",
"dropdownShareableURL": "Upload for Shareable URL",
"dropdownViewer": "Open in Viewer",
"dropdownViewUnthrottledTrace": "View Unthrottled Trace",
"errorLabel": "Error!",
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.dropdownShareableURL}</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('Upload for Shareable URL');
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
5 changes: 4 additions & 1 deletion proto/lighthouse-result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ message I18n {

// Option in a dropdown menu that saves the current report as a new GitHub
// Gist.
string dropdown_save_gist = 38;
string dropdown_save_gist = 38 [deprecated = true];

// Option in a dropdown menu that saves the Lighthouse report HTML locally
// to the system as a '.html' file.
Expand Down Expand Up @@ -668,6 +668,9 @@ message I18n {

// Descriptive label that this analysis considers a snapshot of the page at a single point in time
string runtime_analysis_window_snapshot = 66;

// Option in a dropdown menu that gets a shareable URL for the current report.
string dropdown_shareable_URL = 67;
}

// The message holding all formatted strings used in the renderer.
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="dropdownShareableURL" 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.
// 'Upload for Shareable URL' option may be disabled.
if (node.hasAttribute('disabled')) {
return false;
}

// 'Save as Gist' option may have display none.
// 'Upload for Shareable URL' 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 @@

/**
* 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 Upload for Shareable URL from base report');

Check warning on line 180 in report/renderer/report-ui-features.js

View check run for this annotation

Codecov / codecov/patch

report/renderer/report-ui-features.js#L180

Added line #L180 was not covered by tests
}

_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 shareable URL for the current report. */
dropdownShareableURL: 'Upload for Shareable URL',
/** 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 @@
}
break;
}
case 'save-gist': {
this._reportUIFeatures.saveAsGist();
case 'upload-for-permalink': {
this._reportUIFeatures.uploadForPermalink();

Check warning on line 110 in report/renderer/topbar-features.js

View check run for this annotation

Codecov / codecov/patch

report/renderer/topbar-features.js#L110

Added line #L110 was not covered by tests
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.