mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
New: Edit RlsGroup, Flags, and Edition for Movie Files (#5183)
* New: Edit RlsGroup and Edition for Movie Files * fixup! remove console log * fixup! translation
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import EnhancedSelectInput from './EnhancedSelectInput';
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
(state, { indexerFlags }) => indexerFlags,
|
||||
(state) => state.settings.indexerFlags,
|
||||
(selectedFlags, indexerFlags) => {
|
||||
const value = [];
|
||||
|
||||
indexerFlags.items.forEach((item) => {
|
||||
// eslint-disable-next-line no-bitwise
|
||||
if ((selectedFlags & item.id) === item.id) {
|
||||
value.push(item.id);
|
||||
}
|
||||
});
|
||||
|
||||
const values = indexerFlags.items.map(({ id, name }) => {
|
||||
return {
|
||||
key: id,
|
||||
value: name
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
value,
|
||||
values
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
class IndexerFlagsSelectInputConnector extends Component {
|
||||
|
||||
onChange = ({ name, value }) => {
|
||||
let indexerFlags = 0;
|
||||
|
||||
value.forEach((flagId) => {
|
||||
indexerFlags += flagId;
|
||||
});
|
||||
|
||||
this.props.onChange({ name, value: indexerFlags });
|
||||
}
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
<EnhancedSelectInput
|
||||
{...this.props}
|
||||
onChange={this.onChange}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
IndexerFlagsSelectInputConnector.propTypes = {
|
||||
name: PropTypes.string.isRequired,
|
||||
indexerFlags: PropTypes.number.isRequired,
|
||||
value: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||||
values: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
onChange: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps)(IndexerFlagsSelectInputConnector);
|
Reference in New Issue
Block a user