You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by am...@apache.org on 2026/10/22 10:29:12 UTC

(superset) branch sandbox/qa-env-7f3a1c updated: fix(asset-approval): give a dataset author somewhere to submit from

This is an automated email from the ASF dual-hosted git repository.

amaannawab923 pushed a commit to branch sandbox/qa-env-7f3a1c
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/sandbox/qa-env-7f3a1c by this push:
     new 00fc050c812 fix(asset-approval): give a dataset author somewhere to submit from
00fc050c812 is described below

commit 00fc050c812cf8062eb3430022628c4bfe5c9cfe
Author: amaannawab923 <am...@gmail.com>
AuthorDate: Thu Oct 22 15:59:03 2026 +0530

    fix(asset-approval): give a dataset author somewhere to submit from
    
    A dashboard and a chart are submitted from the banner on the asset, which
    `AssetReview` mounts in Explore and the dashboard. A dataset has no page
    to mount it on, and the per-change-request screen that used to carry the
    author's submit button was removed with the move to contributed pages --
    so a dataset author could save a change and then had no way to send it,
    from anywhere. The write path was never broken: only the route to it.
    
    The Approvals list had two actions, Review (for an approver) and Open
    (for everyone else). It now has three: the author's own row, still a
    draft or sent back to them, offers Request review and opens the same
    dialog the banner does.
    
    That dialog reads `eligible_approvers`, which the list endpoint does not
    return and the record does, and an absent list looks exactly like an
    empty one -- so opening it on a list row told an author with a perfectly
    good reviewer that nobody could approve their change. It opens on the
    record instead, falling back to the row if that read fails.
---
 .../asset-approval/frontend/src/Approvals.tsx      | 96 ++++++++++++++++++----
 1 file changed, 82 insertions(+), 14 deletions(-)

diff --git a/local_extensions/asset-approval/frontend/src/Approvals.tsx b/local_extensions/asset-approval/frontend/src/Approvals.tsx
index a151761658e..058f044237f 100644
--- a/local_extensions/asset-approval/frontend/src/Approvals.tsx
+++ b/local_extensions/asset-approval/frontend/src/Approvals.tsx
@@ -38,10 +38,17 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
 import { pages, theme, translation } from '@apache-superset/core';
 import { Avatar, Input, Select, Table, Tag } from 'antd';
 import { Button } from './host';
-import { approveChange, fetchList, requestChanges } from './api';
+import {
+  approveChange,
+  fetchChangeRequest,
+  fetchList,
+  requestChanges,
+  submitForReview,
+} from './api';
 import ApprovePublishModal from './ApprovePublishModal';
 import DatasetReviewModal from './DatasetReviewModal';
 import RequestChangesModal from './RequestChangesModal';
+import RequestReviewModal from './RequestReviewModal';
 import { age, ago, assetUrl, isStale } from './display';
 import { displayName } from './types';
 import type { ApprovalsView, ChangeRequest } from './types';
@@ -158,6 +165,7 @@ export default function Approvals() {
   const [reviewing, setReviewing] = useState<ChangeRequest | null>(null);
   const [changesFor, setChangesFor] = useState<ChangeRequest | null>(null);
   const [approving, setApproving] = useState<ChangeRequest | null>(null);
+  const [submitting, setSubmitting] = useState<ChangeRequest | null>(null);
   const [busy, setBusy] = useState(false);
 
   const requested = subPath.split('/')[1] ?? '';
@@ -217,12 +225,44 @@ export default function Approvals() {
       setReviewing(null);
       setChangesFor(null);
       setApproving(null);
+      setSubmitting(null);
       await load();
     } finally {
       setBusy(false);
     }
   };
 
+  /**
+   * Whether this row is the reader's own, waiting on them to send it.
+   *
+   * A dashboard or a chart is submitted from its own banner, which is on
+   * the asset. A dataset has no page to put a banner on, so without this
+   * its author has nowhere to submit from at all -- the row's only other
+   * action, Open, leads to the dataset list.
+   *
+   * `changes_requested` counts too: a change sent back is the author's to
+   * send again, by the same route.
+   */
+  const canSubmit = (row: ChangeRequest) =>
+    row.is_author === true &&
+    (row.status === 'draft' || row.status === 'changes_requested');
+
+  /**
+   * Open the request dialog on the full record, not on the list row.
+   *
+   * `fetchList` leaves out `eligible_approvers` -- the dialog's whole
+   * "who can approve" section reads it, and an absent list is indistinguishable
+   * from an empty one, so handing it a row makes it tell an author with a
+   * perfectly good reviewer that nobody can approve their change.
+   */
+  const openSubmit = async (row: ChangeRequest) => {
+    try {
+      setSubmitting(await fetchChangeRequest(row.id));
+    } catch {
+      setSubmitting(row);
+    }
+  };
+
   const review = (row: ChangeRequest) => {
     if (row.asset_type === 'dataset') {
       setReviewing(row);
@@ -279,18 +319,33 @@ export default function Approvals() {
     {
       title: t('Actions'),
       key: 'actions',
-      render: (_: unknown, row: ChangeRequest) =>
-        row.can_approve ? (
-          <Button
-            buttonSize="small"
-            onClick={() => review(row)}
-            data-test="review-action"
-          >
-            {t('Review')}
-          </Button>
-        ) : (
-          // Nothing for this reader to decide, so the row offers the asset
-          // rather than a review they cannot give.
+      render: (_: unknown, row: ChangeRequest) => {
+        if (row.can_approve) {
+          return (
+            <Button
+              buttonSize="small"
+              onClick={() => review(row)}
+              data-test="review-action"
+            >
+              {t('Review')}
+            </Button>
+          );
+        }
+        if (canSubmit(row)) {
+          return (
+            <Button
+              buttonSize="small"
+              buttonStyle="primary"
+              onClick={() => openSubmit(row)}
+              data-test="submit-action"
+            >
+              {t('Request review')}
+            </Button>
+          );
+        }
+        // Nothing for this reader to decide or to send, so the row offers
+        // the asset rather than a review they cannot give.
+        return (
           <Button
             buttonSize="small"
             href={assetUrl(row)}
@@ -298,7 +353,8 @@ export default function Approvals() {
           >
             {t('Open')}
           </Button>
-        ),
+        );
+      },
     },
   ];
 
@@ -396,6 +452,18 @@ export default function Approvals() {
         />
       ) : null}
 
+      {submitting ? (
+        <RequestReviewModal
+          changeRequest={submitting}
+          open
+          onClose={() => setSubmitting(null)}
+          onSubmit={(note, approverId) =>
+            act(() => submitForReview(submitting.id, note, approverId))
+          }
+          onEditorsChanged={load}
+        />
+      ) : null}
+
       {approving ? (
         <ApprovePublishModal
           changeRequest={approving}