(#[prop()] metadata: UpdateMetadata)
| 24 | #[tracing::instrument(level = "debug", skip(metadata))] |
| 25 | #[component] |
| 26 | pub fn UpdateModal(#[prop()] metadata: UpdateMetadata) -> impl IntoView { |
| 27 | let modal_store: RwSignal<ModalStore> = expect_context(); |
| 28 | let close_modal = move |_| modal_store.update(|m| m.clear_active_modal()); |
| 29 | |
| 30 | let trigger_update = move |ev| { |
| 31 | spawn_local(async move { |
| 32 | close_modal(ev); |
| 33 | if let Err(e) = install_update().await { |
| 34 | tracing::error!("Failed to install update: {:?}", e); |
| 35 | } |
| 36 | }); |
| 37 | }; |
| 38 | |
| 39 | tracing::info!("Got update {:?}", metadata); |
| 40 | |
| 41 | view! { |
| 42 | <GenericModal size=move || "modal-lg".into()> |
| 43 | <div class="container-fluid p-0 mt-4"> |
| 44 | <div class="row no-gutters d-flex"> |
| 45 | <div class="col"> |
| 46 | <h4>An update is available. Do you want to update?</h4> |
| 47 | </div> |
| 48 | </div> |
| 49 | <div class="row row-cols-auto mt-3 mr-4"> |
| 50 | <button |
| 51 | on:click=close_modal |
| 52 | class="btn btn-secondary cancel-button ml-auto" |
| 53 | type="button" |
| 54 | > |
| 55 | Cancel |
| 56 | </button> |
| 57 | <button |
| 58 | on:click=trigger_update |
| 59 | class="btn btn-secondary confirm-button ml-3" |
| 60 | type="button" |
| 61 | > |
| 62 | Confirm |
| 63 | </button> |
| 64 | </div> |
| 65 | </div> |
| 66 | </GenericModal> |
| 67 | } |
| 68 | } |
no test coverage detected