pierrejeambrun commented on code in PR #26457:
URL: https://github.com/apache/airflow/pull/26457#discussion_r981456730


##########
airflow/www/static/js/dag/details/SetDagTaskNotes.jsx:
##########
@@ -0,0 +1,120 @@
+/*!
+ * 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, { useState } from 'react';
+import {
+  Accordion,
+  AccordionItem,
+  AccordionButton,
+  AccordionPanel,
+  AccordionIcon,
+  Box,
+  Button,
+  Text,
+} from '@chakra-ui/react';
+import TextareaAutosize from 'react-textarea-autosize';
+import { getMetaValue } from '../../utils';
+import { useSetDagRunNotes, useSetTaskInstanceNotes } from '../../api';
+
+const canEdit = getMetaValue('can_edit') === 'True';
+
+const SetDagTaskNotes = ({
+  dagId, runId, taskId, initialValue, updateApiDataFunction,
+}) => {
+  const [notes, setNotes] = useState(initialValue == null ? '' : initialValue);
+  const [noteBeforeEdit, setNoteBeforeEdit] = useState('');
+  const [editMode, changeEditMode] = useState(false);
+  const {
+    mutateAsync: apiCallToSetDagRunNote, dagRunIsLoading,
+  } = useSetDagRunNotes(dagId, runId, notes);
+  const {
+    mutateAsync: apiCallToSetTINote, tiIsLoading,
+  } = useSetTaskInstanceNotes(dagId, runId, taskId, notes);
+
+  const objectIdentifier = (taskId == null) ? 'DAG Run' : 'Task Instance';
+
+  const handleSubmit = async (e) => {
+    e.preventDefault();
+    if (taskId == null) {
+      await apiCallToSetDagRunNote();
+    } else {
+      await apiCallToSetTINote();
+    }
+    updateApiDataFunction(notes);
+    changeEditMode(false);
+  };
+
+  return (
+    <Accordion defaultIndex={[0]} allowMultiple>
+      <AccordionItem style={{ border: 0 }}>
+        <AccordionButton style={{ padding: 0, paddingBottom: '10px', fontSize: 
'inherit' }}>
+          <Box flex="1" textAlign="left">

Review Comment:
   I am not a big fan of adding a dependancy just for the auto resize  feature 
of the text area. Chakra also provide a textarea component 
https://chakra-ui.com/docs/components/textarea.
   
   It also seems possible to have the autoresize behavior on that one:
   https://github.com/chakra-ui/chakra-ui/issues/670#issuecomment-669916624
   
   Also, is it possible to convert this file to typescript ? (Or is there a 
specific reason for the `.jsx`?)



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

Reply via email to