move shared Mode to separate file
This commit is contained in:
parent
608f07d445
commit
fc0b82418b
9 changed files with 41 additions and 23 deletions
|
|
@ -17,8 +17,8 @@ use serde::{Deserialize, Serialize};
|
||||||
use strum::Display;
|
use strum::Display;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::Mode,
|
|
||||||
components::popup::Type,
|
components::popup::Type,
|
||||||
|
state::Mode,
|
||||||
system::{
|
system::{
|
||||||
disk::{Disk, PartitionTableType},
|
disk::{Disk, PartitionTableType},
|
||||||
drivers::Driver,
|
drivers::Driver,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ use ratatui::{
|
||||||
layout::{Constraint, Direction, Layout},
|
layout::{Constraint, Direction, Layout},
|
||||||
prelude::Rect,
|
prelude::Rect,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tracing::{debug, info};
|
use tracing::{debug, info};
|
||||||
|
|
||||||
|
|
@ -36,6 +35,7 @@ use crate::{
|
||||||
footer::Footer, fps::FpsCounter, left::Left, popup, right::Right, title::Title, Component,
|
footer::Footer, fps::FpsCounter, left::Left, popup, right::Right, title::Title, Component,
|
||||||
},
|
},
|
||||||
config::Config,
|
config::Config,
|
||||||
|
state::Mode,
|
||||||
system::{
|
system::{
|
||||||
boot,
|
boot,
|
||||||
disk::{Disk, PartitionTableType},
|
disk::{Disk, PartitionTableType},
|
||||||
|
|
@ -71,22 +71,6 @@ pub struct App {
|
||||||
tasks: Tasks,
|
tasks: Tasks,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
||||||
pub enum Mode {
|
|
||||||
#[default]
|
|
||||||
ScanDisks,
|
|
||||||
InstallDrivers,
|
|
||||||
SelectDisks,
|
|
||||||
SelectTableType,
|
|
||||||
Confirm,
|
|
||||||
PreClone,
|
|
||||||
Clone,
|
|
||||||
SelectParts,
|
|
||||||
PostClone,
|
|
||||||
Done,
|
|
||||||
Failed,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new(tick_rate: f64, frame_rate: f64) -> Result<Self> {
|
pub fn new(tick_rate: f64, frame_rate: f64) -> Result<Self> {
|
||||||
let (action_tx, action_rx) = mpsc::unbounded_channel();
|
let (action_tx, action_rx) = mpsc::unbounded_channel();
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use ratatui::{
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
use super::Component;
|
use super::Component;
|
||||||
use crate::{action::Action, app::Mode, config::Config};
|
use crate::{action::Action, config::Config, state::Mode};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Footer {
|
pub struct Footer {
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ use tracing::info;
|
||||||
use super::{popup, state::StatefulList, Component};
|
use super::{popup, state::StatefulList, Component};
|
||||||
use crate::{
|
use crate::{
|
||||||
action::Action,
|
action::Action,
|
||||||
app::Mode,
|
|
||||||
config::Config,
|
config::Config,
|
||||||
|
state::Mode,
|
||||||
system::{
|
system::{
|
||||||
disk::{Disk, Partition, PartitionTableType},
|
disk::{Disk, Partition, PartitionTableType},
|
||||||
drivers::{self, Driver},
|
drivers::{self, Driver},
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ use strum::Display;
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
use super::Component;
|
use super::Component;
|
||||||
use crate::{action::Action, app::Mode, config::Config};
|
use crate::{action::Action, config::Config, state::Mode};
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, PartialEq, Eq, Display, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Eq, Display, Serialize, Deserialize)]
|
||||||
pub enum Type {
|
pub enum Type {
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ use tracing::info;
|
||||||
use super::{state::StatefulList, Component};
|
use super::{state::StatefulList, Component};
|
||||||
use crate::{
|
use crate::{
|
||||||
action::Action,
|
action::Action,
|
||||||
app::Mode,
|
|
||||||
config::Config,
|
config::Config,
|
||||||
|
state::Mode,
|
||||||
system::{
|
system::{
|
||||||
cpu::get_cpu_name,
|
cpu::get_cpu_name,
|
||||||
disk::{Disk, Partition, PartitionTableType},
|
disk::{Disk, Partition, PartitionTableType},
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ use ratatui::style::{Color, Modifier, Style};
|
||||||
use serde::{de::Deserializer, Deserialize};
|
use serde::{de::Deserializer, Deserialize};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use crate::{action::Action, app::Mode};
|
use crate::{action::Action, state::Mode};
|
||||||
|
|
||||||
const CONFIG: &str = include_str!("../config/config.json5");
|
const CONFIG: &str = include_str!("../config/config.json5");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ mod components;
|
||||||
mod config;
|
mod config;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod logging;
|
mod logging;
|
||||||
|
mod state;
|
||||||
mod system;
|
mod system;
|
||||||
mod tasks;
|
mod tasks;
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
|
||||||
33
deja_vu/src/state.rs
Normal file
33
deja_vu/src/state.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
// This file is part of Deja-vu.
|
||||||
|
//
|
||||||
|
// Deja-vu is free software: you can redistribute it and/or modify it
|
||||||
|
// under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Deja-vu is distributed in the hope that it will be useful, but
|
||||||
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
// See the GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Deja-vu. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum Mode {
|
||||||
|
#[default]
|
||||||
|
ScanDisks,
|
||||||
|
InstallDrivers,
|
||||||
|
SelectDisks,
|
||||||
|
SelectTableType,
|
||||||
|
Confirm,
|
||||||
|
PreClone,
|
||||||
|
Clone,
|
||||||
|
SelectParts,
|
||||||
|
PostClone,
|
||||||
|
Done,
|
||||||
|
Failed,
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue