-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #504 from zalando-stups/499-Improve-UX-of-applicat…
…ion-lifecycle 499 improve ux of application lifecycle
- Loading branch information
Showing
18 changed files
with
368 additions
and
159 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 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
73 changes: 73 additions & 0 deletions
73
client/lib/application/src/application-lifecycle/components/charts_utils.jsx
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,73 @@ | ||
import React from 'react'; | ||
import Icon from 'react-fa'; | ||
import Spinner from 'common/src/components/pure/Spinner.jsx'; | ||
|
||
import Conditional from 'common/src/components/pure/ConditionalHOC.jsx'; | ||
|
||
// Functions | ||
const iconNameByRepo = function (url) { | ||
if (!url) { | ||
return ''; | ||
} | ||
if (url.includes('github.com')) { | ||
return 'github'; | ||
} | ||
if (url.includes('github')) { | ||
return 'github-square'; | ||
} | ||
return 'external-link-square'; | ||
}; | ||
|
||
const isKioLoading = props => props.application['status'] && props.application['status'] == 'PENDING'; | ||
|
||
// Simple Components | ||
|
||
const ScmDisplay = props => | ||
<div> | ||
<a className='btn btn-default btn-small' | ||
href={props.application.scm_url}> | ||
<Icon fixedWidth name={iconNameByRepo(props.application.scm_url)} /> | ||
</a> SCM | ||
</div>; | ||
ScmDisplay.displayName = 'ScmDisplay'; | ||
ScmDisplay.propTypes = { | ||
application: React.PropTypes.shape({ | ||
scm_url: React.PropTypes.string | ||
}).isRequired | ||
}; | ||
|
||
const ServiceDisplay = props => | ||
<div> | ||
<a className='btn btn-default btn-small' | ||
href={props.application.service_url}> | ||
<Icon fixedWidth name='external-link-square' /> | ||
</a> Service | ||
</div>; | ||
|
||
ServiceDisplay.displayName = 'ServiceDisplay'; | ||
ServiceDisplay.propTypes = { | ||
application: React.PropTypes.shape({ | ||
service_url: React.PropTypes.string | ||
}).isRequired | ||
}; | ||
|
||
/*eslint-disable react/display-name */ | ||
const NotAvailable = displayString => () => <div><Icon name='icon-frown' />{displayString} n/a</div>; | ||
const Loading = displayString => () => <div><Spinner />{displayString}</div>; | ||
/*eslint-enable react/display-name */ | ||
|
||
// HOC'ified Components | ||
|
||
const ScmAvailable = Conditional(props => !!props.application.scm_url, | ||
ScmDisplay, NotAvailable('SCM')); | ||
const ServiceAvailable = Conditional(props => !!props.application.service_url, | ||
ServiceDisplay, NotAvailable('Service')); | ||
|
||
const ScmShortCut = Conditional(props => isKioLoading(props), Loading('SCM'), ScmAvailable); | ||
const ServiceShortCut = Conditional(props => isKioLoading(props), Loading('Service'), ServiceAvailable); | ||
|
||
|
||
export { | ||
ScmShortCut, | ||
ServiceShortCut | ||
} |
Oops, something went wrong.