KTNB-628 Add "Create Gist" action to the toolbar of Kotlin Notebooks

GitOrigin-RevId: eedc263675c19eaf7f7dc8c98d14a9c9bf3395fb
This commit is contained in:
Arkady.Bazhanov
2024-03-27 13:37:06 +00:00
committed by intellij-monorepo-bot
parent 3a8596a0e3
commit d15d074bc9
2 changed files with 25 additions and 0 deletions
@@ -111,6 +111,7 @@
<add-to-group group-id="EditorTabPopupMenu"/>
<add-to-group group-id="ConsoleEditorPopupMenu"/>
</action>
<action id="Github.Create.Gist.AlwaysEnabled" class="org.jetbrains.plugins.github.GithubCreateGistAlwaysEnabledAction"/>
<group id="GitHub.MainMenu" popup="true">
<reference ref="Github.Share"/>
<reference ref="Github.Create.Pull.Request"/>
@@ -0,0 +1,24 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.github
import com.intellij.openapi.actionSystem.ActionPlaces
import com.intellij.openapi.actionSystem.AnActionEvent
/**
* A wrapper around [GithubCreateGistAction].
* This action can be used in toolbars and context menus, and it won't be disabled or hidden when the user
* does not have a GitHub account connected. If this behavior is desired, use this action. Otherwise, use
* [GithubCreateGistAction].
*
* This action won't show up in search, otherwise it would be possible to have both this action and
* [GithubCreateGistAction] in the search results.
*/
class GithubCreateGistAlwaysEnabledAction : GithubCreateGistAction() {
override fun update(e: AnActionEvent) {
// We're intentionally not calling super.update(e), as it would check for a connected GitHub account,
// and we don't want that.
/** We're hiding this action from search so that we won't show it alongside [GithubCreateGistAction] */
e.presentation.isEnabledAndVisible = !ActionPlaces.isMainMenuOrActionSearch(e.place)
}
}