Skip to content

Commit

Permalink
Add option to open apps automatically when they are installed (closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 committed Jan 20, 2024
1 parent 116c766 commit 710e337
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 10 deletions.
8 changes: 8 additions & 0 deletions extension/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,14 @@
"message": "Disable only if you cannot install this web app with the manifest enabled",
"description": "The tooltip for the use manifest checkbox on the web app installation page"
},
"installPageLaunchNowLabel": {
"message": "Launch web app when the installation finishes",
"description": "The label for the launch now checkbox on the web app installation page"
},
"installPageLaunchNowTooltip": {
"message": "Enable if you want this web app to be launched automatically after the installation",
"description": "The tooltip for the launch now checkbox on the web app installation page"
},
"installPageContentScriptError": {
"message": "Failed to access the content script.",
"description": "A message that says the extension was not able to access the content script"
Expand Down
4 changes: 4 additions & 0 deletions extension/src/sites/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
<input class="form-check-input" type="checkbox" value="" id="web-app-use-manifest" checked>
<label class="form-check-label" for="web-app-use-manifest" data-i18n="installPageUseManifestLabel" data-i18n-title="installPageUseManifestTooltip"></label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="web-app-launch-now">
<label class="form-check-label" for="web-app-launch-now" data-i18n="installPageLaunchNowLabel" data-i18n-title="installPageLaunchNowTooltip"></label>
</div>
</form>
</div>
<div class="card-footer position-sticky bottom-0 py-2">
Expand Down
6 changes: 5 additions & 1 deletion extension/src/sites/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ async function initializeForm () {
// Force disable manifest if the checkbox is not checked
if (!document.getElementById('web-app-use-manifest').checked) manifestExists = false

// Handle whether the web app should be launched after the installation
const launchNow = document.getElementById('web-app-launch-now').checked || false

// Get simple site data
const startUrl = document.getElementById('web-app-start-url').value || null
const iconUrl = document.getElementById('web-app-icon-url').value || null
Expand Down Expand Up @@ -389,7 +392,8 @@ async function initializeForm () {
name,
description,
categories,
keywords
keywords,
launch_now: launchNow
}
})

Expand Down
11 changes: 8 additions & 3 deletions native/src/connector/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ impl Process for GetSiteList {

impl Process for LaunchSite {
fn process(&self, _connection: &Connection) -> Result<ConnectorResponse> {
cfg_if! {
if #[cfg(platform_macos)] { let command = SiteLaunchCommand { id: self.id, url: self.url.to_owned(), protocol: None, arguments: vec![], direct_launch: false }; }
else { let command = SiteLaunchCommand { id: self.id, url: self.url.to_owned(), protocol: None, arguments: vec![] }; }
let command = SiteLaunchCommand {
id: self.id,
url: self.url.to_owned(),
protocol: None,
arguments: vec![],
#[cfg(platform_macos)]
direct_launch: false,
};
command.run()?;

Expand All @@ -132,6 +136,7 @@ impl Process for InstallSite {
keywords: self.keywords.to_owned(),
launch_on_login: Some(self.launch_on_login),
launch_on_browser: Some(self.launch_on_browser),
launch_now: self.launch_now,
system_integration: true,
client: self.client.to_owned().into(),
};
Expand Down
4 changes: 4 additions & 0 deletions native/src/connector/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ pub struct InstallSite {
#[serde(default)]
pub launch_on_browser: bool,

/// Whether the web app should be launch when the installation finishes.
#[serde(default)]
pub launch_now: bool,

/// Contains a HTTP client configuration.
#[serde(default)]
pub client: HTTPClientConfig,
Expand Down
16 changes: 10 additions & 6 deletions native/src/console/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,23 @@ pub struct SiteInstallCommand {
#[clap(long)]
pub keywords: Option<Vec<String>>,

/// Set the web app to launch on the system login.
/// Set the web app to launch on the system login
#[clap(long)]
pub launch_on_login: Option<bool>,

/// Set the web app to launch on the browser launch.
/// Set the web app to launch on the browser launch
#[clap(long)]
pub launch_on_browser: Option<bool>,

/// Launch this web app when the installation finishes
#[clap(long)]
pub launch_now: bool,

/// Disable system integration
#[clap(long = "no-system-integration", action = ArgAction::SetFalse)]
pub system_integration: bool,

/// Configuration of the HTTP client.
/// Configuration of the HTTP client
#[clap(flatten)]
pub client: HTTPClientConfig,
}
Expand Down Expand Up @@ -188,7 +192,7 @@ pub struct SiteUpdateCommand {
#[clap(long = "no-system-integration", action = ArgAction::SetFalse)]
pub system_integration: bool,

/// Configuration of the HTTP client.
/// Configuration of the HTTP client
#[clap(flatten)]
pub client: HTTPClientConfig,
}
Expand Down Expand Up @@ -283,11 +287,11 @@ pub struct HTTPClientConfig {
#[clap(long, value_hint = clap::ValueHint::FilePath)]
pub tls_root_certificates_pem: Option<Vec<PathBuf>>,

/// Dangerous: Allow client to client accept invalid certs
/// Dangerous: Allow client to accept invalid certs
#[clap(long)]
pub tls_danger_accept_invalid_certs: bool,

/// Dangerous: Allow client to client accept invalid hostnames
/// Dangerous: Allow client to accept invalid hostnames
#[clap(long)]
pub tls_danger_accept_invalid_hostnames: bool,
}
13 changes: 13 additions & 0 deletions native/src/console/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ impl SiteInstallCommand {
storage.write(&dirs)?;

info!("Web app installed: {}", ulid);

if self.launch_now {
let command = SiteLaunchCommand {
id: ulid,
url: vec![],
protocol: None,
arguments: vec![],
#[cfg(platform_macos)]
direct_launch: false,
};
command.run()?;
}

Ok(ulid)
}
}
Expand Down

0 comments on commit 710e337

Please sign in to comment.