mirror of
https://github.com/safing/portmaster.git
synced 2026-05-20 20:40:36 +00:00
feat(UI/notifications): add "in-app-only" action visibility
Actions with visibility "in-app-only" are shown in the UI but skipped when displaying system-level notifications (Tauri/OS). Updates Go, TypeScript/Angular and Rust projects accordingly.
This commit is contained in:
@@ -136,6 +136,8 @@ const (
|
||||
// Visible only in extended view
|
||||
// (when user clicks on notification to read full message)
|
||||
ActionVisibilityDetailed ActionVisibility = "detailed"
|
||||
// Visible only in the UI app, never on the system level (if ShowOnSystem is true).
|
||||
ActionVisibilityInAppOnly ActionVisibility = "in-app-only"
|
||||
)
|
||||
|
||||
// ActionType defines a specific type of action.
|
||||
|
||||
@@ -19,6 +19,7 @@ export interface BaseAction {
|
||||
// Possible values are:
|
||||
// - "": Action is always visible.
|
||||
// - "detailed": Action is only visible in the detailed view of a notification.
|
||||
// - "in-app-only": Visible only in the UI app, never on the system level (if ShowOnSystem is true).
|
||||
Visibility: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</span>
|
||||
<div class="buttons">
|
||||
<ng-container *ngFor="let action of notif!.AvailableActions">
|
||||
<button *ngIf="action.Visibility !== 'detailed'" (click)="execute(notif!, action, $event)">
|
||||
<button *ngIf="!action.Visibility || action.Visibility === 'in-app-only'" (click)="execute(notif!, action, $event)">
|
||||
{{action.Text}}
|
||||
</button>
|
||||
</ng-container>
|
||||
|
||||
@@ -51,6 +51,9 @@ pub struct Action {
|
||||
|
||||
#[serde(rename = "Payload")]
|
||||
pub payload: serde_json::Value,
|
||||
|
||||
#[serde(rename = "Visibility")]
|
||||
pub visibility: String, // "" - default, "detailed" - only show if the notification is expanded
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
|
||||
@@ -57,6 +57,9 @@ pub async fn show_notification(cli: &PortAPI, key: String, n: Notification) {
|
||||
notif.icon("portmaster");
|
||||
|
||||
for action in n.actions {
|
||||
if !action.visibility.is_empty() {
|
||||
continue
|
||||
}
|
||||
notif.action(&action.id, &action.text);
|
||||
}
|
||||
|
||||
@@ -113,6 +116,9 @@ pub async fn show_notification(cli: &PortAPI, key: String, n: Notification) {
|
||||
.duration(Duration::Long);
|
||||
|
||||
for action in n.actions {
|
||||
if !action.visibility.is_empty() {
|
||||
continue
|
||||
}
|
||||
toast = toast.add_button(&action.text, &action.id);
|
||||
}
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user