Rename planner and document rewrite: rewrite_documents moves qualified names of the renamed flow in every flow (ports, inputs, outputs) and dashboard binding (one key table, WIDGET_BINDINGS, shared with the WidgetDef accessors, legacy pages included), published and draft, as plain JSON with both variants above either version; plan_rename reports documents, counts, fingerprint, warnings and refusals; superuser plan routes for flows and dashboards; key residue classifies state as the mapper does; duplicate retargets inputs and outputs too; queue reports its Redis version and other consumers
This commit is contained in:
@@ -16,8 +16,10 @@ from fluksio.api.deps import (
|
||||
DashboardStoreDep,
|
||||
FlowControllerDep,
|
||||
check_pin,
|
||||
get_current_active_superuser,
|
||||
get_current_user,
|
||||
)
|
||||
from fluksio.api.routes.alerts import read_config as read_alerts_config
|
||||
from fluksio.flow.dashboards import (
|
||||
DashboardCreate,
|
||||
DashboardDef,
|
||||
@@ -28,6 +30,7 @@ from fluksio.flow.dashboards import (
|
||||
results_dashboard,
|
||||
)
|
||||
from fluksio.flow.events import event_bus
|
||||
from fluksio.flow.rename import RenamePlan, RenamePlanRequest, plan_rename
|
||||
from fluksio.flow.store import FlowNotFound, IdTaken, StaleVersion
|
||||
from fluksio.models import Message
|
||||
|
||||
@@ -245,3 +248,34 @@ async def duplicate_dashboard(dashboard_id: str, store: DashboardStoreDep) -> An
|
||||
return await run_in_threadpool(store.duplicate, dashboard_id)
|
||||
except DashboardNotFound:
|
||||
raise _missing(dashboard_id)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/{dashboard_id}/rename/plan",
|
||||
response_model=RenamePlan,
|
||||
dependencies=[Depends(get_current_active_superuser)],
|
||||
)
|
||||
async def plan_dashboard_rename(
|
||||
dashboard_id: str,
|
||||
body: RenamePlanRequest,
|
||||
store: DashboardStoreDep,
|
||||
controller: FlowControllerDep,
|
||||
) -> Any:
|
||||
"""What renaming this dashboard's key would change, and what refuses it.
|
||||
|
||||
Changes nothing. Nothing binds to a dashboard's key, so the plan is the
|
||||
dashboard alone; a superuser's all the same, as a flow's is.
|
||||
"""
|
||||
try:
|
||||
return await run_in_threadpool(
|
||||
lambda: plan_rename(
|
||||
controller,
|
||||
store,
|
||||
"dashboard",
|
||||
dashboard_id,
|
||||
body.new_name,
|
||||
read_alerts_config(),
|
||||
)
|
||||
)
|
||||
except DashboardNotFound:
|
||||
raise _missing(dashboard_id)
|
||||
|
||||
Reference in New Issue
Block a user