Skip to content

Commit

Permalink
Decorated product selection without radio btn
Browse files Browse the repository at this point in the history
* Resolves Issue agama-project#1415

* Entire card is clickable, selection of card
  is still marked by blue boarder

* Add icon to structures, pass it to dbus, etc
  (please do not mix product icon with pattern icon)
  fallback to default.svg in case that no icon is set

* Rework button layout to clickable layout

* We might need to use table or similar in case that
  description is longer than the

* Supply icon for all products including default icon
  • Loading branch information
lkocman committed Aug 21, 2024
1 parent 55fabd7 commit 1888f36
Show file tree
Hide file tree
Showing 16 changed files with 439 additions and 16 deletions.
1 change: 1 addition & 0 deletions products.d/leap_160.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ name: Leap 16.0 Alpha
description: 'Leap 16.0 is the latest version of a community distribution based
on the latest SUSE Linux Enterprise Server.'
# Do not manually change any translations! See README.md for more details.
icon: Leap16.svg
translations:
description:
ca: El Leap 16.0 és la darrera versió d'una distribució comunitària basada en
Expand Down
1 change: 1 addition & 0 deletions products.d/microos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ description: 'A quick, small distribution designed to host container workloads
with automated administration & patching. openSUSE MicroOS provides
transactional (atomic) updates upon a read-only btrfs root file system. As
rolling release distribution the software is always up-to-date.'
icon: MicroOS.svg
# Do not manually change any translations! See README.md for more details.
translations:
description:
Expand Down
1 change: 1 addition & 0 deletions products.d/sles_160.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ description: "SUSE Linux Enterprise Server is the open, reliable, compliant, and
continuity. It is the secure and adaptable OS for long-term supported,
innovation-ready infrastructure running business-critical workloads
on-premises, in the cloud, and at the edge."
icon: SUSE.svg
# Do not manually change any translations! See README.md for more details.
translations:
description:
Expand Down
1 change: 1 addition & 0 deletions products.d/tumbleweed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ description: 'The Tumbleweed distribution is a pure rolling release version of
openSUSE containing the latest "stable" versions of all software instead of
relying on rigid periodic release cycles. The project does this for users that
want the newest stable software.'
icon: Tumbleweed.svg
# Do not manually change any translations! See README.md for more details.
translations:
description:
Expand Down
1 change: 1 addition & 0 deletions rust/agama-lib/share/profile.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"id": {
"title": "Product identifier",
"description": "The id field from a products.d/foo.yaml file",
"icon": "Product Icon path specified in products.d/foo.yaml file",
"type": "string"
},
"registrationCode": {
Expand Down
7 changes: 7 additions & 0 deletions rust/agama-lib/src/product/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub struct Product {
pub name: String,
/// Product description
pub description: String,
/// Product icon (e.g., "default.svg")
pub icon: String,
}

#[derive(Clone, Debug, Serialize, Deserialize, utoipa::ToSchema)]
Expand Down Expand Up @@ -74,10 +76,15 @@ impl<'a> ProductClient<'a> {
Some(value) => value.try_into().unwrap(),
None => "",
};
let icon = match data.get("icon") {
Some(value) => value.try_into().unwrap(),
None => "default.svg",
};
Product {
id,
name,
description: description.to_string(),
icon: icon.to_string(),
}
})
.collect();
Expand Down
3 changes: 2 additions & 1 deletion service/lib/agama/dbus/software/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def issues

def available_products
backend.products.map do |product|
[product.id, product.display_name, { "description" => product.localized_description }]
[product.id, product.display_name, { "description" => product.localized_description,
"icon" => product.icon }]
end
end

Expand Down
8 changes: 8 additions & 0 deletions service/lib/agama/software/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class Product
# @return [String, nil] E.g., "1.0".
attr_accessor :version

# Product icon. Please use specify filename with svg suffix and ensure referenced
# file exists inside agama/web/src/assests/product.
# default.svg unless be used nless specified otherwise.
#
# @return [String, "default.svg"] E.g., "1.0".
attr_accessor :icon

# List of repositories.
#
# @return [Array<String>] Empty if the product requires registration.
Expand Down Expand Up @@ -99,6 +106,7 @@ class Product
# @param id [string] Product id.
def initialize(id)
@id = id
@icon = "default.svg"
@repositories = []
@labels = []
@mandatory_packages = []
Expand Down
3 changes: 3 additions & 0 deletions service/lib/agama/software/product_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def initialize_product(id, data, attrs)
product.description = attrs["description"]
product.name = data[:name]
product.version = data[:version]
product.icon = attrs["icon"] if attrs.key?("icon") && !attrs["icon"].nil?
@logger.info(product.name + " uses icon " + product.icon)
end
end

Expand Down Expand Up @@ -98,6 +100,7 @@ def product_data_from_config(id)
{
name: config.products.dig(id, "software", "base_product"),
version: config.products.dig(id, "software", "version"),
icon: config.products.dig(id, "software", "icon"),
labels: config.arch_elements_from(
id, "software", "installation_labels", property: :label
),
Expand Down
79 changes: 79 additions & 0 deletions web/src/assets/products/Leap16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions web/src/assets/products/MicroOS.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1888f36

Please sign in to comment.