convert the identifier to upper camel case

This commit is contained in:
yggverse 2024-11-22 13:48:41 +02:00
parent 5e9590afdf
commit 582e94a7ab
4 changed files with 24 additions and 24 deletions

View File

@ -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 {
// 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 {
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

View File

@ -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 {
/// 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,
}
}

View File

@ -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 {
/// 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),
}
}
}

View File

@ -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,
}