global table profile name from server in web now

This commit is contained in:
Priec
2026-08-17 13:24:34 +02:00
parent efd9e2481b
commit f0d12584ef
15 changed files with 128 additions and 57 deletions

View File

@@ -30,7 +30,7 @@ use crate::{
};
use super::state::{
DetailColumn, GLOBAL_SCOPE, LoadError, PageInputs, RenameEntry, ScriptView,
DetailColumn, LoadError, PageInputs, RenameEntry, ScriptView,
TableDefinitionPageState, TableDetailView, TableSummary,
};
@@ -93,6 +93,9 @@ pub(crate) async fn load_page(
.map_err(|error| LoadError::Backend(error.message().to_string()))?
.into_inner();
// The profile the shared tables are stored in is the server's to name, so
// it is read off the tree rather than spelled here.
let shared_profile = tree.shared_profile_name.clone();
let profiles = tree
.profiles
.iter()
@@ -103,7 +106,7 @@ pub(crate) async fn load_page(
// says so — the commonest way to get here with a stale one is having just
// deleted its last table, which is worth being told.
if inputs.selection.has_profile()
&& inputs.selection.profile != GLOBAL_SCOPE
&& !inputs.selection.is_shared_profile(&shared_profile)
&& !profiles.contains(&inputs.selection.profile.as_str())
{
let missing = std::mem::take(&mut inputs.selection.profile);
@@ -122,7 +125,7 @@ pub(crate) async fn load_page(
let catalog_tables = definitions
.get_table_catalog(
authenticated_request(headers, GetTableCatalogRequest {
profile_name: crate::pages::GLOBAL_SCOPE.to_string(),
profile_name: shared_profile.clone(),
})
.map_err(|_| LoadError::Unauthenticated)?,
)
@@ -130,7 +133,7 @@ pub(crate) async fn load_page(
.map_err(|error| LoadError::Backend(error.message().to_string()))?
.into_inner()
.tables;
let selected_tables = if inputs.selection.is_global() {
let selected_tables = if inputs.selection.is_shared_profile(&shared_profile) {
table_scope::global_tables(&catalog_tables)
} else {
table_scope::profile_owned_tables(&tree.profiles, &inputs.selection.profile)
@@ -138,7 +141,7 @@ pub(crate) async fn load_page(
// 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() {
let link_targets = if inputs.selection.is_shared_profile(&shared_profile) {
table_scope::global_tables(&catalog_tables)
} else {
table_scope::linkable_tables(&tree.profiles, &catalog_tables, &inputs.selection.profile)
@@ -167,7 +170,9 @@ pub(crate) async fn load_page(
.any(|table| table.name == inputs.selection.table)
{
let missing = std::mem::take(&mut inputs.selection.table);
let scope = inputs.selection.scope_label(&crate::i18n::Locale::from_headers(headers));
let scope = inputs
.selection
.scope_label(&crate::i18n::Locale::from_headers(headers), &shared_profile);
inputs.error.get_or_insert(crate::tr!(
crate::i18n::Locale::from_headers(headers),
"td-err-not-a-table",
@@ -269,7 +274,7 @@ pub(crate) async fn load_page(
// 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()
inputs.columns.global = inputs.selection.is_shared_profile(&shared_profile)
|| tables
.iter()
.any(|table| table.name == inputs.selection.table && table.global);
@@ -277,6 +282,7 @@ pub(crate) async fn load_page(
Ok(TableDefinitionPageState {
nav: crate::ui::Nav::from_authorization(headers, "admin", &authorization),
shared_profile,
tables,
link_targets,
detail,