riahk commented on a change in pull request #10668:
URL: 
https://github.com/apache/incubator-superset/pull/10668#discussion_r478609719



##########
File path: superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx
##########
@@ -16,31 +16,94 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import React from 'react';
-
+import { SupersetClient } from '@superset-ui/connection';
+import { t } from '@superset-ui/translation';
+import React, { useEffect, useState } from 'react';
+import { createErrorHandler } from 'src/views/CRUD/utils';
 import withToasts from 'src/messageToasts/enhancers/withToasts';
 import SubMenu, { SubMenuProps } from 'src/components/Menu/SubMenu';
 import { commonMenuData } from 'src/views/CRUD/data/common';
+import DatabaseModal, { DatabaseObject } from './DatabaseModal';
 
-interface DatasourceListProps {
+interface DatabaseListProps {
   addDangerToast: (msg: string) => void;
   addSuccessToast: (msg: string) => void;
 }
 
-function DatasourceList({
-  addDangerToast,
-  addSuccessToast,
-}: DatasourceListProps) {
+function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
+  const [databaseModalOpen, setDatabaseModalOpen] = useState<boolean>(false);
+  const [currentDatabase, setCurrentDatabase] = useState<DatabaseObject | 
null>(
+    null,
+  );
+  const [permissions, setPermissions] = useState<string[]>([]);
+
+  const fetchDatasetInfo = () => {
+    SupersetClient.get({
+      endpoint: `/api/v1/dataset/_info`,
+    }).then(
+      ({ json: infoJson = {} }) => {
+        setPermissions(infoJson.permissions);
+      },
+      createErrorHandler(errMsg =>
+        addDangerToast(t('An error occurred while fetching datasets', errMsg)),
+      ),
+    );
+  };
+
+  useEffect(() => {
+    fetchDatasetInfo();
+  }, []);
+
+  const hasPerm = (perm: string) => {
+    if (!permissions.length) {
+      return false;
+    }
+
+    return Boolean(permissions.find(p => p === perm));
+  };
+
+  const canCreate = hasPerm('can_add');
+
   const menuData: SubMenuProps = {
     activeChild: 'Databases',
     ...commonMenuData,
   };
 
+  const testDB = {

Review comment:
       Oh yes this is test code that I need to remove! Will update in a bit




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

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