mikebridge commented on code in PR #42845:
URL: https://github.com/apache/superset/pull/42845#discussion_r3833795887


##########
superset-frontend/src/pages/DatabaseList/index.tsx:
##########
@@ -101,6 +101,79 @@ interface DatabaseDeleteObject extends DatabaseObject {
   dashboards: any;
   sqllab_tab_count: number;
 }
+
+/** How many dependent semantic views the delete confirmation lists by name. */
+const MAX_DEPENDENT_VIEWS_LISTED = 10;
+
+type SemanticLayerDeletePreview =
+  | { status: 'loading'; item: ConnectionItem }
+  | {
+      status: 'loaded';
+      item: ConnectionItem;
+      dependentViewCount: number;
+      dependentViewNames: string[];
+    }
+  | { status: 'failed'; item: ConnectionItem };
+
+type ResolvedSemanticLayerDeletePreview = Exclude<
+  SemanticLayerDeletePreview,
+  { status: 'loading' }
+>;
+
+function SemanticLayerCascadeWarning({
+  preview,
+}: {
+  preview: ResolvedSemanticLayerDeletePreview;
+}) {
+  if (preview.status === 'failed' || preview.dependentViewCount === 0) {
+    return (
+      <p>
+        {t(
+          'Deleting this semantic layer also permanently deletes any semantic 
views it contains, and charts built on those views will stop working. The 
affected views could not be listed.',
+        )}
+      </p>
+    );
+  }

Review Comment:
   Fixed in `bcca1b4e53`, exactly as suggested — the folded condition is split: 
`status === 'failed'` keeps the cautious could-not-be-listed copy, and a 
successful `dependentViewCount === 0` now says "This semantic layer has no 
dependent semantic views." Your permission analysis (layer perm and view-count 
perm travel together, so zero is always genuinely empty) is preserved as a 
comment at the branch point, and the test is renamed to the semantics it proves 
— it now also asserts the scary copy is *absent* for the empty case, and fails 
against the pre-fix folded condition (control-run verified: 8/8 with the fix, 1 
failed without it).
   
   _(Fix prepared with AI assistance (Claude), on behalf of and reviewed by 
@mikebridge.)_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to