feat(connection): add editable connection notes
This commit is contained in:
35 files changed
+126
-2
No files matched your search
@@ -598,6 +598,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: "conn".to_string(),
|
||||
name: "Connection".to_string(),
|
||||
note: String::new(),
|
||||
db_type,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -1117,6 +1117,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: id.to_string(),
|
||||
name: "Postgres".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Postgres,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
@@ -1171,6 +1172,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: id.to_string(),
|
||||
name: "Nacos".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Nacos,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
@@ -1262,6 +1264,7 @@ mod tests {
|
||||
let mut config = ConnectionConfig {
|
||||
id: "id".to_string(),
|
||||
name: "name".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Postgres,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -3854,6 +3854,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: "conn".to_string(),
|
||||
name: "MySQL".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Mysql,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -737,6 +737,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: id.to_string(),
|
||||
name: format!("{id} connection"),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Postgres,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -4175,6 +4175,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: "redis".to_string(),
|
||||
name: "Redis".to_string(),
|
||||
note: String::new(),
|
||||
db_type: crate::models::connection::DatabaseType::Redis,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -72,6 +72,8 @@ pub fn database_info_from_protocol_value(value: &Value) -> Option<DatabaseConnec
|
||||
pub struct ConnectionConfig {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
||||
pub note: String,
|
||||
pub db_type: DatabaseType,
|
||||
#[serde(default)]
|
||||
pub driver_profile: Option<String>,
|
||||
@@ -537,6 +539,8 @@ pub enum DatabaseType {
|
||||
struct ConnectionConfigData {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
#[serde(default)]
|
||||
pub note: String,
|
||||
pub db_type: DatabaseType,
|
||||
#[serde(default)]
|
||||
pub driver_profile: Option<String>,
|
||||
@@ -632,6 +636,7 @@ impl From<ConnectionConfigData> for ConnectionConfig {
|
||||
Self {
|
||||
id: data.id,
|
||||
name: data.name,
|
||||
note: data.note,
|
||||
db_type: data.db_type,
|
||||
driver_profile: data.driver_profile,
|
||||
driver_label: data.driver_label,
|
||||
@@ -2176,6 +2181,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: "id".to_string(),
|
||||
name: "name".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Mysql,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
@@ -2244,6 +2250,20 @@ mod tests {
|
||||
assert!(!legacy.read_only);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn connection_note_is_optional_and_round_trips_when_present() {
|
||||
let config = mysql_config("root", "secret", Some("app"));
|
||||
let value = serde_json::to_value(&config).unwrap();
|
||||
assert!(value.get("note").is_none());
|
||||
assert!(serde_json::from_value::<ConnectionConfig>(value).unwrap().note.is_empty());
|
||||
|
||||
let mut config = config;
|
||||
config.note = "Production reporting".to_string();
|
||||
let value = serde_json::to_value(&config).unwrap();
|
||||
assert_eq!(value["note"], "Production reporting");
|
||||
assert_eq!(serde_json::from_value::<ConnectionConfig>(value).unwrap().note, config.note);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn database_identifier_whitespace_is_preserved_and_percent_encoded() {
|
||||
let mut config = mysql_config("root", "secret", Some(" analytics "));
|
||||
|
||||
@@ -104,6 +104,7 @@ mod tests {
|
||||
let mut cfg = ConnectionConfig {
|
||||
id: "c1".to_string(),
|
||||
name: "mq".to_string(),
|
||||
note: String::new(),
|
||||
db_type: crate::models::connection::DatabaseType::MessageQueue,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -857,6 +857,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: "readonly-mq".to_string(),
|
||||
name: "Read only MQ".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::MessageQueue,
|
||||
driver_profile: Some("pulsar".to_string()),
|
||||
driver_label: Some("Apache Pulsar".to_string()),
|
||||
|
||||
@@ -286,6 +286,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: "nacos-1".to_string(),
|
||||
name: "Nacos".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Nacos,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -218,6 +218,7 @@ mod tests {
|
||||
let mut cfg = crate::models::connection::ConnectionConfig {
|
||||
id: "nacos-1".to_string(),
|
||||
name: "Nacos".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Nacos,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
@@ -287,6 +288,7 @@ mod tests {
|
||||
let cfg = crate::models::connection::ConnectionConfig {
|
||||
id: "nacos-rollback".to_string(),
|
||||
name: "Nacos".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Nacos,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -640,6 +640,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: "conn".to_string(),
|
||||
name: "test".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Mysql,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -3579,6 +3579,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: "conn-1".to_string(),
|
||||
name: "Connection".to_string(),
|
||||
note: String::new(),
|
||||
db_type,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
@@ -4666,6 +4667,7 @@ mod tests {
|
||||
let config = ConnectionConfig {
|
||||
id: "jdbc-1".to_string(),
|
||||
name: "JDBC".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Jdbc,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -2887,6 +2887,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: "test".to_string(),
|
||||
name: "test".to_string(),
|
||||
note: String::new(),
|
||||
db_type,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -3720,6 +3720,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: id.to_string(),
|
||||
name: "Pulsar".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::MessageQueue,
|
||||
driver_profile: Some("pulsar".to_string()),
|
||||
driver_label: Some("Apache Pulsar".to_string()),
|
||||
@@ -3781,6 +3782,7 @@ mod tests {
|
||||
ConnectionConfig {
|
||||
id: id.to_string(),
|
||||
name: "Nacos".to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::Nacos,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
@@ -4921,6 +4921,7 @@ mod tests {
|
||||
crate::models::connection::ConnectionConfig {
|
||||
id: id.to_string(),
|
||||
name: id.to_string(),
|
||||
note: String::new(),
|
||||
db_type: DatabaseType::DuckDb,
|
||||
driver_profile: None,
|
||||
driver_label: None,
|
||||
|
||||
Reference in new issue
Block a user