Antonio-RiveroMartnez commented on code in PR #24839:
URL: https://github.com/apache/superset/pull/24839#discussion_r1293555233


##########
superset-frontend/src/features/tags/TagModal.tsx:
##########
@@ -0,0 +1,323 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { ChangeEvent, useState, useEffect } from 'react';
+import rison from 'rison';
+import Modal from 'src/components/Modal';
+import AsyncSelect from 'src/components/Select/AsyncSelect';
+import { FormLabel } from 'src/components/Form';
+import { t, SupersetClient } from '@superset-ui/core';
+import { Input } from 'antd';
+import { Divider } from 'src/components';
+import Button from 'src/components/Button';
+import { Tag } from 'src/views/CRUD/types';
+import { fetchObjects } from 'src/features/tags/tags';
+
+interface TaggableResourceOption {
+  label: string;
+  value: number;
+  key: number;
+}
+
+enum TaggableResources {
+  Chart = 'chart',
+  Dashboard = 'dashboard',
+  SavedQuery = 'query',
+}
+
+interface TagModalProps {
+  onHide: () => void;
+  refreshData: () => void;
+  addSuccessToast: (msg: string) => void;
+  addDangerToast: (msg: string) => void;
+  show: boolean;
+  editTag: Tag | null;

Review Comment:
   Could we use `?`



##########
superset-frontend/src/features/tags/TagModal.tsx:
##########
@@ -0,0 +1,323 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { ChangeEvent, useState, useEffect } from 'react';
+import rison from 'rison';
+import Modal from 'src/components/Modal';
+import AsyncSelect from 'src/components/Select/AsyncSelect';
+import { FormLabel } from 'src/components/Form';
+import { t, SupersetClient } from '@superset-ui/core';
+import { Input } from 'antd';
+import { Divider } from 'src/components';
+import Button from 'src/components/Button';
+import { Tag } from 'src/views/CRUD/types';
+import { fetchObjects } from 'src/features/tags/tags';
+
+interface TaggableResourceOption {
+  label: string;
+  value: number;
+  key: number;
+}
+
+enum TaggableResources {
+  Chart = 'chart',
+  Dashboard = 'dashboard',
+  SavedQuery = 'query',
+}
+
+interface TagModalProps {
+  onHide: () => void;
+  refreshData: () => void;
+  addSuccessToast: (msg: string) => void;
+  addDangerToast: (msg: string) => void;
+  show: boolean;
+  editTag: Tag | null;
+}
+
+const TagModal: React.FC<TagModalProps> = ({
+  show,
+  onHide,
+  editTag,
+  refreshData,
+  addSuccessToast,
+  addDangerToast,
+}) => {
+  const [dashboardsToTag, setDashboardsToTag] = useState<
+    TaggableResourceOption[]
+  >([]);
+  const [chartsToTag, setChartsToTag] = useState<TaggableResourceOption[]>([]);
+  const [savedQueriesToTag, setSavedQueriesToTag] = useState<
+    TaggableResourceOption[]
+  >([]);
+
+  const [tagName, setTagName] = useState<string>('');
+  const [description, setDescription] = useState<string>('');
+
+  const isEditMode = !!editTag;
+  const modalTitle = isEditMode ? 'Edit Tag' : 'Create Tag';
+
+  useEffect(() => {
+    setDashboardsToTag([]);
+    setChartsToTag([]);
+    setSavedQueriesToTag([]);
+    const dashboards: TaggableResourceOption[] = [];
+    const charts: TaggableResourceOption[] = [];
+    const queries: TaggableResourceOption[] = [];
+    if (isEditMode) {
+      fetchObjects(
+        { tags: editTag.name, types: null },
+        (data: Tag[]) => {
+          data.forEach(function (object) {

Review Comment:
   DRY nit:
   ```
   const resourceArrays = {
     [TaggableResources.Dashboard]: dashboards,
     [TaggableResources.Chart]: charts,
     [TaggableResources.SavedQuery]: queries,
   };
   
   data.forEach((object) => {
     const resourceOption = {
       value: object.id,
       label: object.name,
       key: object.id,
     };
     
     if (resourceArrays[object.type]) {
       resourceArrays[object.type].push(resourceOption);
     }
   });
   ```



##########
superset-frontend/src/features/tags/TagModal.tsx:
##########
@@ -0,0 +1,323 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { ChangeEvent, useState, useEffect } from 'react';
+import rison from 'rison';
+import Modal from 'src/components/Modal';
+import AsyncSelect from 'src/components/Select/AsyncSelect';
+import { FormLabel } from 'src/components/Form';
+import { t, SupersetClient } from '@superset-ui/core';
+import { Input } from 'antd';
+import { Divider } from 'src/components';
+import Button from 'src/components/Button';
+import { Tag } from 'src/views/CRUD/types';
+import { fetchObjects } from 'src/features/tags/tags';
+
+interface TaggableResourceOption {
+  label: string;
+  value: number;
+  key: number;
+}
+
+enum TaggableResources {
+  Chart = 'chart',
+  Dashboard = 'dashboard',
+  SavedQuery = 'query',
+}
+
+interface TagModalProps {
+  onHide: () => void;
+  refreshData: () => void;
+  addSuccessToast: (msg: string) => void;
+  addDangerToast: (msg: string) => void;
+  show: boolean;
+  editTag: Tag | null;
+}
+
+const TagModal: React.FC<TagModalProps> = ({

Review Comment:
   Could we add some tests for this component?



##########
superset-frontend/src/views/CRUD/hooks.ts:
##########
@@ -746,6 +746,7 @@ export function useDatabaseValidation() {
   );
   const getValidation = useCallback(
     (database: Partial<DatabaseObject> | null, onCreate = false) => {
+      console.log(database?.parameters);

Review Comment:
   leftover



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