Skip to content

"Remove" default menu item needs to be aware of user preference #4976

Closed

Description

@shiftkey

Following on from #4975, the top-level Repository | Remove menu item needs to be aware of whether the user has this set:

screen shot 2018-06-20 at 11 19 07 am

I wasn't able to fix this in #4975 because we don't have an easy way to get access to this setting (which is managed by the renderer) when generating the menu entries (which is managed by the main process).

build-default-menu.ts is the place to make this change, as well as the related IPC call from the renderer, but this is a potential opportunity to think about how to rethink this area rather than adding another parameter.

Activity

  1. added
    help wanted
    on Jun 20, 2018
  2. iAmWillShepherd commented on Jun 20, 2018

    @iAmWillShepherd
    Contributor

    We have an event handler in main.ts which may be a good starting point.

    ipcMain.on(
    'update-preferred-app-menu-item-labels',
    (
    event: Electron.IpcMessageEvent,
    labels: { editor?: string; pullRequestLabel?: string; shell: string }
    ) => {
    menu = buildDefaultMenu(
    labels.editor,
    labels.shell,
    labels.pullRequestLabel
    )
    Menu.setApplicationMenu(menu)
    if (mainWindow) {
    mainWindow.sendAppMenu()
    }
    }
    )

    The function that you can call to update the menu items is in app-store.ts.

    private updateMenuItemLabels(repository?: Repository) {
    const editorLabel = this.selectedExternalEditor
    ? `Open in ${this.selectedExternalEditor}`
    : undefined
    const prLabel = repository
    ? this.getPullRequestLabel(repository)
    : undefined
    updatePreferredAppMenuItemLabels({
    editor: editorLabel,
    pullRequestLabel: prLabel,
    shell: `Open in ${this.selectedShell}`,
    })
    }

    localStorage.getItem(confirmDiscardChangesKey) should be enough to get the value of the setting.

  3. Daniel-McCarthy commented on Dec 17, 2018

    @Daniel-McCarthy
    Member

    I am interested in this issue as I would like to learn some more about Electron and how the core of the program is set up. This issue deals with the communication between main and renderer, which is great.

    I would be more than happy to submit a pull request to add a parameter for the Remove label to be passed to main, however, this issue proposes rethinking this area.

    Is this something there is still interest in? Are there goals in mind for what some kind of shake up to this area would help address?

  4. shiftkey commented on Dec 24, 2018

    @shiftkey
    MemberAuthor

    @Daniel-McCarthy I think this is an interesting issue because of all the stuff that Electron touches. Feel free to dive into it when you've got time, I'd be happy to help with reviewing stuff...

  5. Daniel-McCarthy commented on Dec 24, 2018

    @Daniel-McCarthy
    Member

    Excellent, I will submit a pull request soon regarding this Issue.

  6. removed
    help wanted
    on Mar 8, 2019
  7. shiftkey commented on Mar 8, 2019

    @shiftkey
    MemberAuthor

    We had a go at getting this working in #6489 but it uncovered a race condition with the tests that needs to be addressed. #6489 (comment) contains the gory details, and for the moment this is blocked on figuring that out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions