Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Cleanup tabs#5181

Merged
bomsy merged 6 commits into
firefox-devtools:masterfrom
bomsy:cleanup-tabs
Jan 25, 2018
Merged

Cleanup tabs#5181
bomsy merged 6 commits into
firefox-devtools:masterfrom
bomsy:cleanup-tabs

Conversation

@bomsy
Copy link
Copy Markdown
Contributor

@bomsy bomsy commented Jan 24, 2018

  • Move part of the items to a util

Comment thread src/components/Editor/Tab.js Outdated
items.push({
item: {
...tabMenuItems.prettyPrint,
click: () => showSource(tab)
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 should be click: () => togglePrettyPrint(sourceTab.get("id"))

Comment thread src/utils/tabs.js Outdated
}

export function getTabMenuItems() {
const items = {
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.

maybe return { ... }

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.

Since it's always the same object you could skip the function and just

export const tabMenuItems = {
...
};

@wldcordeiro
Copy link
Copy Markdown
Contributor

wldcordeiro commented Jan 24, 2018

Sketch of an idea...

const handlers = {
  closeTab: {
    click: () => closeTab(sourceTab.get("url"))
  },
  // ...
};

const items = {
  closeTab: {
    id: "node-menu-close-tab",
    label: L10N.getStr("sourceTabs.closeTab"),
    accesskey: L10N.getStr("sourceTabs.closeTab.accesskey"),
    disabled: false
  },
  // ...
};

function mapTabItems(handlers, items) {
  return Object.entries(items).reduce((acc, [key, item]) => {
    return [...acc, { item, ...handlers[key] }]
  }, []);
}

@jasonLaster
Copy link
Copy Markdown
Contributor

so... frankly i'm okay with a longer menu function. It's cool to try and consolidate it, but lets not add too much indirection in

@bomsy bomsy merged commit 18abdb4 into firefox-devtools:master Jan 25, 2018
jasonLaster pushed a commit that referenced this pull request Jan 29, 2018
* add the  tabs reducer

* add space

* move part of the tab menuitems to the utils

* remove abs reducers

* fixes

* make a function as LION does not exist in the scope of the util
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants