suggested extensions (#9526)
Follow-up from #9138 Release Notes: - Adds suggested extensions for some filetypes ([#7096](https://github.com/zed-industries/zed/issues/7096)). --------- Co-authored-by: Felix Zeller <felixazeller@gmail.com>
This commit is contained in:
parent
7573f35e8e
commit
d6b7f14b51
11 changed files with 318 additions and 37 deletions
|
@ -402,27 +402,13 @@ impl ExtensionStore {
|
|||
self.install_or_upgrade_extension(extension_id, version, ExtensionOperation::Install, cx)
|
||||
}
|
||||
|
||||
pub fn upgrade_extension(
|
||||
fn install_or_upgrade_extension_at_endpoint(
|
||||
&mut self,
|
||||
extension_id: Arc<str>,
|
||||
version: Arc<str>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
self.install_or_upgrade_extension(extension_id, version, ExtensionOperation::Upgrade, cx)
|
||||
}
|
||||
|
||||
fn install_or_upgrade_extension(
|
||||
&mut self,
|
||||
extension_id: Arc<str>,
|
||||
version: Arc<str>,
|
||||
url: String,
|
||||
operation: ExtensionOperation,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
log::info!("installing extension {extension_id} {version}");
|
||||
let url = self
|
||||
.http_client
|
||||
.build_zed_api_url(&format!("/extensions/{extension_id}/{version}/download"));
|
||||
|
||||
let extensions_dir = self.extensions_dir();
|
||||
let http_client = self.http_client.clone();
|
||||
|
||||
|
@ -461,6 +447,49 @@ impl ExtensionStore {
|
|||
.detach_and_log_err(cx);
|
||||
}
|
||||
|
||||
pub fn install_latest_extension(
|
||||
&mut self,
|
||||
extension_id: Arc<str>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
log::info!("installing extension {extension_id} latest version");
|
||||
|
||||
let url = self
|
||||
.http_client
|
||||
.build_zed_api_url(&format!("/extensions/{extension_id}/download"));
|
||||
|
||||
self.install_or_upgrade_extension_at_endpoint(
|
||||
extension_id,
|
||||
url,
|
||||
ExtensionOperation::Install,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn upgrade_extension(
|
||||
&mut self,
|
||||
extension_id: Arc<str>,
|
||||
version: Arc<str>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
self.install_or_upgrade_extension(extension_id, version, ExtensionOperation::Upgrade, cx)
|
||||
}
|
||||
|
||||
fn install_or_upgrade_extension(
|
||||
&mut self,
|
||||
extension_id: Arc<str>,
|
||||
version: Arc<str>,
|
||||
operation: ExtensionOperation,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) {
|
||||
log::info!("installing extension {extension_id} {version}");
|
||||
let url = self
|
||||
.http_client
|
||||
.build_zed_api_url(&format!("/extensions/{extension_id}/{version}/download"));
|
||||
|
||||
self.install_or_upgrade_extension_at_endpoint(extension_id, url, operation, cx);
|
||||
}
|
||||
|
||||
pub fn uninstall_extension(&mut self, extension_id: Arc<str>, cx: &mut ModelContext<Self>) {
|
||||
let extensions_dir = self.extensions_dir();
|
||||
let fs = self.fs.clone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue