Disable update check button when there is no API key #74
3 changed files with 37 additions and 10 deletions
21
Cargo.lock
generated
21
Cargo.lock
generated
|
@ -685,7 +685,8 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "druid"
|
name = "druid"
|
||||||
version = "0.8.3"
|
version = "0.8.3"
|
||||||
source = "git+https://github.com/linebender/druid.git#c02452ddeebc527992e8f112f434f23ce24c934d"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5ece41814b410c87e6379441caa7316539500b2e387b8d691f2ba5c0f4aff631"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"console_error_panic_hook",
|
"console_error_panic_hook",
|
||||||
"druid-derive",
|
"druid-derive",
|
||||||
|
@ -710,7 +711,8 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "druid-derive"
|
name = "druid-derive"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/linebender/druid.git#c02452ddeebc527992e8f112f434f23ce24c934d"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1234fc14b0c07e3d4ff2ae8862eb2c24c87e1f3d6eeef0ec6b9d564fe13cef2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -720,7 +722,8 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "druid-shell"
|
name = "druid-shell"
|
||||||
version = "0.8.3"
|
version = "0.8.3"
|
||||||
source = "git+https://github.com/linebender/druid.git#c02452ddeebc527992e8f112f434f23ce24c934d"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7682d9c8fbf934504c30970775bfcfba7858a600f2f6e56bed331989958350fc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
@ -749,6 +752,17 @@ dependencies = [
|
||||||
"wio",
|
"wio",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "druid-widget-nursery"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fe4e3cbc027e5c9a4f1c135b339ac92aaf99681a7c1b51ff63111b5719194e5"
|
||||||
|
dependencies = [
|
||||||
|
"druid",
|
||||||
|
"log",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dtmm"
|
name = "dtmm"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -759,6 +773,7 @@ dependencies = [
|
||||||
"colors-transform",
|
"colors-transform",
|
||||||
"confy",
|
"confy",
|
||||||
"druid",
|
"druid",
|
||||||
|
"druid-widget-nursery",
|
||||||
"dtmt-shared",
|
"dtmt-shared",
|
||||||
"futures",
|
"futures",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
|
|
@ -10,7 +10,7 @@ bitflags = "1.3.2"
|
||||||
clap = { version = "4.0.15", features = ["color", "derive", "std", "cargo", "string", "unicode"] }
|
clap = { version = "4.0.15", features = ["color", "derive", "std", "cargo", "string", "unicode"] }
|
||||||
color-eyre = "0.6.2"
|
color-eyre = "0.6.2"
|
||||||
confy = "0.5.1"
|
confy = "0.5.1"
|
||||||
druid = { git = "https://github.com/linebender/druid.git", features = ["im", "serde", "image", "png", "jpeg", "bmp", "webp", "svg"] }
|
druid = { version = "0.8", features = ["im", "serde", "image", "png", "jpeg", "bmp", "webp", "svg"] }
|
||||||
dtmt-shared = { path = "../../lib/dtmt-shared", version = "*" }
|
dtmt-shared = { path = "../../lib/dtmt-shared", version = "*" }
|
||||||
futures = "0.3.25"
|
futures = "0.3.25"
|
||||||
oodle-sys = { path = "../../lib/oodle-sys", version = "*" }
|
oodle-sys = { path = "../../lib/oodle-sys", version = "*" }
|
||||||
|
@ -30,3 +30,4 @@ strip-ansi-escapes = "0.1.1"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
colors-transform = "0.2.11"
|
colors-transform = "0.2.11"
|
||||||
usvg = "0.25.0"
|
usvg = "0.25.0"
|
||||||
|
druid-widget-nursery = "0.1"
|
||||||
|
|
|
@ -2,16 +2,17 @@ use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use druid::im::Vector;
|
use druid::im::Vector;
|
||||||
use druid::lens;
|
|
||||||
use druid::widget::{
|
use druid::widget::{
|
||||||
Checkbox, CrossAxisAlignment, Either, Flex, Image, Label, LineBreaking, List,
|
Checkbox, CrossAxisAlignment, Either, Flex, Image, Label, LineBreaking, List,
|
||||||
MainAxisAlignment, Maybe, Scroll, SizedBox, Split, Svg, SvgData, TextBox, ViewSwitcher,
|
MainAxisAlignment, Maybe, Scroll, SizedBox, Split, Svg, SvgData, TextBox, ViewSwitcher,
|
||||||
};
|
};
|
||||||
|
use druid::{lens, Env};
|
||||||
use druid::{
|
use druid::{
|
||||||
Color, FileDialogOptions, FileSpec, FontDescriptor, FontFamily, LensExt, SingleUse, Widget,
|
Color, FileDialogOptions, FileSpec, FontDescriptor, FontFamily, LensExt, SingleUse, Widget,
|
||||||
WidgetExt, WindowDesc, WindowId,
|
WidgetExt, WindowDesc, WindowId,
|
||||||
};
|
};
|
||||||
use druid::{Data, ImageBuf, LifeCycleCtx};
|
use druid::{Data, ImageBuf, LifeCycleCtx};
|
||||||
|
use druid_widget_nursery::WidgetExt as _;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
use crate::state::{
|
use crate::state::{
|
||||||
|
@ -50,11 +51,21 @@ fn build_top_bar() -> impl Widget<State> {
|
||||||
state.current_view = View::Settings;
|
state.current_view = View::Settings;
|
||||||
});
|
});
|
||||||
|
|
||||||
let check_update_button = Button::with_label("Check for updates")
|
let check_update_button = {
|
||||||
.on_click(|ctx, _: &mut State, _| {
|
let make_button = || {
|
||||||
|
Button::with_label("Check for updates").on_click(|ctx, _: &mut State, _| {
|
||||||
ctx.submit_command(ACTION_START_CHECK_UPDATE);
|
ctx.submit_command(ACTION_START_CHECK_UPDATE);
|
||||||
})
|
})
|
||||||
.disabled_if(|data, _| data.nexus_api_key.is_empty() || data.is_update_in_progress);
|
};
|
||||||
|
|
||||||
|
Either::new(
|
||||||
|
|data, _| data.nexus_api_key.is_empty(),
|
||||||
|
make_button()
|
||||||
|
.tooltip(|_: &State, _: &Env| "A Nexus API key is required")
|
||||||
|
.disabled_if(|_, _| true),
|
||||||
|
make_button().disabled_if(|data, _| data.is_update_in_progress),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
let deploy_button = {
|
let deploy_button = {
|
||||||
let icon = Svg::new(SvgData::from_str(theme::icons::ALERT_CIRCLE).expect("invalid SVG"))
|
let icon = Svg::new(SvgData::from_str(theme::icons::ALERT_CIRCLE).expect("invalid SVG"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue