| 1 | use crate::views::query_value; |
| 2 | use forge_web_base::i18n::Lang; |
| 3 | use topcoat::context::Cx; |
| 4 | use topcoat::router::error::{SeeOther, see_other}; |
| 5 | |
| 6 | pub mod admin_runners; |
| 7 | pub mod admin_users; |
| 8 | pub mod ci_estimate; |
| 9 | pub mod ci_fail; |
| 10 | pub mod ci_job; |
| 11 | pub mod ci_runs; |
| 12 | pub mod code_live; |
| 13 | pub mod discussion_settings; |
| 14 | pub mod edit_history; |
| 15 | pub mod finder; |
| 16 | pub mod issue_meta; |
| 17 | pub mod issue_parts; |
| 18 | pub mod issues_list; |
| 19 | pub mod issues_live; |
| 20 | pub mod notifications; |
| 21 | pub mod packages; |
| 22 | pub mod packages_oci; |
| 23 | pub mod pull_live; |
| 24 | pub mod pull_reviews; |
| 25 | pub mod ref_live; |
| 26 | pub mod refs; |
| 27 | pub mod releases; |
| 28 | pub mod releases_live; |
| 29 | pub mod repo; |
| 30 | pub mod repo_ctx; |
| 31 | pub mod repo_mirrors; |
| 32 | pub mod repo_rename; |
| 33 | pub mod repo_security; |
| 34 | pub mod repo_settings; |
| 35 | pub mod repo_settings_live; |
| 36 | pub mod repo_side; |
| 37 | pub mod repo_transfer; |
| 38 | pub mod star; |
| 39 | pub mod tree; |
| 40 | pub mod wiki; |
| 41 | pub mod wiki_live; |
| 42 | |
| 43 | pub fn notice_redirect(href: &str, word: &str) -> SeeOther { |
| 44 | see_other(format!("{href}?notice={word}")) |
| 45 | } |
| 46 | |
| 47 | pub fn notice_from_query<K: Copy>(cx: &Cx, table: &[(&str, K, bool)]) -> Option<(K, bool)> { |
| 48 | let word = query_value(cx, "notice")?; |
| 49 | table |
| 50 | .iter() |
| 51 | .find(|(name, _, _)| *name == word) |
| 52 | .map(|(_, key, is_error)| (*key, *is_error)) |
| 53 | } |
| 54 | |
| 55 | pub fn notice_text<K: Copy>( |
| 56 | cx: &Cx, |
| 57 | lang: Lang, |
| 58 | table: &[(&str, K, bool)], |
| 59 | text: fn(Lang, K) -> &'static str, |
| 60 | ) -> Option<(&'static str, bool)> { |
| 61 | notice_from_query(cx, table).map(|(key, is_error)| (text(lang, key), is_error)) |
| 62 | } |