Browse Source

convert the identifier to upper camel case

master
yggverse 1 week ago
parent
commit
582e94a7ab
  1. 16
      src/app/browser/window/tab/item/identity/gemini.rs
  2. 8
      src/app/browser/window/tab/item/identity/gemini/widget/form.rs
  3. 16
      src/app/browser/window/tab/item/identity/gemini/widget/form/list/item.rs
  4. 8
      src/app/browser/window/tab/item/identity/gemini/widget/form/list/item/value.rs

16
src/app/browser/window/tab/item/identity/gemini.rs

@ -31,21 +31,21 @@ impl Gemini { @@ -31,21 +31,21 @@ impl Gemini {
// Add guest option
widget.form.list.append(
Value::USE_GUEST_SESSION,
Value::UseGuestSession,
"Guest session",
"No identity for this request",
);
// Add new identity option
widget.form.list.append(
Value::GENERATE_NEW_AUTH,
Value::GenerateNewAuth,
"Create new",
"Generate long-term certificate",
);
// Add import existing identity option
widget.form.list.append(
Value::IMPORT_PEM,
Value::ImportPem,
"Import identity",
"Use existing certificate",
);
@ -65,7 +65,7 @@ impl Gemini { @@ -65,7 +65,7 @@ impl Gemini {
// Append record option
widget.form.list.append(
Value::PROFILE_IDENTITY_GEMINI_ID(identity.id),
Value::ProfileIdentityGeminiId(identity.id),
&certificate.subject_name().unwrap().replace("CN=", ""), // trim prefix
&format!(
"valid until {} | auth: {}",
@ -116,16 +116,16 @@ impl Gemini { @@ -116,16 +116,16 @@ impl Gemini {
move |response| {
// Get option match user choice
let option = match response {
Value::PROFILE_IDENTITY_GEMINI_ID(value) => Some(value),
Value::USE_GUEST_SESSION => None,
Value::GENERATE_NEW_AUTH => Some(
Value::ProfileIdentityGeminiId(value) => Some(value),
Value::UseGuestSession => None,
Value::GenerateNewAuth => Some(
profile
.identity
.gemini
.make(None, &widget.form.name.value().unwrap())
.unwrap(),
),
Value::IMPORT_PEM => Some(
Value::ImportPem => Some(
profile
.identity
.gemini

8
src/app/browser/window/tab/item/identity/gemini/widget/form.rs

@ -43,13 +43,13 @@ impl Form { @@ -43,13 +43,13 @@ impl Form {
move |item| {
// Change name entry visibility
name.show(match item {
Value::GENERATE_NEW_AUTH => true,
Value::GenerateNewAuth => true,
_ => false,
});
// Change file choose button visibility
file.show(match item {
Value::IMPORT_PEM => true,
Value::ImportPem => true,
_ => false,
});
@ -73,8 +73,8 @@ impl Form { @@ -73,8 +73,8 @@ impl Form {
/// Validate `Self` components match current selection
pub fn is_valid(&self) -> bool {
match self.list.selected() {
Value::GENERATE_NEW_AUTH => self.name.is_valid(),
Value::IMPORT_PEM => self.file.is_valid(),
Value::GenerateNewAuth => self.name.is_valid(),
Value::ImportPem => self.file.is_valid(),
_ => true,
}
}

16
src/app/browser/window/tab/item/identity/gemini/widget/form/list/item.rs

@ -23,10 +23,10 @@ impl Item { @@ -23,10 +23,10 @@ impl Item {
.property(
"value",
match value {
Value::GENERATE_NEW_AUTH => G_VALUE_GENERATE_NEW_AUTH,
Value::IMPORT_PEM => G_VALUE_IMPORT_PEM,
Value::USE_GUEST_SESSION => G_VALUE_USE_GUEST_SESSION,
Value::PROFILE_IDENTITY_GEMINI_ID(value) => value,
Value::GenerateNewAuth => G_VALUE_GENERATE_NEW_AUTH,
Value::ImportPem => G_VALUE_IMPORT_PEM,
Value::UseGuestSession => G_VALUE_USE_GUEST_SESSION,
Value::ProfileIdentityGeminiId(value) => value,
},
)
.property("title", title)
@ -39,10 +39,10 @@ impl Item { @@ -39,10 +39,10 @@ impl Item {
/// Get `value` as enum `Value`
pub fn value_enum(&self) -> Value {
match self.value() {
G_VALUE_GENERATE_NEW_AUTH => Value::GENERATE_NEW_AUTH,
G_VALUE_IMPORT_PEM => Value::IMPORT_PEM,
G_VALUE_USE_GUEST_SESSION => Value::USE_GUEST_SESSION,
value => Value::PROFILE_IDENTITY_GEMINI_ID(value),
G_VALUE_GENERATE_NEW_AUTH => Value::GenerateNewAuth,
G_VALUE_IMPORT_PEM => Value::ImportPem,
G_VALUE_USE_GUEST_SESSION => Value::UseGuestSession,
value => Value::ProfileIdentityGeminiId(value),
}
}
}

8
src/app/browser/window/tab/item/identity/gemini/widget/form/list/item/value.rs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#[derive(Debug)]
pub enum Value {
GENERATE_NEW_AUTH,
IMPORT_PEM,
PROFILE_IDENTITY_GEMINI_ID(i64),
USE_GUEST_SESSION,
GenerateNewAuth,
ImportPem,
ProfileIdentityGeminiId(i64),
UseGuestSession,
}

Loading…
Cancel
Save