Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extension gitlab icon support #13204

Closed
Closed
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 Cargo.lock

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

1 change: 1 addition & 0 deletions assets/icons/gitlab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions crates/extensions_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ theme_selector.workspace = true
ui.workspace = true
util.workspace = true
workspace.workspace = true
url.workspace = true

[dev-dependencies]
editor = { workspace = true, features = ["test-support"] }
21 changes: 19 additions & 2 deletions crates/extensions_ui/src/extensions_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::time::Duration;
use std::{ops::Range, sync::Arc};
use theme::ThemeSettings;
use ui::{prelude::*, ContextMenu, PopoverMenu, ToggleButton, Tooltip};
use url::{Url, Host};
use util::ResultExt as _;
use workspace::item::TabContentParams;
use workspace::{
Expand Down Expand Up @@ -327,6 +328,14 @@ impl ExtensionsPage {
let status = Self::extension_status(&extension.id, cx);

let repository_url = extension.repository.clone();
let parsed_url = Url::parse(repository_url.clone().unwrap().as_str());

let repository_icon =
if parsed_url.unwrap().host() == Some(Host::Domain("gitlab.com")) {
IconName::Gitlab
} else {
IconName::Github
};

ExtensionCard::new()
.child(
Expand Down Expand Up @@ -405,7 +414,7 @@ impl ExtensionsPage {
.children(repository_url.map(|repository_url| {
IconButton::new(
SharedString::from(format!("repository-{}", extension.id)),
IconName::Github,
repository_icon,
)
.icon_color(Color::Accent)
.icon_size(IconSize::Small)
Expand Down Expand Up @@ -435,6 +444,14 @@ impl ExtensionsPage {
self.buttons_for_entry(extension, &status, has_dev_extension, cx);
let version = extension.manifest.version.clone();
let repository_url = extension.manifest.repository.clone();
let parsed_url = Url::parse(repository_url.as_str());

let repository_icon =
if parsed_url.unwrap().host() == Some(Host::Domain("gitlab.com")) {
IconName::Gitlab
} else {
IconName::Github
};

let installed_version = match status {
ExtensionStatus::Installed(installed_version) => Some(installed_version),
Expand Down Expand Up @@ -512,7 +529,7 @@ impl ExtensionsPage {
.child(
IconButton::new(
SharedString::from(format!("repository-{}", extension.id)),
IconName::Github,
repository_icon,
)
.icon_color(Color::Accent)
.icon_size(IconSize::Small)
Expand Down
2 changes: 2 additions & 0 deletions crates/ui/src/components/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub enum IconName {
FolderOpen,
FolderX,
Github,
Gitlab,
Hash,
HistoryRerun,
Indicator,
Expand Down Expand Up @@ -270,6 +271,7 @@ impl IconName {
IconName::FolderOpen => "icons/file_icons/folder_open.svg",
IconName::FolderX => "icons/stop_sharing.svg",
IconName::Github => "icons/github.svg",
IconName::Gitlab => "icons/gitlab.svg",
IconName::Hash => "icons/hash.svg",
IconName::HistoryRerun => "icons/history_rerun.svg",
IconName::Indicator => "icons/indicator.svg",
Expand Down