web fixes
This commit is contained in:
@@ -117,36 +117,42 @@ pub(crate) async fn load_page(
|
||||
// a table this page can act on. Reading the global scope out of the tree
|
||||
// instead is what used to answer "No table chosen" for a table the panel
|
||||
// had just listed.
|
||||
let selected_tables = if inputs.selection.is_global() {
|
||||
table_scope::global_tables(
|
||||
&definitions
|
||||
.get_table_catalog(
|
||||
authenticated_request(headers, GetTableCatalogRequest { profile_name: None })
|
||||
.map_err(|_| LoadError::Unauthenticated)?,
|
||||
)
|
||||
.await
|
||||
.map_err(|error| LoadError::Backend(error.message().to_string()))?
|
||||
.into_inner()
|
||||
.tables,
|
||||
let catalog_tables = definitions
|
||||
.get_table_catalog(
|
||||
authenticated_request(headers, GetTableCatalogRequest { profile_name: None })
|
||||
.map_err(|_| LoadError::Unauthenticated)?,
|
||||
)
|
||||
.await
|
||||
.map_err(|error| LoadError::Backend(error.message().to_string()))?
|
||||
.into_inner()
|
||||
.tables;
|
||||
let selected_tables = if inputs.selection.is_global() {
|
||||
table_scope::global_tables(&catalog_tables)
|
||||
} else {
|
||||
table_scope::profile_owned_tables(&tree.profiles, &inputs.selection.profile)
|
||||
};
|
||||
let tables = selected_tables
|
||||
.into_iter()
|
||||
.map(|table| TableSummary {
|
||||
name: table.name,
|
||||
table_kind: table.table_kind,
|
||||
global: table.global,
|
||||
// One entry per link, named by the column carrying it, so a table
|
||||
// pointing at one target twice reads as two links.
|
||||
depends_on: table
|
||||
.depends_on
|
||||
.into_iter()
|
||||
.map(|dependency| format!("{} ({})", dependency.table_name, dependency.column_name))
|
||||
.collect(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
// A shared table is a link target from every scope, which is why this is
|
||||
// not the list above: browsing a profile shows the profile's own tables,
|
||||
// and linking from one may reach the shared ones too.
|
||||
let link_targets = if inputs.selection.is_global() {
|
||||
table_scope::global_tables(&catalog_tables)
|
||||
} else {
|
||||
table_scope::linkable_tables(&tree.profiles, &catalog_tables, &inputs.selection.profile)
|
||||
};
|
||||
let summary = |table: crate::definitions::table_definition::profile_tree_response::Table| TableSummary {
|
||||
name: table.name,
|
||||
table_kind: table.table_kind,
|
||||
global: table.global,
|
||||
// One entry per link, named by the column carrying it, so a table
|
||||
// pointing at one target twice reads as two links.
|
||||
depends_on: table
|
||||
.depends_on
|
||||
.into_iter()
|
||||
.map(|dependency| format!("{} ({})", dependency.table_name, dependency.column_name))
|
||||
.collect(),
|
||||
};
|
||||
let tables = selected_tables.into_iter().map(summary).collect::<Vec<_>>();
|
||||
let link_targets = link_targets.into_iter().map(summary).collect::<Vec<_>>();
|
||||
|
||||
// A table the scope does not hold is dropped rather than acted on. It is
|
||||
// said out loud, though: dropping it in silence is what left the panel
|
||||
@@ -251,9 +257,19 @@ pub(crate) async fn load_page(
|
||||
false => Vec::new(),
|
||||
};
|
||||
|
||||
// The append panel is held to the rules of the table it is appending to: a
|
||||
// shared table keeps no quantity ledger, and no link may point at the table
|
||||
// itself.
|
||||
inputs.columns.global = inputs.selection.is_global()
|
||||
|| tables
|
||||
.iter()
|
||||
.any(|table| table.name == inputs.selection.table && table.global);
|
||||
inputs.columns.table_name = inputs.selection.table.clone();
|
||||
|
||||
Ok(TableDefinitionPageState {
|
||||
nav: crate::ui::Nav::new(headers, "admin").with_authorization(&authorization),
|
||||
tables,
|
||||
link_targets,
|
||||
detail,
|
||||
history,
|
||||
selection: inputs.selection,
|
||||
|
||||
Reference in New Issue
Block a user