Skip to content

Commit

Permalink
New: Plugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
ta264 authored and mynameisbogdan committed Nov 5, 2023
1 parent 7e6f3c1 commit ee9c720
Show file tree
Hide file tree
Showing 169 changed files with 3,255 additions and 760 deletions.
2 changes: 1 addition & 1 deletion frontend/src/Activity/Blocklist/BlocklistDetailsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BlocklistDetailsModal extends Component {

<DescriptionListItem
title={translate('Protocol')}
data={protocol}
data={protocol.replace('DownloadProtocol', '')}
/>

{
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/Activity/Queue/ProtocolLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import Label from 'Components/Label';
import styles from './ProtocolLabel.css';

function ProtocolLabel({ protocol }) {
const protocolName = protocol === 'usenet' ? 'nzb' : protocol;
const strippedName = protocol.replace('DownloadProtocol', '').toLowerCase();
const protocolName = strippedName === 'usenet' ? 'nzb' : strippedName;

return (
<Label className={styles[protocol]}>
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/App/AppRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import UISettingsConnector from 'Settings/UI/UISettingsConnector';
import BackupsConnector from 'System/Backup/BackupsConnector';
import LogsTableConnector from 'System/Events/LogsTableConnector';
import Logs from 'System/Logs/Logs';
import PluginsConnector from 'System/Plugins/PluginsConnector';
import Status from 'System/Status/Status';
import Tasks from 'System/Tasks/Tasks';
import UpdatesConnector from 'System/Updates/UpdatesConnector';
Expand Down Expand Up @@ -251,6 +252,11 @@ function AppRoutes(props) {
component={UpdatesConnector}
/>

<Route
path="/system/plugins"
component={PluginsConnector}
/>

<Route
path="/system/events"
component={LogsTableConnector}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/Commands/commandNames.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const DELETE_LOG_FILES = 'DeleteLogFiles';
export const DELETE_UPDATE_LOG_FILES = 'DeleteUpdateLogFiles';
export const DOWNLOADED_ALBUMS_SCAN = 'DownloadedAlbumsScan';
export const ALBUM_SEARCH = 'AlbumSearch';
export const INSTALL_PLUGIN = 'InstallPlugin';
export const INTERACTIVE_IMPORT = 'ManualImport';
export const MISSING_ALBUM_SEARCH = 'MissingAlbumSearch';
export const MOVE_ARTIST = 'MoveArtist';
Expand All @@ -22,3 +23,4 @@ export const RESET_QUALITY_DEFINITIONS = 'ResetQualityDefinitions';
export const RSS_SYNC = 'RssSync';
export const SEASON_SEARCH = 'AlbumSearch';
export const ARTIST_SEARCH = 'ArtistSearch';
export const UNINSTALL_PLUGIN = 'UninstallPlugin';
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ class FilterBuilderModalContent extends Component {
};
}

componentDidMount() {
if (!this.props.isPopulated) {
this.props.dispatchFetchDownloadClients();
this.props.dispatchFetchIndexers();
}
}

componentDidUpdate(prevProps) {
const {
id,
Expand Down Expand Up @@ -219,9 +226,12 @@ FilterBuilderModalContent.propTypes = {
customFilters: PropTypes.arrayOf(PropTypes.object).isRequired,
isSaving: PropTypes.bool.isRequired,
saveError: PropTypes.object,
isPopulated: PropTypes.bool.isRequired,
dispatchDeleteCustomFilter: PropTypes.func.isRequired,
onSaveCustomFilterPress: PropTypes.func.isRequired,
dispatchSetFilter: PropTypes.func.isRequired,
dispatchFetchDownloadClients: PropTypes.func.isRequired,
dispatchFetchIndexers: PropTypes.func.isRequired,
onCancelPress: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { deleteCustomFilter, saveCustomFilter } from 'Store/Actions/customFilterActions';
import { fetchDownloadClients, fetchIndexers } from 'Store/Actions/settingsActions';
import FilterBuilderModalContent from './FilterBuilderModalContent';

function createMapStateToProps() {
Expand All @@ -9,7 +10,11 @@ function createMapStateToProps() {
(state, { id }) => id,
(state) => state.customFilters.isSaving,
(state) => state.customFilters.saveError,
(customFilters, id, isSaving, saveError) => {
(state) => state.settings.downloadClients.isPopulated,
(state) => state.settings.indexers.isPopulated,
(customFilters, id, isSaving, saveError, downloadClientsPopulated, indexersPopulated) => {
const isPopulated = downloadClientsPopulated && indexersPopulated;

if (id) {
const customFilter = customFilters.find((c) => c.id === id);

Expand All @@ -19,7 +24,8 @@ function createMapStateToProps() {
filters: customFilter.filters,
customFilters,
isSaving,
saveError
saveError,
isPopulated
};
}

Expand All @@ -28,15 +34,18 @@ function createMapStateToProps() {
filters: [],
customFilters,
isSaving,
saveError
saveError,
isPopulated
};
}
);
}

const mapDispatchToProps = {
onSaveCustomFilterPress: saveCustomFilter,
dispatchDeleteCustomFilter: deleteCustomFilter
dispatchDeleteCustomFilter: deleteCustomFilter,
dispatchFetchDownloadClients: fetchDownloadClients,
dispatchFetchIndexers: fetchIndexers
};

export default connect(createMapStateToProps, mapDispatchToProps)(FilterBuilderModalContent);
2 changes: 1 addition & 1 deletion frontend/src/Components/Filter/Builder/FilterBuilderRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import FilterBuilderRowValueConnector from './FilterBuilderRowValueConnector';
import HistoryEventTypeFilterBuilderRowValue from './HistoryEventTypeFilterBuilderRowValue';
import IndexerFilterBuilderRowValueConnector from './IndexerFilterBuilderRowValueConnector';
import MetadataProfileFilterBuilderRowValueConnector from './MetadataProfileFilterBuilderRowValueConnector';
import ProtocolFilterBuilderRowValue from './ProtocolFilterBuilderRowValue';
import ProtocolFilterBuilderRowValue from './ProtocolFilterBuilderRowValueConnector';
import QualityFilterBuilderRowValueConnector from './QualityFilterBuilderRowValueConnector';
import QualityProfileFilterBuilderRowValueConnector from './QualityProfileFilterBuilderRowValueConnector';
import TagFilterBuilderRowValueConnector from './TagFilterBuilderRowValueConnector';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import FilterBuilderRowValue from './FilterBuilderRowValue';

function createMapStateToProps() {
return createSelector(
(state) => state.settings.downloadClients,
(state) => state.settings.indexers,
(downloadClients, indexers) => {
const protocols = Array.from(new Set([
...downloadClients.items.map((i) => i.protocol),
...indexers.items.map((i) => i.protocol)
]));

console.log(protocols);
const tagList = protocols.map((protocol) => {
return {
id: protocol,
name: protocol.replace('DownloadProtocol', '')
};
});

return {
tagList
};
}
);
}

export default connect(createMapStateToProps)(FilterBuilderRowValue);
4 changes: 4 additions & 0 deletions frontend/src/Components/Page/Sidebar/PageSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ const links = [
title: () => translate('Updates'),
to: '/system/updates'
},
{
title: () => translate('Plugins'),
to: '/system/plugins'
},
{
title: () => translate('Events'),
to: '/system/events'
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/Components/SignalRConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { setAppValue, setVersion } from 'Store/Actions/appActions';
import { clearMessages, setAppValue, setVersion } from 'Store/Actions/appActions';
import { fetchArtist } from 'Store/Actions/artistActions';
import { removeItem, update, updateItem } from 'Store/Actions/baseActions';
import { fetchCommands, finishCommand, updateCommand } from 'Store/Actions/commandActions';
Expand Down Expand Up @@ -40,6 +40,7 @@ const mapDispatchToProps = {
dispatchFetchCommands: fetchCommands,
dispatchUpdateCommand: updateCommand,
dispatchFinishCommand: finishCommand,
dispatchClearMessages: clearMessages,
dispatchSetAppValue: setAppValue,
dispatchSetVersion: setVersion,
dispatchUpdate: update,
Expand Down Expand Up @@ -338,6 +339,7 @@ class SignalRConnector extends Component {
const {
dispatchFetchCommands,
dispatchFetchArtist,
dispatchClearMessages,
dispatchSetAppValue
} = this.props;

Expand All @@ -351,7 +353,9 @@ class SignalRConnector extends Component {
// Repopulate the page (if a repopulator is set) to ensure things
// are in sync after reconnecting.
dispatchFetchArtist();
dispatchClearMessages();
dispatchFetchCommands();

repopulatePage();
};

Expand Down Expand Up @@ -380,6 +384,7 @@ SignalRConnector.propTypes = {
dispatchFetchCommands: PropTypes.func.isRequired,
dispatchUpdateCommand: PropTypes.func.isRequired,
dispatchFinishCommand: PropTypes.func.isRequired,
dispatchClearMessages: PropTypes.func.isRequired,
dispatchSetAppValue: PropTypes.func.isRequired,
dispatchSetVersion: PropTypes.func.isRequired,
dispatchUpdate: PropTypes.func.isRequired,
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/Components/TagList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { kinds } from 'Helpers/Props';
import Label from './Label';
import styles from './TagList.css';

function TagList({ tags, tagList }) {
function TagList({ className, tags, tagList }) {
const sortedTags = tags
.map((tagId) => tagList.find((tag) => tag.id === tagId))
.filter((tag) => !!tag)
.sort((a, b) => a.label.localeCompare(b.label));

return (
<div className={styles.tags}>
<div className={className}>
{
sortedTags.map((tag) => {
return (
Expand All @@ -29,8 +29,13 @@ function TagList({ tags, tagList }) {
}

TagList.propTypes = {
className: PropTypes.string.isRequired,
tags: PropTypes.arrayOf(PropTypes.number).isRequired,
tagList: PropTypes.arrayOf(PropTypes.object).isRequired
};

TagList.defaultProps = {
className: styles.tags
};

export default TagList;
1 change: 1 addition & 0 deletions frontend/src/Helpers/dragTypes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const QUALITY_PROFILE_ITEM = 'qualityProfileItem';
export const DELAY_PROFILE = 'delayProfile';
export const DOWNLOAD_PROTOCOL_ITEM = 'downloadProtocolItem';
export const TABLE_COLUMN = 'tableColumn';
2 changes: 1 addition & 1 deletion frontend/src/InteractiveSearch/InteractiveSearchRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class InteractiveSearchRow extends Component {

<TableRowCell className={styles.peers}>
{
protocol === 'torrent' &&
protocol === 'TorrentDownloadProtocol' &&
<Peers
seeders={seeders}
leechers={leechers}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ import translate from 'Utilities/String/translate';
import AddDownloadClientItem from './AddDownloadClientItem';
import styles from './AddDownloadClientModalContent.css';

function mapDownloadClients(clients, onDownloadClientSelect) {
return clients.map((downloadClient) => {
return (
<AddDownloadClientItem
key={downloadClient.implementation}
implementation={downloadClient.implementation}
{...downloadClient}
onDownloadClientSelect={onDownloadClientSelect}
/>
);
});
}

class AddDownloadClientModalContent extends Component {

//
Expand All @@ -25,6 +38,7 @@ class AddDownloadClientModalContent extends Component {
schemaError,
usenetDownloadClients,
torrentDownloadClients,
otherDownloadClients,
onDownloadClientSelect,
onModalClose
} = this.props;
Expand Down Expand Up @@ -64,36 +78,30 @@ class AddDownloadClientModalContent extends Component {
<FieldSet legend={translate('Usenet')}>
<div className={styles.downloadClients}>
{
usenetDownloadClients.map((downloadClient) => {
return (
<AddDownloadClientItem
key={downloadClient.implementation}
implementation={downloadClient.implementation}
{...downloadClient}
onDownloadClientSelect={onDownloadClientSelect}
/>
);
})
mapDownloadClients(usenetDownloadClients, onDownloadClientSelect)
}
</div>
</FieldSet>

<FieldSet legend={translate('Torrents')}>
<div className={styles.downloadClients}>
{
torrentDownloadClients.map((downloadClient) => {
return (
<AddDownloadClientItem
key={downloadClient.implementation}
implementation={downloadClient.implementation}
{...downloadClient}
onDownloadClientSelect={onDownloadClientSelect}
/>
);
})
mapDownloadClients(torrentDownloadClients, onDownloadClientSelect)
}
</div>
</FieldSet>

{
otherDownloadClients.length ?
<FieldSet legend="Other">
<div className={styles.downloadClients}>
{
mapDownloadClients(otherDownloadClients, onDownloadClientSelect)
}
</div>
</FieldSet> :
null
}
</div>
}
</ModalBody>
Expand All @@ -115,6 +123,7 @@ AddDownloadClientModalContent.propTypes = {
schemaError: PropTypes.object,
usenetDownloadClients: PropTypes.arrayOf(PropTypes.object).isRequired,
torrentDownloadClients: PropTypes.arrayOf(PropTypes.object).isRequired,
otherDownloadClients: PropTypes.arrayOf(PropTypes.object).isRequired,
onDownloadClientSelect: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ function createMapStateToProps() {
schema
} = downloadClients;

const usenetDownloadClients = _.filter(schema, { protocol: 'usenet' });
const torrentDownloadClients = _.filter(schema, { protocol: 'torrent' });
const usenetDownloadClients = _.filter(schema, { protocol: 'UsenetDownloadProtocol' });
const torrentDownloadClients = _.filter(schema, { protocol: 'TorrentDownloadProtocol' });
const otherDownloadClients = _.filter(schema, (x) => x.protocol !== 'UsenetDownloadProtocol' &&
x.protocol !== 'TorrentDownloadProtocol');

return {
isSchemaFetching,
isSchemaPopulated,
schemaError,
usenetDownloadClients,
torrentDownloadClients
torrentDownloadClients,
otherDownloadClients
};
}
);
Expand Down
Loading

0 comments on commit ee9c720

Please sign in to comment.