debugger icon indicating copy to clipboard operation
debugger copied to clipboard

[Tabs] Show Framework logos

Open jasonLaster opened this issue 9 years ago • 11 comments

It would be really cool if we could show a framework logo in the source tabs. This would help us differentiate between the Expressions component, actions, and reducer.

To figureout if a file is a component, actions, or reducer we need to check the AST.

Component: imports react and uses createClass or the Component class Action: has a function with an inner that has an object with dispatch Reducer: has an update function with a switch statement

canonical actions

export function resumed() {
  return ({ dispatch }) => {
  };
}

export function resumed() {
  return function ({ dispatch }) {
  };
}

canonical reducer:

function update(
  state: Record<BreakpointsState> = initialState(),
  action: Action
) {
  switch (action.type) {
  }
}

jasonLaster avatar Sep 24 '17 14:09 jasonLaster

Here's a patch to help get started

jasonLaster avatar Sep 24 '17 14:09 jasonLaster

James is working on it

jasonLaster avatar Sep 25 '17 22:09 jasonLaster

We landed a util for isReactComponent.

We can now easily check :)

and add it here:

diff --git a/src/components/Editor/Tabs.js b/src/components/Editor/Tabs.js
index 50aba30..927b8a2 100644
--- a/src/components/Editor/Tabs.js
+++ b/src/components/Editor/Tabs.js
@@ -451,6 +451,10 @@ class SourceTabs extends PureComponent<Props, State> {
   getSourceAnnotation(source) {
     const sourceObj = source.toJS();
 
+    if (isReactComponent) {
+      return <img className="react" />;
+    }
+
     if (isPretty(sourceObj)) {
       return <img className="prettyPrint" />;
     }

jasonLaster avatar Oct 27 '17 21:10 jasonLaster

We now have redux state, which will make this easier.

diff --git a/src/components/Editor/Tabs.js b/src/components/Editor/Tabs.js
index ae3f5ab..4c910d5 100644
--- a/src/components/Editor/Tabs.js
+++ b/src/components/Editor/Tabs.js
@@ -453,8 +453,13 @@ class SourceTabs extends PureComponent<Props, State> {
   }
 
   getSourceAnnotation(source) {
+    const { sourceMetaData } = this.props;
     const sourceObj = source.toJS();
 
+    if (sourceMetaData && sourceMetaData.isReactComponent) {
+      return <img className="react" />;
+    }
+
     if (isPretty(sourceObj)) {
       return <img className="prettyPrint" />;
     }
@@ -482,7 +487,8 @@ export default connect(
       searchTabs: getSearchTabs(state),
       sourceTabs: getSourcesForTabs(state),
       activeSearch: getActiveSearch(state),
-      searchOn: getActiveSearch(state) === "source"
+      searchOn: getActiveSearch(state) === "source",
+      metaData: getSourceMetaData(state, source)
     };
   },
   dispatch => bindActionCreators(actions, dispatch)

jasonLaster avatar Nov 10 '17 23:11 jasonLaster

/claim

James300 avatar Nov 15 '17 05:11 James300

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Nov 15 '17 05:11 claim

/claim

khal0988 avatar Nov 18 '17 19:11 khal0988

Thanks for claiming the issue! :wave:

Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.

:fox_face: Debugger team!

claim avatar Nov 18 '17 19:11 claim

/unclaim

khal0988 avatar Nov 18 '17 20:11 khal0988

Done :+1:

claim avatar Nov 18 '17 20:11 claim

/claim

James300 avatar Nov 18 '17 20:11 James300