diff options
| author | Jae-Heon Ji <32578710+jaeheonji@users.noreply.github.com> | 2023-08-12 22:35:42 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-12 15:35:42 +0200 |
| commit | c8ddb23297e2f4fc900b8286d57e2808ae6a4fdb (patch) | |
| tree | c96d26c8bfc24172374aefe88624b78c6890663f /zellij-utils/src/plugin_api/event.rs | |
| parent | docs(changelog): protobuffers (diff) | |
| download | sl0ppij-c8ddb23297e2f4fc900b8286d57e2808ae6a4fdb.tar.gz sl0ppij-c8ddb23297e2f4fc900b8286d57e2808ae6a4fdb.tar.xz sl0ppij-c8ddb23297e2f4fc900b8286d57e2808ae6a4fdb.zip | |
feat: add plugin permission system (#2624)
* WIP: add exaple of permission ui
* feat: add request permission ui
* feat: add caching permission in memory
* feat: add permission check
* feat: add file caching
* fix: changes request
* feat(ui): new status bar mode (#2619)
* supermode prototype
* fix integration tests
* fix tests
* style(fmt): rustfmt
* docs(changelog): status-bar supermode
* fix(rendering): occasional glitches while resizing (#2621)
* docs(changelog): resize glitches fix
* chore(version): bump development version
* Fix colored pane frames in mirrored sessions (#2625)
* server/panes/tiled: Fix colored frames
in mirrored sessions. Colored frames were previously ignored because
they were treated like floating panes when rendering tiled panes.
* CHANGELOG: Add PR #2625
* server/tab/unit: Fix unit tests for server.
* fix(sessions): use custom lists of adjectives and nouns for generating session names (#2122)
* Create custom lists of adjectives and nouns for generating session names
* move word lists to const slices
* add logic to retry name generation
* refactor
- reuse the name generator
- iterator instead of for loop
---------
Co-authored-by: Thomas Linford <linford.t@gmail.com>
* docs(changelog): generate session names with custom words list
* feat(plugins): make plugins configurable (#2646)
* work
* make every plugin entry point configurable
* make integration tests pass
* make e2e tests pass
* add test for plugin configuration
* add test snapshot
* add plugin config parsing test
* cleanups
* style(fmt): rustfmt
* style(comment): remove commented code
* docs(changelog): configurable plugins
* style(fmt): rustfmt
* touch up ui
* fix: don't save permission data in memory
* feat: load cached permission
* test: add example test (WIP)
* fix: issue event are always denied
* test: update snapshot
* apply formatting
* refactor: update default cache function
* test: add more new test
* apply formatting
* Revert "apply formatting"
This reverts commit a4e93703fbfdb6865131daa1c8b90fc5c36ab25e.
* apply format
* fix: update cache path
* apply format
* fix: cache path
* fix: update log level
* test for github workflow
* Revert "test for github workflow"
This reverts commit 01eff3bc5d1627a4e60bc6dac8ebe5500bc5b56e.
* refactor: permission cache
* fix(test): permission grant/deny race condition
* style(fmt): rustfmt
* style(fmt): rustfmt
* configure permissions
* permission denied test
* snapshot
* add ui for small plugins
* style(fmt): rustfmt
* some cleanups
---------
Co-authored-by: Aram Drevekenin <aram@poor.dev>
Co-authored-by: har7an <99636919+har7an@users.noreply.github.com>
Co-authored-by: Kyle Sutherland-Cash <kyle.sutherlandcash@gmail.com>
Co-authored-by: Thomas Linford <linford.t@gmail.com>
Co-authored-by: Thomas Linford <tlinford@users.noreply.github.com>
Diffstat (limited to 'zellij-utils/src/plugin_api/event.rs')
| -rw-r--r-- | zellij-utils/src/plugin_api/event.rs | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs index 315fa54b..6115fe1e 100644 --- a/zellij-utils/src/plugin_api/event.rs +++ b/zellij-utils/src/plugin_api/event.rs @@ -13,9 +13,10 @@ pub use super::generated_api::api::{ style::Style as ProtobufStyle, }; use crate::data::{ - CopyDestination, Direction, Event, EventType, InputMode, Key, ModeInfo, Mouse, Palette, - PaletteColor, PaneInfo, PaneManifest, PluginCapabilities, Style, TabInfo, ThemeHue, + CopyDestination, Event, EventType, InputMode, Key, ModeInfo, Mouse, PaneInfo, PaneManifest, + PermissionStatus, PluginCapabilities, Style, TabInfo, }; + use crate::errors::prelude::*; use crate::input::actions::Action; @@ -160,6 +161,16 @@ impl TryFrom<ProtobufEvent> for Event { }, _ => Err("Malformed payload for the file system delete Event"), }, + Some(ProtobufEventType::PermissionRequestResult) => match protobuf_event.payload { + Some(ProtobufEventPayload::PermissionRequestResultPayload(payload)) => { + if payload.granted { + Ok(Event::PermissionRequestResult(PermissionStatus::Granted)) + } else { + Ok(Event::PermissionRequestResult(PermissionStatus::Denied)) + } + }, + _ => Err("Malformed payload for the file system delete Event"), + }, None => Err("Unknown Protobuf Event"), } } @@ -290,6 +301,18 @@ impl TryFrom<Event> for ProtobufEvent { payload: Some(event::Payload::FileListPayload(file_list_payload)), }) }, + Event::PermissionRequestResult(permission_status) => { + let granted = match permission_status { + PermissionStatus::Granted => true, + PermissionStatus::Denied => false, + }; + Ok(ProtobufEvent { + name: ProtobufEventType::PermissionRequestResult as i32, + payload: Some(event::Payload::PermissionRequestResultPayload( + PermissionRequestResultPayload { granted }, + )), + }) + }, } } } @@ -673,6 +696,7 @@ impl TryFrom<ProtobufEventType> for EventType { ProtobufEventType::FileSystemRead => EventType::FileSystemRead, ProtobufEventType::FileSystemUpdate => EventType::FileSystemUpdate, ProtobufEventType::FileSystemDelete => EventType::FileSystemDelete, + ProtobufEventType::PermissionRequestResult => EventType::PermissionRequestResult, }) } } @@ -696,6 +720,7 @@ impl TryFrom<EventType> for ProtobufEventType { EventType::FileSystemRead => ProtobufEventType::FileSystemRead, EventType::FileSystemUpdate => ProtobufEventType::FileSystemUpdate, EventType::FileSystemDelete => ProtobufEventType::FileSystemDelete, + EventType::PermissionRequestResult => ProtobufEventType::PermissionRequestResult, }) } } @@ -717,6 +742,7 @@ fn serialize_mode_update_event() { #[test] fn serialize_mode_update_event_with_non_default_values() { + use crate::data::{Direction, Palette, PaletteColor, ThemeHue}; use prost::Message; let mode_update_event = Event::ModeUpdate(ModeInfo { mode: InputMode::Locked, |
