Implement the password-store tree sidebar
This commit is contained in:
@@ -21,11 +21,43 @@ pub enum TreeNodeKind {
|
||||
Entry,
|
||||
}
|
||||
|
||||
/// Presentation-safe state calculated by storage services for a tree object.
|
||||
/// Frontends render these flags and never infer them from names or paths.
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
pub struct TreeNodeIndicators {
|
||||
locked: bool,
|
||||
changed: bool,
|
||||
conflict: bool,
|
||||
}
|
||||
|
||||
impl TreeNodeIndicators {
|
||||
pub const fn new(locked: bool, changed: bool, conflict: bool) -> Self {
|
||||
Self {
|
||||
locked,
|
||||
changed,
|
||||
conflict,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn is_locked(self) -> bool {
|
||||
self.locked
|
||||
}
|
||||
|
||||
pub const fn is_changed(self) -> bool {
|
||||
self.changed
|
||||
}
|
||||
|
||||
pub const fn has_conflict(self) -> bool {
|
||||
self.conflict
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct TreeNode {
|
||||
name: String,
|
||||
path: String,
|
||||
kind: TreeNodeKind,
|
||||
indicators: TreeNodeIndicators,
|
||||
children: Vec<TreeNode>,
|
||||
}
|
||||
|
||||
@@ -42,6 +74,10 @@ impl TreeNode {
|
||||
self.kind
|
||||
}
|
||||
|
||||
pub fn indicators(&self) -> TreeNodeIndicators {
|
||||
self.indicators
|
||||
}
|
||||
|
||||
pub fn children(&self) -> &[TreeNode] {
|
||||
&self.children
|
||||
}
|
||||
@@ -592,6 +628,7 @@ fn finalize_children(node: MutableNode, parent: &Path) -> Result<Vec<TreeNode>,
|
||||
name,
|
||||
path: path_text(&path)?,
|
||||
kind,
|
||||
indicators: TreeNodeIndicators::default(),
|
||||
children,
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user