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

[WIP] Refactor tabs#5133

Merged
jasonLaster merged 9 commits into
firefox-devtools:masterfrom
bomsy:refactor-tabs
Jan 22, 2018
Merged

[WIP] Refactor tabs#5133
jasonLaster merged 9 commits into
firefox-devtools:masterfrom
bomsy:refactor-tabs

Conversation

@bomsy

@bomsy bomsy commented Jan 18, 2018

Copy link
Copy Markdown
Contributor

Associated Issue: #3279

Here's the Pull Request Doc
https://devtools-html.github.io/debugger.html/CONTRIBUTING.html#pull-requests

Summary of Changes

  • Add Tab.js
  • Add tab utility

@jasonLaster jasonLaster 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…

looks like there’s a new empty tabs action

Comment thread src/utils/tabs.js
@@ -0,0 +1,28 @@
/*

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.

missing flow and the copyright comment

@jasonLaster

Copy link
Copy Markdown
Contributor

so much cleaner!

@@ -0,0 +1,217 @@
import React, { PureComponent } from "react";

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.

Flow + copyright header missing.

Comment thread src/components/Editor/Tab.js Outdated
}
};

export default class Tab extends PureComponent<Props, State> {

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 like that tabs are now their own component!

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.

One thing though. This component takes lots of props that are from Redux but are being passed through in src/components/Editor/Tabs, maybe instead of default exporting the class we bring in redux connect().

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.

good idea!

Comment thread src/components/Editor/Tabs.js Outdated
handleClick={onClickClose}
tooltip={L10N.getStr("sourceTabs.closeTabButtonTooltip")}
/>
{tabSources.map((source, index) => {

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 think this looks a little nicer as

{tabSources.map((source, index) => (
  <Tab
    key={index}
    source={source}
    tabSources={tabSources}
    selectedSource={selectedSource}
    closeTab={closeTab}
    togglePrettyPrint={togglePrettyPrint}
    showSource={showSource}
    sourceTabsMetaData={sourceTabsMetaData}
    selectSource={selectSource}
  />
))}

Comment thread src/components/Editor/Tab.js Outdated
};

export default class Tab extends PureComponent<Props, State> {
constructor() {

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.

If we have a constructor you should take the props argument and pass it to super. But in this case since the body is empty save for the super call we should remove the constructor.


const isPrettySource = isPretty(tabID);

const closeTabMenuItem = {

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.

Feel like these menu items could be moved to a utility file for most of their body, something like

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

Then this way when you're building up the list here all you're adding is the click properties and can spread in the hard coded stuff from elsewhere.

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.

yep - lets do this in a separate PR though to keep this smaller

@jasonLaster jasonLaster merged commit 8a1e8b0 into firefox-devtools:master Jan 22, 2018
jasonLaster pushed a commit that referenced this pull request Jan 24, 2018
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