extensions icon indicating copy to clipboard operation
extensions copied to clipboard

[API Feature Request] Show Alerts

Open SvenTiigi opened this issue 5 years ago • 1 comments

Describe the feature and the current behavior/state.

An API to display Alerts to the user just like the System Extensions does when rebooting the system.

Bildschirmfoto 2021-10-15 um 19 22 27

Will this change the current api? How?

As this is an API feature request only additions would happen to the Raycast API. The implementation could be based on the Toast API.

Example:

// Initialize a new Alert
const alert = new Alert({
  icon: Icon.Finder,
  title: 'Restart system',
  message: 'Are you sure you want to restart your computer now?',
  buttons: [
    {
      title: 'Cancel',
      style: AlertButtonStyle.cancel,
      action: () => {
        // Perform cancel action
      }
    },
    {
      title: 'Restart',
      style: AlertButtonStyle.destructive,
      action: () => {
        // Perform restart action
      }
    }
  ]
})

// Show Alert
await alert.show();

Additionally, adding a convenience function showAlert would be beneficial as the Toast API has an equivalent with showToast

Who will benefit with this feature?

Developers could add Alerts to get the user confirmation before executing a certain function for example a destructive action like deleting an entry.

SvenTiigi avatar Oct 15 '21 17:10 SvenTiigi

Will certainly happen at some point. Either as free form API to show alerts or as attribute in actions to show confirmation popup.

PitNikola avatar Oct 20 '21 18:10 PitNikola