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


##########
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:
   🟡 **Medium — an empty layer shows a false "could not be listed / charts will 
stop working" warning**
   
   This branch folds a *successful* `count === 0` into the same message as a 
failed lookup, so deleting a semantic layer that genuinely has **no** views 
tells the user it's about to destroy dependent views and break charts that 
don't exist — and implies a lookup failure that never happened.
   
   It's always the empty case here, never access-filtering: a layer is only 
clickable when `SemanticLayer.perm ∈ datasource_access` 
(`semantic_layers/api.py:1032-1034`), and the dependent-view count ORs on that 
same perm (`daos/datasource.py:168-170`), so any layer you can reach always has 
*all* of its views counted — `count === 0` means the layer is genuinely empty. 
Reserving the "could not be listed" copy for a real `failed` lookup keeps the 
warning honest (worth renaming the `an access-filtered empty response…` test to 
match).
   
   ```suggestion
     if (preview.status === 'failed') {
       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>
       );
     }
   
     if (preview.dependentViewCount === 0) {
       return <p>{t('This semantic layer has no dependent semantic 
views.')}</p>;
     }
   ```
   



-- 
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