Files
custum-hyprpanel/modules/notifications/actions/index.ts
Jas Singh 2c72cc66d8 Implemented strict linting standards and prettier formatting config. (#248)
* Implemented strict linting standards and prettier formatting config.

* More linter fixes and type updates.

* More linter updates and type fixes

* Remove noisy comments

* Linter and type updates

* Linter, formatting and type updates.

* Linter updates

* Type updates

* Type updates

* fixed all linter errors

* Fixed all linting, formatting and type issues.

* Resolve merge conflicts.
2024-09-14 16:20:05 -07:00

48 lines
1.8 KiB
TypeScript

import { Attribute, Child } from 'lib/types/widget';
import { Notification, Notifications } from 'types/service/notifications';
import Box from 'types/widgets/box';
const Action = (notif: Notification, notifs: Notifications): Box<Child, Attribute> => {
if (notif.actions !== undefined && notif.actions.length > 0) {
return Widget.Box({
class_name: 'notification-card-actions',
hexpand: true,
vpack: 'end',
children: notif.actions.map((action) => {
return Widget.Button({
hexpand: true,
class_name: 'notification-action-buttons',
on_primary_click: () => {
if (action.id.includes('scriptAction:-')) {
Utils.execAsync(`${action.id.replace('scriptAction:-', '')}`).catch((err) =>
console.error(err),
);
notifs.CloseNotification(notif.id);
} else {
notif.invoke(action.id);
}
},
child: Widget.Box({
hpack: 'center',
hexpand: true,
children: [
Widget.Label({
class_name: 'notification-action-buttons-label',
hexpand: true,
label: action.label,
max_width_chars: 15,
truncate: 'end',
wrap: true,
}),
],
}),
});
}),
});
}
return Widget.Box();
};
export { Action };