Skip to content

Adding keyboard shortcuts to common actions#30950

Merged
bbovenzi merged 23 commits into
apache:mainfrom
Adaverse:test
May 29, 2023
Merged

Adding keyboard shortcuts to common actions#30950
bbovenzi merged 23 commits into
apache:mainfrom
Adaverse:test

Conversation

@Adaverse

@Adaverse Adaverse commented Apr 28, 2023

Copy link
Copy Markdown
Contributor

closes: #22870

Hello,

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)
    • Toggle note (shift + n)
    • Edit notes (shift + e)
  • At TaskInstance
    • Clear task (shift + c)
    • Mark as success or fail (shift + s or shift + f)
    • Toggle notes (shift + n)
    • Edit notes (shift + e)
  • Toggle shortcut cheat sheet (shift + /)

Added the shortcut cheat sheet modal -

image

The tasks

  • Implementing various shortcuts for grid view
  • Creating a cheat sheet for the information
  • keeping focus on the action buttons of the opened modal by default

^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
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.

@boring-cyborg boring-cyborg Bot added area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues labels Apr 28, 2023
@Adaverse Adaverse changed the title # Adding keyboard shortcuts to common actions Apr 28, 2023
@eladkal

eladkal commented Apr 28, 2023

Copy link
Copy Markdown
Contributor

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?

@Adaverse

Adaverse commented Apr 28, 2023

Copy link
Copy Markdown
Contributor Author

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. Just want to get this code reviewed before adding the rest :).

@Adaverse
Adaverse marked this pull request as draft April 29, 2023 16:21

const initialClearButtonFocusRef = useRef<HTMLButtonElement>(null);

useKeysPress("shiftKey", ['c', 'C'], onOpen);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bbovenzi bbovenzi May 10, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Adaverse Adaverse May 13, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for having a look.

Yes, working on creating the cheat sheet.

Yes, will make sure to toggle the notes accordion open (if closed).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

…list

- 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)
@Adaverse
Adaverse requested a review from bbovenzi May 3, 2023 11:13
Adaverse and others added 3 commits May 8, 2023 22:59
…cut cheat sheet

- added cheat sheet modal
- using local storage variable to ignore event which text area is in focus
@Adaverse
Adaverse marked this pull request as ready for review May 15, 2023 21:01
@Adaverse

Copy link
Copy Markdown
Contributor Author

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.

@Adaverse

Copy link
Copy Markdown
Contributor Author

Hi @bbovenzi ,

Do let me know if I missed anything.

Adaverse added 7 commits May 18, 2023 22:39
…list

- 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)
…cut cheat sheet

- added cheat sheet modal
- using local storage variable to ignore event which text area is in focus
@Adaverse

Copy link
Copy Markdown
Contributor Author

Hi @bbovenzi ,

Do let me know if I missed anything.

@bbovenzi any thoughts on the above?

@eladkal
eladkal requested a review from pierrejeambrun May 23, 2023 05:18

@bbovenzi bbovenzi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments.

Comment thread airflow/www/static/js/App.tsx Outdated
cache: EmotionCache;
}

const isInputInFocus: IsInputInFocus = "isInputInFocus";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just a string we don't need a special type for it.

Suggested change
const isInputInFocus: IsInputInFocus = "isInputInFocus";
const isInputInFocus = "isInputInFocus";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just exporting the string from the useKeysPress is fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Defined in useKeysPress and importing it everywhere.

Comment thread airflow/www/static/js/dag/details/NotesAccordion.tsx Outdated
Comment thread airflow/www/static/js/dag/Main.tsx Outdated
};

useKeysPress(
keyboardShortcutIdentifier.toggleShortcutCheatSheet.primaryKey,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just pass keyboardShortcutIdentifier.toggleShortcutCheatSheet and onToggleShortcut?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done

keyboardShortcutIdentifier.viewNotes.secondaryKey,
() => {
// toggling notes accordion (index = 0)
toggleNotesAccordionIthIndex(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need all this extra toggleNotesAccordionIthIndex just toggle the editMode

@Adaverse Adaverse May 25, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

},
};

export default keyboardShortcutIdentifier;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a button. Let me know your thoughts

image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

image

@bbovenzi bbovenzi mentioned this pull request May 25, 2023
2 tasks
@Adaverse
Adaverse requested a review from bbovenzi May 26, 2023 12:07

@bbovenzi bbovenzi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good!

@Adaverse

Copy link
Copy Markdown
Contributor Author

@bbovenzi can this be merged now?

@bbovenzi
bbovenzi merged commit f532d39 into apache:main May 29, 2023
@bbovenzi bbovenzi added this to the Airflow 2.7.0 milestone May 29, 2023
@eladkal eladkal added the type:new-feature Changelog: New Features label Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers. area:webserver Webserver related Issues type:new-feature Changelog: New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard shortcut in Airflow web UI

3 participants