Skip to content

[API Feature Request] Show Alerts #48

@SvenTiigi

Description

@SvenTiigi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiIssues related to APIfeature requestNew feature or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions