You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Adaverse (via GitHub)" <gi...@apache.org> on 2023/04/28 20:41:15 UTC

[GitHub] [airflow] Adaverse opened a new pull request, #30950: #

Adaverse opened a new pull request, #30950:
URL: https://github.com/apache/airflow/pull/30950

   Reference issue: #22870 
   
   Hello,
   
   Added keyboard shortcut where if a user is on the below screen (viewing a task), using shortcut ```shift + c``` triggers the action of ```Clear Task``` button
   
   ![step-1](https://user-images.githubusercontent.com/35839624/235249239-0d3842af-6d2d-41e5-913f-2ce2052b7532.png)
   
   Once the modal appears, the focus would be on the ```Clear``` button as can be seen below. Hence pressing enter on the keyboard will clear the tasks with the default selected value.
   
   ![step-2](https://user-images.githubusercontent.com/35839624/235249520-26771c57-c9f8-4bf6-8556-8ac3d789058a.png)
   
   Let me know what you think. Post suggestions, 
   
   1. we can extend the same behavior at the dag level as well.
   2. Success or Failing a task or dag
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] bbovenzi commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1205959472


##########
airflow/www/static/js/dag/details/NotesAccordion.tsx:
##########
@@ -106,8 +160,16 @@ const NotesAccordion = ({
                     maxRows={10}
                     as={ResizeTextarea}
                     value={note}
-                    onChange={(e) => setNote(e.target.value)}
+                    onChange={(e) => {
+                      setNote(e.target.value);
+                    }}
                     data-testid="notes-input"
+                    onFocus={() => {
+                      localStorage.setItem(isInputIFocus, "true");

Review Comment:
   Ok, we can keep it for now then.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1205977552


##########
airflow/www/static/js/App.tsx:
##########
@@ -55,6 +56,8 @@ interface AppProps extends PropsWithChildren {
   cache: EmotionCache;
 }
 
+const isInputInFocus: IsInputInFocus = "isInputInFocus";

Review Comment:
   Done. Defined in `useKeysPress` and importing it everywhere.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1206468492


##########
airflow/www/static/js/dag/keyboardShortcutIdentifier.ts:
##########
@@ -0,0 +1,71 @@
+/*!
+ * 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 type { KeyboardShortcutIdentifier } from "src/types";
+
+const keyboardShortcutIdentifier: KeyboardShortcutIdentifier = {
+  dagRunClear: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["C", "c"],
+    detail: "Clears the selected DAG run with all its existing tasks",
+  },
+  dagMarkSuccess: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["S", "s"],
+    detail: "Marks the selected DAG run as success",
+  },
+  dagMarkFailed: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["F", "f"],
+    detail: "Marks the selected DAG run as failed",
+  },
+  taskRunClear: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["C", "c"],
+    detail: "Opens modal to Clear selected task instance",
+  },
+  taskMarkSuccess: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["S", "s"],
+    detail: "Opens Mark as Success modal for the selected failed task instance",
+  },
+  taskMarkFailed: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["F", "f"],
+    detail:
+      "Opens Mark as Failed modal for the selected successful task instance",
+  },
+  viewNotes: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["N", "n"],
+    detail: "View the note of the selected DAG run or Task instance",
+  },
+  addOrEditNotes: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["E", "e"],
+    detail: "Edit the note of the selected DAG run or Task instance",
+  },
+  toggleShortcutCheatSheet: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["/", "?"],
+    detail: "Toggle Shortcut cheat sheet",
+  },
+};
+
+export default keyboardShortcutIdentifier;

Review Comment:
   Added a button. Let me know your thoughts
   
   ![image](https://github.com/apache/airflow/assets/35839624/87540021-01d3-4424-acb6-9bdcefe0783b)
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1194361996


##########
airflow/www/static/js/dag/details/taskInstance/taskActions/ClearInstance.tsx:
##########
@@ -77,6 +78,10 @@ const ClearInstance = ({
   const [failed, setFailed] = useState(false);
   const onToggleFailed = () => setFailed(!failed);
 
+  const initialClearButtonFocusRef = useRef<HTMLButtonElement>(null);
+
+  useKeysPress("shiftKey", ['c', 'C'], onOpen);

Review Comment:
   > Looking good! Do we want to add a cheatsheet somewhere? Also, for adding a note, we should make sure to toggle the accordion open if it is closed.
   
   Hi @bbovenzi 
   - Added a cheat sheet for shortcuts
   - Yes, toggling the accordion and making the text area in focus



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1183061403


##########
airflow/www/static/js/dag/details/taskInstance/taskActions/ClearInstance.tsx:
##########
@@ -77,6 +78,10 @@ const ClearInstance = ({
   const [failed, setFailed] = useState(false);
   const onToggleFailed = () => setFailed(!failed);
 
+  const initialClearButtonFocusRef = useRef<HTMLButtonElement>(null);
+
+  useKeysPress("shiftKey", ['c', 'C'], onOpen);

Review Comment:
   Hi @bbovenzi,
   
   Added below shortcuts to the DAGS grid screen - 
   - At DagRun
     - Clear existing tasks (`shift + c`)
     - Mark as success or fail (`shift + s` or `shift + f`)
     - Add note (`shift + n`)
   - At TaskInstance
     - Clear task (`shift + c`)
     - Mark as success or fail `(shift + s` or `shift + f`)
     - Add note (`shift + n`)
   
   The shortcuts are the same, just depends on what is selected. Will add more in the process.
   
   Yes, I have checked with major browsers (Chrome, Firefox, Edge, Opera), and these shortcuts aren't used as of yet (At least nothing happened when I clicked :)).



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] eladkal commented on pull request #30950: Adding keyboard shortcuts to common actions

Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on PR #30950:
URL: https://github.com/apache/airflow/pull/30950#issuecomment-1528105833

   This is cool!
   One thing comes to mind is how users will be aware of the keyboard shortcuts?
   I think we may need hints or/and each page/tab contains a menu explaining page shorcuts avaliable?


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1205951229


##########
airflow/www/static/js/App.tsx:
##########
@@ -55,6 +56,8 @@ interface AppProps extends PropsWithChildren {
   cache: EmotionCache;
 }
 
+const isInputInFocus: IsInputInFocus = "isInputInFocus";

Review Comment:
   Here the idea behind having a type for a string was to enforce this to have only specific values (since it is the key of the local storage object). In the above case, it was below.
   ```
   // In type/index.ts
   type IsInputInFocus = "isInputInFocus";
   ```
   We can replace it with a global constant that will be imported wherever used. Where can I define a constant to import it anywhere required? I do not seem to find where we define all constants used in UI. 
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1206776900


##########
airflow/www/static/js/dag/keyboardShortcutIdentifier.ts:
##########
@@ -0,0 +1,71 @@
+/*!
+ * 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 type { KeyboardShortcutIdentifier } from "src/types";
+
+const keyboardShortcutIdentifier: KeyboardShortcutIdentifier = {
+  dagRunClear: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["C", "c"],
+    detail: "Clears the selected DAG run with all its existing tasks",
+  },
+  dagMarkSuccess: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["S", "s"],
+    detail: "Marks the selected DAG run as success",
+  },
+  dagMarkFailed: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["F", "f"],
+    detail: "Marks the selected DAG run as failed",
+  },
+  taskRunClear: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["C", "c"],
+    detail: "Opens modal to Clear selected task instance",
+  },
+  taskMarkSuccess: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["S", "s"],
+    detail: "Opens Mark as Success modal for the selected failed task instance",
+  },
+  taskMarkFailed: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["F", "f"],
+    detail:
+      "Opens Mark as Failed modal for the selected successful task instance",
+  },
+  viewNotes: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["N", "n"],
+    detail: "View the note of the selected DAG run or Task instance",
+  },
+  addOrEditNotes: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["E", "e"],
+    detail: "Edit the note of the selected DAG run or Task instance",
+  },
+  toggleShortcutCheatSheet: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["/", "?"],
+    detail: "Toggle Shortcut cheat sheet",
+  },
+};
+
+export default keyboardShortcutIdentifier;

Review Comment:
   MB. Didn't notice :). Reverted that part.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on PR #30950:
URL: https://github.com/apache/airflow/pull/30950#issuecomment-1548581841

   > This is cool! One thing comes to mind is how users will be aware of the keyboard shortcuts? I think we may need hints or/and each page/tab contains a menu explaining page shorcuts avaliable?
   
   Hi @eladkal,
   Added a modal listing all the shortcuts accessible using the shortcut (`shitf+/`). I need some suggestions on where to put this text (or hint) to let the user know, like "Press `Shift + /` to view all shortcuts" at the same time making sure that it does not look out of place. The other place is in the Airflow documentation on DAG and Task run.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] bbovenzi commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1182870521


##########
airflow/www/static/js/dag/details/taskInstance/taskActions/ClearInstance.tsx:
##########
@@ -77,6 +78,10 @@ const ClearInstance = ({
   const [failed, setFailed] = useState(false);
   const onToggleFailed = () => setFailed(!failed);
 
+  const initialClearButtonFocusRef = useRef<HTMLButtonElement>(null);
+
+  useKeysPress("shiftKey", ['c', 'C'], onOpen);

Review Comment:
   Cool! Do you have a list of what shortcuts you want to do? We'll need to check this across browsers or toggle on/off if it conflicts with a user's shortcuts for something else.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1205934472


##########
airflow/www/static/js/dag/details/NotesAccordion.tsx:
##########
@@ -80,12 +89,56 @@ const NotesAccordion = ({
     setEditMode(false);
   };
 
+  const toggleNotesAccordionIthIndex = (ithIndex: number) => {
+    if (accordionIndexes.includes(ithIndex)) {
+      setAccordionIndexes((prevIndexes) =>
+        prevIndexes.splice(prevIndexes.indexOf(ithIndex, 1))
+      );
+    } else {
+      setAccordionIndexes((prevIndexes) => [...prevIndexes, ithIndex]);
+    }
+  };
+
+  useKeysPress(
+    keyboardShortcutIdentifier.addOrEditNotes.primaryKey,
+    keyboardShortcutIdentifier.addOrEditNotes.secondaryKey,
+    () => {
+      if (canEdit) {
+        // Notes index is 0
+        if (!accordionIndexes.includes(0)) {
+          toggleNotesAccordionIthIndex(0);
+        }
+        setEditMode(true);
+        setTimeout(() => textAreaRef.current?.focus(), 100);
+      }
+    }
+  );
+
+  useKeysPress(
+    keyboardShortcutIdentifier.viewNotes.primaryKey,
+    keyboardShortcutIdentifier.viewNotes.secondaryKey,
+    () => {
+      // toggling notes accordion (index = 0)
+      toggleNotesAccordionIthIndex(0);

Review Comment:
   True! But implemented `toggleNotesAccordionIthIndex`, thinking new panels might be included in the accordion in the future. Since you think that it might be overkill, hence replaced it with the simplest implementation of `toggleNotesPanel`



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] bbovenzi commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1190171541


##########
airflow/www/static/js/dag/details/taskInstance/taskActions/ClearInstance.tsx:
##########
@@ -77,6 +78,10 @@ const ClearInstance = ({
   const [failed, setFailed] = useState(false);
   const onToggleFailed = () => setFailed(!failed);
 
+  const initialClearButtonFocusRef = useRef<HTMLButtonElement>(null);
+
+  useKeysPress("shiftKey", ['c', 'C'], onOpen);

Review Comment:
   Looking good! Do we want to add a cheatsheet somewhere?
   Also, for adding a note, we should make sure to toggle the accordion open if it is closed.



##########
airflow/www/static/js/dag/details/taskInstance/taskActions/ClearInstance.tsx:
##########
@@ -77,6 +78,10 @@ const ClearInstance = ({
   const [failed, setFailed] = useState(false);
   const onToggleFailed = () => setFailed(!failed);
 
+  const initialClearButtonFocusRef = useRef<HTMLButtonElement>(null);
+
+  useKeysPress("shiftKey", ['c', 'C'], onOpen);

Review Comment:
   Looking good!
   Do we want to add a cheatsheet somewhere?
   Also, for adding a note, we should make sure to toggle the accordion open if it is closed.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] bbovenzi commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1205930257


##########
airflow/www/static/js/dag/details/NotesAccordion.tsx:
##########
@@ -106,8 +160,16 @@ const NotesAccordion = ({
                     maxRows={10}
                     as={ResizeTextarea}
                     value={note}
-                    onChange={(e) => setNote(e.target.value)}
+                    onChange={(e) => {
+                      setNote(e.target.value);
+                    }}
                     data-testid="notes-input"
+                    onFocus={() => {
+                      localStorage.setItem(isInputIFocus, "true");

Review Comment:
   What if we just got rid of it as an accordion? The text has a limit so it will never be too long.
   I can help with that part if you'd like



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on PR #30950:
URL: https://github.com/apache/airflow/pull/30950#issuecomment-1553315956

   Hi @bbovenzi ,
   
   - Fixed the accordion toggle logic making it generic
   - Using the local storage key "isInputInFocus" to discard the events that would get fired when the user is typing. Tried methods like `e.stopPropagation()`, `e.native.stopImmediatePropagation()`. Also tried this patch from react - https://legacy.reactjs.org/blog/2020/08/10/react-v17-rc.html#changes-to-event-delegation but still no luck. Finally used the above-mentioned tactical solution when on focus, setting it to true, and on blur setting it to false. 
   
   Do let me know if I missed anything.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on PR #30950:
URL: https://github.com/apache/airflow/pull/30950#issuecomment-1528121169

   > This is cool! One thing comes to mind is how users will be aware of the keyboard shortcuts? I think we may need hints or/and each page/tab contains a menu explaining page shorcuts avaliable?
   
   Yes! Like YouTube, we can have a modal (at each tab level) that popups upon clicking a button that will show all the shortcuts relevant to that tab. On YouTube, we can see that by hitting ```shift+/```. Let me compile all the shortcuts and list them down. If you guys have anything, do add it. 


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on PR #30950:
URL: https://github.com/apache/airflow/pull/30950#issuecomment-1567334144

   @bbovenzi can this be merged now?
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] bbovenzi commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1204666323


##########
airflow/www/static/js/dag/details/NotesAccordion.tsx:
##########
@@ -106,8 +160,16 @@ const NotesAccordion = ({
                     maxRows={10}
                     as={ResizeTextarea}
                     value={note}
-                    onChange={(e) => setNote(e.target.value)}
+                    onChange={(e) => {
+                      setNote(e.target.value);
+                    }}
                     data-testid="notes-input"
+                    onFocus={() => {
+                      localStorage.setItem(isInputIFocus, "true");

Review Comment:
   We shouldn't use localstorage for this. What are you trying to do here?



##########
airflow/www/static/js/App.tsx:
##########
@@ -55,6 +56,8 @@ interface AppProps extends PropsWithChildren {
   cache: EmotionCache;
 }
 
+const isInputInFocus: IsInputInFocus = "isInputInFocus";

Review Comment:
   it's just a string we don't need a special type for it.
   
   ```suggestion
   const isInputInFocus = "isInputInFocus";
   ```



##########
airflow/www/static/js/dag/details/NotesAccordion.tsx:
##########
@@ -80,12 +89,56 @@ const NotesAccordion = ({
     setEditMode(false);
   };
 
+  const toggleNotesAccordionIthIndex = (ithIndex: number) => {
+    if (accordionIndexes.includes(ithIndex)) {
+      setAccordionIndexes((prevIndexes) =>
+        prevIndexes.splice(prevIndexes.indexOf(ithIndex, 1))
+      );
+    } else {
+      setAccordionIndexes((prevIndexes) => [...prevIndexes, ithIndex]);
+    }
+  };
+
+  useKeysPress(
+    keyboardShortcutIdentifier.addOrEditNotes.primaryKey,
+    keyboardShortcutIdentifier.addOrEditNotes.secondaryKey,
+    () => {
+      if (canEdit) {
+        // Notes index is 0
+        if (!accordionIndexes.includes(0)) {
+          toggleNotesAccordionIthIndex(0);
+        }
+        setEditMode(true);
+        setTimeout(() => textAreaRef.current?.focus(), 100);
+      }
+    }
+  );
+
+  useKeysPress(
+    keyboardShortcutIdentifier.viewNotes.primaryKey,
+    keyboardShortcutIdentifier.viewNotes.secondaryKey,
+    () => {
+      // toggling notes accordion (index = 0)
+      toggleNotesAccordionIthIndex(0);

Review Comment:
   I don't think we need all this extra `toggleNotesAccordionIthIndex` just toggle the `editMode`



##########
airflow/www/static/js/dag/keyboardShortcutIdentifier.ts:
##########
@@ -0,0 +1,71 @@
+/*!
+ * 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 type { KeyboardShortcutIdentifier } from "src/types";
+
+const keyboardShortcutIdentifier: KeyboardShortcutIdentifier = {
+  dagRunClear: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["C", "c"],
+    detail: "Clears the selected DAG run with all its existing tasks",
+  },
+  dagMarkSuccess: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["S", "s"],
+    detail: "Marks the selected DAG run as success",
+  },
+  dagMarkFailed: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["F", "f"],
+    detail: "Marks the selected DAG run as failed",
+  },
+  taskRunClear: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["C", "c"],
+    detail: "Opens modal to Clear selected task instance",
+  },
+  taskMarkSuccess: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["S", "s"],
+    detail: "Opens Mark as Success modal for the selected failed task instance",
+  },
+  taskMarkFailed: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["F", "f"],
+    detail:
+      "Opens Mark as Failed modal for the selected successful task instance",
+  },
+  viewNotes: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["N", "n"],
+    detail: "View the note of the selected DAG run or Task instance",
+  },
+  addOrEditNotes: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["E", "e"],
+    detail: "Edit the note of the selected DAG run or Task instance",
+  },
+  toggleShortcutCheatSheet: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["/", "?"],
+    detail: "Toggle Shortcut cheat sheet",
+  },
+};
+
+export default keyboardShortcutIdentifier;

Review Comment:
   Should we put a small prompt somewhere so users even know this exists?



##########
airflow/www/static/js/dag/Main.tsx:
##########
@@ -145,6 +153,12 @@ const Main = () => {
     }
   };
 
+  useKeysPress(
+    keyboardShortcutIdentifier.toggleShortcutCheatSheet.primaryKey,

Review Comment:
   Could we just pass `keyboardShortcutIdentifier.toggleShortcutCheatSheet` and `onToggleShortcut`? 



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on PR #30950:
URL: https://github.com/apache/airflow/pull/30950#issuecomment-1557530220

   > Hi @bbovenzi ,
   > 
   > * Fixed the accordion toggle logic making it generic
   > * Using the local storage key "isInputInFocus" to discard the events that would get fired when the user is typing. Tried methods like `e.stopPropagation()`, `e.native.stopImmediatePropagation()`. Also tried this patch from react - https://legacy.reactjs.org/blog/2020/08/10/react-v17-rc.html#changes-to-event-delegation but still no luck. Finally used the above-mentioned tactical solution when on focus, setting it to true, and on blur setting it to false.
   > 
   > Do let me know if I missed anything.
   
   @bbovenzi any thoughts on the above?


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1204940812


##########
airflow/www/static/js/dag/details/NotesAccordion.tsx:
##########
@@ -106,8 +160,16 @@ const NotesAccordion = ({
                     maxRows={10}
                     as={ResizeTextarea}
                     value={note}
-                    onChange={(e) => setNote(e.target.value)}
+                    onChange={(e) => {
+                      setNote(e.target.value);
+                    }}
                     data-testid="notes-input"
+                    onFocus={() => {
+                      localStorage.setItem(isInputIFocus, "true");

Review Comment:
   As mentioned [here](https://github.com/apache/airflow/pull/30950#issuecomment-1553315956), no matter what I use, the events still end up bubbling when the user is typing in the notes text box. So, for example, if the user, while typing in the notes textbox presses `shift + C` ( to get capital C ), it fires up the corresponding shortcut as well. Hence, in order to avoid triggering the shortcut, we are using this LocalStorage to identify whether the user is typing or not at any given moment [in this line](https://github.com/apache/airflow/blob/275d4a226a3059bd50b5ae6417a2d4f506c5ae1f/airflow/www/static/js/utils/useKeysPress.ts#L43). If yes, then we will ignore the event to trigger a shortcut, or if no, then otherwise. And onBlur, we are setting it to false.
   
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1192905954


##########
airflow/www/static/js/dag/details/taskInstance/taskActions/ClearInstance.tsx:
##########
@@ -77,6 +78,10 @@ const ClearInstance = ({
   const [failed, setFailed] = useState(false);
   const onToggleFailed = () => setFailed(!failed);
 
+  const initialClearButtonFocusRef = useRef<HTMLButtonElement>(null);
+
+  useKeysPress("shiftKey", ['c', 'C'], onOpen);

Review Comment:
   Thanks for having a look. 
   
   Yes, working on creating the cheat sheet.
   
   Yes, will make sure to toggle the notes accordion open (if closed).



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1192905954


##########
airflow/www/static/js/dag/details/taskInstance/taskActions/ClearInstance.tsx:
##########
@@ -77,6 +78,10 @@ const ClearInstance = ({
   const [failed, setFailed] = useState(false);
   const onToggleFailed = () => setFailed(!failed);
 
+  const initialClearButtonFocusRef = useRef<HTMLButtonElement>(null);
+
+  useKeysPress("shiftKey", ['c', 'C'], onOpen);

Review Comment:
   Thanks for having a look. 
   
   Yes, working on creating the cheat sheet.
   
   Yes, will make sure to toggle the notes accordion open.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1187825939


##########
airflow/www/static/js/dag/details/taskInstance/taskActions/ClearInstance.tsx:
##########
@@ -77,6 +78,10 @@ const ClearInstance = ({
   const [failed, setFailed] = useState(false);
   const onToggleFailed = () => setFailed(!failed);
 
+  const initialClearButtonFocusRef = useRef<HTMLButtonElement>(null);
+
+  useKeysPress("shiftKey", ['c', 'C'], onOpen);

Review Comment:
   Hi @bbovenzi,
   I have fixed all the issues. Can you have a look once at the implementation?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1205939962


##########
airflow/www/static/js/dag/details/NotesAccordion.tsx:
##########
@@ -106,8 +160,16 @@ const NotesAccordion = ({
                     maxRows={10}
                     as={ResizeTextarea}
                     value={note}
-                    onChange={(e) => setNote(e.target.value)}
+                    onChange={(e) => {
+                      setNote(e.target.value);
+                    }}
                     data-testid="notes-input"
+                    onFocus={() => {
+                      localStorage.setItem(isInputIFocus, "true");

Review Comment:
   It is not the problem with the accordion but with how React handles the events and here we have a mix of flask app builder with React inserted into it, which makes the situation even more complex. Even if we got rid of the accordion, given any text box user is typing (in any part of the whole app given useKeysPress components are mounted), the events will be bubbled to the `useKeysPress`, and it will perform those actions that will not be desirable to the user (only while typing). Hence, have put this check using local storage that will completely stop it. 



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1206837286


##########
airflow/www/static/js/dag/keyboardShortcutIdentifier.ts:
##########
@@ -0,0 +1,71 @@
+/*!
+ * 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 type { KeyboardShortcutIdentifier } from "src/types";
+
+const keyboardShortcutIdentifier: KeyboardShortcutIdentifier = {
+  dagRunClear: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["C", "c"],
+    detail: "Clears the selected DAG run with all its existing tasks",
+  },
+  dagMarkSuccess: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["S", "s"],
+    detail: "Marks the selected DAG run as success",
+  },
+  dagMarkFailed: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["F", "f"],
+    detail: "Marks the selected DAG run as failed",
+  },
+  taskRunClear: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["C", "c"],
+    detail: "Opens modal to Clear selected task instance",
+  },
+  taskMarkSuccess: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["S", "s"],
+    detail: "Opens Mark as Success modal for the selected failed task instance",
+  },
+  taskMarkFailed: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["F", "f"],
+    detail:
+      "Opens Mark as Failed modal for the selected successful task instance",
+  },
+  viewNotes: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["N", "n"],
+    detail: "View the note of the selected DAG run or Task instance",
+  },
+  addOrEditNotes: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["E", "e"],
+    detail: "Edit the note of the selected DAG run or Task instance",
+  },
+  toggleShortcutCheatSheet: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["/", "?"],
+    detail: "Toggle Shortcut cheat sheet",
+  },
+};
+
+export default keyboardShortcutIdentifier;

Review Comment:
   Done.
   
   ![image](https://github.com/apache/airflow/assets/35839624/44a133eb-3229-4411-9ea6-20c688ac1c89)
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] bbovenzi merged pull request #30950: Adding keyboard shortcuts to common actions

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi merged PR #30950:
URL: https://github.com/apache/airflow/pull/30950


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1205899917


##########
airflow/www/static/js/dag/Main.tsx:
##########
@@ -145,6 +153,12 @@ const Main = () => {
     }
   };
 
+  useKeysPress(
+    keyboardShortcutIdentifier.toggleShortcutCheatSheet.primaryKey,

Review Comment:
   This is done



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] bbovenzi commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1205960778


##########
airflow/www/static/js/App.tsx:
##########
@@ -55,6 +56,8 @@ interface AppProps extends PropsWithChildren {
   cache: EmotionCache;
 }
 
+const isInputInFocus: IsInputInFocus = "isInputInFocus";

Review Comment:
   Just exporting the string from the useKeysPress is fine.



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] bbovenzi commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "bbovenzi (via GitHub)" <gi...@apache.org>.
bbovenzi commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1206763000


##########
airflow/www/static/js/dag/keyboardShortcutIdentifier.ts:
##########
@@ -0,0 +1,71 @@
+/*!
+ * 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 type { KeyboardShortcutIdentifier } from "src/types";
+
+const keyboardShortcutIdentifier: KeyboardShortcutIdentifier = {
+  dagRunClear: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["C", "c"],
+    detail: "Clears the selected DAG run with all its existing tasks",
+  },
+  dagMarkSuccess: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["S", "s"],
+    detail: "Marks the selected DAG run as success",
+  },
+  dagMarkFailed: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["F", "f"],
+    detail: "Marks the selected DAG run as failed",
+  },
+  taskRunClear: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["C", "c"],
+    detail: "Opens modal to Clear selected task instance",
+  },
+  taskMarkSuccess: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["S", "s"],
+    detail: "Opens Mark as Success modal for the selected failed task instance",
+  },
+  taskMarkFailed: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["F", "f"],
+    detail:
+      "Opens Mark as Failed modal for the selected successful task instance",
+  },
+  viewNotes: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["N", "n"],
+    detail: "View the note of the selected DAG run or Task instance",
+  },
+  addOrEditNotes: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["E", "e"],
+    detail: "Edit the note of the selected DAG run or Task instance",
+  },
+  toggleShortcutCheatSheet: {
+    primaryKey: "shiftKey",
+    secondaryKey: ["/", "?"],
+    detail: "Toggle Shortcut cheat sheet",
+  },
+};
+
+export default keyboardShortcutIdentifier;

Review Comment:
   Text could be smaller, and we could just say : "Type `shift`+`/` for shortcuts



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [airflow] Adaverse commented on a diff in pull request #30950: Adding keyboard shortcuts to common actions

Posted by "Adaverse (via GitHub)" <gi...@apache.org>.
Adaverse commented on code in PR #30950:
URL: https://github.com/apache/airflow/pull/30950#discussion_r1205934472


##########
airflow/www/static/js/dag/details/NotesAccordion.tsx:
##########
@@ -80,12 +89,56 @@ const NotesAccordion = ({
     setEditMode(false);
   };
 
+  const toggleNotesAccordionIthIndex = (ithIndex: number) => {
+    if (accordionIndexes.includes(ithIndex)) {
+      setAccordionIndexes((prevIndexes) =>
+        prevIndexes.splice(prevIndexes.indexOf(ithIndex, 1))
+      );
+    } else {
+      setAccordionIndexes((prevIndexes) => [...prevIndexes, ithIndex]);
+    }
+  };
+
+  useKeysPress(
+    keyboardShortcutIdentifier.addOrEditNotes.primaryKey,
+    keyboardShortcutIdentifier.addOrEditNotes.secondaryKey,
+    () => {
+      if (canEdit) {
+        // Notes index is 0
+        if (!accordionIndexes.includes(0)) {
+          toggleNotesAccordionIthIndex(0);
+        }
+        setEditMode(true);
+        setTimeout(() => textAreaRef.current?.focus(), 100);
+      }
+    }
+  );
+
+  useKeysPress(
+    keyboardShortcutIdentifier.viewNotes.primaryKey,
+    keyboardShortcutIdentifier.viewNotes.secondaryKey,
+    () => {
+      // toggling notes accordion (index = 0)
+      toggleNotesAccordionIthIndex(0);

Review Comment:
   True! But implemented `toggleNotesAccordionIthIndex`, thinking new panels might be included in the accordion in the future. Since you think that it might be overkill, hence replaced it with the simplest implementation - `toggleNotesPanel`



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org