diff --git a/src/components/BugzillaComponentDetails/index.jsx b/src/components/BugzillaComponentDetails/index.jsx index b717136..9c9ba12 100644 --- a/src/components/BugzillaComponentDetails/index.jsx +++ b/src/components/BugzillaComponentDetails/index.jsx @@ -41,11 +41,11 @@ const constructQuery = (metrics, product, component) => Object.values(metrics).m }); const BugzillaComponentDetails = ({ - classes, bugzillaEmail, product, component, metrics = {}, onGoBack, + classes, bugzillaEmail, product, component, title, metrics = {}, onGoBack, }) => ( - +
-

{bugzillaEmail}

+ {bugzillaEmail &&

{bugzillaEmail}

} {Object.keys(metrics).sort().map(metric => ( metrics[metric] && (
@@ -57,7 +57,7 @@ const BugzillaComponentDetails = ({ ) ))}
@@ -67,14 +67,22 @@ const BugzillaComponentDetails = ({ BugzillaComponentDetails.propTypes = { classes: PropTypes.shape({}).isRequired, - bugzillaEmail: PropTypes.string.isRequired, - product: PropTypes.string.isRequired, - component: PropTypes.string.isRequired, + bugzillaEmail: PropTypes.string, + product: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.string), + PropTypes.string, + ]).isRequired, + component: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.string), + PropTypes.string, + ]).isRequired, metrics: PropTypes.shape({}), + title: PropTypes.string.isRequired, onGoBack: PropTypes.func.isRequired, }; BugzillaComponentDetails.defaultProps = { + bugzillaEmail: '', metrics: {}, }; diff --git a/src/components/BugzillaComponents/index.jsx b/src/components/BugzillaComponents/index.jsx index de95f89..9f98277 100644 --- a/src/components/BugzillaComponents/index.jsx +++ b/src/components/BugzillaComponents/index.jsx @@ -42,7 +42,7 @@ const BugzillaComponents = ({ {bugzillaComponents .sort(sortByComponentName) .map(({ - label, component, product, metrics = {}, + label, component, product, metrics = {}, teamKey = null, }) => ( {onComponentDetails && ( @@ -51,12 +51,16 @@ const BugzillaComponents = ({ name={label} onKeyPress={onComponentDetails} onClick={onComponentDetails} - product={product} - component={component} + bzcomponentkey={teamKey || `${product}::${component}`} + teamkey={teamKey} role="button" tabIndex="0" > - +
)} diff --git a/src/components/MainView/index.jsx b/src/components/MainView/index.jsx index e712342..d8d7257 100644 --- a/src/components/MainView/index.jsx +++ b/src/components/MainView/index.jsx @@ -29,6 +29,7 @@ const MainView = ({ { - const team = Object.assign({}, teamInfo); - team.metrics = {}; + const team = { + teamKey, + ...teamInfo, + metrics: {}, + }; const { product, component } = teamInfo; await Promise.all(Object.keys(METRICS).map(async (metric) => { team.metrics[metric] = await getBugsCountAndLink(product, component, metric); @@ -132,12 +135,26 @@ class MainContainer extends Component { handleShowComponentDetails(event) { event.preventDefault(); const element = event.target.tagName === 'DIV' ? event.target : event.target.parentElement; - const product = element.getAttribute('product'); - const component = element.getAttribute('component'); - this.setState(prevState => ({ - showComponent: prevState.bugzillaComponents[`${product}::${component}`], - showPerson: undefined, - })); + // IDEA: In the future we could unify bugzilla components and teams into + // the same data structure and make this logic simpler. We could use a + // property 'team' to distinguish a component from a set of components + const bzComponentKey = element.getAttribute('bzcomponentkey'); + const teamKey = element.getAttribute('teamkey'); + if (teamKey) { + this.setState(prevState => ({ + showComponent: { + title: prevState.teamComponents[teamKey].label, + ...prevState.teamComponents[teamKey], + }, + })); + } else { + this.setState(prevState => ({ + showComponent: { + title: bzComponentKey, + ...prevState.bugzillaComponents[bzComponentKey], + }, + })); + } } handleShowPersonDetails(event) { @@ -146,7 +163,6 @@ class MainContainer extends Component { const ldapEmail = element.getAttribute('value'); const { partialOrg } = this.state; this.setState({ - showComponent: undefined, showPerson: partialOrg[ldapEmail], }); } @@ -169,6 +185,7 @@ class MainContainer extends Component { {showComponent && ( )} diff --git a/test/components/BugzillaComponentDetails.test.jsx b/test/components/BugzillaComponentDetails.test.jsx index 4da80e5..555245e 100644 --- a/test/components/BugzillaComponentDetails.test.jsx +++ b/test/components/BugzillaComponentDetails.test.jsx @@ -8,6 +8,7 @@ it('renders the details for a Bugzilla component', () => { .create(( null} /> )) diff --git a/test/components/__snapshots__/BugzillaComponentDetails.test.jsx.snap b/test/components/__snapshots__/BugzillaComponentDetails.test.jsx.snap index 25e4941..f3a5596 100644 --- a/test/components/__snapshots__/BugzillaComponentDetails.test.jsx.snap +++ b/test/components/__snapshots__/BugzillaComponentDetails.test.jsx.snap @@ -31,7 +31,7 @@ exports[`renders the details for a Bugzilla component 1`] = `

- Core::DOM: IndexedDB + Hello world!