()
| 113 | #[tracing::instrument(level = "debug", skip())] |
| 114 | #[component] |
| 115 | pub fn Accounts() -> impl IntoView { |
| 116 | let show_accounts_popover = RwSignal::new(false); |
| 117 | let provider_store = expect_context::<Arc<ProviderStore>>(); |
| 118 | |
| 119 | let statuses = provider_store.get_all_statuses(); |
| 120 | |
| 121 | let modal_store = expect_context::<RwSignal<ModalStore>>(); |
| 122 | let show_login_modal = move |key: String, name: String, account_id: String, logged_in: bool| { |
| 123 | if logged_in { |
| 124 | modal_store.update(|m| m.set_active_modal(Modals::SignoutModal(key, name, account_id))) |
| 125 | } else { |
| 126 | modal_store.update(|m| m.set_active_modal(Modals::LoginModal(key, name, account_id))) |
| 127 | } |
| 128 | }; |
| 129 | |
| 130 | let target = NodeRef::new(); |
| 131 | let _ = on_click_outside(target, move |_| { |
| 132 | if show_accounts_popover.get_untracked() { |
| 133 | show_accounts_popover.set(false); |
| 134 | } |
| 135 | }); |
| 136 | |
| 137 | let i18n = use_i18n(); |
| 138 | view! { |
| 139 | <div node_ref=target> |
| 140 | <PersonIcon on:click=move |_| show_accounts_popover.set(!show_accounts_popover.get()) /> |
| 141 | |
| 142 | {move || { |
| 143 | if show_accounts_popover.get() { |
| 144 | view! { |
| 145 | <div class="accounts-popover custom-popover"> |
| 146 | <div class="buttons"> |
| 147 | {move || { |
| 148 | let binding = statuses |
| 149 | .get() |
| 150 | .into_iter() |
| 151 | .filter(|s| { |
| 152 | s.scopes.contains(&ExtensionProviderScope::Accounts) |
| 153 | }); |
| 154 | binding |
| 155 | .map(|status| { |
| 156 | let key = status.key.clone(); |
| 157 | let (title_out, title_in) = if status.logged_in { |
| 158 | ( |
| 159 | status.user_name.clone().unwrap_or_default(), |
| 160 | t_string!(i18n, accounts.sign_out).into(), |
| 161 | ) |
| 162 | } else { |
| 163 | ( |
| 164 | t_string!(i18n, accounts.connect).into(), |
| 165 | status.name.clone(), |
| 166 | ) |
| 167 | }; |
| 168 | let title = RwSignal::new(title_out.clone()); |
| 169 | view! { |
| 170 | <div |
| 171 | class="button-bg d-flex ripple w-100" |
| 172 | on:mouseover=move |_| { |
nothing calls this directly
no test coverage detected