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

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 234e308  feat(homepage): move savequeries table and render open 
conditionally (#15711)
234e308 is described below

commit 234e3081a5a238096595f034f910e458322d1352
Author: Phillip Kelley-Dotson <[email protected]>
AuthorDate: Thu Jul 15 15:53:23 2021 -0700

    feat(homepage): move savequeries table and render open conditionally 
(#15711)
    
    * initial commit
    
    * make collapsable
---
 .../src/views/CRUD/welcome/Welcome.tsx             | 31 +++++++++++++++-------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/superset-frontend/src/views/CRUD/welcome/Welcome.tsx 
b/superset-frontend/src/views/CRUD/welcome/Welcome.tsx
index a0ce320..36a0e44 100644
--- a/superset-frontend/src/views/CRUD/welcome/Welcome.tsx
+++ b/superset-frontend/src/views/CRUD/welcome/Welcome.tsx
@@ -114,10 +114,18 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
     null,
   );
   const [loadedCount, setLoadedCount] = useState(0);
-
+  const [activeState, setActiveState] = useState<Array<string>>([
+    '1',
+    '2',
+    '3',
+  ]);
   const userid = user.userId;
   const id = userid.toString();
 
+  const handleCollapse = (state: Array<string>) => {
+    setActiveState(state);
+  };
+
   useEffect(() => {
     const userKey = getFromLocalStorage(id, null);
     const activeTab = getFromLocalStorage(HOMEPAGE_ACTIVITY_FILTER, null);
@@ -192,6 +200,9 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
   };
 
   useEffect(() => {
+    if (queryData?.length) {
+      setActiveState(['1', '2', '3', '4']);
+    }
     setActivityData(activityData => ({
       ...activityData,
       Created: [
@@ -213,7 +224,7 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
           </div>
         ) : null}
       </WelcomeNav>
-      <Collapse defaultActiveKey={['1', '2', '3', '4']} ghost bigger>
+      <Collapse activeKey={activeState} onChange={handleCollapse} ghost bigger>
         <Collapse.Panel header={t('Recents')} key="1">
           {activityData &&
           (activityData.Viewed ||
@@ -242,7 +253,14 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
             />
           )}
         </Collapse.Panel>
-        <Collapse.Panel header={t('Saved queries')} key="3">
+        <Collapse.Panel header={t('Charts')} key="3">
+          {!chartData ? (
+            <Loading position="inline" />
+          ) : (
+            <ChartTable showThumbnails={checked} user={user} mine={chartData} 
/>
+          )}
+        </Collapse.Panel>
+        <Collapse.Panel header={t('Saved queries')} key="4">
           {!queryData ? (
             <Loading position="inline" />
           ) : (
@@ -254,13 +272,6 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
             />
           )}
         </Collapse.Panel>
-        <Collapse.Panel header={t('Charts')} key="4">
-          {!chartData ? (
-            <Loading position="inline" />
-          ) : (
-            <ChartTable showThumbnails={checked} user={user} mine={chartData} 
/>
-          )}
-        </Collapse.Panel>
       </Collapse>
     </WelcomeContainer>
   );

Reply via email to