aboutsummaryrefslogtreecommitdiff
path: root/src/app/api/integrations.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/api/integrations.rs')
-rw-r--r--src/app/api/integrations.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/app/api/integrations.rs b/src/app/api/integrations.rs
index 0cca8cba..ba1603e2 100644
--- a/src/app/api/integrations.rs
+++ b/src/app/api/integrations.rs
@@ -1,9 +1,34 @@
-use crate::api::schema::{IntegrationInstallResult, IntegrationUninstallResult, ResponseResult};
+use crate::api::schema::{
+ IntegrationInfo, IntegrationInstallResult, IntegrationState, IntegrationUninstallResult,
+ ResponseResult,
+};
use crate::app::App;
use super::responses::{encode_error, encode_success};
impl App {
+ pub(super) fn handle_integration_list(&self, id: String) -> String {
+ let integrations = crate::integration::integration_recommendations()
+ .into_iter()
+ .map(|recommendation| IntegrationInfo {
+ target: recommendation.target,
+ label: recommendation.label.to_owned(),
+ command: recommendation.command.to_owned(),
+ available: recommendation.available,
+ state: match recommendation.state {
+ crate::integration::IntegrationStatusKind::NotInstalled => {
+ IntegrationState::NotInstalled
+ }
+ crate::integration::IntegrationStatusKind::Current => IntegrationState::Current,
+ crate::integration::IntegrationStatusKind::Outdated => {
+ IntegrationState::Outdated
+ }
+ },
+ })
+ .collect();
+ encode_success(id, ResponseResult::IntegrationList { integrations })
+ }
+
pub(super) fn handle_integration_install(
&mut self,
id: String,
@@ -14,6 +39,7 @@ impl App {
Ok(messages) => messages,
Err(err) => return encode_error(id, "integration_install_failed", err.to_string()),
};
+ self.state.integration_recommendations = crate::integration::integration_recommendations();
encode_success(
id,
@@ -34,6 +60,7 @@ impl App {
Ok(messages) => messages,
Err(err) => return encode_error(id, "integration_uninstall_failed", err.to_string()),
};
+ self.state.integration_recommendations = crate::integration::integration_recommendations();
encode_success(
id,