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

Add recommendation to enable 'preserve log' #125

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions front_end/panels/console/ConsoleView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,14 @@ export class ConsoleView extends UI.Widget.VBox implements
if (!Common.Settings.Settings.instance().moduleSetting('preserve-console-log').get() &&
model.target().outermostTarget() === model.target()) {
this.consoleCleared();
this.addConsoleMessage(new SDK.ConsoleModel.ConsoleMessage(
model.target().model(SDK.RuntimeModel.RuntimeModel), Protocol.Log.LogEntrySource.Recommendation,
Protocol.Log.LogEntryLevel.Info,
'[React Native] Console messages are currently cleared upon DevTools disconnection. You can preserve logs in settings: ',
{
type: SDK.ConsoleModel.FrontendMessageType.System,
context: 'fusebox_preserve_log_rec',
}));
}
}

Expand Down
11 changes: 11 additions & 0 deletions front_end/panels/console/ConsoleViewMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,17 @@ export class ConsoleViewMessage implements ConsoleViewportElement {
formattedMessage.appendChild(this.anchorElement);
}
formattedMessage.appendChild(messageElement);

if (this.message.context === 'fusebox_preserve_log_rec') {
const link = document.createElement('button');
link.classList.add('devtools-link', 'text-button', 'link-style');
link.appendChild(link.ownerDocument.createTextNode('show settings'));
link.addEventListener('click', async () => {
await Common.Revealer.reveal(Common.Settings.Settings.instance().moduleSetting('preserve-console-log'));
});
formattedMessage.appendChild(link);
}

return formattedMessage;
}

Expand Down
1 change: 1 addition & 0 deletions front_end/ui/components/settings/settingCheckbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

:host {
display: block;
Copy link
Author

Choose a reason for hiding this comment

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

Needed for the existing animation util to work.

The util attempts to animation the background on a Shadow DOM element <setting-checkbox>:

But since the host element is not a block by default, the background wouldn't be applied:
https://stackoverflow.com/a/60702911

padding: 0;
margin: 0;
}
Expand Down
Loading