Skip to content

Commit

Permalink
fix(glossary): handle empty glossary (zanata#1216)
Browse files Browse the repository at this point in the history
doc(frontend): Update readme.md for frontend and styleguide

https://zanata.atlassian.net/browse/ZNTA-1183
  • Loading branch information
Alex Eng authored Jun 21, 2016
1 parent 27f66d6 commit 142fe0b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 44 deletions.
26 changes: 20 additions & 6 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@

This module contains: User profile page, Glossary page, and Zanata side menu bar.

## To run in dev mode (need http://localhost:8080/zanata to run separately):
## To run/setup in nodeJS

Navigate to frontend/src/main/web and run
Navigate to `frontend/src/main/web`, run `npm install`

```npm install```
### To run in dev mode http://localhost:8000 (a HTTP server to serve index.html with webpack produced bundle.js)

to install all dependencies. To start
- need http://localhost:8080/zanata to run separately
`npm start`

```npm start```
### Production Build

## To build it just run
`npm run build`

### Run styleguide

`npm run styleguide-build` follow by `npm run styleguide-server`


## To generate a jar dependency

```mvn install```

Expand All @@ -37,3 +45,9 @@ If you activate profile ```-DnpmOffline``` the cache-min option will become 9999
Currently this module has been "shrinkwrapped" which means its npm module dependencies has been fixed to certain version. If you want to add or upgrade an individual version, you will need to consult [npm shrinkwrap documentation](https://docs.npmjs.com/cli/shrinkwrap#building-shrinkwrapped-packages) for detail instruction.

Since we use maven to copy our source to target/ then run npm from maven, you will need to run above commands under target/ then copy the new npm-shrinkwrap.json file back to src/.


## Documentation

For extensive details on each part of the front-end see the
[documentation](./src/main/web/docs).
22 changes: 0 additions & 22 deletions frontend/src/main/web/README.md

This file was deleted.

25 changes: 14 additions & 11 deletions frontend/src/main/web/src/components/OverlayTrigger/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@ import callWithSameArgs from '../../utils/callWithSameArgs'
import Overlay from '../Overlay'

class OverlayTrigger extends Component {
state = {
isOverlayShown: this.props.defaultOverlayShown
constructor () {
super()
this.state = {
isOverlayShown: this.props.defaultOverlayShown
}
}

show = () => {
show () {
this.setState({
isOverlayShown: true
})
}

hide = () => {
hide () {
this.setState({
isOverlayShown: false
})
}

toggle = () => {
toggle () {
if (this.state.isOverlayShown) {
this.hide()
} else {
Expand All @@ -36,17 +39,17 @@ class OverlayTrigger extends Component {
* without resetting up all context.
* See https://github.com/react-component/dialog/issues/10
*/
renderOverlay = () => {
renderOverlay () {
ReactDOM.unstable_renderSubtreeIntoContainer(
this, this._overlay, this._mountNode
)
}

getOverlayTarget = () => {
getOverlayTarget () {
return ReactDOM.findDOMNode(this)
}

getOverlay = () => {
getOverlay () {
const overlayProps = {
...pick(this.props, Object.keys(Overlay.propTypes)),
show: this.state.isOverlayShown,
Expand All @@ -72,7 +75,7 @@ class OverlayTrigger extends Component {
</Overlay>
)
}
handleDelayedShow = () => {
handleDelayedShow () {
if (this.hoverHideTimeoutHandle !== undefined) {
clearTimeout(this.hoverHideTimeoutHandle)
this.hoverHideTimeoutHandle = undefined
Expand All @@ -97,7 +100,7 @@ class OverlayTrigger extends Component {
}, delay)
}

handleDelayedHide = () => {
handleDelayedHide () {
if (this._hoverShowDelay !== undefined) {
clearTimeout(this._hoverShowDelay)
this._hoverShowDelay = undefined
Expand Down Expand Up @@ -126,7 +129,7 @@ class OverlayTrigger extends Component {
// https://github.com/facebook/react/issues/4251
// for cases when the trigger is disabled and mouseOut/Over can
// cause flicker moving from one child element to another.
handleMouseOverOut = (handler, e) => {
handleMouseOverOut (handler, e) {
let target = e.currentTarget
let related = e.relatedTarget || e.nativeEvent.toElement

Expand Down
13 changes: 8 additions & 5 deletions frontend/src/main/web/src/reducers/glossary.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,18 @@ const glossary = handleActions({
}
},
[GLOSSARY_STATS_SUCCESS]: (state, action) => {
const transLocales = isEmpty(action.payload.transLocale)
? []
: action.payload.transLocale.map(result => ({
value: result.locale.localeId,
label: result.locale.displayName,
count: result.numberOfTerms
}))
return ({
...state,
stats: {
srcLocale: action.payload.srcLocale,
transLocales: action.payload.transLocale.map(result => ({
value: result.locale.localeId,
label: result.locale.displayName,
count: result.numberOfTerms
}))
transLocales: transLocales
},
statsLoading: false
})
Expand Down

0 comments on commit 142fe0b

Please sign in to comment.