Radish alpha
r
rad:z39mP9rQAaGmERfUMPULfPUi473tY
Radicle terminal user interface
Radicle
Git
all: Fix realm commands
Merged did:key:z6MkswQE...2C1V opened 2 years ago
8 files changed +20 -58 92e677fa b56c11da
modified bin/commands/inbox/realm/select/page.rs
@@ -15,6 +15,8 @@ use tui::realm::ui::widget::context::{Progress, Shortcuts};
use tui::realm::ui::widget::Widget;
use tui::realm::ViewPage;

+
use crate::tui_inbox::common::SelectionMode;
+

use super::{ui, Application, Cid, ListCid, Message, Mode};

///
@@ -92,8 +94,8 @@ impl ViewPage<Cid, Message> for ListView {
            .to_boxed();
        self.shortcuts = browser.as_ref().shortcuts();

-
        match self.mode {
-
            Mode::Id => {
+
        match self.mode.selection() {
+
            SelectionMode::Id => {
                let notif_browser =
                    ui::id_select(theme, context, self.filter.clone(), self.sort_by, None)
                        .to_boxed();
@@ -101,7 +103,7 @@ impl ViewPage<Cid, Message> for ListView {

                app.remount(Cid::List(ListCid::NotificationBrowser), browser, vec![])?;
            }
-
            Mode::Operation => {
+
            SelectionMode::Operation => {
                let notif_browser =
                    ui::operation_select(theme, context, self.filter.clone(), self.sort_by, None)
                        .to_boxed();
modified bin/commands/issue/realm/select/event.rs
@@ -126,17 +126,6 @@ impl tuirealm::Component<Message, NoUserEvent> for Widget<OperationSelect> {
                Message::Quit(Some(selection))
            }),
            Event::Keyboard(KeyEvent {
-
                code: Key::Char('d'),
-
                ..
-
            }) => submit().map(|id| {
-
                let selection = Selection {
-
                    operation: Some(IssueOperation::Delete.to_string()),
-
                    ids: vec![id],
-
                    args: vec![],
-
                };
-
                Message::Quit(Some(selection))
-
            }),
-
            Event::Keyboard(KeyEvent {
                code: Key::Char('e'),
                ..
            }) => submit().map(|id| {
@@ -147,17 +136,6 @@ impl tuirealm::Component<Message, NoUserEvent> for Widget<OperationSelect> {
                };
                Message::Quit(Some(selection))
            }),
-
            Event::Keyboard(KeyEvent {
-
                code: Key::Char('m'),
-
                ..
-
            }) => submit().map(|id| {
-
                let selection = Selection {
-
                    operation: Some(IssueOperation::Comment.to_string()),
-
                    ids: vec![id],
-
                    args: vec![],
-
                };
-
                Message::Quit(Some(selection))
-
            }),
            _ => None,
        }
    }
modified bin/commands/issue/realm/select/ui.rs
@@ -91,9 +91,7 @@ impl OperationSelect {
                &self.theme,
                vec![
                    tui::realm::ui::shortcut(&self.theme, "enter", "show"),
-
                    tui::realm::ui::shortcut(&self.theme, "m", "comment"),
                    tui::realm::ui::shortcut(&self.theme, "e", "edit"),
-
                    tui::realm::ui::shortcut(&self.theme, "d", "delete"),
                    tui::realm::ui::shortcut(&self.theme, "q", "quit"),
                ],
            ),
modified bin/commands/issue/realm/suite.rs
@@ -136,7 +136,8 @@ impl App {
        let repo = self.context.repository();
        match id {
            Some(id) => {
-
                if let Some(issue) = cob::issue::find(repo, &id)? {
+
                let profile = self.context.profile();
+
                if let Some(issue) = cob::issue::find(profile, repo, &id)? {
                    let view = Box::new(IssuePage::new(&self.context, theme, Some((id, issue))));
                    self.pages.push(view, app, &self.context, theme)?;

@@ -285,6 +286,7 @@ impl App {
        labels: String,
        assignees: String,
    ) -> Result<IssueId> {
+
        let profile = self.context.profile();
        let repository = self.context.repository();
        let signer = self.context.signer().as_ref().unwrap();

@@ -292,6 +294,7 @@ impl App {
        let assignees = cob::parse_assignees(assignees)?;

        cob::issue::create(
+
            profile,
            repository,
            signer,
            title,
modified bin/commands/issue/realm/suite/page.rs
@@ -152,7 +152,8 @@ impl ViewPage<Cid, Message> for ListPage {
    ) -> Result<Option<Message>> {
        if let Message::Issue(IssueMessage::Reload(id)) = message {
            let selected = match id {
-
                Some(id) => cob::issue::find(context.repository(), &id)?.map(|issue| (id, issue)),
+
                Some(id) => cob::issue::find(context.profile(), context.repository(), &id)?
+
                    .map(|issue| (id, issue)),
                _ => None,
            };

@@ -402,9 +403,10 @@ impl ViewPage<Cid, Message> for IssuePage {
    ) -> Result<Option<Message>> {
        match message {
            Message::Issue(IssueMessage::Created(id)) => {
+
                let profile = context.profile();
                let repo = context.repository();

-
                if let Some(issue) = cob::issue::find(repo, &id)? {
+
                if let Some(issue) = cob::issue::find(profile, repo, &id)? {
                    self.issue = Some((id, issue.clone()));
                    let list = ui::list(context, theme, self.issue.clone()).to_boxed();
                    let comments = issue.comments().collect::<Vec<_>>();
@@ -422,8 +424,10 @@ impl ViewPage<Cid, Message> for IssuePage {
                }
            }
            Message::Issue(IssueMessage::Changed(id)) => {
+
                let profile = context.profile();
                let repo = context.repository();
-
                if let Some(issue) = cob::issue::find(repo, &id)? {
+

+
                if let Some(issue) = cob::issue::find(profile, repo, &id)? {
                    self.issue = Some((id, issue.clone()));
                    let comments = issue.comments().collect::<Vec<_>>();
                    let details = ui::details(
modified bin/commands/patch/realm/select/event.rs
@@ -140,29 +140,7 @@ impl tuirealm::Component<Message, NoUserEvent> for Widget<OperationSelect> {
                ..
            }) => submit().map(|id| {
                let selection = Selection {
-
                    operation: Some(PatchOperation::Delete.to_string()),
-
                    ids: vec![id],
-
                    args: vec![],
-
                };
-
                Message::Quit(Some(selection))
-
            }),
-
            Event::Keyboard(KeyEvent {
-
                code: Key::Char('e'),
-
                ..
-
            }) => submit().map(|id| {
-
                let selection = Selection {
-
                    operation: Some(PatchOperation::Edit.to_string()),
-
                    ids: vec![id],
-
                    args: vec![],
-
                };
-
                Message::Quit(Some(selection))
-
            }),
-
            Event::Keyboard(KeyEvent {
-
                code: Key::Char('m'),
-
                ..
-
            }) => submit().map(|id| {
-
                let selection = Selection {
-
                    operation: Some(PatchOperation::Comment.to_string()),
+
                    operation: Some(PatchOperation::Diff.to_string()),
                    ids: vec![id],
                    args: vec![],
                };
modified bin/commands/patch/realm/select/ui.rs
@@ -92,9 +92,7 @@ impl OperationSelect {
                vec![
                    tui::realm::ui::shortcut(&self.theme, "enter", "show"),
                    tui::realm::ui::shortcut(&self.theme, "c", "checkout"),
-
                    tui::realm::ui::shortcut(&self.theme, "m", "comment"),
-
                    tui::realm::ui::shortcut(&self.theme, "e", "edit"),
-
                    tui::realm::ui::shortcut(&self.theme, "d", "delete"),
+
                    tui::realm::ui::shortcut(&self.theme, "d", "diff"),
                    tui::realm::ui::shortcut(&self.theme, "q", "quit"),
                ],
            ),
modified bin/commands/patch/realm/suite.rs
@@ -120,9 +120,10 @@ impl App {
        id: PatchId,
        theme: &Theme,
    ) -> Result<()> {
+
        let profile = self.context.profile();
        let repo = self.context.repository();

-
        if let Some(patch) = cob::patch::find(repo, &id)? {
+
        if let Some(patch) = cob::patch::find(profile, repo, &id)? {
            let view = Box::new(PatchView::new(theme.clone(), (id, patch)));
            self.pages.push(view, app, &self.context, theme)?;