This repository has been archived by the owner on May 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also fixes the "calling setState on an unmounted component" warning. Also, instead of using CSS classes to target DOM nodes in integration tests, we use `data-test` attributes. We can later strip these out of the build using a babel plugin, if desired. Note: there are other ways of doing this, but for the time being the `data-test` attribute best matches the current code with the least number of changes and is clear enough. It's also a recommended approach by Kent C Dodds, if that holds any weight.
- Loading branch information
1 parent
44c50d2
commit 96be934
Showing
11 changed files
with
104 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
|
||
import { appPropType } from '../../stores/app_store'; | ||
import { orgPropType } from '../../stores/org_store'; | ||
import { spacePropType } from '../../stores/space_store'; | ||
import Item from './breadcrumbs_item'; | ||
import { orgHref, spaceHref } from '../../util/url'; | ||
|
||
const propTypes = { | ||
org: orgPropType.isRequired, | ||
space: spacePropType, | ||
app: appPropType | ||
}; | ||
|
||
const Breadcrumbs = ({ org, space, app }) => { | ||
const items = [ | ||
<Item key="home" href="/" testLabel="overview"> | ||
Overview | ||
</Item> | ||
]; | ||
|
||
if (org && space) { | ||
items.push( | ||
<Item key={org.guid} href={orgHref(org)} testLabel="org"> | ||
{org.name} | ||
</Item> | ||
); | ||
} | ||
|
||
if (org && space && app) { | ||
items.push( | ||
<Item key={space.guid} href={spaceHref(org, space)} testLabel="space"> | ||
{space.name} | ||
</Item> | ||
); | ||
} | ||
|
||
return ( | ||
<ol className="breadcrumbs" data-test="breadcrumbs"> | ||
{items} | ||
</ol> | ||
); | ||
}; | ||
|
||
Breadcrumbs.propTypes = propTypes; | ||
|
||
export default Breadcrumbs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const propTypes = { | ||
children: PropTypes.node.isRequired, | ||
href: PropTypes.string, | ||
testLabel: PropTypes.string | ||
}; | ||
|
||
const BreadcrumbsItem = ({ children, href, testLabel }) => ( | ||
<li className="breadcrumbs-item"> | ||
{href ? ( | ||
<a className="breadcrumbs-item-link" href={href} data-test={testLabel}> | ||
{children} | ||
</a> | ||
) : ( | ||
<span className="breadcrumbs-item-current" data-test={testLabel}> | ||
{children} | ||
</span> | ||
)} | ||
</li> | ||
); | ||
|
||
BreadcrumbsItem.propTypes = propTypes; | ||
|
||
export default BreadcrumbsItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './breadcrumbs'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters