-
-
Notifications
You must be signed in to change notification settings - Fork 956
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9798202
commit 152f50a
Showing
37 changed files
with
2,267 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.movieSearchCell { | ||
composes: cell from '~Components/Table/Cells/TableRowCell.css'; | ||
|
||
width: 70px; | ||
white-space: nowrap; | ||
} |
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,7 @@ | ||
// This file is automatically generated. | ||
// Please do not change this file! | ||
interface CssExports { | ||
'movieSearchCell': string; | ||
} | ||
export const cssExports: CssExports; | ||
export default cssExports; |
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,81 @@ | ||
import PropTypes from 'prop-types'; | ||
import React, { Component } from 'react'; | ||
import IconButton from 'Components/Link/IconButton'; | ||
import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; | ||
import TableRowCell from 'Components/Table/Cells/TableRowCell'; | ||
import { icons } from 'Helpers/Props'; | ||
import translate from 'Utilities/String/translate'; | ||
import MovieInteractiveSearchModalConnector from './Search/MovieInteractiveSearchModalConnector'; | ||
import styles from './MovieSearchCell.css'; | ||
|
||
class MovieSearchCell extends Component { | ||
|
||
// | ||
// Lifecycle | ||
|
||
constructor(props, context) { | ||
super(props, context); | ||
|
||
this.state = { | ||
isInteractiveSearchModalOpen: false | ||
}; | ||
} | ||
|
||
// | ||
// Listeners | ||
|
||
onManualSearchPress = () => { | ||
this.setState({ isInteractiveSearchModalOpen: true }); | ||
}; | ||
|
||
onInteractiveSearchModalClose = () => { | ||
this.setState({ isInteractiveSearchModalOpen: false }); | ||
}; | ||
|
||
// | ||
// Render | ||
|
||
render() { | ||
const { | ||
movieId, | ||
movieTitle, | ||
isSearching, | ||
onSearchPress, | ||
...otherProps | ||
} = this.props; | ||
|
||
return ( | ||
<TableRowCell className={styles.movieSearchCell}> | ||
<SpinnerIconButton | ||
name={icons.SEARCH} | ||
isSpinning={isSearching} | ||
onPress={onSearchPress} | ||
title={translate('AutomaticSearch')} | ||
/> | ||
|
||
<IconButton | ||
name={icons.INTERACTIVE} | ||
onPress={this.onManualSearchPress} | ||
title={translate('InteractiveSearch')} | ||
/> | ||
|
||
<MovieInteractiveSearchModalConnector | ||
isOpen={this.state.isInteractiveSearchModalOpen} | ||
movieId={movieId} | ||
movieTitle={movieTitle} | ||
onModalClose={this.onInteractiveSearchModalClose} | ||
{...otherProps} | ||
/> | ||
</TableRowCell> | ||
); | ||
} | ||
} | ||
|
||
MovieSearchCell.propTypes = { | ||
movieId: PropTypes.number.isRequired, | ||
movieTitle: PropTypes.string.isRequired, | ||
isSearching: PropTypes.bool.isRequired, | ||
onSearchPress: PropTypes.func.isRequired | ||
}; | ||
|
||
export default MovieSearchCell; |
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,48 @@ | ||
import { connect } from 'react-redux'; | ||
import { createSelector } from 'reselect'; | ||
import * as commandNames from 'Commands/commandNames'; | ||
import MovieSearchCell from 'Movie/MovieSearchCell'; | ||
import { executeCommand } from 'Store/Actions/commandActions'; | ||
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; | ||
import createMovieSelector from 'Store/Selectors/createMovieSelector'; | ||
import { isCommandExecuting } from 'Utilities/Command'; | ||
|
||
function createMapStateToProps() { | ||
return createSelector( | ||
(state, { movieId }) => movieId, | ||
createMovieSelector(), | ||
createCommandsSelector(), | ||
(movieId, movie, commands) => { | ||
const isSearching = commands.some((command) => { | ||
const movieSearch = command.name === commandNames.MOVIE_SEARCH; | ||
|
||
if (!movieSearch) { | ||
return false; | ||
} | ||
|
||
return ( | ||
isCommandExecuting(command) && | ||
command.body.movieIds.indexOf(movieId) > -1 | ||
); | ||
}); | ||
|
||
return { | ||
movieMonitored: movie.monitored, | ||
isSearching | ||
}; | ||
} | ||
); | ||
} | ||
|
||
function createMapDispatchToProps(dispatch, props) { | ||
return { | ||
onSearchPress(name, path) { | ||
dispatch(executeCommand({ | ||
name: commandNames.MOVIE_SEARCH, | ||
movieIds: [props.movieId] | ||
})); | ||
} | ||
}; | ||
} | ||
|
||
export default connect(createMapStateToProps, createMapDispatchToProps)(MovieSearchCell); |
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,4 @@ | ||
.center { | ||
display: flex; | ||
justify-content: center; | ||
} |
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,7 @@ | ||
// This file is automatically generated. | ||
// Please do not change this file! | ||
interface CssExports { | ||
'center': string; | ||
} | ||
export const cssExports: CssExports; | ||
export default cssExports; |
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,115 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import QueueDetails from 'Activity/Queue/QueueDetails'; | ||
import Icon from 'Components/Icon'; | ||
import ProgressBar from 'Components/ProgressBar'; | ||
import { icons, kinds, sizes } from 'Helpers/Props'; | ||
import translate from 'Utilities/String/translate'; | ||
import MovieQuality from './MovieQuality'; | ||
import styles from './MovieStatus.css'; | ||
|
||
function MovieStatus(props) { | ||
const { | ||
isAvailable, | ||
monitored, | ||
grabbed, | ||
queueItem, | ||
movieFile | ||
} = props; | ||
|
||
const hasMovieFile = !!movieFile; | ||
const isQueued = !!queueItem; | ||
|
||
if (isQueued) { | ||
const { | ||
sizeleft, | ||
size | ||
} = queueItem; | ||
|
||
const progress = size ? (100 - sizeleft / size * 100) : 0; | ||
|
||
return ( | ||
<div className={styles.center}> | ||
<QueueDetails | ||
{...queueItem} | ||
progressBar={ | ||
<ProgressBar | ||
progress={progress} | ||
kind={kinds.PURPLE} | ||
size={sizes.MEDIUM} | ||
/> | ||
} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
if (grabbed) { | ||
return ( | ||
<div className={styles.center}> | ||
<Icon | ||
name={icons.DOWNLOADING} | ||
title={translate('MovieIsDownloading')} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
if (hasMovieFile) { | ||
const quality = movieFile.quality; | ||
const isCutoffNotMet = movieFile.qualityCutoffNotMet; | ||
|
||
return ( | ||
<div className={styles.center}> | ||
<MovieQuality | ||
quality={quality} | ||
size={movieFile.size} | ||
isCutoffNotMet={isCutoffNotMet} | ||
title={translate('MovieDownloaded')} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
if (!monitored) { | ||
return ( | ||
<div className={styles.center}> | ||
<Icon | ||
name={icons.UNMONITORED} | ||
kind={kinds.DISABLED} | ||
title={translate('MovieIsNotMonitored')} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
if (isAvailable) { | ||
return ( | ||
<div className={styles.center}> | ||
<Icon | ||
name={icons.MISSING} | ||
title={translate('MovieMissingFromDisk')} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div className={styles.center}> | ||
<Icon | ||
name={icons.NOT_AIRED} | ||
title={translate('MovieIsNotAvailable')} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
MovieStatus.propTypes = { | ||
isAvailable: PropTypes.bool.isRequired, | ||
monitored: PropTypes.bool.isRequired, | ||
grabbed: PropTypes.bool, | ||
queueItem: PropTypes.object, | ||
movieFile: PropTypes.object | ||
}; | ||
|
||
export default MovieStatus; |
Oops, something went wrong.