mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-07-31 13:18:46 +00:00
feat: profile export static method to generate new uuid
This commit is contained in:
parent
93f5df9776
commit
14689e5358
1 changed files with 6 additions and 2 deletions
|
@ -248,7 +248,7 @@ impl Display for Profile {
|
||||||
|
|
||||||
impl Default for Profile {
|
impl Default for Profile {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let uuid = Uuid::new_v4().to_string();
|
let uuid = Self::new_uuid();
|
||||||
let profile_dir = get_data_dir().join(&uuid);
|
let profile_dir = get_data_dir().join(&uuid);
|
||||||
Self {
|
Self {
|
||||||
name: "Default profile name".into(),
|
name: "Default profile name".into(),
|
||||||
|
@ -362,10 +362,14 @@ impl Profile {
|
||||||
serde_json::to_writer_pretty(writer, self).expect("Could not write profile")
|
serde_json::to_writer_pretty(writer, self).expect("Could not write profile")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new_uuid() -> String {
|
||||||
|
Uuid::new_v4().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn create_duplicate(&self) -> Self {
|
pub fn create_duplicate(&self) -> Self {
|
||||||
if !self.can_be_built {
|
if !self.can_be_built {
|
||||||
let mut dup = self.clone();
|
let mut dup = self.clone();
|
||||||
dup.uuid = Uuid::new_v4().to_string();
|
dup.uuid = Self::new_uuid();
|
||||||
dup.name = format!("Duplicate of {}", dup.name);
|
dup.name = format!("Duplicate of {}", dup.name);
|
||||||
dup.editable = true;
|
dup.editable = true;
|
||||||
return dup;
|
return dup;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue