question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use the new `toast` component in `restore-file`

See original GitHub issue

restore-file changes the menu item inline

But instead of changing the menu, we should use the new toast introduced by https://github.com/sindresorhus/refined-github/pull/4016

gif

Some changes will be needed in the toast to show possible errors. Refer to https://primer.style/css/components/toasts for classnames and icons.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
yakov116commented, Aug 25, 2021

I think the update branch feature and maybe clone-branch, git-reblame.

Basically wherever we are using the loading icon. (On mobile this is what I can think of offhand)

1reaction
fregantecommented, Aug 19, 2021

Probably you’ll want to change this:

https://github.com/sindresorhus/refined-github/blob/ba878fc91552f41f1860a70864917ca3c40914f4/source/features/restore-file.tsx#L86-L109

To something like:

async function restoreFile() {
	const file = await getFile(filePath);

	if (!file) {
		// The file was created by this PR.
		// This code won’t be reached if `highlight-deleted-and-added-files-in-diffs` works.
		throw new Error('Nothing to restore. Delete file instead');
		return;
	}

	if (file.isTruncated) {
		throw new Error('Restore failed: File too big');
		return;
	}

	await commitFileContent(menuItem, file.text, filePath);
}

try {
	const filePath = menuItem.closest<HTMLDivElement>('[data-path]')!.dataset.path!;
	const task = restoreFile(filePath);
	showToast(task);

	// Hide file from view
	await task;
	menuItem.closest('.file')!.remove();
} catch (error: unknown) {
	features.error(__filebasename, error);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to create a custom toast component with React
Inside src , create a new folder called components . We'll add our toast and button components to this folder. In React, you...
Read more >
Building a toast component - web.dev
A foundational overview of how to build an adaptive and accessible toast component.
Read more >
Toast Notifications - Salesforce Lightning Component Library
A component can send a toast notification that pops up to alert users of a success, error, or warning. A toast can also...
Read more >
Toast - Shopify Polaris
The toast component is a non-disruptive message that appears at the bottom of the interface to provide quick, at-a-glance feedback on the outcome...
Read more >
Lightning Web Component(LWC) Toast Messages - SfdcPoint
Lightning Web component LWC Toast Messages.LWC can send a toast notification that pops up to alert users of success, error or warning.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found