Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions rust/agama-l10n/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mod tests {
use agama_utils::{
actor::Handler,
api::{self, event::Event, scope::Scope},
issue, test,
issue,
};
use test_context::{test_context, AsyncTestContext};
use tokio::sync::broadcast;
Expand All @@ -74,8 +74,7 @@ mod tests {
impl AsyncTestContext for Context {
async fn setup() -> Context {
let (events_tx, events_rx) = broadcast::channel::<Event>(16);
let dbus = test::dbus::connection().await.unwrap();
let issues = issue::start(events_tx.clone(), dbus).await.unwrap();
let issues = issue::Service::starter(events_tx.clone()).start();

let model = TestModel::with_sample_data();
let handler = Service::starter(events_tx, issues.clone())
Expand Down
37 changes: 13 additions & 24 deletions rust/agama-l10n/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use agama_utils::{
self,
event::{self, Event},
l10n::{Proposal, SystemConfig, SystemInfo},
Issue, IssueSeverity, IssueSource, Scope,
Issue, Scope,
},
issue,
};
Expand All @@ -53,8 +53,6 @@ pub enum Error {
#[error(transparent)]
Event(#[from] broadcast::error::SendError<Event>),
#[error(transparent)]
Issue(#[from] api::issue::Error),
#[error(transparent)]
IssueService(#[from] issue::service::Error),
#[error(transparent)]
Actor(#[from] actor::Error),
Expand Down Expand Up @@ -186,33 +184,24 @@ impl Service {
let config = &self.config;
let mut issues = vec![];
if !self.model.locales_db().exists(&config.locale) {
issues.push(Issue {
description: format!("Locale '{}' is unknown", &config.locale),
details: None,
source: IssueSource::Config,
severity: IssueSeverity::Error,
class: "unknown_locale".to_string(),
});
issues.push(Issue::new(
"unknown_locale",
&format!("Locale '{}' is unknown", config.locale),
));
}

if !self.model.keymaps_db().exists(&config.keymap) {
issues.push(Issue {
description: format!("Keymap '{}' is unknown", &config.keymap),
details: None,
source: IssueSource::Config,
severity: IssueSeverity::Error,
class: "unknown_keymap".to_string(),
});
issues.push(Issue::new(
"unknown_keymap",
&format!("Keymap '{}' is unknown", config.keymap),
));
}

if !self.model.timezones_db().exists(&config.timezone) {
issues.push(Issue {
description: format!("Timezone '{}' is unknown", &config.timezone),
details: None,
source: IssueSource::Config,
severity: IssueSeverity::Error,
class: "unknown_timezone".to_string(),
});
issues.push(Issue::new(
"unknown_timezone",
&format!("Timezone '{}' is unknown", config.timezone),
));
}

issues
Expand Down
14 changes: 6 additions & 8 deletions rust/agama-manager/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use agama_utils::{
self, event,
manager::{self, LicenseContent},
status::State,
Action, Config, Event, Issue, IssueMap, IssueSeverity, Proposal, Scope, Status, SystemInfo,
Action, Config, Event, Issue, IssueMap, Proposal, Scope, Status, SystemInfo,
},
issue, licenses,
products::{self, ProductSpec},
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Starter {
pub async fn start(self) -> Result<Handler<Service>, Error> {
let issues = match self.issues {
Some(issues) => issues,
None => issue::start(self.events.clone(), self.dbus.clone()).await?,
None => issue::Service::starter(self.events.clone()).start(),
};

let progress = match self.progress {
Expand Down Expand Up @@ -245,7 +245,9 @@ impl Service {
if let Some(product) = self.products.default_product() {
let config = Config::with_product(product.id.clone());
self.set_config(config).await?;
}
} else {
self.update_issues()?;
};

Ok(())
}
Expand Down Expand Up @@ -412,11 +414,7 @@ impl Service {
self.issues
.cast(issue::message::Clear::new(Scope::Manager))?;
} else {
let issue = Issue::new(
"no_product",
"No product has been selected.",
IssueSeverity::Error,
);
let issue = Issue::new("no_product", "No product has been selected.");
self.issues
.cast(issue::message::Set::new(Scope::Manager, vec![issue]))?;
}
Expand Down
172 changes: 0 additions & 172 deletions rust/agama-manager/src/start.rs

This file was deleted.

2 changes: 1 addition & 1 deletion rust/agama-manager/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::Service;

/// Starts a testing manager service.
pub async fn start_service(events: event::Sender, dbus: zbus::Connection) -> Handler<Service> {
let issues = issue::start(events.clone(), dbus.clone()).await.unwrap();
let issues = issue::Service::starter(events.clone()).start();
let questions = question::start(events.clone()).await.unwrap();
let progress = progress::Service::starter(events.clone()).start();

Expand Down
21 changes: 16 additions & 5 deletions rust/agama-server/src/server/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use agama_utils::{
manager::LicenseContent,
query,
question::{Question, QuestionSpec, UpdateQuestion},
Action, Config, IssueMap, Patch, Status, SystemInfo,
Action, Config, IssueWithScope, Patch, Status, SystemInfo,
},
question,
};
Expand Down Expand Up @@ -252,18 +252,29 @@ async fn get_proposal(State(state): State<ServerState>) -> ServerResult<Response
Ok(to_option_response(proposal))
}

/// Returns the issues for each scope.
/// Returns the list of issues.
#[utoipa::path(
get,
path = "/issues",
context_path = "/api/v2",
responses(
(status = 200, description = "Agama issues", body = IssueMap),
(status = 200, description = "Agama issues", body = Vec<IssueWithScope>),
(status = 400, description = "Not possible to retrieve the issues")
)
)]
async fn get_issues(State(state): State<ServerState>) -> ServerResult<Json<IssueMap>> {
let issues = state.manager.call(message::GetIssues).await?;
async fn get_issues(State(state): State<ServerState>) -> ServerResult<Json<Vec<IssueWithScope>>> {
let issue_groups = state.manager.call(message::GetIssues).await?;

let issues = issue_groups
.into_iter()
.flat_map(|(scope, issues)| -> Vec<IssueWithScope> {
issues
.into_iter()
.map(|issue| IssueWithScope { scope, issue })
.collect()
})
.collect();

Ok(Json(issues))
}

Expand Down
3 changes: 1 addition & 2 deletions rust/agama-server/src/web/docs/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ impl ApiDocBuilder for ConfigApiDocBuilder {
.schema_from::<agama_locale_data::TimezoneId>()
.schema_from::<agama_utils::api::Action>()
.schema_from::<agama_utils::api::Config>()
.schema_from::<agama_utils::api::IssueWithScope>()
.schema_from::<agama_utils::api::Issue>()
.schema_from::<agama_utils::api::IssueSeverity>()
.schema_from::<agama_utils::api::IssueSource>()
.schema_from::<agama_utils::api::Progress>()
.schema_from::<agama_utils::api::Proposal>()
.schema_from::<agama_utils::api::Scope>()
Expand Down
Loading
Loading