diff --git a/.devcontainer/Lidarr.code-workspace b/.devcontainer/Lidarr.code-workspace new file mode 100644 index 000000000..a46158e44 --- /dev/null +++ b/.devcontainer/Lidarr.code-workspace @@ -0,0 +1,13 @@ +// This file is used to open the backend and frontend in the same workspace, which is necessary as +// the frontend has vscode settings that are distinct from the backend +{ + "folders": [ + { + "path": ".." + }, + { + "path": "../frontend" + } + ], + "settings": {} +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..d0fa03d5f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,19 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/dotnet +{ + "name": "Lidarr", + "image": "mcr.microsoft.com/devcontainers/dotnet:1-6.0", + "features": { + "ghcr.io/devcontainers/features/node:1": { + "nodeGypDependencies": true, + "version": "20", + "nvmVersion": "latest" + } + }, + "forwardPorts": [8686], + "customizations": { + "vscode": { + "extensions": ["esbenp.prettier-vscode"] + } + } +} diff --git a/.editorconfig b/.editorconfig index 5e19cc2d6..57d971bc4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,14 +2,275 @@ # editorconfig.org root = true -[*.{cs}] +# NOTE: Requires **VS2019 16.3** or later + +# Stylecop.ruleset +# Description: Rules for Lidarr + +# Code files +[*.cs] charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true indent_style = space indent_size = 4 -[*.{js,html,js,hbs,less,css}] +# Sort using and Import directives with System.* appearing first +dotnet_sort_system_directives_first = true + +# Avoid "this." and "Me." if not necessary +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_property = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_event = false:warning + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = true +csharp_indent_switch_labels = true +csharp_indent_labels = flush_left + +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion +dotnet_naming_style.instance_field_style.capitalization = camel_case +dotnet_naming_style.instance_field_style.required_prefix = _ + +# Prefer "var" everywhere +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true +csharp_style_var_elsewhere = true +# Prefer "out" variables to be declared inline +csharp_style_inlined_variable_declaration = true + +# Using directive is unnecessary. +dotnet_diagnostic.IDE0005.severity = error +# Use var instead of explicit type +dotnet_diagnostic.IDE0007.severity = error +# Inline variable declaration +dotnet_diagnostic.IDE0018.severity = error + +# Stylecop Rules +dotnet_diagnostic.SA0001.severity = none +dotnet_diagnostic.SA1025.severity = none +dotnet_diagnostic.SA1101.severity = none +dotnet_diagnostic.SA1116.severity = none +dotnet_diagnostic.SA1118.severity = none +dotnet_diagnostic.SA1122.severity = none +dotnet_diagnostic.SA1201.severity = suggestion +dotnet_diagnostic.SA1202.severity = suggestion +dotnet_diagnostic.SA1204.severity = suggestion +dotnet_diagnostic.SA1300.severity = none +dotnet_diagnostic.SA1303.severity = none +dotnet_diagnostic.SA1304.severity = none +dotnet_diagnostic.SA1306.severity = none +dotnet_diagnostic.SA1309.severity = none +dotnet_diagnostic.SA1310.severity = none +dotnet_diagnostic.SA1401.severity = none +dotnet_diagnostic.SA1402.severity = none +dotnet_diagnostic.SA1404.severity = suggestion +dotnet_diagnostic.SA1405.severity = suggestion +dotnet_diagnostic.SA1406.severity = suggestion +dotnet_diagnostic.SA1410.severity = suggestion +dotnet_diagnostic.SA1411.severity = suggestion +dotnet_diagnostic.SA1413.severity = none +dotnet_diagnostic.SA1512.severity = none +dotnet_diagnostic.SA1516.severity = none +dotnet_diagnostic.SA1600.severity = none +dotnet_diagnostic.SA1601.severity = none +dotnet_diagnostic.SA1602.severity = none +dotnet_diagnostic.SA1604.severity = none +dotnet_diagnostic.SA1605.severity = none +dotnet_diagnostic.SA1606.severity = none +dotnet_diagnostic.SA1607.severity = none +dotnet_diagnostic.SA1608.severity = none +dotnet_diagnostic.SA1610.severity = none +dotnet_diagnostic.SA1611.severity = none +dotnet_diagnostic.SA1612.severity = none +dotnet_diagnostic.SA1613.severity = none +dotnet_diagnostic.SA1614.severity = none +dotnet_diagnostic.SA1615.severity = none +dotnet_diagnostic.SA1616.severity = none +dotnet_diagnostic.SA1617.severity = none +dotnet_diagnostic.SA1618.severity = none +dotnet_diagnostic.SA1619.severity = none +dotnet_diagnostic.SA1620.severity = none +dotnet_diagnostic.SA1621.severity = none +dotnet_diagnostic.SA1622.severity = none +dotnet_diagnostic.SA1623.severity = none +dotnet_diagnostic.SA1624.severity = none +dotnet_diagnostic.SA1625.severity = none +dotnet_diagnostic.SA1626.severity = none +dotnet_diagnostic.SA1627.severity = none +dotnet_diagnostic.SA1629.severity = none +dotnet_diagnostic.SA1633.severity = none +dotnet_diagnostic.SA1634.severity = none +dotnet_diagnostic.SA1635.severity = none +dotnet_diagnostic.SA1636.severity = none +dotnet_diagnostic.SA1637.severity = none +dotnet_diagnostic.SA1638.severity = none +dotnet_diagnostic.SA1640.severity = none +dotnet_diagnostic.SA1641.severity = none +dotnet_diagnostic.SA1642.severity = none +dotnet_diagnostic.SA1643.severity = none +dotnet_diagnostic.SA1648.severity = none +dotnet_diagnostic.SA1649.severity = none +dotnet_diagnostic.SA1651.severity = none +dotnet_diagnostic.SX1309.severity = warning + +# Microsoft Analyzers that fail and need to be sorted thru +dotnet_diagnostic.ASP0000.severity = suggestion +dotnet_diagnostic.CA1000.severity = suggestion +dotnet_diagnostic.CA1001.severity = suggestion +dotnet_diagnostic.CA1002.severity = suggestion +dotnet_diagnostic.CA1003.severity = suggestion +dotnet_diagnostic.CA1008.severity = suggestion +dotnet_diagnostic.CA1010.severity = suggestion +dotnet_diagnostic.CA1012.severity = suggestion +dotnet_diagnostic.CA1014.severity = suggestion +dotnet_diagnostic.CA1016.severity = suggestion +dotnet_diagnostic.CA1017.severity = suggestion +dotnet_diagnostic.CA1018.severity = suggestion +dotnet_diagnostic.CA1019.severity = suggestion +dotnet_diagnostic.CA1021.severity = suggestion +dotnet_diagnostic.CA1024.severity = suggestion +dotnet_diagnostic.CA1027.severity = suggestion +dotnet_diagnostic.CA1028.severity = suggestion +dotnet_diagnostic.CA1030.severity = suggestion +dotnet_diagnostic.CA1031.severity = suggestion +dotnet_diagnostic.CA1032.severity = suggestion +dotnet_diagnostic.CA1033.severity = suggestion +dotnet_diagnostic.CA1034.severity = suggestion +dotnet_diagnostic.CA1036.severity = suggestion +dotnet_diagnostic.CA1040.severity = suggestion +dotnet_diagnostic.CA1041.severity = suggestion +dotnet_diagnostic.CA1043.severity = suggestion +dotnet_diagnostic.CA1044.severity = suggestion +dotnet_diagnostic.CA1050.severity = suggestion +dotnet_diagnostic.CA1051.severity = suggestion +dotnet_diagnostic.CA1052.severity = suggestion +dotnet_diagnostic.CA1054.severity = suggestion +dotnet_diagnostic.CA1055.severity = suggestion +dotnet_diagnostic.CA1056.severity = suggestion +dotnet_diagnostic.CA1058.severity = suggestion +dotnet_diagnostic.CA1060.severity = suggestion +dotnet_diagnostic.CA1061.severity = suggestion +dotnet_diagnostic.CA1062.severity = suggestion +dotnet_diagnostic.CA1063.severity = suggestion +dotnet_diagnostic.CA1064.severity = suggestion +dotnet_diagnostic.CA1065.severity = suggestion +dotnet_diagnostic.CA1066.severity = suggestion +dotnet_diagnostic.CA1067.severity = suggestion +dotnet_diagnostic.CA1068.severity = suggestion +dotnet_diagnostic.CA1069.severity = suggestion +dotnet_diagnostic.CA1200.severity = suggestion +dotnet_diagnostic.CA1303.severity = suggestion +dotnet_diagnostic.CA1304.severity = suggestion +dotnet_diagnostic.CA1305.severity = suggestion +dotnet_diagnostic.CA1307.severity = suggestion +dotnet_diagnostic.CA1308.severity = suggestion +dotnet_diagnostic.CA1309.severity = suggestion +dotnet_diagnostic.CA1310.severity = suggestion +dotnet_diagnostic.CA1401.severity = suggestion +dotnet_diagnostic.CA1416.severity = suggestion +dotnet_diagnostic.CA1419.severity = suggestion +dotnet_diagnostic.CA1507.severity = suggestion +dotnet_diagnostic.CA1508.severity = suggestion +dotnet_diagnostic.CA1707.severity = suggestion +dotnet_diagnostic.CA1708.severity = suggestion +dotnet_diagnostic.CA1710.severity = suggestion +dotnet_diagnostic.CA1711.severity = suggestion +dotnet_diagnostic.CA1712.severity = suggestion +dotnet_diagnostic.CA1714.severity = suggestion +dotnet_diagnostic.CA1715.severity = suggestion +dotnet_diagnostic.CA1716.severity = suggestion +dotnet_diagnostic.CA1717.severity = suggestion +dotnet_diagnostic.CA1720.severity = suggestion +dotnet_diagnostic.CA1721.severity = suggestion +dotnet_diagnostic.CA1724.severity = suggestion +dotnet_diagnostic.CA1725.severity = suggestion +dotnet_diagnostic.CA1806.severity = suggestion +dotnet_diagnostic.CA1810.severity = suggestion +dotnet_diagnostic.CA1812.severity = suggestion +dotnet_diagnostic.CA1813.severity = suggestion +dotnet_diagnostic.CA1814.severity = suggestion +dotnet_diagnostic.CA1815.severity = suggestion +dotnet_diagnostic.CA1816.severity = suggestion +dotnet_diagnostic.CA1819.severity = suggestion +dotnet_diagnostic.CA1822.severity = suggestion +dotnet_diagnostic.CA1823.severity = suggestion +dotnet_diagnostic.CA1824.severity = suggestion +dotnet_diagnostic.CA1848.severity = suggestion +dotnet_diagnostic.CA2000.severity = suggestion +dotnet_diagnostic.CA2002.severity = suggestion +dotnet_diagnostic.CA2007.severity = suggestion +dotnet_diagnostic.CA2008.severity = suggestion +dotnet_diagnostic.CA2012.severity = suggestion +dotnet_diagnostic.CA2013.severity = suggestion +dotnet_diagnostic.CA2100.severity = suggestion +dotnet_diagnostic.CA2101.severity = suggestion +dotnet_diagnostic.CA2119.severity = suggestion +dotnet_diagnostic.CA2153.severity = suggestion +dotnet_diagnostic.CA2200.severity = suggestion +dotnet_diagnostic.CA2201.severity = suggestion +dotnet_diagnostic.CA2207.severity = suggestion +dotnet_diagnostic.CA2208.severity = suggestion +dotnet_diagnostic.CA2211.severity = suggestion +dotnet_diagnostic.CA2213.severity = suggestion +dotnet_diagnostic.CA2214.severity = suggestion +dotnet_diagnostic.CA2215.severity = suggestion +dotnet_diagnostic.CA2216.severity = suggestion +dotnet_diagnostic.CA2219.severity = suggestion +dotnet_diagnostic.CA2225.severity = suggestion +dotnet_diagnostic.CA2226.severity = suggestion +dotnet_diagnostic.CA2227.severity = suggestion +dotnet_diagnostic.CA2229.severity = suggestion +dotnet_diagnostic.CA2231.severity = suggestion +dotnet_diagnostic.CA2234.severity = suggestion +dotnet_diagnostic.CA2235.severity = suggestion +dotnet_diagnostic.CA2237.severity = suggestion +dotnet_diagnostic.CA2241.severity = suggestion +dotnet_diagnostic.CA2242.severity = suggestion +dotnet_diagnostic.CA2243.severity = suggestion +dotnet_diagnostic.CA2244.severity = suggestion +dotnet_diagnostic.CA2245.severity = suggestion +dotnet_diagnostic.CA2246.severity = suggestion +dotnet_diagnostic.CA2249.severity = suggestion +dotnet_diagnostic.CA2251.severity = suggestion +dotnet_diagnostic.CA2254.severity = suggestion +dotnet_diagnostic.CA3061.severity = suggestion +dotnet_diagnostic.CA3075.severity = suggestion +dotnet_diagnostic.CA3076.severity = suggestion +dotnet_diagnostic.CA3077.severity = suggestion +dotnet_diagnostic.CA3147.severity = suggestion +dotnet_diagnostic.CA5350.severity = suggestion +dotnet_diagnostic.CA5351.severity = suggestion +dotnet_diagnostic.CA5359.severity = suggestion +dotnet_diagnostic.CA5360.severity = suggestion +dotnet_diagnostic.CA5363.severity = suggestion +dotnet_diagnostic.CA5364.severity = suggestion +dotnet_diagnostic.CA5365.severity = suggestion +dotnet_diagnostic.CA5366.severity = suggestion +dotnet_diagnostic.CA5368.severity = suggestion +dotnet_diagnostic.CA5369.severity = suggestion +dotnet_diagnostic.CA5370.severity = suggestion +dotnet_diagnostic.CA5371.severity = suggestion +dotnet_diagnostic.CA5372.severity = suggestion +dotnet_diagnostic.CA5373.severity = suggestion +dotnet_diagnostic.CA5374.severity = suggestion +dotnet_diagnostic.CA5379.severity = suggestion +dotnet_diagnostic.CA5384.severity = suggestion +dotnet_diagnostic.CA5385.severity = suggestion +dotnet_diagnostic.CA5392.severity = suggestion +dotnet_diagnostic.CA5394.severity = suggestion +dotnet_diagnostic.CA5397.severity = suggestion + +dotnet_diagnostic.SYSLIB0006.severity = none + +[*.{js,html,hbs,less,css,ts,tsx}] charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true diff --git a/.esprintrc b/.esprintrc deleted file mode 100644 index 9330e00d1..000000000 --- a/.esprintrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "paths": [ - "frontend/src/**/*.js" - ], - "ignored": [ - "**/node_modules/**/*" - ], - "port": 5004 -} diff --git a/.gitattributes b/.gitattributes index e9852ad00..d98f8fb96 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,9 @@ # Auto detect text files and perform LF normalization -*text eol=lf +* text=auto # Explicitly set bash scripts to have unix endings *.sh text eol=lf +distribution/osx/Lidarr text eol=lf # Custom for Visual Studio *.cs diff=csharp diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 8988a141d..49c3e2d71 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: lidarr # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: lidarr ko_fi: # Replace with a single Ko-fi username diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index 87d054fc8..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,41 +0,0 @@ - - - -## Support / Questions - -Please use https://discord.gg/8Y7rDc9 for support. Support requests or questions will be redirected to discord and the issue will be closed. - - - -## Bug Report - -### System Information/Logs - -**Lidarr Version:** - -**Operating System:** - -**.net Framework (Windows) or mono (macOS/Linux) Version:** - -**Link to Log Files (debug or trace):** - -**Browser (for UI bugs):** - -### Additional Information - - - -## Feature Request - -### Description of request and what problem are you looking to solve? - -### Other Information diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 985b66efd..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Logs** -Link to debug logs. - -**System info (please complete the following information):** - - Lidarr Version: [e.g. 0.3.0.430] - - Operating System [e.g. iOS] - - .net Framework (Windows) or mono (macOS/Linux) Version: [e.g. 4.5 or 5.12] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 000000000..491815370 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,83 @@ +name: Bug Report +description: 'Report a new bug, if you are not 100% certain this is a bug please go to our Discord first' +labels: ['Type: Bug', 'Status: Needs Triage'] +body: +- type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search to see if an open or closed issue already exists for the bug you encountered. If a bug exists and is closed note that it may only be fixed in an unstable branch. + options: + - label: I have searched the existing open and closed issues + required: true +- type: textarea + attributes: + label: Current Behavior + description: A concise description of what you're experiencing. + validations: + required: true +- type: textarea + attributes: + label: Expected Behavior + description: A concise description of what you expected to happen. + validations: + required: true +- type: textarea + attributes: + label: Steps To Reproduce + description: Steps to reproduce the behavior. + placeholder: | + 1. In this environment... + 2. With this config... + 3. Run '...' + 4. See error... + validations: + required: false +- type: textarea + attributes: + label: Environment + description: | + examples: + - **OS**: Ubuntu 20.04 + - **Lidarr**: Lidarr 0.8.1.2135 + - **Docker Install**: Yes + - **Using Reverse Proxy**: No + - **Browser**: Firefox 90 (If UI related) + - **Database**: Sqlite 3.36.0 + value: | + - OS: + - Lidarr: + - Docker Install: + - Using Reverse Proxy: + - Browser: + - Database: + render: markdown + validations: + required: true +- type: dropdown + attributes: + label: What branch are you running? + options: + - Master + - Develop + - Nightly + - Plugins (experimental) + - Other (This issue will be closed) + validations: + required: true +- type: textarea + attributes: + label: Trace Logs? + description: | + Trace Logs (https://wiki.servarr.com/lidarr/troubleshooting#logging-and-log-files) + ***Generally speaking, all bug reports must have trace logs provided.*** + Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. + Additionally, any additional info? Screenshots? References? Anything that will give us more context about the issue you are encountering! + validations: + required: true +- type: checkboxes + attributes: + label: Trace Logs have been provided as applicable. Reports may be closed if the required logs are not provided. + description: Trace logs are generally required for all bug reports and contain `trace`. Info logs are invalid for bug reports and do not contain `debug` nor `trace` + options: + - label: I have read and followed the steps in the wiki link above and provided the required trace logs - the logs contain `trace` - that are relevant and show this issue. + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..880a682f4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Support via Discord + url: https://lidarr.audio/discord + about: Chat with users and devs on support and setup related topics. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md deleted file mode 100644 index 99bb9a009..000000000 --- a/.github/ISSUE_TEMPLATE/custom.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -name: Custom issue template -about: Describe this issue template's purpose here. - ---- - - diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 066b2d920..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 000000000..ef142b0ad --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,38 @@ +name: Feature Request +description: 'Suggest an idea for Lidarr' +labels: ['Type: Feature Request', 'Status: Needs Triage'] +body: +- type: checkboxes + attributes: + label: Is there an existing issue for this? + description: Please search to see if an open or closed issue already exists for the feature you are requesting. If a request exists and is closed note that it may only be fixed in an unstable branch. + options: + - label: I have searched the existing open and closed issues + required: true +- type: textarea + attributes: + label: Is your feature request related to a problem? Please describe + description: A clear and concise description of what the problem is. + validations: + required: true +- type: textarea + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. + validations: + required: true +- type: textarea + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + validations: + required: true +- type: textarea + attributes: + label: Anything else? + description: | + Links? References? Mockups? Anything that will give us more context about the feature you are encountering! + + Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. + validations: + required: true diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e0d682009..2fcae05cc 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,14 +1,16 @@ #### Database Migration -YES | NO +YES - XXXX | NO #### Description A few sentences describing the overall goals of the pull request's commits. +#### Screenshot (if UI related) + #### Todos - [ ] Tests -- [ ] Documentation - +- [ ] Translation Keys (./src/NzbDrone.Core/Localization/Core/en.json) +- [ ] [Wiki Updates](https://wiki.servarr.com) #### Issues Fixed or Closed by this PR -* +* Fixes #XXXX \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..f33a02cd1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/.github/label-actions.yml b/.github/label-actions.yml new file mode 100644 index 000000000..3979401b1 --- /dev/null +++ b/.github/label-actions.yml @@ -0,0 +1,16 @@ +# Configuration for Label Actions - https://github.com/dessant/label-actions + +'Type: Support': + comment: > + :wave: @{issue-author}, we use the issue tracker exclusively + for bug reports and feature requests. However, this issue appears + to be a support request. Please hop over onto our [Discord](https://lidarr.audio/discord). + close: true + close-reason: 'not planned' + +'Status: Logs Needed': + comment: > + :wave: @{issue-author}, In order to help you further we'll need to see logs. + You'll need to enable trace logging and replicate the problem that you encountered. + Guidance on how to enable trace logging can be found in + our [troubleshooting guide](https://wiki.servarr.com/lidarr/troubleshooting#logging-and-log-files). diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 000000000..4203e4418 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,28 @@ +'Area: API': + - src/Lidarr.Api.V1/**/* + +'Area: Db-migration': + - src/NzbDrone.Core/Datastore/Migration/* + +'Area: Download Clients': + - src/NzbDrone.Core/Download/Clients/**/* + +'Area: Import Lists': + - src/NzbDrone.Core/ImportLists/**/* + +'Area: Indexer': + - src/NzbDrone.Core/Indexers/**/* + +'Area: Notifications': + - src/NzbDrone.Core/Notifications/**/* + +'Area: Organizer': + - src/NzbDrone.Core/Organizer/**/* + +'Area: Parser': + - src/NzbDrone.Core/Parser/**/* + +'Area: UI': + - frontend/**/* + - package.json + - yarn.lock diff --git a/.github/workflows/label-actions.yml b/.github/workflows/label-actions.yml new file mode 100644 index 000000000..a6246a6b3 --- /dev/null +++ b/.github/workflows/label-actions.yml @@ -0,0 +1,17 @@ +name: 'Label Actions' + +on: + issues: + types: [labeled, unlabeled] + +permissions: + contents: read + issues: write + +jobs: + action: + runs-on: ubuntu-latest + steps: + - uses: dessant/label-actions@v4 + with: + process-only: 'issues' diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 000000000..857cfb4a7 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,12 @@ +name: "Pull Request Labeler" +on: + - pull_request_target + +jobs: + triage: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v4 diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml new file mode 100644 index 000000000..1d50cb1f1 --- /dev/null +++ b/.github/workflows/lock.yml @@ -0,0 +1,21 @@ +name: 'Lock threads' + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + +jobs: + lock: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v5 + with: + github-token: ${{ github.token }} + issue-inactive-days: '90' + exclude-issue-created-before: '' + exclude-any-issue-labels: '' + add-issue-labels: '' + issue-comment: '' + issue-lock-reason: 'resolved' + process-only: '' diff --git a/.gitignore b/.gitignore index ed6772d69..a5d6bb7c8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ src/**/[Oo]bj/ *.user *.sln.docstates .vs/ +.vscode/ # Build results *_i.c @@ -84,7 +85,6 @@ TestResults [Tt]est[Rr]esult* *.Cache ClientBin -[Ss]tyle[Cc]op.* ~$* *.dbmdl Generated_Code #added for RIA/Silverlight projects @@ -121,25 +121,49 @@ _artifacts _rawPackage/ _dotTrace* _tests/ +_temp* *.Result.xml coverage*.xml coverage*.json setup/Output/ *.~is +.mono -#VS outout folders +# VS outout folders bin obj output/* +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json -#OS X metadata files +# macOS metadata files ._* .DS_Store _start _temp_*/**/* -## Merge any idea folder -*/**/.idea -*.iml +# Windows thumbnail cache files +Thumbs.db + +# AppVeyor +/tools/cake/ +/_artifacts/ + +# Cake +/tools/Addins/* +packages.config.md5sum + +# ignore node_modules symlink +node_modules +node_modules.nosync + +# API doc generation +.config/ + +# Ignore Jetbrains IntelliJ Workspace Directories +.idea/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..7a36fefe1 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "esbenp.prettier-vscode", + "ms-dotnettools.csdevkit", + "ms-vscode-remote.remote-containers" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..74b8d418b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md + "name": "Run Lidarr", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build dotnet", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/_output/net6.0/Lidarr", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "integratedTerminal", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..4b3b00b89 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,44 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build dotnet", + "command": "dotnet", + "type": "process", + "args": [ + "msbuild", + "-restore", + "${workspaceFolder}/src/Lidarr.sln", + "-p:GenerateFullPaths=true", + "-p:Configuration=Debug", + "-p:Platform=Posix", + "-consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/Lidarr.sln", + "-property:GenerateFullPaths=true", + "-consoleloggerparameters:NoSummary;ForceNoAlign" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/src/Lidarr.sln" + ], + "problemMatcher": "$msCompile" + } + ] +} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..52e67a0a4 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fa439931f..36d901f18 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,50 +1,13 @@ -# How to Contribute # +# How to Contribute We're always looking for people to help make Lidarr even better, there are a number of ways to contribute. -## Documentation ## -Setup guides, FAQ, the more information we have on the wiki the better. +This file has been moved to the wiki for the latest details please see the [contributing wiki page](https://wiki.servarr.com/lidarr/contributing). -## Development ## +## Documentation -### Tools required ### -- Visual Studio 2017 or higher (https://www.visualstudio.com/vs/). The community version is free and works (https://www.visualstudio.com/downloads/). -- HTML/Javascript editor of choice (VS Code/Sublime Text/Webstorm/Atom/etc) -- [Git](https://git-scm.com/downloads) -- [NodeJS](https://nodejs.org/en/download/) (Node 8.X.X or higher) -- [Yarn](https://yarnpkg.com/) -- .NET 4.6.2 or Mono equivalent. +Setup guides, [FAQ](https://wiki.servarr.com/lidarr/faq), the more information we have on the [wiki](https://wiki.servarr.com/lidarr) the better. -### Getting started ### +## Development -1. Fork Lidarr -2. Clone the repository into your development machine. [*info*](https://help.github.com/articles/working-with-repositories) -3. Grab the submodules `git submodule init && git submodule update` -4. Install the required Node Packages `yarn install` -5. Start gulp to monitor your dev environment for any changes that need post processing using `yarn start` command. -6. Build the project in Visual Studio, Setting startup project to `NZBDrone.Console` -7. Debug the project in Visual Studio -8. Open http://localhost:8686 - -### Contributing Code ### -- If you're adding a new, already requested feature, please comment on [Github Issues](https://github.com/lidarr/Lidarr/issues "Github Issues") so work is not duplicated (If you want to add something not already on there, please talk to us first) -- Rebase from Lidarr's develop branch, don't merge -- Make meaningful commits, or squash them -- Feel free to make a pull request before work is complete, this will let us see where its at and make comments/suggest improvements -- Reach out to us on the discord if you have any questions -- Add tests (unit/integration) -- Commit with *nix line endings for consistency (We checkout Windows and commit *nix) -- One feature/bug fix per pull request to keep things clean and easy to understand -- Use 4 spaces instead of tabs, this is the default for VS 2017 and WebStorm (to my knowledge) - -### Pull Requesting ### -- Only make pull requests to develop, never master, if you make a PR to master we'll comment on it and close it -- You're probably going to get some comments or questions from us, they will be to ensure consistency and maintainability -- We'll try to respond to pull requests as soon as possible, if its been a day or two, please reach out to us, we may have missed it -- Each PR should come from its own [feature branch](http://martinfowler.com/bliki/FeatureBranch.html) not develop in your fork, it should have a meaningful branch name (what is being added/fixed) - - new-feature (Good) - - fix-bug (Good) - - patch (Bad) - - develop (Bad) - -If you have any questions about any of this, please let us know. +See the [Wiki Page](https://wiki.servarr.com/lidarr/contributing) diff --git a/Logo/dottrace.svg b/Logo/dottrace.svg new file mode 100644 index 000000000..b879517cd --- /dev/null +++ b/Logo/dottrace.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Logo/jetbrains.svg b/Logo/jetbrains.svg new file mode 100644 index 000000000..75d4d2177 --- /dev/null +++ b/Logo/jetbrains.svg @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Logo/resharper.svg b/Logo/resharper.svg new file mode 100644 index 000000000..24c987a78 --- /dev/null +++ b/Logo/resharper.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Logo/rider.svg b/Logo/rider.svg new file mode 100644 index 000000000..82da35b0b --- /dev/null +++ b/Logo/rider.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + rider + + + + + + + + + + + + + + diff --git a/Logo/webstorm.svg b/Logo/webstorm.svg new file mode 100644 index 000000000..39ab7eb97 --- /dev/null +++ b/Logo/webstorm.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/README.md b/README.md index 48f813e0b..7a6da3158 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,17 @@ # Lidarr [![Build Status](https://dev.azure.com/Lidarr/Lidarr/_apis/build/status/lidarr.Lidarr?branchName=develop)](https://dev.azure.com/Lidarr/Lidarr/_build/latest?definitionId=1&branchName=develop) -[![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/lidarr.svg)](https://github.com/lidarr/Lidarr/wiki/Docker) +[![Translation status](https://translate.servarr.com/widget/servarr/lidarr/svg-badge.svg)](https://translate.servarr.com/engage/servarr/?utm_source=widget) +[![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/lidarr.svg)](https://wiki.servarr.com/lidarr/installation#docker) ![Github Downloads](https://img.shields.io/github/downloads/lidarr/lidarr/total.svg) -[![Backers on Open Collective](https://opencollective.com/lidarr/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/lidarr/sponsors/badge.svg)](#sponsors) +[![Backers on Open Collective](https://opencollective.com/lidarr/backers/badge.svg)](#backers) +[![Sponsors on Open Collective](https://opencollective.com/lidarr/sponsors/badge.svg)](#sponsors) Lidarr is a music collection manager for Usenet and BitTorrent users. It can monitor multiple RSS feeds for new tracks from your favorite artists and will grab, sort and rename them. It can also be configured to automatically upgrade the quality of files already downloaded when a better quality format becomes available. +> [!WARNING] +> NOTICE - The Lidarr Metadata Server is recovering and rebuilding the cache which is impacting adding artists, library imports, etc. Please follow [GHI 5498](https://github.com/Lidarr/Lidarr/issues/5498) or see Discord for details. + ## Major Features Include: * Support for major platforms: Windows, Linux, macOS, Raspberry Pi, etc. @@ -21,46 +26,52 @@ Lidarr is a music collection manager for Usenet and BitTorrent users. It can mon * Full support for specials and multi-album releases * And a beautiful UI -## Feature Requests - -[![Feature Requests](http://feathub.com/lidarr/Lidarr?format=svg)](http://feathub.com/lidarr/Lidarr) - ## Support -[![Discord](https://img.shields.io/badge/discord-chat-7289DA.svg?maxAge=60)](https://discord.gg/8Y7rDc9) -[![Reddit](https://img.shields.io/badge/reddit-discussion-FF4500.svg?maxAge=60)](https://www.reddit.com/r/lidarr) -[![GitHub](https://img.shields.io/badge/github-issues-red.svg?maxAge=60)](https://github.com/Lidarr/Lidarr/issues) -[![GitHub Wiki](https://img.shields.io/badge/github-wiki-181717.svg?maxAge=60)](https://github.com/Lidarr/Lidarr/wiki) +Note: GitHub Issues are for Bugs and Feature Requests Only + +[![Discord](https://img.shields.io/badge/discord-chat-7289DA.svg?maxAge=60)](https://lidarr.audio/discord) +[![GitHub - Bugs and Feature Requests Only](https://img.shields.io/badge/github-issues-red.svg?maxAge=60)](https://github.com/Lidarr/Lidarr/issues) +[![Wiki](https://img.shields.io/badge/servarr-wiki-181717.svg?maxAge=60)](https://wiki.servarr.com/lidarr) ## Contributors -This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. +This project exists thanks to all the people who contribute. [Contribute](CONTRIBUTING.md). - ## Backers -Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/lidarr#backer)] - - +Thank you to all our backers! 🙏 [Become a backer](https://opencollective.com/Lidarr#backer) + ## Sponsors -Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/lidarr#sponsor)] +Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor](https://opencollective.com/Lidarr#sponsor) - - - - - - - - - - + + +## Mega Sponsors + + +## JetBrains +Thank you to [JetBrains JetBrains](http://www.jetbrains.com/) for providing us with free licenses to their great tools. + +* [ReSharper ReSharper](http://www.jetbrains.com/resharper/) +* [WebStorm WebStorm](http://www.jetbrains.com/webstorm/) +* [Rider Rider](http://www.jetbrains.com/rider/) +* [dotTrace dotTrace](http://www.jetbrains.com/dottrace/) + +## DigitalOcean + +This project is also supported by DigitalOcean +

+ + + +

### License * [GNU GPL v3](http://www.gnu.org/licenses/gpl.html) -* Copyright 2010-2019 +* Copyright 2010-2021 diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 000000000..765e24fbc --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,8 @@ +# Security Policy + +## Reporting a Vulnerability + +Please report (suspected) security vulnerabilities on Discord (preferred) to +any of the Servarr Dev role holders (red names) or via email: development@servarr.com. You will receive a response from +us within 72 hours. If the issue is confirmed, we will release a patch as soon +as possible depending on complexity/severity. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index a12a1e32f..000000000 --- a/appveyor.yml +++ /dev/null @@ -1,3 +0,0 @@ -skip_commits: - files: - - '**/**' \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 10050f68d..85d13499a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,101 +7,190 @@ variables: outputFolder: './_output' artifactsFolder: './_artifacts' testsFolder: './_tests' - majorVersion: '0.7.0' + yarnCacheFolder: $(Pipeline.Workspace)/.yarn + nugetCacheFolder: $(Pipeline.Workspace)/.nuget/packages + majorVersion: '2.13.3' minorVersion: $[counter('minorVersion', 1076)] lidarrVersion: '$(majorVersion).$(minorVersion)' buildName: '$(Build.SourceBranchName).$(lidarrVersion)' - windowsInstaller: 'Lidarr.$(buildName).windows-installer.exe' - windowsZip: 'Lidarr.$(buildName).windows.zip' - macOsApp: 'Lidarr.$(buildName).osx-app.zip' - macOsTar: 'Lidarr.$(buildName).osx.tar.gz' - linuxTar: 'Lidarr.$(buildName).linux.tar.gz' - sentryOrg: 'lidarr' + sentryOrg: 'servarr' + sentryUrl: 'https://sentry.servarr.com' + dotnetVersion: '6.0.427' + nodeVersion: '20.X' + innoVersion: '6.2.0' + windowsImage: 'windows-2022' + linuxImage: 'ubuntu-22.04' + macImage: 'macOS-13' trigger: branches: include: - develop - master + paths: + exclude: + - .github + - src/Lidarr.Api.*/openapi.json pr: -- develop + branches: + include: + - develop + paths: + exclude: + - .github + - src/NzbDrone.Core/Localization/Core + - src/Lidarr.Api.*/openapi.json stages: + - stage: Setup + displayName: Setup + jobs: + - job: + displayName: Build Variables + pool: + vmImage: ${{ variables.linuxImage }} + steps: + # Set the build name properly. The 'name' property won't recursively expand so hack here: + - bash: echo "##vso[build.updatebuildnumber]$LIDARRVERSION" + displayName: Set Build Name + - bash: | + if [[ $BUILD_REASON == "PullRequest" ]]; then + git diff origin/develop...HEAD --name-only | grep -E "^(src/|azure-pipelines.yml)" + echo $? > not_backend_update + else + echo 0 > not_backend_update + fi + cat not_backend_update + displayName: Check for Backend File Changes + - publish: not_backend_update + artifact: not_backend_update + displayName: Publish update type - stage: Build_Backend displayName: Build Backend - + dependsOn: Setup jobs: - job: Backend strategy: matrix: Linux: osName: 'Linux' - imageName: 'ubuntu-16.04' + imageName: ${{ variables.linuxImage }} + enableAnalysis: 'true' Mac: osName: 'Mac' - imageName: 'macos-10.13' + imageName: ${{ variables.macImage }} + enableAnalysis: 'false' Windows: osName: 'Windows' - imageName: 'vs2017-win2016' + imageName: ${{ variables.windowsImage }} + enableAnalysis: 'false' pool: vmImage: $(imageName) + variables: + # Disable stylecop here - linting errors get caught by the analyze task + EnableAnalyzers: $(enableAnalysis) steps: - # Set the build name properly. The 'name' property won't recursively expand so hack here: - - powershell: Write-Host "##vso[build.updatebuildnumber]$($env:LIDARRVERSION)" - displayName: Set Build Name - checkout: self submodules: true fetchDepth: 1 - - bash: ./build.sh --only-backend + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - bash: | + BUNDLEDVERSIONS=${AGENT_TOOLSDIRECTORY}/dotnet/sdk/${DOTNETVERSION}/Microsoft.NETCoreSdk.BundledVersions.props + echo $BUNDLEDVERSIONS + if grep -q freebsd-x64 $BUNDLEDVERSIONS; then + echo "Extra platforms already enabled" + else + echo "Enabling extra platform support" + sed -i.ORI 's/osx-x64/osx-x64;freebsd-x64;linux-x86/' $BUNDLEDVERSIONS + fi + displayName: Enable Extra Platform Support + - bash: ./build.sh --backend --enable-extra-platforms displayName: Build Lidarr Backend + - bash: | + find ${OUTPUTFOLDER} -type f ! -path "*/publish/*" -exec rm -rf {} \; + find ${OUTPUTFOLDER} -depth -empty -type d -exec rm -r "{}" \; + find ${TESTSFOLDER} -type f ! -path "*/publish/*" -exec rm -rf {} \; + find ${TESTSFOLDER} -depth -empty -type d -exec rm -r "{}" \; + displayName: Clean up intermediate output + condition: and(succeeded(), ne(variables['osName'], 'Windows')) - publish: $(outputFolder) artifact: '$(osName)Backend' displayName: Publish Backend condition: and(succeeded(), eq(variables['osName'], 'Windows')) - - publish: $(testsFolder) - artifact: '$(osName)Tests' - displayName: Publish Test Package + - publish: '$(testsFolder)/net6.0/win-x64/publish' + artifact: win-x64-tests + displayName: Publish win-x64 Test Package + condition: and(succeeded(), eq(variables['osName'], 'Windows')) + - publish: '$(testsFolder)/net6.0/linux-x64/publish' + artifact: linux-x64-tests + displayName: Publish linux-x64 Test Package + condition: and(succeeded(), eq(variables['osName'], 'Windows')) + - publish: '$(testsFolder)/net6.0/linux-x86/publish' + artifact: linux-x86-tests + displayName: Publish linux-x86 Test Package + condition: and(succeeded(), eq(variables['osName'], 'Windows')) + - publish: '$(testsFolder)/net6.0/linux-musl-x64/publish' + artifact: linux-musl-x64-tests + displayName: Publish linux-musl-x64 Test Package + condition: and(succeeded(), eq(variables['osName'], 'Windows')) + - publish: '$(testsFolder)/net6.0/freebsd-x64/publish' + artifact: freebsd-x64-tests + displayName: Publish freebsd-x64 Test Package + condition: and(succeeded(), eq(variables['osName'], 'Windows')) + - publish: '$(testsFolder)/net6.0/osx-x64/publish' + artifact: osx-x64-tests + displayName: Publish osx-x64 Test Package condition: and(succeeded(), eq(variables['osName'], 'Windows')) - stage: Build_Frontend - displayName: Build Frontend - dependsOn: [] - + displayName: Frontend + dependsOn: Setup jobs: - - job: Frontend + - job: Build strategy: matrix: Linux: osName: 'Linux' - imageName: 'ubuntu-16.04' + imageName: ${{ variables.linuxImage }} Mac: osName: 'Mac' - imageName: 'macos-10.13' + imageName: ${{ variables.macImage }} Windows: osName: 'Windows' - imageName: 'vs2017-win2016' + imageName: ${{ variables.windowsImage }} pool: vmImage: $(imageName) steps: - - task: NodeTool@0 + - task: UseNode@1 displayName: Set Node.js version inputs: - versionSpec: '10.x' + version: $(nodeVersion) - checkout: self submodules: true fetchDepth: 1 - - bash: ./build.sh --only-frontend + - task: Cache@2 + inputs: + key: 'yarn | "$(osName)" | yarn.lock' + restoreKeys: | + yarn | "$(osName)" + path: $(yarnCacheFolder) + displayName: Cache Yarn packages + - bash: ./build.sh --frontend displayName: Build Lidarr Frontend env: FORCE_COLOR: 0 + YARN_CACHE_FOLDER: $(yarnCacheFolder) - publish: $(outputFolder) artifact: '$(osName)Frontend' displayName: Publish Frontend condition: and(succeeded(), eq(variables['osName'], 'Windows')) - - - stage: Package + + - stage: Installer dependsOn: - Build_Backend - Build_Frontend @@ -109,7 +198,7 @@ stages: - job: Windows_Installer displayName: Create Installer pool: - vmImage: 'vs2017-win2016' + vmImage: ${{ variables.windowsImage }} steps: - checkout: self fetchDepth: 1 @@ -125,22 +214,25 @@ stages: artifactName: WindowsFrontend targetPath: _output displayName: Fetch Frontend - - bash: ./build.sh --only-packages - displayName: Create Packages - bash: | - ./setup/inno/ISCC.exe "./setup/lidarr.iss" - cp ./setup/output/Lidarr.*windows.exe ${BUILD_ARTIFACTSTAGINGDIRECTORY}/${WINDOWSINSTALLER} - displayName: Create Windows installer + ./build.sh --packages --installer + cp distribution/windows/setup/output/Lidarr.*win-x64.exe ${BUILD_ARTIFACTSTAGINGDIRECTORY}/Lidarr.${BUILDNAME}.windows-core-x64-installer.exe + cp distribution/windows/setup/output/Lidarr.*win-x86.exe ${BUILD_ARTIFACTSTAGINGDIRECTORY}/Lidarr.${BUILDNAME}.windows-core-x86-installer.exe + displayName: Create Installers - publish: $(Build.ArtifactStagingDirectory) artifact: 'WindowsInstaller' displayName: Publish Installer - + + - stage: Packages + dependsOn: + - Build_Backend + - Build_Frontend + jobs: - job: Other_Packages displayName: Create Standard Packages pool: - vmImage: 'ubuntu-16.04' + vmImage: ${{ variables.linuxImage }} steps: - - bash: sudo apt install dos2unix - checkout: self fetchDepth: 1 - task: DownloadPipelineArtifact@2 @@ -155,59 +247,140 @@ stages: artifactName: WindowsFrontend targetPath: _output displayName: Fetch Frontend - - bash: ./build.sh --only-packages + - bash: ./build.sh --packages --enable-extra-platforms displayName: Create Packages - bash: | - chmod a+x $(artifactsFolder)/macos/Lidarr/fpcalc - chmod a+x $(artifactsFolder)/macos/Lidarr/Lidarr - chmod a+x $(artifactsFolder)/macos-app/Lidarr.app/Contents/MacOS/fpcalc - chmod a+x $(artifactsFolder)/macos-app/Lidarr.app/Contents/MacOS/Lidarr - displayName: Set Mac executable bits + find . -name "fpcalc" -exec chmod a+x {} \; + find . -name "Lidarr" -exec chmod a+x {} \; + find . -name "Lidarr.Update" -exec chmod a+x {} \; + displayName: Set executable bits - task: ArchiveFiles@2 - displayName: Create Windows zip + displayName: Create win-x64 zip inputs: - archiveFile: '$(Build.ArtifactStagingDirectory)/$(windowsZip)' + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).windows-core-x64.zip' archiveType: 'zip' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/windows + rootFolderOrFile: $(artifactsFolder)/win-x64/net6.0 - task: ArchiveFiles@2 - displayName: Create MacOS app + displayName: Create win-x86 zip inputs: - archiveFile: '$(Build.ArtifactStagingDirectory)/$(macOsApp)' + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).windows-core-x86.zip' archiveType: 'zip' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/macos-app + rootFolderOrFile: $(artifactsFolder)/win-x86/net6.0 - task: ArchiveFiles@2 - displayName: Create MacOS tar + displayName: Create osx-x64 app inputs: - archiveFile: '$(Build.ArtifactStagingDirectory)/$(macOsTar)' + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).osx-app-core-x64.zip' + archiveType: 'zip' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/osx-x64-app/net6.0 + - task: ArchiveFiles@2 + displayName: Create osx-x64 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).osx-core-x64.tar.gz' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/macos + rootFolderOrFile: $(artifactsFolder)/osx-x64/net6.0 - task: ArchiveFiles@2 - displayName: Create Linux tar + displayName: Create osx-arm64 app inputs: - archiveFile: '$(Build.ArtifactStagingDirectory)/$(linuxTar)' + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).osx-app-core-arm64.zip' + archiveType: 'zip' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/osx-arm64-app/net6.0 + - task: ArchiveFiles@2 + displayName: Create osx-arm64 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).osx-core-arm64.tar.gz' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/linux + rootFolderOrFile: $(artifactsFolder)/osx-arm64/net6.0 + - task: ArchiveFiles@2 + displayName: Create linux-x64 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-core-x64.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/linux-x64/net6.0 + - task: ArchiveFiles@2 + displayName: Create linux-musl-x64 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-musl-core-x64.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/linux-musl-x64/net6.0 + - task: ArchiveFiles@2 + displayName: Create linux-x86 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-core-x86.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/linux-x86/net6.0 + - task: ArchiveFiles@2 + displayName: Create linux-arm tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-core-arm.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/linux-arm/net6.0 + - task: ArchiveFiles@2 + displayName: Create linux-musl-arm tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-musl-core-arm.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/linux-musl-arm/net6.0 + - task: ArchiveFiles@2 + displayName: Create linux-arm64 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-core-arm64.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/linux-arm64/net6.0 + - task: ArchiveFiles@2 + displayName: Create linux-musl-arm64 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).linux-musl-core-arm64.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/linux-musl-arm64/net6.0 + - task: ArchiveFiles@2 + displayName: Create freebsd-x64 tar + inputs: + archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).freebsd-core-x64.tar.gz' + archiveType: 'tar' + tarCompression: 'gz' + includeRootFolder: false + rootFolderOrFile: $(artifactsFolder)/freebsd-x64/net6.0 - publish: $(Build.ArtifactStagingDirectory) artifact: 'Packages' displayName: Publish Packages - bash: | echo "Uploading source maps to sentry" curl -sL https://sentry.io/get-cli/ | bash - RELEASENAME="${LIDARRVERSION}-${BUILD_SOURCEBRANCHNAME}" + RELEASENAME="Lidarr@${LIDARRVERSION}-${BUILD_SOURCEBRANCHNAME}" sentry-cli releases new --finalize -p lidarr -p lidarr-ui -p lidarr-update "${RELEASENAME}" sentry-cli releases -p lidarr-ui files "${RELEASENAME}" upload-sourcemaps _output/UI/ --rewrite sentry-cli releases set-commits --auto "${RELEASENAME}" - if [[ ${BUILD_SOURCEBRANCHNAME} == "refs/heads/develop" ]]; then + if [[ ${BUILD_SOURCEBRANCH} == "refs/heads/develop" ]]; then sentry-cli releases deploys "${RELEASENAME}" new -e nightly else sentry-cli releases deploys "${RELEASENAME}" new -e production fi + if [ $? -gt 0 ]; then + echo "##vso[task.logissue type=warning]Error uploading source maps." + fi + exit 0 displayName: Publish Sentry Source Maps condition: | or @@ -216,116 +389,328 @@ stages: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) ) env: - SENTRY_AUTH_TOKEN: $(sentryAuthToken) + SENTRY_AUTH_TOKEN: $(sentryAuthTokenServarr) SENTRY_ORG: $(sentryOrg) - + SENTRY_URL: $(sentryUrl) + - stage: Unit_Test displayName: Unit Tests dependsOn: Build_Backend condition: succeeded() + jobs: + - job: Prepare + pool: + vmImage: ${{ variables.linuxImage }} + steps: + - checkout: none + - task: DownloadPipelineArtifact@2 + inputs: + buildType: 'current' + artifactName: 'not_backend_update' + targetPath: '.' + - bash: echo "##vso[task.setvariable variable=backendNotUpdated;isOutput=true]$(cat not_backend_update)" + name: setVar + - job: Unit + displayName: Unit Native + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + workspace: + clean: all + strategy: matrix: - Linux: - osName: 'Linux' - imageName: 'ubuntu-16.04' - Mac: + MacCore: osName: 'Mac' - imageName: 'macos-10.13' - Windows: + testName: 'osx-x64' + poolName: 'Azure Pipelines' + imageName: ${{ variables.macImage }} + WindowsCore: osName: 'Windows' - imageName: 'vs2017-win2016' + testName: 'win-x64' + poolName: 'Azure Pipelines' + imageName: ${{ variables.windowsImage }} + LinuxCore: + osName: 'Linux' + testName: 'linux-x64' + poolName: 'Azure Pipelines' + imageName: ${{ variables.linuxImage }} + FreebsdCore: + osName: 'Linux' + testName: 'freebsd-x64' + poolName: 'FreeBSD' + imageName: pool: + name: $(poolName) vmImage: $(imageName) steps: - checkout: none + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + condition: ne(variables['poolName'], 'FreeBSD') - task: DownloadPipelineArtifact@2 displayName: Download Test Artifact inputs: buildType: 'current' - artifactName: WindowsTests + artifactName: '$(testName)-tests' targetPath: $(testsFolder) - - bash: | - wget https://github.com/acoustid/chromaprint/releases/download/v1.4.3/chromaprint-fpcalc-1.4.3-linux-x86_64.tar.gz - sudo tar xf chromaprint-fpcalc-1.4.3-linux-x86_64.tar.gz --strip-components=1 --directory /usr/bin - displayName: Install fpcalc - condition: and(succeeded(), eq(variables['osName'], 'Linux')) - powershell: Set-Service SCardSvr -StartupType Manual displayName: Enable Windows Test Service condition: and(succeeded(), eq(variables['osName'], 'Windows')) - bash: | chmod a+x _tests/fpcalc - export DYLD_FALLBACK_LIBRARY_PATH=${BUILD_SOURCESDIRECTORY}/_tests displayName: Make fpcalc Executable - condition: and(succeeded(), eq(variables['osName'], 'Mac')) - - task: Bash@3 + condition: and(succeeded(), and(ne(variables['osName'], 'Windows'), ne(variables['poolName'], 'FreeBSD'))) + - bash: find ${TESTSFOLDER} -name "Lidarr.Test.Dummy" -exec chmod a+x {} \; + displayName: Make Test Dummy Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ${TESTSFOLDER}/test.sh ${OSNAME} Unit Test displayName: Run Tests env: - DYLD_FALLBACK_LIBRARY_PATH: $(Build.SourcesDirectory)/_tests TEST_DIR: $(Build.SourcesDirectory)/_tests - inputs: - targetType: 'filePath' - filePath: '$(testsFolder)/test.sh' - arguments: '$(osName) Unit Test' - - publish: TestResult.xml - artifact: 'TestResult' - displayName: Publish Test Result - condition: and(succeeded(), eq(variables['osName'], 'Windows')) - task: PublishTestResults@2 displayName: Publish Test Results inputs: testResultsFormat: 'NUnit' testResultsFiles: '**/TestResult.xml' - testRunTitle: '$(osName) Unit Tests' + testRunTitle: '$(testName) Unit Tests' failTaskOnFailedTests: true - - stage: Integration_Automation - displayName: Integration / Automation - dependsOn: Package - jobs: - - - job: Integration + - job: Unit_Docker + displayName: Unit Docker + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) strategy: matrix: - Linux: - osName: 'Linux' - imageName: 'ubuntu-16.04' - pattern: 'Lidarr.**.linux.tar.gz' - Mac: - osName: 'Mac' - imageName: 'macos-10.13' - pattern: 'Lidarr.**.osx.tar.gz' - Windows: - osName: 'Windows' - imageName: 'vs2017-win2016' - pattern: 'Lidarr.**.windows.zip' + alpine: + testName: 'Musl Net Core' + artifactName: linux-musl-x64-tests + containerImage: ghcr.io/servarr/testimages:alpine + linux-x86: + testName: 'linux-x86' + artifactName: linux-x86-tests + containerImage: ghcr.io/servarr/testimages:linux-x86 pool: - vmImage: $(imageName) - + vmImage: ${{ variables.linuxImage }} + + container: $[ variables['containerImage'] ] + + timeoutInMinutes: 10 + steps: - - script: | - wget https://github.com/acoustid/chromaprint/releases/download/v1.4.3/chromaprint-fpcalc-1.4.3-linux-x86_64.tar.gz - sudo tar xf chromaprint-fpcalc-1.4.3-linux-x86_64.tar.gz --strip-components=1 --directory /usr/bin - displayName: Install fpcalc - condition: and(succeeded(), eq(variables['osName'], 'Linux')) + - task: UseDotNet@2 + displayName: 'Install .NET' + inputs: + version: $(dotnetVersion) + condition: and(succeeded(), ne(variables['testName'], 'linux-x86')) - bash: | - SYMLINK=5_18_1 - MONOPREFIX=/Library/Frameworks/Mono.framework/Versions/$SYMLINK - echo "##vso[task.setvariable variable=DYLD_FALLBACK_LIBRARY_PATH;].:$MONOPREFIX/lib:/lib:/usr/lib:$DYLD_LIBRARY_FALLBACK_PATH" - echo "##vso[task.setvariable variable=PKG_CONFIG_PATH;]$MONOPREFIX/lib/pkgconfig:$MONOPREFIX/share/pkgconfig:$PKG_CONFIG_PATH" - echo "##vso[task.setvariable variable=PATH;]$MONOPREFIX/bin:$PATH" - displayName: Set Mono Version - condition: and(succeeded(), eq(variables['osName'], 'Mac')) + SDKURL=$(curl -s https://api.github.com/repos/Servarr/dotnet-linux-x86/releases | jq -rc '.[].assets[].browser_download_url' | grep sdk-${DOTNETVERSION}.*gz$) + curl -fsSL $SDKURL | tar xzf - -C /opt/dotnet + displayName: 'Install .NET' + condition: and(succeeded(), eq(variables['testName'], 'linux-x86')) - checkout: none - task: DownloadPipelineArtifact@2 displayName: Download Test Artifact inputs: buildType: 'current' - artifactName: WindowsTests + artifactName: $(artifactName) + targetPath: $(testsFolder) + - bash: | + chmod a+x _tests/fpcalc + displayName: Make fpcalc Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: find ${TESTSFOLDER} -name "Lidarr.Test.Dummy" -exec chmod a+x {} \; + displayName: Make Test Dummy Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ls -lR ${TESTSFOLDER} + ${TESTSFOLDER}/test.sh Linux Unit Test + displayName: Run Tests + - task: PublishTestResults@2 + displayName: Publish Test Results + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: '$(testName) Unit Tests' + failTaskOnFailedTests: true + + - job: Unit_LinuxCore_Postgres14 + displayName: Unit Native LinuxCore with Postgres14 Database + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + variables: + pattern: 'Lidarr.*.linux-core-x64.tar.gz' + artifactName: linux-x64-tests + Lidarr__Postgres__Host: 'localhost' + Lidarr__Postgres__Port: '5432' + Lidarr__Postgres__User: 'lidarr' + Lidarr__Postgres__Password: 'lidarr' + + pool: + vmImage: ${{ variables.linuxImage }} + + timeoutInMinutes: 10 + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: $(artifactName) + targetPath: $(testsFolder) + - bash: | + chmod a+x _tests/fpcalc + displayName: Make fpcalc Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: find ${TESTSFOLDER} -name "Lidarr.Test.Dummy" -exec chmod a+x {} \; + displayName: Make Test Dummy Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: | + docker run -d --name=postgres14 \ + -e POSTGRES_PASSWORD=lidarr \ + -e POSTGRES_USER=lidarr \ + -p 5432:5432/tcp \ + -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \ + postgres:14 + displayName: Start postgres + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ls -lR ${TESTSFOLDER} + ${TESTSFOLDER}/test.sh Linux Unit Test + displayName: Run Tests + - task: PublishTestResults@2 + displayName: Publish Test Results + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: 'LinuxCore Postgres14 Unit Tests' + failTaskOnFailedTests: true + + - job: Unit_LinuxCore_Postgres15 + displayName: Unit Native LinuxCore with Postgres15 Database + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + variables: + pattern: 'Lidarr.*.linux-core-x64.tar.gz' + artifactName: linux-x64-tests + Lidarr__Postgres__Host: 'localhost' + Lidarr__Postgres__Port: '5432' + Lidarr__Postgres__User: 'lidarr' + Lidarr__Postgres__Password: 'lidarr' + + pool: + vmImage: ${{ variables.linuxImage }} + + timeoutInMinutes: 10 + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: $(artifactName) + targetPath: $(testsFolder) + - bash: | + chmod a+x _tests/fpcalc + displayName: Make fpcalc Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: find ${TESTSFOLDER} -name "Lidarr.Test.Dummy" -exec chmod a+x {} \; + displayName: Make Test Dummy Executable + condition: and(succeeded(), ne(variables['osName'], 'Windows')) + - bash: | + docker run -d --name=postgres15 \ + -e POSTGRES_PASSWORD=lidarr \ + -e POSTGRES_USER=lidarr \ + -p 5432:5432/tcp \ + -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \ + postgres:15 + displayName: Start postgres + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ls -lR ${TESTSFOLDER} + ${TESTSFOLDER}/test.sh Linux Unit Test + displayName: Run Tests + - task: PublishTestResults@2 + displayName: Publish Test Results + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: 'LinuxCore Postgres15 Unit Tests' + failTaskOnFailedTests: true + + - stage: Integration + displayName: Integration + dependsOn: Packages + + jobs: + - job: Prepare + pool: + vmImage: ${{ variables.linuxImage }} + steps: + - checkout: none + - task: DownloadPipelineArtifact@2 + inputs: + buildType: 'current' + artifactName: 'not_backend_update' + targetPath: '.' + - bash: echo "##vso[task.setvariable variable=backendNotUpdated;isOutput=true]$(cat not_backend_update)" + name: setVar + + - job: Integration_Native + displayName: Integration Native + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + strategy: + matrix: + MacCore: + osName: 'Mac' + testName: 'osx-x64' + imageName: ${{ variables.macImage }} + pattern: 'Lidarr.*.osx-core-x64.tar.gz' + WindowsCore: + osName: 'Windows' + testName: 'win-x64' + imageName: ${{ variables.windowsImage }} + pattern: 'Lidarr.*.windows-core-x64.zip' + LinuxCore: + osName: 'Linux' + testName: 'linux-x64' + imageName: ${{ variables.linuxImage }} + pattern: 'Lidarr.*.linux-core-x64.tar.gz' + + pool: + vmImage: $(imageName) + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: '$(testName)-tests' targetPath: $(testsFolder) - task: DownloadPipelineArtifact@2 displayName: Download Build Artifact @@ -336,56 +721,306 @@ stages: targetPath: $(Build.ArtifactStagingDirectory) - task: ExtractFiles@1 inputs: - archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' + archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' displayName: Extract Package - bash: | mkdir -p ./bin/ cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/ displayName: Move Package Contents - - task: Bash@3 + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ${TESTSFOLDER}/test.sh ${OSNAME} Integration Test displayName: Run Integration Tests - inputs: - targetType: 'filePath' - filePath: '$(testsFolder)/test.sh' - arguments: $(osName) Integration Test - task: PublishTestResults@2 inputs: testResultsFormat: 'NUnit' testResultsFiles: '**/TestResult.xml' - testRunTitle: '$(osName) Integration Tests' + testRunTitle: '$(testName) Integration Tests' failTaskOnFailedTests: true displayName: Publish Test Results + - job: Integration_LinuxCore_Postgres14 + displayName: Integration Native LinuxCore with Postgres14 Database + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + variables: + pattern: 'Lidarr.*.linux-core-x64.tar.gz' + Lidarr__Postgres__Host: 'localhost' + Lidarr__Postgres__Port: '5432' + Lidarr__Postgres__User: 'lidarr' + Lidarr__Postgres__Password: 'lidarr' + + pool: + vmImage: ${{ variables.linuxImage }} + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: 'linux-x64-tests' + targetPath: $(testsFolder) + - task: DownloadPipelineArtifact@2 + displayName: Download Build Artifact + inputs: + buildType: 'current' + artifactName: Packages + itemPattern: '**/$(pattern)' + targetPath: $(Build.ArtifactStagingDirectory) + - task: ExtractFiles@1 + inputs: + archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' + destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' + displayName: Extract Package + - bash: | + mkdir -p ./bin/ + cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/ + displayName: Move Package Contents + - bash: | + docker run -d --name=postgres14 \ + -e POSTGRES_PASSWORD=lidarr \ + -e POSTGRES_USER=lidarr \ + -p 5432:5432/tcp \ + -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \ + postgres:14 + displayName: Start postgres + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ${TESTSFOLDER}/test.sh Linux Integration Test + displayName: Run Integration Tests + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: 'Integration LinuxCore Postgres14 Database Integration Tests' + failTaskOnFailedTests: true + displayName: Publish Test Results + + + - job: Integration_LinuxCore_Postgres15 + displayName: Integration Native LinuxCore with Postgres Database + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + variables: + pattern: 'Lidarr.*.linux-core-x64.tar.gz' + Lidarr__Postgres__Host: 'localhost' + Lidarr__Postgres__Port: '5432' + Lidarr__Postgres__User: 'lidarr' + Lidarr__Postgres__Password: 'lidarr' + + pool: + vmImage: ${{ variables.linuxImage }} + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: 'linux-x64-tests' + targetPath: $(testsFolder) + - task: DownloadPipelineArtifact@2 + displayName: Download Build Artifact + inputs: + buildType: 'current' + artifactName: Packages + itemPattern: '**/$(pattern)' + targetPath: $(Build.ArtifactStagingDirectory) + - task: ExtractFiles@1 + inputs: + archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' + destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' + displayName: Extract Package + - bash: | + mkdir -p ./bin/ + cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/ + displayName: Move Package Contents + - bash: | + docker run -d --name=postgres15 \ + -e POSTGRES_PASSWORD=lidarr \ + -e POSTGRES_USER=lidarr \ + -p 5432:5432/tcp \ + -v /usr/share/zoneinfo/America/Chicago:/etc/localtime:ro \ + postgres:15 + displayName: Start postgres + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ${TESTSFOLDER}/test.sh Linux Integration Test + displayName: Run Integration Tests + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: 'Integration LinuxCore Postgres15 Database Integration Tests' + failTaskOnFailedTests: true + displayName: Publish Test Results + + - job: Integration_FreeBSD + displayName: Integration Native FreeBSD + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + workspace: + clean: all + variables: + pattern: 'Lidarr.*.freebsd-core-x64.tar.gz' + pool: + name: 'FreeBSD' + + steps: + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: 'freebsd-x64-tests' + targetPath: $(testsFolder) + - task: DownloadPipelineArtifact@2 + displayName: Download Build Artifact + inputs: + buildType: 'current' + artifactName: Packages + itemPattern: '**/$(pattern)' + targetPath: $(Build.ArtifactStagingDirectory) + - bash: | + mkdir -p ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin + tar xf ${BUILD_ARTIFACTSTAGINGDIRECTORY}/$(pattern) -C ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin + displayName: Extract Package + - bash: | + mkdir -p ./bin/ + cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/ + displayName: Move Package Contents + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ${TESTSFOLDER}/test.sh Linux Integration Test + displayName: Run Integration Tests + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: 'FreeBSD Integration Tests' + failTaskOnFailedTests: true + displayName: Publish Test Results + + - job: Integration_Docker + displayName: Integration Docker + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + strategy: + matrix: + alpine: + testName: 'linux-musl-x64' + artifactName: linux-musl-x64-tests + containerImage: ghcr.io/servarr/testimages:alpine + pattern: 'Lidarr.*.linux-musl-core-x64.tar.gz' + linux-x86: + testName: 'linux-x86' + artifactName: linux-x86-tests + containerImage: ghcr.io/servarr/testimages:linux-x86 + pattern: 'Lidarr.*.linux-core-x86.tar.gz' + pool: + vmImage: ${{ variables.linuxImage }} + + container: $[ variables['containerImage'] ] + + timeoutInMinutes: 15 + + steps: + - task: UseDotNet@2 + displayName: 'Install .NET' + inputs: + version: $(dotnetVersion) + condition: and(succeeded(), ne(variables['testName'], 'linux-x86')) + - bash: | + SDKURL=$(curl -s https://api.github.com/repos/Servarr/dotnet-linux-x86/releases | jq -rc '.[].assets[].browser_download_url' | grep sdk-${DOTNETVERSION}.*gz$) + curl -fsSL $SDKURL | tar xzf - -C /opt/dotnet + displayName: 'Install .NET' + condition: and(succeeded(), eq(variables['testName'], 'linux-x86')) + - checkout: none + - task: DownloadPipelineArtifact@2 + displayName: Download Test Artifact + inputs: + buildType: 'current' + artifactName: $(artifactName) + targetPath: $(testsFolder) + - task: DownloadPipelineArtifact@2 + displayName: Download Build Artifact + inputs: + buildType: 'current' + artifactName: Packages + itemPattern: '**/$(pattern)' + targetPath: $(Build.ArtifactStagingDirectory) + - task: ExtractFiles@1 + inputs: + archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' + destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' + displayName: Extract Package + - bash: | + mkdir -p ./bin/ + cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/ + displayName: Move Package Contents + - bash: | + chmod a+x ${TESTSFOLDER}/test.sh + ${TESTSFOLDER}/test.sh Linux Integration Test + displayName: Run Integration Tests + - task: PublishTestResults@2 + inputs: + testResultsFormat: 'NUnit' + testResultsFiles: '**/TestResult.xml' + testRunTitle: '$(testName) Integration Tests' + failTaskOnFailedTests: true + displayName: Publish Test Results + + - stage: Automation + displayName: Automation + dependsOn: Packages + + jobs: - job: Automation strategy: matrix: Linux: osName: 'Linux' - imageName: 'ubuntu-16.04' - pattern: 'Lidarr.**.linux.tar.gz' + artifactName: 'linux-x64' + imageName: ${{ variables.linuxImage }} + pattern: 'Lidarr.*.linux-core-x64.tar.gz' failBuild: true Mac: osName: 'Mac' - imageName: 'macos-10.13' # Fails due to firefox not being installed on image - pattern: 'Lidarr.**.osx.tar.gz' - failBuild: false + artifactName: 'osx-x64' + imageName: ${{ variables.macImage }} + pattern: 'Lidarr.*.osx-core-x64.tar.gz' + failBuild: true Windows: osName: 'Windows' - imageName: 'vs2017-win2016' - pattern: 'Lidarr.**.windows.zip' + artifactName: 'win-x64' + imageName: ${{ variables.windowsImage }} + pattern: 'Lidarr.*.windows-core-x64.zip' failBuild: true pool: vmImage: $(imageName) - + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) - checkout: none - task: DownloadPipelineArtifact@2 displayName: Download Test Artifact inputs: buildType: 'current' - artifactName: WindowsTests + artifactName: '$(artifactName)-tests' targetPath: $(testsFolder) - task: DownloadPipelineArtifact@2 displayName: Download Build Artifact @@ -396,7 +1031,7 @@ stages: targetPath: $(Build.ArtifactStagingDirectory) - task: ExtractFiles@1 inputs: - archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' + archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/**/$(pattern)' destinationFolder: '$(Build.ArtifactStagingDirectory)/bin' displayName: Extract Package - bash: | @@ -404,26 +1039,20 @@ stages: cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/ displayName: Move Package Contents - bash: | - if [[ $OSNAME == "Mac" ]]; then - url=https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-macos.tar.gz - elif [[ $OSNAME == "Linux" ]]; then - url=https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz - else - echo "Unhandled OS" - exit 1 - fi - curl -s -L "$url" | tar -xz - chmod +x geckodriver - mv geckodriver _tests - displayName: Install Gecko Driver - condition: and(succeeded(), ne(variables['osName'], 'Windows')) - - bash: ls -lR - - task: Bash@3 + chmod a+x ${TESTSFOLDER}/test.sh + ${TESTSFOLDER}/test.sh ${OSNAME} Automation Test displayName: Run Automation Tests + - task: CopyFiles@2 + displayName: 'Copy Screenshot to: $(Build.ArtifactStagingDirectory)' inputs: - targetType: 'filePath' - filePath: '$(testsFolder)/test.sh' - arguments: $(osName) Automation Test + SourceFolder: '$(Build.SourcesDirectory)' + Contents: | + **/*_test_screenshot.png + TargetFolder: '$(Build.ArtifactStagingDirectory)/screenshots' + - publish: $(Build.ArtifactStagingDirectory)/screenshots + artifact: '$(osName)AutomationScreenshots' + displayName: Publish Screenshot Bundle + condition: and(succeeded(), eq(variables['System.JobAttempt'], '1')) - task: PublishTestResults@2 inputs: testResultsFormat: 'NUnit' @@ -433,62 +1062,208 @@ stages: displayName: Publish Test Results - stage: Analyze - dependsOn: [] + dependsOn: + - Setup displayName: Analyze - condition: eq(variables['system.pullrequest.isfork'], false) - + jobs: + - job: Prepare + pool: + vmImage: ${{ variables.linuxImage }} + steps: + - checkout: none + - task: DownloadPipelineArtifact@2 + inputs: + buildType: 'current' + artifactName: 'not_backend_update' + targetPath: '.' + - bash: echo "##vso[task.setvariable variable=backendNotUpdated;isOutput=true]$(cat not_backend_update)" + name: setVar + + - job: Lint_Frontend + displayName: Lint Frontend + strategy: + matrix: + Linux: + osName: 'Linux' + imageName: ${{ variables.linuxImage }} + Windows: + osName: 'Windows' + imageName: ${{ variables.windowsImage }} + pool: + vmImage: $(imageName) + steps: + - task: UseNode@1 + displayName: Set Node.js version + inputs: + version: $(nodeVersion) + - checkout: self + submodules: true + fetchDepth: 1 + - task: Cache@2 + inputs: + key: 'yarn | "$(osName)" | yarn.lock' + restoreKeys: | + yarn | "$(osName)" + path: $(yarnCacheFolder) + displayName: Cache Yarn packages + - bash: ./build.sh --lint + displayName: Lint Lidarr Frontend + env: + FORCE_COLOR: 0 + YARN_CACHE_FOLDER: $(yarnCacheFolder) + - job: Analyze_Frontend displayName: Frontend + condition: eq(variables['System.PullRequest.IsFork'], 'False') pool: - vmImage: vs2017-win2016 + vmImage: ${{ variables.windowsImage }} steps: - checkout: self # Need history for Sonar analysis - - task: SonarCloudPrepare@1 + - task: SonarCloudPrepare@3 env: SONAR_SCANNER_OPTS: '' inputs: SonarCloud: 'SonarCloud' organization: 'lidarr' - scannerMode: 'CLI' + scannerMode: 'cli' configMode: 'manual' cliProjectKey: 'lidarr_Lidarr.UI' cliProjectName: 'LidarrUI' cliProjectVersion: '$(lidarrVersion)' cliSources: './frontend' - - task: SonarCloudAnalyze@1 + - task: SonarCloudAnalyze@3 + + - job: Api_Docs + displayName: API Docs + dependsOn: Prepare + condition: | + and + ( + and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')), + and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + ) + + pool: + vmImage: ${{ variables.windowsImage }} + + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) + - checkout: self + submodules: true + persistCredentials: true + fetchDepth: 1 + - bash: ./docs.sh Windows + displayName: Create openapi.json + - bash: | + git config --global user.email "development@lidarr.audio" + git config --global user.name "Servarr" + git checkout -b api-docs + git add . + if git status | grep -q modified + then + git commit -am 'Automated API Docs update' + git push -f --set-upstream origin api-docs + curl -X POST -H "Authorization: token ${GITHUBTOKEN}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/lidarr/lidarr/pulls -d '{"head":"api-docs","base":"develop","title":"Update API docs"}' + else + echo "No changes since last run" + fi + displayName: Commit API Doc Change + continueOnError: true + env: + GITHUBTOKEN: $(githubToken) + - task: CopyFiles@2 + displayName: 'Copy openapi.json to: $(Build.ArtifactStagingDirectory)' + inputs: + SourceFolder: '$(Build.SourcesDirectory)' + Contents: | + **/*openapi.json + TargetFolder: '$(Build.ArtifactStagingDirectory)/api_docs' + - publish: $(Build.ArtifactStagingDirectory)/api_docs + artifact: 'APIDocs' + displayName: Publish API Docs Bundle + condition: and(succeeded(), eq(variables['System.JobAttempt'], '1')) - job: Analyze_Backend displayName: Backend + dependsOn: Prepare + condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) + + variables: + disable.coverage.autogenerate: 'true' + EnableAnalyzers: 'false' + pool: - vmImage: vs2017-win2016 + vmImage: ${{ variables.windowsImage }} + steps: + - task: UseDotNet@2 + displayName: 'Install .net core' + inputs: + version: $(dotnetVersion) - checkout: self # Need history for Sonar analysis submodules: true - - task: SonarCloudPrepare@1 + - powershell: Set-Service SCardSvr -StartupType Manual + displayName: Enable Windows Test Service + - task: SonarCloudPrepare@3 + condition: eq(variables['System.PullRequest.IsFork'], 'False') inputs: SonarCloud: 'SonarCloud' organization: 'lidarr' - scannerMode: 'MSBuild' + scannerMode: 'dotnet' projectKey: 'lidarr_Lidarr' projectName: 'Lidarr' projectVersion: '$(lidarrVersion)' extraProperties: | sonar.exclusions=**/obj/**,**/*.dll,**/NzbDrone.Core.Test/Files/**/*,./frontend/**,**/ExternalModules/**,./src/Libraries/** - sonar.coverage.exclusions=**/Lidarr.Api.V1/**/*,**/MonoTorrent/**/*,**/Marr.Data/**/* - sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/_tests/CoverageResults/coverage.opencover.xml + sonar.coverage.exclusions=**/Lidarr.Api.V1/**/* + sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/CoverageResults/**/coverage.opencover.xml sonar.cs.nunit.reportsPaths=$(Build.SourcesDirectory)/TestResult.xml - - bash: ./build.sh --only-backend - displayName: Build Lidarr Backend - - task: Bash@3 + - bash: | + ./build.sh --backend -f net6.0 -r win-x64 + TEST_DIR=_tests/net6.0/win-x64/publish/ ./test.sh Windows Unit Coverage displayName: Coverage Unit Tests + - task: SonarCloudAnalyze@3 + condition: eq(variables['System.PullRequest.IsFork'], 'False') + displayName: Publish SonarCloud Results + - task: reportgenerator@5.3.11 + displayName: Generate Coverage Report inputs: - targetType: 'filePath' - filePath: ./test.sh - arguments: Windows Unit Coverage - - task: PublishCodeCoverageResults@1 - displayName: Publish Coverage Results - inputs: - codeCoverageTool: 'cobertura' - summaryFileLocation: './_tests/CoverageResults/coverage.cobertura.xml' - - task: SonarCloudAnalyze@1 + reports: '$(Build.SourcesDirectory)/CoverageResults/**/coverage.opencover.xml' + targetdir: '$(Build.SourcesDirectory)/CoverageResults/combined' + reporttypes: 'HtmlInline_AzurePipelines;Cobertura;Badges' + publishCodeCoverageResults: true + + - stage: Report_Out + dependsOn: + - Analyze + - Unit_Test + - Integration + - Automation + condition: eq(variables['system.pullrequest.isfork'], false) + displayName: Build Status Report + jobs: + - job: + displayName: Discord Notification + pool: + vmImage: ${{ variables.linuxImage }} + steps: + - task: DownloadPipelineArtifact@2 + continueOnError: true + displayName: Download Screenshot Artifact + inputs: + buildType: 'current' + artifactName: 'WindowsAutomationScreenshots' + targetPath: $(Build.SourcesDirectory) + - checkout: none + - pwsh: | + iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Servarr/AzureDiscordNotify/master/DiscordNotify.ps1')) + env: + SYSTEM_ACCESSTOKEN: $(System.AccessToken) + DISCORDCHANNELID: $(discordChannelId) + DISCORDWEBHOOKKEY: $(discordWebhookKey) + DISCORDTHREADID: $(discordThreadId) + diff --git a/build.sh b/build.sh index 64da6b6ac..ca2ab01ef 100755 --- a/build.sh +++ b/build.sh @@ -1,35 +1,9 @@ -#! /bin/bash -msBuildVersion='15.0' -outputFolder='./_output' -outputFolderLinux='./_output_linux' -outputFolderMacOS='./_output_macos' -outputFolderMacOSApp='./_output_macos_app' -testPackageFolder='./_tests/' -sourceFolder='./src' -slnFile=$sourceFolder/Lidarr.sln -updateFolder=$outputFolder/Lidarr.Update -updateFolderMono=$outputFolderLinux/Lidarr.Update +#! /usr/bin/env bash +set -e -#Artifact variables -artifactsFolder="./_artifacts"; -artifactsFolderWindows=$artifactsFolder/windows -artifactsFolderLinux=$artifactsFolder/linux -artifactsFolderMacOS=$artifactsFolder/macos -artifactsFolderMacOSApp=$artifactsFolder/macos-app - -nuget='tools/nuget/nuget.exe'; -vswhere='tools/vswhere/vswhere.exe'; - -CheckExitCode() -{ - "$@" - local status=$? - if [ $status -ne 0 ]; then - echo "error with $1" >&2 - exit 1 - fi - return $status -} +outputFolder='_output' +testPackageFolder='_tests' +artifactsFolder="_artifacts"; ProgressStart() { @@ -45,74 +19,42 @@ UpdateVersionNumber() { if [ "$LIDARRVERSION" != "" ]; then echo "Updating Version Info" - sed -i "s/[0-9.*]\+<\/AssemblyVersion>/$LIDARRVERSION<\/AssemblyVersion>/g" ./src/Directory.Build.props - sed -i "s/[\$()A-Za-z-]\+<\/AssemblyConfiguration>/${BUILD_SOURCEBRANCHNAME}<\/AssemblyConfiguration>/g" ./src/Directory.Build.props - sed -i "s/10.0.0.0<\/string>/$LIDARRVERSION<\/string>/g" ./macOS/Lidarr.app/Contents/Info.plist + sed -i'' -e "s/[0-9.*]\+<\/AssemblyVersion>/$LIDARRVERSION<\/AssemblyVersion>/g" src/Directory.Build.props + sed -i'' -e "s/[\$()A-Za-z-]\+<\/AssemblyConfiguration>/${BUILD_SOURCEBRANCHNAME}<\/AssemblyConfiguration>/g" src/Directory.Build.props + sed -i'' -e "s/10.0.0.0<\/string>/$LIDARRVERSION<\/string>/g" distribution/osx/Lidarr.app/Contents/Info.plist fi } -CleanFolder() +EnableExtraPlatformsInSDK() { - local path=$1 - local keepConfigFiles=$2 - - find $path -name "*.transform" -exec rm "{}" \; - - if [ $keepConfigFiles != true ] ; then - find $path -name "*.dll.config" -exec rm "{}" \; + SDK_PATH=$(dotnet --list-sdks | grep -P '6\.\d\.\d+' | head -1 | sed 's/\(6\.[0-9]*\.[0-9]*\).*\[\(.*\)\]/\2\/\1/g') + BUNDLEDVERSIONS="${SDK_PATH}/Microsoft.NETCoreSdk.BundledVersions.props" + if grep -q freebsd-x64 $BUNDLEDVERSIONS; then + echo "Extra platforms already enabled" + else + echo "Enabling extra platform support" + sed -i.ORI 's/osx-x64/osx-x64;freebsd-x64;linux-x86/' $BUNDLEDVERSIONS fi - - echo "Removing FluentValidation.Resources files" - find $path -name "FluentValidation.resources.dll" -exec rm "{}" \; - find $path -name "App.config" -exec rm "{}" \; - - echo "Removing vshost files" - find $path -name "*.vshost.exe" -exec rm "{}" \; - - echo "Removing dylib files" - find $path -name "*.dylib" -exec rm "{}" \; - - echo "Removing Empty folders" - find $path -depth -empty -type d -exec rm -r "{}" \; } -BuildWithMSBuild() +EnableExtraPlatforms() { - installationPath=`$vswhere -latest -products \* -requires Microsoft.Component.MSBuild -property installationPath` - installationPath=${installationPath/C:\\/\/c\/} - installationPath=${installationPath//\\/\/} - msBuild="$installationPath/MSBuild/$msBuildVersion/Bin" - echo $msBuild - - export PATH=$msBuild:$PATH - CheckExitCode MSBuild.exe $slnFile //p:Configuration=Debug //p:Platform=x86 //t:Clean //m - CheckExitCode MSBuild.exe $slnFile //p:Configuration=Release //p:Platform=x86 //t:Clean //m - $nuget locals all -clear - $nuget restore $slnFile - CheckExitCode MSBuild.exe $slnFile //p:Configuration=Release //p:Platform=x86 //t:Build //m //p:AllowedReferenceRelatedFileExtensions=.pdb -} - -BuildWithXbuild() -{ - export MONO_IOMAP=case - CheckExitCode msbuild /p:Configuration=Debug /t:Clean $slnFile - CheckExitCode msbuild /p:Configuration=Release /t:Clean $slnFile - mono $nuget locals all -clear - mono $nuget restore $slnFile - CheckExitCode msbuild /p:Configuration=Release /p:Platform=x86 /t:Build /p:AllowedReferenceRelatedFileExtensions=.pdb $slnFile + if grep -qv freebsd-x64 src/Directory.Build.props; then + sed -i'' -e "s^\(.*\)^\1;freebsd-x64;linux-x86^g" src/Directory.Build.props + fi } LintUI() { ProgressStart 'ESLint' - CheckExitCode yarn lint + yarn lint ProgressEnd 'ESLint' ProgressStart 'Stylelint' - if [ $runtime = "dotnet" ] ; then - CheckExitCode yarn stylelint-windows + if [ "$os" = "windows" ]; then + yarn stylelint-windows else - CheckExitCode yarn stylelint-linux + yarn stylelint-linux fi ProgressEnd 'Stylelint' } @@ -124,203 +66,292 @@ Build() rm -rf $outputFolder rm -rf $testPackageFolder - if [ $runtime = "dotnet" ] ; then - BuildWithMSBuild + slnFile=src/Lidarr.sln + + if [ $os = "windows" ]; then + platform=Windows else - BuildWithXbuild + platform=Posix fi - CleanFolder $outputFolder false + dotnet clean $slnFile -c Debug + dotnet clean $slnFile -c Release - echo "Removing Mono.Posix.dll" - rm $outputFolder/Mono.Posix.dll - - echo "Adding LICENSE.md" - cp LICENSE.md $outputFolder + if [[ -z "$RID" || -z "$FRAMEWORK" ]]; + then + dotnet msbuild -restore $slnFile -p:Configuration=Release -p:Platform=$platform -t:PublishAllRids + else + dotnet msbuild -restore $slnFile -p:Configuration=Release -p:Platform=$platform -p:RuntimeIdentifiers=$RID -t:PublishAllRids + fi ProgressEnd 'Build' } -RunGulp() +YarnInstall() { ProgressStart 'yarn install' - yarn install - #npm-cache install npm || CheckExitCode npm install --no-optional --no-bin-links + yarn install --frozen-lockfile --network-timeout 120000 ProgressEnd 'yarn install' - - LintUI - - ProgressStart 'Running gulp' - CheckExitCode yarn run build --production - ProgressEnd 'Running gulp' } -PackageMono() +RunWebpack() { - ProgressStart 'Creating Mono Package' + ProgressStart 'Running webpack' + yarn run build --env production + ProgressEnd 'Running webpack' +} - rm -rf $outputFolderLinux +PackageFiles() +{ + local folder="$1" + local framework="$2" + local runtime="$3" - echo "Copying Binaries" - cp -r $outputFolder $outputFolderLinux + rm -rf $folder + mkdir -p $folder + cp -r $outputFolder/$framework/$runtime/publish/* $folder + cp -r $outputFolder/Lidarr.Update/$framework/$runtime/publish $folder/Lidarr.Update + cp -r $outputFolder/UI $folder + + echo "Adding LICENSE" + cp LICENSE.md $folder +} + +PackageLinux() +{ + local framework="$1" + local runtime="$2" + + ProgressStart "Creating $runtime Package for $framework" + + local folder=$artifactsFolder/$runtime/$framework/Lidarr + + PackageFiles "$folder" "$framework" "$runtime" echo "Removing Service helpers" - rm -f $outputFolderLinux/ServiceUninstall.* - rm -f $outputFolderLinux/ServiceInstall.* - - echo "Removing native windows binaries Sqlite, fpcalc" - rm -f $outputFolderLinux/sqlite3.* - rm -f $outputFolderLinux/fpcalc* - - echo "Renaming Lidarr.Console.exe to Lidarr.exe" - rm $outputFolderLinux/Lidarr.exe* - for file in $outputFolderLinux/Lidarr.Console.exe*; do - mv "$file" "${file//.Console/}" - done + rm -f $folder/ServiceUninstall.* + rm -f $folder/ServiceInstall.* echo "Removing Lidarr.Windows" - rm $outputFolderLinux/Lidarr.Windows.* + rm $folder/Lidarr.Windows.* echo "Adding Lidarr.Mono to UpdatePackage" - cp $outputFolderLinux/Lidarr.Mono.* $updateFolderMono + cp $folder/Lidarr.Mono.* $folder/Lidarr.Update + if [ "$framework" = "net6.0" ]; then + cp $folder/Mono.Posix.NETStandard.* $folder/Lidarr.Update + cp $folder/libMonoPosixHelper.* $folder/Lidarr.Update + fi - ProgressEnd 'Creating Mono Package' + ProgressEnd "Creating $runtime Package for $framework" } PackageMacOS() { - ProgressStart 'Creating MacOS Package' + local framework="$1" + local runtime="$2" + + ProgressStart "Creating $runtime Package for $framework" - rm -rf $outputFolderMacOS - mkdir $outputFolderMacOS + local folder=$artifactsFolder/$runtime/$framework/Lidarr - echo "Adding Startup script" - cp ./macOS/Lidarr $outputFolderMacOS - dos2unix $outputFolderMacOS/Lidarr + PackageFiles "$folder" "$framework" "$runtime" - echo "Copying Binaries" - cp -r $outputFolderLinux/* $outputFolderMacOS - cp $outputFolder/fpcalc $outputFolderMacOS + echo "Removing Service helpers" + rm -f $folder/ServiceUninstall.* + rm -f $folder/ServiceInstall.* - echo "Adding sqlite dylibs" - cp $sourceFolder/Libraries/Sqlite/*.dylib $outputFolderMacOS + echo "Removing Lidarr.Windows" + rm $folder/Lidarr.Windows.* + + echo "Adding Lidarr.Mono to UpdatePackage" + cp $folder/Lidarr.Mono.* $folder/Lidarr.Update + if [ "$framework" = "net6.0" ]; then + cp $folder/Mono.Posix.NETStandard.* $folder/Lidarr.Update + cp $folder/libMonoPosixHelper.* $folder/Lidarr.Update + fi ProgressEnd 'Creating MacOS Package' } PackageMacOSApp() { - ProgressStart 'Creating macOS App Package' + local framework="$1" + local runtime="$2" + + ProgressStart "Creating $runtime App Package for $framework" - rm -rf $outputFolderMacOSApp - mkdir $outputFolderMacOSApp - cp -r ./macOS/Lidarr.app $outputFolderMacOSApp - mkdir -p $outputFolderMacOSApp/Lidarr.app/Contents/MacOS + local folder=$artifactsFolder/$runtime-app/$framework - echo "Adding Startup script" - cp ./macOS/Lidarr $outputFolderMacOSApp/Lidarr.app/Contents/MacOS - dos2unix $outputFolderMacOSApp/Lidarr.app/Contents/MacOS/Lidarr + rm -rf $folder + mkdir -p $folder + cp -r distribution/osx/Lidarr.app $folder + mkdir -p $folder/Lidarr.app/Contents/MacOS echo "Copying Binaries" - cp -r $outputFolderLinux/* $outputFolderMacOSApp/Lidarr.app/Contents/MacOS - cp $outputFolder/fpcalc $outputFolderMacOSApp/Lidarr.app/Contents/MacOS - - echo "Adding sqlite dylibs" - cp $sourceFolder/Libraries/Sqlite/*.dylib $outputFolderMacOSApp/Lidarr.app/Contents/MacOS + cp -r $artifactsFolder/$runtime/$framework/Lidarr/* $folder/Lidarr.app/Contents/MacOS echo "Removing Update Folder" - rm -r $outputFolderMacOSApp/Lidarr.app/Contents/MacOS/Lidarr.Update + rm -r $folder/Lidarr.app/Contents/MacOS/Lidarr.Update ProgressEnd 'Creating macOS App Package' } -PackageTests() +PackageWindows() { - ProgressStart 'Creating Test Package' + local framework="$1" + local runtime="$2" + + ProgressStart "Creating Windows Package for $framework" - if [ $runtime = "dotnet" ] ; then - $nuget install NUnit.ConsoleRunner -Version 3.10.0 -Output $testPackageFolder - else - mono $nuget install NUnit.ConsoleRunner -Version 3.10.0 -Output $testPackageFolder - fi - - cp ./test.sh $testPackageFolder - - rm -f $testPackageFolder/*.log.config - - CleanFolder $testPackageFolder true - - echo "Adding sqlite dylibs" - cp $sourceFolder/Libraries/Sqlite/*.dylib $testPackageFolder - - ProgressEnd 'Creating Test Package' -} - -CleanupWindowsPackage() -{ - ProgressStart 'Cleaning Windows Package' + local folder=$artifactsFolder/$runtime/$framework/Lidarr + + PackageFiles "$folder" "$framework" "$runtime" + cp -r $outputFolder/$framework-windows/$runtime/publish/* $folder echo "Removing Lidarr.Mono" - rm -f $outputFolder/Lidarr.Mono.* + rm -f $folder/Lidarr.Mono.* + rm -f $folder/Mono.Posix.NETStandard.* + rm -f $folder/libMonoPosixHelper.* echo "Adding Lidarr.Windows to UpdatePackage" - cp $outputFolder/Lidarr.Windows.* $updateFolder + cp $folder/Lidarr.Windows.* $folder/Lidarr.Update - echo "Removing MacOS fpcalc" - rm $outputFolder/fpcalc - - ProgressEnd 'Cleaning Windows Package' + ProgressEnd "Creating $runtime Package for $framework" } -PackageArtifacts() +Package() { - echo "Creating Artifact Directories" + local framework="$1" + local runtime="$2" + local SPLIT + + IFS='-' read -ra SPLIT <<< "$runtime" + + case "${SPLIT[0]}" in + linux|freebsd*) + PackageLinux "$framework" "$runtime" + ;; + win) + PackageWindows "$framework" "$runtime" + ;; + osx) + PackageMacOS "$framework" "$runtime" + PackageMacOSApp "$framework" "$runtime" + ;; + esac +} + +BuildInstaller() +{ + local framework="$1" + local runtime="$2" - rm -rf $artifactsFolder - mkdir $artifactsFolder + ./_inno/ISCC.exe distribution/windows/setup/lidarr.iss "//DFramework=$framework" "//DRuntime=$runtime" +} + +InstallInno() +{ + ProgressStart "Installing portable Inno Setup" - mkdir $artifactsFolderWindows - mkdir $artifactsFolderMacOS - mkdir $artifactsFolderLinux - mkdir $artifactsFolderWindows/Lidarr - mkdir $artifactsFolderMacOS/Lidarr - mkdir $artifactsFolderLinux/Lidarr - mkdir $artifactsFolderMacOSApp + rm -rf _inno + curl -s --output innosetup.exe "https://files.jrsoftware.org/is/6/innosetup-${INNOVERSION:-6.2.0}.exe" + mkdir _inno + ./innosetup.exe //portable=1 //silent //currentuser //dir=.\\_inno + rm innosetup.exe - cp -r $outputFolder/* $artifactsFolderWindows/Lidarr - cp -r $outputFolderMacOSApp/* $artifactsFolderMacOSApp - cp -r $outputFolderMacOS/* $artifactsFolderMacOS/Lidarr - cp -r $outputFolderLinux/* $artifactsFolderLinux/Lidarr + ProgressEnd "Installed portable Inno Setup" +} + +RemoveInno() +{ + rm -rf _inno +} + +PackageTests() +{ + local framework="$1" + local runtime="$2" + + cp test.sh "$testPackageFolder/$framework/$runtime/publish" + + rm -f $testPackageFolder/$framework/$runtime/*.log.config + + ProgressEnd 'Creating Test Package' } # Use mono or .net depending on OS case "$(uname -s)" in CYGWIN*|MINGW32*|MINGW64*|MSYS*) # on windows, use dotnet - runtime="dotnet" + os="windows" ;; *) # otherwise use mono - runtime="mono" + os="posix" ;; esac POSITIONAL=() + +if [ $# -eq 0 ]; then + echo "No arguments provided, building everything" + BACKEND=YES + FRONTEND=YES + PACKAGES=YES + INSTALLER=NO + LINT=YES + ENABLE_EXTRA_PLATFORMS=NO + ENABLE_EXTRA_PLATFORMS_IN_SDK=NO +fi + while [[ $# -gt 0 ]] do key="$1" case $key in - --only-backend) - ONLY_BACKEND=YES + --backend) + BACKEND=YES shift # past argument ;; - --only-frontend) - ONLY_FRONTEND=YES + --enable-bsd|--enable-extra-platforms) + ENABLE_EXTRA_PLATFORMS=YES shift # past argument ;; - --only-packages) - ONLY_PACKAGES=YES + --enable-extra-platforms-in-sdk) + ENABLE_EXTRA_PLATFORMS_IN_SDK=YES + shift # past argument + ;; + -r|--runtime) + RID="$2" + shift # past argument + shift # past value + ;; + -f|--framework) + FRAMEWORK="$2" + shift # past argument + shift # past value + ;; + --frontend) + FRONTEND=YES + shift # past argument + ;; + --packages) + PACKAGES=YES + shift # past argument + ;; + --installer) + INSTALLER=YES + shift # past argument + ;; + --lint) + LINT=YES + shift # past argument + ;; + --all) + BACKEND=YES + FRONTEND=YES + PACKAGES=YES + LINT=YES shift # past argument ;; *) # unknown option @@ -331,27 +362,81 @@ esac done set -- "${POSITIONAL[@]}" # restore positional parameters -# Only build backend if we haven't set only-frontend or only-packages -if [ -z "$ONLY_FRONTEND" ] && [ -z "$ONLY_PACKAGES" ]; +if [ "$ENABLE_EXTRA_PLATFORMS_IN_SDK" = "YES" ]; +then + EnableExtraPlatformsInSDK +fi + +if [ "$BACKEND" = "YES" ]; then UpdateVersionNumber + if [ "$ENABLE_EXTRA_PLATFORMS" = "YES" ]; + then + EnableExtraPlatforms + fi Build - PackageTests + if [[ -z "$RID" || -z "$FRAMEWORK" ]]; + then + PackageTests "net6.0" "win-x64" + PackageTests "net6.0" "win-x86" + PackageTests "net6.0" "linux-x64" + PackageTests "net6.0" "linux-musl-x64" + PackageTests "net6.0" "osx-x64" + if [ "$ENABLE_EXTRA_PLATFORMS" = "YES" ]; + then + PackageTests "net6.0" "freebsd-x64" + PackageTests "net6.0" "linux-x86" + fi + else + PackageTests "$FRAMEWORK" "$RID" + fi fi -# Only build frontend if we haven't set only-backend or only-packages -if [ -z "$ONLY_BACKEND" ] && [ -z "$ONLY_PACKAGES" ]; +if [[ "$LINT" = "YES" || "$FRONTEND" = "YES" ]]; then - RunGulp + YarnInstall fi -# Only package if we haven't set only-backend or only-frontend -if [ -z "$ONLY_BACKEND" ] && [ -z "$ONLY_FRONTEND" ]; +if [ "$LINT" = "YES" ]; +then + LintUI +fi + +if [ "$FRONTEND" = "YES" ]; +then + RunWebpack +fi + +if [ "$PACKAGES" = "YES" ]; then UpdateVersionNumber - PackageMono - PackageMacOS - PackageMacOSApp - CleanupWindowsPackage - PackageArtifacts + + if [[ -z "$RID" || -z "$FRAMEWORK" ]]; + then + Package "net6.0" "win-x64" + Package "net6.0" "win-x86" + Package "net6.0" "linux-x64" + Package "net6.0" "linux-musl-x64" + Package "net6.0" "linux-arm64" + Package "net6.0" "linux-musl-arm64" + Package "net6.0" "linux-arm" + Package "net6.0" "linux-musl-arm" + Package "net6.0" "osx-x64" + Package "net6.0" "osx-arm64" + if [ "$ENABLE_EXTRA_PLATFORMS" = "YES" ]; + then + Package "net6.0" "freebsd-x64" + Package "net6.0" "linux-x86" + fi + else + Package "$FRAMEWORK" "$RID" + fi +fi + +if [ "$INSTALLER" = "YES" ]; +then + InstallInno + BuildInstaller "net6.0" "win-x64" + BuildInstaller "net6.0" "win-x86" + RemoveInno fi diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index eb8f841a6..000000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -nzbdrone {version} {branch}; urgency=low - - * Automatic Release. - - -- NzbDrone Mon, 26 Aug 2013 00:00:00 -0700 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 45a4fb75d..000000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/debian/control b/debian/control deleted file mode 100644 index 34586f51d..000000000 --- a/debian/control +++ /dev/null @@ -1,12 +0,0 @@ -Section: web -Priority: optional -Maintainer: Sonarr -Source: nzbdrone -Homepage: https://lidarr.audio -Vcs-Git: git@github.com:lidarr/Lidarr.git -Vcs-Browser: https://github.com/lidarr/Lidarr - -Package: nzbdrone -Architecture: all -Depends: libmono-cil-dev (>= 3.2), sqlite3 (>= 3.7), mediainfo (>= 0.7.52) -Description: Lidarr is a music collection manager diff --git a/debian/copyright b/debian/copyright deleted file mode 100755 index 667d82a43..000000000 --- a/debian/copyright +++ /dev/null @@ -1,24 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: nzbdrone -Source: https://github.com/lidarr/Lidarr - -Files: * -Copyright: 2010-2016 Lidarr - -License: GPL-3.0+ - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - . - This package is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - . - You should have received a copy of the GNU General Public License - along with this program. If not, see . - . - On Debian systems, the complete text of the GNU General - Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". diff --git a/debian/install b/debian/install deleted file mode 100755 index 106b06a9b..000000000 --- a/debian/install +++ /dev/null @@ -1 +0,0 @@ -nzbdrone_bin/* opt/NzbDrone diff --git a/debian/rules b/debian/rules deleted file mode 100755 index b760bee7f..000000000 --- a/debian/rules +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -%: - dh $@ diff --git a/distribution/debian/install.sh b/distribution/debian/install.sh new file mode 100644 index 000000000..b71eb20c9 --- /dev/null +++ b/distribution/debian/install.sh @@ -0,0 +1,182 @@ +#!/bin/bash +### Description: Lidarr .NET Debian install +### Originally written for Radarr by: DoctorArr - doctorarr@the-rowlands.co.uk on 2021-10-01 v1.0 +### Updates for servarr suite made by Bakerboy448, DoctorArr, brightghost, aeramor and VP-EN +### Version v1.0.0 2023-12-29 - StevieTV - adapted from servarr script for Lidarr installs +### Version V1.0.1 2024-01-02 - StevieTV - remove UTF8-BOM +### Version V1.0.2 2024-01-03 - markus101 - Get user input from /dev/tty +### Version V1.0.3 2024-01-06 - StevieTV - exit script when it is ran from install directory + +### Boilerplate Warning +#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +#EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +#MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +#NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +#LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +#OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +#WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +scriptversion="1.0.3" +scriptdate="2024-01-06" + +set -euo pipefail + +echo "Running Lidarr Install Script - Version [$scriptversion] as of [$scriptdate]" + +# Am I root?, need root! + +if [ "$EUID" -ne 0 ]; then + echo "Please run as root." + exit +fi + +app="lidarr" +app_port="8686" +app_prereq="curl sqlite3 wget" +app_umask="0002" +branch="main" + +# Constants +### Update these variables as required for your specific instance +installdir="/opt" # {Update me if needed} Install Location +bindir="${installdir}/${app^}" # Full Path to Install Location +datadir="/var/lib/$app/" # {Update me if needed} AppData directory to use +app_bin=${app^} # Binary Name of the app + +# This script should not be ran from installdir, otherwise later in the script the extracted files will be removed before they can be moved to installdir. +if [ "$installdir" == "$(dirname -- "$( readlink -f -- "$0"; )")" ] || [ "$bindir" == "$(dirname -- "$( readlink -f -- "$0"; )")" ]; then + echo "You should not run this script from the intended install directory. The script will exit. Please re-run it from another directory" + exit +fi + +# Prompt User +read -r -p "What user should ${app^} run as? (Default: $app): " app_uid < /dev/tty +app_uid=$(echo "$app_uid" | tr -d ' ') +app_uid=${app_uid:-$app} +# Prompt Group +read -r -p "What group should ${app^} run as? (Default: media): " app_guid < /dev/tty +app_guid=$(echo "$app_guid" | tr -d ' ') +app_guid=${app_guid:-media} + +echo "This will install [${app^}] to [$bindir] and use [$datadir] for the AppData Directory" +echo "${app^} will run as the user [$app_uid] and group [$app_guid]. By continuing, you've confirmed that the selected user and group will have READ and WRITE access to your Media Library and Download Client Completed Download directories" +read -n 1 -r -s -p $'Press enter to continue or ctrl+c to exit...\n' < /dev/tty + +# Create User / Group as needed +if [ "$app_guid" != "$app_uid" ]; then + if ! getent group "$app_guid" >/dev/null; then + groupadd "$app_guid" + fi +fi +if ! getent passwd "$app_uid" >/dev/null; then + adduser --system --no-create-home --ingroup "$app_guid" "$app_uid" + echo "Created and added User [$app_uid] to Group [$app_guid]" +fi +if ! getent group "$app_guid" | grep -qw "$app_uid"; then + echo "User [$app_uid] did not exist in Group [$app_guid]" + usermod -a -G "$app_guid" "$app_uid" + echo "Added User [$app_uid] to Group [$app_guid]" +fi + +# Stop the App if running +if service --status-all | grep -Fq "$app"; then + systemctl stop "$app" + systemctl disable "$app".service + echo "Stopped existing $app" +fi + +# Create Appdata Directory + +# AppData +mkdir -p "$datadir" +chown -R "$app_uid":"$app_guid" "$datadir" +chmod 775 "$datadir" +echo "Directories created" +# Download and install the App + +# prerequisite packages +echo "" +echo "Installing pre-requisite Packages" +# shellcheck disable=SC2086 +apt update && apt install -y $app_prereq +echo "" +ARCH=$(dpkg --print-architecture) +# get arch +dlbase="https://lidarr.servarr.com/v1/update/$branch/updatefile?os=linux&runtime=netcore" +case "$ARCH" in +"amd64") DLURL="${dlbase}&arch=x64" ;; +"armhf") DLURL="${dlbase}&arch=arm" ;; +"arm64") DLURL="${dlbase}&arch=arm64" ;; +*) + echo "Arch not supported" + exit 1 + ;; +esac +echo "" +echo "Removing previous tarballs" +# -f to Force so we fail if it doesn't exist +rm -f "${app^}".*.tar.gz +echo "" +echo "Downloading..." +wget --content-disposition "$DLURL" +tar -xvzf "${app^}".*.tar.gz +echo "" +echo "Installation files downloaded and extracted" + +# remove existing installs +echo "Removing existing installation" +rm -rf "$bindir" +echo "Installing..." +mv "${app^}" $installdir +chown "$app_uid":"$app_guid" -R "$bindir" +chmod 775 "$bindir" +rm -rf "${app^}.*.tar.gz" +# Ensure we check for an update in case user installs older version or different branch +touch "$datadir"/update_required +chown "$app_uid":"$app_guid" "$datadir"/update_required +echo "App Installed" +# Configure Autostart + +# Remove any previous app .service +echo "Removing old service file" +rm -rf /etc/systemd/system/"$app".service + +# Create app .service with correct user startup +echo "Creating service file" +cat </dev/null +[Unit] +Description=${app^} Daemon +After=syslog.target network.target +[Service] +User=$app_uid +Group=$app_guid +UMask=$app_umask +Type=simple +ExecStart=$bindir/$app_bin -nobrowser -data=$datadir +TimeoutStopSec=20 +KillMode=process +Restart=on-failure +[Install] +WantedBy=multi-user.target +EOF + +# Start the App +echo "Service file created. Attempting to start the app" +systemctl -q daemon-reload +systemctl enable --now -q "$app" + +# Finish Update/Installation +host=$(hostname -I) +ip_local=$(grep -oP '^\S*' <<<"$host") +echo "" +echo "Install complete" +sleep 10 +STATUS="$(systemctl is-active "$app")" +if [ "${STATUS}" = "active" ]; then + echo "Browse to http://$ip_local:$app_port for the ${app^} GUI" +else + echo "${app^} failed to start" +fi + +# Exit +exit 0 diff --git a/distribution/debian/lidarr.service b/distribution/debian/lidarr.service new file mode 100644 index 000000000..8ec5b5b1d --- /dev/null +++ b/distribution/debian/lidarr.service @@ -0,0 +1,20 @@ +# This file is owned by the lidarr package, DO NOT MODIFY MANUALLY +# Instead use 'dpkg-reconfigure -plow lidarr' to modify User/Group/UMask/-data +# Or use systemd built-in override functionality using 'systemctl edit lidarr' +[Unit] +Description=Lidarr Daemon +After=network.target + +[Service] +User=lidarr +Group=lidarr +UMask=002 + +Type=simple +ExecStart=/opt/Lidarr/Lidarr -nobrowser -data=/var/lib/lidarr +TimeoutStopSec=20 +KillMode=process +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/macOS/Lidarr.app/Contents/Info.plist b/distribution/osx/Lidarr.app/Contents/Info.plist similarity index 100% rename from macOS/Lidarr.app/Contents/Info.plist rename to distribution/osx/Lidarr.app/Contents/Info.plist diff --git a/macOS/Lidarr.app/Contents/Resources/lidarr.icns b/distribution/osx/Lidarr.app/Contents/Resources/lidarr.icns similarity index 100% rename from macOS/Lidarr.app/Contents/Resources/lidarr.icns rename to distribution/osx/Lidarr.app/Contents/Resources/lidarr.icns diff --git a/distribution/windows/setup/lidarr.iss b/distribution/windows/setup/lidarr.iss new file mode 100644 index 000000000..f5c0cf791 --- /dev/null +++ b/distribution/windows/setup/lidarr.iss @@ -0,0 +1,84 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define AppName "Lidarr" +#define AppPublisher "Team Lidarr" +#define AppURL "https://lidarr.audio/" +#define ForumsURL "https://lidarr.audio/discord" +#define AppExeName "Lidarr.exe" +#define BaseVersion GetEnv('MAJORVERSION') +#define BuildNumber GetEnv('MINORVERSION') +#define BuildVersion GetEnv('LIDARRVERSION') + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{56C1065D-3523-4025-B76D-6F73F67F7F93} +AppName={#AppName} +AppVersion={#BaseVersion} +AppPublisher={#AppPublisher} +AppPublisherURL={#AppURL} +AppSupportURL={#ForumsURL} +AppUpdatesURL={#AppURL} +DefaultDirName={commonappdata}\Lidarr +DisableDirPage=yes +DefaultGroupName={#AppName} +DisableProgramGroupPage=yes +OutputBaseFilename=Lidarr.{#BuildVersion}.{#Runtime} +SolidCompression=yes +AppCopyright=Creative Commons 3.0 License +AllowUNCPath=False +UninstallDisplayIcon={app}\bin\Lidarr.exe +DisableReadyPage=True +CompressionThreads=2 +Compression=lzma2/normal +AppContact={#ForumsURL} +VersionInfoVersion={#BaseVersion}.{#BuildNumber} +SetupLogging=yes +OutputDir=output +WizardStyle=modern + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopIcon"; Description: "{cm:CreateDesktopIcon}" +Name: "windowsService"; Description: "Install Windows Service (Starts when the computer starts as the LocalService user, you will need to change the user to access network shares)"; GroupDescription: "Start automatically"; Flags: exclusive +Name: "startupShortcut"; Description: "Create shortcut in Startup folder (Starts when you log into Windows)"; GroupDescription: "Start automatically"; Flags: exclusive unchecked +Name: "none"; Description: "Do not start automatically"; GroupDescription: "Start automatically"; Flags: exclusive unchecked + +[Dirs] +Name: "{app}"; Permissions: users-modify + +[Files] +Source: "..\..\..\_artifacts\{#Runtime}\{#Framework}\Lidarr\Lidarr.exe"; DestDir: "{app}\bin"; Flags: ignoreversion +Source: "..\..\..\_artifacts\{#Runtime}\{#Framework}\Lidarr\*"; Excludes: "Lidarr.Update"; DestDir: "{app}\bin"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{#AppName}"; Filename: "{app}\bin\{#AppExeName}"; Parameters: "/icon" +Name: "{commondesktop}\{#AppName}"; Filename: "{app}\bin\{#AppExeName}"; Parameters: "/icon"; Tasks: desktopIcon +Name: "{userstartup}\{#AppName}"; Filename: "{app}\bin\Lidarr.exe"; WorkingDir: "{app}\bin"; Tasks: startupShortcut + +[InstallDelete] +Name: "{app}\bin"; Type: filesandordirs + +[Run] +Filename: "{app}\bin\Lidarr.Console.exe"; StatusMsg: "Removing previous Windows Service"; Parameters: "/u /exitimmediately"; Flags: runhidden waituntilterminated; +Filename: "{app}\bin\Lidarr.Console.exe"; Description: "Enable Access from Other Devices"; StatusMsg: "Enabling Remote access"; Parameters: "/registerurl /exitimmediately"; Flags: postinstall runascurrentuser runhidden waituntilterminated; Tasks: startupShortcut none; +Filename: "{app}\bin\Lidarr.Console.exe"; StatusMsg: "Installing Windows Service"; Parameters: "/i /exitimmediately"; Flags: runhidden waituntilterminated; Tasks: windowsService +Filename: "{app}\bin\Lidarr.exe"; Description: "Open Lidarr Web UI"; Flags: postinstall skipifsilent nowait; Tasks: windowsService; +Filename: "{app}\bin\Lidarr.exe"; Description: "Start Lidarr"; Flags: postinstall skipifsilent nowait; Tasks: startupShortcut none; + +[UninstallRun] +Filename: "{app}\bin\lidarr.console.exe"; Parameters: "/u"; Flags: waituntilterminated skipifdoesntexist + +[Code] +function PrepareToInstall(var NeedsRestart: Boolean): String; +var + ResultCode: Integer; +begin + Exec('net', 'stop lidarr', '', 0, ewWaitUntilTerminated, ResultCode) + Exec('sc', 'delete lidarr', '', 0, ewWaitUntilTerminated, ResultCode) +end; diff --git a/docs.sh b/docs.sh new file mode 100644 index 000000000..a44dc90ce --- /dev/null +++ b/docs.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -e + +FRAMEWORK="net6.0" +PLATFORM=$1 +ARCHITECTURE="${2:-x64}" + +if [ "$PLATFORM" = "Windows" ]; then + RUNTIME="win-$ARCHITECTURE" +elif [ "$PLATFORM" = "Linux" ]; then + RUNTIME="linux-$ARCHITECTURE" +elif [ "$PLATFORM" = "Mac" ]; then + RUNTIME="osx-$ARCHITECTURE" +else + echo "Platform must be provided as first argument: Windows, Linux or Mac" + exit 1 +fi + +outputFolder='_output' +testPackageFolder='_tests' + +rm -rf $outputFolder +rm -rf $testPackageFolder + +slnFile=src/Lidarr.sln + +platform=Posix + +if [ "$PLATFORM" = "Windows" ]; then + application=Lidarr.Console.dll +else + application=Lidarr.dll +fi + +dotnet clean $slnFile -c Debug +dotnet clean $slnFile -c Release + +dotnet msbuild -restore $slnFile -p:Configuration=Debug -p:Platform=$platform -p:RuntimeIdentifiers=$RUNTIME -t:PublishAllRids + +dotnet new tool-manifest +dotnet tool install --version 6.6.2 Swashbuckle.AspNetCore.Cli + +dotnet tool run swagger tofile --output ./src/Lidarr.Api.V1/openapi.json "$outputFolder/$FRAMEWORK/$RUNTIME/$application" v1 & + +sleep 45 + +kill %1 + +exit 0 diff --git a/frontend/.csscomb.json b/frontend/.csscomb.json deleted file mode 100644 index a82e49732..000000000 --- a/frontend/.csscomb.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "remove-empty-rulesets": true, - "always-semicolon": true, - "color-case": "lower", - "block-indent": " ", - "color-shorthand": false, - "element-case": "lower", - "eof-newline": true, - "leading-zero": true, - "quotes": "double", - "sort-order-fallback": "abc", - "space-before-colon": "", - "space-after-colon": " ", - "space-before-combinator": " ", - "space-after-combinator": " ", - "space-between-declarations": "\n", - "space-before-opening-brace": " ", - "space-after-opening-brace": "\n", - "space-after-selector-delimiter": " ", - "space-before-selector-delimiter": "", - "space-before-closing-brace": "\n", - "strip-spaces": true, - "tab-size": true, - "unitless-zero": false -} diff --git a/frontend/.editorconfig b/frontend/.editorconfig deleted file mode 100644 index c14ef65ef..000000000 --- a/frontend/.editorconfig +++ /dev/null @@ -1,6 +0,0 @@ -[*] -insert_final_newline = true - -[*.{js,css}] -indent_style = space -indent_size = 2 diff --git a/frontend/.esformatter b/frontend/.esformatter deleted file mode 100644 index 600bb0751..000000000 --- a/frontend/.esformatter +++ /dev/null @@ -1,335 +0,0 @@ -{ - "indent": { - "value": " ", - "FunctionExpression": 1, - "ArrayExpression": 1, - "ObjectExpression": 1 - }, - "lineBreak": { - "value": "\n", - - "before": { - "ArrayPatternClosing": 0, - "ArrayPatternComma": 0, - "ArrayPatternOpening": 0, - "ArrowFunctionExpressionArrow": 0, - "ArrowFunctionExpressionClosingBrace": ">=1", - "ArrowFunctionExpressionOpeningBrace": 0, - "AssignmentExpression": ">=1", - "AssignmentOperator": 0, - "BlockStatement": 0, - "BreakKeyword": ">=1", - "CallExpression": -1, - "CallExpressionClosingParentheses": -1, - "CallExpressionOpeningParentheses": 0, - "CatchClosingBrace": ">=1", - "CatchKeyword": 0, - "CatchOpeningBrace": 0, - "ClassDeclaration": ">=1", - "ClassDeclarationClosingBrace": ">=1", - "ClassDeclarationOpeningBrace": 0, - "ConditionalExpression": ">=1", - "DeleteOperator": ">=1", - "DoWhileStatement": ">=1", - "DoWhileStatementClosingBrace": ">=1", - "DoWhileStatementOpeningBrace": 0, - "ElseIfStatement": 0, - "ElseIfStatementClosingBrace": ">=1", - "ElseIfStatementOpeningBrace": 0, - "ElseStatement": 0, - "ElseStatementClosingBrace": ">=1", - "ElseStatementOpeningBrace": 0, - "EmptyStatement": -1, - "EndOfFile": -1, - "FinallyClosingBrace": ">=1", - "FinallyKeyword": -1, - "FinallyOpeningBrace": 0, - "ForInStatement": ">=1", - "ForInStatementClosingBrace": ">=1", - "ForInStatementExpressionClosing": 0, - "ForInStatementExpressionOpening": 0, - "ForInStatementOpeningBrace": 0, - "ForStatement": ">=1", - "ForStatementClosingBrace": ">=1", - "ForStatementExpressionClosing": "<2", - "ForStatementExpressionOpening": 0, - "ForStatementOpeningBrace": 0, - "FunctionDeclaration": ">=1", - "FunctionDeclarationClosingBrace": ">=1", - "FunctionDeclarationOpeningBrace": 0, - "FunctionExpression": 0, - "FunctionExpressionClosingBrace": 1, - "FunctionExpressionOpeningBrace":0, - "IIFEClosingParentheses": 0, - "IfStatement": ">=1", - "IfStatementClosingBrace": ">=1", - "IfStatementOpeningBrace": 0, - "LogicalExpression": -1, - "MemberExpressionClosing": 0, - "MemberExpressionOpening": 0, - "MemberExpressionPeriod": -1, - "MethodDefinition": ">=1", - "ObjectExpressionClosingBrace": "<=1", - "ObjectPatternClosingBrace": 0, - "ObjectPatternComma": 0, - "ObjectPatternOpeningBrace": 0, - "ParameterDefault": 0, - "Property": "<=2", - "PropertyValue": 0, - "ReturnStatement": -1, - "SwitchClosingBrace": ">=1", - "SwitchOpeningBrace": 0, - "ThisExpression": -1, - "ThrowStatement": ">=1", - "TryClosingBrace": ">=1", - "TryKeyword": -1, - "TryOpeningBrace": 0, - "VariableDeclaration": ">=1", - "VariableDeclarationSemiColon": 0, - "VariableDeclarationWithoutInit": ">=1", - "VariableName": ">=1", - "VariableValue": 0, - "WhileStatement": ">=1", - "WhileStatementClosingBrace": ">=1", - "WhileStatementOpeningBrace": 0 - }, - - "after": { - "ArrayPatternClosing": 0, - "ArrayPatternComma": 0, - "ArrayPatternOpening": 0, - "ArrowFunctionExpressionArrow": 0, - "ArrowFunctionExpressionClosingBrace": -1, - "ArrowFunctionExpressionOpeningBrace": ">=1", - "AssignmentExpression": ">=1", - "AssignmentOperator": 0, - "BlockStatement": 0, - "BreakKeyword": -1, - "CallExpression": -1, - "CallExpressionClosingParentheses": -1, - "CallExpressionOpeningParentheses": -1, - "CatchClosingBrace": ">=0", - "CatchKeyword": 0, - "CatchOpeningBrace": ">=1", - "ClassDeclaration": ">=1", - "ClassDeclarationClosingBrace": ">=1", - "ClassDeclarationOpeningBrace": ">=1", - "ConditionalExpression": ">=1", - "DeleteOperator": ">=1", - "DoWhileStatement": ">=1", - "DoWhileStatementClosingBrace": 0, - "DoWhileStatementOpeningBrace": ">=1", - "ElseIfStatement": ">=1", - "ElseIfStatementClosingBrace": ">=1", - "ElseIfStatementOpeningBrace": ">=1", - "ElseStatement": ">=1", - "ElseStatementClosingBrace": ">=1", - "ElseStatementOpeningBrace": ">=1", - "EmptyStatement": -1, - "FinallyClosingBrace": ">=1", - "FinallyKeyword": -1, - "FinallyOpeningBrace": ">=1", - "ForInStatement": ">=1", - "ForInStatementClosingBrace": ">=1", - "ForInStatementExpressionClosing": -1, - "ForInStatementExpressionOpening": "<2", - "ForInStatementOpeningBrace": ">=1", - "ForStatement": ">=1", - "ForStatementClosingBrace": ">=1", - "ForStatementExpressionClosing": -1, - "ForStatementExpressionOpening": "<2", - "ForStatementOpeningBrace": ">=1", - "FunctionDeclaration": ">=1", - "FunctionDeclarationClosingBrace": ">=1", - "FunctionDeclarationOpeningBrace": ">=1", - "FunctionExpression": 0, - "FunctionExpressionClosingBrace": -1, - "FunctionExpressionOpeningBrace": 1, - "IIFEOpeningParentheses": 0, - "IfStatement": ">=1", - "IfStatementClosingBrace": ">=1", - "IfStatementOpeningBrace": ">=1", - "LogicalExpression": -1, - "MemberExpressionClosing": 0, - "MemberExpressionOpening": 0, - "MemberExpressionPeriod": 0, - "MethodDefinition": ">=1", - "ObjectExpressionOpeningBrace": "<=1", - "ObjectPatternClosingBrace": 0, - "ObjectPatternComma": 0, - "ObjectPatternOpeningBrace": 0, - "ParameterDefault": 0, - "Property": -1, - "PropertyName": 0, - "ReturnStatement": -1, - "SwitchCaseColon": ">=1", - "SwitchClosingBrace": ">=1", - "SwitchOpeningBrace": ">=1", - "ThisExpression": 0, - "ThrowStatement": ">=1", - "TryClosingBrace": 0, - "TryKeyword": -1, - "TryOpeningBrace": ">=1", - "VariableDeclaration": ">=1", - "VariableDeclarationSemiColon": ">=1", - "VariableValue": -1, - "WhileStatement": ">=1", - "WhileStatementClosingBrace": ">=1", - "WhileStatementOpeningBrace": ">=1" - } - }, - "whiteSpace": { - "value": " ", - "removeTrailing": 1, - "before": { - "ArgumentComma": 0, - "ArgumentList": 0, - "ArgumentListArrayExpression": 0, - "ArgumentListFunctionExpression": 1, - "ArgumentListObjectExpression": 0, - "ArrayExpressionClosing": 0, - "ArrayExpressionComma": 0, - "ArrayExpressionOpening": 1, - "AssignmentOperator": 1, - "BinaryExpression": 0, - "BinaryExpressionOperator": 1, - "BlockComment": 1, - "CallExpression": 1, - "CatchClosingBrace": 1, - "CatchKeyword": 1, - "CatchOpeningBrace": 1, - "CatchParameterList": 0, - "CommaOperator": 0, - "ConditionalExpressionAlternate": 1, - "ConditionalExpressionConsequent": 1, - "DoWhileStatementClosingBrace": 1, - "DoWhileStatementConditional": 1, - "DoWhileStatementOpeningBrace": 1, - "ElseIfStatementClosingBrace": 1, - "ElseIfStatementOpeningBrace": 1, - "ElseStatementClosingBrace": 1, - "ElseStatementOpeningBrace": 1, - "EmptyStatement": 0, - "ExpressionClosingParentheses": 0, - "FinallyClosingBrace": 1, - "FinallyKeyword": -1, - "FinallyOpeningBrace": 1, - "ForInStatement": 1, - "ForInStatementClosingBrace": 1, - "ForInStatementExpressionClosing": 0, - "ForInStatementExpressionOpening": 1, - "ForInStatementOpeningBrace": 1, - "ForStatement": 1, - "ForStatementClosingBrace": 1, - "ForStatementExpressionClosing": 0, - "ForStatementExpressionOpening": 1, - "ForStatementOpeningBrace": 1, - "ForStatementSemicolon": 0, - "FunctionDeclarationClosingBrace": 1, - "FunctionDeclarationOpeningBrace": 1, - "FunctionExpressionClosingBrace": 1, - "FunctionExpressionOpeningBrace": 1, - "IfStatementClosingBrace": 1, - "IfStatementConditionalClosing": 0, - "IfStatementConditionalOpening": 1, - "IfStatementOpeningBrace": 1, - "LineComment": 1, - "LogicalExpressionOperator": 1, - "MemberExpressionClosing": 0, - "ObjectExpressionClosingBrace": 1, - "ParameterComma": 0, - "ParameterList": 0, - "Property": 1, - "PropertyName": 1, - "PropertyValue": 1, - "SwitchDiscriminantClosing": 0, - "SwitchDiscriminantOpening": 1, - "ThrowKeyword": 1, - "TryClosingBrace": 1, - "TryKeyword": -1, - "TryOpeningBrace": 1, - "UnaryExpressionOperator": 0, - "VariableName": 1, - "VariableValue": 1, - "WhileStatementClosingBrace": 1, - "WhileStatementConditionalClosing": 0, - "WhileStatementConditionalOpening": 1, - "WhileStatementOpeningBrace": 1 - }, - "after": { - "ArgumentComma": 1, - "ArgumentList": 0, - "ArgumentListArrayExpression": 1, - "ArgumentListFunctionExpression": 1, - "ArgumentListObjectExpression": 0, - "ArrayExpressionClosing": 0, - "ArrayExpressionComma": 1, - "ArrayExpressionOpening": 0, - "AssignmentOperator": 1, - "BinaryExpression": 0, - "BinaryExpressionOperator": 1, - "BlockComment": 1, - "CallExpression": 0, - "CatchClosingBrace": 1, - "CatchKeyword": 1, - "CatchOpeningBrace": 1, - "CatchParameterList": 0, - "CommaOperator": 1, - "ConditionalExpressionConsequent": 1, - "ConditionalExpressionTest": 1, - "DoWhileStatementBody": 1, - "DoWhileStatementClosingBrace": 1, - "DoWhileStatementOpeningBrace": 1, - "ElseIfStatementClosingBrace": 1, - "ElseIfStatementOpeningBrace": 1, - "ElseStatementClosingBrace": 1, - "ElseStatementOpeningBrace": 1, - "EmptyStatement": 0, - "ExpressionOpeningParentheses": 0, - "FinallyClosingBrace": 1, - "FinallyKeyword": -1, - "FinallyOpeningBrace": 1, - "ForInStatement": 1, - "ForInStatementClosingBrace": 1, - "ForInStatementExpressionClosing": 1, - "ForInStatementExpressionOpening": 0, - "ForInStatementOpeningBrace": 1, - "ForStatement": 1, - "ForStatementClosingBrace": 1, - "ForStatementExpressionClosing": 1, - "ForStatementExpressionOpening": 0, - "ForStatementOpeningBrace": 1, - "ForStatementSemicolon": 1, - "FunctionDeclarationClosingBrace": 0, - "FunctionDeclarationOpeningBrace": 0, - "FunctionExpressionClosingBrace": 0, - "FunctionExpressionOpeningBrace": 0, - "FunctionName": 0, - "FunctionReservedWord": 0, - "IfStatementClosingBrace": 1, - "IfStatementConditionalClosing": 0, - "IfStatementConditionalOpening": 0, - "IfStatementOpeningBrace": 1, - "LogicalExpressionOperator": 1, - "MemberExpressionOpening": 0, - "ObjectExpressionClosingBrace": 0, - "ObjectExpressionOpeningBrace": 1, - "ParameterComma": 1, - "ParameterList": 0, - "PropertyName": 0, - "PropertyValue": 0, - "SwitchDiscriminantClosing": 1, - "SwitchDiscriminantOpening": 0, - "ThrowKeyword": 1, - "TryClosingBrace": 1, - "TryKeyword": -1, - "TryOpeningBrace": 1, - "UnaryExpressionOperator": 0, - "VariableName": 1, - "WhileStatementClosingBrace": 1, - "WhileStatementConditionalClosing": 1, - "WhileStatementConditionalOpening": 0, - "WhileStatementOpeningBrace": 1 - } - } -} diff --git a/frontend/.eslintignore b/frontend/.eslintignore index d4b43f836..e6d49ec4d 100644 --- a/frontend/.eslintignore +++ b/frontend/.eslintignore @@ -1 +1,2 @@ **/JsLibraries/** +**/*.css.d.ts diff --git a/frontend/.eslintrc b/frontend/.eslintrc deleted file mode 100644 index 8593e9f61..000000000 --- a/frontend/.eslintrc +++ /dev/null @@ -1,293 +0,0 @@ -{ - "parser": "babel-eslint", - - "env": { - "browser": true, - "commonjs": true, - "node": true, - "es6": true - }, - - "globals": { - "expect": false, - "chai": false, - "sinon": false - }, - - "parserOptions": { - "ecmaVersion": 6, - "sourceType": "module", - "ecmaFeatures": { - "modules": true, - "impliedStrict": true - } - }, - - "plugins": [ - "filenames", - "react" - ], - - "settings": { - "react": { - "version": "detect" - } - }, - - "rules": { - "filenames/match-exported": ["error"], - - # ECMAScript 6 - - "arrow-body-style": [0], - "arrow-parens": ["error", "always"], - "arrow-spacing": ["error", { "before": true, "after": true }], - "constructor-super": "error", - "generator-star-spacing": "off", - "no-class-assign": "error", - "no-confusing-arrow": "error", - "no-const-assign": "error", - "no-dupe-class-members": "error", - "no-duplicate-imports": "error", - "no-new-symbol": "error", - "no-this-before-super": "error", - "no-useless-escape": "error", - "no-useless-computed-key": "error", - "no-useless-constructor": "error", - "no-var": "warn", - "object-shorthand": ["error", "properties"], - "prefer-arrow-callback": "error", - "prefer-const": "warn", - "prefer-reflect": "off", - "prefer-rest-params": "off", - "prefer-spread": "warn", - "prefer-template": "error", - "require-yield": "off", - "template-curly-spacing": ["error", "never"], - "yield-star-spacing": "off", - - # Possible Errors - - "comma-dangle": "error", - "no-cond-assign": "error", - "no-console": "off", - "no-constant-condition": "warn", - "no-control-regex": "error", - "no-debugger": "off", - "no-dupe-args": "error", - "no-dupe-keys": "error", - "no-duplicate-case": "error", - "no-empty": "warn", - "no-empty-character-class": "error", - "no-ex-assign": "error", - "no-extra-boolean-cast": "error", - "no-extra-parens": ["error", "functions"], - "no-extra-semi": "error", - "no-func-assign": "error", - "no-inner-declarations": "error", - "no-invalid-regexp": "error", - "no-irregular-whitespace": "error", - "no-negated-in-lhs": "error", - "no-obj-calls": "error", - "no-regex-spaces": "error", - "no-sparse-arrays": "error", - "no-unexpected-multiline": "error", - "no-unreachable": "warn", - "no-unsafe-finally": "error", - "use-isnan": "error", - "valid-jsdoc": "off", - "valid-typeof": "error", - - # Best Practices - - "accessor-pairs": "off", - "array-callback-return": "warn", - "block-scoped-var": "warn", - "consistent-return": "off", - "curly": "error", - "default-case": "error", - "dot-location": ["error", "property"], - "dot-notation": "error", - "eqeqeq": ["error", "smart"], - "guard-for-in": "error", - "no-alert": "warn", - "no-caller": "error", - "no-case-declarations": "error", - "no-div-regex": "error", - "no-else-return": "error", - "no-empty-function": ["error", {"allow": ["arrowFunctions"]}], - "no-empty-pattern": "error", - "no-eval": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-fallthrough": "error", - "no-floating-decimal": "error", - "no-implicit-coercion": ["error", { - "boolean": false, - "number": true, - "string": true, - "allow": [/* "!!", "~", "*", "+" */] - }], - "no-implicit-globals": "error", - "no-implied-eval": "error", - "no-invalid-this": "off", - "no-iterator": "error", - "no-labels": "error", - "no-lone-blocks": "error", - "no-loop-func": "error", - "no-magic-numbers": ["off", {"ignoreArrayIndexes": true, "ignore": [0, 1] }], - "no-multi-spaces": "error", - "no-multi-str": "error", - "no-native-reassign": ["error", {"exceptions": ["console"]}], - "no-new": "off", - "no-new-func": "error", - "no-new-wrappers": "error", - "no-octal": "error", - "no-octal-escape": "error", - "no-param-reassign": "off", - "no-process-env": "off", - "no-proto": "error", - "no-redeclare": "error", - "no-return-assign": "warn", - "no-script-url": "error", - "no-self-assign": "error", - "no-self-compare": "error", - "no-sequences": "error", - "no-throw-literal": "error", - "no-unmodified-loop-condition": "error", - "no-unused-expressions": "error", - "no-unused-labels": "error", - "no-useless-call": "error", - "no-useless-concat": "error", - "no-void": "error", - "no-warning-comments": "off", - "no-with": "error", - "radix": ["error", "as-needed"], - "vars-on-top": "off", - "wrap-iife": ["error", "inside"], - "yoda": "error", - - # Strict Mode - - "strict": ["error", "never"], - - # Variables - - "init-declarations": ["error", "always"], - "no-catch-shadow": "error", - "no-delete-var": "error", - "no-label-var": "error", - "no-restricted-globals": "off", - "no-shadow": "error", - "no-shadow-restricted-names": "error", - "no-undef": "error", - "no-undef-init": "off", - "no-undefined": "off", - "no-unused-vars": ["error", { "args": "none", "ignoreRestSiblings": true }], - "no-use-before-define": "error", - - # Node.js and CommonJS - - "callback-return": "warn", - "global-require": "error", - "handle-callback-err": "warn", - "no-mixed-requires": "error", - "no-new-require": "error", - "no-path-concat": "error", - "no-process-exit": "error", - - # Stylistic Issues - - "array-bracket-spacing": ["error", "never"], - "block-spacing": ["error", "always"], - "brace-style": ["error", "1tbs", { "allowSingleLine": false }], - "camelcase": "off", - "comma-spacing": ["error", {"before": false, "after": true}], - "comma-style": ["error", "last"], - "computed-property-spacing": ["error", "never"], - "consistent-this": ["error", "self"], - "eol-last": "error", - "func-names": "off", - "func-style": ["error", "declaration"], - "indent": ["error", 2, {"SwitchCase": 1}], - "key-spacing": ["error", {"beforeColon": false, "afterColon": true}], - "keyword-spacing": ["error", { "before": true, "after": true}], - "lines-around-comment": ["error", { "beforeBlockComment": true, "afterBlockComment": false }], - "max-depth": ["error", {"maximum": 5}], - "max-nested-callbacks": ["error", 4], - "max-statements": "off", - "max-statements-per-line": ["error", { "max": 1 }], - "new-cap": ["error", {"capIsNewExceptions": ["$.Deferred", "DragDropContext", "DragLayer", "DragSource", "DropTarget"]}], - "new-parens": "error", - "newline-after-var": "off", - "newline-before-return": "off", - "newline-per-chained-call": "off", - "no-array-constructor": "error", - "no-bitwise": "error", - "no-continue": "error", - "no-inline-comments": "off", - "no-lonely-if": "warn", - "no-mixed-spaces-and-tabs": "error", - "no-multiple-empty-lines": ["error", { "max": 1 }], - "no-negated-condition": "warn", - "no-nested-ternary": "error", - "no-new-object": "error", - "no-plusplus": "off", - "no-restricted-syntax": "off", - "no-spaced-func": "error", - "no-ternary": "off", - "no-trailing-spaces": "error", - "no-underscore-dangle": ["error", { "allowAfterThis": true }], - "no-unneeded-ternary": "error", - "no-whitespace-before-property": "error", - "object-curly-spacing": ["error", "always"], - "one-var": ["error", "never"], - "one-var-declaration-per-line": ["error", "always"], - "operator-assignment": ["off", "never"], - "operator-linebreak": ["error", "after"], - "quote-props": ["error", "as-needed"], - "quotes": ["error", "single"], - "require-jsdoc": "off", - "semi": "error", - "semi-spacing": ["error", { "before": false, "after": true }], - "sort-vars": "off", - "space-before-blocks": ["error", "always"], - "space-before-function-paren": ["error", "never"], - "space-in-parens": "off", - "space-infix-ops": "off", - "space-unary-ops": "off", - "spaced-comment": "error", - "wrap-regex": "error", - - # React - - "react/jsx-boolean-value": [2, "always"], - "react/jsx-uses-vars": 2, - "react/jsx-closing-bracket-location": 2, - "react/jsx-tag-spacing": ["error"], - "react/jsx-curly-spacing": [2, "never"], - "react/jsx-equals-spacing": [2, "never"], - "react/jsx-indent-props": [2, 2], - "react/jsx-indent": [2, 2], - "react/jsx-key": 2, - "react/jsx-no-bind": [2, { "allowArrowFunctions": true }], - "react/jsx-no-duplicate-props": [2, { "ignoreCase": true }], - "react/jsx-max-props-per-line": [2, { "maximum": 2 }], - "react/jsx-handler-names": [2, { "eventHandlerPrefix": "(on|dispatch)", "eventHandlerPropPrefix": "on" }], - "react/jsx-no-undef": 2, - "react/jsx-pascal-case": 2, - "react/jsx-uses-react": 2, - // Explicitly disabled in case we want to enable them again - "react/no-did-mount-set-state": 0, - "react/no-did-update-set-state": 0, - "react/no-direct-mutation-state": 2, - "react/no-multi-comp": [2, { "ignoreStateless": true }], - "react/no-unknown-property": 2, - "react/prefer-es6-class": 2, - "react/prop-types": 2, - "react/react-in-jsx-scope": 2, - "react/self-closing-comp": 2, - "react/sort-comp": 2, - "react/jsx-wrap-multilines": 2 - } -} diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js new file mode 100644 index 000000000..cc26a2633 --- /dev/null +++ b/frontend/.eslintrc.js @@ -0,0 +1,393 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +const fs = require('fs'); +// eslint-disable-next-line @typescript-eslint/no-var-requires +const path = require('path'); +// eslint-disable-next-line @typescript-eslint/no-var-requires +const typescriptEslintRecommended = require('@typescript-eslint/eslint-plugin').configs.recommended; + +const frontendFolder = __dirname; + +const dirs = fs + .readdirSync(path.join(frontendFolder, 'src'), { withFileTypes: true }) + .filter((dirent) => dirent.isDirectory()) + .map((dirent) => dirent.name) + .join('|'); + +module.exports = { + root: true, + + parser: '@babel/eslint-parser', + + env: { + browser: true, + commonjs: true, + node: true, + es6: true + }, + + globals: { + expect: false, + chai: false, + sinon: false, + JSX: true + }, + + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + babelOptions: { + configFile: `${frontendFolder}/babel.config.js` + }, + ecmaFeatures: { + modules: true, + impliedStrict: true + } + }, + + plugins: [ + 'filenames', + 'react', + 'react-hooks', + 'simple-import-sort', + 'import', + '@typescript-eslint', + 'prettier' + ], + + settings: { + react: { + version: 'detect' + } + }, + + rules: { + 'filenames/match-exported': ['error'], + + // ECMAScript 6 + + 'arrow-body-style': [0], + 'arrow-parens': ['error', 'always'], + 'arrow-spacing': ['error', { before: true, after: true }], + 'constructor-super': 'error', + 'generator-star-spacing': 'off', + 'no-class-assign': 'error', + 'no-confusing-arrow': 'error', + 'no-const-assign': 'error', + 'no-dupe-class-members': 'error', + 'no-duplicate-imports': 'error', + 'no-new-symbol': 'error', + 'no-this-before-super': 'error', + 'no-useless-escape': 'error', + 'no-useless-computed-key': 'error', + 'no-useless-constructor': 'error', + 'no-var': 'warn', + 'object-shorthand': ['error', 'properties'], + 'prefer-arrow-callback': 'error', + 'prefer-const': 'warn', + 'prefer-reflect': 'off', + 'prefer-rest-params': 'off', + 'prefer-spread': 'warn', + 'prefer-template': 'error', + 'require-yield': 'off', + 'template-curly-spacing': ['error', 'never'], + 'yield-star-spacing': 'off', + + // Possible Errors + + 'comma-dangle': 'error', + 'no-cond-assign': 'error', + 'no-console': 'off', + 'no-constant-condition': 'warn', + 'no-control-regex': 'error', + 'no-debugger': 'off', + 'no-dupe-args': 'error', + 'no-dupe-keys': 'error', + 'no-duplicate-case': 'error', + 'no-empty': 'warn', + 'no-empty-character-class': 'error', + 'no-ex-assign': 'error', + 'no-extra-boolean-cast': 'error', + 'no-extra-parens': ['error', 'functions'], + 'no-extra-semi': 'error', + 'no-func-assign': 'error', + 'no-inner-declarations': 'error', + 'no-invalid-regexp': 'error', + 'no-irregular-whitespace': 'error', + 'no-negated-in-lhs': 'error', + 'no-obj-calls': 'error', + 'no-regex-spaces': 'error', + 'no-sparse-arrays': 'error', + 'no-unexpected-multiline': 'error', + 'no-unreachable': 'warn', + 'no-unsafe-finally': 'error', + 'use-isnan': 'error', + 'valid-jsdoc': 'off', + 'valid-typeof': 'error', + + // Best Practices + + 'accessor-pairs': 'off', + 'array-callback-return': 'warn', + 'block-scoped-var': 'warn', + 'consistent-return': 'off', + curly: 'error', + 'default-case': 'error', + 'dot-location': ['error', 'property'], + 'dot-notation': 'error', + eqeqeq: ['error', 'smart'], + 'guard-for-in': 'error', + 'no-alert': 'warn', + 'no-caller': 'error', + 'no-case-declarations': 'error', + 'no-div-regex': 'error', + 'no-else-return': 'error', + 'no-empty-function': ['error', { allow: ['arrowFunctions'] }], + 'no-empty-pattern': 'error', + 'no-eval': 'error', + 'no-extend-native': 'error', + 'no-extra-bind': 'error', + 'no-fallthrough': 'error', + 'no-floating-decimal': 'error', + 'no-implicit-coercion': ['error', { + boolean: false, + number: true, + string: true, + allow: [/* "!!", "~", "*", "+" */] + }], + 'no-implicit-globals': 'error', + 'no-implied-eval': 'error', + 'no-invalid-this': 'off', + 'no-iterator': 'error', + 'no-labels': 'error', + 'no-lone-blocks': 'error', + 'no-loop-func': 'error', + 'no-magic-numbers': ['off', { ignoreArrayIndexes: true, ignore: [0, 1] }], + 'no-multi-spaces': 'error', + 'no-multi-str': 'error', + 'no-native-reassign': ['error', { exceptions: ['console'] }], + 'no-new': 'off', + 'no-new-func': 'error', + 'no-new-wrappers': 'error', + 'no-octal': 'error', + 'no-octal-escape': 'error', + 'no-param-reassign': 'off', + 'no-process-env': 'off', + 'no-proto': 'error', + 'no-redeclare': 'error', + 'no-return-assign': 'warn', + 'no-script-url': 'error', + 'no-self-assign': 'error', + 'no-self-compare': 'error', + 'no-sequences': 'error', + 'no-throw-literal': 'error', + 'no-unmodified-loop-condition': 'error', + 'no-unused-expressions': 'error', + 'no-unused-labels': 'error', + 'no-useless-call': 'error', + 'no-useless-concat': 'error', + 'no-void': 'error', + 'no-warning-comments': 'off', + 'no-with': 'error', + radix: ['error', 'as-needed'], + 'vars-on-top': 'off', + 'wrap-iife': ['error', 'inside'], + yoda: 'error', + + // Strict Mode + + strict: ['error', 'never'], + + // Variables + + 'init-declarations': ['error', 'always'], + 'no-catch-shadow': 'error', + 'no-delete-var': 'error', + 'no-label-var': 'error', + 'no-restricted-globals': 'off', + 'no-shadow': 'error', + 'no-shadow-restricted-names': 'error', + 'no-undef': 'error', + 'no-undef-init': 'off', + 'no-undefined': 'off', + 'no-unused-vars': ['error', { args: 'none', ignoreRestSiblings: true }], + 'no-use-before-define': 'error', + + // Node.js and CommonJS + + 'callback-return': 'warn', + 'global-require': 'error', + 'handle-callback-err': 'warn', + 'no-mixed-requires': 'error', + 'no-new-require': 'error', + 'no-path-concat': 'error', + 'no-process-exit': 'error', + + // Stylistic Issues + + 'array-bracket-spacing': ['error', 'never'], + 'block-spacing': ['error', 'always'], + 'brace-style': ['error', '1tbs', { allowSingleLine: false }], + camelcase: 'off', + 'comma-spacing': ['error', { before: false, after: true }], + 'comma-style': ['error', 'last'], + 'computed-property-spacing': ['error', 'never'], + 'consistent-this': ['error', 'self'], + 'eol-last': 'error', + 'func-names': 'off', + 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], + indent: ['error', 2, { SwitchCase: 1 }], + 'key-spacing': ['error', { beforeColon: false, afterColon: true }], + 'keyword-spacing': ['error', { before: true, after: true }], + 'lines-around-comment': ['error', { beforeBlockComment: true, afterBlockComment: false }], + 'max-depth': ['error', { maximum: 5 }], + 'max-nested-callbacks': ['error', 4], + 'max-statements': 'off', + 'max-statements-per-line': ['error', { max: 1 }], + 'new-cap': ['error', { capIsNewExceptions: ['$.Deferred', 'DragDropContext', 'DragLayer', 'DragSource', 'DropTarget'] }], + 'new-parens': 'error', + 'newline-after-var': 'off', + 'newline-before-return': 'off', + 'newline-per-chained-call': 'off', + 'no-array-constructor': 'error', + 'no-bitwise': 'error', + 'no-continue': 'error', + 'no-inline-comments': 'off', + 'no-lonely-if': 'warn', + 'no-mixed-spaces-and-tabs': 'error', + 'no-multiple-empty-lines': ['error', { max: 1 }], + 'no-negated-condition': 'warn', + 'no-nested-ternary': 'error', + 'no-new-object': 'error', + 'no-plusplus': 'off', + 'no-restricted-syntax': 'off', + 'no-spaced-func': 'error', + 'no-ternary': 'off', + 'no-trailing-spaces': 'error', + 'no-underscore-dangle': ['error', { allowAfterThis: true }], + 'no-unneeded-ternary': 'error', + 'no-whitespace-before-property': 'error', + 'object-curly-spacing': ['error', 'always'], + 'one-var': ['error', 'never'], + 'one-var-declaration-per-line': ['error', 'always'], + 'operator-assignment': ['off', 'never'], + 'operator-linebreak': ['error', 'after'], + 'quote-props': ['error', 'as-needed'], + quotes: ['error', 'single'], + 'require-jsdoc': 'off', + semi: 'error', + 'semi-spacing': ['error', { before: false, after: true }], + 'sort-vars': 'off', + 'space-before-blocks': ['error', 'always'], + 'space-before-function-paren': ['error', 'never'], + 'space-in-parens': 'off', + 'space-infix-ops': 'off', + 'space-unary-ops': 'off', + 'spaced-comment': 'error', + 'wrap-regex': 'error', + + // ImportSort + + 'simple-import-sort/imports': 'error', + 'import/newline-after-import': 'error', + + // React + + 'react/jsx-boolean-value': [2, 'always'], + 'react/jsx-uses-vars': 2, + 'react/jsx-closing-bracket-location': 2, + 'react/jsx-tag-spacing': ['error'], + 'react/jsx-curly-spacing': [2, 'never'], + 'react/jsx-equals-spacing': [2, 'never'], + 'react/jsx-indent-props': [2, 2], + 'react/jsx-indent': [2, 2, { indentLogicalExpressions: true }], + 'react/jsx-key': 2, + 'react/jsx-no-bind': [2, { allowArrowFunctions: true }], + 'react/jsx-no-duplicate-props': [2, { ignoreCase: true }], + 'react/jsx-max-props-per-line': [2, { maximum: 2 }], + 'react/jsx-handler-names': [2, { eventHandlerPrefix: '(on|dispatch)', eventHandlerPropPrefix: 'on' }], + 'react/jsx-no-undef': 2, + 'react/jsx-pascal-case': 2, + 'react/jsx-uses-react': 2, + // Explicitly disabled in case we want to enable them again + 'react/no-did-mount-set-state': 0, + 'react/no-did-update-set-state': 0, + 'react/no-direct-mutation-state': 2, + 'react/no-multi-comp': [2, { ignoreStateless: true }], + 'react/no-unknown-property': 2, + 'react/prefer-es6-class': 2, + 'react/prop-types': 2, + 'react/react-in-jsx-scope': 2, + 'react/self-closing-comp': 2, + 'react/sort-comp': 2, + 'react/jsx-wrap-multilines': 2, + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'error' + }, + overrides: [ + { + files: [ + '*.js' + ], + rules: { + 'simple-import-sort/imports': [ + 'error', + { + groups: [ + // Packages + // Absolute Paths + // Relative Paths + // Css + ['^@?\\w', `^(${dirs})(/.*|$)`, '^\\.', '^\\..*css$'] + ] + } + ] + } + }, + { + files: [ + '*.ts', + '*.tsx' + ], + + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.json' + }, + + extends: [ + 'prettier' + ], + + rules: Object.assign(typescriptEslintRecommended.rules, { + 'no-shadow': 'off', + // These should be enabled after cleaning things up + '@typescript-eslint/no-unused-vars': 'warn', + '@typescript-eslint/explicit-function-return-type': 'off', + 'react/prop-types': 'off', + 'prettier/prettier': 'error', + 'simple-import-sort/imports': [ + 'error', + { + groups: [ + // Packages + // Absolute Paths + // Relative Paths + // Css + ['^@?\\w', `^(${dirs})(/.*|$)`, '^\\.', '^\\..*css$'] + ] + } + ] + }) + }, + { + files: [ + '*.css.d.ts' + ], + rules: { + 'filenames/match-exported': 'off', + 'init-declarations': 'off', + 'prettier/prettier': 'off' + } + } + ] +}; diff --git a/frontend/.jsbeautifyrc b/frontend/.jsbeautifyrc deleted file mode 100644 index 50aa6aa29..000000000 --- a/frontend/.jsbeautifyrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "js": { - "indent_size": 2, - "indent_char": " ", - "indent_level": 2, - "indent_with_tabs": false, - "preserve_newlines": true, - "brace_style": "collapse", - "max_preserve_newlines": 2, - "jslint_happy": true - } -} \ No newline at end of file diff --git a/frontend/.prettierignore b/frontend/.prettierignore new file mode 100644 index 000000000..3e6367c54 --- /dev/null +++ b/frontend/.prettierignore @@ -0,0 +1,10 @@ +# Ignore everything recursively +* + +# But not the .ts files +!*.ts* + +*css.d.ts + +# Check subdirectories too +!*/ diff --git a/frontend/.prettierrc.json b/frontend/.prettierrc.json new file mode 100644 index 000000000..2f91ee691 --- /dev/null +++ b/frontend/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "arrowParens": "always", + "endOfLine": "auto", + "singleQuote": true, + "trailingComma": "es5" +} diff --git a/frontend/.stylelintrc b/frontend/.stylelintrc index 5587e5d4d..f19357a4c 100644 --- a/frontend/.stylelintrc +++ b/frontend/.stylelintrc @@ -1,12 +1,12 @@ { -"plugins": [ - "stylelint-order" -], -"ignoreFiles": [ - "frontend/src/Styles/scaffolding.css", - "**/*.js" -], -"rules": { + "plugins": [ + "stylelint-order" + ], + "ignoreFiles": [ + "frontend/src/Styles/scaffolding.css", + "**/*.js" + ], + "rules": { "at-rule-empty-line-before": [ "always", { @@ -15,9 +15,6 @@ ] } ], - "at-rule-name-case": "lower", - "at-rule-name-newline-after": "always-multi-line", - "at-rule-name-space-after": "always", "at-rule-no-unknown": [ true, { @@ -28,83 +25,36 @@ } ], "at-rule-no-vendor-prefix": true, - "at-rule-semicolon-newline-after": "always", - "at-rule-semicolon-space-before": "never", - "block-closing-brace-empty-line-before": "never", - "block-closing-brace-newline-after": "always", - "block-closing-brace-newline-before": "always", - "block-closing-brace-space-after": "always-single-line", - "block-closing-brace-space-before": "always-single-line", "block-no-empty": true, - "block-opening-brace-newline-after": "always", - "block-opening-brace-newline-before": "never-single-line", - "block-opening-brace-space-after": "always-single-line", - "block-opening-brace-space-before": "always", - "color-hex-case": "lower", "color-hex-length": "short", "color-named": "never", "color-no-invalid-hex": true, "comment-whitespace-inside": "always", - "declaration-bang-space-after": "never", - "declaration-bang-space-before": "always", "declaration-block-no-duplicate-properties": [ true, { "ignoreProperties": [ - "composes" + "composes" ] } ], "declaration-block-no-redundant-longhand-properties": true, "declaration-block-no-shorthand-property-overrides": true, - "declaration-block-semicolon-newline-after": "always", - "declaration-block-semicolon-newline-before": "never-multi-line", - "declaration-block-semicolon-space-before": "never", "declaration-block-single-line-max-declarations": 1, - "declaration-block-trailing-semicolon": "always", - "declaration-colon-space-after": "always", - "declaration-colon-space-before": "never", "font-family-name-quotes": "always-unless-keyword", "function-calc-no-unspaced-operator": true, - "function-comma-newline-after": "never-multi-line", - "function-comma-newline-before": "never-multi-line", - "function-comma-space-after": "always", - "function-comma-space-before": "never", "function-linear-gradient-no-nonstandard-direction": true, "function-name-case": "lower", - "function-parentheses-newline-inside": "never-multi-line", - "function-parentheses-space-inside": "never", "function-url-quotes": "always", - "function-url-scheme-blacklist": [ + "function-url-scheme-disallowed-list": [ "data" ], - "function-whitespace-after": "always", - "indentation": 2, "keyframe-declaration-no-important": true, "length-zero-no-unit": true, - "max-empty-lines": 1, - "max-line-length": [ - 100, - { - "ignore": [ - "non-comments" - ] - } - ], "max-nesting-depth": 2, - "media-feature-colon-space-after": "always", - "media-feature-colon-space-before": "never", - "media-feature-name-case": "lower", "media-feature-name-no-vendor-prefix": true, - "media-feature-range-operator-space-after": "always", - "media-feature-range-operator-space-before": "always", "no-empty-source": true, - "no-eol-whitespace": true, - "no-extra-semicolons": true, "no-invalid-double-slash-comments": true, - "no-missing-end-of-source-newline": true, - "number-leading-zero": "always", - "number-no-trailing-zeros": true, "order/order": [ "custom-properties", "dollar-variables", @@ -132,6 +82,7 @@ "right", "bottom", "left", + "inset", "z-index", "display", "visibility", @@ -343,54 +294,33 @@ ] } ], - "property-case": "lower", "property-no-vendor-prefix": true, "rule-empty-line-before": [ "always", { "except": [ - "first-nested" + "first-nested" ], "ignore": [ - "after-comment" + "after-comment" ] } ], - "selector-attribute-brackets-space-inside": "never", - "selector-attribute-operator-space-after": "never", - "selector-attribute-operator-space-before": "never", "selector-attribute-quotes": "never", "selector-class-pattern": "^[A-Za-z0-9]+$", - "selector-combinator-space-after": "always", - "selector-combinator-space-before": "always", - "selector-descendant-combinator-no-non-space": true, - "selector-list-comma-newline-after": "always", - "selector-list-comma-newline-before": "never-multi-line", - "selector-list-comma-space-before": "never", "selector-max-attribute": 0, "selector-max-class": 3, "selector-max-compound-selectors": 3, - "selector-max-empty-lines": 0, "selector-max-id": 0, "selector-max-universal": 0, - "selector-pseudo-class-case": "lower", - "selector-pseudo-class-parentheses-space-inside": "never", - "selector-pseudo-element-case": "lower", "selector-pseudo-element-colon-notation": "double", "selector-pseudo-element-no-unknown": true, "selector-type-case": "lower", "selector-type-no-unknown": true, "shorthand-property-no-redundant-values": true, "string-no-newline": true, - "string-quotes": "single", "time-min-milliseconds": 100, - "unit-case": "lower", "unit-no-unknown": true, - "value-list-comma-newline-after": "never-multi-line", - "value-list-comma-newline-before": "never-multi-line", - "value-list-comma-space-after": "always", - "value-list-comma-space-before": "never", - "value-list-max-empty-lines": 0, "value-no-vendor-prefix": true } -} +} \ No newline at end of file diff --git a/frontend/.vscode/extensions.json b/frontend/.vscode/extensions.json new file mode 100644 index 000000000..0e005a3cd --- /dev/null +++ b/frontend/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "stylelint.vscode-stylelint", + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode" + ] +} \ No newline at end of file diff --git a/frontend/.vscode/settings.json b/frontend/.vscode/settings.json new file mode 100644 index 000000000..8da95337f --- /dev/null +++ b/frontend/.vscode/settings.json @@ -0,0 +1,23 @@ +// Place your settings in this file to overwrite default and user settings. +{ + "files.insertFinalNewline": true, + + "files.exclude": { + "**/node_modules": true, + "**/*.d.css": true + }, + + "editor.formatOnSave": false, + "editor.codeActionsOnSave": { + "source.fixAll": "explicit" + }, + + "typescript.preferences.quoteStyle": "single", + + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact" + ], +} diff --git a/frontend/babel.config.js b/frontend/babel.config.js index fe855af63..ade9f24a2 100644 --- a/frontend/babel.config.js +++ b/frontend/babel.config.js @@ -2,22 +2,25 @@ const loose = true; module.exports = { plugins: [ + '@babel/plugin-transform-logical-assignment-operators', + // Stage 1 '@babel/plugin-proposal-export-default-from', - ['@babel/plugin-proposal-optional-chaining', { loose }], - ['@babel/plugin-proposal-nullish-coalescing-operator', { loose }], + ['@babel/plugin-transform-optional-chaining', { loose }], + ['@babel/plugin-transform-nullish-coalescing-operator', { loose }], // Stage 2 - '@babel/plugin-proposal-export-namespace-from', + '@babel/plugin-transform-export-namespace-from', // Stage 3 - ['@babel/plugin-proposal-class-properties', { loose }], + ['@babel/plugin-transform-class-properties', { loose }], '@babel/plugin-syntax-dynamic-import' ], env: { development: { presets: [ - ['@babel/preset-react', { development: true }] + ['@babel/preset-react', { development: true }], + '@babel/preset-typescript' ], plugins: [ 'babel-plugin-inline-classnames' @@ -25,7 +28,8 @@ module.exports = { }, production: { presets: [ - '@babel/preset-react' + '@babel/preset-react', + '@babel/preset-typescript' ], plugins: [ 'babel-plugin-transform-react-remove-prop-types' diff --git a/frontend/build/webpack.config.js b/frontend/build/webpack.config.js new file mode 100644 index 000000000..d1873380e --- /dev/null +++ b/frontend/build/webpack.config.js @@ -0,0 +1,291 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ +const path = require('path'); +const webpack = require('webpack'); +const FileManagerPlugin = require('filemanager-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const LiveReloadPlugin = require('webpack-livereload-plugin'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); +const TerserPlugin = require('terser-webpack-plugin'); +const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); + +module.exports = (env) => { + const uiFolder = 'UI'; + const frontendFolder = path.join(__dirname, '..'); + const srcFolder = path.join(frontendFolder, 'src'); + const isProduction = !!env.production; + const isProfiling = isProduction && !!env.profile; + const inlineWebWorkers = 'no-fallback'; + + const distFolder = path.resolve(frontendFolder, '..', '_output', uiFolder); + + console.log('Source Folder:', srcFolder); + console.log('Output Folder:', distFolder); + console.log('isProduction:', isProduction); + console.log('isProfiling:', isProfiling); + + const config = { + mode: isProduction ? 'production' : 'development', + devtool: isProduction ? 'source-map' : 'eval-source-map', + target: 'web', + + stats: { + children: false + }, + + watchOptions: { + ignored: /node_modules/ + }, + + entry: { + index: 'index.ts' + }, + + resolve: { + extensions: [ + '.ts', + '.tsx', + '.js' + ], + modules: [ + srcFolder, + path.join(srcFolder, 'Shims'), + 'node_modules' + ], + alias: { + jquery: 'jquery/dist/jquery.min', + 'react-middle-truncate': 'react-middle-truncate/lib/react-middle-truncate' + }, + fallback: { + buffer: false, + http: false, + https: false, + url: false, + util: false, + net: false + } + }, + + output: { + path: distFolder, + publicPath: '/', + filename: isProduction ? '[name]-[contenthash].js' : '[name].js', + sourceMapFilename: '[file].map' + }, + + optimization: { + moduleIds: 'deterministic', + chunkIds: isProduction ? 'deterministic' : 'named' + }, + + performance: { + hints: false + }, + + experiments: { + topLevelAwait: true + }, + + plugins: [ + new webpack.DefinePlugin({ + __DEV__: !isProduction, + 'process.env.NODE_ENV': isProduction ? JSON.stringify('production') : JSON.stringify('development') + }), + + new MiniCssExtractPlugin({ + filename: 'Content/styles.css', + chunkFilename: isProduction ? 'Content/[id]-[chunkhash].css' : 'Content/[id].css' + }), + + new HtmlWebpackPlugin({ + template: 'frontend/src/index.ejs', + filename: 'index.html', + publicPath: '/', + inject: false + }), + + new FileManagerPlugin({ + events: { + onEnd: { + copy: [ + // HTML + { + source: 'frontend/src/*.html', + destination: distFolder + }, + + // Fonts + { + source: 'frontend/src/Content/Fonts/*.*', + destination: path.join(distFolder, 'Content/Fonts') + }, + + // Icon Images + { + source: 'frontend/src/Content/Images/Icons/*.*', + destination: path.join(distFolder, 'Content/Images/Icons') + }, + + // Images + { + source: 'frontend/src/Content/Images/*.*', + destination: path.join(distFolder, 'Content/Images') + }, + + // Robots + { + source: 'frontend/src/Content/robots.txt', + destination: path.join(distFolder, 'Content/robots.txt') + }, + + // manifest.json and browserconfig.xml + { + source: 'frontend/src/Content/*.(json|xml)', + destination: path.join(distFolder, 'Content') + } + ] + } + } + }), + + new ForkTsCheckerWebpackPlugin(), + + new LiveReloadPlugin() + ], + + resolveLoader: { + modules: [ + 'node_modules', + 'frontend/build/webpack/' + ] + }, + + module: { + rules: [ + { + test: /\.worker\.js$/, + use: { + loader: 'worker-loader', + options: { + filename: '[name].js', + inline: inlineWebWorkers + } + } + }, + { + test: [/\.jsx?$/, /\.tsx?$/], + exclude: /(node_modules|JsLibraries)/, + use: [ + { + loader: 'babel-loader', + options: { + configFile: `${frontendFolder}/babel.config.js`, + envName: isProduction ? 'production' : 'development', + presets: [ + [ + '@babel/preset-env', + { + modules: false, + loose: true, + debug: false, + useBuiltIns: 'entry', + corejs: '3.41' + } + ] + ] + } + } + ] + }, + + // CSS Modules + { + test: /\.css$/, + exclude: /(node_modules|globals.css)/, + use: [ + { loader: MiniCssExtractPlugin.loader }, + { loader: 'css-modules-typescript-loader' }, + { + loader: 'css-loader', + options: { + importLoaders: 1, + modules: { + localIdentName: isProduction ? '[name]/[local]/[hash:base64:5]' : '[name]/[local]' + } + } + }, + { + loader: 'postcss-loader', + options: { + postcssOptions: { + config: 'frontend/postcss.config.js' + } + } + } + ] + }, + + // Global styles + { + test: /\.css$/, + include: /(node_modules|globals.css)/, + use: [ + 'style-loader', + { + loader: 'css-loader' + } + ] + }, + + // Fonts + { + test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, + use: [ + { + loader: 'url-loader', + options: { + limit: 10240, + mimetype: 'application/font-woff', + emitFile: false, + name: 'Content/Fonts/[name].[ext]' + } + } + ] + }, + + { + test: /\.(ttf|eot|eot?#iefix|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, + use: [ + { + loader: 'file-loader', + options: { + emitFile: false, + name: 'Content/Fonts/[name].[ext]' + } + } + ] + } + ] + } + }; + + if (isProfiling) { + config.resolve.alias['react-dom$'] = 'react-dom/profiling'; + config.resolve.alias['scheduler/tracing'] = 'scheduler/tracing-profiling'; + + config.optimization = { + minimize: true, + minimizer: [ + new TerserPlugin({ + terserOptions: { + sourceMap: true, // Must be set to true if using source-maps in production + mangle: false, + keep_classnames: true, + keep_fnames: true + } + }) + ] + }; + } + + return config; +}; diff --git a/frontend/gulp/webpack/css-variables-loader.js b/frontend/build/webpack/css-variables-loader.js similarity index 83% rename from frontend/gulp/webpack/css-variables-loader.js rename to frontend/build/webpack/css-variables-loader.js index 5683c98be..717d7d323 100644 --- a/frontend/gulp/webpack/css-variables-loader.js +++ b/frontend/build/webpack/css-variables-loader.js @@ -1,3 +1,4 @@ +// eslint-disable-next-line filenames/match-exported const loaderUtils = require('loader-utils'); module.exports = function cssVariablesLoader(source) { diff --git a/frontend/gulp/build.js b/frontend/gulp/build.js deleted file mode 100644 index de2da698f..000000000 --- a/frontend/gulp/build.js +++ /dev/null @@ -1,18 +0,0 @@ -const gulp = require('gulp'); - -require('./clean'); -require('./copy'); -require('./webpack'); - -gulp.task('build', - gulp.series('clean', - gulp.parallel( - 'webpack', - 'copyHtml', - 'copyFonts', - 'copyImages', - 'copyJs' - ) - ) -); - diff --git a/frontend/gulp/clean.js b/frontend/gulp/clean.js deleted file mode 100644 index ac2e4026f..000000000 --- a/frontend/gulp/clean.js +++ /dev/null @@ -1,8 +0,0 @@ -const gulp = require('gulp'); -const del = require('del'); - -const paths = require('./helpers/paths'); - -gulp.task('clean', () => { - return del([paths.dest.root]); -}); diff --git a/frontend/gulp/copy.js b/frontend/gulp/copy.js deleted file mode 100644 index 8d58ac4a4..000000000 --- a/frontend/gulp/copy.js +++ /dev/null @@ -1,45 +0,0 @@ -const path = require('path'); -const gulp = require('gulp'); -const print = require('gulp-print').default; -const cache = require('gulp-cached'); -const livereload = require('gulp-livereload'); -const paths = require('./helpers/paths.js'); - -gulp.task('copyJs', () => { - return gulp.src( - [ - path.join(paths.src.root, 'polyfills.js') - ], { base: paths.src.root }) - .pipe(cache('copyJs')) - .pipe(print()) - .pipe(gulp.dest(paths.dest.root)) - .pipe(livereload()); -}); - -gulp.task('copyHtml', () => { - return gulp.src(paths.src.html, { base: paths.src.root }) - .pipe(cache('copyHtml')) - .pipe(print()) - .pipe(gulp.dest(paths.dest.root)) - .pipe(livereload()); -}); - -gulp.task('copyFonts', () => { - return gulp.src( - path.join(paths.src.fonts, '**', '*.*'), { base: paths.src.root } - ) - .pipe(cache('copyFonts')) - .pipe(print()) - .pipe(gulp.dest(paths.dest.root)) - .pipe(livereload()); -}); - -gulp.task('copyImages', () => { - return gulp.src( - path.join(paths.src.images, '**', '*.*'), { base: paths.src.root } - ) - .pipe(cache('copyImages')) - .pipe(print()) - .pipe(gulp.dest(paths.dest.root)) - .pipe(livereload()); -}); diff --git a/frontend/gulp/gulpFile.js b/frontend/gulp/gulpFile.js deleted file mode 100644 index 64f14f654..000000000 --- a/frontend/gulp/gulpFile.js +++ /dev/null @@ -1,5 +0,0 @@ -require('./build.js'); -require('./clean.js'); -require('./copy.js'); -require('./watch.js'); -require('./webpack.js'); diff --git a/frontend/gulp/helpers/errorHandler.js b/frontend/gulp/helpers/errorHandler.js deleted file mode 100644 index 9c542398d..000000000 --- a/frontend/gulp/helpers/errorHandler.js +++ /dev/null @@ -1,6 +0,0 @@ -const colors = require('ansi-colors'); - -module.exports = function errorHandler(error) { - console.log(colors.red(`Error (${error.plugin}): ${error.message}`)); - this.emit('end'); -}; diff --git a/frontend/gulp/helpers/paths.js b/frontend/gulp/helpers/paths.js deleted file mode 100644 index 8707faec4..000000000 --- a/frontend/gulp/helpers/paths.js +++ /dev/null @@ -1,23 +0,0 @@ -const root = './frontend/src'; - -const paths = { - src: { - root, - html: `${root}/*.html`, - scripts: `${root}/**/*.js`, - content: `${root}/Content/`, - fonts: `${root}/Content/Fonts/`, - images: `${root}/Content/Images/`, - exclude: { - libs: `!${root}/JsLibraries/**` - } - }, - dest: { - root: './_output/UI/', - content: './_output/UI/Content/', - fonts: './_output/UI/Content/Fonts/', - images: './_output/UI/Content/Images/' - } -}; - -module.exports = paths; diff --git a/frontend/gulp/watch.js b/frontend/gulp/watch.js deleted file mode 100644 index f83a4bba4..000000000 --- a/frontend/gulp/watch.js +++ /dev/null @@ -1,18 +0,0 @@ -const gulp = require('gulp'); -const livereload = require('gulp-livereload'); -const gulpWatch = require('gulp-watch'); -const paths = require('./helpers/paths.js'); - -require('./copy.js'); -require('./webpack.js'); - -function watch() { - livereload.listen({ start: true }); - - gulp.task('webpackWatch')(); - gulpWatch(paths.src.html, gulp.series('copyHtml')); - gulpWatch(`${paths.src.fonts}**/*.*`, gulp.series('copyFonts')); - gulpWatch(`${paths.src.images}**/*.*`, gulp.series('copyImages')); -} - -gulp.task('watch', gulp.series('build', watch)); diff --git a/frontend/gulp/webpack.js b/frontend/gulp/webpack.js deleted file mode 100644 index bbef74e58..000000000 --- a/frontend/gulp/webpack.js +++ /dev/null @@ -1,202 +0,0 @@ -const gulp = require('gulp'); -const webpackStream = require('webpack-stream'); -const livereload = require('gulp-livereload'); -const path = require('path'); -const webpack = require('webpack'); -const errorHandler = require('./helpers/errorHandler'); -const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); - -const uiFolder = 'UI'; -const frontendFolder = path.join(__dirname, '..'); -const srcFolder = path.join(frontendFolder, 'src'); -const isProduction = process.argv.indexOf('--production') > -1; - -console.log('Source Folder:', srcFolder); -console.log('isProduction:', isProduction); - -const cssVarsFiles = [ - '../src/Styles/Variables/colors', - '../src/Styles/Variables/dimensions', - '../src/Styles/Variables/fonts', - '../src/Styles/Variables/animations', - '../src/Styles/Variables/zIndexes' -].map(require.resolve); - -const plugins = [ - new OptimizeCssAssetsPlugin({}), - - new webpack.DefinePlugin({ - __DEV__: !isProduction, - 'process.env.NODE_ENV': isProduction ? JSON.stringify('production') : JSON.stringify('development') - }), - - new MiniCssExtractPlugin({ - filename: path.join('_output', uiFolder, 'Content', 'styles.css') - }) -]; - -const config = { - mode: isProduction ? 'production' : 'development', - devtool: '#source-map', - - stats: { - children: false - }, - - watchOptions: { - ignored: /node_modules/ - }, - - entry: { - preload: 'preload.js', - vendor: 'vendor.js', - index: 'index.js' - }, - - resolve: { - modules: [ - srcFolder, - path.join(srcFolder, 'Shims'), - 'node_modules' - ], - alias: { - jquery: 'jquery/src/jquery' - } - }, - - output: { - filename: path.join('_output', uiFolder, '[name].js'), - sourceMapFilename: '[file].map' - }, - - optimization: { - chunkIds: 'named' - }, - - plugins, - - resolveLoader: { - modules: [ - 'node_modules', - 'frontend/gulp/webpack/' - ] - }, - - module: { - rules: [ - { - test: /\.js?$/, - exclude: /(node_modules|JsLibraries)/, - use: [ - { - loader: 'babel-loader', - options: { - configFile: `${frontendFolder}/babel.config.js`, - envName: isProduction ? 'production' : 'development', - presets: [ - [ - '@babel/preset-env', - { - modules: false, - loose: true, - debug: false, - useBuiltIns: 'entry', - corejs: 3 - } - ] - ] - } - } - ] - }, - - // CSS Modules - { - test: /\.css$/, - exclude: /(node_modules|globals.css)/, - use: [ - { loader: MiniCssExtractPlugin.loader }, - { - loader: 'css-loader', - options: { - importLoaders: 1, - modules: { - localIdentName: '[name]/[local]/[hash:base64:5]' - } - } - }, - { - loader: 'postcss-loader', - options: { - ident: 'postcss', - config: { - ctx: { - cssVarsFiles - }, - path: 'frontend/postcss.config.js' - } - } - } - ] - }, - - // Global styles - { - test: /\.css$/, - include: /(node_modules|globals.css)/, - use: [ - 'style-loader', - { - loader: 'css-loader' - } - ] - }, - - // Fonts - { - test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, - use: [ - { - loader: 'url-loader', - options: { - limit: 10240, - mimetype: 'application/font-woff', - emitFile: false, - name: 'Content/Fonts/[name].[ext]' - } - } - ] - }, - - { - test: /\.(ttf|eot|eot?#iefix|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, - use: [ - { - loader: 'file-loader', - options: { - emitFile: false, - name: 'Content/Fonts/[name].[ext]' - } - } - ] - } - ] - } -}; - -gulp.task('webpack', () => { - return webpackStream(config, webpack) - .pipe(gulp.dest('./')); -}); - -gulp.task('webpackWatch', () => { - config.watch = true; - - return webpackStream(config, webpack) - .on('error', errorHandler) - .pipe(gulp.dest('./')) - .on('error', errorHandler) - .pipe(livereload()) - .on('error', errorHandler); -}); diff --git a/frontend/jsconfig.json b/frontend/jsconfig.json new file mode 100644 index 000000000..329edb2e3 --- /dev/null +++ b/frontend/jsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "es6", + "checkJs": false, + "baseUrl": "src", + "jsx": "react", + "module": "commonjs", + "moduleResolution": "node", + "paths": { + "*": [ + "*" + ] + } + }, + "include": [ + "./src/**/*" + ], + "exclude": [ + ] +} diff --git a/frontend/postcss.config.js b/frontend/postcss.config.js index b0391ec6a..89db00f8c 100644 --- a/frontend/postcss.config.js +++ b/frontend/postcss.config.js @@ -1,23 +1,32 @@ const reload = require('require-nocache')(module); -module.exports = (ctx, configPath, options) => { - const config = { - plugins: { - 'postcss-mixins': { - mixinsDir: [ - 'frontend/src/Styles/Mixins' - ] - }, - 'postcss-simple-vars': { - variables: () => - ctx.options.cssVarsFiles.reduce((acc, vars) => { - return Object.assign(acc, reload(vars)); - }, {}) - }, - 'postcss-color-function': {}, - 'postcss-nested': {} - } - }; +const cssVarsFiles = [ + './src/Styles/Variables/dimensions', + './src/Styles/Variables/fonts', + './src/Styles/Variables/animations', + './src/Styles/Variables/zIndexes' +].map(require.resolve); - return config; +const mixinsFiles = [ + 'frontend/src/Styles/Mixins/cover.css', + 'frontend/src/Styles/Mixins/linkOverlay.css', + 'frontend/src/Styles/Mixins/scroller.css', + 'frontend/src/Styles/Mixins/truncate.css' +]; + +module.exports = { + plugins: [ + 'autoprefixer', + ['postcss-mixins', { + mixinsFiles + }], + ['postcss-simple-vars', { + variables: () => + cssVarsFiles.reduce((acc, vars) => { + return Object.assign(acc, reload(vars)); + }, {}) + }], + 'postcss-color-function', + 'postcss-nested' + ] }; diff --git a/frontend/src/.vscode/settings.json b/frontend/src/.vscode/settings.json deleted file mode 100644 index 0fb2bf460..000000000 --- a/frontend/src/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -// Place your settings in this file to overwrite default and user settings. -{ - "files.insertFinalNewline": true -} \ No newline at end of file diff --git a/frontend/src/Activity/Blacklist/Blacklist.js b/frontend/src/Activity/Blacklist/Blacklist.js deleted file mode 100644 index d93bec0bf..000000000 --- a/frontend/src/Activity/Blacklist/Blacklist.js +++ /dev/null @@ -1,123 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { align, icons } from 'Helpers/Props'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import Table from 'Components/Table/Table'; -import TableBody from 'Components/Table/TableBody'; -import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; -import TablePager from 'Components/Table/TablePager'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; -import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; -import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; -import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; -import BlacklistRowConnector from './BlacklistRowConnector'; - -class Blacklist extends Component { - - // - // Render - - render() { - const { - isFetching, - isPopulated, - error, - items, - columns, - totalRecords, - isClearingBlacklistExecuting, - onClearBlacklistPress, - ...otherProps - } = this.props; - - return ( - - - - - - - - - - - - - - - { - isFetching && !isPopulated && - - } - - { - !isFetching && !!error && -
Unable to load blacklist
- } - - { - isPopulated && !error && !items.length && -
- No history blacklist -
- } - - { - isPopulated && !error && !!items.length && -
- - - { - items.map((item) => { - return ( - - ); - }) - } - -
- - -
- } -
-
- ); - } -} - -Blacklist.propTypes = { - isFetching: PropTypes.bool.isRequired, - isPopulated: PropTypes.bool.isRequired, - error: PropTypes.object, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - totalRecords: PropTypes.number, - isClearingBlacklistExecuting: PropTypes.bool.isRequired, - onClearBlacklistPress: PropTypes.func.isRequired -}; - -export default Blacklist; diff --git a/frontend/src/Activity/Blacklist/BlacklistConnector.js b/frontend/src/Activity/Blacklist/BlacklistConnector.js deleted file mode 100644 index 466cc40b7..000000000 --- a/frontend/src/Activity/Blacklist/BlacklistConnector.js +++ /dev/null @@ -1,146 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; -import withCurrentPage from 'Components/withCurrentPage'; -import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; -import * as blacklistActions from 'Store/Actions/blacklistActions'; -import { executeCommand } from 'Store/Actions/commandActions'; -import * as commandNames from 'Commands/commandNames'; -import Blacklist from './Blacklist'; - -function createMapStateToProps() { - return createSelector( - (state) => state.blacklist, - createCommandExecutingSelector(commandNames.CLEAR_BLACKLIST), - (blacklist, isClearingBlacklistExecuting) => { - return { - isClearingBlacklistExecuting, - ...blacklist - }; - } - ); -} - -const mapDispatchToProps = { - ...blacklistActions, - executeCommand -}; - -class BlacklistConnector extends Component { - - // - // Lifecycle - - componentDidMount() { - const { - useCurrentPage, - fetchBlacklist, - gotoBlacklistFirstPage - } = this.props; - - registerPagePopulator(this.repopulate); - - if (useCurrentPage) { - fetchBlacklist(); - } else { - gotoBlacklistFirstPage(); - } - } - - componentDidUpdate(prevProps) { - if (prevProps.isClearingBlacklistExecuting && !this.props.isClearingBlacklistExecuting) { - this.props.gotoBlacklistFirstPage(); - } - } - - componentWillUnmount() { - this.props.clearBlacklist(); - unregisterPagePopulator(this.repopulate); - } - - // - // Control - - repopulate = () => { - this.props.fetchBlacklist(); - } - // - // Listeners - - onFirstPagePress = () => { - this.props.gotoBlacklistFirstPage(); - } - - onPreviousPagePress = () => { - this.props.gotoBlacklistPreviousPage(); - } - - onNextPagePress = () => { - this.props.gotoBlacklistNextPage(); - } - - onLastPagePress = () => { - this.props.gotoBlacklistLastPage(); - } - - onPageSelect = (page) => { - this.props.gotoBlacklistPage({ page }); - } - - onSortPress = (sortKey) => { - this.props.setBlacklistSort({ sortKey }); - } - - onTableOptionChange = (payload) => { - this.props.setBlacklistTableOption(payload); - - if (payload.pageSize) { - this.props.gotoBlacklistFirstPage(); - } - } - - onClearBlacklistPress = () => { - this.props.executeCommand({ name: commandNames.CLEAR_BLACKLIST }); - } - - // - // Render - - render() { - return ( - - ); - } -} - -BlacklistConnector.propTypes = { - useCurrentPage: PropTypes.bool.isRequired, - isClearingBlacklistExecuting: PropTypes.bool.isRequired, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - fetchBlacklist: PropTypes.func.isRequired, - gotoBlacklistFirstPage: PropTypes.func.isRequired, - gotoBlacklistPreviousPage: PropTypes.func.isRequired, - gotoBlacklistNextPage: PropTypes.func.isRequired, - gotoBlacklistLastPage: PropTypes.func.isRequired, - gotoBlacklistPage: PropTypes.func.isRequired, - setBlacklistSort: PropTypes.func.isRequired, - setBlacklistTableOption: PropTypes.func.isRequired, - clearBlacklist: PropTypes.func.isRequired, - executeCommand: PropTypes.func.isRequired -}; - -export default withCurrentPage( - connect(createMapStateToProps, mapDispatchToProps)(BlacklistConnector) -); diff --git a/frontend/src/Activity/Blocklist/Blocklist.js b/frontend/src/Activity/Blocklist/Blocklist.js new file mode 100644 index 000000000..ab43c106d --- /dev/null +++ b/frontend/src/Activity/Blocklist/Blocklist.js @@ -0,0 +1,268 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import Alert from 'Components/Alert'; +import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import ConfirmModal from 'Components/Modal/ConfirmModal'; +import PageContent from 'Components/Page/PageContent'; +import PageContentBody from 'Components/Page/PageContentBody'; +import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; +import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; +import Table from 'Components/Table/Table'; +import TableBody from 'Components/Table/TableBody'; +import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; +import TablePager from 'Components/Table/TablePager'; +import { align, icons, kinds } from 'Helpers/Props'; +import getRemovedItems from 'Utilities/Object/getRemovedItems'; +import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; +import translate from 'Utilities/String/translate'; +import getSelectedIds from 'Utilities/Table/getSelectedIds'; +import removeOldSelectedState from 'Utilities/Table/removeOldSelectedState'; +import selectAll from 'Utilities/Table/selectAll'; +import toggleSelected from 'Utilities/Table/toggleSelected'; +import BlocklistRowConnector from './BlocklistRowConnector'; + +class Blocklist extends Component { + + // + // Lifecycle + + constructor(props, context) { + super(props, context); + + this.state = { + allSelected: false, + allUnselected: false, + lastToggled: null, + selectedState: {}, + isConfirmRemoveModalOpen: false, + isConfirmClearModalOpen: false, + items: props.items + }; + } + + componentDidUpdate(prevProps) { + const { + items + } = this.props; + + if (hasDifferentItems(prevProps.items, items)) { + this.setState((state) => { + return { + ...removeOldSelectedState(state, getRemovedItems(prevProps.items, items)), + items + }; + }); + + return; + } + } + + // + // Control + + getSelectedIds = () => { + return getSelectedIds(this.state.selectedState); + }; + + // + // Listeners + + onSelectAllChange = ({ value }) => { + this.setState(selectAll(this.state.selectedState, value)); + }; + + onSelectedChange = ({ id, value, shiftKey = false }) => { + this.setState((state) => { + return toggleSelected(state, this.props.items, id, value, shiftKey); + }); + }; + + onRemoveSelectedPress = () => { + this.setState({ isConfirmRemoveModalOpen: true }); + }; + + onRemoveSelectedConfirmed = () => { + this.props.onRemoveSelected(this.getSelectedIds()); + this.setState({ isConfirmRemoveModalOpen: false }); + }; + + onConfirmRemoveModalClose = () => { + this.setState({ isConfirmRemoveModalOpen: false }); + }; + + onClearBlocklistPress = () => { + this.setState({ isConfirmClearModalOpen: true }); + }; + + onClearBlocklistConfirmed = () => { + this.props.onClearBlocklistPress(); + this.setState({ isConfirmClearModalOpen: false }); + }; + + onConfirmClearModalClose = () => { + this.setState({ isConfirmClearModalOpen: false }); + }; + + // + // Render + + render() { + const { + isFetching, + isPopulated, + isArtistFetching, + isArtistPopulated, + error, + items, + columns, + totalRecords, + isRemoving, + isClearingBlocklistExecuting, + ...otherProps + } = this.props; + + const isAllPopulated = isPopulated && isArtistPopulated; + const isAnyFetching = isFetching || isArtistFetching; + + const { + allSelected, + allUnselected, + selectedState, + isConfirmRemoveModalOpen, + isConfirmClearModalOpen + } = this.state; + + const selectedIds = this.getSelectedIds(); + + return ( + + + + + + + + + + + + + + + + + { + isAnyFetching && !isAllPopulated && + + } + + { + !isAnyFetching && !!error && + + {translate('UnableToLoadBlocklist')} + + } + + { + isAllPopulated && !error && !items.length && + + {translate('NoHistoryBlocklist')} + + } + + { + isAllPopulated && !error && !!items.length && +
+ + + { + items.map((item) => { + return ( + + ); + }) + } + +
+ + +
+ } +
+ + + + +
+ ); + } +} + +Blocklist.propTypes = { + isArtistFetching: PropTypes.bool.isRequired, + isArtistPopulated: PropTypes.bool.isRequired, + isFetching: PropTypes.bool.isRequired, + isPopulated: PropTypes.bool.isRequired, + error: PropTypes.object, + items: PropTypes.arrayOf(PropTypes.object).isRequired, + columns: PropTypes.arrayOf(PropTypes.object).isRequired, + totalRecords: PropTypes.number, + isRemoving: PropTypes.bool.isRequired, + isClearingBlocklistExecuting: PropTypes.bool.isRequired, + onRemoveSelected: PropTypes.func.isRequired, + onClearBlocklistPress: PropTypes.func.isRequired +}; + +export default Blocklist; diff --git a/frontend/src/Activity/Blocklist/BlocklistConnector.js b/frontend/src/Activity/Blocklist/BlocklistConnector.js new file mode 100644 index 000000000..d810d1c0f --- /dev/null +++ b/frontend/src/Activity/Blocklist/BlocklistConnector.js @@ -0,0 +1,155 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; +import * as commandNames from 'Commands/commandNames'; +import withCurrentPage from 'Components/withCurrentPage'; +import * as blocklistActions from 'Store/Actions/blocklistActions'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; +import Blocklist from './Blocklist'; + +function createMapStateToProps() { + return createSelector( + (state) => state.blocklist, + (state) => state.artist, + createCommandExecutingSelector(commandNames.CLEAR_BLOCKLIST), + (blocklist, artist, isClearingBlocklistExecuting) => { + return { + isArtistFetching: artist.isFetching, + isArtistPopulated: artist.isPopulated, + isClearingBlocklistExecuting, + ...blocklist + }; + } + ); +} + +const mapDispatchToProps = { + ...blocklistActions, + executeCommand +}; + +class BlocklistConnector extends Component { + + // + // Lifecycle + + componentDidMount() { + const { + useCurrentPage, + fetchBlocklist, + gotoBlocklistFirstPage + } = this.props; + + registerPagePopulator(this.repopulate); + + if (useCurrentPage) { + fetchBlocklist(); + } else { + gotoBlocklistFirstPage(); + } + } + + componentDidUpdate(prevProps) { + if (prevProps.isClearingBlocklistExecuting && !this.props.isClearingBlocklistExecuting) { + this.props.gotoBlocklistFirstPage(); + } + } + + componentWillUnmount() { + this.props.clearBlocklist(); + unregisterPagePopulator(this.repopulate); + } + + // + // Control + + repopulate = () => { + this.props.fetchBlocklist(); + }; + // + // Listeners + + onFirstPagePress = () => { + this.props.gotoBlocklistFirstPage(); + }; + + onPreviousPagePress = () => { + this.props.gotoBlocklistPreviousPage(); + }; + + onNextPagePress = () => { + this.props.gotoBlocklistNextPage(); + }; + + onLastPagePress = () => { + this.props.gotoBlocklistLastPage(); + }; + + onPageSelect = (page) => { + this.props.gotoBlocklistPage({ page }); + }; + + onRemoveSelected = (ids) => { + this.props.removeBlocklistItems({ ids }); + }; + + onSortPress = (sortKey) => { + this.props.setBlocklistSort({ sortKey }); + }; + + onTableOptionChange = (payload) => { + this.props.setBlocklistTableOption(payload); + + if (payload.pageSize) { + this.props.gotoBlocklistFirstPage(); + } + }; + + onClearBlocklistPress = () => { + this.props.executeCommand({ name: commandNames.CLEAR_BLOCKLIST }); + }; + + // + // Render + + render() { + return ( + + ); + } +} + +BlocklistConnector.propTypes = { + useCurrentPage: PropTypes.bool.isRequired, + isClearingBlocklistExecuting: PropTypes.bool.isRequired, + items: PropTypes.arrayOf(PropTypes.object).isRequired, + fetchBlocklist: PropTypes.func.isRequired, + gotoBlocklistFirstPage: PropTypes.func.isRequired, + gotoBlocklistPreviousPage: PropTypes.func.isRequired, + gotoBlocklistNextPage: PropTypes.func.isRequired, + gotoBlocklistLastPage: PropTypes.func.isRequired, + gotoBlocklistPage: PropTypes.func.isRequired, + removeBlocklistItems: PropTypes.func.isRequired, + setBlocklistSort: PropTypes.func.isRequired, + setBlocklistTableOption: PropTypes.func.isRequired, + clearBlocklist: PropTypes.func.isRequired, + executeCommand: PropTypes.func.isRequired +}; + +export default withCurrentPage( + connect(createMapStateToProps, mapDispatchToProps)(BlocklistConnector) +); diff --git a/frontend/src/Activity/Blacklist/BlacklistDetailsModal.js b/frontend/src/Activity/Blocklist/BlocklistDetailsModal.js similarity index 84% rename from frontend/src/Activity/Blacklist/BlacklistDetailsModal.js rename to frontend/src/Activity/Blocklist/BlocklistDetailsModal.js index 356512a9d..506fa0129 100644 --- a/frontend/src/Activity/Blacklist/BlacklistDetailsModal.js +++ b/frontend/src/Activity/Blocklist/BlocklistDetailsModal.js @@ -1,15 +1,16 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import Button from 'Components/Link/Button'; import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import Button from 'Components/Link/Button'; import Modal from 'Components/Modal/Modal'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import translate from 'Utilities/String/translate'; -class BlacklistDetailsModal extends Component { +class BlocklistDetailsModal extends Component { // // Render @@ -39,19 +40,19 @@ class BlacklistDetailsModal extends Component { { !!message && } @@ -59,7 +60,7 @@ class BlacklistDetailsModal extends Component { { !!message && } @@ -77,7 +78,7 @@ class BlacklistDetailsModal extends Component { } } -BlacklistDetailsModal.propTypes = { +BlocklistDetailsModal.propTypes = { isOpen: PropTypes.bool.isRequired, sourceTitle: PropTypes.string.isRequired, protocol: PropTypes.string.isRequired, @@ -86,4 +87,4 @@ BlacklistDetailsModal.propTypes = { onModalClose: PropTypes.func.isRequired }; -export default BlacklistDetailsModal; +export default BlocklistDetailsModal; diff --git a/frontend/src/Activity/Blacklist/BlacklistRow.css b/frontend/src/Activity/Blocklist/BlocklistRow.css similarity index 100% rename from frontend/src/Activity/Blacklist/BlacklistRow.css rename to frontend/src/Activity/Blocklist/BlocklistRow.css diff --git a/frontend/src/Activity/Blocklist/BlocklistRow.css.d.ts b/frontend/src/Activity/Blocklist/BlocklistRow.css.d.ts new file mode 100644 index 000000000..a608ab3d2 --- /dev/null +++ b/frontend/src/Activity/Blocklist/BlocklistRow.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'indexer': string; + 'quality': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Blacklist/BlacklistRow.js b/frontend/src/Activity/Blocklist/BlocklistRow.js similarity index 77% rename from frontend/src/Activity/Blacklist/BlacklistRow.js rename to frontend/src/Activity/Blocklist/BlocklistRow.js index 31813a41d..9dcfc47cd 100644 --- a/frontend/src/Activity/Blacklist/BlacklistRow.js +++ b/frontend/src/Activity/Blocklist/BlocklistRow.js @@ -1,16 +1,19 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons, kinds } from 'Helpers/Props'; -import IconButton from 'Components/Link/IconButton'; -import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; -import TableRow from 'Components/Table/TableRow'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import AlbumFormats from 'Album/AlbumFormats'; import TrackQuality from 'Album/TrackQuality'; import ArtistNameLink from 'Artist/ArtistNameLink'; -import BlacklistDetailsModal from './BlacklistDetailsModal'; -import styles from './BlacklistRow.css'; +import IconButton from 'Components/Link/IconButton'; +import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; +import TableRow from 'Components/Table/TableRow'; +import { icons, kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import BlocklistDetailsModal from './BlocklistDetailsModal'; +import styles from './BlocklistRow.css'; -class BlacklistRow extends Component { +class BlocklistRow extends Component { // // Lifecycle @@ -28,25 +31,29 @@ class BlacklistRow extends Component { onDetailsPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; // // Render render() { const { + id, artist, sourceTitle, quality, + customFormats, date, protocol, indexer, message, + isSelected, columns, + onSelectedChange, onRemovePress } = this.props; @@ -56,6 +63,12 @@ class BlacklistRow extends Component { return ( + + { columns.map((column) => { const { @@ -67,7 +80,7 @@ class BlacklistRow extends Component { return null; } - if (name === 'artist.sortName') { + if (name === 'artists.sortName') { return ( + + + ); + } + if (name === 'date') { return ( {formatMissing(oldValue)} {formatMissing(newValue)} +
+ {formatMissing(oldValue)} {formatMissing(newValue)} +
); } @@ -56,6 +60,7 @@ function HistoryDetails(props) { eventType, sourceTitle, data, + downloadId, shortDateFormat, timeFormat } = props; @@ -64,83 +69,102 @@ function HistoryDetails(props) { const { indexer, releaseGroup, + customFormatScore, nzbInfoUrl, downloadClient, - downloadId, + downloadClientName, age, ageHours, ageMinutes, publishedDate } = data; + const downloadClientNameInfo = downloadClientName ?? downloadClient; + return ( { - !!indexer && + indexer ? + /> : + null } { - !!releaseGroup && + releaseGroup ? + /> : + null } { - !!nzbInfoUrl && + customFormatScore && customFormatScore !== '0' ? + : + null + } + + { + nzbInfoUrl ? - Info URL + {translate('InfoUrl')} {nzbInfoUrl} - + : + null } { - !!downloadClient && + downloadClientNameInfo ? + title={translate('DownloadClient')} + data={downloadClientNameInfo} + /> : + null } { - !!downloadId && + downloadId ? + /> : + null } { - !!indexer && + age || ageHours || ageMinutes ? + /> : + null } { - !!publishedDate && + publishedDate ? + /> : + null } ); @@ -148,23 +172,42 @@ function HistoryDetails(props) { if (eventType === 'downloadFailed') { const { - message + message, + indexer } = data; return ( { - !!message && + downloadId ? : + null + } + + { + indexer ? ( + + ) : null} + + { + message ? + : + null } ); @@ -172,6 +215,7 @@ function HistoryDetails(props) { if (eventType === 'trackFileImported') { const { + customFormatScore, droppedPath, importedPath } = data; @@ -180,26 +224,37 @@ function HistoryDetails(props) { { - !!droppedPath && + droppedPath ? + /> : + null } { - !!importedPath && + importedPath ? + /> : + null + } + + { + customFormatScore && customFormatScore !== '0' ? + : + null } ); @@ -207,7 +262,8 @@ function HistoryDetails(props) { if (eventType === 'trackFileDeleted') { const { - reason + reason, + customFormatScore } = data; let reasonMessage = ''; @@ -217,7 +273,7 @@ function HistoryDetails(props) { reasonMessage = 'File was deleted by via UI'; break; case 'MissingFromDisk': - reasonMessage = 'Lidarr was unable to find the file on disk so it was removed'; + reasonMessage = 'Lidarr was unable to find the file on disk so the file was unlinked from the album/track in the database'; break; case 'Upgrade': reasonMessage = 'File was deleted to import an upgrade'; @@ -229,14 +285,23 @@ function HistoryDetails(props) { return ( + + { + customFormatScore && customFormatScore !== '0' ? + : + null + } ); } @@ -244,32 +309,20 @@ function HistoryDetails(props) { if (eventType === 'trackFileRenamed') { const { sourcePath, - sourceRelativePath, - path, - relativePath + path } = data; return ( - - - - ); } @@ -283,7 +336,7 @@ function HistoryDetails(props) { return ( { @@ -298,7 +351,7 @@ function HistoryDetails(props) { }) } : } /> @@ -313,14 +366,14 @@ function HistoryDetails(props) { return ( { !!statusMessages && } @@ -332,9 +385,9 @@ function HistoryDetails(props) { const { indexer, releaseGroup, + customFormatScore, nzbInfoUrl, downloadClient, - downloadId, age, ageHours, ageMinutes, @@ -344,69 +397,119 @@ function HistoryDetails(props) { return ( { - !!indexer && + indexer ? + /> : + null } { - !!releaseGroup && + releaseGroup ? + /> : + null } { - !!nzbInfoUrl && + customFormatScore && customFormatScore !== '0' ? + : + null + } + + { + nzbInfoUrl ? - Info URL + {translate('InfoUrl')} {nzbInfoUrl} - + : + null } { - !!downloadClient && + downloadClient ? + /> : + null } { - !!downloadId && + downloadId ? + /> : + null } { - !!indexer && + age || ageHours || ageMinutes ? + /> : + null } { - !!publishedDate && + publishedDate ? + /> : + null + } + + ); + } + + if (eventType === 'downloadIgnored') { + const { + message + } = data; + + return ( + + + + { + downloadId ? + : + null + } + + { + message ? + : + null } ); @@ -416,7 +519,7 @@ function HistoryDetails(props) { @@ -427,6 +530,7 @@ HistoryDetails.propTypes = { eventType: PropTypes.string.isRequired, sourceTitle: PropTypes.string.isRequired, data: PropTypes.object.isRequired, + downloadId: PropTypes.string, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired }; diff --git a/frontend/src/Activity/History/Details/HistoryDetailsModal.css.d.ts b/frontend/src/Activity/History/Details/HistoryDetailsModal.css.d.ts new file mode 100644 index 000000000..a8cc499e2 --- /dev/null +++ b/frontend/src/Activity/History/Details/HistoryDetailsModal.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'markAsFailedButton': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/History/Details/HistoryDetailsModal.js b/frontend/src/Activity/History/Details/HistoryDetailsModal.js index 865024491..5362a2f43 100644 --- a/frontend/src/Activity/History/Details/HistoryDetailsModal.js +++ b/frontend/src/Activity/History/Details/HistoryDetailsModal.js @@ -1,13 +1,13 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { kinds } from 'Helpers/Props'; import Button from 'Components/Link/Button'; import SpinnerButton from 'Components/Link/SpinnerButton'; import Modal from 'Components/Modal/Modal'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { kinds } from 'Helpers/Props'; import HistoryDetails from './HistoryDetails'; import styles from './HistoryDetailsModal.css'; @@ -29,6 +29,8 @@ function getHeaderTitle(eventType) { return 'Album Import Incomplete'; case 'downloadImported': return 'Download Completed'; + case 'downloadIgnored': + return 'Download Ignored'; default: return 'Unknown'; } @@ -40,6 +42,7 @@ function HistoryDetailsModal(props) { eventType, sourceTitle, data, + downloadId, isMarkingAsFailed, shortDateFormat, timeFormat, @@ -62,6 +65,7 @@ function HistoryDetailsModal(props) { eventType={eventType} sourceTitle={sourceTitle} data={data} + downloadId={downloadId} shortDateFormat={shortDateFormat} timeFormat={timeFormat} /> @@ -96,6 +100,7 @@ HistoryDetailsModal.propTypes = { eventType: PropTypes.string.isRequired, sourceTitle: PropTypes.string.isRequired, data: PropTypes.object.isRequired, + downloadId: PropTypes.string, isMarkingAsFailed: PropTypes.bool.isRequired, shortDateFormat: PropTypes.string.isRequired, timeFormat: PropTypes.string.isRequired, diff --git a/frontend/src/Activity/History/History.js b/frontend/src/Activity/History/History.js index a525d9988..d144a5402 100644 --- a/frontend/src/Activity/History/History.js +++ b/frontend/src/Activity/History/History.js @@ -1,18 +1,21 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { align, icons } from 'Helpers/Props'; -import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; +import Alert from 'Components/Alert'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import FilterMenu from 'Components/Menu/FilterMenu'; +import PageContent from 'Components/Page/PageContent'; +import PageContentBody from 'Components/Page/PageContentBody'; +import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; +import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; import TablePager from 'Components/Table/TablePager'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; -import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; -import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; -import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; -import FilterMenu from 'Components/Menu/FilterMenu'; +import { align, icons, kinds } from 'Helpers/Props'; +import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; +import translate from 'Utilities/String/translate'; +import HistoryFilterModal from './HistoryFilterModal'; import HistoryRowConnector from './HistoryRowConnector'; class History extends Component { @@ -50,7 +53,10 @@ class History extends Component { columns, selectedFilterKey, filters, + customFilters, totalRecords, + isArtistFetching, + isArtistPopulated, isAlbumsFetching, isAlbumsPopulated, albumsError, @@ -59,16 +65,16 @@ class History extends Component { ...otherProps } = this.props; - const isFetchingAny = isFetching || isAlbumsFetching; - const isAllPopulated = isPopulated && (isAlbumsPopulated || !items.length); + const isFetchingAny = isFetching || isArtistFetching || isAlbumsFetching; + const isAllPopulated = isPopulated && ((isArtistPopulated && isAlbumsPopulated) || !items.length); const hasError = error || albumsError; return ( - + @@ -90,13 +96,14 @@ class History extends Component { alignMenu={align.RIGHT} selectedFilterKey={selectedFilterKey} filters={filters} - customFilters={[]} + customFilters={customFilters} + filterModalConnectorComponent={HistoryFilterModal} onFilterSelect={onFilterSelect} /> - + { isFetchingAny && !isAllPopulated && @@ -104,7 +111,9 @@ class History extends Component { { !isFetchingAny && hasError && -
Unable to load history
+ + {translate('UnableToLoadHistory')} + } { @@ -112,9 +121,9 @@ class History extends Component { // wait for the albums to populate because they are never coming. isPopulated && !hasError && !items.length && -
- No history found -
+ + {translate('NoHistory')} + } { @@ -147,7 +156,7 @@ class History extends Component { /> } -
+
); } @@ -159,9 +168,12 @@ History.propTypes = { error: PropTypes.object, items: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, - selectedFilterKey: PropTypes.string.isRequired, + selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired, + customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, totalRecords: PropTypes.number, + isArtistFetching: PropTypes.bool.isRequired, + isArtistPopulated: PropTypes.bool.isRequired, isAlbumsFetching: PropTypes.bool.isRequired, isAlbumsPopulated: PropTypes.bool.isRequired, albumsError: PropTypes.object, diff --git a/frontend/src/Activity/History/HistoryConnector.js b/frontend/src/Activity/History/HistoryConnector.js index d8ca60839..2b3354bc5 100644 --- a/frontend/src/Activity/History/HistoryConnector.js +++ b/frontend/src/Activity/History/HistoryConnector.js @@ -2,28 +2,34 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; +import withCurrentPage from 'Components/withCurrentPage'; +import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; +import * as historyActions from 'Store/Actions/historyActions'; +import { clearTracks, fetchTracks } from 'Store/Actions/trackActions'; +import { createCustomFiltersSelector } from 'Store/Selectors/createClientSideCollectionSelector'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; -import withCurrentPage from 'Components/withCurrentPage'; -import * as historyActions from 'Store/Actions/historyActions'; -import { fetchAlbums, clearAlbums } from 'Store/Actions/albumActions'; -import { fetchTracks, clearTracks } from 'Store/Actions/trackActions'; +import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; import History from './History'; function createMapStateToProps() { return createSelector( (state) => state.history, + (state) => state.artist, (state) => state.albums, (state) => state.tracks, - (history, albums, tracks) => { + createCustomFiltersSelector('history'), + (history, artist, albums, tracks, customFilters) => { return { + isArtistFetching: artist.isFetching, + isArtistPopulated: artist.isPopulated, isAlbumsFetching: albums.isFetching, isAlbumsPopulated: albums.isPopulated, albumsError: albums.error, isTracksFetching: tracks.isFetching, isTracksPopulated: tracks.isPopulated, tracksError: tracks.error, + customFilters, ...history }; } @@ -88,38 +94,38 @@ class HistoryConnector extends Component { repopulate = () => { this.props.fetchHistory(); - } + }; // // Listeners onFirstPagePress = () => { this.props.gotoHistoryFirstPage(); - } + }; onPreviousPagePress = () => { this.props.gotoHistoryPreviousPage(); - } + }; onNextPagePress = () => { this.props.gotoHistoryNextPage(); - } + }; onLastPagePress = () => { this.props.gotoHistoryLastPage(); - } + }; onPageSelect = (page) => { this.props.gotoHistoryPage({ page }); - } + }; onSortPress = (sortKey) => { this.props.setHistorySort({ sortKey }); - } + }; onFilterSelect = (selectedFilterKey) => { this.props.setHistoryFilter({ selectedFilterKey }); - } + }; onTableOptionChange = (payload) => { this.props.setHistoryTableOption(payload); @@ -127,7 +133,7 @@ class HistoryConnector extends Component { if (payload.pageSize) { this.props.gotoHistoryFirstPage(); } - } + }; // // Render diff --git a/frontend/src/Activity/History/HistoryEventTypeCell.css.d.ts b/frontend/src/Activity/History/HistoryEventTypeCell.css.d.ts new file mode 100644 index 000000000..c748f6f97 --- /dev/null +++ b/frontend/src/Activity/History/HistoryEventTypeCell.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'cell': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/History/HistoryEventTypeCell.js b/frontend/src/Activity/History/HistoryEventTypeCell.js index 172796cd4..937cedd98 100644 --- a/frontend/src/Activity/History/HistoryEventTypeCell.js +++ b/frontend/src/Activity/History/HistoryEventTypeCell.js @@ -1,11 +1,12 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { icons, kinds } from 'Helpers/Props'; import Icon from 'Components/Icon'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import { icons, kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './HistoryEventTypeCell.css'; -function getIconName(eventType) { +function getIconName(eventType, data) { switch (eventType) { case 'grabbed': return icons.DOWNLOADING; @@ -16,7 +17,7 @@ function getIconName(eventType) { case 'downloadFailed': return icons.DOWNLOADING; case 'trackFileDeleted': - return icons.DELETE; + return data.reason === 'MissingFromDisk' ? icons.FILE_MISSING : icons.DELETE; case 'trackFileRenamed': return icons.ORGANIZE; case 'trackFileRetagged': @@ -25,6 +26,8 @@ function getIconName(eventType) { return icons.DOWNLOADED; case 'downloadImported': return icons.DOWNLOADED; + case 'downloadIgnored': + return icons.IGNORE; default: return icons.UNKNOWN; } @@ -52,22 +55,24 @@ function getTooltip(eventType, data) { case 'downloadFailed': return 'Album download failed'; case 'trackFileDeleted': - return 'Track file deleted'; + return data.reason === 'MissingFromDisk' ? translate('TrackFileMissingTooltip') : translate('TrackFileDeletedTooltip'); case 'trackFileRenamed': - return 'Track file renamed'; + return translate('TrackFileRenamedTooltip'); case 'trackFileRetagged': - return 'Track file tags updated'; + return translate('TrackFileTagsUpdatedTooltip'); case 'albumImportIncomplete': return 'Files downloaded but not all could be imported'; case 'downloadImported': return 'Download completed and successfully imported'; + case 'downloadIgnored': + return 'Album Download Ignored'; default: return 'Unknown event'; } } function HistoryEventTypeCell({ eventType, data }) { - const iconName = getIconName(eventType); + const iconName = getIconName(eventType, data); const iconKind = getIconKind(eventType); const tooltip = getTooltip(eventType, data); diff --git a/frontend/src/Activity/History/HistoryFilterModal.tsx b/frontend/src/Activity/History/HistoryFilterModal.tsx new file mode 100644 index 000000000..f4ad2e57c --- /dev/null +++ b/frontend/src/Activity/History/HistoryFilterModal.tsx @@ -0,0 +1,54 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterModal from 'Components/Filter/FilterModal'; +import { setHistoryFilter } from 'Store/Actions/historyActions'; + +function createHistorySelector() { + return createSelector( + (state: AppState) => state.history.items, + (queueItems) => { + return queueItems; + } + ); +} + +function createFilterBuilderPropsSelector() { + return createSelector( + (state: AppState) => state.history.filterBuilderProps, + (filterBuilderProps) => { + return filterBuilderProps; + } + ); +} + +interface HistoryFilterModalProps { + isOpen: boolean; +} + +export default function HistoryFilterModal(props: HistoryFilterModalProps) { + const sectionItems = useSelector(createHistorySelector()); + const filterBuilderProps = useSelector(createFilterBuilderPropsSelector()); + const customFilterType = 'history'; + + const dispatch = useDispatch(); + + const dispatchSetFilter = useCallback( + (payload: unknown) => { + dispatch(setHistoryFilter(payload)); + }, + [dispatch] + ); + + return ( + + ); +} diff --git a/frontend/src/Activity/History/HistoryRow.css b/frontend/src/Activity/History/HistoryRow.css index 669377fdb..039804b63 100644 --- a/frontend/src/Activity/History/HistoryRow.css +++ b/frontend/src/Activity/History/HistoryRow.css @@ -10,6 +10,12 @@ width: 80px; } +.customFormatScore { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 55px; +} + .releaseGroup { composes: cell from '~Components/Table/Cells/TableRowCell.css'; diff --git a/frontend/src/Activity/History/HistoryRow.css.d.ts b/frontend/src/Activity/History/HistoryRow.css.d.ts new file mode 100644 index 000000000..e1f54bc96 --- /dev/null +++ b/frontend/src/Activity/History/HistoryRow.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'customFormatScore': string; + 'details': string; + 'downloadClient': string; + 'indexer': string; + 'releaseGroup': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/History/HistoryRow.js b/frontend/src/Activity/History/HistoryRow.js index 62b83ed93..9f2da78d0 100644 --- a/frontend/src/Activity/History/HistoryRow.js +++ b/frontend/src/Activity/History/HistoryRow.js @@ -1,15 +1,18 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons } from 'Helpers/Props'; -import IconButton from 'Components/Link/IconButton'; -import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; -import TableRow from 'Components/Table/TableRow'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import AlbumFormats from 'Album/AlbumFormats'; import AlbumTitleLink from 'Album/AlbumTitleLink'; import TrackQuality from 'Album/TrackQuality'; import ArtistNameLink from 'Artist/ArtistNameLink'; -import HistoryEventTypeCell from './HistoryEventTypeCell'; +import IconButton from 'Components/Link/IconButton'; +import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import TableRow from 'Components/Table/TableRow'; +import Tooltip from 'Components/Tooltip/Tooltip'; +import { icons, tooltipPositions } from 'Helpers/Props'; +import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; import HistoryDetailsModal from './Details/HistoryDetailsModal'; +import HistoryEventTypeCell from './HistoryEventTypeCell'; import styles from './HistoryRow.css'; class HistoryRow extends Component { @@ -40,11 +43,11 @@ class HistoryRow extends Component { onDetailsPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; // // Render @@ -55,11 +58,14 @@ class HistoryRow extends Component { album, track, quality, + customFormats, + customFormatScore, qualityCutoffNotMet, eventType, sourceTitle, date, data, + downloadId, isMarkingAsFailed, columns, shortDateFormat, @@ -94,7 +100,7 @@ class HistoryRow extends Component { ); } - if (name === 'artist.sortName') { + if (name === 'artists.sortName') { return ( + + + ); + } + if (name === 'date') { return ( + } + position={tooltipPositions.BOTTOM} + /> + + ); + } + if (name === 'releaseGroup') { return ( + {sourceTitle} + + ); + } + if (name === 'details') { return ( { this.props.markAsFailed({ id: this.props.id }); - } + }; // // Render diff --git a/frontend/src/Activity/Queue/ProtocolLabel.css b/frontend/src/Activity/Queue/ProtocolLabel.css index 259fd5c65..110c7e01c 100644 --- a/frontend/src/Activity/Queue/ProtocolLabel.css +++ b/frontend/src/Activity/Queue/ProtocolLabel.css @@ -1,13 +1,13 @@ .torrent { composes: label from '~Components/Label.css'; - border-color: $torrentColor; - background-color: $torrentColor; + border-color: var(--torrentColor); + background-color: var(--torrentColor); } .usenet { composes: label from '~Components/Label.css'; - border-color: $usenetColor; - background-color: $usenetColor; + border-color: var(--usenetColor); + background-color: var(--usenetColor); } diff --git a/frontend/src/Activity/Queue/ProtocolLabel.css.d.ts b/frontend/src/Activity/Queue/ProtocolLabel.css.d.ts new file mode 100644 index 000000000..f3b389e3d --- /dev/null +++ b/frontend/src/Activity/Queue/ProtocolLabel.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'torrent': string; + 'usenet': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Queue/Queue.js b/frontend/src/Activity/Queue/Queue.js index 9169927a3..0efc29f21 100644 --- a/frontend/src/Activity/Queue/Queue.js +++ b/frontend/src/Activity/Queue/Queue.js @@ -1,26 +1,31 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import Alert from 'Components/Alert'; +import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import FilterMenu from 'Components/Menu/FilterMenu'; +import PageContent from 'Components/Page/PageContent'; +import PageContentBody from 'Components/Page/PageContentBody'; +import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; +import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; +import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; +import Table from 'Components/Table/Table'; +import TableBody from 'Components/Table/TableBody'; +import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; +import TablePager from 'Components/Table/TablePager'; +import { align, icons, kinds } from 'Helpers/Props'; +import getRemovedItems from 'Utilities/Object/getRemovedItems'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; +import translate from 'Utilities/String/translate'; import getSelectedIds from 'Utilities/Table/getSelectedIds'; import removeOldSelectedState from 'Utilities/Table/removeOldSelectedState'; import selectAll from 'Utilities/Table/selectAll'; import toggleSelected from 'Utilities/Table/toggleSelected'; -import { align, icons } from 'Helpers/Props'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import Table from 'Components/Table/Table'; -import TableBody from 'Components/Table/TableBody'; -import TablePager from 'Components/Table/TablePager'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; -import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; -import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; -import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; -import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; -import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; -import RemoveQueueItemsModal from './RemoveQueueItemsModal'; +import QueueFilterModal from './QueueFilterModal'; import QueueOptionsConnector from './QueueOptionsConnector'; import QueueRowConnector from './QueueRowConnector'; +import RemoveQueueItemModal from './RemoveQueueItemModal'; class Queue extends Component { @@ -30,30 +35,21 @@ class Queue extends Component { constructor(props, context) { super(props, context); + this._shouldBlockRefresh = false; + this.state = { allSelected: false, allUnselected: false, lastToggled: null, selectedState: {}, isPendingSelected: false, - isConfirmRemoveModalOpen: false + isConfirmRemoveModalOpen: false, + items: props.items }; } - shouldComponentUpdate(nextProps) { - // Don't update when fetching has completed if items have changed, - // before albums start fetching or when albums start fetching. - - if ( - this.props.isFetching && - nextProps.isPopulated && - hasDifferentItems(this.props.items, nextProps.items) && - nextProps.items.some((e) => e.albumId) - ) { - return false; - } - - if (!this.props.isAlbumsFetching && nextProps.isAlbumsFetching) { + shouldComponentUpdate() { + if (this._shouldBlockRefresh) { return false; } @@ -61,21 +57,44 @@ class Queue extends Component { } componentDidUpdate(prevProps) { - if (hasDifferentItems(prevProps.items, this.props.items)) { + const { + items, + isFetching, + isAlbumsFetching + } = this.props; + + if ( + (!isAlbumsFetching && prevProps.isAlbumsFetching) || + (!isFetching && prevProps.isFetching) || + (hasDifferentItems(prevProps.items, items) && !items.some((e) => e.albumId)) + ) { this.setState((state) => { - return removeOldSelectedState(state, prevProps.items); + return { + ...removeOldSelectedState(state, getRemovedItems(prevProps.items, items)), + items + }; }); return; } + const nextState = {}; + + if (prevProps.items !== items) { + nextState.items = items; + } + const selectedIds = this.getSelectedIds(); const isPendingSelected = _.some(this.props.items, (item) => { - return selectedIds.indexOf(item.id) > -1 && item.status === 'Delay'; + return selectedIds.indexOf(item.id) > -1 && item.status === 'delay'; }); if (isPendingSelected !== this.state.isPendingSelected) { - this.setState({ isPendingSelected }); + nextState.isPendingSelected = isPendingSelected; + } + + if (!_.isEmpty(nextState)) { + this.setState(nextState); } } @@ -84,37 +103,45 @@ class Queue extends Component { getSelectedIds = () => { return getSelectedIds(this.state.selectedState); - } + }; // // Listeners + onQueueRowModalOpenOrClose = (isOpen) => { + this._shouldBlockRefresh = isOpen; + }; + onSelectAllChange = ({ value }) => { this.setState(selectAll(this.state.selectedState, value)); - } + }; onSelectedChange = ({ id, value, shiftKey = false }) => { this.setState((state) => { return toggleSelected(state, this.props.items, id, value, shiftKey); }); - } + }; onGrabSelectedPress = () => { this.props.onGrabSelectedPress(this.getSelectedIds()); - } + }; onRemoveSelectedPress = () => { - this.setState({ isConfirmRemoveModalOpen: true }); - } + this.setState({ isConfirmRemoveModalOpen: true }, () => { + this._shouldBlockRefresh = true; + }); + }; - onRemoveSelectedConfirmed = (blacklist, skipredownload) => { - this.props.onRemoveSelectedPress(this.getSelectedIds(), blacklist, skipredownload); + onRemoveSelectedConfirmed = (payload) => { + this._shouldBlockRefresh = false; + this.props.onRemoveSelectedPress({ ids: this.getSelectedIds(), ...payload }); this.setState({ isConfirmRemoveModalOpen: false }); - } + }; onConfirmRemoveModalClose = () => { + this._shouldBlockRefresh = false; this.setState({ isConfirmRemoveModalOpen: false }); - } + }; // // Render @@ -124,16 +151,22 @@ class Queue extends Component { isFetching, isPopulated, error, - items, + isArtistFetching, + isArtistPopulated, isAlbumsFetching, isAlbumsPopulated, albumsError, columns, + selectedFilterKey, + filters, + customFilters, + count, totalRecords, isGrabbing, isRemoving, - isCheckForFinishedDownloadExecuting, + isRefreshMonitoredDownloadsExecuting, onRefreshPress, + onFilterSelect, ...otherProps } = this.props; @@ -142,21 +175,23 @@ class Queue extends Component { allUnselected, selectedState, isConfirmRemoveModalOpen, - isPendingSelected + isPendingSelected, + items } = this.state; - const isRefreshing = isFetching || isAlbumsFetching || isCheckForFinishedDownloadExecuting; - const isAllPopulated = isPopulated && (isAlbumsPopulated || !items.length || items.every((e) => !e.albumId)); + const isRefreshing = isFetching || isArtistFetching || isAlbumsFetching || isRefreshMonitoredDownloadsExecuting; + const isAllPopulated = isPopulated && ((isArtistPopulated && isAlbumsPopulated) || !items.length || items.every((e) => !e.albumId)); const hasError = error || albumsError; - const selectedCount = this.getSelectedIds().length; + const selectedIds = this.getSelectedIds(); + const selectedCount = selectedIds.length; const disableSelectedActions = selectedCount === 0; return ( - + + + - + { - isRefreshing && !isAllPopulated && - + isRefreshing && !isAllPopulated ? + : + null } { - !isRefreshing && hasError && -
- Failed to load Queue -
+ !isRefreshing && hasError ? + + {translate('FailedToLoadQueue')} + : + null } { - isPopulated && !hasError && !items.length && -
- Queue is empty -
+ isAllPopulated && !hasError && !items.length ? + + { + selectedFilterKey !== 'all' && count > 0 ? + translate('QueueFilterHasNoItems') : + translate('QueueIsEmpty') + } + : + null } { - isAllPopulated && !hasError && !!items.length && + isAllPopulated && !hasError && !!items.length ?
); }) @@ -252,13 +304,39 @@ class Queue extends Component { isFetching={isRefreshing} {...otherProps} /> - + : + null } - + - { + const item = items.find((i) => i.id === id); + + return !!(item && item.downloadClientHasPostImportCategory); + }) + )} + canIgnore={isConfirmRemoveModalOpen && ( + selectedIds.every((id) => { + const item = items.find((i) => i.id === id); + + return !!(item && item.artistId && item.albumId); + }) + )} + pending={isConfirmRemoveModalOpen && ( + selectedIds.every((id) => { + const item = items.find((i) => i.id === id); + + if (!item) { + return false; + } + + return item.status === 'delay' || item.status === 'downloadClientUnavailable'; + }) + )} onRemovePress={this.onRemoveSelectedConfirmed} onModalClose={this.onConfirmRemoveModalClose} /> @@ -272,17 +350,28 @@ Queue.propTypes = { isPopulated: PropTypes.bool.isRequired, error: PropTypes.object, items: PropTypes.arrayOf(PropTypes.object).isRequired, + isArtistFetching: PropTypes.bool.isRequired, + isArtistPopulated: PropTypes.bool.isRequired, isAlbumsFetching: PropTypes.bool.isRequired, isAlbumsPopulated: PropTypes.bool.isRequired, albumsError: PropTypes.object, columns: PropTypes.arrayOf(PropTypes.object).isRequired, + selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + filters: PropTypes.arrayOf(PropTypes.object).isRequired, + customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, + count: PropTypes.number.isRequired, totalRecords: PropTypes.number, isGrabbing: PropTypes.bool.isRequired, isRemoving: PropTypes.bool.isRequired, - isCheckForFinishedDownloadExecuting: PropTypes.bool.isRequired, + isRefreshMonitoredDownloadsExecuting: PropTypes.bool.isRequired, onRefreshPress: PropTypes.func.isRequired, onGrabSelectedPress: PropTypes.func.isRequired, - onRemoveSelectedPress: PropTypes.func.isRequired + onRemoveSelectedPress: PropTypes.func.isRequired, + onFilterSelect: PropTypes.func.isRequired +}; + +Queue.defaultProps = { + count: 0 }; export default Queue; diff --git a/frontend/src/Activity/Queue/QueueConnector.js b/frontend/src/Activity/Queue/QueueConnector.js index ea571e8af..fc0bb4699 100644 --- a/frontend/src/Activity/Queue/QueueConnector.js +++ b/frontend/src/Activity/Queue/QueueConnector.js @@ -2,29 +2,37 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; -import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; -import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; +import * as commandNames from 'Commands/commandNames'; import withCurrentPage from 'Components/withCurrentPage'; -import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; import { executeCommand } from 'Store/Actions/commandActions'; import * as queueActions from 'Store/Actions/queueActions'; -import { fetchAlbums, clearAlbums } from 'Store/Actions/albumActions'; -import * as commandNames from 'Commands/commandNames'; +import { createCustomFiltersSelector } from 'Store/Selectors/createClientSideCollectionSelector'; +import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; +import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; +import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; import Queue from './Queue'; function createMapStateToProps() { return createSelector( + (state) => state.artist, (state) => state.albums, (state) => state.queue.options, (state) => state.queue.paged, - createCommandExecutingSelector(commandNames.CHECK_FOR_FINISHED_DOWNLOAD), - (albums, options, queue, isCheckForFinishedDownloadExecuting) => { + (state) => state.queue.status.item, + createCustomFiltersSelector('queue'), + createCommandExecutingSelector(commandNames.REFRESH_MONITORED_DOWNLOADS), + (artist, albums, options, queue, status, customFilters, isRefreshMonitoredDownloadsExecuting) => { return { + count: options.includeUnknownArtistItems ? status.totalCount : status.count, + isArtistFetching: artist.isFetching, + isArtistPopulated: artist.isPopulated, isAlbumsFetching: albums.isFetching, isAlbumsPopulated: albums.isPopulated, albumsError: albums.error, - isCheckForFinishedDownloadExecuting, + customFilters, + isRefreshMonitoredDownloadsExecuting, ...options, ...queue }; @@ -48,6 +56,7 @@ class QueueConnector extends Component { const { useCurrentPage, fetchQueue, + fetchQueueStatus, gotoQueueFirstPage } = this.props; @@ -58,6 +67,8 @@ class QueueConnector extends Component { } else { gotoQueueFirstPage(); } + + fetchQueueStatus(); } componentDidUpdate(prevProps) { @@ -90,34 +101,38 @@ class QueueConnector extends Component { repopulate = () => { this.props.fetchQueue(); - } + }; // // Listeners onFirstPagePress = () => { this.props.gotoQueueFirstPage(); - } + }; onPreviousPagePress = () => { this.props.gotoQueuePreviousPage(); - } + }; onNextPagePress = () => { this.props.gotoQueueNextPage(); - } + }; onLastPagePress = () => { this.props.gotoQueueLastPage(); - } + }; onPageSelect = (page) => { this.props.gotoQueuePage({ page }); - } + }; onSortPress = (sortKey) => { this.props.setQueueSort({ sortKey }); - } + }; + + onFilterSelect = (selectedFilterKey) => { + this.props.setQueueFilter({ selectedFilterKey }); + }; onTableOptionChange = (payload) => { this.props.setQueueTableOption(payload); @@ -125,21 +140,21 @@ class QueueConnector extends Component { if (payload.pageSize) { this.props.gotoQueueFirstPage(); } - } + }; onRefreshPress = () => { this.props.executeCommand({ - name: commandNames.CHECK_FOR_FINISHED_DOWNLOAD + name: commandNames.REFRESH_MONITORED_DOWNLOADS }); - } + }; onGrabSelectedPress = (ids) => { this.props.grabQueueItems({ ids }); - } + }; - onRemoveSelectedPress = (ids, blacklist, skipredownload) => { - this.props.removeQueueItems({ ids, blacklist, skipredownload }); - } + onRemoveSelectedPress = (payload) => { + this.props.removeQueueItems(payload); + }; // // Render @@ -153,6 +168,7 @@ class QueueConnector extends Component { onLastPagePress={this.onLastPagePress} onPageSelect={this.onPageSelect} onSortPress={this.onSortPress} + onFilterSelect={this.onFilterSelect} onTableOptionChange={this.onTableOptionChange} onRefreshPress={this.onRefreshPress} onGrabSelectedPress={this.onGrabSelectedPress} @@ -168,12 +184,14 @@ QueueConnector.propTypes = { items: PropTypes.arrayOf(PropTypes.object).isRequired, includeUnknownArtistItems: PropTypes.bool.isRequired, fetchQueue: PropTypes.func.isRequired, + fetchQueueStatus: PropTypes.func.isRequired, gotoQueueFirstPage: PropTypes.func.isRequired, gotoQueuePreviousPage: PropTypes.func.isRequired, gotoQueueNextPage: PropTypes.func.isRequired, gotoQueueLastPage: PropTypes.func.isRequired, gotoQueuePage: PropTypes.func.isRequired, setQueueSort: PropTypes.func.isRequired, + setQueueFilter: PropTypes.func.isRequired, setQueueTableOption: PropTypes.func.isRequired, clearQueue: PropTypes.func.isRequired, grabQueueItems: PropTypes.func.isRequired, diff --git a/frontend/src/Activity/Queue/QueueDetails.js b/frontend/src/Activity/Queue/QueueDetails.js index 8256b8af3..208f50f4c 100644 --- a/frontend/src/Activity/Queue/QueueDetails.js +++ b/frontend/src/Activity/Queue/QueueDetails.js @@ -1,8 +1,9 @@ import moment from 'moment'; import PropTypes from 'prop-types'; import React from 'react'; -import { icons, kinds } from 'Helpers/Props'; import Icon from 'Components/Icon'; +import { icons, kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; function QueueDetails(props) { const { @@ -10,20 +11,20 @@ function QueueDetails(props) { size, sizeleft, estimatedCompletionTime, - status: queueStatus, + status, + trackedDownloadState, + trackedDownloadStatus, errorMessage, progressBar } = props; - const status = queueStatus.toLowerCase(); - const progress = (100 - sizeleft / size * 100); if (status === 'pending') { return ( ); } @@ -34,12 +35,40 @@ function QueueDetails(props) { ); } - // TODO: show an icon when download is complete, but not imported yet? + if (trackedDownloadStatus === 'warning') { + return ( + + ); + } + + if (trackedDownloadState === 'importPending') { + return ( + + ); + } + + if (trackedDownloadState === 'importing') { + return ( + + ); + } } if (errorMessage) { @@ -47,7 +76,7 @@ function QueueDetails(props) { ); } @@ -57,7 +86,7 @@ function QueueDetails(props) { ); } @@ -67,7 +96,7 @@ function QueueDetails(props) { ); } @@ -76,7 +105,7 @@ function QueueDetails(props) { return ( ); } @@ -90,6 +119,8 @@ QueueDetails.propTypes = { sizeleft: PropTypes.number.isRequired, estimatedCompletionTime: PropTypes.string, status: PropTypes.string.isRequired, + trackedDownloadState: PropTypes.string.isRequired, + trackedDownloadStatus: PropTypes.string.isRequired, errorMessage: PropTypes.string, progressBar: PropTypes.node.isRequired }; diff --git a/frontend/src/Activity/Queue/QueueFilterModal.tsx b/frontend/src/Activity/Queue/QueueFilterModal.tsx new file mode 100644 index 000000000..3fce6c166 --- /dev/null +++ b/frontend/src/Activity/Queue/QueueFilterModal.tsx @@ -0,0 +1,54 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterModal from 'Components/Filter/FilterModal'; +import { setQueueFilter } from 'Store/Actions/queueActions'; + +function createQueueSelector() { + return createSelector( + (state: AppState) => state.queue.paged.items, + (queueItems) => { + return queueItems; + } + ); +} + +function createFilterBuilderPropsSelector() { + return createSelector( + (state: AppState) => state.queue.paged.filterBuilderProps, + (filterBuilderProps) => { + return filterBuilderProps; + } + ); +} + +interface QueueFilterModalProps { + isOpen: boolean; +} + +export default function QueueFilterModal(props: QueueFilterModalProps) { + const sectionItems = useSelector(createQueueSelector()); + const filterBuilderProps = useSelector(createFilterBuilderPropsSelector()); + const customFilterType = 'queue'; + + const dispatch = useDispatch(); + + const dispatchSetFilter = useCallback( + (payload: unknown) => { + dispatch(setQueueFilter(payload)); + }, + [dispatch] + ); + + return ( + + ); +} diff --git a/frontend/src/Activity/Queue/QueueOptions.js b/frontend/src/Activity/Queue/QueueOptions.js index 835be52b3..2ca0d7663 100644 --- a/frontend/src/Activity/Queue/QueueOptions.js +++ b/frontend/src/Activity/Queue/QueueOptions.js @@ -1,9 +1,10 @@ import PropTypes from 'prop-types'; import React, { Component, Fragment } from 'react'; -import { inputTypes } from 'Helpers/Props'; import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import { inputTypes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; class QueueOptions extends Component { @@ -41,7 +42,7 @@ class QueueOptions extends Component { [name]: value }); }); - } + }; // // Render @@ -54,13 +55,15 @@ class QueueOptions extends Component { return ( - Show Unknown Artist Items + + {translate('ShowUnknownArtistItems')} + diff --git a/frontend/src/Activity/Queue/QueueRow.css b/frontend/src/Activity/Queue/QueueRow.css index 16805dbf6..2a0df3595 100644 --- a/frontend/src/Activity/Queue/QueueRow.css +++ b/frontend/src/Activity/Queue/QueueRow.css @@ -16,8 +16,15 @@ width: 150px; } +.customFormatScore { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 55px; +} + .actions { composes: cell from '~Components/Table/Cells/TableRowCell.css'; width: 90px; + text-align: right; } diff --git a/frontend/src/Activity/Queue/QueueRow.css.d.ts b/frontend/src/Activity/Queue/QueueRow.css.d.ts new file mode 100644 index 000000000..13d67ea3a --- /dev/null +++ b/frontend/src/Activity/Queue/QueueRow.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'customFormatScore': string; + 'progress': string; + 'protocol': string; + 'quality': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Queue/QueueRow.js b/frontend/src/Activity/Queue/QueueRow.js index 06cf16f70..d0f1fbacf 100644 --- a/frontend/src/Activity/Queue/QueueRow.js +++ b/frontend/src/Activity/Queue/QueueRow.js @@ -1,23 +1,28 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons, kinds, tooltipPositions } from 'Helpers/Props'; +import ProtocolLabel from 'Activity/Queue/ProtocolLabel'; +import AlbumFormats from 'Album/AlbumFormats'; +import AlbumTitleLink from 'Album/AlbumTitleLink'; +import TrackQuality from 'Album/TrackQuality'; +import ArtistNameLink from 'Artist/ArtistNameLink'; +import Icon from 'Components/Icon'; import IconButton from 'Components/Link/IconButton'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; import ProgressBar from 'Components/ProgressBar'; -import TableRow from 'Components/Table/TableRow'; import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; -import Icon from 'Components/Icon'; +import TableRow from 'Components/Table/TableRow'; import Popover from 'Components/Tooltip/Popover'; -import ProtocolLabel from 'Activity/Queue/ProtocolLabel'; -import AlbumTitleLink from 'Album/AlbumTitleLink'; -import TrackQuality from 'Album/TrackQuality'; +import Tooltip from 'Components/Tooltip/Tooltip'; +import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import InteractiveImportModal from 'InteractiveImport/InteractiveImportModal'; -import ArtistNameLink from 'Artist/ArtistNameLink'; +import formatBytes from 'Utilities/Number/formatBytes'; +import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; +import translate from 'Utilities/String/translate'; import QueueStatusCell from './QueueStatusCell'; -import TimeleftCell from './TimeleftCell'; import RemoveQueueItemModal from './RemoveQueueItemModal'; +import TimeleftCell from './TimeleftCell'; import styles from './QueueRow.css'; class QueueRow extends Component { @@ -39,24 +44,37 @@ class QueueRow extends Component { onRemoveQueueItemPress = () => { this.setState({ isRemoveQueueItemModalOpen: true }); - } + }; + + onRemoveQueueItemModalConfirmed = (blocklist, skipRedownload) => { + const { + onRemoveQueueItemPress, + onQueueRowModalOpenOrClose + } = this.props; + + onQueueRowModalOpenOrClose(false); + onRemoveQueueItemPress(blocklist, skipRedownload); - onRemoveQueueItemModalConfirmed = (blacklist, skipredownload) => { - this.props.onRemoveQueueItemPress(blacklist, skipredownload); this.setState({ isRemoveQueueItemModalOpen: false }); - } + }; onRemoveQueueItemModalClose = () => { + this.props.onQueueRowModalOpenOrClose(false); + this.setState({ isRemoveQueueItemModalOpen: false }); - } + }; onInteractiveImportPress = () => { + this.props.onQueueRowModalOpenOrClose(true); + this.setState({ isInteractiveImportModalOpen: true }); - } + }; onInteractiveImportModalClose = () => { + this.props.onQueueRowModalOpenOrClose(false); + this.setState({ isInteractiveImportModalOpen: false }); - } + }; // // Render @@ -68,17 +86,22 @@ class QueueRow extends Component { title, status, trackedDownloadStatus, + trackedDownloadState, statusMessages, errorMessage, artist, album, quality, + customFormats, + customFormatScore, protocol, indexer, outputPath, downloadClient, + downloadClientHasPostImportCategory, downloadForced, estimatedCompletionTime, + added, timeleft, size, sizeleft, @@ -100,8 +123,8 @@ class QueueRow extends Component { } = this.state; const progress = 100 - (sizeleft / size * 100); - const showInteractiveImport = status === 'Completed' && trackedDownloadStatus === 'Warning'; - const isPending = status === 'Delay' || status === 'DownloadClientUnavailable'; + const showInteractiveImport = status === 'completed' && trackedDownloadStatus === 'warning'; + const isPending = status === 'delay' || status === 'downloadClientUnavailable'; return ( @@ -129,13 +152,14 @@ class QueueRow extends Component { sourceTitle={title} status={status} trackedDownloadStatus={trackedDownloadStatus} + trackedDownloadState={trackedDownloadState} statusMessages={statusMessages} errorMessage={errorMessage} /> ); } - if (name === 'artist.sortName') { + if (name === 'artists.sortName') { return ( { @@ -150,7 +174,7 @@ class QueueRow extends Component { ); } - if (name === 'album.title') { + if (name === 'albums.title') { return ( { @@ -166,7 +190,7 @@ class QueueRow extends Component { ); } - if (name === 'album.releaseDate') { + if (name === 'albums.releaseDate') { if (album) { return ( - : + null + } + + ); + } + + if (name === 'customFormats') { + return ( + + + + ); + } + + if (name === 'customFormatScore') { + return ( + + } + position={tooltipPositions.BOTTOM} /> ); @@ -227,6 +283,12 @@ class QueueRow extends Component { ); } + if (name === 'size') { + return ( + {formatBytes(size)} + ); + } + if (name === 'outputPath') { return ( @@ -268,6 +330,15 @@ class QueueRow extends Component { ); } + if (name === 'added') { + return ( + + ); + } + if (name === 'actions') { return ( } - title="Manual Download" + title={translate('ManualDownload')} body="This release failed parsing checks and was manually downloaded from an interactive search. Import is likely to fail." position={tooltipPositions.LEFT} /> @@ -308,7 +379,7 @@ class QueueRow extends Component { } @@ -348,17 +422,22 @@ QueueRow.propTypes = { title: PropTypes.string.isRequired, status: PropTypes.string.isRequired, trackedDownloadStatus: PropTypes.string, + trackedDownloadState: PropTypes.string, statusMessages: PropTypes.arrayOf(PropTypes.object), errorMessage: PropTypes.string, artist: PropTypes.object, album: PropTypes.object, quality: PropTypes.object.isRequired, + customFormats: PropTypes.arrayOf(PropTypes.object), + customFormatScore: PropTypes.number.isRequired, protocol: PropTypes.string.isRequired, indexer: PropTypes.string, outputPath: PropTypes.string, downloadClient: PropTypes.string, + downloadClientHasPostImportCategory: PropTypes.bool, downloadForced: PropTypes.bool.isRequired, estimatedCompletionTime: PropTypes.string, + added: PropTypes.string, timeleft: PropTypes.string, size: PropTypes.number, sizeleft: PropTypes.number, @@ -372,10 +451,12 @@ QueueRow.propTypes = { columns: PropTypes.arrayOf(PropTypes.object).isRequired, onSelectedChange: PropTypes.func.isRequired, onGrabPress: PropTypes.func.isRequired, - onRemoveQueueItemPress: PropTypes.func.isRequired + onRemoveQueueItemPress: PropTypes.func.isRequired, + onQueueRowModalOpenOrClose: PropTypes.func.isRequired }; QueueRow.defaultProps = { + customFormats: [], isGrabbing: false, isRemoving: false }; diff --git a/frontend/src/Activity/Queue/QueueRowConnector.js b/frontend/src/Activity/Queue/QueueRowConnector.js index 6bbbde361..e2a5ba368 100644 --- a/frontend/src/Activity/Queue/QueueRowConnector.js +++ b/frontend/src/Activity/Queue/QueueRowConnector.js @@ -1,11 +1,10 @@ -import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { grabQueueItem, removeQueueItem } from 'Store/Actions/queueActions'; -import createArtistSelector from 'Store/Selectors/createArtistSelector'; import createAlbumSelector from 'Store/Selectors/createAlbumSelector'; +import createArtistSelector from 'Store/Selectors/createArtistSelector'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; import QueueRow from './QueueRow'; @@ -15,11 +14,11 @@ function createMapStateToProps() { createAlbumSelector(), createUISettingsSelector(), (artist, album, uiSettings) => { - const result = _.pick(uiSettings, [ - 'showRelativeDates', - 'shortDateFormat', - 'timeFormat' - ]); + const result = { + showRelativeDates: uiSettings.showRelativeDates, + shortDateFormat: uiSettings.shortDateFormat, + timeFormat: uiSettings.timeFormat + }; result.artist = artist; result.album = album; @@ -41,11 +40,11 @@ class QueueRowConnector extends Component { onGrabPress = () => { this.props.grabQueueItem({ id: this.props.id }); - } + }; - onRemoveQueueItemPress = (blacklist, skipredownload) => { - this.props.removeQueueItem({ id: this.props.id, blacklist, skipredownload }); - } + onRemoveQueueItemPress = (payload) => { + this.props.removeQueueItem({ id: this.props.id, ...payload }); + }; // // Render diff --git a/frontend/src/Activity/Queue/QueueStatusCell.css b/frontend/src/Activity/Queue/QueueStatusCell.css index e1b9a23e9..538d5a15d 100644 --- a/frontend/src/Activity/Queue/QueueStatusCell.css +++ b/frontend/src/Activity/Queue/QueueStatusCell.css @@ -3,3 +3,7 @@ width: 30px; } + +.noMessages { + margin-bottom: 10px; +} diff --git a/frontend/src/Activity/Queue/QueueStatusCell.css.d.ts b/frontend/src/Activity/Queue/QueueStatusCell.css.d.ts new file mode 100644 index 000000000..aefdc03b9 --- /dev/null +++ b/frontend/src/Activity/Queue/QueueStatusCell.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'noMessages': string; + 'status': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Queue/QueueStatusCell.js b/frontend/src/Activity/Queue/QueueStatusCell.js index 552fa1444..d4dcdfeee 100644 --- a/frontend/src/Activity/Queue/QueueStatusCell.js +++ b/frontend/src/Activity/Queue/QueueStatusCell.js @@ -1,9 +1,10 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import Icon from 'Components/Icon'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; import Popover from 'Components/Tooltip/Popover'; +import { icons, kinds, tooltipPositions } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './QueueStatusCell.css'; function getDetailedPopoverBody(statusMessages) { @@ -12,7 +13,10 @@ function getDetailedPopoverBody(statusMessages) { { statusMessages.map(({ title, messages }) => { return ( -
+
{title}
    { @@ -37,70 +41,98 @@ function QueueStatusCell(props) { const { sourceTitle, status, - trackedDownloadStatus = 'Ok', + trackedDownloadStatus, + trackedDownloadState, statusMessages, errorMessage } = props; - const hasWarning = trackedDownloadStatus === 'Warning'; - const hasError = trackedDownloadStatus === 'Error'; + const hasWarning = trackedDownloadStatus === 'warning'; + const hasError = trackedDownloadStatus === 'error'; // status === 'downloading' let iconName = icons.DOWNLOADING; let iconKind = kinds.DEFAULT; - let title = 'Downloading'; + let title = translate('Downloading'); + + if (status === 'paused') { + iconName = icons.PAUSED; + title = translate('Paused'); + } + + if (status === 'queued') { + iconName = icons.QUEUED; + title = translate('Queued'); + } + + if (status === 'completed') { + iconName = icons.DOWNLOADED; + title = translate('Downloaded'); + + if (trackedDownloadState === 'importBlocked') { + title += ` - ${translate('UnableToImportAutomatically')}`; + iconKind = kinds.WARNING; + } + + if (trackedDownloadState === 'importFailed') { + title += ` - ${translate('ImportFailed', { sourceTitle })}`; + iconKind = kinds.WARNING; + } + + if (trackedDownloadState === 'importPending') { + title += ` - ${translate('WaitingToImport')}`; + iconKind = kinds.PURPLE; + } + + if (trackedDownloadState === 'importing') { + title += ` - ${translate('Importing')}`; + iconKind = kinds.PURPLE; + } + + if (trackedDownloadState === 'failedPending') { + title += ` - ${translate('WaitingToProcess')}`; + iconKind = kinds.DANGER; + } + } if (hasWarning) { iconKind = kinds.WARNING; } - if (status === 'Paused') { - iconName = icons.PAUSED; - title = 'Paused'; - } - - if (status === 'Queued') { - iconName = icons.QUEUED; - title = 'Queued'; - } - - if (status === 'Completed') { - iconName = icons.DOWNLOADED; - title = 'Downloaded'; - } - - if (status === 'Delay') { + if (status === 'delay') { iconName = icons.PENDING; - title = 'Pending'; + title = translate('Pending'); } - if (status === 'DownloadClientUnavailable') { + if (status === 'downloadClientUnavailable') { iconName = icons.PENDING; iconKind = kinds.WARNING; - title = 'Pending - Download client is unavailable'; + title = translate('PendingDownloadClientUnavailable'); } - if (status === 'Failed') { + if (status === 'failed') { iconName = icons.DOWNLOADING; iconKind = kinds.DANGER; - title = 'Download failed'; + title = translate('DownloadFailed'); } - if (status === 'Warning') { + if (status === 'warning') { iconName = icons.DOWNLOADING; iconKind = kinds.WARNING; - title = `Download warning: ${errorMessage || 'check download client for more details'}`; + const warningMessage = + errorMessage || translate('CheckDownloadClientForDetails'); + title = translate('DownloadWarning', { warningMessage }); } if (hasError) { - if (status === 'Completed') { + if (status === 'completed') { iconName = icons.DOWNLOAD; iconKind = kinds.DANGER; - title = `Import failed: ${sourceTitle}`; + title = translate('ImportFailed', { sourceTitle }); } else { iconName = icons.DOWNLOADING; iconKind = kinds.DANGER; - title = 'Download failed'; + title = translate('DownloadFailed'); } } @@ -125,9 +157,15 @@ function QueueStatusCell(props) { QueueStatusCell.propTypes = { sourceTitle: PropTypes.string.isRequired, status: PropTypes.string.isRequired, - trackedDownloadStatus: PropTypes.string, + trackedDownloadStatus: PropTypes.string.isRequired, + trackedDownloadState: PropTypes.string.isRequired, statusMessages: PropTypes.arrayOf(PropTypes.object), errorMessage: PropTypes.string }; +QueueStatusCell.defaultProps = { + trackedDownloadStatus: 'Ok', + trackedDownloadState: 'Downloading' +}; + export default QueueStatusCell; diff --git a/frontend/src/Activity/Queue/RemoveQueueItemModal.css b/frontend/src/Activity/Queue/RemoveQueueItemModal.css index d7a643463..c9ef59ec1 100644 --- a/frontend/src/Activity/Queue/RemoveQueueItemModal.css +++ b/frontend/src/Activity/Queue/RemoveQueueItemModal.css @@ -1,4 +1,3 @@ -.messageRemove { +.message { margin-bottom: 30px; - color: $dangerColor; } diff --git a/frontend/src/Activity/Queue/RemoveQueueItemModal.css.d.ts b/frontend/src/Activity/Queue/RemoveQueueItemModal.css.d.ts new file mode 100644 index 000000000..65c237dff --- /dev/null +++ b/frontend/src/Activity/Queue/RemoveQueueItemModal.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Queue/RemoveQueueItemModal.js b/frontend/src/Activity/Queue/RemoveQueueItemModal.js deleted file mode 100644 index d2f929aee..000000000 --- a/frontend/src/Activity/Queue/RemoveQueueItemModal.js +++ /dev/null @@ -1,145 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { inputTypes, kinds, sizes } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import Modal from 'Components/Modal/Modal'; -import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import styles from './RemoveQueueItemModal.css'; - -class RemoveQueueItemModal extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - blacklist: false, - skipredownload: false - }; - } - - // - // Listeners - - onBlacklistChange = ({ value }) => { - this.setState({ blacklist: value }); - } - - onSkipReDownloadChange = ({ value }) => { - this.setState({ skipredownload: value }); - } - - onRemoveQueueItemConfirmed = () => { - const blacklist = this.state.blacklist; - const skipredownload = this.state.skipredownload; - - this.setState({ - blacklist: false, - skipredownload: false - }); - this.props.onRemovePress(blacklist, skipredownload); - } - - onModalClose = () => { - this.setState({ - blacklist: false, - skipredownload: false - }); - this.props.onModalClose(); - } - - // - // Render - - render() { - const { - isOpen, - sourceTitle - } = this.props; - - const blacklist = this.state.blacklist; - const skipredownload = this.state.skipredownload; - - return ( - - - - Remove - {sourceTitle} - - - -
    - Are you sure you want to remove '{sourceTitle}' from the queue? -
    - -
    - Removing will remove the download and the file(s) from the download client. -
    - - - Blacklist Release - - - - { - blacklist && - - Skip Redownload - - - } - -
    - - - - - - -
    -
    - ); - } -} - -RemoveQueueItemModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - sourceTitle: PropTypes.string.isRequired, - onRemovePress: PropTypes.func.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default RemoveQueueItemModal; diff --git a/frontend/src/Activity/Queue/RemoveQueueItemModal.tsx b/frontend/src/Activity/Queue/RemoveQueueItemModal.tsx new file mode 100644 index 000000000..f25bb0d1b --- /dev/null +++ b/frontend/src/Activity/Queue/RemoveQueueItemModal.tsx @@ -0,0 +1,231 @@ +import React, { useCallback, useMemo, useState } from 'react'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import Modal from 'Components/Modal/Modal'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes, kinds, sizes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import styles from './RemoveQueueItemModal.css'; + +interface RemovePressProps { + removeFromClient: boolean; + changeCategory: boolean; + blocklist: boolean; + skipRedownload: boolean; +} + +interface RemoveQueueItemModalProps { + isOpen: boolean; + sourceTitle: string; + canChangeCategory: boolean; + canIgnore: boolean; + isPending: boolean; + selectedCount?: number; + onRemovePress(props: RemovePressProps): void; + onModalClose: () => void; +} + +type RemovalMethod = 'removeFromClient' | 'changeCategory' | 'ignore'; +type BlocklistMethod = + | 'doNotBlocklist' + | 'blocklistAndSearch' + | 'blocklistOnly'; + +function RemoveQueueItemModal(props: RemoveQueueItemModalProps) { + const { + isOpen, + sourceTitle, + canIgnore, + canChangeCategory, + isPending, + selectedCount, + onRemovePress, + onModalClose, + } = props; + + const multipleSelected = selectedCount && selectedCount > 1; + + const [removalMethod, setRemovalMethod] = + useState('removeFromClient'); + const [blocklistMethod, setBlocklistMethod] = + useState('doNotBlocklist'); + + const { title, message } = useMemo(() => { + if (!selectedCount) { + return { + title: translate('RemoveQueueItem', { sourceTitle }), + message: translate('RemoveQueueItemConfirmation', { sourceTitle }), + }; + } + + if (selectedCount === 1) { + return { + title: translate('RemoveSelectedItem'), + message: translate('RemoveSelectedItemQueueMessageText'), + }; + } + + return { + title: translate('RemoveSelectedItems'), + message: translate('RemoveSelectedItemsQueueMessageText', { + selectedCount, + }), + }; + }, [sourceTitle, selectedCount]); + + const removalMethodOptions = useMemo(() => { + return [ + { + key: 'removeFromClient', + value: translate('RemoveFromDownloadClient'), + hint: multipleSelected + ? translate('RemoveMultipleFromDownloadClientHint') + : translate('RemoveFromDownloadClientHint'), + }, + { + key: 'changeCategory', + value: translate('ChangeCategory'), + isDisabled: !canChangeCategory, + hint: multipleSelected + ? translate('ChangeCategoryMultipleHint') + : translate('ChangeCategoryHint'), + }, + { + key: 'ignore', + value: multipleSelected + ? translate('IgnoreDownloads') + : translate('IgnoreDownload'), + isDisabled: !canIgnore, + hint: multipleSelected + ? translate('IgnoreDownloadsHint') + : translate('IgnoreDownloadHint'), + }, + ]; + }, [canChangeCategory, canIgnore, multipleSelected]); + + const blocklistMethodOptions = useMemo(() => { + return [ + { + key: 'doNotBlocklist', + value: translate('DoNotBlocklist'), + hint: translate('DoNotBlocklistHint'), + }, + { + key: 'blocklistAndSearch', + value: translate('BlocklistAndSearch'), + isDisabled: isPending, + hint: multipleSelected + ? translate('BlocklistAndSearchMultipleHint') + : translate('BlocklistAndSearchHint'), + }, + { + key: 'blocklistOnly', + value: translate('BlocklistOnly'), + hint: multipleSelected + ? translate('BlocklistMultipleOnlyHint') + : translate('BlocklistOnlyHint'), + }, + ]; + }, [isPending, multipleSelected]); + + const handleRemovalMethodChange = useCallback( + ({ value }: { value: RemovalMethod }) => { + setRemovalMethod(value); + }, + [setRemovalMethod] + ); + + const handleBlocklistMethodChange = useCallback( + ({ value }: { value: BlocklistMethod }) => { + setBlocklistMethod(value); + }, + [setBlocklistMethod] + ); + + const handleConfirmRemove = useCallback(() => { + onRemovePress({ + removeFromClient: removalMethod === 'removeFromClient', + changeCategory: removalMethod === 'changeCategory', + blocklist: blocklistMethod !== 'doNotBlocklist', + skipRedownload: blocklistMethod === 'blocklistOnly', + }); + + setRemovalMethod('removeFromClient'); + setBlocklistMethod('doNotBlocklist'); + }, [ + removalMethod, + blocklistMethod, + setRemovalMethod, + setBlocklistMethod, + onRemovePress, + ]); + + const handleModalClose = useCallback(() => { + setRemovalMethod('removeFromClient'); + setBlocklistMethod('doNotBlocklist'); + + onModalClose(); + }, [setRemovalMethod, setBlocklistMethod, onModalClose]); + + return ( + + + {title} + + +
    {message}
    + + {isPending ? null : ( + + {translate('RemoveQueueItemRemovalMethod')} + + + + )} + + + + {multipleSelected + ? translate('BlocklistReleases') + : translate('BlocklistRelease')} + + + + +
    + + + + + + +
    +
    + ); +} + +export default RemoveQueueItemModal; diff --git a/frontend/src/Activity/Queue/RemoveQueueItemsModal.css b/frontend/src/Activity/Queue/RemoveQueueItemsModal.css deleted file mode 100644 index c9ef59ec1..000000000 --- a/frontend/src/Activity/Queue/RemoveQueueItemsModal.css +++ /dev/null @@ -1,3 +0,0 @@ -.message { - margin-bottom: 30px; -} diff --git a/frontend/src/Activity/Queue/RemoveQueueItemsModal.js b/frontend/src/Activity/Queue/RemoveQueueItemsModal.js deleted file mode 100644 index b573c5cbd..000000000 --- a/frontend/src/Activity/Queue/RemoveQueueItemsModal.js +++ /dev/null @@ -1,141 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { inputTypes, kinds, sizes } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import Modal from 'Components/Modal/Modal'; -import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import styles from './RemoveQueueItemsModal.css'; - -class RemoveQueueItemsModal extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - blacklist: false, - skipredownload: false - }; - } - - // - // Listeners - - onBlacklistChange = ({ value }) => { - this.setState({ blacklist: value }); - } - - onSkipReDownloadChange = ({ value }) => { - this.setState({ skipredownload: value }); - } - - onRemoveQueueItemConfirmed = () => { - const blacklist = this.state.blacklist; - const skipredownload = this.state.skipredownload; - - this.setState({ - blacklist: false, - skipredownload: false - }); - this.props.onRemovePress(blacklist, skipredownload); - } - - onModalClose = () => { - this.setState({ - blacklist: false, - skipredownload: false - }); - this.props.onModalClose(); - } - - // - // Render - - render() { - const { - isOpen, - selectedCount - } = this.props; - - const blacklist = this.state.blacklist; - const skipredownload = this.state.skipredownload; - - return ( - - - - Remove Selected Item{selectedCount > 1 ? 's' : ''} - - - -
    - Are you sure you want to remove {selectedCount} item{selectedCount > 1 ? 's' : ''} from the queue? -
    - - - Blacklist Release - - - - { - blacklist && - - Skip Redownload - - - } - -
    - - - - - - -
    -
    - ); - } -} - -RemoveQueueItemsModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - selectedCount: PropTypes.number.isRequired, - onRemovePress: PropTypes.func.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default RemoveQueueItemsModal; diff --git a/frontend/src/Activity/Queue/Status/QueueStatusConnector.js b/frontend/src/Activity/Queue/Status/QueueStatusConnector.js index 090b8fc96..7f58f2810 100644 --- a/frontend/src/Activity/Queue/Status/QueueStatusConnector.js +++ b/frontend/src/Activity/Queue/Status/QueueStatusConnector.js @@ -2,8 +2,8 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { fetchQueueStatus } from 'Store/Actions/queueActions'; import PageSidebarStatus from 'Components/Page/Sidebar/PageSidebarStatus'; +import { fetchQueueStatus } from 'Store/Actions/queueActions'; function createMapStateToProps() { return createSelector( diff --git a/frontend/src/Activity/Queue/TimeleftCell.css.d.ts b/frontend/src/Activity/Queue/TimeleftCell.css.d.ts new file mode 100644 index 000000000..f5c9402d1 --- /dev/null +++ b/frontend/src/Activity/Queue/TimeleftCell.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'timeleft': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Activity/Queue/TimeleftCell.js b/frontend/src/Activity/Queue/TimeleftCell.js index c9515f172..b280b5a06 100644 --- a/frontend/src/Activity/Queue/TimeleftCell.js +++ b/frontend/src/Activity/Queue/TimeleftCell.js @@ -1,10 +1,14 @@ import PropTypes from 'prop-types'; import React from 'react'; +import Icon from 'Components/Icon'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import Tooltip from 'Components/Tooltip/Tooltip'; +import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import formatTime from 'Utilities/Date/formatTime'; import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; import getRelativeDate from 'Utilities/Date/getRelativeDate'; import formatBytes from 'Utilities/Number/formatBytes'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import translate from 'Utilities/String/translate'; import styles from './TimeleftCell.css'; function TimeleftCell(props) { @@ -19,35 +23,39 @@ function TimeleftCell(props) { timeFormat } = props; - if (status === 'Delay') { + if (status === 'delay') { const date = getRelativeDate(estimatedCompletionTime, shortDateFormat, showRelativeDates); const time = formatTime(estimatedCompletionTime, timeFormat, { includeMinuteZero: true }); return ( - - - + + } + tooltip={translate('DelayingDownloadUntil', { date, time })} + kind={kinds.INVERSE} + position={tooltipPositions.TOP} + /> ); } - if (status === 'DownloadClientUnavailable') { + if (status === 'downloadClientUnavailable') { const date = getRelativeDate(estimatedCompletionTime, shortDateFormat, showRelativeDates); const time = formatTime(estimatedCompletionTime, timeFormat, { includeMinuteZero: true }); return ( - - - + + } + tooltip={translate('RetryingDownloadOn', { date, time })} + kind={kinds.INVERSE} + position={tooltipPositions.TOP} + /> ); } - if (!timeleft) { + if (!timeleft || status === 'completed' || status === 'failed') { return ( - diff --git a/frontend/src/AddArtist/AddNewArtist/AddNewArtist.js b/frontend/src/AddArtist/AddNewArtist/AddNewArtist.js deleted file mode 100644 index 23affe605..000000000 --- a/frontend/src/AddArtist/AddNewArtist/AddNewArtist.js +++ /dev/null @@ -1,183 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { icons } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import Link from 'Components/Link/Link'; -import Icon from 'Components/Icon'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import TextInput from 'Components/Form/TextInput'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; -import AddNewArtistSearchResultConnector from './AddNewArtistSearchResultConnector'; -import styles from './AddNewArtist.css'; - -class AddNewArtist extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - term: props.term || '', - isFetching: false - }; - } - - componentDidMount() { - const term = this.state.term; - - if (term) { - this.props.onArtistLookupChange(term); - } - } - - componentDidUpdate(prevProps) { - const { - term, - isFetching - } = this.props; - - if (term && term !== prevProps.term) { - this.setState({ - term, - isFetching: true - }); - this.props.onArtistLookupChange(term); - } else if (isFetching !== prevProps.isFetching) { - this.setState({ - isFetching - }); - } - } - - // - // Listeners - - onSearchInputChange = ({ value }) => { - const hasValue = !!value.trim(); - - this.setState({ term: value, isFetching: hasValue }, () => { - if (hasValue) { - this.props.onArtistLookupChange(value); - } else { - this.props.onClearArtistLookup(); - } - }); - } - - onClearArtistLookupPress = () => { - this.setState({ term: '' }); - this.props.onClearArtistLookup(); - } - - // - // Render - - render() { - const { - error, - items - } = this.props; - - const term = this.state.term; - const isFetching = this.state.isFetching; - - return ( - - -
    -
    - -
    - - - - -
    - - { - isFetching && - - } - - { - !isFetching && !!error && -
    Failed to load search results, please try again.
    - } - - { - !isFetching && !error && !!items.length && -
    - { - items.map((item) => { - return ( - - ); - }) - } -
    - } - - { - !isFetching && !error && !items.length && !!term && -
    -
    Couldn't find any results for '{term}'
    -
    You can also search using MusicBrainz ID of an artist. eg. lidarr:cc197bad-dc9c-440d-a5b5-d52ba2e14234
    -
    - - Why can't I find my artist? - -
    -
    - } - - { - !term && -
    -
    It's easy to add a new artist, just start typing the name the artist you want to add.
    -
    You can also search using MusicBrainz ID of an artist. eg. lidarr:cc197bad-dc9c-440d-a5b5-d52ba2e14234
    -
    - } - -
    - - - ); - } -} - -AddNewArtist.propTypes = { - term: PropTypes.string, - isFetching: PropTypes.bool.isRequired, - error: PropTypes.object, - isAdding: PropTypes.bool.isRequired, - addError: PropTypes.object, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - onArtistLookupChange: PropTypes.func.isRequired, - onClearArtistLookup: PropTypes.func.isRequired -}; - -export default AddNewArtist; diff --git a/frontend/src/AddArtist/AddNewArtist/AddNewArtistConnector.js b/frontend/src/AddArtist/AddNewArtist/AddNewArtistConnector.js deleted file mode 100644 index 50cc07cd2..000000000 --- a/frontend/src/AddArtist/AddNewArtist/AddNewArtistConnector.js +++ /dev/null @@ -1,102 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import parseUrl from 'Utilities/String/parseUrl'; -import { lookupArtist, clearAddArtist } from 'Store/Actions/addArtistActions'; -import { fetchRootFolders } from 'Store/Actions/rootFolderActions'; -import AddNewArtist from './AddNewArtist'; - -function createMapStateToProps() { - return createSelector( - (state) => state.addArtist, - (state) => state.router.location, - (addArtist, location) => { - const { params } = parseUrl(location.search); - - return { - term: params.term, - ...addArtist - }; - } - ); -} - -const mapDispatchToProps = { - lookupArtist, - clearAddArtist, - fetchRootFolders -}; - -class AddNewArtistConnector extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this._artistLookupTimeout = null; - } - - componentDidMount() { - this.props.fetchRootFolders(); - } - - componentWillUnmount() { - if (this._artistLookupTimeout) { - clearTimeout(this._artistLookupTimeout); - } - - this.props.clearAddArtist(); - } - - // - // Listeners - - onArtistLookupChange = (term) => { - if (this._artistLookupTimeout) { - clearTimeout(this._artistLookupTimeout); - } - - if (term.trim() === '') { - this.props.clearAddArtist(); - } else { - this._artistLookupTimeout = setTimeout(() => { - this.props.lookupArtist({ term }); - }, 300); - } - } - - onClearArtistLookup = () => { - this.props.clearAddArtist(); - } - - // - // Render - - render() { - const { - term, - ...otherProps - } = this.props; - - return ( - - ); - } -} - -AddNewArtistConnector.propTypes = { - term: PropTypes.string, - lookupArtist: PropTypes.func.isRequired, - clearAddArtist: PropTypes.func.isRequired, - fetchRootFolders: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(AddNewArtistConnector); diff --git a/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.js b/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.js deleted file mode 100644 index 2278812b8..000000000 --- a/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.js +++ /dev/null @@ -1,241 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import TextTruncate from 'react-text-truncate'; -import { icons, kinds, inputTypes, tooltipPositions } from 'Helpers/Props'; -import Icon from 'Components/Icon'; -import SpinnerButton from 'Components/Link/SpinnerButton'; -import Form from 'Components/Form/Form'; -import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import CheckInput from 'Components/Form/CheckInput'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import Popover from 'Components/Tooltip/Popover'; -import ArtistPoster from 'Artist/ArtistPoster'; -import ArtistMonitoringOptionsPopoverContent from 'AddArtist/ArtistMonitoringOptionsPopoverContent'; -import styles from './AddNewArtistModalContent.css'; - -class AddNewArtistModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - searchForMissingAlbums: false - }; - } - - // - // Listeners - - onSearchForMissingAlbumsChange = ({ value }) => { - this.setState({ searchForMissingAlbums: value }); - } - - onQualityProfileIdChange = ({ value }) => { - this.props.onInputChange({ name: 'qualityProfileId', value: parseInt(value) }); - } - - onMetadataProfileIdChange = ({ value }) => { - this.props.onInputChange({ name: 'metadataProfileId', value: parseInt(value) }); - } - - onAddArtistPress = () => { - this.props.onAddArtistPress(this.state.searchForMissingAlbums); - } - - // - // Render - - render() { - const { - artistName, - overview, - images, - isAdding, - rootFolderPath, - monitor, - qualityProfileId, - metadataProfileId, - albumFolder, - tags, - showMetadataProfile, - isSmallScreen, - onModalClose, - onInputChange, - ...otherProps - } = this.props; - - return ( - - - {artistName} - - - -
    - { - isSmallScreen ? - null: -
    - -
    - } - -
    - { - overview ? -
    - -
    : - null - } - -
    - - Root Folder - - - - - - - Monitor - - - } - title="Monitoring Options" - body={} - position={tooltipPositions.RIGHT} - /> - - - - - - - Quality Profile - - - - - - Metadata Profile - - - - - - Album Folder - - - - - - Tags - - - - -
    -
    -
    - - - - - - Add {artistName} - - -
    - ); - } -} - -AddNewArtistModalContent.propTypes = { - artistName: PropTypes.string.isRequired, - overview: PropTypes.string, - images: PropTypes.arrayOf(PropTypes.object).isRequired, - isAdding: PropTypes.bool.isRequired, - addError: PropTypes.object, - rootFolderPath: PropTypes.object, - monitor: PropTypes.object.isRequired, - qualityProfileId: PropTypes.object, - metadataProfileId: PropTypes.object, - albumFolder: PropTypes.object.isRequired, - tags: PropTypes.object.isRequired, - showMetadataProfile: PropTypes.bool.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired, - onInputChange: PropTypes.func.isRequired, - onAddArtistPress: PropTypes.func.isRequired -}; - -export default AddNewArtistModalContent; diff --git a/frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResult.css b/frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResult.css deleted file mode 100644 index c56765538..000000000 --- a/frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResult.css +++ /dev/null @@ -1,42 +0,0 @@ -.searchResult { - display: flex; - margin: 20px 0; - padding: 20px; - width: 100%; - background-color: $white; - color: inherit; - transition: background 500ms; - - &:hover { - background-color: #eaf2ff; - color: inherit; - text-decoration: none; - } -} - -.poster { - flex: 0 0 170px; - margin-right: 20px; - height: 250px; -} - -.name { - font-weight: 300; - font-size: 36px; -} - -.year { - margin-left: 10px; - color: $disabledColor; -} - -.alreadyExistsIcon { - margin-left: 10px; - color: #37bc9b; -} - -.overview { - overflow: hidden; - margin-top: 20px; - text-align: justify; -} diff --git a/frontend/src/AddArtist/ArtistMetadataProfilePopoverContent.js b/frontend/src/AddArtist/ArtistMetadataProfilePopoverContent.js new file mode 100644 index 000000000..d7c663674 --- /dev/null +++ b/frontend/src/AddArtist/ArtistMetadataProfilePopoverContent.js @@ -0,0 +1,11 @@ +import React from 'react'; + +function ArtistMetadataProfilePopoverContent() { + return ( +
    + Select 'None' to only include items manually added via search or that match files on disk +
    + ); +} + +export default ArtistMetadataProfilePopoverContent; diff --git a/frontend/src/AddArtist/ArtistMonitorNewItemsOptionsPopoverContent.js b/frontend/src/AddArtist/ArtistMonitorNewItemsOptionsPopoverContent.js new file mode 100644 index 000000000..cda224e2f --- /dev/null +++ b/frontend/src/AddArtist/ArtistMonitorNewItemsOptionsPopoverContent.js @@ -0,0 +1,27 @@ +import React from 'react'; +import DescriptionList from 'Components/DescriptionList/DescriptionList'; +import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import translate from 'Utilities/String/translate'; + +function ArtistMonitorNewItemsOptionsPopoverContent() { + return ( + + + + + + + + ); +} + +export default ArtistMonitorNewItemsOptionsPopoverContent; diff --git a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css new file mode 100644 index 000000000..7393b9c35 --- /dev/null +++ b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css @@ -0,0 +1,5 @@ +.message { + composes: alert from '~Components/Alert.css'; + + margin-bottom: 30px; +} diff --git a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css.d.ts b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css.d.ts new file mode 100644 index 000000000..65c237dff --- /dev/null +++ b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.js b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.js index 5b53425a4..d53bda8e3 100644 --- a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.js +++ b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.js @@ -1,45 +1,55 @@ import React from 'react'; +import Alert from 'Components/Alert'; import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import { kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistMonitoringOptionsPopoverContent.css'; function ArtistMonitoringOptionsPopoverContent() { return ( - - + <> + + This is a one time adjustment to set which albums are monitored + - + + - + - + - + - + - - + + + + + ); } diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtist.js b/frontend/src/AddArtist/ImportArtist/Import/ImportArtist.js deleted file mode 100644 index 3ed2459d1..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtist.js +++ /dev/null @@ -1,173 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import getSelectedIds from 'Utilities/Table/getSelectedIds'; -import selectAll from 'Utilities/Table/selectAll'; -import toggleSelected from 'Utilities/Table/toggleSelected'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; -import ImportArtistTableConnector from './ImportArtistTableConnector'; -import ImportArtistFooterConnector from './ImportArtistFooterConnector'; - -class ImportArtist extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - allSelected: false, - allUnselected: false, - lastToggled: null, - selectedState: {}, - contentBody: null, - scrollTop: 0 - }; - } - - // - // Control - - setContentBodyRef = (ref) => { - this.setState({ contentBody: ref }); - } - - // - // Listeners - - getSelectedIds = () => { - return getSelectedIds(this.state.selectedState, { parseIds: false }); - } - - onSelectAllChange = ({ value }) => { - // Only select non-dupes - this.setState(selectAll(this.state.selectedState, value)); - } - - onSelectedChange = ({ id, value, shiftKey = false }) => { - this.setState((state) => { - return toggleSelected(state, this.props.items, id, value, shiftKey); - }); - } - - onRemoveSelectedStateItem = (id) => { - this.setState((state) => { - const selectedState = Object.assign({}, state.selectedState); - delete selectedState[id]; - - return { - ...state, - selectedState - }; - }); - } - - onInputChange = ({ name, value }) => { - this.props.onInputChange(this.getSelectedIds(), name, value); - } - - onImportPress = () => { - this.props.onImportPress(this.getSelectedIds()); - } - - onScroll = ({ scrollTop }) => { - this.setState({ scrollTop }); - } - - // - // Render - - render() { - const { - rootFolderId, - path, - rootFoldersFetching, - rootFoldersPopulated, - rootFoldersError, - unmappedFolders, - showMetadataProfile - } = this.props; - - const { - allSelected, - allUnselected, - selectedState, - contentBody - } = this.state; - - return ( - - - { - rootFoldersFetching && !rootFoldersPopulated && - - } - - { - !rootFoldersFetching && !!rootFoldersError && -
    Unable to load root folders
    - } - - { - !rootFoldersError && rootFoldersPopulated && !unmappedFolders.length && -
    - All artist in {path} have been imported -
    - } - - { - !rootFoldersError && rootFoldersPopulated && !!unmappedFolders.length && contentBody && - - } -
    - - { - !rootFoldersError && rootFoldersPopulated && !!unmappedFolders.length && - - } -
    - ); - } -} - -ImportArtist.propTypes = { - rootFolderId: PropTypes.number.isRequired, - path: PropTypes.string, - rootFoldersFetching: PropTypes.bool.isRequired, - rootFoldersPopulated: PropTypes.bool.isRequired, - rootFoldersError: PropTypes.object, - unmappedFolders: PropTypes.arrayOf(PropTypes.object), - items: PropTypes.arrayOf(PropTypes.object), - showMetadataProfile: PropTypes.bool.isRequired, - onInputChange: PropTypes.func.isRequired, - onImportPress: PropTypes.func.isRequired -}; - -ImportArtist.defaultProps = { - unmappedFolders: [] -}; - -export default ImportArtist; diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistConnector.js b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistConnector.js deleted file mode 100644 index 4ce182bbd..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistConnector.js +++ /dev/null @@ -1,170 +0,0 @@ -/* eslint max-params: 0 */ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setImportArtistValue, importArtist, clearImportArtist } from 'Store/Actions/importArtistActions'; -import { fetchRootFolders } from 'Store/Actions/rootFolderActions'; -import { setAddArtistDefault } from 'Store/Actions/addArtistActions'; -import createRouteMatchShape from 'Helpers/Props/Shapes/createRouteMatchShape'; -import ImportArtist from './ImportArtist'; - -function createMapStateToProps() { - return createSelector( - (state, { match }) => match, - (state) => state.rootFolders, - (state) => state.addArtist, - (state) => state.importArtist, - (state) => state.settings.qualityProfiles, - (state) => state.settings.metadataProfiles, - ( - match, - rootFolders, - addArtist, - importArtistState, - qualityProfiles, - metadataProfiles - ) => { - const { - isFetching: rootFoldersFetching, - isPopulated: rootFoldersPopulated, - error: rootFoldersError, - items - } = rootFolders; - - const rootFolderId = parseInt(match.params.rootFolderId); - - const result = { - rootFolderId, - rootFoldersFetching, - rootFoldersPopulated, - rootFoldersError, - qualityProfiles: qualityProfiles.items, - metadataProfiles: metadataProfiles.items, - showMetadataProfile: metadataProfiles.items.length > 1, - defaultQualityProfileId: addArtist.defaults.qualityProfileId, - defaultMetadataProfileId: addArtist.defaults.metadataProfileId - }; - - if (items.length) { - const rootFolder = _.find(items, { id: rootFolderId }); - - return { - ...result, - ...rootFolder, - items: importArtistState.items - }; - } - - return result; - } - ); -} - -const mapDispatchToProps = { - dispatchSetImportArtistValue: setImportArtistValue, - dispatchImportArtist: importArtist, - dispatchClearImportArtist: clearImportArtist, - dispatchFetchRootFolders: fetchRootFolders, - dispatchSetAddArtistDefault: setAddArtistDefault -}; - -class ImportArtistConnector extends Component { - - // - // Lifecycle - - componentDidMount() { - const { - qualityProfiles, - metadataProfiles, - defaultQualityProfileId, - defaultMetadataProfileId, - dispatchFetchRootFolders, - dispatchSetAddArtistDefault - } = this.props; - - if (!this.props.rootFoldersPopulated) { - dispatchFetchRootFolders(); - } - - let setDefaults = false; - const setDefaultPayload = {}; - - if ( - !defaultQualityProfileId || - !qualityProfiles.some((p) => p.id === defaultQualityProfileId) - ) { - setDefaults = true; - setDefaultPayload.qualityProfileId = qualityProfiles[0].id; - } - - if ( - !defaultMetadataProfileId || - !metadataProfiles.some((p) => p.id === defaultMetadataProfileId) - ) { - setDefaults = true; - setDefaultPayload.metadataProfileId = metadataProfiles[0].id; - } - - if (setDefaults) { - dispatchSetAddArtistDefault(setDefaultPayload); - } - } - - componentWillUnmount() { - this.props.dispatchClearImportArtist(); - } - - // - // Listeners - - onInputChange = (ids, name, value) => { - this.props.dispatchSetAddArtistDefault({ [name]: value }); - - ids.forEach((id) => { - this.props.dispatchSetImportArtistValue({ - id, - [name]: value - }); - }); - } - - onImportPress = (ids) => { - this.props.dispatchImportArtist({ ids }); - } - - // - // Render - - render() { - return ( - - ); - } -} - -const routeMatchShape = createRouteMatchShape({ - rootFolderId: PropTypes.string.isRequired -}); - -ImportArtistConnector.propTypes = { - match: routeMatchShape.isRequired, - rootFoldersPopulated: PropTypes.bool.isRequired, - qualityProfiles: PropTypes.arrayOf(PropTypes.object).isRequired, - metadataProfiles: PropTypes.arrayOf(PropTypes.object).isRequired, - defaultQualityProfileId: PropTypes.number.isRequired, - defaultMetadataProfileId: PropTypes.number.isRequired, - dispatchSetImportArtistValue: PropTypes.func.isRequired, - dispatchImportArtist: PropTypes.func.isRequired, - dispatchClearImportArtist: PropTypes.func.isRequired, - dispatchFetchRootFolders: PropTypes.func.isRequired, - dispatchSetAddArtistDefault: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(ImportArtistConnector); diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.css b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.css deleted file mode 100644 index 616aeaf3c..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.css +++ /dev/null @@ -1,33 +0,0 @@ -.inputContainer { - margin-right: 20px; - min-width: 150px; -} - -.label { - margin-bottom: 3px; - font-weight: bold; -} - -.importButtonContainer { - display: flex; - align-items: center; -} - -.importButton { - composes: button from '~Components/Link/SpinnerButton.css'; - - height: 35px; -} - -.loadingButton { - composes: importButton; - - margin-left: 10px; -} - -.loading { - composes: loading from '~Components/Loading/LoadingIndicator.css'; - - margin: 0 10px 0 12px; - text-align: left; -} diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.js b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.js deleted file mode 100644 index a0feaad89..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.js +++ /dev/null @@ -1,261 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { inputTypes, kinds } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import SpinnerButton from 'Components/Link/SpinnerButton'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import CheckInput from 'Components/Form/CheckInput'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import PageContentFooter from 'Components/Page/PageContentFooter'; -import styles from './ImportArtistFooter.css'; - -const MIXED = 'mixed'; - -class ImportArtistFooter extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - const { - defaultMonitor, - defaultQualityProfileId, - defaultMetadataProfileId, - defaultAlbumFolder - } = props; - - this.state = { - monitor: defaultMonitor, - qualityProfileId: defaultQualityProfileId, - metadataProfileId: defaultMetadataProfileId, - albumFolder: defaultAlbumFolder - }; - } - - componentDidUpdate(prevProps, prevState) { - const { - defaultMonitor, - defaultQualityProfileId, - defaultMetadataProfileId, - defaultAlbumFolder, - isMonitorMixed, - isQualityProfileIdMixed, - isMetadataProfileIdMixed, - isAlbumFolderMixed - } = this.props; - - const { - monitor, - qualityProfileId, - metadataProfileId, - albumFolder - } = this.state; - - const newState = {}; - - if (isMonitorMixed && monitor !== MIXED) { - newState.monitor = MIXED; - } else if (!isMonitorMixed && monitor !== defaultMonitor) { - newState.monitor = defaultMonitor; - } - - if (isQualityProfileIdMixed && qualityProfileId !== MIXED) { - newState.qualityProfileId = MIXED; - } else if (!isQualityProfileIdMixed && qualityProfileId !== defaultQualityProfileId) { - newState.qualityProfileId = defaultQualityProfileId; - } - - if (isMetadataProfileIdMixed && metadataProfileId !== MIXED) { - newState.metadataProfileId = MIXED; - } else if (!isMetadataProfileIdMixed && metadataProfileId !== defaultMetadataProfileId) { - newState.metadataProfileId = defaultMetadataProfileId; - } - - if (isAlbumFolderMixed && albumFolder != null) { - newState.albumFolder = null; - } else if (!isAlbumFolderMixed && albumFolder !== defaultAlbumFolder) { - newState.albumFolder = defaultAlbumFolder; - } - - if (!_.isEmpty(newState)) { - this.setState(newState); - } - } - - // - // Listeners - - onInputChange = ({ name, value }) => { - this.setState({ [name]: value }); - this.props.onInputChange({ name, value }); - } - - // - // Render - - render() { - const { - selectedCount, - isImporting, - isLookingUpArtist, - isMonitorMixed, - isQualityProfileIdMixed, - isMetadataProfileIdMixed, - hasUnsearchedItems, - showMetadataProfile, - onImportPress, - onLookupPress, - onCancelLookupPress - } = this.props; - - const { - monitor, - qualityProfileId, - metadataProfileId, - albumFolder - } = this.state; - - return ( - -
    -
    - Monitor -
    - - -
    - -
    -
    - Quality Profile -
    - - -
    - - { - showMetadataProfile && -
    -
    - Metadata Profile -
    - - -
    - } - -
    -
    - Album Folder -
    - - -
    - -
    -
    -   -
    - -
    - - Import {selectedCount} Artist(s) - - - { - isLookingUpArtist && - - } - - { - hasUnsearchedItems && - - } - - { - isLookingUpArtist && - - } - - { - isLookingUpArtist && - 'Processing Folders' - } -
    -
    -
    - ); - } -} - -ImportArtistFooter.propTypes = { - selectedCount: PropTypes.number.isRequired, - isImporting: PropTypes.bool.isRequired, - isLookingUpArtist: PropTypes.bool.isRequired, - defaultMonitor: PropTypes.string.isRequired, - defaultQualityProfileId: PropTypes.number, - defaultMetadataProfileId: PropTypes.number, - defaultAlbumFolder: PropTypes.bool.isRequired, - isMonitorMixed: PropTypes.bool.isRequired, - isQualityProfileIdMixed: PropTypes.bool.isRequired, - isMetadataProfileIdMixed: PropTypes.bool.isRequired, - isAlbumFolderMixed: PropTypes.bool.isRequired, - hasUnsearchedItems: PropTypes.bool.isRequired, - showMetadataProfile: PropTypes.bool.isRequired, - onInputChange: PropTypes.func.isRequired, - onImportPress: PropTypes.func.isRequired, - onLookupPress: PropTypes.func.isRequired, - onCancelLookupPress: PropTypes.func.isRequired -}; - -export default ImportArtistFooter; diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooterConnector.js b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooterConnector.js deleted file mode 100644 index 873d13b28..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooterConnector.js +++ /dev/null @@ -1,61 +0,0 @@ -import _ from 'lodash'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import ImportArtistFooter from './ImportArtistFooter'; -import { lookupUnsearchedArtist, cancelLookupArtist } from 'Store/Actions/importArtistActions'; - -function isMixed(items, selectedIds, defaultValue, key) { - return _.some(items, (artist) => { - return selectedIds.indexOf(artist.id) > -1 && artist[key] !== defaultValue; - }); -} - -function createMapStateToProps() { - return createSelector( - (state) => state.addArtist, - (state) => state.importArtist, - (state, { selectedIds }) => selectedIds, - (addArtist, importArtist, selectedIds) => { - const { - monitor: defaultMonitor, - qualityProfileId: defaultQualityProfileId, - metadataProfileId: defaultMetadataProfileId, - albumFolder: defaultAlbumFolder - } = addArtist.defaults; - - const { - isLookingUpArtist, - isImporting, - items - } = importArtist; - - const isMonitorMixed = isMixed(items, selectedIds, defaultMonitor, 'monitor'); - const isQualityProfileIdMixed = isMixed(items, selectedIds, defaultQualityProfileId, 'qualityProfileId'); - const isMetadataProfileIdMixed = isMixed(items, selectedIds, defaultMetadataProfileId, 'metadataProfileId'); - const isAlbumFolderMixed = isMixed(items, selectedIds, defaultAlbumFolder, 'albumFolder'); - const hasUnsearchedItems = !isLookingUpArtist && items.some((item) => !item.isPopulated); - - return { - selectedCount: selectedIds.length, - isLookingUpArtist, - isImporting, - defaultMonitor, - defaultQualityProfileId, - defaultMetadataProfileId, - defaultAlbumFolder, - isMonitorMixed, - isQualityProfileIdMixed, - isMetadataProfileIdMixed, - isAlbumFolderMixed, - hasUnsearchedItems - }; - } - ); -} - -const mapDispatchToProps = { - onLookupPress: lookupUnsearchedArtist, - onCancelLookupPress: cancelLookupArtist -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(ImportArtistFooter); diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistHeader.css b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistHeader.css deleted file mode 100644 index 52b918403..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistHeader.css +++ /dev/null @@ -1,38 +0,0 @@ -.folder { - composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; - - flex: 1 0 200px; -} - -.monitor { - composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; - - flex: 0 1 200px; - min-width: 185px; -} - -.qualityProfile, -.metadataProfile { - composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; - - flex: 0 1 250px; - min-width: 170px; -} - -.albumFolder { - composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; - - flex: 0 1 150px; - min-width: 120px; -} - -.artist { - composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; - - flex: 0 1 400px; - min-width: 300px; -} - -.detailsIcon { - margin-left: 8px; -} diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistHeader.js b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistHeader.js deleted file mode 100644 index fb0a01cb7..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistHeader.js +++ /dev/null @@ -1,96 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { icons, tooltipPositions } from 'Helpers/Props'; -import Icon from 'Components/Icon'; -import Popover from 'Components/Tooltip/Popover'; -import VirtualTableHeader from 'Components/Table/VirtualTableHeader'; -import VirtualTableHeaderCell from 'Components/Table/VirtualTableHeaderCell'; -import VirtualTableSelectAllHeaderCell from 'Components/Table/VirtualTableSelectAllHeaderCell'; -import ArtistMonitoringOptionsPopoverContent from 'AddArtist/ArtistMonitoringOptionsPopoverContent'; -// import SeriesTypePopoverContent from 'AddArtist/SeriesTypePopoverContent'; -import styles from './ImportArtistHeader.css'; - -function ImportArtistHeader(props) { - const { - showMetadataProfile, - allSelected, - allUnselected, - onSelectAllChange - } = props; - - return ( - - - - - Folder - - - - Monitor - - - } - title="Monitoring Options" - body={} - position={tooltipPositions.RIGHT} - /> - - - - Quality Profile - - - { - showMetadataProfile && - - Metadata Profile - - } - - - Album Folder - - - - Artist - - - ); -} - -ImportArtistHeader.propTypes = { - showMetadataProfile: PropTypes.bool.isRequired, - allSelected: PropTypes.bool.isRequired, - allUnselected: PropTypes.bool.isRequired, - onSelectAllChange: PropTypes.func.isRequired -}; - -export default ImportArtistHeader; diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRow.css b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRow.css deleted file mode 100644 index f5e6ed2e5..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRow.css +++ /dev/null @@ -1,45 +0,0 @@ -.selectInput { - composes: input from '~Components/Form/CheckInput.css'; -} - -.folder { - composes: cell from '~Components/Table/Cells/VirtualTableRowCell.css'; - - flex: 1 0 200px; - line-height: 36px; -} - -.monitor { - composes: cell from '~Components/Table/Cells/VirtualTableRowCell.css'; - - flex: 0 1 200px; - min-width: 185px; -} - -.qualityProfile, -.metadataProfile { - composes: cell from '~Components/Table/Cells/VirtualTableRowCell.css'; - - flex: 0 1 250px; - min-width: 170px; -} - -.albumFolder { - composes: cell from '~Components/Table/Cells/VirtualTableRowCell.css'; - - flex: 0 1 150px; - min-width: 120px; -} - -.artist { - composes: cell from '~Components/Table/Cells/VirtualTableRowCell.css'; - - flex: 0 1 400px; - min-width: 300px; -} - -.hideMetadataProfile { - composes: cell from '~Components/Table/Cells/VirtualTableRowCell.css'; - - display: none; -} diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRow.js b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRow.js deleted file mode 100644 index ca3f32132..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRow.js +++ /dev/null @@ -1,109 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { inputTypes } from 'Helpers/Props'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import VirtualTableRow from 'Components/Table/VirtualTableRow'; -import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; -import VirtualTableSelectCell from 'Components/Table/Cells/VirtualTableSelectCell'; -import ImportArtistSelectArtistConnector from './SelectArtist/ImportArtistSelectArtistConnector'; -import styles from './ImportArtistRow.css'; - -function ImportArtistRow(props) { - const { - style, - id, - monitor, - qualityProfileId, - metadataProfileId, - albumFolder, - selectedArtist, - isExistingArtist, - showMetadataProfile, - isSelected, - onSelectedChange, - onInputChange - } = props; - - return ( - - - - - {id} - - - - - - - - - - - - - - - - - - - - - - - ); -} - -ImportArtistRow.propTypes = { - style: PropTypes.object.isRequired, - id: PropTypes.string.isRequired, - monitor: PropTypes.string.isRequired, - qualityProfileId: PropTypes.number.isRequired, - metadataProfileId: PropTypes.number.isRequired, - albumFolder: PropTypes.bool.isRequired, - selectedArtist: PropTypes.object, - isExistingArtist: PropTypes.bool.isRequired, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - showMetadataProfile: PropTypes.bool.isRequired, - isSelected: PropTypes.bool, - onSelectedChange: PropTypes.func.isRequired, - onInputChange: PropTypes.func.isRequired -}; - -ImportArtistRow.defaultsProps = { - items: [] -}; - -export default ImportArtistRow; diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRowConnector.js b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRowConnector.js deleted file mode 100644 index 2480bfdb6..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRowConnector.js +++ /dev/null @@ -1,87 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setImportArtistValue } from 'Store/Actions/importArtistActions'; -import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; -import ImportArtistRow from './ImportArtistRow'; - -function createImportArtistItemSelector() { - return createSelector( - (state, { id }) => id, - (state) => state.importArtist.items, - (id, items) => { - return _.find(items, { id }) || {}; - } - ); -} - -function createMapStateToProps() { - return createSelector( - createImportArtistItemSelector(), - createAllArtistSelector(), - (item, artist) => { - const selectedArtist = item && item.selectedArtist; - const isExistingArtist = !!selectedArtist && _.some(artist, { foreignArtistId: selectedArtist.foreignArtistId }); - - return { - ...item, - isExistingArtist - }; - } - ); -} - -const mapDispatchToProps = { - setImportArtistValue -}; - -class ImportArtistRowConnector extends Component { - - // - // Listeners - - onInputChange = ({ name, value }) => { - this.props.setImportArtistValue({ - id: this.props.id, - [name]: value - }); - } - - // - // Render - - render() { - // Don't show the row until we have the information we require for it. - - const { - items, - monitor, - albumFolder - } = this.props; - - if (!items || !monitor || !albumFolder == null) { - return null; - } - - return ( - - ); - } -} - -ImportArtistRowConnector.propTypes = { - rootFolderId: PropTypes.number.isRequired, - id: PropTypes.string.isRequired, - monitor: PropTypes.string, - albumFolder: PropTypes.bool, - items: PropTypes.arrayOf(PropTypes.object), - setImportArtistValue: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(ImportArtistRowConnector); diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistSelected.css b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistSelected.css deleted file mode 100644 index 51fe4ce39..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistSelected.css +++ /dev/null @@ -1,3 +0,0 @@ -.input { - composes: input from '~Components/Form/CheckInput.css'; -} diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistTable.js b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistTable.js deleted file mode 100644 index f2c5f92eb..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistTable.js +++ /dev/null @@ -1,194 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import VirtualTable from 'Components/Table/VirtualTable'; -import ImportArtistHeader from './ImportArtistHeader'; -import ImportArtistRowConnector from './ImportArtistRowConnector'; - -class ImportArtistTable extends Component { - - // - // Lifecycle - - componentDidMount() { - const { - unmappedFolders, - defaultMonitor, - defaultQualityProfileId, - defaultMetadataProfileId, - defaultAlbumFolder, - onArtistLookup, - onSetImportArtistValue - } = this.props; - - const values = { - monitor: defaultMonitor, - qualityProfileId: defaultQualityProfileId, - metadataProfileId: defaultMetadataProfileId, - albumFolder: defaultAlbumFolder - }; - - unmappedFolders.forEach((unmappedFolder) => { - const id = unmappedFolder.name; - - onArtistLookup(id, unmappedFolder.path); - - onSetImportArtistValue({ - id, - ...values - }); - }); - } - - // This isn't great, but it's the most reliable way to ensure the items - // are checked off even if they aren't actually visible since the cells - // are virtualized. - - componentDidUpdate(prevProps) { - const { - items, - selectedState, - onSelectedChange, - onRemoveSelectedStateItem - } = this.props; - - prevProps.items.forEach((prevItem) => { - const { - id - } = prevItem; - - const item = _.find(items, { id }); - - if (!item) { - onRemoveSelectedStateItem(id); - return; - } - - const selectedArtist = item.selectedArtist; - const isSelected = selectedState[id]; - - const isExistingArtist = !!selectedArtist && - _.some(prevProps.allArtists, { foreignArtistId: selectedArtist.foreignArtistId }); - - // Props doesn't have a selected artist or - // the selected artist is an existing artist. - if ((!selectedArtist && prevItem.selectedArtist) || (isExistingArtist && !prevItem.selectedArtist)) { - onSelectedChange({ id, value: false }); - - return; - } - - // State is selected, but a artist isn't selected or - // the selected artist is an existing artist. - if (isSelected && (!selectedArtist || isExistingArtist)) { - onSelectedChange({ id, value: false }); - - return; - } - - // A artist is being selected that wasn't previously selected. - if (selectedArtist && selectedArtist !== prevItem.selectedArtist) { - onSelectedChange({ id, value: true }); - - return; - } - }); - } - - // - // Control - - rowRenderer = ({ key, rowIndex, style }) => { - const { - rootFolderId, - items, - selectedState, - showMetadataProfile, - onSelectedChange - } = this.props; - - const item = items[rowIndex]; - - return ( - - ); - } - - // - // Render - - render() { - const { - items, - allSelected, - allUnselected, - isSmallScreen, - contentBody, - showMetadataProfile, - scrollTop, - selectedState, - onSelectAllChange, - onScroll - } = this.props; - - if (!items.length) { - return null; - } - - return ( - - } - selectedState={selectedState} - onScroll={onScroll} - /> - ); - } -} - -ImportArtistTable.propTypes = { - rootFolderId: PropTypes.number.isRequired, - items: PropTypes.arrayOf(PropTypes.object), - unmappedFolders: PropTypes.arrayOf(PropTypes.object), - defaultMonitor: PropTypes.string.isRequired, - defaultQualityProfileId: PropTypes.number, - defaultMetadataProfileId: PropTypes.number, - defaultAlbumFolder: PropTypes.bool.isRequired, - allSelected: PropTypes.bool.isRequired, - allUnselected: PropTypes.bool.isRequired, - selectedState: PropTypes.object.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - allArtists: PropTypes.arrayOf(PropTypes.object), - contentBody: PropTypes.object.isRequired, - showMetadataProfile: PropTypes.bool.isRequired, - scrollTop: PropTypes.number.isRequired, - onSelectAllChange: PropTypes.func.isRequired, - onSelectedChange: PropTypes.func.isRequired, - onRemoveSelectedStateItem: PropTypes.func.isRequired, - onArtistLookup: PropTypes.func.isRequired, - onSetImportArtistValue: PropTypes.func.isRequired, - onScroll: PropTypes.func.isRequired -}; - -export default ImportArtistTable; diff --git a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistTableConnector.js b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistTableConnector.js deleted file mode 100644 index fd7bf4fe2..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/ImportArtistTableConnector.js +++ /dev/null @@ -1,43 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { queueLookupArtist, setImportArtistValue } from 'Store/Actions/importArtistActions'; -import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; -import ImportArtistTable from './ImportArtistTable'; - -function createMapStateToProps() { - return createSelector( - (state) => state.addArtist, - (state) => state.importArtist, - (state) => state.app.dimensions, - createAllArtistSelector(), - (addArtist, importArtist, dimensions, allArtists) => { - return { - defaultMonitor: addArtist.defaults.monitor, - defaultQualityProfileId: addArtist.defaults.qualityProfileId, - defaultMetadataProfileId: addArtist.defaults.metadataProfileId, - defaultAlbumFolder: addArtist.defaults.albumFolder, - items: importArtist.items, - isSmallScreen: dimensions.isSmallScreen, - allArtists - }; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onArtistLookup(name, path) { - dispatch(queueLookupArtist({ - name, - path, - term: name - })); - }, - - onSetImportArtistValue(values) { - dispatch(setImportArtistValue(values)); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(ImportArtistTable); diff --git a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistName.css b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistName.css deleted file mode 100644 index fc86c41d1..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistName.css +++ /dev/null @@ -1,19 +0,0 @@ -.artistNameContainer { - display: flex; - align-items: center; - flex: 0 1 auto; - overflow: hidden; -} - -.artistName { - @add-mixin truncate; -} - -.disambiguation { - margin-right: 5px; - color: $disabledColor; -} - -.existing { - margin-left: 5px; -} diff --git a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistName.js b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistName.js deleted file mode 100644 index 1d9fb21b7..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistName.js +++ /dev/null @@ -1,41 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { kinds } from 'Helpers/Props'; -import Label from 'Components/Label'; -import styles from './ImportArtistName.css'; - -function ImportArtistName(props) { - const { - artistName, - disambiguation, - isExistingArtist - } = props; - - return ( -
    -
    - {artistName} -
    -
    - {disambiguation} -
    - - { - isExistingArtist && - - } -
    - ); -} - -ImportArtistName.propTypes = { - artistName: PropTypes.string.isRequired, - disambiguation: PropTypes.string, - isExistingArtist: PropTypes.bool.isRequired -}; - -export default ImportArtistName; diff --git a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResult.css b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResult.css deleted file mode 100644 index f7bc065b5..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResult.css +++ /dev/null @@ -1,8 +0,0 @@ -.artist { - padding: 10px 20px; - width: 100%; - - &:hover { - background-color: $menuItemHoverBackgroundColor; - } -} diff --git a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResult.js b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResult.js deleted file mode 100644 index aa489f0fb..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResult.js +++ /dev/null @@ -1,52 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import Link from 'Components/Link/Link'; -import ImportArtistName from './ImportArtistName'; -import styles from './ImportArtistSearchResult.css'; - -class ImportArtistSearchResult extends Component { - - // - // Listeners - - onPress = () => { - this.props.onPress(this.props.foreignArtistId); - } - - // - // Render - - render() { - const { - artistName, - disambiguation, - // year, - isExistingArtist - } = this.props; - - return ( - - - - ); - } -} - -ImportArtistSearchResult.propTypes = { - foreignArtistId: PropTypes.string.isRequired, - artistName: PropTypes.string.isRequired, - disambiguation: PropTypes.string, - // year: PropTypes.number.isRequired, - isExistingArtist: PropTypes.bool.isRequired, - onPress: PropTypes.func.isRequired -}; - -export default ImportArtistSearchResult; diff --git a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResultConnector.js b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResultConnector.js deleted file mode 100644 index cdbcc03b3..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResultConnector.js +++ /dev/null @@ -1,17 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createExistingArtistSelector from 'Store/Selectors/createExistingArtistSelector'; -import ImportArtistSearchResult from './ImportArtistSearchResult'; - -function createMapStateToProps() { - return createSelector( - createExistingArtistSelector(), - (isExistingArtist) => { - return { - isExistingArtist - }; - } - ); -} - -export default connect(createMapStateToProps)(ImportArtistSearchResult); diff --git a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtist.css b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtist.css deleted file mode 100644 index 6bdfd093e..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtist.css +++ /dev/null @@ -1,77 +0,0 @@ -.button { - composes: link from '~Components/Link/Link.css'; - - display: flex; - align-items: center; - padding: 6px 16px; - width: 100%; - height: 35px; - border: 1px solid $inputBorderColor; - border-radius: 4px; - background-color: $white; - box-shadow: inset 0 1px 1px $inputBoxShadowColor; -} - -.loading { - display: inline-block; -} - -.warningIcon { - margin-right: 8px; -} - -.existing { - margin-left: 5px; -} - -.dropdownArrowContainer { - flex: 1 0 auto; - margin-left: 5px; - text-align: right; -} - -.contentContainer { - z-index: $popperZIndex; - margin-top: 4px; - /* 400px container witdh with 8px padding on each side */ - width: 384px; -} - -.content { - padding: 4px; - border: 1px solid $inputBorderColor; - border-radius: 4px; - background-color: $white; -} - -.searchContainer { - display: flex; -} - -.searchIconContainer { - width: 58px; - border: 1px solid $inputBorderColor; - border-right: none; - border-radius: 4px; - border-top-right-radius: 0; - border-bottom-right-radius: 0; - background-color: #edf1f2; - text-align: center; - line-height: 33px; -} - -.searchInput { - composes: input from '~Components/Form/TextInput.css'; - - border-radius: 0; -} - -.results { - @add-mixin scrollbar; - @add-mixin scrollbarTrack; - @add-mixin scrollbarThumb; - - overflow-x: hidden; - overflow-y: scroll; - max-height: 165px; -} diff --git a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtist.js b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtist.js deleted file mode 100644 index 68c448d1c..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtist.js +++ /dev/null @@ -1,303 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { Manager, Popper, Reference } from 'react-popper'; -import getUniqueElememtId from 'Utilities/getUniqueElementId'; -import { icons, kinds } from 'Helpers/Props'; -import Icon from 'Components/Icon'; -import Portal from 'Components/Portal'; -import FormInputButton from 'Components/Form/FormInputButton'; -import Link from 'Components/Link/Link'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import TextInput from 'Components/Form/TextInput'; -import ImportArtistSearchResultConnector from './ImportArtistSearchResultConnector'; -import ImportArtistName from './ImportArtistName'; -import styles from './ImportArtistSelectArtist.css'; - -class ImportArtistSelectArtist extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this._artistLookupTimeout = null; - this._scheduleUpdate = null; - this._buttonId = getUniqueElememtId(); - this._contentId = getUniqueElememtId(); - - this.state = { - term: props.id, - isOpen: false - }; - } - - componentDidUpdate() { - if (this._scheduleUpdate) { - this._scheduleUpdate(); - } - } - - // - // Control - - _addListener() { - window.addEventListener('click', this.onWindowClick); - } - - _removeListener() { - window.removeEventListener('click', this.onWindowClick); - } - - // - // Listeners - - onWindowClick = (event) => { - const button = document.getElementById(this._buttonId); - const content = document.getElementById(this._contentId); - - if (!button || !content) { - return; - } - - if ( - !button.contains(event.target) && - !content.contains(event.target) && - this.state.isOpen - ) { - this.setState({ isOpen: false }); - this._removeListener(); - } - } - - onPress = () => { - if (this.state.isOpen) { - this._removeListener(); - } else { - this._addListener(); - } - - this.setState({ isOpen: !this.state.isOpen }); - } - - onSearchInputChange = ({ value }) => { - if (this._artistLookupTimeout) { - clearTimeout(this._artistLookupTimeout); - } - - this.setState({ term: value }, () => { - this._artistLookupTimeout = setTimeout(() => { - this.props.onSearchInputChange(value); - }, 200); - }); - } - - onRefreshPress = () => { - this.props.onSearchInputChange(this.state.term); - } - - onArtistSelect = (foreignArtistId) => { - this.setState({ isOpen: false }); - - this.props.onArtistSelect(foreignArtistId); - } - - // - // Render - - render() { - const { - selectedArtist, - isExistingArtist, - isFetching, - isPopulated, - error, - items, - isQueued, - isLookingUpArtist - } = this.props; - - const errorMessage = error && - error.responseJSON && - error.responseJSON.message; - - return ( - - - {({ ref }) => ( -
    - - { - isLookingUpArtist && isQueued && !isPopulated ? - : - null - } - - { - isPopulated && selectedArtist && isExistingArtist ? - : - null - } - - { - isPopulated && selectedArtist ? - : - null - } - - { - isPopulated && !selectedArtist ? -
    - - - No match found! -
    : - null - } - - { - !isFetching && !!error ? -
    - - - Search failed, please try again later. -
    : - null - } - -
    - -
    - -
    - )} -
    - - - - {({ ref, style, scheduleUpdate }) => { - this._scheduleUpdate = scheduleUpdate; - - return ( -
    - { - this.state.isOpen ? -
    -
    -
    - -
    - - - - - - -
    - -
    - { - items.map((item) => { - return ( - - ); - }) - } -
    -
    : - null - } - -
    - ); - }} -
    -
    -
    - ); - } -} - -ImportArtistSelectArtist.propTypes = { - id: PropTypes.string.isRequired, - selectedArtist: PropTypes.object, - isExistingArtist: PropTypes.bool.isRequired, - isFetching: PropTypes.bool.isRequired, - isPopulated: PropTypes.bool.isRequired, - error: PropTypes.object, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - isQueued: PropTypes.bool.isRequired, - isLookingUpArtist: PropTypes.bool.isRequired, - onSearchInputChange: PropTypes.func.isRequired, - onArtistSelect: PropTypes.func.isRequired -}; - -ImportArtistSelectArtist.defaultProps = { - isFetching: true, - isPopulated: false, - items: [], - isQueued: true -}; - -export default ImportArtistSelectArtist; diff --git a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtistConnector.js b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtistConnector.js deleted file mode 100644 index 21e2bcab2..000000000 --- a/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtistConnector.js +++ /dev/null @@ -1,76 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { queueLookupArtist, setImportArtistValue } from 'Store/Actions/importArtistActions'; -import createImportArtistItemSelector from 'Store/Selectors/createImportArtistItemSelector'; -import ImportArtistSelectArtist from './ImportArtistSelectArtist'; - -function createMapStateToProps() { - return createSelector( - (state) => state.importArtist.isLookingUpArtist, - createImportArtistItemSelector(), - (isLookingUpArtist, item) => { - return { - isLookingUpArtist, - ...item - }; - } - ); -} - -const mapDispatchToProps = { - queueLookupArtist, - setImportArtistValue -}; - -class ImportArtistSelectArtistConnector extends Component { - - // - // Listeners - - onSearchInputChange = (term) => { - this.props.queueLookupArtist({ - name: this.props.id, - term, - topOfQueue: true - }); - } - - onArtistSelect = (foreignArtistId) => { - const { - id, - items - } = this.props; - - this.props.setImportArtistValue({ - id, - selectedArtist: _.find(items, { foreignArtistId }) - }); - } - - // - // Render - - render() { - return ( - - ); - } -} - -ImportArtistSelectArtistConnector.propTypes = { - id: PropTypes.string.isRequired, - items: PropTypes.arrayOf(PropTypes.object), - selectedArtist: PropTypes.object, - isSelected: PropTypes.bool, - queueLookupArtist: PropTypes.func.isRequired, - setImportArtistValue: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(ImportArtistSelectArtistConnector); diff --git a/frontend/src/AddArtist/ImportArtist/ImportArtist.js b/frontend/src/AddArtist/ImportArtist/ImportArtist.js deleted file mode 100644 index ce5ec27ee..000000000 --- a/frontend/src/AddArtist/ImportArtist/ImportArtist.js +++ /dev/null @@ -1,30 +0,0 @@ -import React, { Component } from 'react'; -import { Route } from 'react-router-dom'; -import Switch from 'Components/Router/Switch'; -import ImportArtistSelectFolderConnector from 'AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolderConnector'; -import ImportArtistConnector from 'AddArtist/ImportArtist/Import/ImportArtistConnector'; - -class ImportArtist extends Component { - - // - // Render - - render() { - return ( - - - - - - ); - } -} - -export default ImportArtist; diff --git a/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolder.css b/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolder.css deleted file mode 100644 index 030da96fb..000000000 --- a/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolder.css +++ /dev/null @@ -1,32 +0,0 @@ -.header { - margin-bottom: 40px; - text-align: center; - font-weight: 300; - font-size: 36px; -} - -.tips { - font-size: 20px; -} - -.tip { - font-size: $defaultFontSize; -} - -.code { - font-size: 12px; - font-family: $monoSpaceFontFamily; -} - -.recentFolders { - margin-top: 40px; -} - -.startImport { - margin-top: 40px; - text-align: center; -} - -.importButtonIcon { - margin-right: 8px; -} diff --git a/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolder.js b/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolder.js deleted file mode 100644 index 9a7253ec7..000000000 --- a/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolder.js +++ /dev/null @@ -1,147 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { icons, kinds, sizes } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import FieldSet from 'Components/FieldSet'; -import Icon from 'Components/Icon'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import FileBrowserModal from 'Components/FileBrowser/FileBrowserModal'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; -import RootFolders from 'RootFolder/RootFolders'; -import styles from './ImportArtistSelectFolder.css'; - -class ImportArtistSelectFolder extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - isAddNewRootFolderModalOpen: false - }; - } - - // - // Lifecycle - - onAddNewRootFolderPress = () => { - this.setState({ isAddNewRootFolderModalOpen: true }); - } - - onNewRootFolderSelect = ({ value }) => { - this.props.onNewRootFolderSelect(value); - } - - onAddRootFolderModalClose = () => { - this.setState({ isAddNewRootFolderModalOpen: false }); - } - - // - // Render - - render() { - const { - isWindows, - isFetching, - isPopulated, - error, - items - } = this.props; - - return ( - - - { - isFetching && !isPopulated && - - } - - { - !isFetching && !!error && -
    Unable to load root folders
    - } - - { - !error && isPopulated && -
    -
    - Import artist(s) you already have -
    - -
    - Some tips to ensure the import goes smoothly: -
      -
    • - Point Lidarr to the folder containing all of your music not a specific one. eg. "{isWindows ? 'C:\\music' : '/music'}" and not "{isWindows ? 'C:\\music\\sublime' : '/music/sublime'}" -
    • -
    -
    - - { - items.length > 0 ? -
    -
    - -
    - - -
    : - -
    - -
    - } - - -
    - } -
    -
    - ); - } -} - -ImportArtistSelectFolder.propTypes = { - isWindows: PropTypes.bool.isRequired, - isFetching: PropTypes.bool.isRequired, - isPopulated: PropTypes.bool.isRequired, - error: PropTypes.object, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - onNewRootFolderSelect: PropTypes.func.isRequired -}; - -export default ImportArtistSelectFolder; diff --git a/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolderConnector.js b/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolderConnector.js deleted file mode 100644 index 8354ed4da..000000000 --- a/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolderConnector.js +++ /dev/null @@ -1,84 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { push } from 'connected-react-router'; -import createSystemStatusSelector from 'Store/Selectors/createSystemStatusSelector'; -import { fetchRootFolders, addRootFolder } from 'Store/Actions/rootFolderActions'; -import ImportArtistSelectFolder from './ImportArtistSelectFolder'; - -function createMapStateToProps() { - return createSelector( - (state) => state.rootFolders, - createSystemStatusSelector(), - (rootFolders, systemStatus) => { - return { - ...rootFolders, - isWindows: systemStatus.isWindows - }; - } - ); -} - -const mapDispatchToProps = { - fetchRootFolders, - addRootFolder, - push -}; - -class ImportArtistSelectFolderConnector extends Component { - - // - // Lifecycle - - componentDidMount() { - this.props.fetchRootFolders(); - } - - componentDidUpdate(prevProps) { - const { - items, - isSaving, - saveError - } = this.props; - - if (prevProps.isSaving && !isSaving && !saveError) { - const newRootFolders = _.differenceBy(items, prevProps.items, (item) => item.id); - - if (newRootFolders.length === 1) { - this.props.push(`${window.Lidarr.urlBase}/add/import/${newRootFolders[0].id}`); - } - } - } - - // - // Listeners - - onNewRootFolderSelect = (path) => { - this.props.addRootFolder({ path }); - } - - // - // Render - - render() { - return ( - - ); - } -} - -ImportArtistSelectFolderConnector.propTypes = { - isSaving: PropTypes.bool.isRequired, - saveError: PropTypes.object, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - fetchRootFolders: PropTypes.func.isRequired, - addRootFolder: PropTypes.func.isRequired, - push: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(ImportArtistSelectFolderConnector); diff --git a/frontend/src/Album/Album.ts b/frontend/src/Album/Album.ts new file mode 100644 index 000000000..86f1ed5fe --- /dev/null +++ b/frontend/src/Album/Album.ts @@ -0,0 +1,27 @@ +import ModelBase from 'App/ModelBase'; +import Artist from 'Artist/Artist'; + +export interface Statistics { + trackCount: number; + trackFileCount: number; + percentOfTracks: number; + sizeOnDisk: number; + totalTrackCount: number; +} + +interface Album extends ModelBase { + artistId: number; + artist: Artist; + foreignAlbumId: string; + title: string; + overview: string; + disambiguation?: string; + albumType: string; + monitored: boolean; + releaseDate: string; + statistics: Statistics; + lastSearchTime?: string; + isSaving?: boolean; +} + +export default Album; diff --git a/frontend/src/Album/AlbumFormats.js b/frontend/src/Album/AlbumFormats.js new file mode 100644 index 000000000..1591fa714 --- /dev/null +++ b/frontend/src/Album/AlbumFormats.js @@ -0,0 +1,33 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import Label from 'Components/Label'; +import { kinds } from 'Helpers/Props'; + +function AlbumFormats({ formats }) { + return ( +
    + { + formats.map((format) => { + return ( + + ); + }) + } +
    + ); +} + +AlbumFormats.propTypes = { + formats: PropTypes.arrayOf(PropTypes.object).isRequired +}; + +AlbumFormats.defaultProps = { + formats: [] +}; + +export default AlbumFormats; diff --git a/frontend/src/Album/AlbumSearchCell.css.d.ts b/frontend/src/Album/AlbumSearchCell.css.d.ts new file mode 100644 index 000000000..154740212 --- /dev/null +++ b/frontend/src/Album/AlbumSearchCell.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'AlbumSearchCell': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/AlbumSearchCell.js b/frontend/src/Album/AlbumSearchCell.js index 9cd41f3f1..f9ca44800 100644 --- a/frontend/src/Album/AlbumSearchCell.js +++ b/frontend/src/Album/AlbumSearchCell.js @@ -1,9 +1,10 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons } from 'Helpers/Props'; 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 AlbumInteractiveSearchModalConnector from './Search/AlbumInteractiveSearchModalConnector'; import styles from './AlbumSearchCell.css'; @@ -25,11 +26,11 @@ class AlbumSearchCell extends Component { onManualSearchPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; // // Render @@ -49,11 +50,13 @@ class AlbumSearchCell extends Component { name={icons.SEARCH} isSpinning={isSearching} onPress={onSearchPress} + title={translate('AutomaticSearch')} /> - {title}{disambiguation ? ` (${disambiguation})` : ''} + + {albumTitle} ); } diff --git a/frontend/src/Artist/Editor/Organize/OrganizeArtistModal.js b/frontend/src/Album/Delete/DeleteAlbumModal.js similarity index 60% rename from frontend/src/Artist/Editor/Organize/OrganizeArtistModal.js rename to frontend/src/Album/Delete/DeleteAlbumModal.js index 412396355..303010ca3 100644 --- a/frontend/src/Artist/Editor/Organize/OrganizeArtistModal.js +++ b/frontend/src/Album/Delete/DeleteAlbumModal.js @@ -1,9 +1,10 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; -import OrganizeArtistModalContentConnector from './OrganizeArtistModalContentConnector'; +import { sizes } from 'Helpers/Props'; +import DeleteAlbumModalContentConnector from './DeleteAlbumModalContentConnector'; -function OrganizeArtistModal(props) { +function DeleteAlbumModal(props) { const { isOpen, onModalClose, @@ -13,9 +14,10 @@ function OrganizeArtistModal(props) { return ( - @@ -23,9 +25,9 @@ function OrganizeArtistModal(props) { ); } -OrganizeArtistModal.propTypes = { +DeleteAlbumModal.propTypes = { isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; -export default OrganizeArtistModal; +export default DeleteAlbumModal; diff --git a/frontend/src/Album/Delete/DeleteAlbumModalContent.css b/frontend/src/Album/Delete/DeleteAlbumModalContent.css new file mode 100644 index 000000000..df8e4822e --- /dev/null +++ b/frontend/src/Album/Delete/DeleteAlbumModalContent.css @@ -0,0 +1,12 @@ +.pathContainer { + margin-bottom: 20px; +} + +.pathIcon { + margin-right: 8px; +} + +.deleteFilesMessage { + margin-top: 20px; + color: var(--dangerColor); +} diff --git a/frontend/src/Album/Delete/DeleteAlbumModalContent.css.d.ts b/frontend/src/Album/Delete/DeleteAlbumModalContent.css.d.ts new file mode 100644 index 000000000..e55686abe --- /dev/null +++ b/frontend/src/Album/Delete/DeleteAlbumModalContent.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'deleteFilesMessage': string; + 'pathContainer': string; + 'pathIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Delete/DeleteAlbumModalContent.js b/frontend/src/Album/Delete/DeleteAlbumModalContent.js new file mode 100644 index 000000000..28505ea75 --- /dev/null +++ b/frontend/src/Album/Delete/DeleteAlbumModalContent.js @@ -0,0 +1,164 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes, kinds } from 'Helpers/Props'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import styles from './DeleteAlbumModalContent.css'; + +class DeleteAlbumModalContent extends Component { + + // + // Lifecycle + + constructor(props, context) { + super(props, context); + + this.state = { + deleteFiles: false, + addImportListExclusion: true + }; + } + + // + // Listeners + + onDeleteFilesChange = ({ value }) => { + this.setState({ deleteFiles: value }); + }; + + onAddImportListExclusionChange = ({ value }) => { + this.setState({ addImportListExclusion: value }); + }; + + onDeleteAlbumConfirmed = () => { + const deleteFiles = this.state.deleteFiles; + const addImportListExclusion = this.state.addImportListExclusion; + + this.setState({ deleteFiles: false }); + this.setState({ addImportListExclusion: false }); + this.props.onDeletePress(deleteFiles, addImportListExclusion); + }; + + // + // Render + + render() { + const { + title, + statistics = {}, + onModalClose + } = this.props; + + const { + trackFileCount = 0, + sizeOnDisk = 0 + } = statistics; + + const deleteFiles = this.state.deleteFiles; + const addImportListExclusion = this.state.addImportListExclusion; + + const deleteFilesLabel = `Delete ${trackFileCount} Track Files`; + const deleteFilesHelpText = 'Delete the track files'; + + return ( + + + Delete - {title} + + + + + + {deleteFilesLabel} + + + + + + + {translate('AddListExclusion')} + + + + + + { + !addImportListExclusion && +
    +
    + {translate('IfYouDontAddAnImportListExclusionAndTheArtistHasAMetadataProfileOtherThanNoneThenThisAlbumMayBeReaddedDuringTheNextArtistRefresh')} +
    +
    + } + + { + deleteFiles && +
    +
    + {translate('TheAlbumsFilesWillBeDeleted')} +
    + + { + !!trackFileCount && +
    {trackFileCount} track files totaling {formatBytes(sizeOnDisk)}
    + } +
    + } + +
    + + + + + + +
    + ); + } +} + +DeleteAlbumModalContent.propTypes = { + title: PropTypes.string.isRequired, + statistics: PropTypes.object.isRequired, + onDeletePress: PropTypes.func.isRequired, + onModalClose: PropTypes.func.isRequired +}; + +DeleteAlbumModalContent.defaultProps = { + statistics: { + trackFileCount: 0 + } +}; + +export default DeleteAlbumModalContent; diff --git a/frontend/src/Album/Delete/DeleteAlbumModalContentConnector.js b/frontend/src/Album/Delete/DeleteAlbumModalContentConnector.js new file mode 100644 index 000000000..45ae4ceb3 --- /dev/null +++ b/frontend/src/Album/Delete/DeleteAlbumModalContentConnector.js @@ -0,0 +1,62 @@ +import { push } from 'connected-react-router'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; +import { deleteAlbum } from 'Store/Actions/albumActions'; +import createAlbumSelector from 'Store/Selectors/createAlbumSelector'; +import DeleteAlbumModalContent from './DeleteAlbumModalContent'; + +function createMapStateToProps() { + return createSelector( + createAlbumSelector(), + (album) => { + return album; + } + ); +} + +const mapDispatchToProps = { + push, + deleteAlbum +}; + +class DeleteAlbumModalContentConnector extends Component { + + // + // Listeners + + onDeletePress = (deleteFiles, addImportListExclusion) => { + this.props.deleteAlbum({ + id: this.props.albumId, + deleteFiles, + addImportListExclusion + }); + + this.props.onModalClose(true); + + this.props.push(`${window.Lidarr.urlBase}/artist/${this.props.foreignArtistId}`); + }; + + // + // Render + + render() { + return ( + + ); + } +} + +DeleteAlbumModalContentConnector.propTypes = { + albumId: PropTypes.number.isRequired, + foreignArtistId: PropTypes.string.isRequired, + push: PropTypes.func.isRequired, + onModalClose: PropTypes.func.isRequired, + deleteAlbum: PropTypes.func.isRequired +}; + +export default connect(createMapStateToProps, mapDispatchToProps)(DeleteAlbumModalContentConnector); diff --git a/frontend/src/Album/Details/AlbumDetails.css b/frontend/src/Album/Details/AlbumDetails.css index 1e590835a..a676ae574 100644 --- a/frontend/src/Album/Details/AlbumDetails.css +++ b/frontend/src/Album/Details/AlbumDetails.css @@ -20,7 +20,7 @@ position: absolute; width: 100%; height: 100%; - background: $black; + background: var(--black); opacity: 0.7; } @@ -29,7 +29,7 @@ padding: 30px; width: 100%; height: 100%; - color: $white; + color: var(--white); } .cover { @@ -47,6 +47,7 @@ } .titleRow { + position: relative; display: flex; justify-content: space-between; flex: 0 0 auto; @@ -74,7 +75,7 @@ width: 40px; &:hover { - color: $iconButtonHoverLightColor; + color: var(--iconButtonHoverLightColor); } } @@ -84,6 +85,8 @@ } .albumNavigationButtons { + position: absolute; + right: 0; white-space: nowrap; } @@ -96,7 +99,7 @@ white-space: nowrap; &:hover { - color: $iconButtonHoverLightColor; + color: var(--iconButtonHoverLightColor); } } @@ -116,7 +119,10 @@ margin: 5px 10px 5px 0; } +.releaseDate, .sizeOnDisk, +.albumType, +.secondaryTypes, .qualityProfileName, .links, .tags { @@ -144,6 +150,12 @@ .headerContent { padding: 15px; } + + .title { + font-weight: 300; + font-size: 30px; + line-height: 30px; + } } @media only screen and (max-width: $breakpointLarge) { diff --git a/frontend/src/Album/Details/AlbumDetails.css.d.ts b/frontend/src/Album/Details/AlbumDetails.css.d.ts new file mode 100644 index 000000000..1d14a0ccf --- /dev/null +++ b/frontend/src/Album/Details/AlbumDetails.css.d.ts @@ -0,0 +1,33 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'albumNavigationButton': string; + 'albumNavigationButtons': string; + 'albumType': string; + 'alternateTitlesIconContainer': string; + 'backdrop': string; + 'backdropOverlay': string; + 'contentContainer': string; + 'cover': string; + 'details': string; + 'detailsLabel': string; + 'duration': string; + 'header': string; + 'headerContent': string; + 'info': string; + 'innerContentBody': string; + 'links': string; + 'monitorToggleButton': string; + 'overview': string; + 'qualityProfileName': string; + 'releaseDate': string; + 'secondaryTypes': string; + 'sizeOnDisk': string; + 'tags': string; + 'title': string; + 'titleContainer': string; + 'titleRow': string; + 'toggleMonitoredContainer': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Details/AlbumDetails.js b/frontend/src/Album/Details/AlbumDetails.js index f2288b00f..fe007e168 100644 --- a/frontend/src/Album/Details/AlbumDetails.js +++ b/frontend/src/Album/Details/AlbumDetails.js @@ -3,44 +3,44 @@ import moment from 'moment'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import TextTruncate from 'react-text-truncate'; -import formatBytes from 'Utilities/Number/formatBytes'; -import selectAll from 'Utilities/Table/selectAll'; -import toggleSelected from 'Utilities/Table/toggleSelected'; -import { align, icons, kinds, sizes, tooltipPositions } from 'Helpers/Props'; -import fonts from 'Styles/Variables/fonts'; +import AlbumCover from 'Album/AlbumCover'; +import DeleteAlbumModal from 'Album/Delete/DeleteAlbumModal'; +import EditAlbumModalConnector from 'Album/Edit/EditAlbumModalConnector'; +import AlbumInteractiveSearchModalConnector from 'Album/Search/AlbumInteractiveSearchModalConnector'; +import ArtistGenres from 'Artist/Details/ArtistGenres'; +import ArtistHistoryModal from 'Artist/History/ArtistHistoryModal'; +import Alert from 'Components/Alert'; import HeartRating from 'Components/HeartRating'; import Icon from 'Components/Icon'; -import IconButton from 'Components/Link/IconButton'; import Label from 'Components/Label'; -import MonitorToggleButton from 'Components/MonitorToggleButton'; -import Tooltip from 'Components/Tooltip/Tooltip'; -import AlbumCover from 'Album/AlbumCover'; -import OrganizePreviewModalConnector from 'Organize/OrganizePreviewModalConnector'; -import RetagPreviewModalConnector from 'Retag/RetagPreviewModalConnector'; -import EditAlbumModalConnector from 'Album/Edit/EditAlbumModalConnector'; +import IconButton from 'Components/Link/IconButton'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import MonitorToggleButton from 'Components/MonitorToggleButton'; import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; +import PageContentBody from 'Components/Page/PageContentBody'; import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; -import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; -import AlbumDetailsMediumConnector from './AlbumDetailsMediumConnector'; -import ArtistHistoryModal from 'Artist/History/ArtistHistoryModal'; -import AlbumInteractiveSearchModalConnector from 'Album/Search/AlbumInteractiveSearchModalConnector'; +import Tooltip from 'Components/Tooltip/Tooltip'; +import { align, icons, kinds, sizes, tooltipPositions } from 'Helpers/Props'; +import OrganizePreviewModalConnector from 'Organize/OrganizePreviewModalConnector'; +import RetagPreviewModalConnector from 'Retag/RetagPreviewModalConnector'; +import fonts from 'Styles/Variables/fonts'; import TrackFileEditorModal from 'TrackFile/Editor/TrackFileEditorModal'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import selectAll from 'Utilities/Table/selectAll'; +import toggleSelected from 'Utilities/Table/toggleSelected'; import AlbumDetailsLinks from './AlbumDetailsLinks'; +import AlbumDetailsMediumConnector from './AlbumDetailsMediumConnector'; import styles from './AlbumDetails.css'; -const defaultFontSize = parseInt(fonts.defaultFontSize); +const intermediateFontSize = parseInt(fonts.intermediateFontSize); const lineHeight = parseFloat(fonts.lineHeight); function getFanartUrl(images) { - const fanartImage = _.find(images, { coverType: 'fanart' }); - if (fanartImage) { - // Remove protocol - return fanartImage.url.replace(/^https?:/, ''); - } + return _.find(images, { coverType: 'fanart' })?.url; } function formatDuration(timeSpan) { @@ -88,6 +88,7 @@ class AlbumDetails extends Component { isInteractiveSearchModalOpen: false, isManageTracksOpen: false, isEditAlbumModalOpen: false, + isDeleteAlbumModalOpen: false, allExpanded: false, allCollapsed: false, expandedState: {} @@ -99,51 +100,62 @@ class AlbumDetails extends Component { onOrganizePress = () => { this.setState({ isOrganizeModalOpen: true }); - } + }; onOrganizeModalClose = () => { this.setState({ isOrganizeModalOpen: false }); - } + }; onRetagPress = () => { this.setState({ isRetagModalOpen: true }); - } + }; onRetagModalClose = () => { this.setState({ isRetagModalOpen: false }); - } + }; onEditAlbumPress = () => { this.setState({ isEditAlbumModalOpen: true }); - } + }; onEditAlbumModalClose = () => { this.setState({ isEditAlbumModalOpen: false }); - } + }; + + onDeleteAlbumPress = () => { + this.setState({ + isEditAlbumModalOpen: false, + isDeleteAlbumModalOpen: true + }); + }; + + onDeleteAlbumModalClose = () => { + this.setState({ isDeleteAlbumModalOpen: false }); + }; onManageTracksPress = () => { this.setState({ isManageTracksOpen: true }); - } + }; onManageTracksModalClose = () => { this.setState({ isManageTracksOpen: false }); - } + }; onInteractiveSearchPress = () => { this.setState({ isInteractiveSearchModalOpen: true }); - } + }; onInteractiveSearchModalClose = () => { this.setState({ isInteractiveSearchModalOpen: false }); - } + }; onArtistHistoryPress = () => { this.setState({ isArtistHistoryModalOpen: true }); - } + }; onArtistHistoryModalClose = () => { this.setState({ isArtistHistoryModalOpen: false }); - } + }; onExpandAllPress = () => { const { @@ -152,7 +164,7 @@ class AlbumDetails extends Component { } = this.state; this.setState(getExpandedState(selectAll(expandedState, !allExpanded))); - } + }; onExpandPress = (albumId, isExpanded) => { this.setState((state) => { @@ -166,7 +178,7 @@ class AlbumDetails extends Component { return getExpandedState(newState); }); - } + }; // // Render @@ -180,17 +192,20 @@ class AlbumDetails extends Component { duration, overview, albumType, + secondaryTypes, statistics = {}, monitored, releaseDate, ratings, images, + genres, links, media, isSaving, isFetching, isPopulated, albumsError, + tracksError, trackFilesError, hasTrackFiles, shortDateFormat, @@ -202,19 +217,34 @@ class AlbumDetails extends Component { onSearchPress } = this.props; + const { + trackFileCount = 0, + sizeOnDisk = 0 + } = statistics; + const { isOrganizeModalOpen, isRetagModalOpen, isArtistHistoryModalOpen, isInteractiveSearchModalOpen, isEditAlbumModalOpen, + isDeleteAlbumModalOpen, isManageTracksOpen, allExpanded, allCollapsed, expandedState } = this.state; + const fanartUrl = getFanartUrl(artist.images); + let expandIcon = icons.EXPAND_INDETERMINATE; + let trackFilesCountMessage = translate('TrackFilesCountMessage'); + + if (trackFileCount === 1) { + trackFilesCountMessage = '1 track file'; + } else if (trackFileCount > 1) { + trackFilesCountMessage = `${trackFileCount} track files`; + } if (allExpanded) { expandIcon = icons.COLLAPSE; @@ -227,14 +257,14 @@ class AlbumDetails extends Component { @@ -242,28 +272,28 @@ class AlbumDetails extends Component { @@ -271,28 +301,36 @@ class AlbumDetails extends Component { + + - +
    @@ -319,8 +357,14 @@ class AlbumDetails extends Component { />
    -
    - {title}{disambiguation ? ` (${disambiguation})` : ''} +
    +
    @@ -329,7 +373,7 @@ class AlbumDetails extends Component { className={styles.albumNavigationButton} name={icons.ARROW_LEFT} size={30} - title={`Go to ${previousAlbum.title}`} + title={translate('GoToInterp', [previousAlbum.title])} to={`/album/${previousAlbum.foreignAlbumId}`} /> @@ -337,7 +381,7 @@ class AlbumDetails extends Component { className={styles.albumNavigationButton} name={icons.ARROW_UP} size={30} - title={`Go to ${artist.artistName}`} + title={translate('GoToInterp', [artist.artistName])} to={`/artist/${artist.foreignArtistId}`} /> @@ -345,7 +389,7 @@ class AlbumDetails extends Component { className={styles.albumNavigationButton} name={icons.ARROW_RIGHT} size={30} - title={`Go to ${nextAlbum.title}`} + title={translate('GoToInterp', [nextAlbum.title])} to={`/album/${nextAlbum.foreignAlbumId}`} />
    @@ -354,16 +398,19 @@ class AlbumDetails extends Component {
    { - !!duration && + duration ? {formatDuration(duration)} - + : + null } + +
    @@ -371,66 +418,99 @@ class AlbumDetails extends Component { + +
    + + + {formatBytes(sizeOnDisk)} + +
    + + } + tooltip={ + + {trackFilesCountMessage} + + } + kind={kinds.INVERSE} + position={tooltipPositions.BOTTOM} + /> + - - { - !!albumType && + albumType ? : + null + } - - {albumType} - - + { + secondaryTypes.length ? + : + null } - - - - Links - +
    + + + {translate('Links')} + +
    } tooltip={ @@ -460,9 +541,9 @@ class AlbumDetails extends Component { />
    -
    +
    @@ -472,24 +553,38 @@ class AlbumDetails extends Component {
    { - !isPopulated && !albumsError && !trackFilesError && - + !isPopulated && !albumsError && !tracksError && !trackFilesError ? + : + null } { - !isFetching && albumsError && -
    Loading albums failed
    + !isFetching && albumsError ? + + {translate('AlbumsLoadError')} + : + null } { - !isFetching && trackFilesError && -
    Loading track files failed
    + !isFetching && tracksError ? + + {translate('TracksLoadError')} + : + null + } + + { + !isFetching && trackFilesError ? + + {translate('TrackFilesLoadError')} + : + null } { isPopulated && !!media.length &&
    - { media.slice(0).map((medium) => { return ( @@ -507,6 +602,14 @@ class AlbumDetails extends Component {
    } + { + isPopulated && !media.length ? + + {translate('NoMediumInformation')} + : + null + } +
    - + + + ); } @@ -565,10 +676,12 @@ AlbumDetails.propTypes = { duration: PropTypes.number, overview: PropTypes.string, albumType: PropTypes.string.isRequired, + secondaryTypes: PropTypes.arrayOf(PropTypes.string).isRequired, statistics: PropTypes.object.isRequired, releaseDate: PropTypes.string.isRequired, ratings: PropTypes.object.isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired, + genres: PropTypes.arrayOf(PropTypes.string).isRequired, links: PropTypes.arrayOf(PropTypes.object).isRequired, media: PropTypes.arrayOf(PropTypes.object).isRequired, monitored: PropTypes.bool.isRequired, @@ -590,6 +703,8 @@ AlbumDetails.propTypes = { }; AlbumDetails.defaultProps = { + secondaryTypes: [], + statistics: {}, isSaving: false }; diff --git a/frontend/src/Album/Details/AlbumDetailsConnector.js b/frontend/src/Album/Details/AlbumDetailsConnector.js index 3bcbfd06b..7a5dbc95e 100644 --- a/frontend/src/Album/Details/AlbumDetailsConnector.js +++ b/frontend/src/Album/Details/AlbumDetailsConnector.js @@ -4,17 +4,17 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { findCommand } from 'Utilities/Command'; -import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; -import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; -import { toggleAlbumsMonitored } from 'Store/Actions/albumActions'; -import { fetchTracks, clearTracks } from 'Store/Actions/trackActions'; -import { fetchTrackFiles, clearTrackFiles } from 'Store/Actions/trackFileActions'; -import { executeCommand } from 'Store/Actions/commandActions'; import * as commandNames from 'Commands/commandNames'; -import AlbumDetails from './AlbumDetails'; +import { toggleAlbumsMonitored } from 'Store/Actions/albumActions'; +import { executeCommand } from 'Store/Actions/commandActions'; +import { clearTracks, fetchTracks } from 'Store/Actions/trackActions'; +import { clearTrackFiles, fetchTrackFiles } from 'Store/Actions/trackFileActions'; import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; +import { findCommand, isCommandExecuting } from 'Utilities/Command'; +import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; +import AlbumDetails from './AlbumDetails'; const selectTrackFiles = createSelector( (state) => state.trackFiles, @@ -65,7 +65,17 @@ function createMapStateToProps() { const previousAlbum = sortedAlbums[albumIndex - 1] || _.last(sortedAlbums); const nextAlbum = sortedAlbums[albumIndex + 1] || _.first(sortedAlbums); - const isSearching = !!findCommand(commands, { name: commandNames.ALBUM_SEARCH }); + const isSearchingCommand = findCommand(commands, { name: commandNames.ALBUM_SEARCH }); + const isSearching = ( + isCommandExecuting(isSearchingCommand) && + isSearchingCommand.body.albumIds.indexOf(album.id) > -1 + ); + const isRenamingFiles = isCommandExecuting(findCommand(commands, { name: commandNames.RENAME_FILES, artistId: artist.id })); + const isRenamingArtistCommand = findCommand(commands, { name: commandNames.RENAME_ARTIST }); + const isRenamingArtist = ( + isCommandExecuting(isRenamingArtistCommand) && + isRenamingArtistCommand.body.artistIds.indexOf(artist.id) > -1 + ); const isFetching = tracks.isFetching || isTrackFilesFetching; const isPopulated = tracks.isPopulated && isTrackFilesPopulated; @@ -76,6 +86,8 @@ function createMapStateToProps() { shortDateFormat: uiSettings.shortDateFormat, artist, isSearching, + isRenamingFiles, + isRenamingArtist, isFetching, isPopulated, tracksError, @@ -109,8 +121,27 @@ class AlbumDetailsConnector extends Component { } componentDidUpdate(prevProps) { - if (!_.isEqual(getMonitoredReleases(prevProps), getMonitoredReleases(this.props)) || - (prevProps.anyReleaseOk === false && this.props.anyReleaseOk === true)) { + const { + id, + anyReleaseOk, + isRenamingFiles, + isRenamingArtist + } = this.props; + + if ( + (prevProps.isRenamingFiles && !isRenamingFiles) || + (prevProps.isRenamingArtist && !isRenamingArtist) || + !_.isEqual(getMonitoredReleases(prevProps), getMonitoredReleases(this.props)) || + (prevProps.anyReleaseOk === false && anyReleaseOk === true) + ) { + this.unpopulate(); + this.populate(); + } + + // If the id has changed we need to clear the album + // files and fetch from the server. + + if (prevProps.id !== id) { this.unpopulate(); this.populate(); } @@ -129,12 +160,12 @@ class AlbumDetailsConnector extends Component { this.props.fetchTracks({ albumId }); this.props.fetchTrackFiles({ albumId }); - } + }; unpopulate = () => { this.props.clearTracks(); this.props.clearTrackFiles(); - } + }; // // Listeners @@ -144,14 +175,14 @@ class AlbumDetailsConnector extends Component { albumIds: [this.props.id], monitored }); - } + }; onSearchPress = () => { this.props.executeCommand({ name: commandNames.ALBUM_SEARCH, albumIds: [this.props.id] }); - } + }; // // Render @@ -170,6 +201,8 @@ class AlbumDetailsConnector extends Component { AlbumDetailsConnector.propTypes = { id: PropTypes.number, anyReleaseOk: PropTypes.bool, + isRenamingFiles: PropTypes.bool.isRequired, + isRenamingArtist: PropTypes.bool.isRequired, isAlbumFetching: PropTypes.bool, isAlbumPopulated: PropTypes.bool, foreignAlbumId: PropTypes.string.isRequired, diff --git a/frontend/src/Album/Details/AlbumDetailsLinks.css.d.ts b/frontend/src/Album/Details/AlbumDetailsLinks.css.d.ts new file mode 100644 index 000000000..9f91f93a4 --- /dev/null +++ b/frontend/src/Album/Details/AlbumDetailsLinks.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'link': string; + 'linkLabel': string; + 'links': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Details/AlbumDetailsLinks.js b/frontend/src/Album/Details/AlbumDetailsLinks.js index 265a7c4ff..241836bd4 100644 --- a/frontend/src/Album/Details/AlbumDetailsLinks.js +++ b/frontend/src/Album/Details/AlbumDetailsLinks.js @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { kinds, sizes } from 'Helpers/Props'; import Label from 'Components/Label'; import Link from 'Components/Link/Link'; +import { kinds, sizes } from 'Helpers/Props'; import styles from './AlbumDetailsLinks.css'; function AlbumDetailsLinks(props) { diff --git a/frontend/src/Album/Details/AlbumDetailsMedium.css b/frontend/src/Album/Details/AlbumDetailsMedium.css index 67418316d..2bf1f6b1e 100644 --- a/frontend/src/Album/Details/AlbumDetailsMedium.css +++ b/frontend/src/Album/Details/AlbumDetailsMedium.css @@ -1,8 +1,8 @@ .medium { margin-bottom: 20px; - border: 1px solid $borderColor; + border: 1px solid var(--borderColor); border-radius: 4px; - background-color: $white; + background-color: var(--cardBackgroundColor); &:last-of-type { margin-bottom: 0; @@ -72,16 +72,16 @@ .tracks { padding-top: 15px; - border-top: 1px solid $borderColor; + border-top: 1px solid var(--borderColor); } .collapseButtonContainer { padding: 10px 15px; width: 100%; - border-top: 1px solid $borderColor; + border-top: 1px solid var(--borderColor); border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; - background-color: #fafafa; + background-color: var(--cardBackgroundColor); text-align: center; } diff --git a/frontend/src/Album/Details/AlbumDetailsMedium.css.d.ts b/frontend/src/Album/Details/AlbumDetailsMedium.css.d.ts new file mode 100644 index 000000000..94964280a --- /dev/null +++ b/frontend/src/Album/Details/AlbumDetailsMedium.css.d.ts @@ -0,0 +1,21 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actionButton': string; + 'actionMenuIcon': string; + 'actions': string; + 'actionsMenu': string; + 'actionsMenuContent': string; + 'collapseButtonContainer': string; + 'expandButton': string; + 'expandButtonIcon': string; + 'header': string; + 'left': string; + 'medium': string; + 'mediumFormat': string; + 'mediumNumber': string; + 'noTracks': string; + 'tracks': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Details/AlbumDetailsMedium.js b/frontend/src/Album/Details/AlbumDetailsMedium.js index 33d6efb80..9e80e2c7a 100644 --- a/frontend/src/Album/Details/AlbumDetailsMedium.js +++ b/frontend/src/Album/Details/AlbumDetailsMedium.js @@ -1,26 +1,24 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons, kinds, sizes } from 'Helpers/Props'; import Icon from 'Components/Icon'; -import IconButton from 'Components/Link/IconButton'; import Label from 'Components/Label'; +import IconButton from 'Components/Link/IconButton'; import Link from 'Components/Link/Link'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; +import { icons, kinds, sizes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import TrackRowConnector from './TrackRowConnector'; import styles from './AlbumDetailsMedium.css'; function getMediumStatistics(tracks) { - let trackCount = 0; + const trackCount = tracks.length; let trackFileCount = 0; let totalTrackCount = 0; tracks.forEach((track) => { if (track.trackFileId) { - trackCount++; trackFileCount++; - } else { - trackCount++; } totalTrackCount++; @@ -82,7 +80,7 @@ class AlbumDetailsMedium extends Component { } = this.props; this.props.onExpandPress(mediumNumber, !isExpanded); - } + }; // // Render @@ -120,7 +118,7 @@ class AlbumDetailsMedium extends Component { }
:
- No tracks in this medium + {translate('NoTracksInThisMedium')}
}
diff --git a/frontend/src/Album/Details/AlbumDetailsMediumConnector.js b/frontend/src/Album/Details/AlbumDetailsMediumConnector.js index e05d9870d..17c6969e3 100644 --- a/frontend/src/Album/Details/AlbumDetailsMediumConnector.js +++ b/frontend/src/Album/Details/AlbumDetailsMediumConnector.js @@ -3,9 +3,9 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import { setTracksTableOption } from 'Store/Actions/trackActions'; import { executeCommand } from 'Store/Actions/commandActions'; +import { setTracksTableOption } from 'Store/Actions/trackActions'; +import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; import AlbumDetailsMedium from './AlbumDetailsMedium'; function createMapStateToProps() { @@ -39,7 +39,7 @@ class AlbumDetailsMediumConnector extends Component { onTableOptionChange = (payload) => { this.props.setTracksTableOption(payload); - } + }; // // Render diff --git a/frontend/src/Album/Details/AlbumDetailsPageConnector.js b/frontend/src/Album/Details/AlbumDetailsPageConnector.js index fffd014ad..ad0cdbdb7 100644 --- a/frontend/src/Album/Details/AlbumDetailsPageConnector.js +++ b/frontend/src/Album/Details/AlbumDetailsPageConnector.js @@ -1,13 +1,15 @@ +import { push } from 'connected-react-router'; +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { push } from 'connected-react-router'; -import NotFound from 'Components/NotFound'; -import { fetchAlbums, clearAlbums } from 'Store/Actions/albumActions'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import NotFound from 'Components/NotFound'; +import PageContent from 'Components/Page/PageContent'; +import PageContentBody from 'Components/Page/PageContentBody'; +import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; +import translate from 'Utilities/String/translate'; import AlbumDetailsConnector from './AlbumDetailsConnector'; function createMapStateToProps() { @@ -20,6 +22,18 @@ function createMapStateToProps() { const isFetching = albums.isFetching || artist.isFetching; const isPopulated = albums.isPopulated && artist.isPopulated; + // if albums have been fetched, make sure requested one exists + // otherwise don't map foreignAlbumId to trigger not found page + if (!isFetching && isPopulated) { + const albumIndex = _.findIndex(albums.items, { foreignAlbumId }); + if (albumIndex === -1) { + return { + isFetching, + isPopulated + }; + } + } + return { foreignAlbumId, isFetching, @@ -62,11 +76,11 @@ class AlbumDetailsPageConnector extends Component { foreignAlbumId, includeAllArtistAlbums: true }); - } + }; unpopulate = () => { this.props.clearAlbums(); - } + }; // // Render @@ -81,7 +95,7 @@ class AlbumDetailsPageConnector extends Component { if (!foreignAlbumId) { return ( ); } @@ -89,10 +103,10 @@ class AlbumDetailsPageConnector extends Component { if ((isFetching || !this.state.hasMounted) || (!isFetching && !isPopulated)) { return ( - - + + - + ); } diff --git a/frontend/src/Album/Details/TrackActionsCell.css.d.ts b/frontend/src/Album/Details/TrackActionsCell.css.d.ts new file mode 100644 index 000000000..0f432ca4c --- /dev/null +++ b/frontend/src/Album/Details/TrackActionsCell.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'TrackActionsCell': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Details/TrackActionsCell.js b/frontend/src/Album/Details/TrackActionsCell.js index db73b35b7..8e2a2ade4 100644 --- a/frontend/src/Album/Details/TrackActionsCell.js +++ b/frontend/src/Album/Details/TrackActionsCell.js @@ -1,10 +1,11 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons, kinds } from 'Helpers/Props'; import IconButton from 'Components/Link/IconButton'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; import ConfirmModal from 'Components/Modal/ConfirmModal'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import { icons, kinds } from 'Helpers/Props'; import FileDetailsModal from 'TrackFile/FileDetailsModal'; +import translate from 'Utilities/String/translate'; import styles from './TrackActionsCell.css'; class TrackActionsCell extends Component { @@ -26,24 +27,24 @@ class TrackActionsCell extends Component { onDetailsPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; onDeleteFilePress = () => { this.setState({ isConfirmDeleteModalOpen: true }); - } + }; onConfirmDelete = () => { this.setState({ isConfirmDeleteModalOpen: false }); this.props.deleteTrackFile({ id: this.props.trackFileId }); - } + }; onConfirmDeleteModalClose = () => { this.setState({ isConfirmDeleteModalOpen: false }); - } + }; // // Render @@ -71,10 +72,10 @@ class TrackActionsCell extends Component { } { trackFilePath && - + } diff --git a/frontend/src/Album/Details/TrackRow.css b/frontend/src/Album/Details/TrackRow.css index c77d215f2..912c00101 100644 --- a/frontend/src/Album/Details/TrackRow.css +++ b/frontend/src/Album/Details/TrackRow.css @@ -19,12 +19,25 @@ .audio { composes: cell from '~Components/Table/Cells/TableRowCell.css'; - width: 250px; + width: 300px; } .duration, +.size, .status { composes: cell from '~Components/Table/Cells/TableRowCell.css'; width: 100px; } + +.customFormatScore { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 55px; +} + +.indexerFlags { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + width: 50px; +} diff --git a/frontend/src/Album/Details/TrackRow.css.d.ts b/frontend/src/Album/Details/TrackRow.css.d.ts new file mode 100644 index 000000000..79bbdaf43 --- /dev/null +++ b/frontend/src/Album/Details/TrackRow.css.d.ts @@ -0,0 +1,15 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'audio': string; + 'customFormatScore': string; + 'duration': string; + 'indexerFlags': string; + 'monitored': string; + 'size': string; + 'status': string; + 'title': string; + 'trackNumber': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Album/Details/TrackRow.js b/frontend/src/Album/Details/TrackRow.js index 217215f5c..db128d493 100644 --- a/frontend/src/Album/Details/TrackRow.js +++ b/frontend/src/Album/Details/TrackRow.js @@ -1,13 +1,21 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import TableRow from 'Components/Table/TableRow'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; -import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; +import AlbumFormats from 'Album/AlbumFormats'; import EpisodeStatusConnector from 'Album/EpisodeStatusConnector'; +import IndexerFlags from 'Album/IndexerFlags'; +import Icon from 'Components/Icon'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import TableRow from 'Components/Table/TableRow'; +import Popover from 'Components/Tooltip/Popover'; +import Tooltip from 'Components/Tooltip/Tooltip'; +import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import MediaInfoConnector from 'TrackFile/MediaInfoConnector'; -import TrackActionsCell from './TrackActionsCell'; import * as mediaInfoTypes from 'TrackFile/mediaInfoTypes'; - +import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; +import formatBytes from 'Utilities/Number/formatBytes'; +import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; +import translate from 'Utilities/String/translate'; +import TrackActionsCell from './TrackActionsCell'; import styles from './TrackRow.css'; class TrackRow extends Component { @@ -25,7 +33,10 @@ class TrackRow extends Component { title, duration, trackFilePath, - trackFileRelativePath, + trackFileSize, + customFormats, + customFormatScore, + indexerFlags, columns, deleteTrackFile } = this.props; @@ -86,16 +97,6 @@ class TrackRow extends Component { ); } - if (name === 'relativePath') { - return ( - - { - trackFileRelativePath - } - - ); - } - if (name === 'duration') { return ( + + + ); + } + + if (name === 'customFormatScore') { + return ( + + } + position={tooltipPositions.LEFT} + /> + + ); + } + + if (name === 'indexerFlags') { + return ( + + {indexerFlags ? ( + } + title={translate('IndexerFlags')} + body={} + position={tooltipPositions.LEFT} + /> + ) : null} + + ); + } + + if (name === 'size') { + return ( + + {!!trackFileSize && formatBytes(trackFileSize)} + + ); + } + if (name === 'status') { return ( { return { trackFilePath: trackFile ? trackFile.path : null, - trackFileRelativePath: trackFile ? trackFile.relativePath : null + trackFileSize: trackFile ? trackFile.size : null, + customFormats: trackFile ? trackFile.customFormats : [], + customFormatScore: trackFile ? trackFile.customFormatScore : 0, + indexerFlags: trackFile ? trackFile.indexerFlags : 0 }; } ); diff --git a/frontend/src/Album/Edit/EditAlbumModalConnector.js b/frontend/src/Album/Edit/EditAlbumModalConnector.js index 7c2383f0f..2aadcd955 100644 --- a/frontend/src/Album/Edit/EditAlbumModalConnector.js +++ b/frontend/src/Album/Edit/EditAlbumModalConnector.js @@ -16,7 +16,7 @@ class EditAlbumModalConnector extends Component { onModalClose = () => { this.props.clearPendingChanges({ section: 'albums' }); this.props.onModalClose(); - } + }; // // Render diff --git a/frontend/src/Album/Edit/EditAlbumModalContent.js b/frontend/src/Album/Edit/EditAlbumModalContent.js index 949feee08..dafc0312d 100644 --- a/frontend/src/Album/Edit/EditAlbumModalContent.js +++ b/frontend/src/Album/Edit/EditAlbumModalContent.js @@ -1,16 +1,17 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { inputTypes } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import SpinnerButton from 'Components/Link/SpinnerButton'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; import Form from 'Components/Form/Form'; import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import SpinnerButton from 'Components/Link/SpinnerButton'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes, sizes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; class EditAlbumModalContent extends Component { @@ -24,7 +25,7 @@ class EditAlbumModalContent extends Component { onSavePress(false); - } + }; // // Render @@ -34,7 +35,7 @@ class EditAlbumModalContent extends Component { title, artistName, albumType, - statistics, + statistics = {}, item, isSaving, onInputChange, @@ -42,6 +43,10 @@ class EditAlbumModalContent extends Component { ...otherProps } = this.props; + const { + trackFileCount = 0 + } = statistics; + const { monitored, anyReleaseOk, @@ -58,38 +63,44 @@ class EditAlbumModalContent extends Component {
- - Monitored + + + {translate('Monitored')} + - - Automatically Switch Release + + + {translate('AutomaticallySwitchRelease')} + - - Release + + + {translate('Release')} + 0} + helpText={translate('ReleasesHelpText')} + isDisabled={anyReleaseOk.value && trackFileCount > 0} albumReleases={releases} onChange={onInputChange} /> @@ -101,14 +112,14 @@ class EditAlbumModalContent extends Component { - Save + {translate('Save')} diff --git a/frontend/src/Album/Edit/EditAlbumModalContentConnector.js b/frontend/src/Album/Edit/EditAlbumModalContentConnector.js index f6329f8e8..e9c49bd75 100644 --- a/frontend/src/Album/Edit/EditAlbumModalContentConnector.js +++ b/frontend/src/Album/Edit/EditAlbumModalContentConnector.js @@ -3,10 +3,10 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import selectSettings from 'Store/Selectors/selectSettings'; +import { saveAlbum, setAlbumValue } from 'Store/Actions/albumActions'; import createAlbumSelector from 'Store/Selectors/createAlbumSelector'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; -import { setAlbumValue, saveAlbum } from 'Store/Actions/albumActions'; +import selectSettings from 'Store/Selectors/selectSettings'; import EditAlbumModalContent from './EditAlbumModalContent'; function createMapStateToProps() { @@ -64,13 +64,13 @@ class EditAlbumModalContentConnector extends Component { onInputChange = ({ name, value }) => { this.props.dispatchSetAlbumValue({ name, value }); - } + }; onSavePress = () => { this.props.dispatchSaveAlbum({ id: this.props.albumId }); - } + }; // // Render diff --git a/frontend/src/Album/EpisodeNumber.js b/frontend/src/Album/EpisodeNumber.js index 73e105376..37d46686c 100644 --- a/frontend/src/Album/EpisodeNumber.js +++ b/frontend/src/Album/EpisodeNumber.js @@ -1,8 +1,9 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { icons, kinds, tooltipPositions } from 'Helpers/Props'; import Icon from 'Components/Icon'; import Popover from 'Components/Tooltip/Popover'; +import { icons, kinds, tooltipPositions } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import SceneInfo from './SceneInfo'; import styles from './EpisodeNumber.css'; @@ -40,7 +41,7 @@ function EpisodeNumber(props) { } } - title="Scene Information" + title={translate('SceneInformation')} body={ } @@ -80,7 +81,7 @@ function EpisodeNumber(props) { className={styles.warning} name={icons.WARNING} kind={kinds.WARNING} - title="Episode does not have an absolute episode number" + title={translate('EpisodeDoesNotHaveAnAbsoluteEpisodeNumber')} /> } diff --git a/frontend/src/Album/EpisodeStatus.css.d.ts b/frontend/src/Album/EpisodeStatus.css.d.ts new file mode 100644 index 000000000..a49c06d3a --- /dev/null +++ b/frontend/src/Album/EpisodeStatus.css.d.ts @@ -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; diff --git a/frontend/src/Album/EpisodeStatus.js b/frontend/src/Album/EpisodeStatus.js index a2c792752..fc976103b 100644 --- a/frontend/src/Album/EpisodeStatus.js +++ b/frontend/src/Album/EpisodeStatus.js @@ -1,10 +1,11 @@ import PropTypes from 'prop-types'; import React from 'react'; -import isBefore from 'Utilities/Date/isBefore'; -import { icons, kinds, sizes } from 'Helpers/Props'; +import QueueDetails from 'Activity/Queue/QueueDetails'; import Icon from 'Components/Icon'; import ProgressBar from 'Components/ProgressBar'; -import QueueDetails from 'Activity/Queue/QueueDetails'; +import { icons, kinds, sizes } from 'Helpers/Props'; +import isBefore from 'Utilities/Date/isBefore'; +import translate from 'Utilities/String/translate'; import TrackQuality from './TrackQuality'; import styles from './EpisodeStatus.css'; @@ -27,7 +28,7 @@ function EpisodeStatus(props) { size } = queueItem; - const progress = (100 - sizeleft / size * 100); + const progress = size ? (100 - sizeleft / size * 100) : 0; return (
@@ -35,7 +36,7 @@ function EpisodeStatus(props) { {...queueItem} progressBar={
); @@ -67,7 +68,7 @@ function EpisodeStatus(props) { quality={quality} size={trackFile.size} isCutoffNotMet={isCutoffNotMet} - title="Track Downloaded" + title={translate('TrackDownloaded')} />
); @@ -78,7 +79,7 @@ function EpisodeStatus(props) {
); @@ -89,7 +90,7 @@ function EpisodeStatus(props) {
); @@ -100,7 +101,7 @@ function EpisodeStatus(props) {
); @@ -110,7 +111,7 @@ function EpisodeStatus(props) {
); diff --git a/frontend/src/Album/IndexerFlags.tsx b/frontend/src/Album/IndexerFlags.tsx new file mode 100644 index 000000000..74e2e033c --- /dev/null +++ b/frontend/src/Album/IndexerFlags.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import createIndexerFlagsSelector from 'Store/Selectors/createIndexerFlagsSelector'; + +interface IndexerFlagsProps { + indexerFlags: number; +} + +function IndexerFlags({ indexerFlags = 0 }: IndexerFlagsProps) { + const allIndexerFlags = useSelector(createIndexerFlagsSelector); + + const flags = allIndexerFlags.items.filter( + // eslint-disable-next-line no-bitwise + (item) => (indexerFlags & item.id) === item.id + ); + + return flags.length ? ( +
    + {flags.map((flag, index) => { + return
  • {flag.name}
  • ; + })} +
+ ) : null; +} + +export default IndexerFlags; diff --git a/frontend/src/Album/SceneInfo.css b/frontend/src/Album/SceneInfo.css index 8a5f4bccd..6f1155494 100644 --- a/frontend/src/Album/SceneInfo.css +++ b/frontend/src/Album/SceneInfo.css @@ -15,3 +15,8 @@ margin-left: 100px; } + +.comment { + color: var(--darkGray); + font-size: $smallFontSize; +} diff --git a/frontend/src/Album/SceneInfo.js b/frontend/src/Album/SceneInfo.js index ed171248a..061c54c10 100644 --- a/frontend/src/Album/SceneInfo.js +++ b/frontend/src/Album/SceneInfo.js @@ -2,6 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import DescriptionList from 'Components/DescriptionList/DescriptionList'; import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import translate from 'Utilities/String/translate'; import styles from './SceneInfo.css'; function SceneInfo(props) { @@ -20,7 +21,7 @@ function SceneInfo(props) { } @@ -30,7 +31,7 @@ function SceneInfo(props) { } @@ -40,7 +41,7 @@ function SceneInfo(props) { } @@ -50,7 +51,7 @@ function SceneInfo(props) { { diff --git a/frontend/src/Album/Search/AlbumInteractiveSearchModal.js b/frontend/src/Album/Search/AlbumInteractiveSearchModal.js index 52e825bab..6ce488615 100644 --- a/frontend/src/Album/Search/AlbumInteractiveSearchModal.js +++ b/frontend/src/Album/Search/AlbumInteractiveSearchModal.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; +import { sizes } from 'Helpers/Props'; import AlbumInteractiveSearchModalContent from './AlbumInteractiveSearchModalContent'; function AlbumInteractiveSearchModal(props) { @@ -14,6 +15,7 @@ function AlbumInteractiveSearchModal(props) { return ( diff --git a/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js b/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js index 5b23395fb..ac10cd146 100644 --- a/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js +++ b/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js @@ -1,9 +1,19 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; import { connect } from 'react-redux'; import { cancelFetchReleases, clearReleases } from 'Store/Actions/releaseActions'; import AlbumInteractiveSearchModal from './AlbumInteractiveSearchModal'; function createMapDispatchToProps(dispatch, props) { return { + dispatchCancelFetchReleases() { + dispatch(cancelFetchReleases()); + }, + + dispatchClearReleases() { + dispatch(clearReleases()); + }, + onModalClose() { dispatch(cancelFetchReleases()); dispatch(clearReleases()); @@ -12,4 +22,38 @@ function createMapDispatchToProps(dispatch, props) { }; } -export default connect(null, createMapDispatchToProps)(AlbumInteractiveSearchModal); +class AlbumInteractiveSearchModalConnector extends Component { + + // + // Lifecycle + + componentWillUnmount() { + this.props.dispatchCancelFetchReleases(); + this.props.dispatchClearReleases(); + } + + // + // Render + + render() { + const { + dispatchCancelFetchReleases, + dispatchClearReleases, + ...otherProps + } = this.props; + + return ( + + ); + } +} + +AlbumInteractiveSearchModalConnector.propTypes = { + ...AlbumInteractiveSearchModal.propTypes, + dispatchCancelFetchReleases: PropTypes.func.isRequired, + dispatchClearReleases: PropTypes.func.isRequired +}; + +export default connect(null, createMapDispatchToProps)(AlbumInteractiveSearchModalConnector); diff --git a/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js b/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js index ff8cbe384..370f67ab1 100644 --- a/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js +++ b/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js @@ -1,12 +1,13 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { scrollDirections } from 'Helpers/Props'; import Button from 'Components/Link/Button'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { scrollDirections } from 'Helpers/Props'; import InteractiveSearchConnector from 'InteractiveSearch/InteractiveSearchConnector'; +import translate from 'Utilities/String/translate'; function AlbumInteractiveSearchModalContent(props) { const { @@ -18,7 +19,10 @@ function AlbumInteractiveSearchModalContent(props) { return ( - Interactive Search {albumId != null && `- ${albumTitle}`} + {albumTitle === undefined ? + translate('InteractiveSearchModalHeader') : + translate('InteractiveSearchModalHeaderTitle', { title: albumTitle }) + } @@ -32,7 +36,7 @@ function AlbumInteractiveSearchModalContent(props) { diff --git a/frontend/src/Album/TrackQuality.js b/frontend/src/Album/TrackQuality.js index 866e7d11f..6eac5d2f8 100644 --- a/frontend/src/Album/TrackQuality.js +++ b/frontend/src/Album/TrackQuality.js @@ -1,8 +1,9 @@ import PropTypes from 'prop-types'; import React from 'react'; -import formatBytes from 'Utilities/Number/formatBytes'; -import { kinds } from 'Helpers/Props'; import Label from 'Components/Label'; +import { kinds } from 'Helpers/Props'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; function getTooltip(title, quality, size) { if (!title) { @@ -26,23 +27,60 @@ function getTooltip(title, quality, size) { return title; } +function revisionLabel(className, quality, showRevision) { + if (!showRevision) { + return; + } + + if (quality.revision.isRepack) { + return ( + + ); + } + + if (quality.revision.version && quality.revision.version > 1) { + return ( + + ); + } +} + function TrackQuality(props) { const { className, title, quality, size, - isCutoffNotMet + isCutoffNotMet, + showRevision } = props; + if (!quality) { + return null; + } + return ( - + + {revisionLabel(className, quality, showRevision)} + ); } @@ -51,11 +89,13 @@ TrackQuality.propTypes = { title: PropTypes.string, quality: PropTypes.object.isRequired, size: PropTypes.number, - isCutoffNotMet: PropTypes.bool + isCutoffNotMet: PropTypes.bool, + showRevision: PropTypes.bool }; TrackQuality.defaultProps = { - title: '' + title: '', + showRevision: false }; export default TrackQuality; diff --git a/frontend/src/AlbumStudio/AlbumStudio.js b/frontend/src/AlbumStudio/AlbumStudio.js deleted file mode 100644 index 39222a9e2..000000000 --- a/frontend/src/AlbumStudio/AlbumStudio.js +++ /dev/null @@ -1,218 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import getErrorMessage from 'Utilities/Object/getErrorMessage'; -import getSelectedIds from 'Utilities/Table/getSelectedIds'; -import selectAll from 'Utilities/Table/selectAll'; -import toggleSelected from 'Utilities/Table/toggleSelected'; -import { align, sortDirections } from 'Helpers/Props'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; -import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; -import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; -import FilterMenu from 'Components/Menu/FilterMenu'; -import Table from 'Components/Table/Table'; -import TableBody from 'Components/Table/TableBody'; -import NoArtist from 'Artist/NoArtist'; -import AlbumStudioFilterModalConnector from './AlbumStudioFilterModalConnector'; -import AlbumStudioRowConnector from './AlbumStudioRowConnector'; -import AlbumStudioFooter from './AlbumStudioFooter'; - -const columns = [ - { - name: 'status', - isVisible: true - }, - { - name: 'sortName', - label: 'Name', - isSortable: true, - isVisible: true - }, - { - name: 'monitored', - isVisible: true - }, - { - name: 'albumCount', - label: 'Albums', - isSortable: true, - isVisible: true - } -]; - -class AlbumStudio extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - allSelected: false, - allUnselected: false, - lastToggled: null, - selectedState: {} - }; - } - - componentDidUpdate(prevProps) { - const { - isSaving, - saveError - } = this.props; - - if (prevProps.isSaving && !isSaving && !saveError) { - this.onSelectAllChange({ value: false }); - } - } - - // - // Control - - getSelectedIds = () => { - return getSelectedIds(this.state.selectedState); - } - - // - // Listeners - - onSelectAllChange = ({ value }) => { - this.setState(selectAll(this.state.selectedState, value)); - } - - onSelectedChange = ({ id, value, shiftKey = false }) => { - this.setState((state) => { - return toggleSelected(state, this.props.items, id, value, shiftKey); - }); - } - - onUpdateSelectedPress = (changes) => { - this.props.onUpdateSelectedPress({ - artistIds: this.getSelectedIds(), - ...changes - }); - } - - // - // Render - - render() { - const { - isFetching, - isPopulated, - error, - totalItems, - items, - selectedFilterKey, - filters, - customFilters, - sortKey, - sortDirection, - isSaving, - saveError, - onSortPress, - onFilterSelect - } = this.props; - - const { - allSelected, - allUnselected, - selectedState - } = this.state; - - return ( - - - - - - - - - - { - isFetching && !isPopulated && - - } - - { - !isFetching && !!error && -
{getErrorMessage(error, 'Failed to load artist from API')}
- } - - { - !error && isPopulated && !!items.length && -
- - - { - items.map((item) => { - return ( - - ); - }) - } - -
-
- } - - { - !error && isPopulated && !items.length && - - } -
- - -
- ); - } -} - -AlbumStudio.propTypes = { - isFetching: PropTypes.bool.isRequired, - isPopulated: PropTypes.bool.isRequired, - error: PropTypes.object, - totalItems: PropTypes.number.isRequired, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, - isSaving: PropTypes.bool.isRequired, - saveError: PropTypes.object, - onSortPress: PropTypes.func.isRequired, - onFilterSelect: PropTypes.func.isRequired, - onUpdateSelectedPress: PropTypes.func.isRequired -}; - -export default AlbumStudio; diff --git a/frontend/src/AlbumStudio/AlbumStudioAlbum.css b/frontend/src/AlbumStudio/AlbumStudioAlbum.css deleted file mode 100644 index f3c9f6102..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioAlbum.css +++ /dev/null @@ -1,37 +0,0 @@ -.album { - display: flex; - align-items: stretch; - overflow: hidden; - margin: 2px 4px; - border: 1px solid $borderColor; - border-radius: 4px; - background-color: #eee; - cursor: default; -} - -.info { - padding: 0 4px; -} - -.albumType { - padding: 0 4px; - border-width: 0 1px; - border-style: solid; - border-color: $borderColor; - background-color: $white; - color: $defaultColor; -} - -.tracks { - padding: 0 4px; - background-color: $white; - color: $defaultColor; -} - -.allTracks { - background-color: #e0ffe0; -} - -.missingWanted { - background-color: #ffe0e0; -} diff --git a/frontend/src/AlbumStudio/AlbumStudioAlbum.js b/frontend/src/AlbumStudio/AlbumStudioAlbum.js deleted file mode 100644 index 8bec82840..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioAlbum.js +++ /dev/null @@ -1,101 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import classNames from 'classnames'; -import MonitorToggleButton from 'Components/MonitorToggleButton'; -import styles from './AlbumStudioAlbum.css'; - -class AlbumStudioAlbum extends Component { - - // - // Listeners - - onAlbumMonitoredPress = () => { - const { - id, - monitored - } = this.props; - - this.props.onAlbumMonitoredPress(id, !monitored); - } - - // - // Render - - render() { - const { - title, - disambiguation, - albumType, - monitored, - statistics, - isSaving - } = this.props; - - const { - trackFileCount, - totalTrackCount, - percentOfTracks - } = statistics; - - return ( -
-
- - - - { - disambiguation ? `${title} (${disambiguation})` : `${title}` - } - -
- -
- - { - `${albumType}` - } - -
- -
- { - totalTrackCount === 0 ? '0/0' : `${trackFileCount}/${totalTrackCount}` - } -
-
- ); - } -} - -AlbumStudioAlbum.propTypes = { - id: PropTypes.number.isRequired, - title: PropTypes.string.isRequired, - disambiguation: PropTypes.string, - albumType: PropTypes.string.isRequired, - monitored: PropTypes.bool.isRequired, - statistics: PropTypes.object.isRequired, - isSaving: PropTypes.bool.isRequired, - onAlbumMonitoredPress: PropTypes.func.isRequired -}; - -AlbumStudioAlbum.defaultProps = { - isSaving: false, - statistics: { - trackFileCount: 0, - totalTrackCount: 0, - percentOfTracks: 0 - } -}; - -export default AlbumStudioAlbum; diff --git a/frontend/src/AlbumStudio/AlbumStudioConnector.js b/frontend/src/AlbumStudio/AlbumStudioConnector.js deleted file mode 100644 index 12e863c24..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioConnector.js +++ /dev/null @@ -1,91 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector'; -import { setAlbumStudioSort, setAlbumStudioFilter, saveAlbumStudio } from 'Store/Actions/albumStudioActions'; -import { fetchAlbums, clearAlbums } from 'Store/Actions/albumActions'; -import AlbumStudio from './AlbumStudio'; - -function createMapStateToProps() { - return createSelector( - createClientSideCollectionSelector('artist', 'albumStudio'), - (artist) => { - return { - ...artist - }; - } - ); -} - -const mapDispatchToProps = { - fetchAlbums, - clearAlbums, - setAlbumStudioSort, - setAlbumStudioFilter, - saveAlbumStudio -}; - -class AlbumStudioConnector extends Component { - - // - // Lifecycle - - componentDidMount() { - this.populate(); - } - - componentWillUnmount() { - this.unpopulate(); - } - - // - // Control - - populate = () => { - this.props.fetchAlbums(); - } - - unpopulate = () => { - this.props.clearAlbums(); - } - - // - // Listeners - - onSortPress = (sortKey) => { - this.props.setAlbumStudioSort({ sortKey }); - } - - onFilterSelect = (selectedFilterKey) => { - this.props.setAlbumStudioFilter({ selectedFilterKey }); - } - - onUpdateSelectedPress = (payload) => { - this.props.saveAlbumStudio(payload); - } - - // - // Render - - render() { - return ( - - ); - } -} - -AlbumStudioConnector.propTypes = { - setAlbumStudioSort: PropTypes.func.isRequired, - setAlbumStudioFilter: PropTypes.func.isRequired, - fetchAlbums: PropTypes.func.isRequired, - clearAlbums: PropTypes.func.isRequired, - saveAlbumStudio: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(AlbumStudioConnector); diff --git a/frontend/src/AlbumStudio/AlbumStudioFilterModalConnector.js b/frontend/src/AlbumStudio/AlbumStudioFilterModalConnector.js deleted file mode 100644 index 655601cca..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioFilterModalConnector.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setAlbumStudioFilter } from 'Store/Actions/albumStudioActions'; -import FilterModal from 'Components/Filter/FilterModal'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artist.items, - (state) => state.albumStudio.filterBuilderProps, - (sectionItems, filterBuilderProps) => { - return { - sectionItems, - filterBuilderProps, - customFilterType: 'albumStudio' - }; - } - ); -} - -const mapDispatchToProps = { - dispatchSetFilter: setAlbumStudioFilter -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(FilterModal); diff --git a/frontend/src/AlbumStudio/AlbumStudioFooter.css b/frontend/src/AlbumStudio/AlbumStudioFooter.css deleted file mode 100644 index 11ea5496a..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioFooter.css +++ /dev/null @@ -1,14 +0,0 @@ -.inputContainer { - margin-right: 20px; -} - -.label { - margin-bottom: 3px; - font-weight: bold; -} - -.updateSelectedButton { - composes: button from '~Components/Link/SpinnerButton.css'; - - height: 35px; -} diff --git a/frontend/src/AlbumStudio/AlbumStudioFooter.js b/frontend/src/AlbumStudio/AlbumStudioFooter.js deleted file mode 100644 index d5eb300cd..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioFooter.js +++ /dev/null @@ -1,145 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { kinds } from 'Helpers/Props'; -import SpinnerButton from 'Components/Link/SpinnerButton'; -import MonitorAlbumsSelectInput from 'Components/Form/MonitorAlbumsSelectInput'; -import SelectInput from 'Components/Form/SelectInput'; -import PageContentFooter from 'Components/Page/PageContentFooter'; -import styles from './AlbumStudioFooter.css'; - -const NO_CHANGE = 'noChange'; - -class AlbumStudioFooter extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - monitored: NO_CHANGE, - monitor: NO_CHANGE - }; - } - - componentDidUpdate(prevProps) { - const { - isSaving, - saveError - } = prevProps; - - if (prevProps.isSaving && !isSaving && !saveError) { - this.setState({ - monitored: NO_CHANGE, - monitor: NO_CHANGE - }); - } - } - - // - // Listeners - - onInputChange = ({ name, value }) => { - this.setState({ [name]: value }); - } - - onUpdateSelectedPress = () => { - const { - monitor, - monitored - } = this.state; - - const changes = {}; - - if (monitored !== NO_CHANGE) { - changes.monitored = monitored === 'monitored'; - } - - if (monitor !== NO_CHANGE) { - changes.monitor = monitor; - } - - this.props.onUpdateSelectedPress(changes); - } - - // - // Render - - render() { - const { - selectedCount, - isSaving - } = this.props; - - const { - monitored, - monitor - } = this.state; - - const monitoredOptions = [ - { key: NO_CHANGE, value: 'No Change', disabled: true }, - { key: 'monitored', value: 'Monitored' }, - { key: 'unmonitored', value: 'Unmonitored' } - ]; - - const noChanges = monitored === NO_CHANGE && monitor === NO_CHANGE; - - return ( - -
-
- Monitor Artist -
- - -
- -
-
- Monitor Albums -
- - -
- -
-
- {selectedCount} Artist(s) Selected -
- - - Update Selected - -
-
- ); - } -} - -AlbumStudioFooter.propTypes = { - selectedCount: PropTypes.number.isRequired, - isSaving: PropTypes.bool.isRequired, - saveError: PropTypes.object, - onUpdateSelectedPress: PropTypes.func.isRequired -}; - -export default AlbumStudioFooter; diff --git a/frontend/src/AlbumStudio/AlbumStudioRow.css b/frontend/src/AlbumStudio/AlbumStudioRow.css deleted file mode 100644 index 7b9d1f52b..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioRow.css +++ /dev/null @@ -1,20 +0,0 @@ -.status, -.monitored { - composes: cell from '~Components/Table/Cells/TableRowCell.css'; - - width: 50px; -} - -.title { - composes: cell from '~Components/Table/Cells/TableRowCell.css'; - - width: 1px; - white-space: nowrap; -} - -.albums { - composes: cell from '~Components/Table/Cells/TableRowCell.css'; - - display: flex; - flex-wrap: wrap; -} diff --git a/frontend/src/AlbumStudio/AlbumStudioRow.js b/frontend/src/AlbumStudio/AlbumStudioRow.js deleted file mode 100644 index f6a146999..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioRow.js +++ /dev/null @@ -1,100 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { icons } from 'Helpers/Props'; -import Icon from 'Components/Icon'; -import MonitorToggleButton from 'Components/MonitorToggleButton'; -import TableRow from 'Components/Table/TableRow'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; -import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; -import ArtistNameLink from 'Artist/ArtistNameLink'; -import AlbumStudioAlbum from './AlbumStudioAlbum'; -import styles from './AlbumStudioRow.css'; - -class AlbumStudioRow extends Component { - - // - // Render - - render() { - const { - artistId, - status, - foreignArtistId, - artistName, - monitored, - albums, - isSaving, - isSelected, - onSelectedChange, - onArtistMonitoredPress, - onAlbumMonitoredPress - } = this.props; - - return ( - - - - - - - - - - - - - - - - - { - albums.map((album) => { - return ( - - ); - }) - } - - - ); - } -} - -AlbumStudioRow.propTypes = { - artistId: PropTypes.number.isRequired, - status: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - artistName: PropTypes.string.isRequired, - monitored: PropTypes.bool.isRequired, - albums: PropTypes.arrayOf(PropTypes.object).isRequired, - isSaving: PropTypes.bool.isRequired, - isSelected: PropTypes.bool, - onSelectedChange: PropTypes.func.isRequired, - onArtistMonitoredPress: PropTypes.func.isRequired, - onAlbumMonitoredPress: PropTypes.func.isRequired -}; - -AlbumStudioRow.defaultProps = { - isSaving: false -}; - -export default AlbumStudioRow; diff --git a/frontend/src/AlbumStudio/AlbumStudioRowConnector.js b/frontend/src/AlbumStudio/AlbumStudioRowConnector.js deleted file mode 100644 index 901f9407e..000000000 --- a/frontend/src/AlbumStudio/AlbumStudioRowConnector.js +++ /dev/null @@ -1,83 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createArtistSelector from 'Store/Selectors/createArtistSelector'; -import { toggleArtistMonitored } from 'Store/Actions/artistActions'; -import { toggleAlbumsMonitored } from 'Store/Actions/albumActions'; -import AlbumStudioRow from './AlbumStudioRow'; - -function createMapStateToProps() { - return createSelector( - (state) => state.albums, - createArtistSelector(), - (albums, artist) => { - const albumsInArtist = _.filter(albums.items, { artistId: artist.id }); - const sortedAlbums = _.orderBy(albumsInArtist, 'releaseDate', 'desc'); - - return { - ...artist, - artistId: artist.id, - artistName: artist.artistName, - monitored: artist.monitored, - status: artist.status, - isSaving: artist.isSaving, - albums: sortedAlbums - }; - } - ); -} - -const mapDispatchToProps = { - toggleArtistMonitored, - toggleAlbumsMonitored -}; - -class AlbumStudioRowConnector extends Component { - - // - // Listeners - - onArtistMonitoredPress = () => { - const { - artistId, - monitored - } = this.props; - - this.props.toggleArtistMonitored({ - artistId, - monitored: !monitored - }); - } - - onAlbumMonitoredPress = (albumId, monitored) => { - const albumIds = [albumId]; - this.props.toggleAlbumsMonitored({ - albumIds, - monitored - }); - } - - // - // Render - - render() { - return ( - - ); - } -} - -AlbumStudioRowConnector.propTypes = { - artistId: PropTypes.number.isRequired, - monitored: PropTypes.bool.isRequired, - toggleArtistMonitored: PropTypes.func.isRequired, - toggleAlbumsMonitored: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(AlbumStudioRowConnector); diff --git a/frontend/src/App/App.js b/frontend/src/App/App.js index ecd3ea533..9e8d508ac 100644 --- a/frontend/src/App/App.js +++ b/frontend/src/App/App.js @@ -1,16 +1,18 @@ +import { ConnectedRouter } from 'connected-react-router'; import PropTypes from 'prop-types'; import React from 'react'; import DocumentTitle from 'react-document-title'; import { Provider } from 'react-redux'; -import { ConnectedRouter } from 'connected-react-router'; import PageConnector from 'Components/Page/PageConnector'; +import ApplyTheme from './ApplyTheme'; import AppRoutes from './AppRoutes'; function App({ store, history }) { return ( - + + diff --git a/frontend/src/App/AppRoutes.js b/frontend/src/App/AppRoutes.js index ed55547e0..c1004d36d 100644 --- a/frontend/src/App/AppRoutes.js +++ b/frontend/src/App/AppRoutes.js @@ -1,41 +1,39 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { Route, Redirect } from 'react-router-dom'; -import getPathWithUrlBase from 'Utilities/getPathWithUrlBase'; -import NotFound from 'Components/NotFound'; -import Switch from 'Components/Router/Switch'; -import ArtistIndexConnector from 'Artist/Index/ArtistIndexConnector'; -import AddNewArtistConnector from 'AddArtist/AddNewArtist/AddNewArtistConnector'; -import ImportArtist from 'AddArtist/ImportArtist/ImportArtist'; -import ArtistEditorConnector from 'Artist/Editor/ArtistEditorConnector'; -import AlbumStudioConnector from 'AlbumStudio/AlbumStudioConnector'; -import UnmappedFilesTableConnector from 'UnmappedFiles/UnmappedFilesTableConnector'; -import ArtistDetailsPageConnector from 'Artist/Details/ArtistDetailsPageConnector'; -import AlbumDetailsPageConnector from 'Album/Details/AlbumDetailsPageConnector'; -import CalendarPageConnector from 'Calendar/CalendarPageConnector'; +import { Redirect, Route } from 'react-router-dom'; +import BlocklistConnector from 'Activity/Blocklist/BlocklistConnector'; import HistoryConnector from 'Activity/History/HistoryConnector'; import QueueConnector from 'Activity/Queue/QueueConnector'; -import BlacklistConnector from 'Activity/Blacklist/BlacklistConnector'; -import MissingConnector from 'Wanted/Missing/MissingConnector'; -import CutoffUnmetConnector from 'Wanted/CutoffUnmet/CutoffUnmetConnector'; -import Settings from 'Settings/Settings'; -import MediaManagementConnector from 'Settings/MediaManagement/MediaManagementConnector'; -import Profiles from 'Settings/Profiles/Profiles'; -import Quality from 'Settings/Quality/Quality'; -import IndexerSettingsConnector from 'Settings/Indexers/IndexerSettingsConnector'; -import ImportListSettingsConnector from 'Settings/ImportLists/ImportListSettingsConnector'; +import AlbumDetailsPageConnector from 'Album/Details/AlbumDetailsPageConnector'; +import ArtistDetailsPageConnector from 'Artist/Details/ArtistDetailsPageConnector'; +import ArtistIndex from 'Artist/Index/ArtistIndex'; +import CalendarPageConnector from 'Calendar/CalendarPageConnector'; +import NotFound from 'Components/NotFound'; +import Switch from 'Components/Router/Switch'; +import AddNewItemConnector from 'Search/AddNewItemConnector'; +import CustomFormatSettingsPage from 'Settings/CustomFormats/CustomFormatSettingsPage'; import DownloadClientSettingsConnector from 'Settings/DownloadClients/DownloadClientSettingsConnector'; -import NotificationSettings from 'Settings/Notifications/NotificationSettings'; -import MetadataSettings from 'Settings/Metadata/MetadataSettings'; -import TagSettings from 'Settings/Tags/TagSettings'; import GeneralSettingsConnector from 'Settings/General/GeneralSettingsConnector'; +import ImportListSettingsConnector from 'Settings/ImportLists/ImportListSettingsConnector'; +import IndexerSettingsConnector from 'Settings/Indexers/IndexerSettingsConnector'; +import MediaManagementConnector from 'Settings/MediaManagement/MediaManagementConnector'; +import MetadataSettings from 'Settings/Metadata/MetadataSettings'; +import NotificationSettings from 'Settings/Notifications/NotificationSettings'; +import Profiles from 'Settings/Profiles/Profiles'; +import QualityConnector from 'Settings/Quality/QualityConnector'; +import Settings from 'Settings/Settings'; +import TagSettings from 'Settings/Tags/TagSettings'; import UISettingsConnector from 'Settings/UI/UISettingsConnector'; -import Status from 'System/Status/Status'; -import Tasks from 'System/Tasks/Tasks'; import BackupsConnector from 'System/Backup/BackupsConnector'; -import UpdatesConnector from 'System/Updates/UpdatesConnector'; import LogsTableConnector from 'System/Events/LogsTableConnector'; import Logs from 'System/Logs/Logs'; +import Status from 'System/Status/Status'; +import Tasks from 'System/Tasks/Tasks'; +import Updates from 'System/Updates/Updates'; +import UnmappedFilesTableConnector from 'UnmappedFiles/UnmappedFilesTableConnector'; +import getPathWithUrlBase from 'Utilities/getPathWithUrlBase'; +import CutoffUnmetConnector from 'Wanted/CutoffUnmet/CutoffUnmetConnector'; +import MissingConnector from 'Wanted/Missing/MissingConnector'; function AppRoutes(props) { const { @@ -51,7 +49,7 @@ function AppRoutes(props) { { @@ -72,23 +70,34 @@ function AppRoutes(props) { } - - { + return ( + + ); + }} /> { + return ( + + ); + }} /> {/* @@ -170,7 +179,12 @@ function AppRoutes(props) { + + u.version === version); + let installedPreviouslyIndex = items.findIndex((u) => u.version === prevVersion); + + if (installedIndex === -1) { + installedIndex = 0; + } + + if (installedPreviouslyIndex === -1) { + installedPreviouslyIndex = items.length; + } else if (installedPreviouslyIndex === installedIndex && items.length) { + installedPreviouslyIndex += 1; + } + + const appliedUpdates = items.slice(installedIndex, installedPreviouslyIndex); + + if (!appliedUpdates.length) { + return null; + } + + const appliedChanges = { new: [], fixed: [] }; + appliedUpdates.forEach((u) => { + if (u.changes) { + appliedChanges.new.push(... u.changes.new); + appliedChanges.fixed.push(... u.changes.fixed); + } + }); + + const mergedUpdate = Object.assign({}, appliedUpdates[0], { changes: appliedChanges }); + + if (!appliedChanges.new.length && !appliedChanges.fixed.length) { + mergedUpdate.changes = null; + } + + return mergedUpdate; +} + function AppUpdatedModalContent(props) { const { version, + prevVersion, isPopulated, error, items, @@ -20,17 +60,17 @@ function AppUpdatedModalContent(props) { onModalClose } = props; - const update = items[0]; + const update = mergeUpdates(items, version, prevVersion); return ( - Lidarr Updated + {translate('AppUpdated')}
- Version {version} of Lidarr has been installed, in order to get the latest changes you'll need to reload Lidarr. +
{ @@ -38,23 +78,23 @@ function AppUpdatedModalContent(props) {
{ !update.changes && -
Maintenance release
+
{translate('MaintenanceRelease')}
} { !!update.changes &&
- What's new? + {translate('WhatsNew')}
@@ -72,14 +112,14 @@ function AppUpdatedModalContent(props) { @@ -88,6 +128,7 @@ function AppUpdatedModalContent(props) { AppUpdatedModalContent.propTypes = { version: PropTypes.string.isRequired, + prevVersion: PropTypes.string, isPopulated: PropTypes.bool.isRequired, error: PropTypes.object, items: PropTypes.arrayOf(PropTypes.object).isRequired, diff --git a/frontend/src/App/AppUpdatedModalContentConnector.js b/frontend/src/App/AppUpdatedModalContentConnector.js index 7cf649b65..5a991f236 100644 --- a/frontend/src/App/AppUpdatedModalContentConnector.js +++ b/frontend/src/App/AppUpdatedModalContentConnector.js @@ -8,8 +8,9 @@ import AppUpdatedModalContent from './AppUpdatedModalContent'; function createMapStateToProps() { return createSelector( (state) => state.app.version, + (state) => state.app.prevVersion, (state) => state.system.updates, - (version, updates) => { + (version, prevVersion, updates) => { const { isPopulated, error, @@ -18,6 +19,7 @@ function createMapStateToProps() { return { version, + prevVersion, isPopulated, error, items diff --git a/frontend/src/App/ApplyTheme.tsx b/frontend/src/App/ApplyTheme.tsx new file mode 100644 index 000000000..e04dda8c4 --- /dev/null +++ b/frontend/src/App/ApplyTheme.tsx @@ -0,0 +1,37 @@ +import React, { Fragment, ReactNode, useCallback, useEffect } from 'react'; +import { useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import themes from 'Styles/Themes'; +import AppState from './State/AppState'; + +interface ApplyThemeProps { + children: ReactNode; +} + +function createThemeSelector() { + return createSelector( + (state: AppState) => state.settings.ui.item.theme || window.Lidarr.theme, + (theme) => { + return theme; + } + ); +} + +function ApplyTheme({ children }: ApplyThemeProps) { + const theme = useSelector(createThemeSelector()); + + const updateCSSVariables = useCallback(() => { + Object.entries(themes[theme]).forEach(([key, value]) => { + document.documentElement.style.setProperty(`--${key}`, value); + }); + }, [theme]); + + // On Component Mount and Component Update + useEffect(() => { + updateCSSVariables(); + }, [updateCSSVariables, theme]); + + return {children}; +} + +export default ApplyTheme; diff --git a/frontend/src/App/ConnectionLostModal.css.d.ts b/frontend/src/App/ConnectionLostModal.css.d.ts new file mode 100644 index 000000000..027f2a9a3 --- /dev/null +++ b/frontend/src/App/ConnectionLostModal.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'automatic': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/App/ConnectionLostModal.js b/frontend/src/App/ConnectionLostModal.js index 9178d2ab8..5c08f491f 100644 --- a/frontend/src/App/ConnectionLostModal.js +++ b/frontend/src/App/ConnectionLostModal.js @@ -1,12 +1,13 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { kinds } from 'Helpers/Props'; import Button from 'Components/Link/Button'; import Modal from 'Components/Modal/Modal'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './ConnectionLostModal.css'; function ConnectionLostModal(props) { @@ -22,16 +23,16 @@ function ConnectionLostModal(props) { > - Connnection Lost + {translate('ConnectionLost')}
- Lidarr has lost it's connection to the backend and will need to be reloaded to restore functionality. + {translate('ConnectionLostToBackend')}
- Lidarr will try to connect automatically, or you can click reload below. + {translate('ConnectionLostReconnect')}
@@ -39,7 +40,7 @@ function ConnectionLostModal(props) { kind={kinds.PRIMARY} onPress={onModalClose} > - Reload + {translate('Reload')}
diff --git a/frontend/src/App/ModelBase.ts b/frontend/src/App/ModelBase.ts new file mode 100644 index 000000000..187b12fb2 --- /dev/null +++ b/frontend/src/App/ModelBase.ts @@ -0,0 +1,5 @@ +interface ModelBase { + id: number; +} + +export default ModelBase; diff --git a/frontend/src/App/SelectContext.tsx b/frontend/src/App/SelectContext.tsx new file mode 100644 index 000000000..66be388ce --- /dev/null +++ b/frontend/src/App/SelectContext.tsx @@ -0,0 +1,83 @@ +import { cloneDeep } from 'lodash'; +import React, { useCallback, useEffect } from 'react'; +import useSelectState, { SelectState } from 'Helpers/Hooks/useSelectState'; +import ModelBase from './ModelBase'; + +export type SelectContextAction = + | { type: 'reset' } + | { type: 'selectAll' } + | { type: 'unselectAll' } + | { + type: 'toggleSelected'; + id: number; + isSelected: boolean; + shiftKey: boolean; + } + | { + type: 'removeItem'; + id: number; + } + | { + type: 'updateItems'; + items: ModelBase[]; + }; + +export type SelectDispatch = (action: SelectContextAction) => void; + +interface SelectProviderOptions { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + children: any; + items: Array; +} + +const SelectContext = React.createContext< + [SelectState, SelectDispatch] | undefined +>(cloneDeep(undefined)); + +export function SelectProvider( + props: SelectProviderOptions +) { + const { items } = props; + const [state, dispatch] = useSelectState(); + + const dispatchWrapper = useCallback( + (action: SelectContextAction) => { + switch (action.type) { + case 'reset': + case 'removeItem': + dispatch(action); + break; + + default: + dispatch({ + ...action, + items, + }); + break; + } + }, + [items, dispatch] + ); + + const value: [SelectState, SelectDispatch] = [state, dispatchWrapper]; + + useEffect(() => { + dispatch({ type: 'updateItems', items }); + }, [items, dispatch]); + + return ( + + {props.children} + + ); +} + +export function useSelect() { + const context = React.useContext(SelectContext); + + if (context === undefined) { + throw new Error('useSelect must be used within a SelectProvider'); + } + + return context; +} diff --git a/frontend/src/App/State/AlbumAppState.ts b/frontend/src/App/State/AlbumAppState.ts new file mode 100644 index 000000000..e03d4a497 --- /dev/null +++ b/frontend/src/App/State/AlbumAppState.ts @@ -0,0 +1,8 @@ +import Album from 'Album/Album'; +import AppSectionState, { + AppSectionDeleteState, +} from 'App/State/AppSectionState'; + +interface AlbumAppState extends AppSectionState, AppSectionDeleteState {} + +export default AlbumAppState; diff --git a/frontend/src/App/State/AppSectionState.ts b/frontend/src/App/State/AppSectionState.ts new file mode 100644 index 000000000..cabc39b1c --- /dev/null +++ b/frontend/src/App/State/AppSectionState.ts @@ -0,0 +1,53 @@ +import SortDirection from 'Helpers/Props/SortDirection'; +import { FilterBuilderProp } from './AppState'; + +export interface Error { + responseJSON: { + message: string; + }; +} + +export interface AppSectionDeleteState { + isDeleting: boolean; + deleteError: Error; +} + +export interface AppSectionSaveState { + isSaving: boolean; + saveError: Error; +} + +export interface PagedAppSectionState { + pageSize: number; +} + +export interface AppSectionFilterState { + filterBuilderProps: FilterBuilderProp[]; +} + +export interface AppSectionSchemaState { + isSchemaFetching: boolean; + isSchemaPopulated: boolean; + schemaError: Error; + schema: { + items: T[]; + }; +} + +export interface AppSectionItemState { + isFetching: boolean; + isPopulated: boolean; + error: Error; + item: T; +} + +interface AppSectionState { + isFetching: boolean; + isPopulated: boolean; + error: Error; + items: T[]; + sortKey: string; + sortDirection: SortDirection; +} + +export default AppSectionState; diff --git a/frontend/src/App/State/AppState.ts b/frontend/src/App/State/AppState.ts new file mode 100644 index 000000000..cb8da5987 --- /dev/null +++ b/frontend/src/App/State/AppState.ts @@ -0,0 +1,72 @@ +import ParseAppState from 'App/State/ParseAppState'; +import AlbumAppState from './AlbumAppState'; +import ArtistAppState, { ArtistIndexAppState } from './ArtistAppState'; +import CalendarAppState from './CalendarAppState'; +import CommandAppState from './CommandAppState'; +import HistoryAppState from './HistoryAppState'; +import QueueAppState from './QueueAppState'; +import SettingsAppState from './SettingsAppState'; +import SystemAppState from './SystemAppState'; +import TagsAppState from './TagsAppState'; +import TrackFilesAppState from './TrackFilesAppState'; +import TracksAppState from './TracksAppState'; + +interface FilterBuilderPropOption { + id: string; + name: string; +} + +export interface FilterBuilderProp { + name: string; + label: string; + type: string; + valueType?: string; + optionsSelector?: (items: T[]) => FilterBuilderPropOption[]; +} + +export interface PropertyFilter { + key: string; + value: boolean | string | number | string[] | number[]; + type: string; +} + +export interface Filter { + key: string; + label: string; + filers: PropertyFilter[]; +} + +export interface CustomFilter { + id: number; + type: string; + label: string; + filers: PropertyFilter[]; +} + +export interface AppSectionState { + version: string; + dimensions: { + isSmallScreen: boolean; + width: number; + height: number; + }; +} + +interface AppState { + albums: AlbumAppState; + app: AppSectionState; + artist: ArtistAppState; + artistIndex: ArtistIndexAppState; + calendar: CalendarAppState; + commands: CommandAppState; + history: HistoryAppState; + parse: ParseAppState; + queue: QueueAppState; + settings: SettingsAppState; + tags: TagsAppState; + trackFiles: TrackFilesAppState; + tracksSelection: TracksAppState; + system: SystemAppState; +} + +export default AppState; diff --git a/frontend/src/App/State/ArtistAppState.ts b/frontend/src/App/State/ArtistAppState.ts new file mode 100644 index 000000000..9e0628df7 --- /dev/null +++ b/frontend/src/App/State/ArtistAppState.ts @@ -0,0 +1,72 @@ +import AppSectionState, { + AppSectionDeleteState, + AppSectionSaveState, +} from 'App/State/AppSectionState'; +import Artist from 'Artist/Artist'; +import Column from 'Components/Table/Column'; +import SortDirection from 'Helpers/Props/SortDirection'; +import { Filter, FilterBuilderProp } from './AppState'; + +export interface ArtistIndexAppState { + sortKey: string; + sortDirection: SortDirection; + secondarySortKey: string; + secondarySortDirection: SortDirection; + view: string; + + posterOptions: { + detailedProgressBar: boolean; + size: string; + showTitle: boolean; + showMonitored: boolean; + showQualityProfile: boolean; + showNextAlbum: boolean; + showSearchAction: boolean; + }; + + bannerOptions: { + detailedProgressBar: boolean; + size: string; + showTitle: boolean; + showMonitored: boolean; + showQualityProfile: boolean; + showNextAlbum: boolean; + showSearchAction: boolean; + }; + + overviewOptions: { + detailedProgressBar: boolean; + size: string; + showMonitored: boolean; + showQualityProfile: boolean; + showLastAlbum: boolean; + showAdded: boolean; + showAlbumCount: boolean; + showPath: boolean; + showSizeOnDisk: boolean; + showSearchAction: boolean; + }; + + tableOptions: { + showBanners: boolean; + showSearchAction: boolean; + }; + + selectedFilterKey: string; + filterBuilderProps: FilterBuilderProp[]; + filters: Filter[]; + columns: Column[]; +} + +interface ArtistAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState { + itemMap: Record; + + deleteOptions: { + addImportListExclusion: boolean; + }; +} + +export default ArtistAppState; diff --git a/frontend/src/App/State/CalendarAppState.ts b/frontend/src/App/State/CalendarAppState.ts new file mode 100644 index 000000000..503d2c25b --- /dev/null +++ b/frontend/src/App/State/CalendarAppState.ts @@ -0,0 +1,10 @@ +import Album from 'Album/Album'; +import AppSectionState, { + AppSectionFilterState, +} from 'App/State/AppSectionState'; + +interface CalendarAppState + extends AppSectionState, + AppSectionFilterState {} + +export default CalendarAppState; diff --git a/frontend/src/App/State/ClientSideCollectionAppState.ts b/frontend/src/App/State/ClientSideCollectionAppState.ts new file mode 100644 index 000000000..f4110ef73 --- /dev/null +++ b/frontend/src/App/State/ClientSideCollectionAppState.ts @@ -0,0 +1,8 @@ +import { CustomFilter } from './AppState'; + +interface ClientSideCollectionAppState { + totalItems: number; + customFilters: CustomFilter[]; +} + +export default ClientSideCollectionAppState; diff --git a/frontend/src/App/State/CommandAppState.ts b/frontend/src/App/State/CommandAppState.ts new file mode 100644 index 000000000..1bde37371 --- /dev/null +++ b/frontend/src/App/State/CommandAppState.ts @@ -0,0 +1,6 @@ +import AppSectionState from 'App/State/AppSectionState'; +import Command from 'Commands/Command'; + +export type CommandAppState = AppSectionState; + +export default CommandAppState; diff --git a/frontend/src/App/State/CustomFiltersAppState.ts b/frontend/src/App/State/CustomFiltersAppState.ts new file mode 100644 index 000000000..6ac4820c7 --- /dev/null +++ b/frontend/src/App/State/CustomFiltersAppState.ts @@ -0,0 +1,10 @@ +import AppSectionState, { + AppSectionDeleteState, +} from 'App/State/AppSectionState'; +import { CustomFilter } from './AppState'; + +interface CustomFiltersAppState + extends AppSectionState, + AppSectionDeleteState {} + +export default CustomFiltersAppState; diff --git a/frontend/src/App/State/HistoryAppState.ts b/frontend/src/App/State/HistoryAppState.ts new file mode 100644 index 000000000..e368ff86e --- /dev/null +++ b/frontend/src/App/State/HistoryAppState.ts @@ -0,0 +1,10 @@ +import AppSectionState, { + AppSectionFilterState, +} from 'App/State/AppSectionState'; +import History from 'typings/History'; + +interface HistoryAppState + extends AppSectionState, + AppSectionFilterState {} + +export default HistoryAppState; diff --git a/frontend/src/App/State/ParseAppState.ts b/frontend/src/App/State/ParseAppState.ts new file mode 100644 index 000000000..827d5b1a7 --- /dev/null +++ b/frontend/src/App/State/ParseAppState.ts @@ -0,0 +1,35 @@ +import Album from 'Album/Album'; +import ModelBase from 'App/ModelBase'; +import { AppSectionItemState } from 'App/State/AppSectionState'; +import Artist from 'Artist/Artist'; +import { QualityModel } from 'Quality/Quality'; +import CustomFormat from 'typings/CustomFormat'; + +export interface ArtistTitleInfo { + title: string; +} + +export interface ParsedAlbumInfo { + albumTitle: string; + artistName: string; + artistTitleInfo: ArtistTitleInfo; + discography: boolean; + quality: QualityModel; + releaseGroup?: string; + releaseHash: string; + releaseTitle: string; + releaseTokens: string; +} + +export interface ParseModel extends ModelBase { + title: string; + parsedAlbumInfo: ParsedAlbumInfo; + artist?: Artist; + albums: Album[]; + customFormats?: CustomFormat[]; + customFormatScore?: number; +} + +type ParseAppState = AppSectionItemState; + +export default ParseAppState; diff --git a/frontend/src/App/State/QueueAppState.ts b/frontend/src/App/State/QueueAppState.ts new file mode 100644 index 000000000..05d74acac --- /dev/null +++ b/frontend/src/App/State/QueueAppState.ts @@ -0,0 +1,27 @@ +import Queue from 'typings/Queue'; +import AppSectionState, { + AppSectionFilterState, + AppSectionItemState, + Error, +} from './AppSectionState'; + +export interface QueueDetailsAppState extends AppSectionState { + params: unknown; +} + +export interface QueuePagedAppState + extends AppSectionState, + AppSectionFilterState { + isGrabbing: boolean; + grabError: Error; + isRemoving: boolean; + removeError: Error; +} + +interface QueueAppState { + status: AppSectionItemState; + details: QueueDetailsAppState; + paged: QueuePagedAppState; +} + +export default QueueAppState; diff --git a/frontend/src/App/State/SettingsAppState.ts b/frontend/src/App/State/SettingsAppState.ts new file mode 100644 index 000000000..b387e13fd --- /dev/null +++ b/frontend/src/App/State/SettingsAppState.ts @@ -0,0 +1,76 @@ +import AppSectionState, { + AppSectionDeleteState, + AppSectionItemState, + AppSectionSaveState, + AppSectionSchemaState, +} from 'App/State/AppSectionState'; +import CustomFormat from 'typings/CustomFormat'; +import DownloadClient from 'typings/DownloadClient'; +import ImportList from 'typings/ImportList'; +import Indexer from 'typings/Indexer'; +import IndexerFlag from 'typings/IndexerFlag'; +import MetadataProfile from 'typings/MetadataProfile'; +import Notification from 'typings/Notification'; +import QualityProfile from 'typings/QualityProfile'; +import RootFolder from 'typings/RootFolder'; +import General from 'typings/Settings/General'; +import UiSettings from 'typings/Settings/UiSettings'; + +export interface DownloadClientAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +export type GeneralAppState = AppSectionItemState; + +export interface ImportListAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +export interface IndexerAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +export interface NotificationAppState + extends AppSectionState, + AppSectionDeleteState {} + +export interface QualityProfilesAppState + extends AppSectionState, + AppSectionSchemaState {} + +export interface MetadataProfilesAppState + extends AppSectionState, + AppSectionSchemaState {} + +export interface CustomFormatAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +export interface RootFolderAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +export type IndexerFlagSettingsAppState = AppSectionState; +export type UiSettingsAppState = AppSectionItemState; + +interface SettingsAppState { + advancedSettings: boolean; + customFormats: CustomFormatAppState; + downloadClients: DownloadClientAppState; + general: GeneralAppState; + importLists: ImportListAppState; + indexerFlags: IndexerFlagSettingsAppState; + indexers: IndexerAppState; + metadataProfiles: MetadataProfilesAppState; + notifications: NotificationAppState; + qualityProfiles: QualityProfilesAppState; + rootFolders: RootFolderAppState; + ui: UiSettingsAppState; +} + +export default SettingsAppState; diff --git a/frontend/src/App/State/SystemAppState.ts b/frontend/src/App/State/SystemAppState.ts new file mode 100644 index 000000000..3c150fcfb --- /dev/null +++ b/frontend/src/App/State/SystemAppState.ts @@ -0,0 +1,13 @@ +import SystemStatus from 'typings/SystemStatus'; +import Update from 'typings/Update'; +import AppSectionState, { AppSectionItemState } from './AppSectionState'; + +export type SystemStatusAppState = AppSectionItemState; +export type UpdateAppState = AppSectionState; + +interface SystemAppState { + updates: UpdateAppState; + status: SystemStatusAppState; +} + +export default SystemAppState; diff --git a/frontend/src/App/State/TagsAppState.ts b/frontend/src/App/State/TagsAppState.ts new file mode 100644 index 000000000..edaf3a158 --- /dev/null +++ b/frontend/src/App/State/TagsAppState.ts @@ -0,0 +1,32 @@ +import ModelBase from 'App/ModelBase'; +import AppSectionState, { + AppSectionDeleteState, + AppSectionSaveState, +} from 'App/State/AppSectionState'; + +export interface Tag extends ModelBase { + label: string; +} + +export interface TagDetail extends ModelBase { + label: string; + autoTagIds: number[]; + delayProfileIds: number[]; + downloadClientIds: []; + importListIds: number[]; + indexerIds: number[]; + notificationIds: number[]; + restrictionIds: number[]; + artistIds: number[]; +} + +export interface TagDetailAppState + extends AppSectionState, + AppSectionDeleteState, + AppSectionSaveState {} + +interface TagsAppState extends AppSectionState, AppSectionDeleteState { + details: TagDetailAppState; +} + +export default TagsAppState; diff --git a/frontend/src/App/State/TrackFilesAppState.ts b/frontend/src/App/State/TrackFilesAppState.ts new file mode 100644 index 000000000..403ba904d --- /dev/null +++ b/frontend/src/App/State/TrackFilesAppState.ts @@ -0,0 +1,10 @@ +import AppSectionState, { + AppSectionDeleteState, +} from 'App/State/AppSectionState'; +import { TrackFile } from 'TrackFile/TrackFile'; + +interface TrackFilesAppState + extends AppSectionState, + AppSectionDeleteState {} + +export default TrackFilesAppState; diff --git a/frontend/src/App/State/TracksAppState.ts b/frontend/src/App/State/TracksAppState.ts new file mode 100644 index 000000000..22aaabed9 --- /dev/null +++ b/frontend/src/App/State/TracksAppState.ts @@ -0,0 +1,6 @@ +import AppSectionState from 'App/State/AppSectionState'; +import Track from 'Track/Track'; + +type TracksAppState = AppSectionState; + +export default TracksAppState; diff --git a/frontend/src/Artist/Artist.ts b/frontend/src/Artist/Artist.ts new file mode 100644 index 000000000..813dbea08 --- /dev/null +++ b/frontend/src/Artist/Artist.ts @@ -0,0 +1,51 @@ +import Album from 'Album/Album'; +import ModelBase from 'App/ModelBase'; + +export interface Image { + coverType: string; + url: string; + remoteUrl: string; +} + +export interface Statistics { + albumCount: number; + trackCount: number; + trackFileCount: number; + percentOfTracks: number; + sizeOnDisk: number; + totalTrackCount: number; +} + +export interface Ratings { + votes: number; + value: number; +} + +interface Artist extends ModelBase { + added: string; + foreignArtistId: string; + cleanName: string; + ended: boolean; + genres: string[]; + images: Image[]; + monitored: boolean; + overview: string; + path: string; + lastAlbum?: Album; + nextAlbum?: Album; + qualityProfileId: number; + metadataProfileId: number; + monitorNewItems: string; + ratings: Ratings; + rootFolderPath: string; + sortName: string; + statistics: Statistics; + status: string; + tags: number[]; + artistName: string; + artistType?: string; + disambiguation?: string; + isSaving?: boolean; +} + +export default Artist; diff --git a/frontend/src/Artist/ArtistBanner.js b/frontend/src/Artist/ArtistBanner.js index b409667b1..5483912e1 100644 --- a/frontend/src/Artist/ArtistBanner.js +++ b/frontend/src/Artist/ArtistBanner.js @@ -15,6 +15,10 @@ function ArtistBanner(props) { } ArtistBanner.propTypes = { + ...ArtistImage.propTypes, + coverType: PropTypes.string, + placeholder: PropTypes.string, + overflow: PropTypes.bool, size: PropTypes.number.isRequired }; diff --git a/frontend/src/Artist/ArtistImage.js b/frontend/src/Artist/ArtistImage.js index 6ae479a18..669cba8d8 100644 --- a/frontend/src/Artist/ArtistImage.js +++ b/frontend/src/Artist/ArtistImage.js @@ -7,13 +7,10 @@ function findImage(images, coverType) { } function getUrl(image, coverType, size) { - if (image) { - // Remove protocol - let url = image.url.replace(/^https?:/, ''); + const imageUrl = image?.url; - url = url.replace(`${coverType}.jpg`, `${coverType}-${size}.jpg`); - - return url; + if (imageUrl) { + return imageUrl.replace(`${coverType}.jpg`, `${coverType}-${size}.jpg`); } } @@ -99,7 +96,7 @@ class ArtistImage extends Component { if (this.props.onError) { this.props.onError(); } - } + }; onLoad = () => { this.setState({ @@ -110,7 +107,7 @@ class ArtistImage extends Component { if (this.props.onLoad) { this.props.onLoad(); } - } + }; // // Render @@ -161,6 +158,7 @@ class ArtistImage extends Component { src={url} onError={this.onError} onLoad={this.onLoad} + rel="noreferrer" /> ); diff --git a/frontend/src/Artist/ArtistLogo.js b/frontend/src/Artist/ArtistLogo.js index 05e665186..93b91c2da 100644 --- a/frontend/src/Artist/ArtistLogo.js +++ b/frontend/src/Artist/ArtistLogo.js @@ -10,12 +10,10 @@ function findLogo(images) { } function getLogoUrl(logo, size) { - if (logo) { - // Remove protocol - let url = logo.url.replace(/^https?:/, ''); - url = url.replace('logo.jpg', `logo-${size}.jpg`); + const logoUrl = logo?.url; - return url; + if (logoUrl) { + return logoUrl.replace('logo.jpg', `logo-${size}.jpg`); } } @@ -72,11 +70,11 @@ class ArtistLogo extends Component { onError = () => { this.setState({ hasError: true }); - } + }; onLoad = () => { this.setState({ isLoaded: true }); - } + }; // // Render diff --git a/frontend/src/Artist/ArtistPoster.js b/frontend/src/Artist/ArtistPoster.js index 4eebd9ca4..de594e5b9 100644 --- a/frontend/src/Artist/ArtistPoster.js +++ b/frontend/src/Artist/ArtistPoster.js @@ -15,6 +15,10 @@ function ArtistPoster(props) { } ArtistPoster.propTypes = { + ...ArtistImage.propTypes, + coverType: PropTypes.string, + placeholder: PropTypes.string, + overflow: PropTypes.bool, size: PropTypes.number.isRequired }; diff --git a/frontend/src/Artist/Delete/DeleteArtistModal.js b/frontend/src/Artist/Delete/DeleteArtistModal.js index 5b6490c66..c647b7735 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModal.js +++ b/frontend/src/Artist/Delete/DeleteArtistModal.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { sizes } from 'Helpers/Props'; import Modal from 'Components/Modal/Modal'; +import { sizes } from 'Helpers/Props'; import DeleteArtistModalContentConnector from './DeleteArtistModalContentConnector'; function DeleteArtistModal(props) { @@ -26,6 +26,7 @@ function DeleteArtistModal(props) { } DeleteArtistModal.propTypes = { + ...DeleteArtistModalContentConnector.propTypes, isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; diff --git a/frontend/src/Artist/Delete/DeleteArtistModalContent.css b/frontend/src/Artist/Delete/DeleteArtistModalContent.css index dbfef0871..df8e4822e 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModalContent.css +++ b/frontend/src/Artist/Delete/DeleteArtistModalContent.css @@ -8,5 +8,5 @@ .deleteFilesMessage { margin-top: 20px; - color: $dangerColor; + color: var(--dangerColor); } diff --git a/frontend/src/Artist/Delete/DeleteArtistModalContent.css.d.ts b/frontend/src/Artist/Delete/DeleteArtistModalContent.css.d.ts new file mode 100644 index 000000000..e55686abe --- /dev/null +++ b/frontend/src/Artist/Delete/DeleteArtistModalContent.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'deleteFilesMessage': string; + 'pathContainer': string; + 'pathIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Delete/DeleteArtistModalContent.js b/frontend/src/Artist/Delete/DeleteArtistModalContent.js index a242a1e20..ac1e2b041 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModalContent.js +++ b/frontend/src/Artist/Delete/DeleteArtistModalContent.js @@ -1,16 +1,17 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import formatBytes from 'Utilities/Number/formatBytes'; -import { icons, inputTypes, kinds } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import Icon from 'Components/Icon'; import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; import FormInputGroup from 'Components/Form/FormInputGroup'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; +import FormLabel from 'Components/Form/FormLabel'; +import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { icons, inputTypes, kinds } from 'Helpers/Props'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; import styles from './DeleteArtistModalContent.css'; class DeleteArtistModalContent extends Component { @@ -22,8 +23,7 @@ class DeleteArtistModalContent extends Component { super(props, context); this.state = { - deleteFiles: false, - addImportListExclusion: false + deleteFiles: false }; } @@ -32,20 +32,15 @@ class DeleteArtistModalContent extends Component { onDeleteFilesChange = ({ value }) => { this.setState({ deleteFiles: value }); - } - - onAddImportListExclusionChange = ({ value }) => { - this.setState({ addImportListExclusion: value }); - } + }; onDeleteArtistConfirmed = () => { const deleteFiles = this.state.deleteFiles; - const addImportListExclusion = this.state.addImportListExclusion; + const addImportListExclusion = this.props.deleteOptions.addImportListExclusion; this.setState({ deleteFiles: false }); - this.setState({ addImportListExclusion: false }); this.props.onDeletePress(deleteFiles, addImportListExclusion); - } + }; // // Render @@ -55,19 +50,21 @@ class DeleteArtistModalContent extends Component { artistName, path, statistics, - onModalClose + deleteOptions, + onModalClose, + onDeleteOptionChange } = this.props; const { - trackFileCount, - sizeOnDisk + trackFileCount = 0, + sizeOnDisk = 0 } = statistics; const deleteFiles = this.state.deleteFiles; - const addImportListExclusion = this.state.addImportListExclusion; + const addImportListExclusion = deleteOptions.addImportListExclusion; let deleteFilesLabel = `Delete ${trackFileCount} Track Files`; - let deleteFilesHelpText = 'Delete the track files and artist folder'; + let deleteFilesHelpText = translate('DeleteFilesHelpText'); if (trackFileCount === 0) { deleteFilesLabel = 'Delete Artist Folder'; @@ -106,22 +103,26 @@ class DeleteArtistModalContent extends Component { - Add List Exclusion + + {translate('AddListExclusion')} + { deleteFiles &&
-
The artist folder {path} and all of its content will be deleted.
+
+ {translate('TheArtistFolderStrongpathstrongAndAllOfItsContentWillBeDeleted', [path])} +
{ !!trackFileCount && @@ -134,14 +135,14 @@ class DeleteArtistModalContent extends Component { @@ -153,14 +154,14 @@ DeleteArtistModalContent.propTypes = { artistName: PropTypes.string.isRequired, path: PropTypes.string.isRequired, statistics: PropTypes.object.isRequired, + deleteOptions: PropTypes.object.isRequired, + onDeleteOptionChange: PropTypes.func.isRequired, onDeletePress: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired }; DeleteArtistModalContent.defaultProps = { - statistics: { - trackFileCount: 0 - } + statistics: {} }; export default DeleteArtistModalContent; diff --git a/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js b/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js index e0ea034ab..321dc63a6 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js +++ b/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js @@ -1,56 +1,44 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; +import { deleteArtist, setDeleteOption } from 'Store/Actions/artistActions'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; -import { deleteArtist } from 'Store/Actions/artistActions'; import DeleteArtistModalContent from './DeleteArtistModalContent'; function createMapStateToProps() { return createSelector( + (state) => state.artist.deleteOptions, createArtistSelector(), - (artist) => { - return artist; + (deleteOptions, artist) => { + return { + ...artist, + deleteOptions + }; } ); } -const mapDispatchToProps = { - deleteArtist -}; +function createMapDispatchToProps(dispatch, props) { + return { + onDeleteOptionChange(option) { + dispatch( + setDeleteOption({ + [option.name]: option.value + }) + ); + }, -class DeleteArtistModalContentConnector extends Component { + onDeletePress(deleteFiles, addImportListExclusion) { + dispatch( + deleteArtist({ + id: props.artistId, + deleteFiles, + addImportListExclusion + }) + ); - // - // Listeners - - onDeletePress = (deleteFiles, addImportListExclusion) => { - this.props.deleteArtist({ - id: this.props.artistId, - deleteFiles, - addImportListExclusion - }); - - this.props.onModalClose(true); - } - - // - // Render - - render() { - return ( - - ); - } + props.onModalClose(true); + } + }; } -DeleteArtistModalContentConnector.propTypes = { - artistId: PropTypes.number.isRequired, - onModalClose: PropTypes.func.isRequired, - deleteArtist: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(DeleteArtistModalContentConnector); +export default connect(createMapStateToProps, createMapDispatchToProps)(DeleteArtistModalContent); diff --git a/frontend/src/Artist/Details/AlbumGroupInfo.css b/frontend/src/Artist/Details/AlbumGroupInfo.css new file mode 100644 index 000000000..9a414e728 --- /dev/null +++ b/frontend/src/Artist/Details/AlbumGroupInfo.css @@ -0,0 +1,11 @@ +.title { + composes: title from '~Components/DescriptionList/DescriptionListItemTitle.css'; + + width: 90px; +} + +.description { + composes: description from '~Components/DescriptionList/DescriptionListItemDescription.css'; + + margin-left: 110px; +} diff --git a/frontend/src/Artist/Details/AlbumGroupInfo.css.d.ts b/frontend/src/Artist/Details/AlbumGroupInfo.css.d.ts new file mode 100644 index 000000000..e0d8c2f6b --- /dev/null +++ b/frontend/src/Artist/Details/AlbumGroupInfo.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'description': string; + 'title': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Details/AlbumGroupInfo.js b/frontend/src/Artist/Details/AlbumGroupInfo.js new file mode 100644 index 000000000..139cd7765 --- /dev/null +++ b/frontend/src/Artist/Details/AlbumGroupInfo.js @@ -0,0 +1,66 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import DescriptionList from 'Components/DescriptionList/DescriptionList'; +import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import styles from './AlbumGroupInfo.css'; + +function AlbumGroupInfo(props) { + const { + totalAlbumCount, + monitoredAlbumCount, + albumFileCount, + trackFileCount, + sizeOnDisk + } = props; + + return ( + + + + + + + + + + + + ); +} + +AlbumGroupInfo.propTypes = { + totalAlbumCount: PropTypes.number.isRequired, + monitoredAlbumCount: PropTypes.number.isRequired, + albumFileCount: PropTypes.number.isRequired, + trackFileCount: PropTypes.number.isRequired, + sizeOnDisk: PropTypes.number.isRequired +}; + +export default AlbumGroupInfo; diff --git a/frontend/src/Artist/Details/AlbumRow.css b/frontend/src/Artist/Details/AlbumRow.css index e29f491d7..383d97746 100644 --- a/frontend/src/Artist/Details/AlbumRow.css +++ b/frontend/src/Artist/Details/AlbumRow.css @@ -1,7 +1,7 @@ .title { composes: cell from '~Components/Table/Cells/TableRowCell.css'; - white-space: nowrap; + word-break: break-word; } .monitored { @@ -10,6 +10,7 @@ width: 42px; } +.size, .status { composes: cell from '~Components/Table/Cells/TableRowCell.css'; diff --git a/frontend/src/Artist/Details/AlbumRow.css.d.ts b/frontend/src/Artist/Details/AlbumRow.css.d.ts new file mode 100644 index 000000000..90377b53b --- /dev/null +++ b/frontend/src/Artist/Details/AlbumRow.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'monitored': string; + 'size': string; + 'status': string; + 'title': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Details/AlbumRow.js b/frontend/src/Artist/Details/AlbumRow.js index e2d6cf65e..b5c8fa2cf 100644 --- a/frontend/src/Artist/Details/AlbumRow.js +++ b/frontend/src/Artist/Details/AlbumRow.js @@ -1,15 +1,17 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import MonitorToggleButton from 'Components/MonitorToggleButton'; -import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; -import { kinds, sizes } from 'Helpers/Props'; -import TableRow from 'Components/Table/TableRow'; -import Label from 'Components/Label'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; -import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; import AlbumSearchCellConnector from 'Album/AlbumSearchCellConnector'; import AlbumTitleLink from 'Album/AlbumTitleLink'; +import Label from 'Components/Label'; +import MonitorToggleButton from 'Components/MonitorToggleButton'; import StarRating from 'Components/StarRating'; +import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import TableRow from 'Components/Table/TableRow'; +import { kinds, sizes } from 'Helpers/Props'; +import formatTimeSpan from 'Utilities/Date/formatTimeSpan'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; import styles from './AlbumRow.css'; function getTrackCountKind(monitored, trackFileCount, trackCount) { @@ -43,23 +45,23 @@ class AlbumRow extends Component { onManualSearchPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; onEditAlbumPress = () => { this.setState({ isEditAlbumModalOpen: true }); - } + }; onEditAlbumModalClose = () => { this.setState({ isEditAlbumModalOpen: false }); - } + }; onMonitorAlbumPress = (monitored, options) => { this.props.onMonitorAlbumPress(this.props.id, monitored, options); - } + }; // // Render @@ -84,9 +86,10 @@ class AlbumRow extends Component { } = this.props; const { - trackCount, - trackFileCount, - totalTrackCount + trackCount = 0, + trackFileCount = 0, + totalTrackCount = 0, + sizeOnDisk = 0 } = statistics; return ( @@ -146,9 +149,7 @@ class AlbumRow extends Component { if (name === 'secondaryTypes') { return ( - { - secondaryTypes - } + {secondaryTypes.join(', ')} ); } @@ -157,7 +158,7 @@ class AlbumRow extends Component { return ( { - statistics.totalTrackCount + totalTrackCount } ); @@ -195,6 +196,17 @@ class AlbumRow extends Component { ); } + if (name === 'size') { + return ( + + {!!sizeOnDisk && formatBytes(sizeOnDisk)} + + ); + } + if (name === 'status') { return (
@@ -445,26 +469,36 @@ class ArtistDetails extends Component { - + + { + formatBytes(sizeOnDisk || 0) + } + + + } + tooltip={ + + {trackFilesCountMessage} + + } + kind={kinds.INVERSE} + position={tooltipPositions.BOTTOM} + /> @@ -522,7 +556,7 @@ class ArtistDetails extends Component { /> - Links + {translate('Links')} } @@ -578,13 +612,19 @@ class ArtistDetails extends Component { } { - !isFetching && albumsError && -
Loading albums failed
+ !isFetching && albumsError ? + + {translate('AlbumsLoadError')} + : + null } { - !isFetching && trackFilesError && -
Loading track files failed
+ !isFetching && trackFilesError ? + + {translate('TrackFilesLoadError')} + : + null } { @@ -611,7 +651,11 @@ class ArtistDetails extends Component {
- Missing Albums, Singles, or Other Types? Modify or Create a New Metadata Profile! + Missing Albums, Singles, or Other Types? Modify or create a new + Metadata Profile + or manually + Search + for new items!
-
+ + +
); } @@ -682,6 +733,7 @@ ArtistDetails.propTypes = { monitored: PropTypes.bool.isRequired, artistType: PropTypes.string, albumTypes: PropTypes.arrayOf(PropTypes.string), + genres: PropTypes.arrayOf(PropTypes.string), status: PropTypes.string.isRequired, overview: PropTypes.string.isRequired, links: PropTypes.arrayOf(PropTypes.object).isRequired, diff --git a/frontend/src/Artist/Details/ArtistDetailsConnector.js b/frontend/src/Artist/Details/ArtistDetailsConnector.js index 2e5ba1d11..bed30a937 100644 --- a/frontend/src/Artist/Details/ArtistDetailsConnector.js +++ b/frontend/src/Artist/Details/ArtistDetailsConnector.js @@ -4,16 +4,16 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { findCommand, isCommandExecuting } from 'Utilities/Command'; -import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; +import * as commandNames from 'Commands/commandNames'; +import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; +import { toggleArtistMonitored } from 'Store/Actions/artistActions'; +import { executeCommand } from 'Store/Actions/commandActions'; +import { clearQueueDetails, fetchQueueDetails } from 'Store/Actions/queueActions'; +import { clearTrackFiles, fetchTrackFiles } from 'Store/Actions/trackFileActions'; import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; -import { fetchAlbums, clearAlbums } from 'Store/Actions/albumActions'; -import { fetchTrackFiles, clearTrackFiles } from 'Store/Actions/trackFileActions'; -import { toggleArtistMonitored } from 'Store/Actions/artistActions'; -import { fetchQueueDetails, clearQueueDetails } from 'Store/Actions/queueActions'; -import { executeCommand } from 'Store/Actions/commandActions'; -import * as commandNames from 'Commands/commandNames'; +import { findCommand, isCommandExecuting } from 'Utilities/Command'; +import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; import ArtistDetails from './ArtistDetails'; const selectAlbums = createSelector( @@ -28,13 +28,15 @@ const selectAlbums = createSelector( const hasAlbums = !!items.length; const hasMonitoredAlbums = items.some((e) => e.monitored); + const albumTypes = _.uniq(_.map(items, 'albumType')); return { isAlbumsFetching: isFetching, isAlbumsPopulated: isPopulated, albumsError: error, hasAlbums, - hasMonitoredAlbums + hasMonitoredAlbums, + albumTypes }; } ); @@ -65,20 +67,12 @@ function createMapStateToProps() { (state, { foreignArtistId }) => foreignArtistId, selectAlbums, selectTrackFiles, - (state) => state.settings.metadataProfiles, createAllArtistSelector(), createCommandsSelector(), - (foreignArtistId, albums, trackFiles, metadataProfiles, allArtists, commands) => { + (foreignArtistId, albums, trackFiles, allArtists, commands) => { const sortedArtist = _.orderBy(allArtists, 'sortName'); const artistIndex = _.findIndex(sortedArtist, { foreignArtistId }); const artist = sortedArtist[artistIndex]; - const metadataProfile = _.find(metadataProfiles.items, { id: artist.metadataProfileId }); - const albumTypes = _.reduce(metadataProfile.primaryAlbumTypes, (acc, primaryType) => { - if (primaryType.allowed) { - acc.push(primaryType.albumType.name); - } - return acc; - }, []); if (!artist) { return {}; @@ -89,7 +83,8 @@ function createMapStateToProps() { isAlbumsPopulated, albumsError, hasAlbums, - hasMonitoredAlbums + hasMonitoredAlbums, + albumTypes } = albums; const { @@ -112,7 +107,6 @@ function createMapStateToProps() { const isRefreshing = isArtistRefreshing || allArtistRefreshing; const isSearching = isCommandExecuting(findCommand(commands, { name: commandNames.ARTIST_SEARCH, artistId: artist.id })); const isRenamingFiles = isCommandExecuting(findCommand(commands, { name: commandNames.RENAME_FILES, artistId: artist.id })); - const isRenamingArtistCommand = findCommand(commands, { name: commandNames.RENAME_ARTIST }); const isRenamingArtist = ( isCommandExecuting(isRenamingArtistCommand) && @@ -217,13 +211,13 @@ class ArtistDetailsConnector extends Component { this.props.fetchAlbums({ artistId }); this.props.fetchTrackFiles({ artistId }); this.props.fetchQueueDetails({ artistId }); - } + }; unpopulate = () => { this.props.clearAlbums(); this.props.clearTrackFiles(); this.props.clearQueueDetails(); - } + }; // // Listeners @@ -233,21 +227,21 @@ class ArtistDetailsConnector extends Component { artistId: this.props.id, monitored }); - } + }; onRefreshPress = () => { this.props.executeCommand({ name: commandNames.REFRESH_ARTIST, artistId: this.props.id }); - } + }; onSearchPress = () => { this.props.executeCommand({ name: commandNames.ARTIST_SEARCH, artistId: this.props.id }); - } + }; // // Render diff --git a/frontend/src/Artist/Details/ArtistDetailsLinks.css.d.ts b/frontend/src/Artist/Details/ArtistDetailsLinks.css.d.ts new file mode 100644 index 000000000..9f91f93a4 --- /dev/null +++ b/frontend/src/Artist/Details/ArtistDetailsLinks.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'link': string; + 'linkLabel': string; + 'links': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Details/ArtistDetailsLinks.js b/frontend/src/Artist/Details/ArtistDetailsLinks.js index 23941d06b..d6229b484 100644 --- a/frontend/src/Artist/Details/ArtistDetailsLinks.js +++ b/frontend/src/Artist/Details/ArtistDetailsLinks.js @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { kinds, sizes } from 'Helpers/Props'; import Label from 'Components/Label'; import Link from 'Components/Link/Link'; +import { kinds, sizes } from 'Helpers/Props'; import styles from './ArtistDetailsLinks.css'; function ArtistDetailsLinks(props) { diff --git a/frontend/src/Artist/Details/ArtistDetailsPageConnector.js b/frontend/src/Artist/Details/ArtistDetailsPageConnector.js index 61b1a0f4c..cb379af26 100644 --- a/frontend/src/Artist/Details/ArtistDetailsPageConnector.js +++ b/frontend/src/Artist/Details/ArtistDetailsPageConnector.js @@ -1,14 +1,15 @@ +import { push } from 'connected-react-router'; import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { push } from 'connected-react-router'; -import getErrorMessage from 'Utilities/Object/getErrorMessage'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import NotFound from 'Components/NotFound'; +import PageContent from 'Components/Page/PageContent'; +import PageContentBody from 'Components/Page/PageContentBody'; +import getErrorMessage from 'Utilities/Object/getErrorMessage'; +import translate from 'Utilities/String/translate'; import ArtistDetailsConnector from './ArtistDetailsConnector'; import styles from './ArtistDetails.css'; @@ -73,10 +74,10 @@ class ArtistDetailsPageConnector extends Component { if (isFetching && !isPopulated) { return ( - - + + - + ); } @@ -92,7 +93,7 @@ class ArtistDetailsPageConnector extends Component { if (!foreignArtistId) { return ( ); } diff --git a/frontend/src/Artist/Details/ArtistDetailsSeason.css b/frontend/src/Artist/Details/ArtistDetailsSeason.css index 127f0c772..4421fe7a7 100644 --- a/frontend/src/Artist/Details/ArtistDetailsSeason.css +++ b/frontend/src/Artist/Details/ArtistDetailsSeason.css @@ -1,8 +1,8 @@ .albumType { margin-bottom: 20px; - border: 1px solid $borderColor; + border: 1px solid var(--borderColor); border-radius: 4px; - background-color: $white; + background-color: var(--cardBackgroundColor); &:last-of-type { margin-bottom: 0; @@ -15,11 +15,10 @@ align-items: center; width: 100%; font-size: 24px; - cursor: pointer; } .albumTypeLabel { - margin-right: 5px; + margin-right: 10px; margin-left: 5px; } @@ -29,10 +28,16 @@ font-size: 18px; } -.episodeCountTooltip { +.albumCountTooltip { display: flex; } +.sizeOnDisk { + margin-left: 10px; + color: #777; + font-size: $defaultFontSize; +} + .expandButton { composes: link from '~Components/Link/Link.css'; @@ -44,7 +49,7 @@ .left { display: flex; align-items: center; - flex: 0 1 300px; + flex: 0 1 350px; } .left, @@ -77,7 +82,7 @@ .albums { padding-top: 15px; - border-top: 1px solid $borderColor; + border-top: 1px solid var(--borderColor); } .collapseButtonContainer { @@ -86,10 +91,10 @@ justify-content: center; padding: 10px 15px; width: 100%; - border-top: 1px solid $borderColor; + border-top: 1px solid var(--borderColor); border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; - background-color: #fafafa; + background-color: var(--collapseButtonBackgroundColor); } .collapseButtonIcon { @@ -103,7 +108,7 @@ top: 50%; left: 50%; margin-top: -12px; - margin-left: -15px; + margin-left: -12px; } .noAlbums { @@ -122,4 +127,8 @@ position: static; margin: 0; } + + .sizeOnDisk { + display: none; + } } diff --git a/frontend/src/Artist/Details/ArtistDetailsSeason.css.d.ts b/frontend/src/Artist/Details/ArtistDetailsSeason.css.d.ts new file mode 100644 index 000000000..c3c20ac42 --- /dev/null +++ b/frontend/src/Artist/Details/ArtistDetailsSeason.css.d.ts @@ -0,0 +1,24 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actionButton': string; + 'actionMenuIcon': string; + 'actions': string; + 'actionsMenu': string; + 'actionsMenuContent': string; + 'albumCount': string; + 'albumCountTooltip': string; + 'albumType': string; + 'albumTypeLabel': string; + 'albums': string; + 'collapseButtonContainer': string; + 'collapseButtonIcon': string; + 'expandButton': string; + 'expandButtonIcon': string; + 'header': string; + 'left': string; + 'noAlbums': string; + 'sizeOnDisk': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Details/ArtistDetailsSeason.js b/frontend/src/Artist/Details/ArtistDetailsSeason.js index f9968a8e9..004613e30 100644 --- a/frontend/src/Artist/Details/ArtistDetailsSeason.js +++ b/frontend/src/Artist/Details/ArtistDetailsSeason.js @@ -1,18 +1,84 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import getToggledRange from 'Utilities/Table/getToggledRange'; -import { icons, sortDirections } from 'Helpers/Props'; import Icon from 'Components/Icon'; +import Label from 'Components/Label'; import IconButton from 'Components/Link/IconButton'; import Link from 'Components/Link/Link'; +import MonitorToggleButton from 'Components/MonitorToggleButton'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; -import TrackFileEditorModal from 'TrackFile/Editor/TrackFileEditorModal'; +import Popover from 'Components/Tooltip/Popover'; +import { icons, kinds, sizes, sortDirections, tooltipPositions } from 'Helpers/Props'; import OrganizePreviewModalConnector from 'Organize/OrganizePreviewModalConnector'; +import TrackFileEditorModal from 'TrackFile/Editor/TrackFileEditorModal'; +import isBefore from 'Utilities/Date/isBefore'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import getToggledRange from 'Utilities/Table/getToggledRange'; +import AlbumGroupInfo from './AlbumGroupInfo'; import AlbumRowConnector from './AlbumRowConnector'; import styles from './ArtistDetailsSeason.css'; +function getAlbumStatistics(albums) { + let albumCount = 0; + let albumFileCount = 0; + let trackFileCount = 0; + let totalAlbumCount = 0; + let monitoredAlbumCount = 0; + let hasMonitoredAlbums = false; + let sizeOnDisk = 0; + + albums.forEach(({ monitored, releaseDate, statistics = {} }) => { + const { + trackFileCount: albumTrackFileCount = 0, + totalTrackCount: albumTotalTrackCount = 0, + sizeOnDisk: albumSizeOnDisk = 0 + } = statistics; + + const hasFiles = albumTrackFileCount > 0 && albumTrackFileCount === albumTotalTrackCount; + + if (hasFiles || (monitored && isBefore(releaseDate))) { + albumCount++; + } + + if (hasFiles) { + albumFileCount++; + } + + if (monitored) { + monitoredAlbumCount++; + hasMonitoredAlbums = true; + } + + totalAlbumCount++; + trackFileCount = trackFileCount + albumTrackFileCount; + sizeOnDisk = sizeOnDisk + albumSizeOnDisk; + }); + + return { + albumCount, + albumFileCount, + totalAlbumCount, + trackFileCount, + monitoredAlbumCount, + sizeOnDisk, + hasMonitoredAlbums + }; +} + +function getAlbumCountKind(monitored, albumCount, albumFileCount) { + if (albumCount === albumFileCount && albumFileCount > 0) { + return kinds.SUCCESS; + } + + if (!monitored) { + return kinds.WARNING; + } + + return kinds.DANGER; +} + class ArtistDetailsSeason extends Component { // @@ -69,19 +135,19 @@ class ArtistDetailsSeason extends Component { onOrganizePress = () => { this.setState({ isOrganizeModalOpen: true }); - } + }; onOrganizeModalClose = () => { this.setState({ isOrganizeModalOpen: false }); - } + }; onManageTracksPress = () => { this.setState({ isManageTracksOpen: true }); - } + }; onManageTracksModalClose = () => { this.setState({ isManageTracksOpen: false }); - } + }; onExpandPress = () => { const { @@ -90,7 +156,7 @@ class ArtistDetailsSeason extends Component { } = this.props; this.props.onExpandPress(name, !isExpanded); - } + }; onMonitorAlbumPress = (albumId, monitored, { shiftKey }) => { const lastToggled = this.state.lastToggledAlbum; @@ -107,8 +173,14 @@ class ArtistDetailsSeason extends Component { this.setState({ lastToggledAlbum: albumId }); - this.props.onMonitorAlbumPress(_.uniq(albumIds), monitored); - } + this.props.onMonitorAlbumsPress(_.uniq(albumIds), monitored); + }; + + onMonitorAlbumsPress = (monitored, { shiftKey }) => { + const albumIds = this.props.items.map((a) => a.id); + + this.props.onMonitorAlbumsPress(_.uniq(albumIds), monitored); + }; // // Render @@ -119,7 +191,9 @@ class ArtistDetailsSeason extends Component { label, items, columns, + isSaving, isExpanded, + artistMonitored, sortKey, sortDirection, onSortPress, @@ -127,6 +201,16 @@ class ArtistDetailsSeason extends Component { onTableOptionChange } = this.props; + const { + albumCount, + albumFileCount, + totalAlbumCount, + trackFileCount, + monitoredAlbumCount, + hasMonitoredAlbums, + sizeOnDisk = 0 + } = getAlbumStatistics(items); + const { isOrganizeModalOpen, isManageTracksOpen @@ -136,30 +220,62 @@ class ArtistDetailsSeason extends Component {
- -
-
- { +
+
+ + + {label} + + + {albumFileCount} / {albumCount} + + } + title={translate('GroupInformation')} + body={
- - {label} - - - - ({items.length} Releases) - +
} + position={tooltipPositions.BOTTOM} + /> -
+ { + sizeOnDisk ? +
+ {formatBytes(sizeOnDisk)} +
: + null + } +
+ + @@ -167,9 +283,9 @@ class ArtistDetailsSeason extends Component { !isSmallScreen &&   } + -
- +
{ @@ -209,7 +325,7 @@ class ArtistDetailsSeason extends Component { iconClassName={styles.collapseButtonIcon} name={icons.COLLAPSE} size={20} - title="Hide albums" + title={translate('HideAlbums')} onPress={this.onExpandPress} />
@@ -237,16 +353,18 @@ ArtistDetailsSeason.propTypes = { artistId: PropTypes.number.isRequired, name: PropTypes.string.isRequired, label: PropTypes.string.isRequired, + artistMonitored: PropTypes.bool.isRequired, sortKey: PropTypes.string, sortDirection: PropTypes.oneOf(sortDirections.all), items: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, + isSaving: PropTypes.bool, isExpanded: PropTypes.bool, isSmallScreen: PropTypes.bool.isRequired, onTableOptionChange: PropTypes.func.isRequired, onExpandPress: PropTypes.func.isRequired, onSortPress: PropTypes.func.isRequired, - onMonitorAlbumPress: PropTypes.func.isRequired, + onMonitorAlbumsPress: PropTypes.func.isRequired, uiSettings: PropTypes.object.isRequired }; diff --git a/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js b/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js index ffb84ba2c..6eb98cd52 100644 --- a/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js +++ b/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js @@ -4,13 +4,13 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import createArtistSelector from 'Store/Selectors/createArtistSelector'; -import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; -import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector'; -import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; -import { toggleAlbumsMonitored, setAlbumsTableOption, setAlbumsSort } from 'Store/Actions/albumActions'; +import { setAlbumsSort, setAlbumsTableOption, toggleAlbumsMonitored } from 'Store/Actions/albumActions'; import { executeCommand } from 'Store/Actions/commandActions'; +import createArtistSelector from 'Store/Selectors/createArtistSelector'; +import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector'; +import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; +import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; +import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; import ArtistDetailsSeason from './ArtistDetailsSeason'; function createMapStateToProps() { @@ -36,9 +36,9 @@ function createMapStateToProps() { return { items: sortedAlbums, columns: albums.columns, + artistMonitored: artist.monitored, sortKey: albums.sortKey, sortDirection: albums.sortDirection, - artistMonitored: artist.monitored, isSmallScreen: dimensions.isSmallScreen, uiSettings }; @@ -60,18 +60,18 @@ class ArtistDetailsSeasonConnector extends Component { onTableOptionChange = (payload) => { this.props.setAlbumsTableOption(payload); - } + }; onSortPress = (sortKey) => { this.props.dispatchSetAlbumSort({ sortKey }); - } + }; - onMonitorAlbumPress = (albumIds, monitored) => { + onMonitorAlbumsPress = (albumIds, monitored) => { this.props.toggleAlbumsMonitored({ albumIds, monitored }); - } + }; // // Render @@ -82,7 +82,7 @@ class ArtistDetailsSeasonConnector extends Component { {...this.props} onSortPress={this.onSortPress} onTableOptionChange={this.onTableOptionChange} - onMonitorAlbumPress={this.onMonitorAlbumPress} + onMonitorAlbumsPress={this.onMonitorAlbumsPress} /> ); } diff --git a/frontend/src/Artist/Details/ArtistGenres.css b/frontend/src/Artist/Details/ArtistGenres.css new file mode 100644 index 000000000..93a028748 --- /dev/null +++ b/frontend/src/Artist/Details/ArtistGenres.css @@ -0,0 +1,3 @@ +.genres { + margin-right: 15px; +} diff --git a/frontend/src/Artist/Details/ArtistGenres.css.d.ts b/frontend/src/Artist/Details/ArtistGenres.css.d.ts new file mode 100644 index 000000000..83399e63b --- /dev/null +++ b/frontend/src/Artist/Details/ArtistGenres.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'genres': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Details/ArtistGenres.js b/frontend/src/Artist/Details/ArtistGenres.js new file mode 100644 index 000000000..15f3505d8 --- /dev/null +++ b/frontend/src/Artist/Details/ArtistGenres.js @@ -0,0 +1,53 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import Label from 'Components/Label'; +import Tooltip from 'Components/Tooltip/Tooltip'; +import { kinds, sizes, tooltipPositions } from 'Helpers/Props'; +import styles from './ArtistGenres.css'; + +function ArtistGenres({ genres }) { + const [firstGenre, ...otherGenres] = genres; + + if (otherGenres.length) { + return ( + + {firstGenre} + + } + tooltip={ +
+ { + otherGenres.map((tag) => { + return ( + + ); + }) + } +
+ } + kind={kinds.INVERSE} + position={tooltipPositions.TOP} + /> + ); + } + + return ( + + {firstGenre} + + ); +} + +ArtistGenres.propTypes = { + genres: PropTypes.arrayOf(PropTypes.string).isRequired +}; + +export default ArtistGenres; diff --git a/frontend/src/Artist/Details/ArtistTags.js b/frontend/src/Artist/Details/ArtistTags.js index 7ea841a36..b5f8a6e89 100644 --- a/frontend/src/Artist/Details/ArtistTags.js +++ b/frontend/src/Artist/Details/ArtistTags.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { kinds, sizes } from 'Helpers/Props'; import Label from 'Components/Label'; +import { kinds, sizes } from 'Helpers/Props'; function ArtistTags({ tags }) { return ( diff --git a/frontend/src/Artist/Details/ArtistTagsConnector.js b/frontend/src/Artist/Details/ArtistTagsConnector.js index 1ecde26cd..1d24a5755 100644 --- a/frontend/src/Artist/Details/ArtistTagsConnector.js +++ b/frontend/src/Artist/Details/ArtistTagsConnector.js @@ -1,8 +1,8 @@ -import _ from 'lodash'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; import createTagsSelector from 'Store/Selectors/createTagsSelector'; +import sortByProp from 'Utilities/Array/sortByProp'; import ArtistTags from './ArtistTags'; function createMapStateToProps() { @@ -10,15 +10,11 @@ function createMapStateToProps() { createArtistSelector(), createTagsSelector(), (artist, tagList) => { - const tags = _.reduce(artist.tags, (acc, tag) => { - const matchingTag = _.find(tagList, { id: tag }); - - if (matchingTag) { - acc.push(matchingTag.label); - } - - return acc; - }, []); + const tags = artist.tags + .map((tagId) => tagList.find((tag) => tag.id === tagId)) + .filter((tag) => !!tag) + .sort(sortByProp('label')) + .map((tag) => tag.label); return { tags diff --git a/frontend/src/Artist/Edit/EditArtistModal.js b/frontend/src/Artist/Edit/EditArtistModal.js index 6e99a2f53..f221e728c 100644 --- a/frontend/src/Artist/Edit/EditArtistModal.js +++ b/frontend/src/Artist/Edit/EditArtistModal.js @@ -18,6 +18,7 @@ function EditArtistModal({ isOpen, onModalClose, ...otherProps }) { } EditArtistModal.propTypes = { + ...EditArtistModalContentConnector.propTypes, isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; diff --git a/frontend/src/Artist/Edit/EditArtistModalConnector.js b/frontend/src/Artist/Edit/EditArtistModalConnector.js index 9e62a4780..9c4e6325f 100644 --- a/frontend/src/Artist/Edit/EditArtistModalConnector.js +++ b/frontend/src/Artist/Edit/EditArtistModalConnector.js @@ -16,7 +16,7 @@ class EditArtistModalConnector extends Component { onModalClose = () => { this.props.clearPendingChanges({ section: 'artist' }); this.props.onModalClose(); - } + }; // // Render @@ -32,6 +32,7 @@ class EditArtistModalConnector extends Component { } EditArtistModalConnector.propTypes = { + ...EditArtistModal.propTypes, onModalClose: PropTypes.func.isRequired, clearPendingChanges: PropTypes.func.isRequired }; diff --git a/frontend/src/Artist/Edit/EditArtistModalContent.css b/frontend/src/Artist/Edit/EditArtistModalContent.css index a2b6014df..fd7ddf093 100644 --- a/frontend/src/Artist/Edit/EditArtistModalContent.css +++ b/frontend/src/Artist/Edit/EditArtistModalContent.css @@ -3,3 +3,7 @@ margin-right: auto; } + +.labelIcon { + margin-left: 8px; +} diff --git a/frontend/src/Artist/Edit/EditArtistModalContent.css.d.ts b/frontend/src/Artist/Edit/EditArtistModalContent.css.d.ts new file mode 100644 index 000000000..238343ae5 --- /dev/null +++ b/frontend/src/Artist/Edit/EditArtistModalContent.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'deleteButton': string; + 'labelIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Edit/EditArtistModalContent.js b/frontend/src/Artist/Edit/EditArtistModalContent.js index 73dd652e8..bca6e3ea6 100644 --- a/frontend/src/Artist/Edit/EditArtistModalContent.js +++ b/frontend/src/Artist/Edit/EditArtistModalContent.js @@ -1,17 +1,22 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { inputTypes, kinds } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import SpinnerButton from 'Components/Link/SpinnerButton'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; +import ArtistMetadataProfilePopoverContent from 'AddArtist/ArtistMetadataProfilePopoverContent'; +import ArtistMonitorNewItemsOptionsPopoverContent from 'AddArtist/ArtistMonitorNewItemsOptionsPopoverContent'; +import MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal'; import Form from 'Components/Form/Form'; import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; import FormInputGroup from 'Components/Form/FormInputGroup'; -import MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal'; +import FormLabel from 'Components/Form/FormLabel'; +import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; +import SpinnerButton from 'Components/Link/SpinnerButton'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import Popover from 'Components/Tooltip/Popover'; +import { icons, inputTypes, kinds, sizes, tooltipPositions } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './EditArtistModalContent.css'; class EditArtistModalContent extends Component { @@ -30,6 +35,10 @@ class EditArtistModalContent extends Component { // // Listeners + onCancelPress = () => { + this.setState({ isConfirmMoveModalOpen: false }); + }; + onSavePress = () => { const { isPathChanging, @@ -43,13 +52,13 @@ class EditArtistModalContent extends Component { onSavePress(false); } - } + }; onMoveArtistPress = () => { this.setState({ isConfirmMoveModalOpen: false }); this.props.onSavePress(true); - } + }; // // Render @@ -69,7 +78,7 @@ class EditArtistModalContent extends Component { const { monitored, - albumFolder, + monitorNewItems, qualityProfileId, metadataProfileId, path, @@ -84,32 +93,50 @@ class EditArtistModalContent extends Component { - - Monitored + + + {translate('Monitored')} + - - Use Album Folder + + + {translate('MonitorNewItems')} + + + } + title={translate('MonitorNewItems')} + body={} + position={tooltipPositions.RIGHT} + /> + - - Quality Profile + + + {translate('QualityProfile')} + { - showMetadataProfile && - - Metadata Profile + showMetadataProfile ? + + + {translate('MetadataProfile')} + + + } + title={translate('MetadataProfile')} + body={} + position={tooltipPositions.RIGHT} + /> + + - + : + null } - - Path + + + {translate('Path')} + - - Tags + + + {translate('Tags')} + - Delete + {translate('Delete')} - Save + {translate('Save')} @@ -184,6 +232,7 @@ class EditArtistModalContent extends Component { originalPath={originalPath} destinationPath={path.value} isOpen={this.state.isConfirmMoveModalOpen} + onModalClose={this.onCancelPress} onSavePress={this.onSavePress} onMoveArtistPress={this.onMoveArtistPress} /> diff --git a/frontend/src/Artist/Edit/EditArtistModalContentConnector.js b/frontend/src/Artist/Edit/EditArtistModalContentConnector.js index 351bc7d34..bd9592d42 100644 --- a/frontend/src/Artist/Edit/EditArtistModalContentConnector.js +++ b/frontend/src/Artist/Edit/EditArtistModalContentConnector.js @@ -3,9 +3,9 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import selectSettings from 'Store/Selectors/selectSettings'; +import { saveArtist, setArtistValue } from 'Store/Actions/artistActions'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; -import { setArtistValue, saveArtist } from 'Store/Actions/artistActions'; +import selectSettings from 'Store/Selectors/selectSettings'; import EditArtistModalContent from './EditArtistModalContent'; function createIsPathChangingSelector() { @@ -39,7 +39,7 @@ function createMapStateToProps() { const artistSettings = _.pick(artist, [ 'monitored', - 'albumFolder', + 'monitorNewItems', 'qualityProfileId', 'metadataProfileId', 'path', @@ -83,14 +83,14 @@ class EditArtistModalContentConnector extends Component { onInputChange = ({ name, value }) => { this.props.dispatchSetArtistValue({ name, value }); - } + }; onSavePress = (moveFiles) => { this.props.dispatchSaveArtist({ id: this.props.artistId, moveFiles }); - } + }; // // Render diff --git a/frontend/src/Artist/Editor/ArtistEditor.js b/frontend/src/Artist/Editor/ArtistEditor.js deleted file mode 100644 index d4f6b282c..000000000 --- a/frontend/src/Artist/Editor/ArtistEditor.js +++ /dev/null @@ -1,309 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import getErrorMessage from 'Utilities/Object/getErrorMessage'; -import getSelectedIds from 'Utilities/Table/getSelectedIds'; -import selectAll from 'Utilities/Table/selectAll'; -import toggleSelected from 'Utilities/Table/toggleSelected'; -import { align, sortDirections } from 'Helpers/Props'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; -import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; -import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; -import FilterMenu from 'Components/Menu/FilterMenu'; -import Table from 'Components/Table/Table'; -import TableBody from 'Components/Table/TableBody'; -import NoArtist from 'Artist/NoArtist'; -import OrganizeArtistModal from './Organize/OrganizeArtistModal'; -import RetagArtistModal from './AudioTags/RetagArtistModal'; -import ArtistEditorRowConnector from './ArtistEditorRowConnector'; -import ArtistEditorFooter from './ArtistEditorFooter'; -import ArtistEditorFilterModalConnector from './ArtistEditorFilterModalConnector'; - -function getColumns(showMetadataProfile) { - return [ - { - name: 'status', - isSortable: true, - isVisible: true - }, - { - name: 'sortName', - label: 'Name', - isSortable: true, - isVisible: true - }, - { - name: 'qualityProfileId', - label: 'Quality Profile', - isSortable: true, - isVisible: true - }, - { - name: 'metadataProfileId', - label: 'Metadata Profile', - isSortable: true, - isVisible: showMetadataProfile - }, - { - name: 'albumFolder', - label: 'Album Folder', - isSortable: true, - isVisible: true - }, - { - name: 'path', - label: 'Path', - isSortable: true, - isVisible: true - }, - { - name: 'tags', - label: 'Tags', - isSortable: false, - isVisible: true - } - ]; -} - -class ArtistEditor extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - allSelected: false, - allUnselected: false, - lastToggled: null, - selectedState: {}, - isOrganizingArtistModalOpen: false, - isRetaggingArtistModalOpen: false, - columns: getColumns(props.showMetadataProfile) - }; - } - - componentDidUpdate(prevProps) { - const { - isDeleting, - deleteError - } = this.props; - - const hasFinishedDeleting = prevProps.isDeleting && - !isDeleting && - !deleteError; - - if (hasFinishedDeleting) { - this.onSelectAllChange({ value: false }); - } - } - - // - // Control - - getSelectedIds = () => { - return getSelectedIds(this.state.selectedState); - } - - // - // Listeners - - onSelectAllChange = ({ value }) => { - this.setState(selectAll(this.state.selectedState, value)); - } - - onSelectedChange = ({ id, value, shiftKey = false }) => { - this.setState((state) => { - return toggleSelected(state, this.props.items, id, value, shiftKey); - }); - } - - onSaveSelected = (changes) => { - this.props.onSaveSelected({ - artistIds: this.getSelectedIds(), - ...changes - }); - } - - onOrganizeArtistPress = () => { - this.setState({ isOrganizingArtistModalOpen: true }); - } - - onOrganizeArtistModalClose = (organized) => { - this.setState({ isOrganizingArtistModalOpen: false }); - - if (organized === true) { - this.onSelectAllChange({ value: false }); - } - } - - onRetagArtistPress = () => { - this.setState({ isRetaggingArtistModalOpen: true }); - } - - onRetagArtistModalClose = (organized) => { - this.setState({ isRetaggingArtistModalOpen: false }); - - if (organized === true) { - this.onSelectAllChange({ value: false }); - } - } - - // - // Render - - render() { - const { - isFetching, - isPopulated, - error, - totalItems, - items, - selectedFilterKey, - filters, - customFilters, - sortKey, - sortDirection, - isSaving, - saveError, - isDeleting, - deleteError, - isOrganizingArtist, - isRetaggingArtist, - showMetadataProfile, - onSortPress, - onFilterSelect - } = this.props; - - const { - allSelected, - allUnselected, - selectedState, - columns - } = this.state; - - const selectedArtistIds = this.getSelectedIds(); - - return ( - - - - - - - - - - { - isFetching && !isPopulated && - - } - - { - !isFetching && !!error && -
{getErrorMessage(error, 'Failed to load artist from API')}
- } - - { - !error && isPopulated && !!items.length && -
- - - { - items.map((item) => { - return ( - - ); - }) - } - -
-
- } - - { - !error && isPopulated && !items.length && - - } -
- - - - - - - -
- ); - } -} - -ArtistEditor.propTypes = { - isFetching: PropTypes.bool.isRequired, - isPopulated: PropTypes.bool.isRequired, - error: PropTypes.object, - totalItems: PropTypes.number.isRequired, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, - isSaving: PropTypes.bool.isRequired, - saveError: PropTypes.object, - isDeleting: PropTypes.bool.isRequired, - deleteError: PropTypes.object, - isOrganizingArtist: PropTypes.bool.isRequired, - isRetaggingArtist: PropTypes.bool.isRequired, - showMetadataProfile: PropTypes.bool.isRequired, - onSortPress: PropTypes.func.isRequired, - onFilterSelect: PropTypes.func.isRequired, - onSaveSelected: PropTypes.func.isRequired -}; - -export default ArtistEditor; diff --git a/frontend/src/Artist/Editor/ArtistEditorConnector.js b/frontend/src/Artist/Editor/ArtistEditorConnector.js deleted file mode 100644 index c0188ee6d..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorConnector.js +++ /dev/null @@ -1,92 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector'; -import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; -import { setArtistEditorSort, setArtistEditorFilter, saveArtistEditor } from 'Store/Actions/artistEditorActions'; -import { fetchRootFolders } from 'Store/Actions/rootFolderActions'; -import { executeCommand } from 'Store/Actions/commandActions'; -import * as commandNames from 'Commands/commandNames'; -import ArtistEditor from './ArtistEditor'; - -function createMapStateToProps() { - return createSelector( - (state) => state.settings.metadataProfiles, - createClientSideCollectionSelector('artist', 'artistEditor'), - createCommandExecutingSelector(commandNames.RENAME_ARTIST), - createCommandExecutingSelector(commandNames.RETAG_ARTIST), - (metadataProfiles, artist, isOrganizingArtist, isRetaggingArtist) => { - return { - isOrganizingArtist, - isRetaggingArtist, - showMetadataProfile: metadataProfiles.items.length > 1, - ...artist - }; - } - ); -} - -const mapDispatchToProps = { - dispatchSetArtistEditorSort: setArtistEditorSort, - dispatchSetArtistEditorFilter: setArtistEditorFilter, - dispatchSaveArtistEditor: saveArtistEditor, - dispatchFetchRootFolders: fetchRootFolders, - dispatchExecuteCommand: executeCommand -}; - -class ArtistEditorConnector extends Component { - - // - // Lifecycle - - componentDidMount() { - this.props.dispatchFetchRootFolders(); - } - - // - // Listeners - - onSortPress = (sortKey) => { - this.props.dispatchSetArtistEditorSort({ sortKey }); - } - - onFilterSelect = (selectedFilterKey) => { - this.props.dispatchSetArtistEditorFilter({ selectedFilterKey }); - } - - onSaveSelected = (payload) => { - this.props.dispatchSaveArtistEditor(payload); - } - - onMoveSelected = (payload) => { - this.props.dispatchExecuteCommand({ - name: commandNames.MOVE_ARTIST, - ...payload - }); - } - - // - // Render - - render() { - return ( - - ); - } -} - -ArtistEditorConnector.propTypes = { - dispatchSetArtistEditorSort: PropTypes.func.isRequired, - dispatchSetArtistEditorFilter: PropTypes.func.isRequired, - dispatchSaveArtistEditor: PropTypes.func.isRequired, - dispatchFetchRootFolders: PropTypes.func.isRequired, - dispatchExecuteCommand: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(ArtistEditorConnector); diff --git a/frontend/src/Artist/Editor/ArtistEditorFilterModalConnector.js b/frontend/src/Artist/Editor/ArtistEditorFilterModalConnector.js deleted file mode 100644 index 4aff2df06..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorFilterModalConnector.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setArtistEditorFilter } from 'Store/Actions/artistEditorActions'; -import FilterModal from 'Components/Filter/FilterModal'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artist.items, - (state) => state.artistEditor.filterBuilderProps, - (sectionItems, filterBuilderProps) => { - return { - sectionItems, - filterBuilderProps, - customFilterType: 'artistEditor' - }; - } - ); -} - -const mapDispatchToProps = { - dispatchSetFilter: setArtistEditorFilter -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(FilterModal); diff --git a/frontend/src/Artist/Editor/ArtistEditorFooter.css b/frontend/src/Artist/Editor/ArtistEditorFooter.css deleted file mode 100644 index 3785f88d3..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorFooter.css +++ /dev/null @@ -1,70 +0,0 @@ -.inputContainer { - margin-right: 20px; - min-width: 150px; -} - -.buttonContainer { - display: flex; - justify-content: flex-end; - flex-grow: 1; -} - -.buttonContainerContent { - flex-grow: 0; -} - -.buttons { - display: flex; - justify-content: flex-end; - flex-grow: 1; -} - -.organizeSelectedButton, -.tagsButton { - composes: button from '~Components/Link/SpinnerButton.css'; - - margin-right: 10px; - height: 35px; -} - -.deleteSelectedButton { - composes: button from '~Components/Link/SpinnerButton.css'; - - margin-left: 50px; - height: 35px; -} - -@media only screen and (max-width: $breakpointExtraLarge) { - .deleteSelectedButton { - margin-left: 0; - } -} - -@media only screen and (max-width: $breakpointLarge) { - .buttonContainer { - justify-content: flex-start; - margin-top: 10px; - } -} - -@media only screen and (max-width: $breakpointSmall) { - .inputContainer { - margin-right: 0; - } - - .buttonContainer { - justify-content: flex-start; - } - - .buttonContainerContent { - flex-grow: 1; - } - - .buttons { - justify-content: space-between; - } - - .selectedArtistLabel { - text-align: left; - } -} diff --git a/frontend/src/Artist/Editor/ArtistEditorFooter.js b/frontend/src/Artist/Editor/ArtistEditorFooter.js deleted file mode 100644 index ccf044c53..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorFooter.js +++ /dev/null @@ -1,349 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { kinds } from 'Helpers/Props'; -import SelectInput from 'Components/Form/SelectInput'; -import MetadataProfileSelectInputConnector from 'Components/Form/MetadataProfileSelectInputConnector'; -import QualityProfileSelectInputConnector from 'Components/Form/QualityProfileSelectInputConnector'; -import RootFolderSelectInputConnector from 'Components/Form/RootFolderSelectInputConnector'; -import SpinnerButton from 'Components/Link/SpinnerButton'; -import PageContentFooter from 'Components/Page/PageContentFooter'; -import MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal'; -import TagsModal from './Tags/TagsModal'; -import DeleteArtistModal from './Delete/DeleteArtistModal'; -import ArtistEditorFooterLabel from './ArtistEditorFooterLabel'; -import styles from './ArtistEditorFooter.css'; - -const NO_CHANGE = 'noChange'; - -class ArtistEditorFooter extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - monitored: NO_CHANGE, - qualityProfileId: NO_CHANGE, - metadataProfileId: NO_CHANGE, - albumFolder: NO_CHANGE, - rootFolderPath: NO_CHANGE, - savingTags: false, - isDeleteArtistModalOpen: false, - isTagsModalOpen: false, - isConfirmMoveModalOpen: false, - destinationRootFolder: null - }; - } - - componentDidUpdate(prevProps) { - const { - isSaving, - saveError - } = this.props; - - if (prevProps.isSaving && !isSaving && !saveError) { - this.setState({ - monitored: NO_CHANGE, - qualityProfileId: NO_CHANGE, - metadataProfileId: NO_CHANGE, - albumFolder: NO_CHANGE, - rootFolderPath: NO_CHANGE, - savingTags: false - }); - } - } - - // - // Listeners - - onInputChange = ({ name, value }) => { - this.setState({ [name]: value }); - - if (value === NO_CHANGE) { - return; - } - - switch (name) { - case 'rootFolderPath': - this.setState({ - isConfirmMoveModalOpen: true, - destinationRootFolder: value - }); - break; - case 'monitored': - this.props.onSaveSelected({ [name]: value === 'monitored' }); - break; - case 'albumFolder': - this.props.onSaveSelected({ [name]: value === 'yes' }); - break; - default: - this.props.onSaveSelected({ [name]: value }); - } - } - - onApplyTagsPress = (tags, applyTags) => { - this.setState({ - savingTags: true, - isTagsModalOpen: false - }); - - this.props.onSaveSelected({ - tags, - applyTags - }); - } - - onDeleteSelectedPress = () => { - this.setState({ isDeleteArtistModalOpen: true }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - onTagsPress = () => { - this.setState({ isTagsModalOpen: true }); - } - - onTagsModalClose = () => { - this.setState({ isTagsModalOpen: false }); - } - - onSaveRootFolderPress = () => { - this.setState({ - isConfirmMoveModalOpen: false, - destinationRootFolder: null - }); - - this.props.onSaveSelected({ rootFolderPath: this.state.destinationRootFolder }); - } - - onMoveArtistPress = () => { - this.setState({ - isConfirmMoveModalOpen: false, - destinationRootFolder: null - }); - - this.props.onSaveSelected({ - rootFolderPath: this.state.destinationRootFolder, - moveFiles: true - }); - } - - // - // Render - - render() { - const { - artistIds, - selectedCount, - isSaving, - isDeleting, - isOrganizingArtist, - isRetaggingArtist, - showMetadataProfile, - onOrganizeArtistPress, - onRetagArtistPress - } = this.props; - - const { - monitored, - qualityProfileId, - metadataProfileId, - albumFolder, - rootFolderPath, - savingTags, - isTagsModalOpen, - isDeleteArtistModalOpen, - isConfirmMoveModalOpen, - destinationRootFolder - } = this.state; - - const monitoredOptions = [ - { key: NO_CHANGE, value: 'No Change', disabled: true }, - { key: 'monitored', value: 'Monitored' }, - { key: 'unmonitored', value: 'Unmonitored' } - ]; - - const albumFolderOptions = [ - { key: NO_CHANGE, value: 'No Change', disabled: true }, - { key: 'yes', value: 'Yes' }, - { key: 'no', value: 'No' } - ]; - - return ( - -
- - - -
- -
- - - -
- - { - showMetadataProfile && -
- - - -
- } - -
- - - -
- -
- - - -
- -
-
- - -
-
- - Rename Files - - - - Write Metadata Tags - - - - Set Lidarr Tags - -
- - - Delete - -
-
-
- - - - - - - -
- ); - } -} - -ArtistEditorFooter.propTypes = { - artistIds: PropTypes.arrayOf(PropTypes.number).isRequired, - selectedCount: PropTypes.number.isRequired, - isSaving: PropTypes.bool.isRequired, - saveError: PropTypes.object, - isDeleting: PropTypes.bool.isRequired, - deleteError: PropTypes.object, - isOrganizingArtist: PropTypes.bool.isRequired, - isRetaggingArtist: PropTypes.bool.isRequired, - showMetadataProfile: PropTypes.bool.isRequired, - onSaveSelected: PropTypes.func.isRequired, - onOrganizeArtistPress: PropTypes.func.isRequired, - onRetagArtistPress: PropTypes.func.isRequired -}; - -export default ArtistEditorFooter; diff --git a/frontend/src/Artist/Editor/ArtistEditorFooterLabel.css b/frontend/src/Artist/Editor/ArtistEditorFooterLabel.css deleted file mode 100644 index 9b4b40be6..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorFooterLabel.css +++ /dev/null @@ -1,8 +0,0 @@ -.label { - margin-bottom: 3px; - font-weight: bold; -} - -.savingIcon { - margin-left: 8px; -} diff --git a/frontend/src/Artist/Editor/ArtistEditorFooterLabel.js b/frontend/src/Artist/Editor/ArtistEditorFooterLabel.js deleted file mode 100644 index 1c6be745d..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorFooterLabel.js +++ /dev/null @@ -1,40 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { icons } from 'Helpers/Props'; -import SpinnerIcon from 'Components/SpinnerIcon'; -import styles from './ArtistEditorFooterLabel.css'; - -function ArtistEditorFooterLabel(props) { - const { - className, - label, - isSaving - } = props; - - return ( -
- {label} - - { - isSaving && - - } -
- ); -} - -ArtistEditorFooterLabel.propTypes = { - className: PropTypes.string.isRequired, - label: PropTypes.string.isRequired, - isSaving: PropTypes.bool.isRequired -}; - -ArtistEditorFooterLabel.defaultProps = { - className: styles.label -}; - -export default ArtistEditorFooterLabel; diff --git a/frontend/src/Artist/Editor/ArtistEditorRow.css b/frontend/src/Artist/Editor/ArtistEditorRow.css deleted file mode 100644 index aeb9776ca..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorRow.css +++ /dev/null @@ -1,5 +0,0 @@ -.albumFolder { - composes: cell from '~Components/Table/Cells/TableRowCell.css'; - - width: 150px; -} diff --git a/frontend/src/Artist/Editor/ArtistEditorRow.js b/frontend/src/Artist/Editor/ArtistEditorRow.js deleted file mode 100644 index cfead73be..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorRow.js +++ /dev/null @@ -1,120 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import TagListConnector from 'Components/TagListConnector'; -import CheckInput from 'Components/Form/CheckInput'; -import TableRow from 'Components/Table/TableRow'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; -import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; -import ArtistNameLink from 'Artist/ArtistNameLink'; -import ArtistStatusCell from 'Artist/Index/Table/ArtistStatusCell'; -import styles from './ArtistEditorRow.css'; - -class ArtistEditorRow extends Component { - - // - // Listeners - - onAlbumFolderChange = () => { - // Mock handler to satisfy `onChange` being required for `CheckInput`. - // - } - - // - // Render - - render() { - const { - id, - status, - foreignArtistId, - artistName, - artistType, - monitored, - metadataProfile, - qualityProfile, - albumFolder, - path, - tags, - columns, - isSelected, - onSelectedChange - } = this.props; - - return ( - - - - - - - - - - - {qualityProfile.name} - - - { - _.find(columns, { name: 'metadataProfileId' }).isVisible && - - {metadataProfile.name} - - } - - - - - - - {path} - - - - - - - ); - } -} - -ArtistEditorRow.propTypes = { - id: PropTypes.number.isRequired, - status: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - artistName: PropTypes.string.isRequired, - artistType: PropTypes.string, - monitored: PropTypes.bool.isRequired, - metadataProfile: PropTypes.object.isRequired, - qualityProfile: PropTypes.object.isRequired, - albumFolder: PropTypes.bool.isRequired, - path: PropTypes.string.isRequired, - tags: PropTypes.arrayOf(PropTypes.number).isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - isSelected: PropTypes.bool, - onSelectedChange: PropTypes.func.isRequired -}; - -ArtistEditorRow.defaultProps = { - tags: [] -}; - -export default ArtistEditorRow; diff --git a/frontend/src/Artist/Editor/ArtistEditorRowConnector.js b/frontend/src/Artist/Editor/ArtistEditorRowConnector.js deleted file mode 100644 index 32694a6b9..000000000 --- a/frontend/src/Artist/Editor/ArtistEditorRowConnector.js +++ /dev/null @@ -1,34 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createMetadataProfileSelector from 'Store/Selectors/createMetadataProfileSelector'; -import createQualityProfileSelector from 'Store/Selectors/createQualityProfileSelector'; -import ArtistEditorRow from './ArtistEditorRow'; - -function createMapStateToProps() { - return createSelector( - createMetadataProfileSelector(), - createQualityProfileSelector(), - (metadataProfile, qualityProfile) => { - return { - metadataProfile, - qualityProfile - }; - } - ); -} - -function ArtistEditorRowConnector(props) { - return ( - - ); -} - -ArtistEditorRowConnector.propTypes = { - qualityProfileId: PropTypes.number.isRequired -}; - -export default connect(createMapStateToProps)(ArtistEditorRowConnector); diff --git a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.js b/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.js deleted file mode 100644 index 015112556..000000000 --- a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.js +++ /dev/null @@ -1,73 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { icons, kinds } from 'Helpers/Props'; -import Alert from 'Components/Alert'; -import Button from 'Components/Link/Button'; -import Icon from 'Components/Icon'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import styles from './RetagArtistModalContent.css'; - -function RetagArtistModalContent(props) { - const { - artistNames, - onModalClose, - onRetagArtistPress - } = props; - - return ( - - - Retag Selected Artist - - - - - Tip: To preview the tags that will be written... select "Cancel" then click any artist name and use the - - - -
- Are you sure you want to re-tag all files in the {artistNames.length} selected artist? -
-
    - { - artistNames.map((artistName) => { - return ( -
  • - {artistName} -
  • - ); - }) - } -
-
- - - - - - -
- ); -} - -RetagArtistModalContent.propTypes = { - artistNames: PropTypes.arrayOf(PropTypes.string).isRequired, - onModalClose: PropTypes.func.isRequired, - onRetagArtistPress: PropTypes.func.isRequired -}; - -export default RetagArtistModalContent; diff --git a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContentConnector.js b/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContentConnector.js deleted file mode 100644 index 1c104db00..000000000 --- a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContentConnector.js +++ /dev/null @@ -1,67 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; -import { executeCommand } from 'Store/Actions/commandActions'; -import * as commandNames from 'Commands/commandNames'; -import RetagArtistModalContent from './RetagArtistModalContent'; - -function createMapStateToProps() { - return createSelector( - (state, { artistIds }) => artistIds, - createAllArtistSelector(), - (artistIds, allArtists) => { - const artist = _.intersectionWith(allArtists, artistIds, (s, id) => { - return s.id === id; - }); - - const sortedArtist = _.orderBy(artist, 'sortName'); - const artistNames = _.map(sortedArtist, 'artistName'); - - return { - artistNames - }; - } - ); -} - -const mapDispatchToProps = { - executeCommand -}; - -class RetagArtistModalContentConnector extends Component { - - // - // Listeners - - onRetagArtistPress = () => { - this.props.executeCommand({ - name: commandNames.RETAG_ARTIST, - artistIds: this.props.artistIds - }); - - this.props.onModalClose(true); - } - - // - // Render - - render(props) { - return ( - - ); - } -} - -RetagArtistModalContentConnector.propTypes = { - artistIds: PropTypes.arrayOf(PropTypes.number).isRequired, - onModalClose: PropTypes.func.isRequired, - executeCommand: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(RetagArtistModalContentConnector); diff --git a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.js b/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.js deleted file mode 100644 index 87088b472..000000000 --- a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.js +++ /dev/null @@ -1,123 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { inputTypes, kinds } from 'Helpers/Props'; -import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import Button from 'Components/Link/Button'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import styles from './DeleteArtistModalContent.css'; - -class DeleteArtistModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - deleteFiles: false - }; - } - - // - // Listeners - - onDeleteFilesChange = ({ value }) => { - this.setState({ deleteFiles: value }); - } - - onDeleteArtistConfirmed = () => { - const deleteFiles = this.state.deleteFiles; - - this.setState({ deleteFiles: false }); - this.props.onDeleteSelectedPress(deleteFiles); - } - - // - // Render - - render() { - const { - artist, - onModalClose - } = this.props; - const deleteFiles = this.state.deleteFiles; - - return ( - - - Delete Selected Artist - - - -
- - {`Delete Artist Folder${artist.length > 1 ? 's' : ''}`} - - 1 ? 's' : ''} and all contents`} - kind={kinds.DANGER} - onChange={this.onDeleteFilesChange} - /> - -
- -
- {`Are you sure you want to delete ${artist.length} selected artist${artist.length > 1 ? 's' : ''}${deleteFiles ? ' and all contents' : ''}?`} -
- -
    - { - artist.map((s) => { - return ( -
  • - {s.artistName} - - { - deleteFiles && - - - - - {s.path} - - - } -
  • - ); - }) - } -
-
- - - - - - -
- ); - } -} - -DeleteArtistModalContent.propTypes = { - artist: PropTypes.arrayOf(PropTypes.object).isRequired, - onModalClose: PropTypes.func.isRequired, - onDeleteSelectedPress: PropTypes.func.isRequired -}; - -export default DeleteArtistModalContent; diff --git a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContentConnector.js b/frontend/src/Artist/Editor/Delete/DeleteArtistModalContentConnector.js deleted file mode 100644 index 8c61976e8..000000000 --- a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContentConnector.js +++ /dev/null @@ -1,45 +0,0 @@ -import _ from 'lodash'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; -import { bulkDeleteArtist } from 'Store/Actions/artistEditorActions'; -import DeleteArtistModalContent from './DeleteArtistModalContent'; - -function createMapStateToProps() { - return createSelector( - (state, { artistIds }) => artistIds, - createAllArtistSelector(), - (artistIds, allArtists) => { - const selectedArtist = _.intersectionWith(allArtists, artistIds, (s, id) => { - return s.id === id; - }); - - const sortedArtist = _.orderBy(selectedArtist, 'sortName'); - const artist = _.map(sortedArtist, (s) => { - return { - artistName: s.artistName, - path: s.path - }; - }); - - return { - artist - }; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onDeleteSelectedPress(deleteFiles) { - dispatch(bulkDeleteArtist({ - artistIds: props.artistIds, - deleteFiles - })); - - props.onModalClose(); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(DeleteArtistModalContent); diff --git a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.js b/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.js deleted file mode 100644 index 5f90eca90..000000000 --- a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.js +++ /dev/null @@ -1,74 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { icons, kinds } from 'Helpers/Props'; -import Alert from 'Components/Alert'; -import Button from 'Components/Link/Button'; -import Icon from 'Components/Icon'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import styles from './OrganizeArtistModalContent.css'; - -function OrganizeArtistModalContent(props) { - const { - artistNames, - onModalClose, - onOrganizeArtistPress - } = props; - - return ( - - - Organize Selected Artist - - - - - Tip: To preview a rename... select "Cancel" then click any artist name and use the - - - -
- Are you sure you want to organize all files in the {artistNames.length} selected artist? -
- -
    - { - artistNames.map((artistName) => { - return ( -
  • - {artistName} -
  • - ); - }) - } -
-
- - - - - - -
- ); -} - -OrganizeArtistModalContent.propTypes = { - artistNames: PropTypes.arrayOf(PropTypes.string).isRequired, - onModalClose: PropTypes.func.isRequired, - onOrganizeArtistPress: PropTypes.func.isRequired -}; - -export default OrganizeArtistModalContent; diff --git a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContentConnector.js b/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContentConnector.js deleted file mode 100644 index 6be1eb961..000000000 --- a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContentConnector.js +++ /dev/null @@ -1,67 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; -import { executeCommand } from 'Store/Actions/commandActions'; -import * as commandNames from 'Commands/commandNames'; -import OrganizeArtistModalContent from './OrganizeArtistModalContent'; - -function createMapStateToProps() { - return createSelector( - (state, { artistIds }) => artistIds, - createAllArtistSelector(), - (artistIds, allArtists) => { - const artist = _.intersectionWith(allArtists, artistIds, (s, id) => { - return s.id === id; - }); - - const sortedArtist = _.orderBy(artist, 'sortName'); - const artistNames = _.map(sortedArtist, 'artistName'); - - return { - artistNames - }; - } - ); -} - -const mapDispatchToProps = { - executeCommand -}; - -class OrganizeArtistModalContentConnector extends Component { - - // - // Listeners - - onOrganizeArtistPress = () => { - this.props.executeCommand({ - name: commandNames.RENAME_ARTIST, - artistIds: this.props.artistIds - }); - - this.props.onModalClose(true); - } - - // - // Render - - render(props) { - return ( - - ); - } -} - -OrganizeArtistModalContentConnector.propTypes = { - artistIds: PropTypes.arrayOf(PropTypes.number).isRequired, - onModalClose: PropTypes.func.isRequired, - executeCommand: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(OrganizeArtistModalContentConnector); diff --git a/frontend/src/Artist/Editor/Tags/TagsModalContent.js b/frontend/src/Artist/Editor/Tags/TagsModalContent.js deleted file mode 100644 index b982fee0e..000000000 --- a/frontend/src/Artist/Editor/Tags/TagsModalContent.js +++ /dev/null @@ -1,187 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { inputTypes, kinds, sizes } from 'Helpers/Props'; -import Label from 'Components/Label'; -import Button from 'Components/Link/Button'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; -import Form from 'Components/Form/Form'; -import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import styles from './TagsModalContent.css'; - -class TagsModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - tags: [], - applyTags: 'add' - }; - } - - // - // Lifecycle - - onInputChange = ({ name, value }) => { - this.setState({ [name]: value }); - } - - onApplyTagsPress = () => { - const { - tags, - applyTags - } = this.state; - - this.props.onApplyTagsPress(tags, applyTags); - } - - // - // Render - - render() { - const { - artistTags, - tagList, - onModalClose - } = this.props; - - const { - tags, - applyTags - } = this.state; - - const applyTagsOptions = [ - { key: 'add', value: 'Add' }, - { key: 'remove', value: 'Remove' }, - { key: 'replace', value: 'Replace' } - ]; - - return ( - - - Tags - - - - - - Tags - - - - - - Apply Tags - - - - - - Result - -
- { - artistTags.map((t) => { - const tag = _.find(tagList, { id: t }); - - if (!tag) { - return null; - } - - const removeTag = (applyTags === 'remove' && tags.indexOf(t) > -1) || - (applyTags === 'replace' && tags.indexOf(t) === -1); - - return ( - - ); - }) - } - - { - (applyTags === 'add' || applyTags === 'replace') && - tags.map((t) => { - const tag = _.find(tagList, { id: t }); - - if (!tag) { - return null; - } - - if (artistTags.indexOf(t) > -1) { - return null; - } - - return ( - - ); - }) - } -
-
- -
- - - - - - -
- ); - } -} - -TagsModalContent.propTypes = { - artistTags: PropTypes.arrayOf(PropTypes.number).isRequired, - tagList: PropTypes.arrayOf(PropTypes.object).isRequired, - onModalClose: PropTypes.func.isRequired, - onApplyTagsPress: PropTypes.func.isRequired -}; - -export default TagsModalContent; diff --git a/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js b/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js deleted file mode 100644 index 6741e8b5c..000000000 --- a/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js +++ /dev/null @@ -1,36 +0,0 @@ -import _ from 'lodash'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; -import createTagsSelector from 'Store/Selectors/createTagsSelector'; -import TagsModalContent from './TagsModalContent'; - -function createMapStateToProps() { - return createSelector( - (state, { artistIds }) => artistIds, - createAllArtistSelector(), - createTagsSelector(), - (artistIds, allArtists, tagList) => { - const artist = _.intersectionWith(allArtists, artistIds, (s, id) => { - return s.id === id; - }); - - const artistTags = _.uniq(_.concat(..._.map(artist, 'tags'))); - - return { - artistTags, - tagList - }; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onAction() { - // Do something - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(TagsModalContent); diff --git a/frontend/src/Artist/History/ArtistHistoryModal.js b/frontend/src/Artist/History/ArtistHistoryModal.js index 7139d7633..a4362484c 100644 --- a/frontend/src/Artist/History/ArtistHistoryModal.js +++ b/frontend/src/Artist/History/ArtistHistoryModal.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; +import { sizes } from 'Helpers/Props'; import ArtistHistoryModalContentConnector from './ArtistHistoryModalContentConnector'; function ArtistHistoryModal(props) { @@ -13,6 +14,7 @@ function ArtistHistoryModal(props) { return ( translate('Album'), isVisible: true }, { name: 'sourceTitle', - label: 'Source Title', + label: () => translate('SourceTitle'), isVisible: true }, { name: 'quality', - label: 'Quality', + label: () => translate('Quality'), + isVisible: true + }, + { + name: 'customFormats', + label: () => translate('CustomFormats'), + isSortable: false, + isVisible: true + }, + { + name: 'customFormatScore', + label: React.createElement(Icon, { + name: icons.SCORE, + title: 'Custom format score' + }), + isSortable: true, isVisible: true }, { name: 'date', - label: 'Date', - isVisible: true - }, - { - name: 'details', - label: 'Details', + label: () => translate('Date'), isVisible: true }, { name: 'actions', - label: 'Actions', isVisible: true } ]; @@ -80,12 +93,16 @@ class ArtistHistoryModalContent extends Component { { !isFetching && !!error && -
Unable to load history.
+ + {translate('UnableToLoadHistory')} + } { isPopulated && !hasItems && !error && -
No history.
+ + {translate('NoHistory')} + } { diff --git a/frontend/src/Artist/History/ArtistHistoryModalContentConnector.js b/frontend/src/Artist/History/ArtistHistoryModalContentConnector.js index a989361f5..f5f93ed7d 100644 --- a/frontend/src/Artist/History/ArtistHistoryModalContentConnector.js +++ b/frontend/src/Artist/History/ArtistHistoryModalContentConnector.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { fetchArtistHistory, clearArtistHistory, artistHistoryMarkAsFailed } from 'Store/Actions/artistHistoryActions'; +import { artistHistoryMarkAsFailed, clearArtistHistory, fetchArtistHistory } from 'Store/Actions/artistHistoryActions'; import ArtistHistoryModalContent from './ArtistHistoryModalContent'; function createMapStateToProps() { @@ -55,7 +55,7 @@ class ArtistHistoryModalContentConnector extends Component { artistId, albumId }); - } + }; // // Render diff --git a/frontend/src/Artist/History/ArtistHistoryRow.css b/frontend/src/Artist/History/ArtistHistoryRow.css index deafecb81..33dba8df9 100644 --- a/frontend/src/Artist/History/ArtistHistoryRow.css +++ b/frontend/src/Artist/History/ArtistHistoryRow.css @@ -1,4 +1,9 @@ -.details, +.sourceTitle { + composes: cell from '~Components/Table/Cells/TableRowCell.css'; + + word-break: break-word; +} + .actions { composes: cell from '~Components/Table/Cells/TableRowCell.css'; diff --git a/frontend/src/Artist/History/ArtistHistoryRow.css.d.ts b/frontend/src/Artist/History/ArtistHistoryRow.css.d.ts new file mode 100644 index 000000000..b0b91a6b8 --- /dev/null +++ b/frontend/src/Artist/History/ArtistHistoryRow.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'sourceTitle': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/History/ArtistHistoryRow.js b/frontend/src/Artist/History/ArtistHistoryRow.js index e69f8395b..fe8326378 100644 --- a/frontend/src/Artist/History/ArtistHistoryRow.js +++ b/frontend/src/Artist/History/ArtistHistoryRow.js @@ -1,16 +1,19 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons, kinds, tooltipPositions } from 'Helpers/Props'; +import HistoryDetailsConnector from 'Activity/History/Details/HistoryDetailsConnector'; +import HistoryEventTypeCell from 'Activity/History/HistoryEventTypeCell'; +import AlbumFormats from 'Album/AlbumFormats'; +import TrackQuality from 'Album/TrackQuality'; import Icon from 'Components/Icon'; import IconButton from 'Components/Link/IconButton'; import ConfirmModal from 'Components/Modal/ConfirmModal'; import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; -import TableRow from 'Components/Table/TableRow'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import TableRow from 'Components/Table/TableRow'; import Popover from 'Components/Tooltip/Popover'; -import TrackQuality from 'Album/TrackQuality'; -import HistoryDetailsConnector from 'Activity/History/Details/HistoryDetailsConnector'; -import HistoryEventTypeCell from 'Activity/History/HistoryEventTypeCell'; +import { icons, kinds, tooltipPositions } from 'Helpers/Props'; +import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; +import translate from 'Utilities/String/translate'; import styles from './ArtistHistoryRow.css'; function getTitle(eventType) { @@ -54,16 +57,16 @@ class ArtistHistoryRow extends Component { onMarkAsFailedPress = () => { this.setState({ isMarkAsFailedModalOpen: true }); - } + }; onConfirmMarkAsFailed = () => { this.props.onMarkAsFailedPress(this.props.id); this.setState({ isMarkAsFailedModalOpen: false }); - } + }; onMarkAsFailedModalClose = () => { this.setState({ isMarkAsFailedModalOpen: false }); - } + }; // // Render @@ -74,8 +77,11 @@ class ArtistHistoryRow extends Component { sourceTitle, quality, qualityCutoffNotMet, + customFormats, + customFormatScore, date, data, + downloadId, album } = this.props; @@ -94,7 +100,7 @@ class ArtistHistoryRow extends Component { {album.title} - + {sourceTitle} @@ -105,11 +111,19 @@ class ArtistHistoryRow extends Component { /> + + + + + + {formatCustomFormatScore(customFormatScore, customFormats.length)} + + - + } position={tooltipPositions.LEFT} /> - - { eventType === 'grabbed' && } @@ -142,9 +156,9 @@ class ArtistHistoryRow extends Component { @@ -159,12 +173,19 @@ ArtistHistoryRow.propTypes = { sourceTitle: PropTypes.string.isRequired, quality: PropTypes.object.isRequired, qualityCutoffNotMet: PropTypes.bool.isRequired, + customFormats: PropTypes.arrayOf(PropTypes.object), + customFormatScore: PropTypes.number.isRequired, date: PropTypes.string.isRequired, data: PropTypes.object.isRequired, + downloadId: PropTypes.string, fullArtist: PropTypes.bool.isRequired, artist: PropTypes.object.isRequired, album: PropTypes.object.isRequired, onMarkAsFailedPress: PropTypes.func.isRequired }; +ArtistHistoryRow.defaultProps = { + customFormats: [] +}; + export default ArtistHistoryRow; diff --git a/frontend/src/Artist/History/ArtistHistoryRowConnector.js b/frontend/src/Artist/History/ArtistHistoryRowConnector.js index 2bcfc7cb6..65249aca6 100644 --- a/frontend/src/Artist/History/ArtistHistoryRowConnector.js +++ b/frontend/src/Artist/History/ArtistHistoryRowConnector.js @@ -1,8 +1,8 @@ import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { fetchHistory, markAsFailed } from 'Store/Actions/historyActions'; -import createArtistSelector from 'Store/Selectors/createArtistSelector'; import createAlbumSelector from 'Store/Selectors/createAlbumSelector'; +import createArtistSelector from 'Store/Selectors/createArtistSelector'; import ArtistHistoryRow from './ArtistHistoryRow'; function createMapStateToProps() { diff --git a/frontend/src/Artist/Index/ArtistIndex.css b/frontend/src/Artist/Index/ArtistIndex.css index 43b445c3c..908cb2d16 100644 --- a/frontend/src/Artist/Index/ArtistIndex.css +++ b/frontend/src/Artist/Index/ArtistIndex.css @@ -13,6 +13,7 @@ .contentBody { composes: contentBody from '~Components/Page/PageContentBody.css'; + position: relative; display: flex; flex-direction: column; } diff --git a/frontend/src/Artist/Index/ArtistIndex.css.d.ts b/frontend/src/Artist/Index/ArtistIndex.css.d.ts new file mode 100644 index 000000000..ec08fc921 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndex.css.d.ts @@ -0,0 +1,13 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'bannersInnerContentBody': string; + 'contentBody': string; + 'contentBodyContainer': string; + 'errorMessage': string; + 'pageContentBodyWrapper': string; + 'postersInnerContentBody': string; + 'tableInnerContentBody': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/ArtistIndex.js b/frontend/src/Artist/Index/ArtistIndex.js deleted file mode 100644 index f88ffda52..000000000 --- a/frontend/src/Artist/Index/ArtistIndex.js +++ /dev/null @@ -1,429 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; -import getErrorMessage from 'Utilities/Object/getErrorMessage'; -import { align, icons, sortDirections } from 'Helpers/Props'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import PageContent from 'Components/Page/PageContent'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; -import PageJumpBar from 'Components/Page/PageJumpBar'; -import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; -import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; -import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; -import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; -import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; -import NoArtist from 'Artist/NoArtist'; -import ArtistIndexTableConnector from './Table/ArtistIndexTableConnector'; -import ArtistIndexTableOptionsConnector from './Table/ArtistIndexTableOptionsConnector'; -import ArtistIndexPosterOptionsModal from './Posters/Options/ArtistIndexPosterOptionsModal'; -import ArtistIndexPostersConnector from './Posters/ArtistIndexPostersConnector'; -import ArtistIndexBannerOptionsModal from './Banners/Options/ArtistIndexBannerOptionsModal'; -import ArtistIndexBannersConnector from './Banners/ArtistIndexBannersConnector'; -import ArtistIndexOverviewOptionsModal from './Overview/Options/ArtistIndexOverviewOptionsModal'; -import ArtistIndexOverviewsConnector from './Overview/ArtistIndexOverviewsConnector'; -import ArtistIndexFooterConnector from './ArtistIndexFooterConnector'; -import ArtistIndexFilterMenu from './Menus/ArtistIndexFilterMenu'; -import ArtistIndexSortMenu from './Menus/ArtistIndexSortMenu'; -import ArtistIndexViewMenu from './Menus/ArtistIndexViewMenu'; -import styles from './ArtistIndex.css'; - -function getViewComponent(view) { - if (view === 'posters') { - return ArtistIndexPostersConnector; - } - - if (view === 'banners') { - return ArtistIndexBannersConnector; - } - - if (view === 'overview') { - return ArtistIndexOverviewsConnector; - } - - return ArtistIndexTableConnector; -} - -class ArtistIndex extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - contentBody: null, - jumpBarItems: [], - jumpToCharacter: null, - isPosterOptionsModalOpen: false, - isBannerOptionsModalOpen: false, - isOverviewOptionsModalOpen: false, - isRendered: false - }; - } - - componentDidMount() { - this.setJumpBarItems(); - } - - componentDidUpdate(prevProps) { - const { - items, - sortKey, - sortDirection, - scrollTop - } = this.props; - - if ( - hasDifferentItems(prevProps.items, items) || - sortKey !== prevProps.sortKey || - sortDirection !== prevProps.sortDirection - ) { - this.setJumpBarItems(); - } - - if (this.state.jumpToCharacter != null && scrollTop !== prevProps.scrollTop) { - this.setState({ jumpToCharacter: null }); - } - } - - // - // Control - - setContentBodyRef = (ref) => { - this.setState({ contentBody: ref }); - } - - setJumpBarItems() { - const { - items, - sortKey, - sortDirection - } = this.props; - - // Reset if not sorting by sortName - if (sortKey !== 'sortName') { - this.setState({ jumpBarItems: [] }); - return; - } - - const characters = _.reduce(items, (acc, item) => { - const firstCharacter = item.sortName.charAt(0); - - if (isNaN(firstCharacter)) { - acc.push(firstCharacter); - } else { - acc.push('#'); - } - - return acc; - }, []).sort(); - - // Reverse if sorting descending - if (sortDirection === sortDirections.DESCENDING) { - characters.reverse(); - } - - this.setState({ jumpBarItems: _.sortedUniq(characters) }); - } - - // - // Listeners - - onPosterOptionsPress = () => { - this.setState({ isPosterOptionsModalOpen: true }); - } - - onPosterOptionsModalClose = () => { - this.setState({ isPosterOptionsModalOpen: false }); - } - - onBannerOptionsPress = () => { - this.setState({ isBannerOptionsModalOpen: true }); - } - - onBannerOptionsModalClose = () => { - this.setState({ isBannerOptionsModalOpen: false }); - } - - onOverviewOptionsPress = () => { - this.setState({ isOverviewOptionsModalOpen: true }); - } - - onOverviewOptionsModalClose = () => { - this.setState({ isOverviewOptionsModalOpen: false }); - } - - onJumpBarItemPress = (jumpToCharacter) => { - this.setState({ jumpToCharacter }); - } - - onRender = () => { - this.setState({ isRendered: true }, () => { - const { - scrollTop, - isSmallScreen - } = this.props; - - if (isSmallScreen) { - // Seems to result in the view being off by 125px (distance to the top of the page) - // document.documentElement.scrollTop = document.body.scrollTop = scrollTop; - - // This works, but then jumps another 1px after scrolling - document.documentElement.scrollTop = scrollTop; - } - }); - } - - onScroll = ({ scrollTop }) => { - this.props.onScroll({ scrollTop }); - } - - // - // Render - - render() { - const { - isFetching, - isPopulated, - error, - totalItems, - items, - columns, - selectedFilterKey, - filters, - customFilters, - sortKey, - sortDirection, - view, - isRefreshingArtist, - isRssSyncExecuting, - scrollTop, - onSortSelect, - onFilterSelect, - onViewSelect, - onRefreshArtistPress, - onRssSyncPress, - ...otherProps - } = this.props; - - const { - contentBody, - jumpBarItems, - jumpToCharacter, - isPosterOptionsModalOpen, - isBannerOptionsModalOpen, - isOverviewOptionsModalOpen, - isRendered - } = this.state; - - const ViewComponent = getViewComponent(view); - const isLoaded = !!(!error && isPopulated && items.length && contentBody); - const hasNoArtist = !totalItems; - - return ( - - - - - - - - - - - { - view === 'table' ? - - - : - null - } - - { - view === 'posters' ? - : - null - } - - { - view === 'banners' ? - : - null - } - - { - view === 'overview' ? - : - null - } - - { - (view === 'posters' || view === 'banners' || view === 'overview') && - - - } - - - - - - - - - -
- - { - isFetching && !isPopulated && - - } - - { - !isFetching && !!error && -
- {getErrorMessage(error, 'Failed to load artist from API')} -
- } - - { - isLoaded && -
- - - -
- } - - { - !error && isPopulated && !items.length && - - } -
- - { - isLoaded && !!jumpBarItems.length && - - } -
- - - - - - -
- ); - } -} - -ArtistIndex.propTypes = { - isFetching: PropTypes.bool.isRequired, - isPopulated: PropTypes.bool.isRequired, - error: PropTypes.object, - totalItems: PropTypes.number.isRequired, - items: PropTypes.arrayOf(PropTypes.object).isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - view: PropTypes.string.isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - isRssSyncExecuting: PropTypes.bool.isRequired, - scrollTop: PropTypes.number.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - onSortSelect: PropTypes.func.isRequired, - onFilterSelect: PropTypes.func.isRequired, - onViewSelect: PropTypes.func.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired, - onRssSyncPress: PropTypes.func.isRequired, - onScroll: PropTypes.func.isRequired -}; - -export default ArtistIndex; diff --git a/frontend/src/Artist/Index/ArtistIndex.tsx b/frontend/src/Artist/Index/ArtistIndex.tsx new file mode 100644 index 000000000..2fcc0fadf --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndex.tsx @@ -0,0 +1,375 @@ +import React, { + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { SelectProvider } from 'App/SelectContext'; +import ArtistAppState, { ArtistIndexAppState } from 'App/State/ArtistAppState'; +import ClientSideCollectionAppState from 'App/State/ClientSideCollectionAppState'; +import NoArtist from 'Artist/NoArtist'; +import { RSS_SYNC } from 'Commands/commandNames'; +import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import PageContent from 'Components/Page/PageContent'; +import PageContentBody from 'Components/Page/PageContentBody'; +import PageJumpBar from 'Components/Page/PageJumpBar'; +import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; +import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; +import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; +import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; +import withScrollPosition from 'Components/withScrollPosition'; +import { align, icons } from 'Helpers/Props'; +import SortDirection from 'Helpers/Props/SortDirection'; +import { + setArtistFilter, + setArtistSort, + setArtistTableOption, + setArtistView, +} from 'Store/Actions/artistIndexActions'; +import { executeCommand } from 'Store/Actions/commandActions'; +import { fetchQueueDetails } from 'Store/Actions/queueActions'; +import scrollPositions from 'Store/scrollPositions'; +import createArtistClientSideCollectionItemsSelector from 'Store/Selectors/createArtistClientSideCollectionItemsSelector'; +import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; +import getErrorMessage from 'Utilities/Object/getErrorMessage'; +import translate from 'Utilities/String/translate'; +import ArtistIndexFooter from './ArtistIndexFooter'; +import ArtistIndexRefreshArtistsButton from './ArtistIndexRefreshArtistsButton'; +import ArtistIndexBanners from './Banners/ArtistIndexBanners'; +import ArtistIndexBannerOptionsModal from './Banners/Options/ArtistIndexBannerOptionsModal'; +import ArtistIndexFilterMenu from './Menus/ArtistIndexFilterMenu'; +import ArtistIndexSortMenu from './Menus/ArtistIndexSortMenu'; +import ArtistIndexViewMenu from './Menus/ArtistIndexViewMenu'; +import ArtistIndexOverviews from './Overview/ArtistIndexOverviews'; +import ArtistIndexOverviewOptionsModal from './Overview/Options/ArtistIndexOverviewOptionsModal'; +import ArtistIndexPosters from './Posters/ArtistIndexPosters'; +import ArtistIndexPosterOptionsModal from './Posters/Options/ArtistIndexPosterOptionsModal'; +import ArtistIndexSelectAllButton from './Select/ArtistIndexSelectAllButton'; +import ArtistIndexSelectAllMenuItem from './Select/ArtistIndexSelectAllMenuItem'; +import ArtistIndexSelectFooter from './Select/ArtistIndexSelectFooter'; +import ArtistIndexSelectModeButton from './Select/ArtistIndexSelectModeButton'; +import ArtistIndexSelectModeMenuItem from './Select/ArtistIndexSelectModeMenuItem'; +import ArtistIndexTable from './Table/ArtistIndexTable'; +import ArtistIndexTableOptions from './Table/ArtistIndexTableOptions'; +import styles from './ArtistIndex.css'; + +function getViewComponent(view: string) { + if (view === 'posters') { + return ArtistIndexPosters; + } + + if (view === 'banners') { + return ArtistIndexBanners; + } + + if (view === 'overview') { + return ArtistIndexOverviews; + } + + return ArtistIndexTable; +} + +interface ArtistIndexProps { + initialScrollTop?: number; +} + +const ArtistIndex = withScrollPosition((props: ArtistIndexProps) => { + const { + isFetching, + isPopulated, + error, + totalItems, + items, + columns, + selectedFilterKey, + filters, + customFilters, + sortKey, + sortDirection, + view, + }: ArtistAppState & ArtistIndexAppState & ClientSideCollectionAppState = + useSelector(createArtistClientSideCollectionItemsSelector('artistIndex')); + + const isRssSyncExecuting = useSelector( + createCommandExecutingSelector(RSS_SYNC) + ); + const { isSmallScreen } = useSelector(createDimensionsSelector()); + const dispatch = useDispatch(); + const scrollerRef = useRef(null); + const [isOptionsModalOpen, setIsOptionsModalOpen] = useState(false); + const [jumpToCharacter, setJumpToCharacter] = useState( + undefined + ); + const [isSelectMode, setIsSelectMode] = useState(false); + + useEffect(() => { + dispatch(fetchQueueDetails({ all: true })); + }, [dispatch]); + + const onRssSyncPress = useCallback(() => { + dispatch( + executeCommand({ + name: RSS_SYNC, + }) + ); + }, [dispatch]); + + const onSelectModePress = useCallback(() => { + setIsSelectMode(!isSelectMode); + }, [isSelectMode, setIsSelectMode]); + + const onTableOptionChange = useCallback( + (payload: unknown) => { + dispatch(setArtistTableOption(payload)); + }, + [dispatch] + ); + + const onViewSelect = useCallback( + (value: string) => { + dispatch(setArtistView({ view: value })); + + if (scrollerRef.current) { + scrollerRef.current.scrollTo(0, 0); + } + }, + [scrollerRef, dispatch] + ); + + const onSortSelect = useCallback( + (value: string) => { + dispatch(setArtistSort({ sortKey: value })); + }, + [dispatch] + ); + + const onFilterSelect = useCallback( + (value: string) => { + dispatch(setArtistFilter({ selectedFilterKey: value })); + }, + [dispatch] + ); + + const onOptionsPress = useCallback(() => { + setIsOptionsModalOpen(true); + }, [setIsOptionsModalOpen]); + + const onOptionsModalClose = useCallback(() => { + setIsOptionsModalOpen(false); + }, [setIsOptionsModalOpen]); + + const onJumpBarItemPress = useCallback( + (character: string) => { + setJumpToCharacter(character); + }, + [setJumpToCharacter] + ); + + const onScroll = useCallback( + ({ scrollTop }: { scrollTop: number }) => { + setJumpToCharacter(undefined); + scrollPositions.artistIndex = scrollTop; + }, + [setJumpToCharacter] + ); + + const jumpBarItems = useMemo(() => { + // Reset if not sorting by sortName + if (sortKey !== 'sortName') { + return { + order: [], + }; + } + + const characters = items.reduce((acc: Record, item) => { + let char = item.sortName.charAt(0); + + if (!isNaN(Number(char))) { + char = '#'; + } + + if (char in acc) { + acc[char] = acc[char] + 1; + } else { + acc[char] = 1; + } + + return acc; + }, {}); + + const order = Object.keys(characters).sort(); + + // Reverse if sorting descending + if (sortDirection === SortDirection.Descending) { + order.reverse(); + } + + return { + characters, + order, + }; + }, [items, sortKey, sortDirection]); + const ViewComponent = useMemo(() => getViewComponent(view), [view]); + + const isLoaded = !!(!error && isPopulated && items.length); + const hasNoArtist = !totalItems; + + return ( + + + + + + + + + + + + + + + + + {view === 'table' ? ( + + + + ) : ( + + )} + + + + + + + + + + +
+ + {isFetching && !isPopulated ? : null} + + {!isFetching && !!error ? ( +
+ {getErrorMessage(error, 'Failed to load artist from API')} +
+ ) : null} + + {isLoaded ? ( +
+ + + +
+ ) : null} + + {!error && isPopulated && !items.length ? ( + + ) : null} +
+ {isLoaded && !!jumpBarItems.order.length ? ( + + ) : null} +
+ + {isSelectMode ? : null} + + {view === 'posters' ? ( + + ) : null} + {view === 'banners' ? ( + + ) : null} + {view === 'overview' ? ( + + ) : null} +
+
+ ); +}, 'artistIndex'); + +export default ArtistIndex; diff --git a/frontend/src/Artist/Index/ArtistIndexConnector.js b/frontend/src/Artist/Index/ArtistIndexConnector.js deleted file mode 100644 index a9e0b7dcc..000000000 --- a/frontend/src/Artist/Index/ArtistIndexConnector.js +++ /dev/null @@ -1,162 +0,0 @@ -/* eslint max-params: 0 */ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createArtistClientSideCollectionItemsSelector from 'Store/Selectors/createArtistClientSideCollectionItemsSelector'; -import dimensions from 'Styles/Variables/dimensions'; -import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import scrollPositions from 'Store/scrollPositions'; -import { setArtistSort, setArtistFilter, setArtistView, setArtistTableOption } from 'Store/Actions/artistIndexActions'; -import { executeCommand } from 'Store/Actions/commandActions'; -import * as commandNames from 'Commands/commandNames'; -import withScrollPosition from 'Components/withScrollPosition'; -import ArtistIndex from './ArtistIndex'; - -const POSTERS_PADDING = 15; -const POSTERS_PADDING_SMALL_SCREEN = 5; -const BANNERS_PADDING = 15; -const BANNERS_PADDING_SMALL_SCREEN = 5; -const TABLE_PADDING = parseInt(dimensions.pageContentBodyPadding); -const TABLE_PADDING_SMALL_SCREEN = parseInt(dimensions.pageContentBodyPaddingSmallScreen); - -// If the scrollTop is greater than zero it needs to be offset -// by the padding so when it is set initially so it is correct -// after React Virtualized takes the padding into account. - -function getScrollTop(view, scrollTop, isSmallScreen) { - if (scrollTop === 0) { - return 0; - } - - let padding = isSmallScreen ? TABLE_PADDING_SMALL_SCREEN : TABLE_PADDING; - - if (view === 'posters') { - padding = isSmallScreen ? POSTERS_PADDING_SMALL_SCREEN : POSTERS_PADDING; - } - - if (view === 'banners') { - padding = isSmallScreen ? BANNERS_PADDING_SMALL_SCREEN : BANNERS_PADDING; - } - - return scrollTop + padding; -} - -function createMapStateToProps() { - return createSelector( - createArtistClientSideCollectionItemsSelector('artistIndex'), - createCommandExecutingSelector(commandNames.REFRESH_ARTIST), - createCommandExecutingSelector(commandNames.RSS_SYNC), - createDimensionsSelector(), - ( - artist, - isRefreshingArtist, - isRssSyncExecuting, - dimensionsState - ) => { - return { - ...artist, - isRefreshingArtist, - isRssSyncExecuting, - isSmallScreen: dimensionsState.isSmallScreen - }; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onTableOptionChange(payload) { - dispatch(setArtistTableOption(payload)); - }, - - onSortSelect(sortKey) { - dispatch(setArtistSort({ sortKey })); - }, - - onFilterSelect(selectedFilterKey) { - dispatch(setArtistFilter({ selectedFilterKey })); - }, - - dispatchSetArtistView(view) { - dispatch(setArtistView({ view })); - }, - - onRefreshArtistPress() { - dispatch(executeCommand({ - name: commandNames.REFRESH_ARTIST - })); - }, - - onRssSyncPress() { - dispatch(executeCommand({ - name: commandNames.RSS_SYNC - })); - } - }; -} - -class ArtistIndexConnector extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - const { - view, - scrollTop, - isSmallScreen - } = props; - - this.state = { - scrollTop: getScrollTop(view, scrollTop, isSmallScreen) - }; - } - - // - // Listeners - - onViewSelect = (view) => { - // Reset the scroll position before changing the view - this.setState({ scrollTop: 0 }, () => { - this.props.dispatchSetArtistView(view); - }); - } - - onScroll = ({ scrollTop }) => { - this.setState({ - scrollTop - }, () => { - scrollPositions.artistIndex = scrollTop; - }); - } - - // - // Render - - render() { - return ( - - ); - } -} - -ArtistIndexConnector.propTypes = { - isSmallScreen: PropTypes.bool.isRequired, - view: PropTypes.string.isRequired, - scrollTop: PropTypes.number.isRequired, - dispatchSetArtistView: PropTypes.func.isRequired -}; - -export default withScrollPosition( - connect(createMapStateToProps, createMapDispatchToProps)(ArtistIndexConnector), - 'artistIndex' -); diff --git a/frontend/src/Artist/Index/ArtistIndexFilterModal.tsx b/frontend/src/Artist/Index/ArtistIndexFilterModal.tsx new file mode 100644 index 000000000..07e454fc2 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexFilterModal.tsx @@ -0,0 +1,56 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterModal from 'Components/Filter/FilterModal'; +import { setArtistFilter } from 'Store/Actions/artistIndexActions'; + +function createArtistSelector() { + return createSelector( + (state: AppState) => state.artist.items, + (artist) => { + return artist; + } + ); +} + +function createFilterBuilderPropsSelector() { + return createSelector( + (state: AppState) => state.artistIndex.filterBuilderProps, + (filterBuilderProps) => { + return filterBuilderProps; + } + ); +} + +interface ArtistIndexFilterModalProps { + isOpen: boolean; +} + +export default function ArtistIndexFilterModal( + props: ArtistIndexFilterModalProps +) { + const sectionItems = useSelector(createArtistSelector()); + const filterBuilderProps = useSelector(createFilterBuilderPropsSelector()); + const customFilterType = 'artist'; + + const dispatch = useDispatch(); + + const dispatchSetFilter = useCallback( + (payload: unknown) => { + dispatch(setArtistFilter(payload)); + }, + [dispatch] + ); + + return ( + + ); +} diff --git a/frontend/src/Artist/Index/ArtistIndexFilterModalConnector.js b/frontend/src/Artist/Index/ArtistIndexFilterModalConnector.js deleted file mode 100644 index 412f3df34..000000000 --- a/frontend/src/Artist/Index/ArtistIndexFilterModalConnector.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setArtistFilter } from 'Store/Actions/artistIndexActions'; -import FilterModal from 'Components/Filter/FilterModal'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artist.items, - (state) => state.artistIndex.filterBuilderProps, - (sectionItems, filterBuilderProps) => { - return { - sectionItems, - filterBuilderProps, - customFilterType: 'artistIndex' - }; - } - ); -} - -const mapDispatchToProps = { - dispatchSetFilter: setArtistFilter -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(FilterModal); diff --git a/frontend/src/Artist/Index/ArtistIndexFooter.css b/frontend/src/Artist/Index/ArtistIndexFooter.css index 71d0439b6..bf3fedfd6 100644 --- a/frontend/src/Artist/Index/ArtistIndexFooter.css +++ b/frontend/src/Artist/Index/ArtistIndexFooter.css @@ -21,35 +21,41 @@ .continuing { composes: legendItemColor; - background-color: $primaryColor; + background-color: var(--primaryColor); } .ended { composes: legendItemColor; - background-color: $successColor; + background-color: var(--successColor); } .missingMonitored { composes: legendItemColor; - background-color: $dangerColor; + background-color: var(--dangerColor); &:global(.colorImpaired) { - background: repeating-linear-gradient(90deg, color($dangerColor shade(5%)), color($dangerColor shade(5%)) 5px, color($dangerColor shade(15%)) 5px, color($dangerColor shade(15%)) 10px); + background: repeating-linear-gradient(90deg, color(#f05050 shade(5%)), color(#f05050 shade(5%)) 5px, color(#f05050 shade(15%)) 5px, color(#f05050 shade(15%)) 10px); } } .missingUnmonitored { composes: legendItemColor; - background-color: $warningColor; + background-color: var(--warningColor); &:global(.colorImpaired) { - background: repeating-linear-gradient(45deg, $warningColor, $warningColor 5px, color($warningColor tint(15%)) 5px, color($warningColor tint(15%)) 10px); + background: repeating-linear-gradient(45deg, #ffa500, #ffa500 5px, color(#ffa500 tint(15%)) 5px, color(#ffa500 tint(15%)) 10px); } } +.downloading { + composes: legendItemColor; + + background-color: var(--purple); +} + .statistics { display: flex; justify-content: space-between; diff --git a/frontend/src/Artist/Index/ArtistIndexFooter.css.d.ts b/frontend/src/Artist/Index/ArtistIndexFooter.css.d.ts new file mode 100644 index 000000000..29f693a8c --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexFooter.css.d.ts @@ -0,0 +1,15 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'continuing': string; + 'downloading': string; + 'ended': string; + 'footer': string; + 'legendItem': string; + 'legendItemColor': string; + 'missingMonitored': string; + 'missingUnmonitored': string; + 'statistics': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/ArtistIndexFooter.js b/frontend/src/Artist/Index/ArtistIndexFooter.js deleted file mode 100644 index 245312ae6..000000000 --- a/frontend/src/Artist/Index/ArtistIndexFooter.js +++ /dev/null @@ -1,158 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { PureComponent } from 'react'; -import classNames from 'classnames'; -import formatBytes from 'Utilities/Number/formatBytes'; -import { ColorImpairedConsumer } from 'App/ColorImpairedContext'; -import DescriptionList from 'Components/DescriptionList/DescriptionList'; -import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; -import styles from './ArtistIndexFooter.css'; - -class ArtistIndexFooter extends PureComponent { - - // - // Render - - render() { - const { artist } = this.props; - const count = artist.length; - let tracks = 0; - let trackFiles = 0; - let ended = 0; - let continuing = 0; - let monitored = 0; - let totalFileSize = 0; - - artist.forEach((s) => { - const { statistics = {} } = s; - - const { - trackCount = 0, - trackFileCount = 0, - sizeOnDisk = 0 - } = statistics; - - tracks += trackCount; - trackFiles += trackFileCount; - - if (s.status === 'ended') { - ended++; - } else { - continuing++; - } - - if (s.monitored) { - monitored++; - } - - totalFileSize += sizeOnDisk; - }); - - return ( - - {(enableColorImpairedMode) => { - return ( -
-
-
-
-
Continuing (All tracks downloaded)
-
- -
-
-
Ended (All tracks downloaded)
-
- -
-
-
Missing Tracks (Artist monitored)
-
- -
-
-
Missing Tracks (Artist not monitored)
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - -
-
- ); - }} - - ); - } -} - -ArtistIndexFooter.propTypes = { - artist: PropTypes.arrayOf(PropTypes.object).isRequired -}; - -export default ArtistIndexFooter; diff --git a/frontend/src/Artist/Index/ArtistIndexFooter.tsx b/frontend/src/Artist/Index/ArtistIndexFooter.tsx new file mode 100644 index 000000000..47241b224 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexFooter.tsx @@ -0,0 +1,179 @@ +import classNames from 'classnames'; +import React from 'react'; +import { useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import { ColorImpairedConsumer } from 'App/ColorImpairedContext'; +import ArtistAppState from 'App/State/ArtistAppState'; +import DescriptionList from 'Components/DescriptionList/DescriptionList'; +import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector'; +import createDeepEqualSelector from 'Store/Selectors/createDeepEqualSelector'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistIndexFooter.css'; + +function createUnoptimizedSelector() { + return createSelector( + createClientSideCollectionSelector('artist', 'artistIndex'), + (artist: ArtistAppState) => { + return artist.items.map((s) => { + const { monitored, status, statistics } = s; + + return { + monitored, + status, + statistics, + }; + }); + } + ); +} + +function createArtistSelector() { + return createDeepEqualSelector( + createUnoptimizedSelector(), + (artist) => artist + ); +} + +export default function ArtistIndexFooter() { + const artist = useSelector(createArtistSelector()); + const count = artist.length; + let tracks = 0; + let trackFiles = 0; + let ended = 0; + let continuing = 0; + let monitored = 0; + let totalFileSize = 0; + + artist.forEach((a) => { + const { statistics = { trackCount: 0, trackFileCount: 0, sizeOnDisk: 0 } } = + a; + + const { trackCount = 0, trackFileCount = 0, sizeOnDisk = 0 } = statistics; + + tracks += trackCount; + trackFiles += trackFileCount; + + if (a.status === 'ended') { + ended++; + } else { + continuing++; + } + + if (a.monitored) { + monitored++; + } + + totalFileSize += sizeOnDisk; + }); + + return ( + + {(enableColorImpairedMode) => { + return ( +
+
+
+
+
{translate('ContinuingAllTracksDownloaded')}
+
+ +
+
+
{translate('EndedAllTracksDownloaded')}
+
+ +
+
+
{translate('MissingTracksArtistMonitored')}
+
+ +
+
+
{translate('MissingTracksArtistNotMonitored')}
+
+ +
+
+
{translate('ArtistIndexFooterDownloading')}
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
+
+ ); + }} + + ); +} diff --git a/frontend/src/Artist/Index/ArtistIndexFooterConnector.js b/frontend/src/Artist/Index/ArtistIndexFooterConnector.js deleted file mode 100644 index 9d7afc298..000000000 --- a/frontend/src/Artist/Index/ArtistIndexFooterConnector.js +++ /dev/null @@ -1,46 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createDeepEqualSelector from 'Store/Selectors/createDeepEqualSelector'; -import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector'; -import ArtistIndexFooter from './ArtistIndexFooter'; - -function createUnoptimizedSelector() { - return createSelector( - createClientSideCollectionSelector('artist', 'artistIndex'), - (artist) => { - return artist.items.map((s) => { - const { - monitored, - status, - statistics - } = s; - - return { - monitored, - status, - statistics - }; - }); - } - ); -} - -function createArtistSelector() { - return createDeepEqualSelector( - createUnoptimizedSelector(), - (artist) => artist - ); -} - -function createMapStateToProps() { - return createSelector( - createArtistSelector(), - (artist) => { - return { - artist - }; - } - ); -} - -export default connect(createMapStateToProps)(ArtistIndexFooter); diff --git a/frontend/src/Artist/Index/ArtistIndexItemConnector.js b/frontend/src/Artist/Index/ArtistIndexItemConnector.js deleted file mode 100644 index aef6a8e5e..000000000 --- a/frontend/src/Artist/Index/ArtistIndexItemConnector.js +++ /dev/null @@ -1,141 +0,0 @@ -/* eslint max-params: 0 */ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createArtistSelector from 'Store/Selectors/createArtistSelector'; -import createExecutingCommandsSelector from 'Store/Selectors/createExecutingCommandsSelector'; -import createArtistQualityProfileSelector from 'Store/Selectors/createArtistQualityProfileSelector'; -import createArtistMetadataProfileSelector from 'Store/Selectors/createArtistMetadataProfileSelector'; -import { executeCommand } from 'Store/Actions/commandActions'; -import * as commandNames from 'Commands/commandNames'; - -function selectShowSearchAction() { - return createSelector( - (state) => state.artistIndex, - (artistIndex) => { - const view = artistIndex.view; - - switch (view) { - case 'posters': - return artistIndex.posterOptions.showSearchAction; - case 'banners': - return artistIndex.bannerOptions.showSearchAction; - case 'overview': - return artistIndex.overviewOptions.showSearchAction; - default: - return artistIndex.tableOptions.showSearchAction; - } - } - ); -} - -function createMapStateToProps() { - return createSelector( - createArtistSelector(), - createArtistQualityProfileSelector(), - createArtistMetadataProfileSelector(), - selectShowSearchAction(), - createExecutingCommandsSelector(), - ( - artist, - qualityProfile, - metadataProfile, - showSearchAction, - executingCommands - ) => { - - // If an artist is deleted this selector may fire before the parent - // selectors, which will result in an undefined artist, if that happens - // we want to return early here and again in the render function to avoid - // trying to show an artist that has no information available. - - if (!artist) { - return {}; - } - - const isRefreshingArtist = executingCommands.some((command) => { - return ( - command.name === commandNames.REFRESH_ARTIST && - command.body.artistId === artist.id - ); - }); - - const isSearchingArtist = executingCommands.some((command) => { - return ( - command.name === commandNames.ARTIST_SEARCH && - command.body.artistId === artist.id - ); - }); - - const latestAlbum = _.maxBy(artist.albums, (album) => album.releaseDate); - - return { - ...artist, - qualityProfile, - metadataProfile, - latestAlbum, - showSearchAction, - isRefreshingArtist, - isSearchingArtist - }; - } - ); -} - -const mapDispatchToProps = { - dispatchExecuteCommand: executeCommand -}; - -class ArtistIndexItemConnector extends Component { - - // - // Listeners - - onRefreshArtistPress = () => { - this.props.dispatchExecuteCommand({ - name: commandNames.REFRESH_ARTIST, - artistId: this.props.id - }); - } - - onSearchPress = () => { - this.props.dispatchExecuteCommand({ - name: commandNames.ARTIST_SEARCH, - artistId: this.props.id - }); - } - - // - // Render - - render() { - const { - id, - component: ItemComponent, - ...otherProps - } = this.props; - - if (!id) { - return null; - } - - return ( - - ); - } -} - -ArtistIndexItemConnector.propTypes = { - id: PropTypes.number, - component: PropTypes.elementType.isRequired, - dispatchExecuteCommand: PropTypes.func.isRequired -}; - -export default connect(createMapStateToProps, mapDispatchToProps)(ArtistIndexItemConnector); diff --git a/frontend/src/Artist/Index/ArtistIndexRefreshArtistsButton.tsx b/frontend/src/Artist/Index/ArtistIndexRefreshArtistsButton.tsx new file mode 100644 index 000000000..07a180857 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexRefreshArtistsButton.tsx @@ -0,0 +1,74 @@ +import React, { useCallback, useMemo } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { useSelect } from 'App/SelectContext'; +import ArtistAppState, { ArtistIndexAppState } from 'App/State/ArtistAppState'; +import ClientSideCollectionAppState from 'App/State/ClientSideCollectionAppState'; +import { REFRESH_ARTIST } from 'Commands/commandNames'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; +import { icons } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createArtistClientSideCollectionItemsSelector from 'Store/Selectors/createArtistClientSideCollectionItemsSelector'; +import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +import translate from 'Utilities/String/translate'; +import getSelectedIds from 'Utilities/Table/getSelectedIds'; + +interface ArtistIndexRefreshArtistsButtonProps { + isSelectMode: boolean; + selectedFilterKey: string; +} + +function ArtistIndexRefreshArtistsButton( + props: ArtistIndexRefreshArtistsButtonProps +) { + const isRefreshing = useSelector( + createCommandExecutingSelector(REFRESH_ARTIST) + ); + const { + items, + totalItems, + }: ArtistAppState & ArtistIndexAppState & ClientSideCollectionAppState = + useSelector(createArtistClientSideCollectionItemsSelector('artistIndex')); + + const dispatch = useDispatch(); + const { isSelectMode, selectedFilterKey } = props; + const [selectState] = useSelect(); + const { selectedState } = selectState; + + const selectedArtistIds = useMemo(() => { + return getSelectedIds(selectedState); + }, [selectedState]); + + const artistsToRefresh = + isSelectMode && selectedArtistIds.length > 0 + ? selectedArtistIds + : items.map((m) => m.id); + + let refreshLabel = translate('UpdateAll'); + + if (selectedArtistIds.length > 0) { + refreshLabel = translate('UpdateSelected'); + } else if (selectedFilterKey !== 'all') { + refreshLabel = translate('UpdateFiltered'); + } + + const onPress = useCallback(() => { + dispatch( + executeCommand({ + name: REFRESH_ARTIST, + artistIds: artistsToRefresh, + }) + ); + }, [dispatch, artistsToRefresh]); + + return ( + + ); +} + +export default ArtistIndexRefreshArtistsButton; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css index 3f9bfdd8b..7f1fc71c6 100644 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css @@ -1,15 +1,11 @@ $hoverScale: 1.05; -.container { - padding: 10px; -} - .content { transition: all 200ms ease-in; &:hover { z-index: 2; - box-shadow: 0 0 12px $black; + box-shadow: 0 0 12px var(--black); transition: all 200ms ease-in; .controls { @@ -26,12 +22,29 @@ $hoverScale: 1.05; .link { composes: link from '~Components/Link/Link.css'; + position: relative; display: block; - background-color: $defaultColor; + height: 50px; + background-color: var(--defaultColor); } -.nextAiring { - background-color: #fafbfc; +.overlayTitle { + position: absolute; + top: 0; + left: 0; + display: flex; + align-items: center; + justify-content: center; + padding: 5px; + width: 100%; + height: 100%; + color: var(--offWhite); + text-align: center; + font-size: 20px; +} + +.nextAlbum { + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } @@ -39,8 +52,7 @@ $hoverScale: 1.05; .title { @add-mixin truncate; - background-color: $defaultColor; - color: $white; + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } @@ -49,12 +61,13 @@ $hoverScale: 1.05; position: absolute; top: 0; right: 0; + z-index: 1; width: 0; height: 0; border-width: 0 25px 25px 0; border-style: solid; - border-color: transparent $dangerColor transparent transparent; - color: $white; + border-color: transparent var(--dangerColor) transparent transparent; + color: var(--white); } .controls { @@ -64,7 +77,7 @@ $hoverScale: 1.05; z-index: 3; border-radius: 4px; background-color: #216044; - color: $white; + color: var(--white); font-size: $smallFontSize; opacity: 0; transition: opacity 0; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css.d.ts b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css.d.ts new file mode 100644 index 000000000..bd6cb4ac9 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css.d.ts @@ -0,0 +1,16 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'action': string; + 'bannerContainer': string; + 'container': string; + 'content': string; + 'controls': string; + 'ended': string; + 'link': string; + 'nextAlbum': string; + 'overlayTitle': string; + 'title': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.js b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.js deleted file mode 100644 index 42883da51..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.js +++ /dev/null @@ -1,272 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; -import { icons } from 'Helpers/Props'; -import IconButton from 'Components/Link/IconButton'; -import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; -import Label from 'Components/Label'; -import Link from 'Components/Link/Link'; -import ArtistBanner from 'Artist/ArtistBanner'; -import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; -import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; -import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; -import ArtistIndexBannerInfo from './ArtistIndexBannerInfo'; -import styles from './ArtistIndexBanner.css'; - -class ArtistIndexBanner extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: false - }; - } - - // - // Listeners - - onEditArtistPress = () => { - this.setState({ isEditArtistModalOpen: true }); - } - - onEditArtistModalClose = () => { - this.setState({ isEditArtistModalOpen: false }); - } - - onDeleteArtistPress = () => { - this.setState({ - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: true - }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - // - // Render - - render() { - const { - style, - id, - artistName, - monitored, - status, - foreignArtistId, - nextAiring, - statistics, - images, - bannerWidth, - bannerHeight, - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile, - showSearchAction, - qualityProfile, - showRelativeDates, - shortDateFormat, - timeFormat, - isRefreshingArtist, - isSearchingArtist, - onRefreshArtistPress, - onSearchPress, - ...otherProps - } = this.props; - - const { - albumCount, - sizeOnDisk, - trackCount, - trackFileCount, - totalTrackCount - } = statistics; - - const { - isEditArtistModalOpen, - isDeleteArtistModalOpen - } = this.state; - - const link = `/artist/${foreignArtistId}`; - - const elementStyle = { - width: `${bannerWidth}px`, - height: `${bannerHeight}px` - }; - - return ( -
-
-
- - - { - status === 'ended' && -
- } - - - - -
- - - - { - showTitle && -
- {artistName} -
- } - - { - showMonitored && -
- {monitored ? 'Monitored' : 'Unmonitored'} -
- } - - { - showQualityProfile && -
- {qualityProfile.name} -
- } - { - nextAiring && -
- { - getRelativeDate( - nextAiring, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - } -
- } - - - - - - -
-
- ); - } -} - -ArtistIndexBanner.propTypes = { - style: PropTypes.object.isRequired, - id: PropTypes.number.isRequired, - artistName: PropTypes.string.isRequired, - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - nextAiring: PropTypes.string, - statistics: PropTypes.object.isRequired, - images: PropTypes.arrayOf(PropTypes.object).isRequired, - bannerWidth: PropTypes.number.isRequired, - bannerHeight: PropTypes.number.isRequired, - detailedProgressBar: PropTypes.bool.isRequired, - showTitle: PropTypes.bool.isRequired, - showMonitored: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - qualityProfile: PropTypes.object.isRequired, - showSearchAction: PropTypes.bool.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - isSearchingArtist: PropTypes.bool.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired, - onSearchPress: PropTypes.func.isRequired -}; - -ArtistIndexBanner.defaultProps = { - statistics: { - albumCount: 0, - trackCount: 0, - trackFileCount: 0, - totalTrackCount: 0 - } -}; - -export default ArtistIndexBanner; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.tsx b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.tsx new file mode 100644 index 000000000..f6a03c521 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.tsx @@ -0,0 +1,263 @@ +import React, { useCallback, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { Statistics } from 'Artist/Artist'; +import ArtistBanner from 'Artist/ArtistBanner'; +import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; +import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; +import ArtistIndexBannerInfo from 'Artist/Index/Banners/ArtistIndexBannerInfo'; +import createArtistIndexItemSelector from 'Artist/Index/createArtistIndexItemSelector'; +import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; +import ArtistIndexPosterSelect from 'Artist/Index/Select/ArtistIndexPosterSelect'; +import { ARTIST_SEARCH, REFRESH_ARTIST } from 'Commands/commandNames'; +import Label from 'Components/Label'; +import IconButton from 'Components/Link/IconButton'; +import Link from 'Components/Link/Link'; +import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; +import { icons } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import translate from 'Utilities/String/translate'; +import selectBannerOptions from './selectBannerOptions'; +import styles from './ArtistIndexBanner.css'; + +interface ArtistIndexBannerProps { + artistId: number; + sortKey: string; + isSelectMode: boolean; + bannerWidth: number; + bannerHeight: number; +} + +function ArtistIndexBanner(props: ArtistIndexBannerProps) { + const { artistId, sortKey, isSelectMode, bannerWidth, bannerHeight } = props; + + const { + artist, + qualityProfile, + metadataProfile, + isRefreshingArtist, + isSearchingArtist, + } = useSelector(createArtistIndexItemSelector(props.artistId)); + + const { + detailedProgressBar, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + showSearchAction, + } = useSelector(selectBannerOptions); + + const { showRelativeDates, shortDateFormat, longDateFormat, timeFormat } = + useSelector(createUISettingsSelector()); + + const { + artistName, + artistType, + monitored, + status, + path, + foreignArtistId, + nextAlbum, + added, + statistics = {} as Statistics, + images, + tags, + } = artist; + + const { + albumCount = 0, + trackCount = 0, + trackFileCount = 0, + totalTrackCount = 0, + sizeOnDisk = 0, + } = statistics; + + const dispatch = useDispatch(); + const [hasBannerError, setHasBannerError] = useState(false); + const [isEditArtistModalOpen, setIsEditArtistModalOpen] = useState(false); + const [isDeleteArtistModalOpen, setIsDeleteArtistModalOpen] = useState(false); + + const onRefreshPress = useCallback(() => { + dispatch( + executeCommand({ + name: REFRESH_ARTIST, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onSearchPress = useCallback(() => { + dispatch( + executeCommand({ + name: ARTIST_SEARCH, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onBannerLoadError = useCallback(() => { + setHasBannerError(true); + }, [setHasBannerError]); + + const onBannerLoad = useCallback(() => { + setHasBannerError(false); + }, [setHasBannerError]); + + const onEditArtistPress = useCallback(() => { + setIsEditArtistModalOpen(true); + }, [setIsEditArtistModalOpen]); + + const onEditArtistModalClose = useCallback(() => { + setIsEditArtistModalOpen(false); + }, [setIsEditArtistModalOpen]); + + const onDeleteArtistPress = useCallback(() => { + setIsEditArtistModalOpen(false); + setIsDeleteArtistModalOpen(true); + }, [setIsDeleteArtistModalOpen]); + + const onDeleteArtistModalClose = useCallback(() => { + setIsDeleteArtistModalOpen(false); + }, [setIsDeleteArtistModalOpen]); + + const link = `/artist/${foreignArtistId}`; + + const elementStyle = { + width: `${bannerWidth}px`, + height: `${bannerHeight}px`, + }; + + return ( +
+
+ {isSelectMode ? : null} + + + + {status === 'ended' ? ( +
+ ) : null} + + + + + {hasBannerError ? ( +
{artistName}
+ ) : null} + +
+ + + + {showTitle ? ( +
+ {artistName} +
+ ) : null} + + {showMonitored ? ( +
+ {monitored ? translate('Monitored') : translate('Unmonitored')} +
+ ) : null} + + {showQualityProfile && !!qualityProfile?.name ? ( +
+ {qualityProfile.name} +
+ ) : null} + + {showNextAlbum && !!nextAlbum?.releaseDate ? ( +
+ {getRelativeDate( + nextAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ) : null} + + + + + + +
+ ); +} + +export default ArtistIndexBanner; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css index aab27d827..22ed2d528 100644 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css @@ -1,5 +1,5 @@ .info { - background-color: #fafbfc; + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css.d.ts b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css.d.ts new file mode 100644 index 000000000..062365d36 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'info': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.js b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.js deleted file mode 100644 index f641de0e1..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.js +++ /dev/null @@ -1,115 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; -import formatBytes from 'Utilities/Number/formatBytes'; -import styles from './ArtistIndexBannerInfo.css'; - -function ArtistIndexBannerInfo(props) { - const { - qualityProfile, - showQualityProfile, - previousAiring, - added, - albumCount, - path, - sizeOnDisk, - sortKey, - showRelativeDates, - shortDateFormat, - timeFormat - } = props; - - if (sortKey === 'qualityProfileId' && !showQualityProfile) { - return ( -
- {qualityProfile.name} -
- ); - } - - if (sortKey === 'previousAiring' && previousAiring) { - return ( -
- { - getRelativeDate( - previousAiring, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - } -
- ); - } - - if (sortKey === 'added' && added) { - const addedDate = getRelativeDate( - added, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: false - } - ); - - return ( -
- {`Added ${addedDate}`} -
- ); - } - - if (sortKey === 'albumCount') { - let albums = '1 album'; - - if (albumCount === 0) { - albums = 'No albums'; - } else if (albumCount > 1) { - albums = `${albumCount} albums`; - } - - return ( -
- {albums} -
- ); - } - - if (sortKey === 'path') { - return ( -
- {path} -
- ); - } - - if (sortKey === 'sizeOnDisk') { - return ( -
- {formatBytes(sizeOnDisk)} -
- ); - } - - return null; -} - -ArtistIndexBannerInfo.propTypes = { - qualityProfile: PropTypes.object.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - previousAiring: PropTypes.string, - added: PropTypes.string, - albumCount: PropTypes.number.isRequired, - path: PropTypes.string.isRequired, - sizeOnDisk: PropTypes.number, - sortKey: PropTypes.string.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired -}; - -export default ArtistIndexBannerInfo; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.tsx b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.tsx new file mode 100644 index 000000000..a93b0bafc --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.tsx @@ -0,0 +1,187 @@ +import React from 'react'; +import Album from 'Album/Album'; +import TagListConnector from 'Components/TagListConnector'; +import MetadataProfile from 'typings/MetadataProfile'; +import QualityProfile from 'typings/QualityProfile'; +import formatDateTime from 'Utilities/Date/formatDateTime'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistIndexBannerInfo.css'; + +interface ArtistIndexBannerInfoProps { + artistType?: string; + showQualityProfile: boolean; + qualityProfile?: QualityProfile; + metadataProfile?: MetadataProfile; + showNextAlbum: boolean; + nextAlbum?: Album; + lastAlbum?: Album; + added?: string; + albumCount: number; + path: string; + sizeOnDisk?: number; + tags?: number[]; + sortKey: string; + showRelativeDates: boolean; + shortDateFormat: string; + longDateFormat: string; + timeFormat: string; +} + +function ArtistIndexBannerInfo(props: ArtistIndexBannerInfoProps) { + const { + artistType, + qualityProfile, + metadataProfile, + showQualityProfile, + showNextAlbum, + nextAlbum, + lastAlbum, + added, + albumCount, + path, + sizeOnDisk, + tags, + sortKey, + showRelativeDates, + shortDateFormat, + longDateFormat, + timeFormat, + } = props; + + if (sortKey === 'artistType' && artistType) { + return ( +
+ {artistType} +
+ ); + } + + if ( + sortKey === 'qualityProfileId' && + !showQualityProfile && + !!qualityProfile?.name + ) { + return ( +
+ {qualityProfile.name} +
+ ); + } + + if (sortKey === 'metadataProfileId' && !!metadataProfile?.name) { + return ( +
+ {metadataProfile.name} +
+ ); + } + + if (sortKey === 'nextAlbum' && !showNextAlbum && !!nextAlbum?.releaseDate) { + return ( +
+ {getRelativeDate( + nextAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ); + } + + if (sortKey === 'lastAlbum' && !!lastAlbum?.releaseDate) { + return ( +
+ {getRelativeDate( + lastAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ); + } + + if (sortKey === 'added' && added) { + const addedDate = getRelativeDate( + added, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: false, + } + ); + + return ( +
+ {translate('Added')}: {addedDate} +
+ ); + } + + if (sortKey === 'albumCount') { + let albums = translate('OneAlbum'); + + if (albumCount === 0) { + albums = translate('NoAlbums'); + } else if (albumCount > 1) { + albums = translate('CountAlbums', { albumCount }); + } + + return
{albums}
; + } + + if (sortKey === 'path') { + return ( +
+ {path} +
+ ); + } + + if (sortKey === 'sizeOnDisk') { + return ( +
+ {formatBytes(sizeOnDisk)} +
+ ); + } + + if (sortKey === 'tags' && tags) { + return ( +
+ +
+ ); + } + + return null; +} + +export default ArtistIndexBannerInfo; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.css.d.ts b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.css.d.ts new file mode 100644 index 000000000..b97436b41 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'grid': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js deleted file mode 100644 index 28cfdf14c..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js +++ /dev/null @@ -1,326 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import ReactDOM from 'react-dom'; -import { Grid, WindowScroller } from 'react-virtualized'; -import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; -import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; -import dimensions from 'Styles/Variables/dimensions'; -import { sortDirections } from 'Helpers/Props'; -import Measure from 'Components/Measure'; -import ArtistIndexItemConnector from 'Artist/Index/ArtistIndexItemConnector'; -import ArtistIndexBanner from './ArtistIndexBanner'; -import styles from './ArtistIndexBanners.css'; - -// container dimensions -const columnPadding = parseInt(dimensions.artistIndexColumnPadding); -const columnPaddingSmallScreen = parseInt(dimensions.artistIndexColumnPaddingSmallScreen); -const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); -const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); - -const additionalColumnCount = { - small: 3, - medium: 2, - large: 1 -}; - -function calculateColumnWidth(width, bannerSize, isSmallScreen) { - const maxiumColumnWidth = isSmallScreen ? 344 : 364; - const columns = Math.floor(width / maxiumColumnWidth); - const remainder = width % maxiumColumnWidth; - - if (remainder === 0 && bannerSize === 'large') { - return maxiumColumnWidth; - } - - return Math.floor(width / (columns + additionalColumnCount[bannerSize])); -} - -function calculateRowHeight(bannerHeight, sortKey, isSmallScreen, bannerOptions) { - const { - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile - } = bannerOptions; - - const nextAiringHeight = 19; - - const heights = [ - bannerHeight, - detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, - nextAiringHeight, - isSmallScreen ? columnPaddingSmallScreen : columnPadding - ]; - - if (showTitle) { - heights.push(19); - } - - if (showMonitored) { - heights.push(19); - } - - if (showQualityProfile) { - heights.push(19); - } - - switch (sortKey) { - case 'seasons': - case 'previousAiring': - case 'added': - case 'path': - case 'sizeOnDisk': - heights.push(19); - break; - case 'qualityProfileId': - if (!showQualityProfile) { - heights.push(19); - } - break; - default: - // No need to add a height of 0 - } - - return heights.reduce((acc, height) => acc + height, 0); -} - -function calculateHeight(bannerWidth) { - return Math.ceil((88/476) * bannerWidth); -} - -class ArtistIndexBanners extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - width: 0, - columnWidth: 364, - columnCount: 1, - bannerWidth: 476, - bannerHeight: 88, - rowHeight: calculateRowHeight(88, null, props.isSmallScreen, {}) - }; - - this._isInitialized = false; - this._grid = null; - } - - componentDidMount() { - this._contentBodyNode = ReactDOM.findDOMNode(this.props.contentBody); - } - - componentDidUpdate(prevProps) { - const { - items, - filters, - sortKey, - sortDirection, - bannerOptions, - jumpToCharacter - } = this.props; - - const itemsChanged = hasDifferentItems(prevProps.items, items); - - if ( - prevProps.sortKey !== sortKey || - prevProps.bannerOptions !== bannerOptions || - itemsChanged - ) { - this.calculateGrid(); - } - - if ( - prevProps.filters !== filters || - prevProps.sortKey !== sortKey || - prevProps.sortDirection !== sortDirection || - itemsChanged - ) { - this._grid.recomputeGridSize(); - } - - if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { - const index = getIndexOfFirstCharacter(items, jumpToCharacter); - - if (index != null) { - const { - columnCount, - rowHeight - } = this.state; - - const row = Math.floor(index / columnCount); - const scrollTop = rowHeight * row; - - this.props.onScroll({ scrollTop }); - } - } - } - - // - // Control - - setGridRef = (ref) => { - this._grid = ref; - } - - calculateGrid = (width = this.state.width, isSmallScreen) => { - const { - sortKey, - bannerOptions - } = this.props; - - const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding; - const columnWidth = calculateColumnWidth(width, bannerOptions.size, isSmallScreen); - const columnCount = Math.max(Math.floor(width / columnWidth), 1); - const bannerWidth = columnWidth - padding; - const bannerHeight = calculateHeight(bannerWidth); - const rowHeight = calculateRowHeight(bannerHeight, sortKey, isSmallScreen, bannerOptions); - - this.setState({ - width, - columnWidth, - columnCount, - bannerWidth, - bannerHeight, - rowHeight - }); - } - - cellRenderer = ({ key, rowIndex, columnIndex, style }) => { - const { - items, - sortKey, - bannerOptions, - showRelativeDates, - shortDateFormat, - timeFormat - } = this.props; - - const { - bannerWidth, - bannerHeight, - columnCount - } = this.state; - - const { - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile - } = bannerOptions; - - const artist = items[rowIndex * columnCount + columnIndex]; - - if (!artist) { - return null; - } - - return ( - - ); - } - - // - // Listeners - - onMeasure = ({ width }) => { - this.calculateGrid(width, this.props.isSmallScreen); - } - - onSectionRendered = () => { - if (!this._isInitialized && this._contentBodyNode) { - this.props.onRender(); - this._isInitialized = true; - } - } - - // - // Render - - render() { - const { - items, - scrollTop, - isSmallScreen, - onScroll - } = this.props; - - const { - width, - columnWidth, - columnCount, - rowHeight - } = this.state; - - const rowCount = Math.ceil(items.length / columnCount); - - return ( - - - {({ height, isScrolling }) => { - return ( - - ); - } - } - - - ); - } -} - -ArtistIndexBanners.propTypes = { - items: PropTypes.arrayOf(PropTypes.object).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - bannerOptions: PropTypes.object.isRequired, - scrollTop: PropTypes.number.isRequired, - jumpToCharacter: PropTypes.string, - contentBody: PropTypes.object.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - timeFormat: PropTypes.string.isRequired, - onRender: PropTypes.func.isRequired, - onScroll: PropTypes.func.isRequired -}; - -export default ArtistIndexBanners; diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.tsx b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.tsx new file mode 100644 index 000000000..3582da097 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.tsx @@ -0,0 +1,304 @@ +import { throttle } from 'lodash'; +import React, { RefObject, useEffect, useMemo, useRef, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { FixedSizeGrid as Grid, GridChildComponentProps } from 'react-window'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import Artist from 'Artist/Artist'; +import ArtistIndexBanner from 'Artist/Index/Banners/ArtistIndexBanner'; +import useMeasure from 'Helpers/Hooks/useMeasure'; +import SortDirection from 'Helpers/Props/SortDirection'; +import dimensions from 'Styles/Variables/dimensions'; +import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; + +const bodyPadding = parseInt(dimensions.pageContentBodyPadding); +const bodyPaddingSmallScreen = parseInt( + dimensions.pageContentBodyPaddingSmallScreen +); +const columnPadding = parseInt(dimensions.artistIndexColumnPadding); +const columnPaddingSmallScreen = parseInt( + dimensions.artistIndexColumnPaddingSmallScreen +); +const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); +const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); + +const ADDITIONAL_COLUMN_COUNT: Record = { + small: 3, + medium: 2, + large: 1, +}; + +interface CellItemData { + layout: { + columnCount: number; + padding: number; + bannerWidth: number; + bannerHeight: number; + }; + items: Artist[]; + sortKey: string; + isSelectMode: boolean; +} + +interface ArtistIndexBannersProps { + items: Artist[]; + sortKey: string; + sortDirection?: SortDirection; + jumpToCharacter?: string; + scrollTop?: number; + scrollerRef: RefObject; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +const artistIndexSelector = createSelector( + (state: AppState) => state.artistIndex.bannerOptions, + (bannerOptions) => { + return { + bannerOptions, + }; + } +); + +const Cell: React.FC> = ({ + columnIndex, + rowIndex, + style, + data, +}) => { + const { layout, items, sortKey, isSelectMode } = data; + const { columnCount, padding, bannerWidth, bannerHeight } = layout; + const index = rowIndex * columnCount + columnIndex; + + if (index >= items.length) { + return null; + } + + const artist = items[index]; + + return ( +
+ +
+ ); +}; + +function getWindowScrollTopPosition() { + return document.documentElement.scrollTop || document.body.scrollTop || 0; +} + +export default function ArtistIndexBanners(props: ArtistIndexBannersProps) { + const { + scrollerRef, + items, + sortKey, + jumpToCharacter, + isSelectMode, + isSmallScreen, + } = props; + + const { bannerOptions } = useSelector(artistIndexSelector); + const ref = useRef(null); + const [measureRef, bounds] = useMeasure(); + const [size, setSize] = useState({ width: 0, height: 0 }); + + const columnWidth = useMemo(() => { + const { width } = size; + const maximumColumnWidth = isSmallScreen ? 344 : 364; + const columns = Math.floor(width / maximumColumnWidth); + const remainder = width % maximumColumnWidth; + return remainder === 0 + ? maximumColumnWidth + : Math.floor( + width / (columns + ADDITIONAL_COLUMN_COUNT[bannerOptions.size]) + ); + }, [isSmallScreen, bannerOptions, size]); + + const columnCount = useMemo( + () => Math.max(Math.floor(size.width / columnWidth), 1), + [size, columnWidth] + ); + const padding = props.isSmallScreen + ? columnPaddingSmallScreen + : columnPadding; + const bannerWidth = columnWidth - padding * 2; + const bannerHeight = Math.ceil((88 / 476) * bannerWidth); + + const rowHeight = useMemo(() => { + const { + detailedProgressBar, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + } = bannerOptions; + + const nextAiringHeight = 19; + + const heights = [ + bannerHeight, + detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, + nextAiringHeight, + isSmallScreen ? columnPaddingSmallScreen : columnPadding, + ]; + + if (showTitle) { + heights.push(19); + } + + if (showMonitored) { + heights.push(19); + } + + if (showQualityProfile) { + heights.push(19); + } + + if (showNextAlbum) { + heights.push(19); + } + + switch (sortKey) { + case 'artistType': + case 'metadataProfileId': + case 'lastAlbum': + case 'added': + case 'albumCount': + case 'path': + case 'sizeOnDisk': + case 'tags': + heights.push(19); + break; + case 'qualityProfileId': + if (!showQualityProfile) { + heights.push(19); + } + break; + case 'nextAlbum': + if (!showNextAlbum) { + heights.push(19); + } + break; + default: + // No need to add a height of 0 + } + + return heights.reduce((acc, height) => acc + height, 0); + }, [isSmallScreen, bannerOptions, sortKey, bannerHeight]); + + useEffect(() => { + const current = scrollerRef.current; + + if (isSmallScreen) { + const padding = bodyPaddingSmallScreen - 5; + + setSize({ + width: window.innerWidth - padding * 2, + height: window.innerHeight, + }); + + return; + } + + if (current) { + const width = current.clientWidth; + const padding = bodyPadding - 5; + + setSize({ + width: width - padding * 2, + height: window.innerHeight, + }); + } + }, [isSmallScreen, scrollerRef, bounds]); + + useEffect(() => { + const currentScrollerRef = scrollerRef.current as HTMLElement; + const currentScrollListener = isSmallScreen ? window : currentScrollerRef; + + const handleScroll = throttle(() => { + const { offsetTop = 0 } = currentScrollerRef; + const scrollTop = + (isSmallScreen + ? getWindowScrollTopPosition() + : currentScrollerRef.scrollTop) - offsetTop; + + ref.current?.scrollTo({ scrollLeft: 0, scrollTop }); + }, 10); + + currentScrollListener.addEventListener('scroll', handleScroll); + + return () => { + handleScroll.cancel(); + + if (currentScrollListener) { + currentScrollListener.removeEventListener('scroll', handleScroll); + } + }; + }, [isSmallScreen, ref, scrollerRef]); + + useEffect(() => { + if (jumpToCharacter) { + const index = getIndexOfFirstCharacter(items, jumpToCharacter); + + if (index != null) { + const rowIndex = Math.floor(index / columnCount); + + const scrollTop = rowIndex * rowHeight + padding; + + ref.current?.scrollTo({ scrollLeft: 0, scrollTop }); + scrollerRef.current?.scrollTo(0, scrollTop); + } + } + }, [ + jumpToCharacter, + rowHeight, + columnCount, + padding, + items, + scrollerRef, + ref, + ]); + + return ( +
+ + ref={ref} + style={{ + width: '100%', + height: '100%', + overflow: 'none', + }} + width={size.width} + height={size.height} + columnCount={columnCount} + columnWidth={columnWidth} + rowCount={Math.ceil(items.length / columnCount)} + rowHeight={rowHeight} + itemData={{ + layout: { + columnCount, + padding, + bannerWidth, + bannerHeight, + }, + items, + sortKey, + isSelectMode, + }} + > + {Cell} + +
+ ); +} diff --git a/frontend/src/Artist/Index/Banners/ArtistIndexBannersConnector.js b/frontend/src/Artist/Index/Banners/ArtistIndexBannersConnector.js deleted file mode 100644 index bac56ebd2..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBannersConnector.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import ArtistIndexBanners from './ArtistIndexBanners'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex.bannerOptions, - createUISettingsSelector(), - createDimensionsSelector(), - (bannerOptions, uiSettings, dimensions) => { - return { - bannerOptions, - showRelativeDates: uiSettings.showRelativeDates, - shortDateFormat: uiSettings.shortDateFormat, - timeFormat: uiSettings.timeFormat, - isSmallScreen: dimensions.isSmallScreen - }; - } - ); -} - -export default connect(createMapStateToProps)(ArtistIndexBanners); diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.js b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.js deleted file mode 100644 index 34c8abfcf..000000000 --- a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.js +++ /dev/null @@ -1,25 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Modal from 'Components/Modal/Modal'; -import ArtistIndexBannerOptionsModalContentConnector from './ArtistIndexBannerOptionsModalContentConnector'; - -function ArtistIndexBannerOptionsModal({ isOpen, onModalClose, ...otherProps }) { - return ( - - - - ); -} - -ArtistIndexBannerOptionsModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexBannerOptionsModal; diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.tsx b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.tsx new file mode 100644 index 000000000..156e06079 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import ArtistIndexBannerOptionsModalContent from './ArtistIndexBannerOptionsModalContent'; + +interface ArtistIndexBannerOptionsModalProps { + isOpen: boolean; + onModalClose(...args: unknown[]): unknown; +} + +function ArtistIndexBannerOptionsModal({ + isOpen, + onModalClose, +}: ArtistIndexBannerOptionsModalProps) { + return ( + + + + ); +} + +export default ArtistIndexBannerOptionsModal; diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.js b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.js deleted file mode 100644 index 6bfcad0bb..000000000 --- a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.js +++ /dev/null @@ -1,213 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { inputTypes } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import Form from 'Components/Form/Form'; -import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; - -const bannerSizeOptions = [ - { key: 'small', value: 'Small' }, - { key: 'medium', value: 'Medium' }, - { key: 'large', value: 'Large' } -]; - -class ArtistIndexBannerOptionsModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - detailedProgressBar: props.detailedProgressBar, - size: props.size, - showTitle: props.showTitle, - showMonitored: props.showMonitored, - showQualityProfile: props.showQualityProfile, - showSearchAction: props.showSearchAction - }; - } - - componentDidUpdate(prevProps) { - const { - detailedProgressBar, - size, - showTitle, - showMonitored, - showQualityProfile, - showSearchAction - } = this.props; - - const state = {}; - - if (detailedProgressBar !== prevProps.detailedProgressBar) { - state.detailedProgressBar = detailedProgressBar; - } - - if (size !== prevProps.size) { - state.size = size; - } - - if (showTitle !== prevProps.showTitle) { - state.showTitle = showTitle; - } - - if (showMonitored !== prevProps.showMonitored) { - state.showMonitored = showMonitored; - } - - if (showQualityProfile !== prevProps.showQualityProfile) { - state.showQualityProfile = showQualityProfile; - } - - if (showSearchAction !== prevProps.showSearchAction) { - state.showSearchAction = showSearchAction; - } - - if (!_.isEmpty(state)) { - this.setState(state); - } - } - - // - // Listeners - - onChangeBannerOption = ({ name, value }) => { - this.setState({ - [name]: value - }, () => { - this.props.onChangeBannerOption({ [name]: value }); - }); - } - - // - // Render - - render() { - const { - onModalClose - } = this.props; - - const { - detailedProgressBar, - size, - showTitle, - showMonitored, - showQualityProfile, - showSearchAction - } = this.state; - - return ( - - - Options - - - -
- - Size - - - - - - Detailed Progress Bar - - - - - - Show Name - - - - - - Show Monitored - - - - - - Show Quality Profile - - - - - - Show Search - - - -
-
- - - - -
- ); - } -} - -ArtistIndexBannerOptionsModalContent.propTypes = { - size: PropTypes.string.isRequired, - showTitle: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - detailedProgressBar: PropTypes.bool.isRequired, - showSearchAction: PropTypes.bool.isRequired, - onChangeBannerOption: PropTypes.func.isRequired, - showMonitored: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexBannerOptionsModalContent; diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.tsx b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.tsx new file mode 100644 index 000000000..f889ea450 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.tsx @@ -0,0 +1,167 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import selectBannerOptions from 'Artist/Index/Banners/selectBannerOptions'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes } from 'Helpers/Props'; +import { setArtistBannerOption } from 'Store/Actions/artistIndexActions'; +import translate from 'Utilities/String/translate'; + +const bannerSizeOptions = [ + { + key: 'small', + get value() { + return translate('Small'); + }, + }, + { + key: 'medium', + get value() { + return translate('Medium'); + }, + }, + { + key: 'large', + get value() { + return translate('Large'); + }, + }, +]; + +interface ArtistIndexBannerOptionsModalContentProps { + onModalClose(...args: unknown[]): unknown; +} + +function ArtistIndexBannerOptionsModalContent( + props: ArtistIndexBannerOptionsModalContentProps +) { + const { onModalClose } = props; + + const bannerOptions = useSelector(selectBannerOptions); + + const { + detailedProgressBar, + size, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + showSearchAction, + } = bannerOptions; + + const dispatch = useDispatch(); + + const onBannerOptionChange = useCallback( + ({ name, value }: { name: string; value: unknown }) => { + dispatch(setArtistBannerOption({ [name]: value })); + }, + [dispatch] + ); + + return ( + + {translate('BannerOptions')} + + +
+ + {translate('BannerSize')} + + + + + + {translate('DetailedProgressBar')} + + + + + + {translate('ShowName')} + + + + + + {translate('ShowMonitored')} + + + + + + {translate('ShowQualityProfile')} + + + + + + {translate('ShowNextAlbum')} + + + + + + {translate('ShowSearch')} + + + +
+
+ + + + +
+ ); +} + +export default ArtistIndexBannerOptionsModalContent; diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContentConnector.js b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContentConnector.js deleted file mode 100644 index 884edd05d..000000000 --- a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContentConnector.js +++ /dev/null @@ -1,23 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setArtistBannerOption } from 'Store/Actions/artistIndexActions'; -import ArtistIndexBannerOptionsModalContent from './ArtistIndexBannerOptionsModalContent'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex, - (artistIndex) => { - return artistIndex.bannerOptions; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onChangeBannerOption(payload) { - dispatch(setArtistBannerOption(payload)); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(ArtistIndexBannerOptionsModalContent); diff --git a/frontend/src/Artist/Index/Banners/selectBannerOptions.ts b/frontend/src/Artist/Index/Banners/selectBannerOptions.ts new file mode 100644 index 000000000..529c15e06 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/selectBannerOptions.ts @@ -0,0 +1,9 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +const selectBannerOptions = createSelector( + (state: AppState) => state.artistIndex.bannerOptions, + (bannerOptions) => bannerOptions +); + +export default selectBannerOptions; diff --git a/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.js b/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.js deleted file mode 100644 index 818e83311..000000000 --- a/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.js +++ /dev/null @@ -1,41 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { align } from 'Helpers/Props'; -import FilterMenu from 'Components/Menu/FilterMenu'; -import ArtistIndexFilterModalConnector from 'Artist/Index/ArtistIndexFilterModalConnector'; - -function ArtistIndexFilterMenu(props) { - const { - selectedFilterKey, - filters, - customFilters, - isDisabled, - onFilterSelect - } = props; - - return ( - - ); -} - -ArtistIndexFilterMenu.propTypes = { - selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - customFilters: PropTypes.arrayOf(PropTypes.object).isRequired, - isDisabled: PropTypes.bool.isRequired, - onFilterSelect: PropTypes.func.isRequired -}; - -ArtistIndexFilterMenu.defaultProps = { - showCustomFilters: false -}; - -export default ArtistIndexFilterMenu; diff --git a/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.tsx b/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.tsx new file mode 100644 index 000000000..91ebbef2d --- /dev/null +++ b/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.tsx @@ -0,0 +1,41 @@ +import React from 'react'; +import { CustomFilter } from 'App/State/AppState'; +import ArtistIndexFilterModal from 'Artist/Index/ArtistIndexFilterModal'; +import FilterMenu from 'Components/Menu/FilterMenu'; +import { align } from 'Helpers/Props'; + +interface ArtistIndexFilterMenuProps { + selectedFilterKey: string | number; + filters: object[]; + customFilters: CustomFilter[]; + isDisabled: boolean; + onFilterSelect(filterName: string): unknown; +} + +function ArtistIndexFilterMenu(props: ArtistIndexFilterMenuProps) { + const { + selectedFilterKey, + filters, + customFilters, + isDisabled, + onFilterSelect, + } = props; + + return ( + + ); +} + +ArtistIndexFilterMenu.defaultProps = { + showCustomFilters: false, +}; + +export default ArtistIndexFilterMenu; diff --git a/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.js b/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.tsx similarity index 70% rename from frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.js rename to frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.tsx index fc5854648..1b72d0f4c 100644 --- a/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.js +++ b/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.tsx @@ -1,23 +1,23 @@ -import PropTypes from 'prop-types'; import React from 'react'; -import { align, sortDirections } from 'Helpers/Props'; -import SortMenu from 'Components/Menu/SortMenu'; import MenuContent from 'Components/Menu/MenuContent'; +import SortMenu from 'Components/Menu/SortMenu'; import SortMenuItem from 'Components/Menu/SortMenuItem'; +import { align } from 'Helpers/Props'; +import SortDirection from 'Helpers/Props/SortDirection'; +import translate from 'Utilities/String/translate'; -function ArtistIndexSortMenu(props) { - const { - sortKey, - sortDirection, - isDisabled, - onSortSelect - } = props; +interface SeriesIndexSortMenuProps { + sortKey?: string; + sortDirection?: SortDirection; + isDisabled: boolean; + onSortSelect(sortKey: string): unknown; +} + +function ArtistIndexSortMenu(props: SeriesIndexSortMenuProps) { + const { sortKey, sortDirection, isDisabled, onSortSelect } = props; return ( - + - Monitored/Status + {translate('MonitoredStatus')} - Name + {translate('Name')} - Type + {translate('Type')} - Quality Profile + {translate('QualityProfile')} - Metadata Profile + {translate('MetadataProfile')} - Next Album + {translate('NextAlbum')} - Last Album + {translate('LastAlbum')} - Added + {translate('Added')} - Albums + {translate('Albums')} - Tracks + {translate('Tracks')} - Track Count + {translate('TrackCount')} - Path + {translate('Path')} - Size on Disk + {translate('SizeOnDisk')} + + + + {translate('Tags')} ); } -ArtistIndexSortMenu.propTypes = { - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - isDisabled: PropTypes.bool.isRequired, - onSortSelect: PropTypes.func.isRequired -}; - export default ArtistIndexSortMenu; diff --git a/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.js b/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.js deleted file mode 100644 index 46ca03b9f..000000000 --- a/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.js +++ /dev/null @@ -1,63 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { align } from 'Helpers/Props'; -import ViewMenu from 'Components/Menu/ViewMenu'; -import MenuContent from 'Components/Menu/MenuContent'; -import ViewMenuItem from 'Components/Menu/ViewMenuItem'; - -function ArtistIndexViewMenu(props) { - const { - view, - isDisabled, - onViewSelect - } = props; - - return ( - - - - Table - - - - Posters - - - - Banners - - - - Overview - - - - ); -} - -ArtistIndexViewMenu.propTypes = { - view: PropTypes.string.isRequired, - isDisabled: PropTypes.bool.isRequired, - onViewSelect: PropTypes.func.isRequired -}; - -export default ArtistIndexViewMenu; diff --git a/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.tsx b/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.tsx new file mode 100644 index 000000000..bb88d9149 --- /dev/null +++ b/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import MenuContent from 'Components/Menu/MenuContent'; +import ViewMenu from 'Components/Menu/ViewMenu'; +import ViewMenuItem from 'Components/Menu/ViewMenuItem'; +import { align } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; + +interface ArtistIndexViewMenuProps { + view: string; + isDisabled: boolean; + onViewSelect(value: string): unknown; +} + +function ArtistIndexViewMenu(props: ArtistIndexViewMenuProps) { + const { view, isDisabled, onViewSelect } = props; + + return ( + + + + {translate('Table')} + + + + {translate('Posters')} + + + + {translate('Banners')} + + + + {translate('Overview')} + + + + ); +} + +export default ArtistIndexViewMenu; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css index 054319ebc..1f482a2d6 100644 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css @@ -1,13 +1,5 @@ $hoverScale: 1.05; -.container { - &:hover { - .content { - background-color: $tableRowHoverBackgroundColor; - } - } -} - .content { display: flex; flex-grow: 1; @@ -25,10 +17,10 @@ $hoverScale: 1.05; composes: link from '~Components/Link/Link.css'; display: block; - color: $defaultColor; + color: var(--defaultColor); &:hover { - color: $defaultColor; + color: var(--defaultColor); text-decoration: none; } } @@ -42,8 +34,8 @@ $hoverScale: 1.05; height: 0; border-width: 0 25px 25px 0; border-style: solid; - border-color: transparent $dangerColor transparent transparent; - color: $white; + border-color: transparent var(--dangerColor) transparent transparent; + color: var(--white); } .info { diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css.d.ts b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css.d.ts new file mode 100644 index 000000000..de94277cc --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css.d.ts @@ -0,0 +1,17 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'content': string; + 'details': string; + 'ended': string; + 'info': string; + 'link': string; + 'overview': string; + 'poster': string; + 'posterContainer': string; + 'title': string; + 'titleRow': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.js deleted file mode 100644 index 6be34d622..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.js +++ /dev/null @@ -1,284 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import TextTruncate from 'react-text-truncate'; -import { icons } from 'Helpers/Props'; -import dimensions from 'Styles/Variables/dimensions'; -import fonts from 'Styles/Variables/fonts'; -import IconButton from 'Components/Link/IconButton'; -import Link from 'Components/Link/Link'; -import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; -import ArtistPoster from 'Artist/ArtistPoster'; -import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; -import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; -import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; -import ArtistIndexOverviewInfo from './ArtistIndexOverviewInfo'; -import styles from './ArtistIndexOverview.css'; - -const columnPadding = parseInt(dimensions.artistIndexColumnPadding); -const columnPaddingSmallScreen = parseInt(dimensions.artistIndexColumnPaddingSmallScreen); -const defaultFontSize = parseInt(fonts.defaultFontSize); -const lineHeight = parseFloat(fonts.lineHeight); - -// Hardcoded height beased on line-height of 32 + bottom margin of 10. -// Less side-effecty than using react-measure. -const titleRowHeight = 42; - -function getContentHeight(rowHeight, isSmallScreen) { - const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding; - - return rowHeight - padding; -} - -class ArtistIndexOverview extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: false - }; - } - - // - // Listeners - - onEditArtistPress = () => { - this.setState({ isEditArtistModalOpen: true }); - } - - onEditArtistModalClose = () => { - this.setState({ isEditArtistModalOpen: false }); - } - - onDeleteArtistPress = () => { - this.setState({ - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: true - }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - // - // Render - - render() { - const { - style, - id, - artistName, - overview, - monitored, - status, - foreignArtistId, - nextAiring, - statistics, - images, - posterWidth, - posterHeight, - qualityProfile, - overviewOptions, - showSearchAction, - showRelativeDates, - shortDateFormat, - longDateFormat, - timeFormat, - rowHeight, - isSmallScreen, - isRefreshingArtist, - isSearchingArtist, - onRefreshArtistPress, - onSearchPress, - ...otherProps - } = this.props; - - const { - albumCount, - sizeOnDisk, - trackCount, - trackFileCount, - totalTrackCount - } = statistics; - - const { - isEditArtistModalOpen, - isDeleteArtistModalOpen - } = this.state; - - const link = `/artist/${foreignArtistId}`; - - const elementStyle = { - width: `${posterWidth}px`, - height: `${posterHeight}px` - }; - - const contentHeight = getContentHeight(rowHeight, isSmallScreen); - const overviewHeight = contentHeight - titleRowHeight; - - return ( -
-
-
-
- { - status === 'ended' && -
- } - - - - -
- - -
- -
-
- - {artistName} - - -
- - - { - showSearchAction && - - } - - -
-
- -
- - - - - - -
-
-
- - - - -
- ); - } -} - -ArtistIndexOverview.propTypes = { - style: PropTypes.object.isRequired, - id: PropTypes.number.isRequired, - artistName: PropTypes.string.isRequired, - overview: PropTypes.string.isRequired, - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - nextAiring: PropTypes.string, - statistics: PropTypes.object.isRequired, - images: PropTypes.arrayOf(PropTypes.object).isRequired, - posterWidth: PropTypes.number.isRequired, - posterHeight: PropTypes.number.isRequired, - rowHeight: PropTypes.number.isRequired, - qualityProfile: PropTypes.object.isRequired, - overviewOptions: PropTypes.object.isRequired, - showSearchAction: PropTypes.bool.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - longDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - isSearchingArtist: PropTypes.bool.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired, - onSearchPress: PropTypes.func.isRequired -}; - -ArtistIndexOverview.defaultProps = { - statistics: { - albumCount: 0, - trackCount: 0, - trackFileCount: 0, - totalTrackCount: 0 - } -}; - -export default ArtistIndexOverview; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.tsx b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.tsx new file mode 100644 index 000000000..ebef28264 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.tsx @@ -0,0 +1,249 @@ +import React, { useCallback, useMemo, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import TextTruncate from 'react-text-truncate'; +import { Statistics } from 'Artist/Artist'; +import ArtistPoster from 'Artist/ArtistPoster'; +import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; +import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; +import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; +import ArtistIndexPosterSelect from 'Artist/Index/Select/ArtistIndexPosterSelect'; +import { ARTIST_SEARCH, REFRESH_ARTIST } from 'Commands/commandNames'; +import IconButton from 'Components/Link/IconButton'; +import Link from 'Components/Link/Link'; +import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; +import { icons } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import dimensions from 'Styles/Variables/dimensions'; +import fonts from 'Styles/Variables/fonts'; +import translate from 'Utilities/String/translate'; +import createArtistIndexItemSelector from '../createArtistIndexItemSelector'; +import ArtistIndexOverviewInfo from './ArtistIndexOverviewInfo'; +import selectOverviewOptions from './selectOverviewOptions'; +import styles from './ArtistIndexOverview.css'; + +const columnPadding = parseInt(dimensions.artistIndexColumnPadding); +const columnPaddingSmallScreen = parseInt( + dimensions.artistIndexColumnPaddingSmallScreen +); +const defaultFontSize = parseInt(fonts.defaultFontSize); +const lineHeight = parseFloat(fonts.lineHeight); + +// Hardcoded height based on line-height of 32 + bottom margin of 10. +// Less side-effecty than using react-measure. +const TITLE_HEIGHT = 42; + +interface ArtistIndexOverviewProps { + artistId: number; + sortKey: string; + posterWidth: number; + posterHeight: number; + rowHeight: number; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +function ArtistIndexOverview(props: ArtistIndexOverviewProps) { + const { + artistId, + sortKey, + posterWidth, + posterHeight, + rowHeight, + isSelectMode, + isSmallScreen, + } = props; + + const { artist, qualityProfile, isRefreshingArtist, isSearchingArtist } = + useSelector(createArtistIndexItemSelector(props.artistId)); + + const overviewOptions = useSelector(selectOverviewOptions); + + const { + artistName, + monitored, + status, + path, + foreignArtistId, + nextAlbum, + lastAlbum, + added, + overview, + statistics = {} as Statistics, + images, + } = artist; + + const { + albumCount = 0, + sizeOnDisk = 0, + trackCount = 0, + trackFileCount = 0, + totalTrackCount = 0, + } = statistics; + + const dispatch = useDispatch(); + const [isEditArtistModalOpen, setIsEditArtistModalOpen] = useState(false); + const [isDeleteArtistModalOpen, setIsDeleteArtistModalOpen] = useState(false); + + const onRefreshPress = useCallback(() => { + dispatch( + executeCommand({ + name: REFRESH_ARTIST, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onSearchPress = useCallback(() => { + dispatch( + executeCommand({ + name: ARTIST_SEARCH, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onEditArtistPress = useCallback(() => { + setIsEditArtistModalOpen(true); + }, [setIsEditArtistModalOpen]); + + const onEditArtistModalClose = useCallback(() => { + setIsEditArtistModalOpen(false); + }, [setIsEditArtistModalOpen]); + + const onDeleteArtistPress = useCallback(() => { + setIsEditArtistModalOpen(false); + setIsDeleteArtistModalOpen(true); + }, [setIsDeleteArtistModalOpen]); + + const onDeleteArtistModalClose = useCallback(() => { + setIsDeleteArtistModalOpen(false); + }, [setIsDeleteArtistModalOpen]); + + const link = `/artist/${foreignArtistId}`; + + const elementStyle = { + width: `${posterWidth}px`, + height: `${posterHeight}px`, + }; + + const contentHeight = useMemo(() => { + const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding; + + return rowHeight - padding; + }, [rowHeight, isSmallScreen]); + + const overviewHeight = contentHeight - TITLE_HEIGHT; + + return ( +
+
+
+
+ {isSelectMode ? ( + + ) : null} + + {status === 'ended' && ( +
+ )} + + + + +
+ + +
+ +
+
+ + {artistName} + + +
+ + + {overviewOptions.showSearchAction ? ( + + ) : null} + + +
+
+ +
+ + + + + +
+
+
+ + + + +
+ ); +} + +export default ArtistIndexOverview; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.css.d.ts b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.css.d.ts new file mode 100644 index 000000000..eb2309a64 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'infos': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.js deleted file mode 100644 index f7839cab5..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.js +++ /dev/null @@ -1,250 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import formatDateTime from 'Utilities/Date/formatDateTime'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; -import formatBytes from 'Utilities/Number/formatBytes'; -import { icons } from 'Helpers/Props'; -import dimensions from 'Styles/Variables/dimensions'; -import ArtistIndexOverviewInfoRow from './ArtistIndexOverviewInfoRow'; -import styles from './ArtistIndexOverviewInfo.css'; - -const infoRowHeight = parseInt(dimensions.artistIndexOverviewInfoRowHeight); - -const rows = [ - { - name: 'monitored', - showProp: 'showMonitored', - valueProp: 'monitored' - - }, - { - name: 'qualityProfileId', - showProp: 'showQualityProfile', - valueProp: 'qualityProfileId' - }, - { - name: 'lastAlbum', - showProp: 'showLastAlbum', - valueProp: 'lastAlbum' - }, - { - name: 'added', - showProp: 'showAdded', - valueProp: 'added' - }, - { - name: 'albumCount', - showProp: 'showAlbumCount', - valueProp: 'albumCount' - }, - { - name: 'path', - showProp: 'showPath', - valueProp: 'path' - }, - { - name: 'sizeOnDisk', - showProp: 'showSizeOnDisk', - valueProp: 'sizeOnDisk' - } -]; - -function isVisible(row, props) { - const { - name, - showProp, - valueProp - } = row; - - if (props[valueProp] == null) { - return false; - } - - return props[showProp] || props.sortKey === name; -} - -function getInfoRowProps(row, props) { - const { name } = row; - - if (name === 'monitored') { - const monitoredText = props.monitored ? 'Monitored' : 'Unmonitored'; - - return { - title: monitoredText, - iconName: props.monitored ? icons.MONITORED : icons.UNMONITORED, - label: monitoredText - }; - } - - if (name === 'qualityProfileId') { - return { - title: 'Quality Profile', - iconName: icons.PROFILE, - label: props.qualityProfile.name - }; - } - - if (name === 'lastAlbum') { - const { - lastAlbum, - showRelativeDates, - shortDateFormat, - timeFormat - } = props; - - return { - title: `Last Album: ${lastAlbum.title}`, - iconName: icons.CALENDAR, - label: getRelativeDate( - lastAlbum.releaseDate, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - }; - } - - if (name === 'added') { - const { - added, - showRelativeDates, - shortDateFormat, - longDateFormat, - timeFormat - } = props; - - return { - title: `Added: ${formatDateTime(added, longDateFormat, timeFormat)}`, - iconName: icons.ADD, - label: getRelativeDate( - added, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - }; - } - - if (name === 'albumCount') { - const { albumCount } = props; - let albums = '1 album'; - - if (albumCount === 0) { - albums = 'No albums'; - } else if (albumCount > 1) { - albums = `${albumCount} albums`; - } - - return { - title: 'Album Count', - iconName: icons.CIRCLE, - label: albums - }; - } - - if (name === 'path') { - return { - title: 'Path', - iconName: icons.FOLDER, - label: props.path - }; - } - - if (name === 'sizeOnDisk') { - return { - title: 'Size on Disk', - iconName: icons.DRIVE, - label: formatBytes(props.sizeOnDisk) - }; - } -} - -function ArtistIndexOverviewInfo(props) { - const { - height, - nextAiring, - showRelativeDates, - shortDateFormat, - longDateFormat, - timeFormat - } = props; - - let shownRows = 1; - - const maxRows = Math.floor(height / (infoRowHeight + 4)); - - return ( -
- { - !!nextAiring && - - } - - { - rows.map((row) => { - if (!isVisible(row, props)) { - return null; - } - - if (shownRows >= maxRows) { - return null; - } - - shownRows++; - - const infoRowProps = getInfoRowProps(row, props); - - return ( - - ); - }) - } -
- ); -} - -ArtistIndexOverviewInfo.propTypes = { - height: PropTypes.number.isRequired, - showMonitored: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - showAdded: PropTypes.bool.isRequired, - showAlbumCount: PropTypes.bool.isRequired, - showPath: PropTypes.bool.isRequired, - showSizeOnDisk: PropTypes.bool.isRequired, - monitored: PropTypes.bool.isRequired, - nextAiring: PropTypes.string, - qualityProfile: PropTypes.object.isRequired, - lastAlbum: PropTypes.object, - added: PropTypes.string, - albumCount: PropTypes.number.isRequired, - path: PropTypes.string.isRequired, - sizeOnDisk: PropTypes.number, - sortKey: PropTypes.string.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - longDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired -}; - -export default ArtistIndexOverviewInfo; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.tsx b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.tsx new file mode 100644 index 000000000..c95d34b84 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.tsx @@ -0,0 +1,260 @@ +import { IconDefinition } from '@fortawesome/free-regular-svg-icons'; +import React, { useMemo } from 'react'; +import { useSelector } from 'react-redux'; +import Album from 'Album/Album'; +import { icons } from 'Helpers/Props'; +import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; +import dimensions from 'Styles/Variables/dimensions'; +import QualityProfile from 'typings/QualityProfile'; +import UiSettings from 'typings/Settings/UiSettings'; +import formatDateTime from 'Utilities/Date/formatDateTime'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import ArtistIndexOverviewInfoRow from './ArtistIndexOverviewInfoRow'; +import styles from './ArtistIndexOverviewInfo.css'; + +interface RowProps { + name: string; + showProp: string; + valueProp: string; +} + +interface RowInfoProps { + title: string; + iconName: IconDefinition; + label: string; +} + +interface ArtistIndexOverviewInfoProps { + height: number; + showMonitored: boolean; + showQualityProfile: boolean; + showLastAlbum: boolean; + showAdded: boolean; + showAlbumCount: boolean; + showPath: boolean; + showSizeOnDisk: boolean; + monitored: boolean; + nextAlbum?: Album; + qualityProfile?: QualityProfile; + lastAlbum?: Album; + added?: string; + albumCount: number; + path: string; + sizeOnDisk?: number; + sortKey: string; +} + +const infoRowHeight = parseInt(dimensions.artistIndexOverviewInfoRowHeight); + +const rows = [ + { + name: 'monitored', + showProp: 'showMonitored', + valueProp: 'monitored', + }, + { + name: 'qualityProfileId', + showProp: 'showQualityProfile', + valueProp: 'qualityProfile', + }, + { + name: 'lastAlbum', + showProp: 'showLastAlbum', + valueProp: 'lastAlbum', + }, + { + name: 'added', + showProp: 'showAdded', + valueProp: 'added', + }, + { + name: 'albumCount', + showProp: 'showAlbumCount', + valueProp: 'albumCount', + }, + { + name: 'path', + showProp: 'showPath', + valueProp: 'path', + }, + { + name: 'sizeOnDisk', + showProp: 'showSizeOnDisk', + valueProp: 'sizeOnDisk', + }, +]; + +function getInfoRowProps( + row: RowProps, + props: ArtistIndexOverviewInfoProps, + uiSettings: UiSettings +): RowInfoProps | null { + const { name } = row; + + if (name === 'monitored') { + const monitoredText = props.monitored + ? translate('Monitored') + : translate('Unmonitored'); + + return { + title: monitoredText, + iconName: props.monitored ? icons.MONITORED : icons.UNMONITORED, + label: monitoredText, + }; + } + + if (name === 'qualityProfileId' && !!props.qualityProfile?.name) { + return { + title: translate('QualityProfile'), + iconName: icons.PROFILE, + label: props.qualityProfile.name, + }; + } + + if (name === 'lastAlbum' && !!props.lastAlbum?.title) { + const lastAlbum = props.lastAlbum; + const { showRelativeDates, shortDateFormat, timeFormat } = uiSettings; + + return { + title: `Last Album: ${lastAlbum.title}`, + iconName: icons.CALENDAR, + label: + getRelativeDate( + lastAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + ) ?? '', + }; + } + + if (name === 'added') { + const added = props.added; + const { showRelativeDates, shortDateFormat, longDateFormat, timeFormat } = + uiSettings; + + return { + title: `Added: ${formatDateTime(added, longDateFormat, timeFormat)}`, + iconName: icons.ADD, + label: + getRelativeDate(added, shortDateFormat, showRelativeDates, { + timeFormat, + timeForToday: true, + }) ?? '', + }; + } + + if (name === 'albumCount') { + const { albumCount } = props; + let albums = '1 album'; + + if (albumCount === 0) { + albums = 'No albums'; + } else if (albumCount > 1) { + albums = `${albumCount} albums`; + } + + return { + title: translate('AlbumCount'), + iconName: icons.CIRCLE, + label: albums, + }; + } + + if (name === 'path') { + return { + title: translate('Path'), + iconName: icons.FOLDER, + label: props.path, + }; + } + + if (name === 'sizeOnDisk') { + return { + title: translate('SizeOnDisk'), + iconName: icons.DRIVE, + label: formatBytes(props.sizeOnDisk), + }; + } + + return null; +} + +function ArtistIndexOverviewInfo(props: ArtistIndexOverviewInfoProps) { + const { height, nextAlbum } = props; + + const uiSettings = useSelector(createUISettingsSelector()); + + const { shortDateFormat, showRelativeDates, longDateFormat, timeFormat } = + uiSettings; + + let shownRows = 1; + const maxRows = Math.floor(height / (infoRowHeight + 4)); + + const rowInfo = useMemo(() => { + return rows.map((row) => { + const { name, showProp, valueProp } = row; + + const isVisible = + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ts(7053) + props[valueProp] != null && (props[showProp] || props.sortKey === name); + + return { + ...row, + isVisible, + }; + }); + }, [props]); + + return ( +
+ {!!nextAlbum?.releaseDate && ( + + )} + + {rowInfo.map((row) => { + if (!row.isVisible) { + return null; + } + + if (shownRows >= maxRows) { + return null; + } + + shownRows++; + + const infoRowProps = getInfoRowProps(row, props, uiSettings); + + if (infoRowProps == null) { + return null; + } + + return ; + })} +
+ ); +} + +export default ArtistIndexOverviewInfo; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.css.d.ts b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.css.d.ts new file mode 100644 index 000000000..04f22fc2e --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'icon': string; + 'infoRow': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.js deleted file mode 100644 index b04029b88..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.js +++ /dev/null @@ -1,35 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Icon from 'Components/Icon'; -import styles from './ArtistIndexOverviewInfoRow.css'; - -function ArtistIndexOverviewInfoRow(props) { - const { - title, - iconName, - label - } = props; - - return ( -
- - - {label} -
- ); -} - -ArtistIndexOverviewInfoRow.propTypes = { - title: PropTypes.string, - iconName: PropTypes.object.isRequired, - label: PropTypes.string.isRequired -}; - -export default ArtistIndexOverviewInfoRow; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.tsx b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.tsx new file mode 100644 index 000000000..5d9b4a069 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.tsx @@ -0,0 +1,24 @@ +import { IconDefinition } from '@fortawesome/free-regular-svg-icons'; +import React from 'react'; +import Icon from 'Components/Icon'; +import styles from './ArtistIndexOverviewInfoRow.css'; + +interface ArtistIndexOverviewInfoRowProps { + title?: string; + iconName?: IconDefinition; + label: string | null; +} + +function ArtistIndexOverviewInfoRow(props: ArtistIndexOverviewInfoRowProps) { + const { title, iconName, label } = props; + + return ( +
+ + + {label} +
+ ); +} + +export default ArtistIndexOverviewInfoRow; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.css.d.ts b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.css.d.ts new file mode 100644 index 000000000..b97436b41 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'grid': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js deleted file mode 100644 index 8b23cdf95..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js +++ /dev/null @@ -1,289 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import ReactDOM from 'react-dom'; -import { Grid, WindowScroller } from 'react-virtualized'; -import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; -import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; -import dimensions from 'Styles/Variables/dimensions'; -import { sortDirections } from 'Helpers/Props'; -import Measure from 'Components/Measure'; -import ArtistIndexItemConnector from 'Artist/Index/ArtistIndexItemConnector'; -import ArtistIndexOverview from './ArtistIndexOverview'; -import styles from './ArtistIndexOverviews.css'; - -// Poster container dimensions -const columnPadding = parseInt(dimensions.artistIndexColumnPadding); -const columnPaddingSmallScreen = parseInt(dimensions.artistIndexColumnPaddingSmallScreen); -const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); -const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); - -function calculatePosterWidth(posterSize, isSmallScreen) { - const maxiumPosterWidth = isSmallScreen ? 192 : 202; - - if (posterSize === 'large') { - return maxiumPosterWidth; - } - - if (posterSize === 'medium') { - return Math.floor(maxiumPosterWidth * 0.75); - } - - return Math.floor(maxiumPosterWidth * 0.5); -} - -function calculateRowHeight(posterHeight, sortKey, isSmallScreen, overviewOptions) { - const { - detailedProgressBar - } = overviewOptions; - - const heights = [ - posterHeight, - detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, - isSmallScreen ? columnPaddingSmallScreen : columnPadding - ]; - - return heights.reduce((acc, height) => acc + height, 0); -} - -function calculatePosterHeight(posterWidth) { - return posterWidth; -} - -class ArtistIndexOverviews extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - width: 0, - columnCount: 1, - posterWidth: 238, - posterHeight: 238, - rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}) - }; - - this._isInitialized = false; - this._grid = null; - } - - componentDidMount() { - this._contentBodyNode = ReactDOM.findDOMNode(this.props.contentBody); - } - - componentDidUpdate(prevProps) { - const { - items, - filters, - sortKey, - sortDirection, - overviewOptions, - jumpToCharacter - } = this.props; - - const itemsChanged = hasDifferentItems(prevProps.items, items); - const overviewOptionsChanged = !_.isMatch(prevProps.overviewOptions, overviewOptions); - - if ( - prevProps.sortKey !== sortKey || - prevProps.overviewOptions !== overviewOptions || - itemsChanged - ) { - this.calculateGrid(); - } - - if ( - prevProps.filters !== filters || - prevProps.sortKey !== sortKey || - prevProps.sortDirection !== sortDirection || - itemsChanged || - overviewOptionsChanged - ) { - this._grid.recomputeGridSize(); - } - - if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { - const index = getIndexOfFirstCharacter(items, jumpToCharacter); - - if (index != null) { - const { - rowHeight - } = this.state; - - const scrollTop = rowHeight * index; - - this.props.onScroll({ scrollTop }); - } - } - } - - // - // Control - - scrollToFirstCharacter(character) { - const items = this.props.items; - const { - rowHeight - } = this.state; - - const index = getIndexOfFirstCharacter(items, character); - - if (index != null) { - const scrollTop = rowHeight * index; - - this.props.onScroll({ scrollTop }); - } - } - - setGridRef = (ref) => { - this._grid = ref; - } - - calculateGrid = (width = this.state.width, isSmallScreen) => { - const { - sortKey, - overviewOptions - } = this.props; - - const posterWidth = calculatePosterWidth(overviewOptions.size, isSmallScreen); - const posterHeight = calculatePosterHeight(posterWidth); - const rowHeight = calculateRowHeight(posterHeight, sortKey, isSmallScreen, overviewOptions); - - this.setState({ - width, - posterWidth, - posterHeight, - rowHeight - }); - } - - cellRenderer = ({ key, rowIndex, style }) => { - const { - items, - sortKey, - overviewOptions, - showRelativeDates, - shortDateFormat, - longDateFormat, - timeFormat, - isSmallScreen - } = this.props; - - const { - posterWidth, - posterHeight, - rowHeight - } = this.state; - - const artist = items[rowIndex]; - - if (!artist) { - return null; - } - - return ( - - ); - } - - // - // Listeners - - onMeasure = ({ width }) => { - this.calculateGrid(width, this.props.isSmallScreen); - } - - onSectionRendered = () => { - if (!this._isInitialized && this._contentBodyNode) { - this.props.onRender(); - this._isInitialized = true; - } - } - - // - // Render - - render() { - const { - items, - scrollTop, - isSmallScreen, - onScroll - } = this.props; - - const { - width, - rowHeight - } = this.state; - - return ( - - - {({ height, isScrolling }) => { - return ( - - ); - } - } - - - ); - } -} - -ArtistIndexOverviews.propTypes = { - items: PropTypes.arrayOf(PropTypes.object).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - overviewOptions: PropTypes.object.isRequired, - scrollTop: PropTypes.number.isRequired, - jumpToCharacter: PropTypes.string, - contentBody: PropTypes.object.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - longDateFormat: PropTypes.string.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - timeFormat: PropTypes.string.isRequired, - onRender: PropTypes.func.isRequired, - onScroll: PropTypes.func.isRequired -}; - -export default ArtistIndexOverviews; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.tsx b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.tsx new file mode 100644 index 000000000..11285c1b3 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.tsx @@ -0,0 +1,213 @@ +import { throttle } from 'lodash'; +import React, { RefObject, useEffect, useMemo, useRef, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { FixedSizeList as List, ListChildComponentProps } from 'react-window'; +import Artist from 'Artist/Artist'; +import useMeasure from 'Helpers/Hooks/useMeasure'; +import dimensions from 'Styles/Variables/dimensions'; +import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; +import ArtistIndexOverview from './ArtistIndexOverview'; +import selectOverviewOptions from './selectOverviewOptions'; + +// Poster container dimensions +const columnPadding = parseInt(dimensions.artistIndexColumnPadding); +const columnPaddingSmallScreen = parseInt( + dimensions.artistIndexColumnPaddingSmallScreen +); +const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); +const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); +const bodyPadding = parseInt(dimensions.pageContentBodyPadding); +const bodyPaddingSmallScreen = parseInt( + dimensions.pageContentBodyPaddingSmallScreen +); + +interface RowItemData { + items: Artist[]; + sortKey: string; + posterWidth: number; + posterHeight: number; + rowHeight: number; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +interface ArtistIndexOverviewsProps { + items: Artist[]; + sortKey: string; + sortDirection?: string; + jumpToCharacter?: string; + scrollTop?: number; + scrollerRef: RefObject; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +const Row: React.FC> = ({ + index, + style, + data, +}) => { + const { items, ...otherData } = data; + + if (index >= items.length) { + return null; + } + + const artist = items[index]; + + return ( +
+ +
+ ); +}; + +function getWindowScrollTopPosition() { + return document.documentElement.scrollTop || document.body.scrollTop || 0; +} + +function ArtistIndexOverviews(props: ArtistIndexOverviewsProps) { + const { + items, + sortKey, + jumpToCharacter, + scrollerRef, + isSelectMode, + isSmallScreen, + } = props; + + const { size: posterSize, detailedProgressBar } = useSelector( + selectOverviewOptions + ); + const listRef = useRef(null); + const [measureRef, bounds] = useMeasure(); + const [size, setSize] = useState({ width: 0, height: 0 }); + + const posterWidth = useMemo(() => { + const maxiumPosterWidth = isSmallScreen ? 192 : 202; + + if (posterSize === 'large') { + return maxiumPosterWidth; + } + + if (posterSize === 'medium') { + return Math.floor(maxiumPosterWidth * 0.75); + } + + return Math.floor(maxiumPosterWidth * 0.5); + }, [posterSize, isSmallScreen]); + + const posterHeight = useMemo(() => { + return posterWidth; + }, [posterWidth]); + + const rowHeight = useMemo(() => { + const heights = [ + posterHeight, + detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, + isSmallScreen ? columnPaddingSmallScreen : columnPadding, + ]; + + return heights.reduce((acc, height) => acc + height, 0); + }, [detailedProgressBar, posterHeight, isSmallScreen]); + + useEffect(() => { + const current = scrollerRef.current as HTMLElement; + + if (isSmallScreen) { + setSize({ + width: window.innerWidth, + height: window.innerHeight, + }); + + return; + } + + if (current) { + const width = current.clientWidth; + const padding = + (isSmallScreen ? bodyPaddingSmallScreen : bodyPadding) - 5; + + setSize({ + width: width - padding * 2, + height: window.innerHeight, + }); + } + }, [isSmallScreen, scrollerRef, bounds]); + + useEffect(() => { + const currentScrollerRef = scrollerRef.current as HTMLElement; + const currentScrollListener = isSmallScreen ? window : currentScrollerRef; + + const handleScroll = throttle(() => { + const { offsetTop = 0 } = currentScrollerRef; + const scrollTop = + (isSmallScreen + ? getWindowScrollTopPosition() + : currentScrollerRef.scrollTop) - offsetTop; + + listRef.current?.scrollTo(scrollTop); + }, 10); + + currentScrollListener.addEventListener('scroll', handleScroll); + + return () => { + handleScroll.cancel(); + + if (currentScrollListener) { + currentScrollListener.removeEventListener('scroll', handleScroll); + } + }; + }, [isSmallScreen, listRef, scrollerRef]); + + useEffect(() => { + if (jumpToCharacter) { + const index = getIndexOfFirstCharacter(items, jumpToCharacter); + + if (index != null) { + let scrollTop = index * rowHeight; + + // If the offset is zero go to the top, otherwise offset + // by the approximate size of the header + padding (37 + 20). + if (scrollTop > 0) { + const offset = 57; + + scrollTop += offset; + } + + listRef.current?.scrollTo(scrollTop); + scrollerRef.current?.scrollTo(0, scrollTop); + } + } + }, [jumpToCharacter, rowHeight, items, scrollerRef, listRef]); + + return ( +
+ + ref={listRef} + style={{ + width: '100%', + height: '100%', + overflow: 'none', + }} + width={size.width} + height={size.height} + itemCount={items.length} + itemSize={rowHeight} + itemData={{ + items, + sortKey, + posterWidth, + posterHeight, + rowHeight, + isSelectMode, + isSmallScreen, + }} + > + {Row} + +
+ ); +} + +export default ArtistIndexOverviews; diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewsConnector.js b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewsConnector.js deleted file mode 100644 index 595a471b1..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewsConnector.js +++ /dev/null @@ -1,25 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import ArtistIndexOverviews from './ArtistIndexOverviews'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex.overviewOptions, - createUISettingsSelector(), - createDimensionsSelector(), - (overviewOptions, uiSettings, dimensions) => { - return { - overviewOptions, - showRelativeDates: uiSettings.showRelativeDates, - shortDateFormat: uiSettings.shortDateFormat, - longDateFormat: uiSettings.longDateFormat, - timeFormat: uiSettings.timeFormat, - isSmallScreen: dimensions.isSmallScreen - }; - } - ); -} - -export default connect(createMapStateToProps)(ArtistIndexOverviews); diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.js b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.js deleted file mode 100644 index 9ca575185..000000000 --- a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.js +++ /dev/null @@ -1,25 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Modal from 'Components/Modal/Modal'; -import ArtistIndexOverviewOptionsModalContentConnector from './ArtistIndexOverviewOptionsModalContentConnector'; - -function ArtistIndexOverviewOptionsModal({ isOpen, onModalClose, ...otherProps }) { - return ( - - - - ); -} - -ArtistIndexOverviewOptionsModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexOverviewOptionsModal; diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.tsx b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.tsx new file mode 100644 index 000000000..bc999cee4 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.tsx @@ -0,0 +1,25 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import ArtistIndexOverviewOptionsModalContent from './ArtistIndexOverviewOptionsModalContent'; + +interface ArtistIndexOverviewOptionsModalProps { + isOpen: boolean; + onModalClose(...args: unknown[]): void; +} + +function ArtistIndexOverviewOptionsModal({ + isOpen, + onModalClose, + ...otherProps +}: ArtistIndexOverviewOptionsModalProps) { + return ( + + + + ); +} + +export default ArtistIndexOverviewOptionsModal; diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.js b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.js deleted file mode 100644 index 2fe569965..000000000 --- a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.js +++ /dev/null @@ -1,287 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { inputTypes } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import Form from 'Components/Form/Form'; -import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; - -const posterSizeOptions = [ - { key: 'small', value: 'Small' }, - { key: 'medium', value: 'Medium' }, - { key: 'large', value: 'Large' } -]; - -class ArtistIndexOverviewOptionsModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - detailedProgressBar: props.detailedProgressBar, - size: props.size, - showMonitored: props.showMonitored, - showQualityProfile: props.showQualityProfile, - showLastAlbum: props.showLastAlbum, - showAdded: props.showAdded, - showAlbumCount: props.showAlbumCount, - showPath: props.showPath, - showSizeOnDisk: props.showSizeOnDisk, - showSearchAction: props.showSearchAction - }; - } - - componentDidUpdate(prevProps) { - const { - detailedProgressBar, - size, - showMonitored, - showQualityProfile, - showLastAlbum, - showAdded, - showAlbumCount, - showPath, - showSizeOnDisk, - showSearchAction - } = this.props; - - const state = {}; - - if (detailedProgressBar !== prevProps.detailedProgressBar) { - state.detailedProgressBar = detailedProgressBar; - } - - if (size !== prevProps.size) { - state.size = size; - } - - if (showMonitored !== prevProps.showMonitored) { - state.showMonitored = showMonitored; - } - - if (showQualityProfile !== prevProps.showQualityProfile) { - state.showQualityProfile = showQualityProfile; - } - - if (showLastAlbum !== prevProps.showLastAlbum) { - state.showLastAlbum = showLastAlbum; - } - - if (showAdded !== prevProps.showAdded) { - state.showAdded = showAdded; - } - - if (showAlbumCount !== prevProps.showAlbumCount) { - state.showAlbumCount = showAlbumCount; - } - - if (showPath !== prevProps.showPath) { - state.showPath = showPath; - } - - if (showSizeOnDisk !== prevProps.showSizeOnDisk) { - state.showSizeOnDisk = showSizeOnDisk; - } - - if (showSearchAction !== prevProps.showSearchAction) { - state.showSearchAction = showSearchAction; - } - - if (!_.isEmpty(state)) { - this.setState(state); - } - } - - // - // Listeners - - onChangeOverviewOption = ({ name, value }) => { - this.setState({ - [name]: value - }, () => { - this.props.onChangeOverviewOption({ [name]: value }); - }); - } - - // - // Render - - render() { - const { - onModalClose - } = this.props; - - const { - detailedProgressBar, - size, - showMonitored, - showQualityProfile, - showLastAlbum, - showAdded, - showAlbumCount, - showPath, - showSizeOnDisk, - showSearchAction - } = this.state; - - return ( - - - Overview Options - - - -
- - Poster Size - - - - - - Detailed Progress Bar - - - - - - Show Monitored - - - - - - - Show Quality Profile - - - - - - Show Last Album - - - - - - Show Date Added - - - - - - Show Album Count - - - - - - Show Path - - - - - - Show Size on Disk - - - - - - Show Search - - - -
-
- - - - -
- ); - } -} - -ArtistIndexOverviewOptionsModalContent.propTypes = { - size: PropTypes.string.isRequired, - detailedProgressBar: PropTypes.bool.isRequired, - showMonitored: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - showLastAlbum: PropTypes.bool.isRequired, - showAdded: PropTypes.bool.isRequired, - showAlbumCount: PropTypes.bool.isRequired, - showPath: PropTypes.bool.isRequired, - showSizeOnDisk: PropTypes.bool.isRequired, - showSearchAction: PropTypes.bool.isRequired, - onChangeOverviewOption: PropTypes.func.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexOverviewOptionsModalContent; diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.tsx b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.tsx new file mode 100644 index 000000000..4ab9391e3 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.tsx @@ -0,0 +1,197 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes } from 'Helpers/Props'; +import { setArtistOverviewOption } from 'Store/Actions/artistIndexActions'; +import translate from 'Utilities/String/translate'; +import selectOverviewOptions from '../selectOverviewOptions'; + +const posterSizeOptions = [ + { + key: 'small', + get value() { + return translate('Small'); + }, + }, + { + key: 'medium', + get value() { + return translate('Medium'); + }, + }, + { + key: 'large', + get value() { + return translate('Large'); + }, + }, +]; + +interface ArtistIndexOverviewOptionsModalContentProps { + onModalClose(...args: unknown[]): void; +} + +function ArtistIndexOverviewOptionsModalContent( + props: ArtistIndexOverviewOptionsModalContentProps +) { + const { onModalClose } = props; + + const { + detailedProgressBar, + size, + showMonitored, + showQualityProfile, + showLastAlbum, + showAdded, + showAlbumCount, + showPath, + showSizeOnDisk, + showSearchAction, + } = useSelector(selectOverviewOptions); + + const dispatch = useDispatch(); + + const onOverviewOptionChange = useCallback( + ({ name, value }: { name: string; value: unknown }) => { + dispatch(setArtistOverviewOption({ [name]: value })); + }, + [dispatch] + ); + + return ( + + {translate('OverviewOptions')} + + +
+ + {translate('PosterSize')} + + + + + + {translate('DetailedProgressBar')} + + + + + + {translate('ShowMonitored')} + + + + + + {translate('ShowQualityProfile')} + + + + + + {translate('ShowLastAlbum')} + + + + + + {translate('ShowDateAdded')} + + + + + + {translate('ShowAlbumCount')} + + + + + + {translate('ShowPath')} + + + + + + {translate('ShowSizeOnDisk')} + + + + + + {translate('ShowSearch')} + + + +
+
+ + + + +
+ ); +} + +export default ArtistIndexOverviewOptionsModalContent; diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContentConnector.js b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContentConnector.js deleted file mode 100644 index 70c30dba6..000000000 --- a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContentConnector.js +++ /dev/null @@ -1,23 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setArtistOverviewOption } from 'Store/Actions/artistIndexActions'; -import ArtistIndexOverviewOptionsModalContent from './ArtistIndexOverviewOptionsModalContent'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex, - (artistIndex) => { - return artistIndex.overviewOptions; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onChangeOverviewOption(payload) { - dispatch(setArtistOverviewOption(payload)); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(ArtistIndexOverviewOptionsModalContent); diff --git a/frontend/src/Artist/Index/Overview/selectOverviewOptions.ts b/frontend/src/Artist/Index/Overview/selectOverviewOptions.ts new file mode 100644 index 000000000..5875163c8 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/selectOverviewOptions.ts @@ -0,0 +1,9 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +const selectOverviewOptions = createSelector( + (state: AppState) => state.artistIndex.overviewOptions, + (overviewOptions) => overviewOptions +); + +export default selectOverviewOptions; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css index cd378e34c..aaccec8a8 100644 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css @@ -1,15 +1,11 @@ $hoverScale: 1.05; -.container { - padding: 10px; -} - .content { transition: all 200ms ease-in; &:hover { z-index: 2; - box-shadow: 0 0 12px $black; + box-shadow: 0 0 12px var(--black); transition: all 200ms ease-in; .controls { @@ -29,7 +25,7 @@ $hoverScale: 1.05; position: relative; display: block; height: 70px; - background-color: $defaultColor; + background-color: var(--defaultColor); } .overlayTitle { @@ -42,13 +38,13 @@ $hoverScale: 1.05; padding: 5px; width: 100%; height: 100%; - color: $offWhite; + color: var(--offWhite); text-align: center; font-size: 20px; } -.nextAiring { - background-color: #fafbfc; +.nextAlbum { + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } @@ -56,8 +52,7 @@ $hoverScale: 1.05; .title { @add-mixin truncate; - background-color: $defaultColor; - color: $white; + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } @@ -71,8 +66,8 @@ $hoverScale: 1.05; height: 0; border-width: 0 25px 25px 0; border-style: solid; - border-color: transparent $dangerColor transparent transparent; - color: $white; + border-color: transparent var(--dangerColor) transparent transparent; + color: var(--white); } .controls { @@ -82,7 +77,7 @@ $hoverScale: 1.05; z-index: 3; border-radius: 4px; background-color: #216044; - color: $white; + color: var(--white); font-size: $smallFontSize; opacity: 0; transition: opacity 0; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css.d.ts b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css.d.ts new file mode 100644 index 000000000..b1eeccf08 --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css.d.ts @@ -0,0 +1,16 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'action': string; + 'container': string; + 'content': string; + 'controls': string; + 'ended': string; + 'link': string; + 'nextAlbum': string; + 'overlayTitle': string; + 'posterContainer': string; + 'title': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.js b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.js deleted file mode 100644 index 101b49f7b..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.js +++ /dev/null @@ -1,295 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; -import { icons } from 'Helpers/Props'; -import IconButton from 'Components/Link/IconButton'; -import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; -import Label from 'Components/Label'; -import Link from 'Components/Link/Link'; -import ArtistPoster from 'Artist/ArtistPoster'; -import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; -import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; -import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; -import ArtistIndexPosterInfo from './ArtistIndexPosterInfo'; -import styles from './ArtistIndexPoster.css'; - -class ArtistIndexPoster extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - hasPosterError: false, - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: false - }; - } - - // - // Listeners - - onEditArtistPress = () => { - this.setState({ isEditArtistModalOpen: true }); - } - - onEditArtistModalClose = () => { - this.setState({ isEditArtistModalOpen: false }); - } - - onDeleteArtistPress = () => { - this.setState({ - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: true - }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - onPosterLoad = () => { - if (this.state.hasPosterError) { - this.setState({ hasPosterError: false }); - } - } - - onPosterLoadError = () => { - if (!this.state.hasPosterError) { - this.setState({ hasPosterError: true }); - } - } - - // - // Render - - render() { - const { - style, - id, - artistName, - monitored, - foreignArtistId, - status, - nextAiring, - statistics, - images, - posterWidth, - posterHeight, - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile, - qualityProfile, - showSearchAction, - showRelativeDates, - shortDateFormat, - timeFormat, - isRefreshingArtist, - isSearchingArtist, - onRefreshArtistPress, - onSearchPress, - ...otherProps - } = this.props; - - const { - albumCount, - sizeOnDisk, - trackCount, - trackFileCount, - totalTrackCount - } = statistics; - - const { - hasPosterError, - isEditArtistModalOpen, - isDeleteArtistModalOpen - } = this.state; - - const link = `/artist/${foreignArtistId}`; - - const elementStyle = { - width: `${posterWidth}px`, - height: `${posterHeight}px` - }; - - return ( -
-
-
- - - { - status === 'ended' && -
- } - - - - - { - hasPosterError && -
- {artistName} -
- } - - -
- - - - { - showTitle && -
- {artistName} -
- } - - { - showMonitored && -
- {monitored ? 'Monitored' : 'Unmonitored'} -
- } - - { - showQualityProfile && -
- {qualityProfile.name} -
- } - { - nextAiring && -
- { - getRelativeDate( - nextAiring, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - } -
- } - - - - - -
-
- ); - } -} - -ArtistIndexPoster.propTypes = { - style: PropTypes.object.isRequired, - id: PropTypes.number.isRequired, - artistName: PropTypes.string.isRequired, - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - nextAiring: PropTypes.string, - statistics: PropTypes.object.isRequired, - images: PropTypes.arrayOf(PropTypes.object).isRequired, - posterWidth: PropTypes.number.isRequired, - posterHeight: PropTypes.number.isRequired, - detailedProgressBar: PropTypes.bool.isRequired, - showTitle: PropTypes.bool.isRequired, - showMonitored: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - qualityProfile: PropTypes.object.isRequired, - showSearchAction: PropTypes.bool.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - isSearchingArtist: PropTypes.bool.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired, - onSearchPress: PropTypes.func.isRequired -}; - -ArtistIndexPoster.defaultProps = { - statistics: { - albumCount: 0, - trackCount: 0, - trackFileCount: 0, - totalTrackCount: 0 - } -}; - -export default ArtistIndexPoster; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.tsx b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.tsx new file mode 100644 index 000000000..67c37c00d --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.tsx @@ -0,0 +1,263 @@ +import React, { useCallback, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { Statistics } from 'Artist/Artist'; +import ArtistPoster from 'Artist/ArtistPoster'; +import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; +import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; +import createArtistIndexItemSelector from 'Artist/Index/createArtistIndexItemSelector'; +import ArtistIndexPosterInfo from 'Artist/Index/Posters/ArtistIndexPosterInfo'; +import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; +import ArtistIndexPosterSelect from 'Artist/Index/Select/ArtistIndexPosterSelect'; +import { ARTIST_SEARCH, REFRESH_ARTIST } from 'Commands/commandNames'; +import Label from 'Components/Label'; +import IconButton from 'Components/Link/IconButton'; +import Link from 'Components/Link/Link'; +import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; +import { icons } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import translate from 'Utilities/String/translate'; +import selectPosterOptions from './selectPosterOptions'; +import styles from './ArtistIndexPoster.css'; + +interface ArtistIndexPosterProps { + artistId: number; + sortKey: string; + isSelectMode: boolean; + posterWidth: number; + posterHeight: number; +} + +function ArtistIndexPoster(props: ArtistIndexPosterProps) { + const { artistId, sortKey, isSelectMode, posterWidth, posterHeight } = props; + + const { + artist, + qualityProfile, + metadataProfile, + isRefreshingArtist, + isSearchingArtist, + } = useSelector(createArtistIndexItemSelector(props.artistId)); + + const { + detailedProgressBar, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + showSearchAction, + } = useSelector(selectPosterOptions); + + const { showRelativeDates, shortDateFormat, longDateFormat, timeFormat } = + useSelector(createUISettingsSelector()); + + const { + artistName, + artistType, + monitored, + status, + path, + foreignArtistId, + nextAlbum, + added, + statistics = {} as Statistics, + images, + tags, + } = artist; + + const { + albumCount = 0, + trackCount = 0, + trackFileCount = 0, + totalTrackCount = 0, + sizeOnDisk = 0, + } = statistics; + + const dispatch = useDispatch(); + const [hasPosterError, setHasPosterError] = useState(false); + const [isEditArtistModalOpen, setIsEditArtistModalOpen] = useState(false); + const [isDeleteArtistModalOpen, setIsDeleteArtistModalOpen] = useState(false); + + const onRefreshPress = useCallback(() => { + dispatch( + executeCommand({ + name: REFRESH_ARTIST, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onSearchPress = useCallback(() => { + dispatch( + executeCommand({ + name: ARTIST_SEARCH, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onPosterLoadError = useCallback(() => { + setHasPosterError(true); + }, [setHasPosterError]); + + const onPosterLoad = useCallback(() => { + setHasPosterError(false); + }, [setHasPosterError]); + + const onEditArtistPress = useCallback(() => { + setIsEditArtistModalOpen(true); + }, [setIsEditArtistModalOpen]); + + const onEditArtistModalClose = useCallback(() => { + setIsEditArtistModalOpen(false); + }, [setIsEditArtistModalOpen]); + + const onDeleteArtistPress = useCallback(() => { + setIsEditArtistModalOpen(false); + setIsDeleteArtistModalOpen(true); + }, [setIsDeleteArtistModalOpen]); + + const onDeleteArtistModalClose = useCallback(() => { + setIsDeleteArtistModalOpen(false); + }, [setIsDeleteArtistModalOpen]); + + const link = `/artist/${foreignArtistId}`; + + const elementStyle = { + width: `${posterWidth}px`, + height: `${posterHeight}px`, + }; + + return ( +
+
+ {isSelectMode ? : null} + + + + {status === 'ended' ? ( +
+ ) : null} + + + + + {hasPosterError ? ( +
{artistName}
+ ) : null} + +
+ + + + {showTitle ? ( +
+ {artistName} +
+ ) : null} + + {showMonitored ? ( +
+ {monitored ? translate('Monitored') : translate('Unmonitored')} +
+ ) : null} + + {showQualityProfile && !!qualityProfile?.name ? ( +
+ {qualityProfile.name} +
+ ) : null} + + {showNextAlbum && !!nextAlbum?.releaseDate ? ( +
+ {getRelativeDate( + nextAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ) : null} + + + + + + +
+ ); +} + +export default ArtistIndexPoster; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css index aab27d827..22ed2d528 100644 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css @@ -1,5 +1,5 @@ .info { - background-color: #fafbfc; + background-color: var(--artistBackgroundColor); text-align: center; font-size: $smallFontSize; } diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css.d.ts b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css.d.ts new file mode 100644 index 000000000..062365d36 --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'info': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.js b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.js deleted file mode 100644 index 591961605..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.js +++ /dev/null @@ -1,115 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; -import formatBytes from 'Utilities/Number/formatBytes'; -import styles from './ArtistIndexPosterInfo.css'; - -function ArtistIndexPosterInfo(props) { - const { - qualityProfile, - showQualityProfile, - previousAiring, - added, - albumCount, - path, - sizeOnDisk, - sortKey, - showRelativeDates, - shortDateFormat, - timeFormat - } = props; - - if (sortKey === 'qualityProfileId' && !showQualityProfile) { - return ( -
- {qualityProfile.name} -
- ); - } - - if (sortKey === 'previousAiring' && previousAiring) { - return ( -
- { - getRelativeDate( - previousAiring, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: true - } - ) - } -
- ); - } - - if (sortKey === 'added' && added) { - const addedDate = getRelativeDate( - added, - shortDateFormat, - showRelativeDates, - { - timeFormat, - timeForToday: false - } - ); - - return ( -
- {`Added ${addedDate}`} -
- ); - } - - if (sortKey === 'albumCount') { - let albums = '1 album'; - - if (albumCount === 0) { - albums = 'No albums'; - } else if (albumCount > 1) { - albums = `${albumCount} albums`; - } - - return ( -
- {albums} -
- ); - } - - if (sortKey === 'path') { - return ( -
- {path} -
- ); - } - - if (sortKey === 'sizeOnDisk') { - return ( -
- {formatBytes(sizeOnDisk)} -
- ); - } - - return null; -} - -ArtistIndexPosterInfo.propTypes = { - qualityProfile: PropTypes.object.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - previousAiring: PropTypes.string, - added: PropTypes.string, - albumCount: PropTypes.number.isRequired, - path: PropTypes.string.isRequired, - sizeOnDisk: PropTypes.number, - sortKey: PropTypes.string.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - timeFormat: PropTypes.string.isRequired -}; - -export default ArtistIndexPosterInfo; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.tsx b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.tsx new file mode 100644 index 000000000..0d4ff9135 --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.tsx @@ -0,0 +1,187 @@ +import React from 'react'; +import Album from 'Album/Album'; +import TagListConnector from 'Components/TagListConnector'; +import MetadataProfile from 'typings/MetadataProfile'; +import QualityProfile from 'typings/QualityProfile'; +import formatDateTime from 'Utilities/Date/formatDateTime'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import formatBytes from 'Utilities/Number/formatBytes'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistIndexPosterInfo.css'; + +interface ArtistIndexPosterInfoProps { + artistType?: string; + showQualityProfile: boolean; + qualityProfile?: QualityProfile; + metadataProfile?: MetadataProfile; + showNextAlbum: boolean; + nextAlbum?: Album; + lastAlbum?: Album; + added?: string; + albumCount: number; + path: string; + sizeOnDisk?: number; + tags?: number[]; + sortKey: string; + showRelativeDates: boolean; + shortDateFormat: string; + longDateFormat: string; + timeFormat: string; +} + +function ArtistIndexPosterInfo(props: ArtistIndexPosterInfoProps) { + const { + artistType, + qualityProfile, + metadataProfile, + showQualityProfile, + showNextAlbum, + nextAlbum, + lastAlbum, + added, + albumCount, + path, + sizeOnDisk, + tags, + sortKey, + showRelativeDates, + shortDateFormat, + longDateFormat, + timeFormat, + } = props; + + if (sortKey === 'artistType' && artistType) { + return ( +
+ {artistType} +
+ ); + } + + if ( + sortKey === 'qualityProfileId' && + !showQualityProfile && + !!qualityProfile?.name + ) { + return ( +
+ {qualityProfile.name} +
+ ); + } + + if (sortKey === 'metadataProfileId' && !!metadataProfile?.name) { + return ( +
+ {metadataProfile.name} +
+ ); + } + + if (sortKey === 'nextAlbum' && !showNextAlbum && !!nextAlbum?.releaseDate) { + return ( +
+ {getRelativeDate( + nextAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ); + } + + if (sortKey === 'lastAlbum' && !!lastAlbum?.releaseDate) { + return ( +
+ {getRelativeDate( + lastAlbum.releaseDate, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: true, + } + )} +
+ ); + } + + if (sortKey === 'added' && added) { + const addedDate = getRelativeDate( + added, + shortDateFormat, + showRelativeDates, + { + timeFormat, + timeForToday: false, + } + ); + + return ( +
+ {translate('Added')}: {addedDate} +
+ ); + } + + if (sortKey === 'albumCount') { + let albums = translate('OneAlbum'); + + if (albumCount === 0) { + albums = translate('NoAlbums'); + } else if (albumCount > 1) { + albums = translate('CountAlbums', { albumCount }); + } + + return
{albums}
; + } + + if (sortKey === 'path') { + return ( +
+ {path} +
+ ); + } + + if (sortKey === 'sizeOnDisk') { + return ( +
+ {formatBytes(sizeOnDisk)} +
+ ); + } + + if (sortKey === 'tags' && tags) { + return ( +
+ +
+ ); + } + + return null; +} + +export default ArtistIndexPosterInfo; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.css.d.ts b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.css.d.ts new file mode 100644 index 000000000..b97436b41 --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'grid': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js deleted file mode 100644 index 3650db93e..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js +++ /dev/null @@ -1,326 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import ReactDOM from 'react-dom'; -import { Grid, WindowScroller } from 'react-virtualized'; -import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; -import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; -import dimensions from 'Styles/Variables/dimensions'; -import { sortDirections } from 'Helpers/Props'; -import Measure from 'Components/Measure'; -import ArtistIndexItemConnector from 'Artist/Index/ArtistIndexItemConnector'; -import ArtistIndexPoster from './ArtistIndexPoster'; -import styles from './ArtistIndexPosters.css'; - -// Poster container dimensions -const columnPadding = parseInt(dimensions.artistIndexColumnPadding); -const columnPaddingSmallScreen = parseInt(dimensions.artistIndexColumnPaddingSmallScreen); -const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); -const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); - -const additionalColumnCount = { - small: 3, - medium: 2, - large: 1 -}; - -function calculateColumnWidth(width, posterSize, isSmallScreen) { - const maxiumColumnWidth = isSmallScreen ? 172 : 182; - const columns = Math.floor(width / maxiumColumnWidth); - const remainder = width % maxiumColumnWidth; - - if (remainder === 0 && posterSize === 'large') { - return maxiumColumnWidth; - } - - return Math.floor(width / (columns + additionalColumnCount[posterSize])); -} - -function calculateRowHeight(posterHeight, sortKey, isSmallScreen, posterOptions) { - const { - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile - } = posterOptions; - - const nextAiringHeight = 19; - - const heights = [ - posterHeight, - detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, - nextAiringHeight, - isSmallScreen ? columnPaddingSmallScreen : columnPadding - ]; - - if (showTitle) { - heights.push(19); - } - - if (showMonitored) { - heights.push(19); - } - - if (showQualityProfile) { - heights.push(19); - } - - switch (sortKey) { - case 'seasons': - case 'previousAiring': - case 'added': - case 'path': - case 'sizeOnDisk': - heights.push(19); - break; - case 'qualityProfileId': - if (!showQualityProfile) { - heights.push(19); - } - break; - default: - // No need to add a height of 0 - } - - return heights.reduce((acc, height) => acc + height, 0); -} - -function calculatePosterHeight(posterWidth) { - return Math.ceil(posterWidth); -} - -class ArtistIndexPosters extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - width: 0, - columnWidth: 182, - columnCount: 1, - posterWidth: 238, - posterHeight: 238, - rowHeight: calculateRowHeight(238, null, props.isSmallScreen, {}) - }; - - this._isInitialized = false; - this._grid = null; - } - - componentDidMount() { - this._contentBodyNode = ReactDOM.findDOMNode(this.props.contentBody); - } - - componentDidUpdate(prevProps) { - const { - items, - filters, - sortKey, - sortDirection, - posterOptions, - jumpToCharacter - } = this.props; - - const itemsChanged = hasDifferentItems(prevProps.items, items); - - if ( - prevProps.sortKey !== sortKey || - prevProps.posterOptions !== posterOptions || - itemsChanged - ) { - this.calculateGrid(); - } - - if ( - prevProps.filters !== filters || - prevProps.sortKey !== sortKey || - prevProps.sortDirection !== sortDirection || - itemsChanged - ) { - this._grid.recomputeGridSize(); - } - - if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { - const index = getIndexOfFirstCharacter(items, jumpToCharacter); - - if (index != null) { - const { - columnCount, - rowHeight - } = this.state; - - const row = Math.floor(index / columnCount); - const scrollTop = rowHeight * row; - - this.props.onScroll({ scrollTop }); - } - } - } - - // - // Control - - setGridRef = (ref) => { - this._grid = ref; - } - - calculateGrid = (width = this.state.width, isSmallScreen) => { - const { - sortKey, - posterOptions - } = this.props; - - const padding = isSmallScreen ? columnPaddingSmallScreen : columnPadding; - const columnWidth = calculateColumnWidth(width, posterOptions.size, isSmallScreen); - const columnCount = Math.max(Math.floor(width / columnWidth), 1); - const posterWidth = columnWidth - padding; - const posterHeight = calculatePosterHeight(posterWidth); - const rowHeight = calculateRowHeight(posterHeight, sortKey, isSmallScreen, posterOptions); - - this.setState({ - width, - columnWidth, - columnCount, - posterWidth, - posterHeight, - rowHeight - }); - } - - cellRenderer = ({ key, rowIndex, columnIndex, style }) => { - const { - items, - sortKey, - posterOptions, - showRelativeDates, - shortDateFormat, - timeFormat - } = this.props; - - const { - posterWidth, - posterHeight, - columnCount - } = this.state; - - const { - detailedProgressBar, - showTitle, - showMonitored, - showQualityProfile - } = posterOptions; - - const artist = items[rowIndex * columnCount + columnIndex]; - - if (!artist) { - return null; - } - - return ( - - ); - } - - // - // Listeners - - onMeasure = ({ width }) => { - this.calculateGrid(width, this.props.isSmallScreen); - } - - onSectionRendered = () => { - if (!this._isInitialized && this._contentBodyNode) { - this.props.onRender(); - this._isInitialized = true; - } - } - - // - // Render - - render() { - const { - items, - scrollTop, - isSmallScreen, - onScroll - } = this.props; - - const { - width, - columnWidth, - columnCount, - rowHeight - } = this.state; - - const rowCount = Math.ceil(items.length / columnCount); - - return ( - - - {({ height, isScrolling }) => { - return ( - - ); - } - } - - - ); - } -} - -ArtistIndexPosters.propTypes = { - items: PropTypes.arrayOf(PropTypes.object).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - posterOptions: PropTypes.object.isRequired, - scrollTop: PropTypes.number.isRequired, - jumpToCharacter: PropTypes.string, - contentBody: PropTypes.object.isRequired, - showRelativeDates: PropTypes.bool.isRequired, - shortDateFormat: PropTypes.string.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - timeFormat: PropTypes.string.isRequired, - onRender: PropTypes.func.isRequired, - onScroll: PropTypes.func.isRequired -}; - -export default ArtistIndexPosters; diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.tsx b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.tsx new file mode 100644 index 000000000..c478ac1ae --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.tsx @@ -0,0 +1,313 @@ +import { throttle } from 'lodash'; +import React, { RefObject, useEffect, useMemo, useRef, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { FixedSizeGrid as Grid, GridChildComponentProps } from 'react-window'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import Artist from 'Artist/Artist'; +import ArtistIndexPoster from 'Artist/Index/Posters/ArtistIndexPoster'; +import useMeasure from 'Helpers/Hooks/useMeasure'; +import SortDirection from 'Helpers/Props/SortDirection'; +import dimensions from 'Styles/Variables/dimensions'; +import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; + +const bodyPadding = parseInt(dimensions.pageContentBodyPadding); +const bodyPaddingSmallScreen = parseInt( + dimensions.pageContentBodyPaddingSmallScreen +); +const columnPadding = parseInt(dimensions.artistIndexColumnPadding); +const columnPaddingSmallScreen = parseInt( + dimensions.artistIndexColumnPaddingSmallScreen +); +const progressBarHeight = parseInt(dimensions.progressBarSmallHeight); +const detailedProgressBarHeight = parseInt(dimensions.progressBarMediumHeight); + +const ADDITIONAL_COLUMN_COUNT: Record = { + small: 3, + medium: 2, + large: 1, +}; + +interface CellItemData { + layout: { + columnCount: number; + padding: number; + posterWidth: number; + posterHeight: number; + }; + items: Artist[]; + sortKey: string; + isSelectMode: boolean; +} + +interface ArtistIndexPostersProps { + items: Artist[]; + sortKey: string; + sortDirection?: SortDirection; + jumpToCharacter?: string; + scrollTop?: number; + scrollerRef: RefObject; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +const artistIndexSelector = createSelector( + (state: AppState) => state.artistIndex.posterOptions, + (posterOptions) => { + return { + posterOptions, + }; + } +); + +const Cell: React.FC> = ({ + columnIndex, + rowIndex, + style, + data, +}) => { + const { layout, items, sortKey, isSelectMode } = data; + const { columnCount, padding, posterWidth, posterHeight } = layout; + const index = rowIndex * columnCount + columnIndex; + + if (index >= items.length) { + return null; + } + + const artist = items[index]; + + return ( +
+ +
+ ); +}; + +function getWindowScrollTopPosition() { + return document.documentElement.scrollTop || document.body.scrollTop || 0; +} + +export default function ArtistIndexPosters(props: ArtistIndexPostersProps) { + const { + scrollerRef, + items, + sortKey, + jumpToCharacter, + isSelectMode, + isSmallScreen, + } = props; + + const { posterOptions } = useSelector(artistIndexSelector); + const ref = useRef(null); + const [measureRef, bounds] = useMeasure(); + const [size, setSize] = useState({ width: 0, height: 0 }); + + const columnWidth = useMemo(() => { + const { width } = size; + const maximumColumnWidth = isSmallScreen ? 172 : 182; + const columns = Math.floor(width / maximumColumnWidth); + const remainder = width % maximumColumnWidth; + return remainder === 0 + ? maximumColumnWidth + : Math.floor( + width / (columns + ADDITIONAL_COLUMN_COUNT[posterOptions.size]) + ); + }, [isSmallScreen, posterOptions, size]); + + const columnCount = useMemo( + () => Math.max(Math.floor(size.width / columnWidth), 1), + [size, columnWidth] + ); + const padding = props.isSmallScreen + ? columnPaddingSmallScreen + : columnPadding; + const posterWidth = columnWidth - padding * 2; + const posterHeight = Math.ceil(posterWidth); + + const rowHeight = useMemo(() => { + const { + detailedProgressBar, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + } = posterOptions; + + const nextAiringHeight = 19; + + const heights = [ + posterHeight, + detailedProgressBar ? detailedProgressBarHeight : progressBarHeight, + nextAiringHeight, + isSmallScreen ? columnPaddingSmallScreen : columnPadding, + ]; + + if (showTitle) { + heights.push(19); + } + + if (showMonitored) { + heights.push(19); + } + + if (showQualityProfile) { + heights.push(19); + } + + if (showNextAlbum) { + heights.push(19); + } + + switch (sortKey) { + case 'artistType': + case 'metadataProfileId': + case 'lastAlbum': + case 'added': + case 'albumCount': + case 'path': + case 'sizeOnDisk': + case 'tags': + heights.push(19); + break; + case 'qualityProfileId': + if (!showQualityProfile) { + heights.push(19); + } + break; + case 'nextAlbum': + if (!showNextAlbum) { + heights.push(19); + } + break; + default: + // No need to add a height of 0 + } + + return heights.reduce((acc, height) => acc + height, 0); + }, [isSmallScreen, posterOptions, sortKey, posterHeight]); + + useEffect(() => { + const current = scrollerRef.current; + + if (isSmallScreen) { + const padding = bodyPaddingSmallScreen - 5; + const width = window.innerWidth - padding * 2; + const height = window.innerHeight; + + if (width !== size.width || height !== size.height) { + setSize({ + width, + height, + }); + } + + return; + } + + if (current) { + const width = current.clientWidth; + const padding = bodyPadding - 5; + const finalWidth = width - padding * 2; + + if (Math.abs(size.width - finalWidth) < 20 || size.width === finalWidth) { + return; + } + + setSize({ + width: finalWidth, + height: window.innerHeight, + }); + } + }, [isSmallScreen, size, scrollerRef, bounds]); + + useEffect(() => { + const currentScrollerRef = scrollerRef.current as HTMLElement; + const currentScrollListener = isSmallScreen ? window : currentScrollerRef; + + const handleScroll = throttle(() => { + const { offsetTop = 0 } = currentScrollerRef; + const scrollTop = + (isSmallScreen + ? getWindowScrollTopPosition() + : currentScrollerRef.scrollTop) - offsetTop; + + ref.current?.scrollTo({ scrollLeft: 0, scrollTop }); + }, 10); + + currentScrollListener.addEventListener('scroll', handleScroll); + + return () => { + handleScroll.cancel(); + + if (currentScrollListener) { + currentScrollListener.removeEventListener('scroll', handleScroll); + } + }; + }, [isSmallScreen, ref, scrollerRef]); + + useEffect(() => { + if (jumpToCharacter) { + const index = getIndexOfFirstCharacter(items, jumpToCharacter); + + if (index != null) { + const rowIndex = Math.floor(index / columnCount); + + const scrollTop = rowIndex * rowHeight + padding; + + ref.current?.scrollTo({ scrollLeft: 0, scrollTop }); + scrollerRef.current?.scrollTo(0, scrollTop); + } + } + }, [ + jumpToCharacter, + rowHeight, + columnCount, + padding, + items, + scrollerRef, + ref, + ]); + + return ( +
+ + ref={ref} + style={{ + width: '100%', + height: '100%', + overflow: 'none', + }} + width={size.width} + height={size.height} + columnCount={columnCount} + columnWidth={columnWidth} + rowCount={Math.ceil(items.length / columnCount)} + rowHeight={rowHeight} + itemData={{ + layout: { + columnCount, + padding, + posterWidth, + posterHeight, + }, + items, + sortKey, + isSelectMode, + }} + > + {Cell} + +
+ ); +} diff --git a/frontend/src/Artist/Index/Posters/ArtistIndexPostersConnector.js b/frontend/src/Artist/Index/Posters/ArtistIndexPostersConnector.js deleted file mode 100644 index 04c187e4e..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPostersConnector.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import ArtistIndexPosters from './ArtistIndexPosters'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex.posterOptions, - createUISettingsSelector(), - createDimensionsSelector(), - (posterOptions, uiSettings, dimensions) => { - return { - posterOptions, - showRelativeDates: uiSettings.showRelativeDates, - shortDateFormat: uiSettings.shortDateFormat, - timeFormat: uiSettings.timeFormat, - isSmallScreen: dimensions.isSmallScreen - }; - } - ); -} - -export default connect(createMapStateToProps)(ArtistIndexPosters); diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.js b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.js deleted file mode 100644 index e1b0a257a..000000000 --- a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.js +++ /dev/null @@ -1,25 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import Modal from 'Components/Modal/Modal'; -import ArtistIndexPosterOptionsModalContentConnector from './ArtistIndexPosterOptionsModalContentConnector'; - -function ArtistIndexPosterOptionsModal({ isOpen, onModalClose, ...otherProps }) { - return ( - - - - ); -} - -ArtistIndexPosterOptionsModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexPosterOptionsModal; diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.tsx b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.tsx new file mode 100644 index 000000000..69368807a --- /dev/null +++ b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import ArtistIndexPosterOptionsModalContent from './ArtistIndexPosterOptionsModalContent'; + +interface ArtistIndexPosterOptionsModalProps { + isOpen: boolean; + onModalClose(...args: unknown[]): unknown; +} + +function ArtistIndexPosterOptionsModal({ + isOpen, + onModalClose, +}: ArtistIndexPosterOptionsModalProps) { + return ( + + + + ); +} + +export default ArtistIndexPosterOptionsModal; diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.js b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.js deleted file mode 100644 index 6918436a6..000000000 --- a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.js +++ /dev/null @@ -1,213 +0,0 @@ -import _ from 'lodash'; -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { inputTypes } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; -import Form from 'Components/Form/Form'; -import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; -import ModalBody from 'Components/Modal/ModalBody'; -import ModalFooter from 'Components/Modal/ModalFooter'; - -const posterSizeOptions = [ - { key: 'small', value: 'Small' }, - { key: 'medium', value: 'Medium' }, - { key: 'large', value: 'Large' } -]; - -class ArtistIndexPosterOptionsModalContent extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - detailedProgressBar: props.detailedProgressBar, - size: props.size, - showTitle: props.showTitle, - showMonitored: props.showMonitored, - showQualityProfile: props.showQualityProfile, - showSearchAction: props.showSearchAction - }; - } - - componentDidUpdate(prevProps) { - const { - detailedProgressBar, - size, - showTitle, - showMonitored, - showQualityProfile, - showSearchAction - } = this.props; - - const state = {}; - - if (detailedProgressBar !== prevProps.detailedProgressBar) { - state.detailedProgressBar = detailedProgressBar; - } - - if (size !== prevProps.size) { - state.size = size; - } - - if (showTitle !== prevProps.showTitle) { - state.showTitle = showTitle; - } - - if (showMonitored !== prevProps.showMonitored) { - state.showMonitored = showMonitored; - } - - if (showQualityProfile !== prevProps.showQualityProfile) { - state.showQualityProfile = showQualityProfile; - } - - if (showSearchAction !== prevProps.showSearchAction) { - state.showSearchAction = showSearchAction; - } - - if (!_.isEmpty(state)) { - this.setState(state); - } - } - - // - // Listeners - - onChangePosterOption = ({ name, value }) => { - this.setState({ - [name]: value - }, () => { - this.props.onChangePosterOption({ [name]: value }); - }); - } - - // - // Render - - render() { - const { - onModalClose - } = this.props; - - const { - detailedProgressBar, - size, - showTitle, - showMonitored, - showQualityProfile, - showSearchAction - } = this.state; - - return ( - - - Poster Options - - - -
- - Poster Size - - - - - - Detailed Progress Bar - - - - - - Show Name - - - - - - Show Monitored - - - - - - Show Quality Profile - - - - - - Show Search - - - -
-
- - - - -
- ); - } -} - -ArtistIndexPosterOptionsModalContent.propTypes = { - size: PropTypes.string.isRequired, - showTitle: PropTypes.bool.isRequired, - showMonitored: PropTypes.bool.isRequired, - showQualityProfile: PropTypes.bool.isRequired, - detailedProgressBar: PropTypes.bool.isRequired, - showSearchAction: PropTypes.bool.isRequired, - onChangePosterOption: PropTypes.func.isRequired, - onModalClose: PropTypes.func.isRequired -}; - -export default ArtistIndexPosterOptionsModalContent; diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.tsx b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.tsx new file mode 100644 index 000000000..2560d855a --- /dev/null +++ b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.tsx @@ -0,0 +1,167 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import selectPosterOptions from 'Artist/Index/Posters/selectPosterOptions'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes } from 'Helpers/Props'; +import { setArtistPosterOption } from 'Store/Actions/artistIndexActions'; +import translate from 'Utilities/String/translate'; + +const posterSizeOptions = [ + { + key: 'small', + get value() { + return translate('Small'); + }, + }, + { + key: 'medium', + get value() { + return translate('Medium'); + }, + }, + { + key: 'large', + get value() { + return translate('Large'); + }, + }, +]; + +interface ArtistIndexPosterOptionsModalContentProps { + onModalClose(...args: unknown[]): unknown; +} + +function ArtistIndexPosterOptionsModalContent( + props: ArtistIndexPosterOptionsModalContentProps +) { + const { onModalClose } = props; + + const posterOptions = useSelector(selectPosterOptions); + + const { + detailedProgressBar, + size, + showTitle, + showMonitored, + showQualityProfile, + showNextAlbum, + showSearchAction, + } = posterOptions; + + const dispatch = useDispatch(); + + const onPosterOptionChange = useCallback( + ({ name, value }: { name: string; value: unknown }) => { + dispatch(setArtistPosterOption({ [name]: value })); + }, + [dispatch] + ); + + return ( + + {translate('PosterOptions')} + + +
+ + {translate('PosterSize')} + + + + + + {translate('DetailedProgressBar')} + + + + + + {translate('ShowName')} + + + + + + {translate('ShowMonitored')} + + + + + + {translate('ShowQualityProfile')} + + + + + + {translate('ShowNextAlbum')} + + + + + + {translate('ShowSearch')} + + + +
+
+ + + + +
+ ); +} + +export default ArtistIndexPosterOptionsModalContent; diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContentConnector.js b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContentConnector.js deleted file mode 100644 index 72af268ad..000000000 --- a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContentConnector.js +++ /dev/null @@ -1,23 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setArtistPosterOption } from 'Store/Actions/artistIndexActions'; -import ArtistIndexPosterOptionsModalContent from './ArtistIndexPosterOptionsModalContent'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex, - (artistIndex) => { - return artistIndex.posterOptions; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onChangePosterOption(payload) { - dispatch(setArtistPosterOption(payload)); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(ArtistIndexPosterOptionsModalContent); diff --git a/frontend/src/Artist/Index/Posters/selectPosterOptions.ts b/frontend/src/Artist/Index/Posters/selectPosterOptions.ts new file mode 100644 index 000000000..1a53a0add --- /dev/null +++ b/frontend/src/Artist/Index/Posters/selectPosterOptions.ts @@ -0,0 +1,9 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +const selectPosterOptions = createSelector( + (state: AppState) => state.artistIndex.posterOptions, + (posterOptions) => posterOptions +); + +export default selectPosterOptions; diff --git a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css index b98bb33d5..9b5777117 100644 --- a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css +++ b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css @@ -3,8 +3,7 @@ border-radius: 0; background-color: #5b5b5b; - color: $white; - transition: width 200ms ease; + color: var(--white); } .progressBar { diff --git a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css.d.ts b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css.d.ts new file mode 100644 index 000000000..dab280261 --- /dev/null +++ b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'progress': string; + 'progressBar': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.js b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.js deleted file mode 100644 index 6be32a46d..000000000 --- a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.js +++ /dev/null @@ -1,47 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import getProgressBarKind from 'Utilities/Artist/getProgressBarKind'; -import { sizes } from 'Helpers/Props'; -import ProgressBar from 'Components/ProgressBar'; -import styles from './ArtistIndexProgressBar.css'; - -function ArtistIndexProgressBar(props) { - const { - monitored, - status, - trackCount, - trackFileCount, - totalTrackCount, - posterWidth, - detailedProgressBar - } = props; - - const progress = trackCount ? trackFileCount / trackCount * 100 : 100; - const text = `${trackFileCount} / ${trackCount}`; - - return ( - - ); -} - -ArtistIndexProgressBar.propTypes = { - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - trackCount: PropTypes.number.isRequired, - trackFileCount: PropTypes.number.isRequired, - totalTrackCount: PropTypes.number.isRequired, - posterWidth: PropTypes.number.isRequired, - detailedProgressBar: PropTypes.bool.isRequired -}; - -export default ArtistIndexProgressBar; diff --git a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.tsx b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.tsx new file mode 100644 index 000000000..2a8167b99 --- /dev/null +++ b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.tsx @@ -0,0 +1,72 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import createArtistQueueItemsDetailsSelector, { + ArtistQueueDetails, +} from 'Artist/Index/createArtistQueueDetailsSelector'; +import ProgressBar from 'Components/ProgressBar'; +import { sizes } from 'Helpers/Props'; +import getProgressBarKind from 'Utilities/Artist/getProgressBarKind'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistIndexProgressBar.css'; + +interface ArtistIndexProgressBarProps { + artistId: number; + monitored: boolean; + status: string; + trackCount: number; + trackFileCount: number; + totalTrackCount: number; + width: number; + detailedProgressBar: boolean; + isStandalone: boolean; +} + +function ArtistIndexProgressBar(props: ArtistIndexProgressBarProps) { + const { + artistId, + monitored, + status, + trackCount, + trackFileCount, + totalTrackCount, + width, + detailedProgressBar, + isStandalone, + } = props; + + const queueDetails: ArtistQueueDetails = useSelector( + createArtistQueueItemsDetailsSelector(artistId) + ); + + const newDownloads = queueDetails.count - queueDetails.tracksWithFiles; + const progress = trackCount ? (trackFileCount / trackCount) * 100 : 100; + const text = newDownloads + ? `${trackFileCount} + ${newDownloads} / ${trackCount}` + : `${trackFileCount} / ${trackCount}`; + + return ( + 0 + )} + size={detailedProgressBar ? sizes.MEDIUM : sizes.SMALL} + showText={detailedProgressBar} + text={text} + title={translate('ArtistProgressBarText', { + trackFileCount, + trackCount, + totalTrackCount, + downloadingCount: queueDetails.count, + })} + width={width} + /> + ); +} + +export default ArtistIndexProgressBar; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css new file mode 100644 index 000000000..5f6ee37c1 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css @@ -0,0 +1,10 @@ +.albums { + display: flex; + flex-wrap: wrap; +} + +.truncated { + align-self: center; + flex: 0 0 100%; + padding: 4px 6px; +} diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css.d.ts b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css.d.ts new file mode 100644 index 000000000..13c576f2c --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'albums': string; + 'truncated': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.tsx b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.tsx new file mode 100644 index 000000000..255bd9ba4 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.tsx @@ -0,0 +1,89 @@ +import _ from 'lodash'; +import React, { useEffect, useMemo } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { Statistics } from 'Album/Album'; +import Alert from 'Components/Alert'; +import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import { kinds } from 'Helpers/Props'; +import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; +import createArtistAlbumsSelector from 'Store/Selectors/createArtistAlbumsSelector'; +import translate from 'Utilities/String/translate'; +import AlbumStudioAlbum from './AlbumStudioAlbum'; +import styles from './AlbumDetails.css'; + +interface AlbumDetailsProps { + artistId: number; +} + +function AlbumDetails(props: AlbumDetailsProps) { + const { artistId } = props; + + const { + isFetching, + isPopulated, + error, + items: albums, + } = useSelector(createArtistAlbumsSelector(artistId)); + + const dispatch = useDispatch(); + + useEffect(() => { + dispatch(fetchAlbums({ artistId })); + + return () => { + dispatch(clearAlbums()); + }; + }, [dispatch, artistId]); + + const latestAlbums = useMemo(() => { + const sortedAlbums = _.orderBy(albums, 'releaseDate', 'desc'); + + return sortedAlbums.slice(0, 20); + }, [albums]); + + return ( +
+ {isFetching ? : null} + + {!isFetching && error ? ( + {translate('AlbumsLoadError')} + ) : null} + + {isPopulated && !error + ? latestAlbums.map((album) => { + const { + id: albumId, + title, + disambiguation, + albumType, + monitored, + statistics = {} as Statistics, + isSaving = false, + } = album; + + return ( + + ); + }) + : null} + + {latestAlbums.length < albums.length ? ( +
+ {translate('AlbumStudioTruncated')} +
+ ) : null} +
+ ); +} + +export default AlbumDetails; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css new file mode 100644 index 000000000..c568a2489 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css @@ -0,0 +1,39 @@ +.album { + display: flex; + align-items: stretch; + overflow: hidden; + margin: 2px 4px; + border: 1px solid var(--borderColor); + border-radius: 4px; + background-color: var(--albumBackgroundColor); + cursor: default; +} + +.info { + padding: 0 4px; +} + +.albumType { + padding: 0 4px; + border-width: 0 1px; + border-style: solid; + border-color: var(--borderColor); + background-color: var(--albumBackgroundColor); + color: var(--defaultColor); +} + +.tracks { + padding: 0 4px; + background-color: var(--trackBackgroundColor); + color: var(--defaultColor); +} + +.allTracks { + background-color: color(#27c24c saturation(-25%)); + color: var(--white); +} + +.missingWanted { + background-color: color(#f05050 saturation(-20%)); + color: var(--white); +} diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css.d.ts b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css.d.ts new file mode 100644 index 000000000..31142374e --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'album': string; + 'albumType': string; + 'allTracks': string; + 'info': string; + 'missingWanted': string; + 'tracks': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.tsx b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.tsx new file mode 100644 index 000000000..3e7e0578f --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.tsx @@ -0,0 +1,87 @@ +import classNames from 'classnames'; +import React, { useCallback } from 'react'; +import { useDispatch } from 'react-redux'; +import { Statistics } from 'Album/Album'; +import MonitorToggleButton from 'Components/MonitorToggleButton'; +import { toggleAlbumsMonitored } from 'Store/Actions/albumActions'; +import translate from 'Utilities/String/translate'; +import styles from './AlbumStudioAlbum.css'; + +interface AlbumStudioAlbumProps { + artistId: number; + albumId: number; + title: string; + disambiguation?: string; + albumType: string; + monitored: boolean; + statistics: Statistics; + isSaving: boolean; +} + +function AlbumStudioAlbum(props: AlbumStudioAlbumProps) { + const { + albumId, + title, + disambiguation, + albumType, + monitored, + statistics = { + trackFileCount: 0, + totalTrackCount: 0, + percentOfTracks: 0, + }, + isSaving = false, + } = props; + + const { + trackFileCount = 0, + totalTrackCount = 0, + percentOfTracks = 0, + } = statistics; + + const dispatch = useDispatch(); + const onAlbumMonitoredPress = useCallback(() => { + dispatch( + toggleAlbumsMonitored({ + albumIds: [albumId], + monitored: !monitored, + }) + ); + }, [albumId, monitored, dispatch]); + + return ( +
+
+ + + + {disambiguation ? `${title} (${disambiguation})` : `${title}`} + +
+ +
+ {albumType} +
+ +
+ {totalTrackCount === 0 ? '0/0' : `${trackFileCount}/${totalTrackCount}`} +
+
+ ); +} + +export default AlbumStudioAlbum; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModal.tsx b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModal.tsx new file mode 100644 index 000000000..b48717af0 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModal.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import ChangeMonitoringModalContent from './ChangeMonitoringModalContent'; + +interface ChangeMonitoringModalProps { + isOpen: boolean; + artistIds: number[]; + onSavePress(monitor: string): void; + onModalClose(): void; +} + +function ChangeMonitoringModal(props: ChangeMonitoringModalProps) { + const { isOpen, artistIds, onSavePress, onModalClose } = props; + + return ( + + + + ); +} + +export default ChangeMonitoringModal; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css new file mode 100644 index 000000000..29dc69dc4 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css @@ -0,0 +1,26 @@ +.labelIcon { + margin-left: 8px; +} + +.message { + composes: alert from '~Components/Alert.css'; + + margin-bottom: 30px; +} + +.modalFooter { + composes: modalFooter from '~Components/Modal/ModalFooter.css'; + + justify-content: space-between; +} + +.selected { + font-weight: bold; +} + +@media only screen and (max-width: $breakpointExtraSmall) { + .modalFooter { + flex-direction: column; + gap: 10px; + } +} diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css.d.ts b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css.d.ts new file mode 100644 index 000000000..4c59f6545 --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'labelIcon': string; + 'message': string; + 'modalFooter': string; + 'selected': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.tsx b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.tsx new file mode 100644 index 000000000..b3c2abbbe --- /dev/null +++ b/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.tsx @@ -0,0 +1,96 @@ +import React, { useCallback, useState } from 'react'; +import ArtistMonitoringOptionsPopoverContent from 'AddArtist/ArtistMonitoringOptionsPopoverContent'; +import Alert from 'Components/Alert'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import Popover from 'Components/Tooltip/Popover'; +import { icons, inputTypes, kinds, tooltipPositions } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import styles from './ChangeMonitoringModalContent.css'; + +const NO_CHANGE = 'noChange'; + +interface ChangeMonitoringModalContentProps { + artistIds: number[]; + saveError?: object; + onSavePress(monitor: string): void; + onModalClose(): void; +} + +function ChangeMonitoringModalContent( + props: ChangeMonitoringModalContentProps +) { + const { artistIds, onSavePress, onModalClose, ...otherProps } = props; + + const [monitor, setMonitor] = useState(NO_CHANGE); + + const onInputChange = useCallback( + ({ value }: { value: string }) => { + setMonitor(value); + }, + [setMonitor] + ); + + const onSavePressWrapper = useCallback(() => { + onSavePress(monitor); + }, [monitor, onSavePress]); + + const selectedCount = artistIds.length; + + return ( + + {translate('MonitorArtists')} + + + + {translate('MonitorAlbumExistingOnlyWarning')} + + +
+ + + {translate('MonitorExistingAlbums')} + + } + title={translate('MonitoringOptions')} + body={} + position={tooltipPositions.RIGHT} + /> + + + + +
+
+ + +
+ {translate('CountArtistsSelected', { count: selectedCount })} +
+ +
+ + + +
+
+
+ ); +} + +export default ChangeMonitoringModalContent; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css new file mode 100644 index 000000000..eccb80f87 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css @@ -0,0 +1,38 @@ +.checkButton { + position: absolute; + top: 0; + left: 0; + z-index: 3; + width: 36px; + height: 36px; +} + +.checkContainer { + position: absolute; + top: 8px; + left: 8px; + width: 20px; + height: 20px; + border-radius: 50%; + background-color: var(--defaultColor); +} + +.selected { + color: var(--lidarrGreen); +} + +.unselected { + color: var(--white); +} + +.checkButton { + &:hover { + .selected { + color: var(--white); + } + + .unselected { + color: var(--lidarrGreen); + } + } +} diff --git a/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css.d.ts b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css.d.ts new file mode 100644 index 000000000..d4de0b5f5 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'checkButton': string; + 'checkContainer': string; + 'selected': string; + 'unselected': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.tsx b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.tsx new file mode 100644 index 000000000..86b41e8ba --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.tsx @@ -0,0 +1,45 @@ +import React, { SyntheticEvent, useCallback } from 'react'; +import { useSelect } from 'App/SelectContext'; +import Icon from 'Components/Icon'; +import Link from 'Components/Link/Link'; +import { icons } from 'Helpers/Props'; +import styles from './ArtistIndexPosterSelect.css'; + +interface ArtistIndexPosterSelectProps { + artistId: number; +} + +function ArtistIndexPosterSelect(props: ArtistIndexPosterSelectProps) { + const { artistId } = props; + const [selectState, selectDispatch] = useSelect(); + const isSelected = selectState.selectedState[artistId]; + + const onSelectPress = useCallback( + (event: SyntheticEvent) => { + const nativeEvent = event.nativeEvent as PointerEvent; + const shiftKey = nativeEvent.shiftKey; + + selectDispatch({ + type: 'toggleSelected', + id: artistId, + isSelected: !isSelected, + shiftKey, + }); + }, + [artistId, isSelected, selectDispatch] + ); + + return ( + + + + + + ); +} + +export default ArtistIndexPosterSelect; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectAllButton.tsx b/frontend/src/Artist/Index/Select/ArtistIndexSelectAllButton.tsx new file mode 100644 index 000000000..2b3e9c01c --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectAllButton.tsx @@ -0,0 +1,40 @@ +import React, { useCallback } from 'react'; +import { useSelect } from 'App/SelectContext'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; +import { icons } from 'Helpers/Props'; + +interface ArtistIndexSelectAllButtonProps { + label: string; + isSelectMode: boolean; + overflowComponent: React.FunctionComponent; +} + +function ArtistIndexSelectAllButton(props: ArtistIndexSelectAllButtonProps) { + const { isSelectMode } = props; + const [selectState, selectDispatch] = useSelect(); + const { allSelected, allUnselected } = selectState; + + let icon = icons.SQUARE_MINUS; + + if (allSelected) { + icon = icons.CHECK_SQUARE; + } else if (allUnselected) { + icon = icons.SQUARE; + } + + const onPress = useCallback(() => { + selectDispatch({ + type: allSelected ? 'unselectAll' : 'selectAll', + }); + }, [allSelected, selectDispatch]); + + return isSelectMode ? ( + + ) : null; +} + +export default ArtistIndexSelectAllButton; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectAllMenuItem.tsx b/frontend/src/Artist/Index/Select/ArtistIndexSelectAllMenuItem.tsx new file mode 100644 index 000000000..2340b65b6 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectAllMenuItem.tsx @@ -0,0 +1,41 @@ +import React, { useCallback } from 'react'; +import { useSelect } from 'App/SelectContext'; +import PageToolbarOverflowMenuItem from 'Components/Page/Toolbar/PageToolbarOverflowMenuItem'; +import { icons } from 'Helpers/Props'; + +interface ArtistIndexSelectAllMenuItemProps { + label: string; + isSelectMode: boolean; +} + +function ArtistIndexSelectAllMenuItem( + props: ArtistIndexSelectAllMenuItemProps +) { + const { isSelectMode } = props; + const [selectState, selectDispatch] = useSelect(); + const { allSelected, allUnselected } = selectState; + + let iconName = icons.SQUARE_MINUS; + + if (allSelected) { + iconName = icons.CHECK_SQUARE; + } else if (allUnselected) { + iconName = icons.SQUARE; + } + + const onPressWrapper = useCallback(() => { + selectDispatch({ + type: allSelected ? 'unselectAll' : 'selectAll', + }); + }, [allSelected, selectDispatch]); + + return isSelectMode ? ( + + ) : null; +} + +export default ArtistIndexSelectAllMenuItem; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css new file mode 100644 index 000000000..d385923ef --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css @@ -0,0 +1,72 @@ +.footer { + composes: contentFooter from '~Components/Page/PageContentFooter.css'; + + align-items: center; +} + +.buttons { + display: flex; +} + +.actionButtons, +.deleteButtons { + display: flex; + gap: 10px; +} + +.deleteButtons { + margin-left: 50px; +} + +.selected { + display: flex; + justify-content: flex-end; + flex-grow: 1; + font-weight: bold; +} + +@media only screen and (max-width: $breakpointMedium) { + .buttons { + justify-content: center; + width: 100%; + } + + .selected { + justify-content: center; + margin-bottom: 20px; + width: 100%; + order: -1; + } +} + +@media only screen and (max-width: $breakpointSmall) { + .footer { + display: flex; + flex-direction: column; + } + + .buttons { + flex-direction: column; + margin-top: 20px; + gap: 20px; + } + + .actionButtons { + flex-wrap: wrap; + } + + .actionButtons, + .deleteButtons { + display: flex; + justify-content: center; + } + + .deleteButtons { + margin-left: 0; + } + + .selected { + justify-content: center; + order: -1; + } +} diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css.d.ts b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css.d.ts new file mode 100644 index 000000000..7f02229e3 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actionButtons': string; + 'buttons': string; + 'deleteButtons': string; + 'footer': string; + 'selected': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.tsx b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.tsx new file mode 100644 index 000000000..f0569d607 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.tsx @@ -0,0 +1,300 @@ +import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import { useSelect } from 'App/SelectContext'; +import AppState from 'App/State/AppState'; +import { RENAME_ARTIST, RETAG_ARTIST } from 'Commands/commandNames'; +import SpinnerButton from 'Components/Link/SpinnerButton'; +import PageContentFooter from 'Components/Page/PageContentFooter'; +import usePrevious from 'Helpers/Hooks/usePrevious'; +import { kinds } from 'Helpers/Props'; +import { + saveArtistEditor, + updateArtistsMonitor, +} from 'Store/Actions/artistActions'; +import { fetchRootFolders } from 'Store/Actions/settingsActions'; +import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +import translate from 'Utilities/String/translate'; +import getSelectedIds from 'Utilities/Table/getSelectedIds'; +import ChangeMonitoringModal from './AlbumStudio/ChangeMonitoringModal'; +import RetagArtistModal from './AudioTags/RetagArtistModal'; +import DeleteArtistModal from './Delete/DeleteArtistModal'; +import EditArtistModal from './Edit/EditArtistModal'; +import OrganizeArtistModal from './Organize/OrganizeArtistModal'; +import TagsModal from './Tags/TagsModal'; +import styles from './ArtistIndexSelectFooter.css'; + +interface SavePayload { + monitored?: boolean; + qualityProfileId?: number; + metadataProfileId?: number; + rootFolderPath?: string; + moveFiles?: boolean; +} + +const artistEditorSelector = createSelector( + (state: AppState) => state.artist, + (artist) => { + const { isSaving, isDeleting, deleteError } = artist; + + return { + isSaving, + isDeleting, + deleteError, + }; + } +); + +function ArtistIndexSelectFooter() { + const { isSaving, isDeleting, deleteError } = + useSelector(artistEditorSelector); + + const isOrganizingArtist = useSelector( + createCommandExecutingSelector(RENAME_ARTIST) + ); + const isRetaggingArtist = useSelector( + createCommandExecutingSelector(RETAG_ARTIST) + ); + + const dispatch = useDispatch(); + + const [isEditModalOpen, setIsEditModalOpen] = useState(false); + const [isOrganizeModalOpen, setIsOrganizeModalOpen] = useState(false); + const [isRetaggingModalOpen, setIsRetaggingModalOpen] = useState(false); + const [isTagsModalOpen, setIsTagsModalOpen] = useState(false); + const [isMonitoringModalOpen, setIsMonitoringModalOpen] = useState(false); + const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); + const [isSavingArtist, setIsSavingArtist] = useState(false); + const [isSavingTags, setIsSavingTags] = useState(false); + const [isSavingMonitoring, setIsSavingMonitoring] = useState(false); + const previousIsDeleting = usePrevious(isDeleting); + + const [selectState, selectDispatch] = useSelect(); + const { selectedState } = selectState; + + const artistIds = useMemo(() => { + return getSelectedIds(selectedState); + }, [selectedState]); + + const selectedCount = artistIds.length; + + const onEditPress = useCallback(() => { + setIsEditModalOpen(true); + }, [setIsEditModalOpen]); + + const onEditModalClose = useCallback(() => { + setIsEditModalOpen(false); + }, [setIsEditModalOpen]); + + const onSavePress = useCallback( + (payload: SavePayload) => { + setIsSavingArtist(true); + setIsEditModalOpen(false); + + dispatch( + saveArtistEditor({ + ...payload, + artistIds, + }) + ); + }, + [artistIds, dispatch] + ); + + const onOrganizePress = useCallback(() => { + setIsOrganizeModalOpen(true); + }, [setIsOrganizeModalOpen]); + + const onOrganizeModalClose = useCallback(() => { + setIsOrganizeModalOpen(false); + }, [setIsOrganizeModalOpen]); + + const onRetagPress = useCallback(() => { + setIsRetaggingModalOpen(true); + }, [setIsRetaggingModalOpen]); + + const onRetagModalClose = useCallback(() => { + setIsRetaggingModalOpen(false); + }, [setIsRetaggingModalOpen]); + + const onTagsPress = useCallback(() => { + setIsTagsModalOpen(true); + }, [setIsTagsModalOpen]); + + const onTagsModalClose = useCallback(() => { + setIsTagsModalOpen(false); + }, [setIsTagsModalOpen]); + + const onApplyTagsPress = useCallback( + (tags: number[], applyTags: string) => { + setIsSavingTags(true); + setIsTagsModalOpen(false); + + dispatch( + saveArtistEditor({ + artistIds, + tags, + applyTags, + }) + ); + }, + [artistIds, dispatch] + ); + + const onMonitoringPress = useCallback(() => { + setIsMonitoringModalOpen(true); + }, [setIsMonitoringModalOpen]); + + const onMonitoringClose = useCallback(() => { + setIsMonitoringModalOpen(false); + }, [setIsMonitoringModalOpen]); + + const onMonitoringSavePress = useCallback( + (monitor: string) => { + setIsSavingMonitoring(true); + setIsMonitoringModalOpen(false); + + dispatch( + updateArtistsMonitor({ + artistIds, + monitor, + }) + ); + }, + [artistIds, dispatch] + ); + + const onDeletePress = useCallback(() => { + setIsDeleteModalOpen(true); + }, [setIsDeleteModalOpen]); + + const onDeleteModalClose = useCallback(() => { + setIsDeleteModalOpen(false); + }, []); + + useEffect(() => { + if (!isSaving) { + setIsSavingArtist(false); + setIsSavingTags(false); + setIsSavingMonitoring(false); + } + }, [isSaving]); + + useEffect(() => { + if (previousIsDeleting && !isDeleting && !deleteError) { + selectDispatch({ type: 'unselectAll' }); + } + }, [previousIsDeleting, isDeleting, deleteError, selectDispatch]); + + useEffect(() => { + dispatch(fetchRootFolders()); + }, [dispatch]); + + const anySelected = selectedCount > 0; + + return ( + +
+
+ + {translate('Edit')} + + + + {translate('RenameFiles')} + + + + {translate('WriteMetadataTags')} + + + + {translate('SetAppTags')} + + + + {translate('UpdateMonitoring')} + +
+ +
+ + {translate('Delete')} + +
+
+ +
+ {translate('CountArtistsSelected', { count: selectedCount })} +
+ + + + + + + + + + + + +
+ ); +} + +export default ArtistIndexSelectFooter; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectModeButton.tsx b/frontend/src/Artist/Index/Select/ArtistIndexSelectModeButton.tsx new file mode 100644 index 000000000..8679bba99 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectModeButton.tsx @@ -0,0 +1,37 @@ +import { IconDefinition } from '@fortawesome/fontawesome-common-types'; +import React, { useCallback } from 'react'; +import { useSelect } from 'App/SelectContext'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; + +interface ArtistIndexSelectModeButtonProps { + label: string; + iconName: IconDefinition; + isSelectMode: boolean; + overflowComponent: React.FunctionComponent; + onPress: () => void; +} + +function ArtistIndexSelectModeButton(props: ArtistIndexSelectModeButtonProps) { + const { label, iconName, isSelectMode, onPress } = props; + const [, selectDispatch] = useSelect(); + + const onPressWrapper = useCallback(() => { + if (isSelectMode) { + selectDispatch({ + type: 'reset', + }); + } + + onPress(); + }, [isSelectMode, onPress, selectDispatch]); + + return ( + + ); +} + +export default ArtistIndexSelectModeButton; diff --git a/frontend/src/Artist/Index/Select/ArtistIndexSelectModeMenuItem.tsx b/frontend/src/Artist/Index/Select/ArtistIndexSelectModeMenuItem.tsx new file mode 100644 index 000000000..b5a7a6de4 --- /dev/null +++ b/frontend/src/Artist/Index/Select/ArtistIndexSelectModeMenuItem.tsx @@ -0,0 +1,38 @@ +import { IconDefinition } from '@fortawesome/fontawesome-common-types'; +import React, { useCallback } from 'react'; +import { useSelect } from 'App/SelectContext'; +import PageToolbarOverflowMenuItem from 'Components/Page/Toolbar/PageToolbarOverflowMenuItem'; + +interface ArtistIndexSelectModeMenuItemProps { + label: string; + iconName: IconDefinition; + isSelectMode: boolean; + onPress: () => void; +} + +function ArtistIndexSelectModeMenuItem( + props: ArtistIndexSelectModeMenuItemProps +) { + const { label, iconName, isSelectMode, onPress } = props; + const [, selectDispatch] = useSelect(); + + const onPressWrapper = useCallback(() => { + if (isSelectMode) { + selectDispatch({ + type: 'reset', + }); + } + + onPress(); + }, [isSelectMode, onPress, selectDispatch]); + + return ( + + ); +} + +export default ArtistIndexSelectModeMenuItem; diff --git a/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModal.tsx b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModal.tsx new file mode 100644 index 000000000..5d5f1fb6a --- /dev/null +++ b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModal.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import RetagArtistModalContent from './RetagArtistModalContent'; + +interface RetagArtistModalProps { + isOpen: boolean; + artistIds: number[]; + onModalClose: () => void; +} + +function RetagArtistModal(props: RetagArtistModalProps) { + const { isOpen, onModalClose, ...otherProps } = props; + + return ( + + + + ); +} + +export default RetagArtistModal; diff --git a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.css b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css similarity index 100% rename from frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.css rename to frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css diff --git a/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css.d.ts new file mode 100644 index 000000000..c2556006e --- /dev/null +++ b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; + 'retagIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.tsx b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.tsx new file mode 100644 index 000000000..b67ee60aa --- /dev/null +++ b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.tsx @@ -0,0 +1,91 @@ +import { orderBy } from 'lodash'; +import React, { useCallback, useMemo } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import Artist from 'Artist/Artist'; +import { RETAG_ARTIST } from 'Commands/commandNames'; +import Alert from 'Components/Alert'; +import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { icons, kinds } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import translate from 'Utilities/String/translate'; +import styles from './RetagArtistModalContent.css'; + +interface RetagArtistModalContentProps { + artistIds: number[]; + onModalClose: () => void; +} + +function RetagArtistModalContent(props: RetagArtistModalContentProps) { + const { artistIds, onModalClose } = props; + + const allArtists: Artist[] = useSelector(createAllArtistSelector()); + const dispatch = useDispatch(); + + const artistNames = useMemo(() => { + const artists = artistIds.reduce((acc: Artist[], id) => { + const a = allArtists.find((a) => a.id === id); + + if (a) { + acc.push(a); + } + + return acc; + }, []); + + const sorted = orderBy(artists, ['sortName']); + + return sorted.map((a) => a.artistName); + }, [artistIds, allArtists]); + + const onRetagPress = useCallback(() => { + dispatch( + executeCommand({ + name: RETAG_ARTIST, + artistIds, + }) + ); + + onModalClose(); + }, [artistIds, onModalClose, dispatch]); + + return ( + + {translate('RetagSelectedArtists')} + + + + Tip: To preview the tags that will be written, select "Cancel", then + select any artist name and use the + + + +
+ Are you sure you want to retag all files in the {artistNames.length}{' '} + selected artist? +
+ +
    + {artistNames.map((artistName) => { + return
  • {artistName}
  • ; + })} +
+
+ + + + + + +
+ ); +} + +export default RetagArtistModalContent; diff --git a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModal.tsx b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModal.tsx new file mode 100644 index 000000000..c909d7406 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModal.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import DeleteArtistModalContent from './DeleteArtistModalContent'; + +interface DeleteArtistModalProps { + isOpen: boolean; + artistIds: number[]; + onModalClose(): void; +} + +function DeleteArtistModal(props: DeleteArtistModalProps) { + const { isOpen, artistIds, onModalClose } = props; + + return ( + + + + ); +} + +export default DeleteArtistModal; diff --git a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.css b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css similarity index 81% rename from frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.css rename to frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css index 950fdc27d..02a0514be 100644 --- a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.css +++ b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css @@ -9,5 +9,5 @@ .path { margin-left: 5px; - color: $dangerColor; + color: var(--dangerColor); } diff --git a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css.d.ts new file mode 100644 index 000000000..bcc2e2492 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; + 'path': string; + 'pathContainer': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.tsx b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.tsx new file mode 100644 index 000000000..4accc9f0e --- /dev/null +++ b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.tsx @@ -0,0 +1,166 @@ +import { orderBy } from 'lodash'; +import React, { useCallback, useMemo, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import Artist from 'Artist/Artist'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes, kinds } from 'Helpers/Props'; +import { bulkDeleteArtist, setDeleteOption } from 'Store/Actions/artistActions'; +import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import { CheckInputChanged } from 'typings/inputs'; +import translate from 'Utilities/String/translate'; +import styles from './DeleteArtistModalContent.css'; + +interface DeleteArtistModalContentProps { + artistIds: number[]; + onModalClose(): void; +} + +const selectDeleteOptions = createSelector( + (state: AppState) => state.artist.deleteOptions, + (deleteOptions) => deleteOptions +); + +function DeleteArtistModalContent(props: DeleteArtistModalContentProps) { + const { artistIds, onModalClose } = props; + + const { addImportListExclusion } = useSelector(selectDeleteOptions); + const allArtists: Artist[] = useSelector(createAllArtistSelector()); + const dispatch = useDispatch(); + + const [deleteFiles, setDeleteFiles] = useState(false); + + const artists = useMemo((): Artist[] => { + const artistList = artistIds.map((id) => { + return allArtists.find((a) => a.id === id); + }) as Artist[]; + + return orderBy(artistList, ['sortName']); + }, [artistIds, allArtists]); + + const onDeleteFilesChange = useCallback( + ({ value }: CheckInputChanged) => { + setDeleteFiles(value); + }, + [setDeleteFiles] + ); + + const onDeleteOptionChange = useCallback( + ({ name, value }: { name: string; value: boolean }) => { + dispatch( + setDeleteOption({ + [name]: value, + }) + ); + }, + [dispatch] + ); + + const onDeleteArtistConfirmed = useCallback(() => { + setDeleteFiles(false); + + dispatch( + bulkDeleteArtist({ + artistIds, + deleteFiles, + addImportListExclusion, + }) + ); + + onModalClose(); + }, [ + artistIds, + deleteFiles, + addImportListExclusion, + setDeleteFiles, + dispatch, + onModalClose, + ]); + + return ( + + {translate('DeleteSelectedArtists')} + + +
+ + {translate('AddListExclusion')} + + + + + + + {artists.length > 1 + ? translate('DeleteArtistFolders') + : translate('DeleteArtistFolder')} + + + 1 + ? translate('DeleteArtistFoldersHelpText') + : translate('DeleteArtistFolderHelpText') + } + kind={kinds.DANGER} + onChange={onDeleteFilesChange} + /> + +
+ +
+ {deleteFiles + ? translate('DeleteArtistFolderCountWithFilesConfirmation', { + count: artists.length, + }) + : translate('DeleteArtistFolderCountConfirmation', { + count: artists.length, + })} +
+ +
    + {artists.map((a) => { + return ( +
  • + {a.artistName} + + {deleteFiles && ( + + -{a.path} + + )} +
  • + ); + })} +
+
+ + + + + + +
+ ); +} + +export default DeleteArtistModalContent; diff --git a/frontend/src/Artist/Index/Select/Edit/EditArtistModal.tsx b/frontend/src/Artist/Index/Select/Edit/EditArtistModal.tsx new file mode 100644 index 000000000..bdb6726be --- /dev/null +++ b/frontend/src/Artist/Index/Select/Edit/EditArtistModal.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import EditArtistModalContent from './EditArtistModalContent'; + +interface EditArtistModalProps { + isOpen: boolean; + artistIds: number[]; + onSavePress(payload: object): void; + onModalClose(): void; +} + +function EditArtistModal(props: EditArtistModalProps) { + const { isOpen, artistIds, onSavePress, onModalClose } = props; + + return ( + + + + ); +} + +export default EditArtistModal; diff --git a/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css new file mode 100644 index 000000000..ea406894e --- /dev/null +++ b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css @@ -0,0 +1,16 @@ +.modalFooter { + composes: modalFooter from '~Components/Modal/ModalFooter.css'; + + justify-content: space-between; +} + +.selected { + font-weight: bold; +} + +@media only screen and (max-width: $breakpointExtraSmall) { + .modalFooter { + flex-direction: column; + gap: 10px; + } +} diff --git a/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css.d.ts new file mode 100644 index 000000000..cbf2d6328 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'modalFooter': string; + 'selected': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.tsx b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.tsx new file mode 100644 index 000000000..993be8ce5 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.tsx @@ -0,0 +1,264 @@ +import React, { useCallback, useState } from 'react'; +import MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import styles from './EditArtistModalContent.css'; + +interface SavePayload { + monitored?: boolean; + monitorNewItems?: string; + qualityProfileId?: number; + metadataProfileId?: number; + rootFolderPath?: string; + moveFiles?: boolean; +} + +interface EditArtistModalContentProps { + artistIds: number[]; + onSavePress(payload: object): void; + onModalClose(): void; +} + +const NO_CHANGE = 'noChange'; + +const monitoredOptions = [ + { + key: NO_CHANGE, + get value() { + return translate('NoChange'); + }, + isDisabled: true, + }, + { + key: 'monitored', + get value() { + return translate('Monitored'); + }, + }, + { + key: 'unmonitored', + get value() { + return translate('Unmonitored'); + }, + }, +]; + +function EditArtistModalContent(props: EditArtistModalContentProps) { + const { artistIds, onSavePress, onModalClose } = props; + + const [monitored, setMonitored] = useState(NO_CHANGE); + const [monitorNewItems, setMonitorNewItems] = useState(NO_CHANGE); + const [qualityProfileId, setQualityProfileId] = useState( + NO_CHANGE + ); + const [metadataProfileId, setMetadataProfileId] = useState( + NO_CHANGE + ); + const [rootFolderPath, setRootFolderPath] = useState(NO_CHANGE); + const [isConfirmMoveModalOpen, setIsConfirmMoveModalOpen] = useState(false); + + const save = useCallback( + (moveFiles: boolean) => { + let hasChanges = false; + const payload: SavePayload = {}; + + if (monitored !== NO_CHANGE) { + hasChanges = true; + payload.monitored = monitored === 'monitored'; + } + + if (monitorNewItems !== NO_CHANGE) { + hasChanges = true; + payload.monitorNewItems = monitorNewItems; + } + + if (qualityProfileId !== NO_CHANGE) { + hasChanges = true; + payload.qualityProfileId = qualityProfileId as number; + } + + if (metadataProfileId !== NO_CHANGE) { + hasChanges = true; + payload.metadataProfileId = metadataProfileId as number; + } + + if (rootFolderPath !== NO_CHANGE) { + hasChanges = true; + payload.rootFolderPath = rootFolderPath; + payload.moveFiles = moveFiles; + } + + if (hasChanges) { + onSavePress(payload); + } + + onModalClose(); + }, + [ + monitored, + monitorNewItems, + qualityProfileId, + metadataProfileId, + rootFolderPath, + onSavePress, + onModalClose, + ] + ); + + const onInputChange = useCallback( + ({ name, value }: { name: string; value: string }) => { + switch (name) { + case 'monitored': + setMonitored(value); + break; + case 'monitorNewItems': + setMonitorNewItems(value); + break; + case 'qualityProfileId': + setQualityProfileId(value); + break; + case 'metadataProfileId': + setMetadataProfileId(value); + break; + case 'rootFolderPath': + setRootFolderPath(value); + break; + default: + console.warn('EditArtistModalContent Unknown Input'); + } + }, + [setMonitored] + ); + + const onSavePressWrapper = useCallback(() => { + if (rootFolderPath === NO_CHANGE) { + save(false); + } else { + setIsConfirmMoveModalOpen(true); + } + }, [rootFolderPath, save]); + + const onCancelPress = useCallback(() => { + setIsConfirmMoveModalOpen(false); + }, [setIsConfirmMoveModalOpen]); + + const onDoNotMoveArtistPress = useCallback(() => { + setIsConfirmMoveModalOpen(false); + save(false); + }, [setIsConfirmMoveModalOpen, save]); + + const onMoveArtistPress = useCallback(() => { + setIsConfirmMoveModalOpen(false); + save(true); + }, [setIsConfirmMoveModalOpen, save]); + + const selectedCount = artistIds.length; + + return ( + + {translate('EditSelectedArtists')} + + + + {translate('Monitored')} + + + + + + {translate('MonitorNewItems')} + + + + + + {translate('QualityProfile')} + + + + + + {translate('MetadataProfile')} + + + + + + {translate('RootFolder')} + + + + + + +
+ {translate('CountArtistsSelected', { count: selectedCount })} +
+ +
+ + + +
+
+ + +
+ ); +} + +export default EditArtistModalContent; diff --git a/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModal.tsx b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModal.tsx new file mode 100644 index 000000000..bec35222b --- /dev/null +++ b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModal.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import OrganizeArtistModalContent from './OrganizeArtistModalContent'; + +interface OrganizeArtistModalProps { + isOpen: boolean; + artistIds: number[]; + onModalClose: () => void; +} + +function OrganizeArtistModal(props: OrganizeArtistModalProps) { + const { isOpen, onModalClose, ...otherProps } = props; + + return ( + + + + ); +} + +export default OrganizeArtistModal; diff --git a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.css b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css similarity index 100% rename from frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.css rename to frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css diff --git a/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css.d.ts new file mode 100644 index 000000000..ae2303476 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; + 'renameIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.tsx b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.tsx new file mode 100644 index 000000000..8184abba7 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.tsx @@ -0,0 +1,91 @@ +import { orderBy } from 'lodash'; +import React, { useCallback, useMemo } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import Artist from 'Artist/Artist'; +import { RENAME_ARTIST } from 'Commands/commandNames'; +import Alert from 'Components/Alert'; +import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { icons, kinds } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import translate from 'Utilities/String/translate'; +import styles from './OrganizeArtistModalContent.css'; + +interface OrganizeArtistModalContentProps { + artistIds: number[]; + onModalClose: () => void; +} + +function OrganizeArtistModalContent(props: OrganizeArtistModalContentProps) { + const { artistIds, onModalClose } = props; + + const allArtists: Artist[] = useSelector(createAllArtistSelector()); + const dispatch = useDispatch(); + + const artistNames = useMemo(() => { + const artists = artistIds.reduce((acc: Artist[], id) => { + const a = allArtists.find((a) => a.id === id); + + if (a) { + acc.push(a); + } + + return acc; + }, []); + + const sorted = orderBy(artists, ['sortName']); + + return sorted.map((a) => a.artistName); + }, [artistIds, allArtists]); + + const onOrganizePress = useCallback(() => { + dispatch( + executeCommand({ + name: RENAME_ARTIST, + artistIds, + }) + ); + + onModalClose(); + }, [artistIds, onModalClose, dispatch]); + + return ( + + {translate('OrganizeSelectedArtists')} + + + + Tip: To preview a rename, select "Cancel", then select any artist name + and use the + + + +
+ Are you sure you want to organize all files in the{' '} + {artistNames.length} selected artist? +
+ +
    + {artistNames.map((artistName) => { + return
  • {artistName}
  • ; + })} +
+
+ + + + + + +
+ ); +} + +export default OrganizeArtistModalContent; diff --git a/frontend/src/Artist/Index/Select/Tags/TagsModal.tsx b/frontend/src/Artist/Index/Select/Tags/TagsModal.tsx new file mode 100644 index 000000000..8635867e4 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Tags/TagsModal.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import TagsModalContent from './TagsModalContent'; + +interface TagsModalProps { + isOpen: boolean; + artistIds: number[]; + onApplyTagsPress: (tags: number[], applyTags: string) => void; + onModalClose: () => void; +} + +function TagsModal(props: TagsModalProps) { + const { isOpen, onModalClose, ...otherProps } = props; + + return ( + + + + ); +} + +export default TagsModal; diff --git a/frontend/src/Artist/Editor/Tags/TagsModalContent.css b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css similarity index 100% rename from frontend/src/Artist/Editor/Tags/TagsModalContent.css rename to frontend/src/Artist/Index/Select/Tags/TagsModalContent.css diff --git a/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css.d.ts new file mode 100644 index 000000000..9b4321dcc --- /dev/null +++ b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'message': string; + 'renameIcon': string; + 'result': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Select/Tags/TagsModalContent.tsx b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.tsx new file mode 100644 index 000000000..95a7eaae2 --- /dev/null +++ b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.tsx @@ -0,0 +1,189 @@ +import { uniq } from 'lodash'; +import React, { useCallback, useMemo, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { Tag } from 'App/State/TagsAppState'; +import Artist from 'Artist/Artist'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Label from 'Components/Label'; +import Button from 'Components/Link/Button'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes, kinds, sizes } from 'Helpers/Props'; +import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import createTagsSelector from 'Store/Selectors/createTagsSelector'; +import translate from 'Utilities/String/translate'; +import styles from './TagsModalContent.css'; + +interface TagsModalContentProps { + artistIds: number[]; + onApplyTagsPress: (tags: number[], applyTags: string) => void; + onModalClose: () => void; +} + +function TagsModalContent(props: TagsModalContentProps) { + const { artistIds, onModalClose, onApplyTagsPress } = props; + + const allArtists: Artist[] = useSelector(createAllArtistSelector()); + const tagList: Tag[] = useSelector(createTagsSelector()); + + const [tags, setTags] = useState([]); + const [applyTags, setApplyTags] = useState('add'); + + const artistTags = useMemo(() => { + const tags = artistIds.reduce((acc: number[], id) => { + const a = allArtists.find((a) => a.id === id); + + if (a) { + acc.push(...a.tags); + } + + return acc; + }, []); + + return uniq(tags); + }, [artistIds, allArtists]); + + const onTagsChange = useCallback( + ({ value }: { value: number[] }) => { + setTags(value); + }, + [setTags] + ); + + const onApplyTagsChange = useCallback( + ({ value }: { value: string }) => { + setApplyTags(value); + }, + [setApplyTags] + ); + + const onApplyPress = useCallback(() => { + onApplyTagsPress(tags, applyTags); + }, [tags, applyTags, onApplyTagsPress]); + + const applyTagsOptions = [ + { + key: 'add', + value: translate('Add'), + }, + { + key: 'remove', + value: translate('Remove'), + }, + { + key: 'replace', + value: translate('Replace'), + }, + ]; + + return ( + + {translate('Tags')} + + +
+ + {translate('Tags')} + + + + + + {translate('ApplyTags')} + + + + + + {translate('Result')} + +
+ {artistTags.map((id) => { + const tag = tagList.find((t) => t.id === id); + + if (!tag) { + return null; + } + + const removeTag = + (applyTags === 'remove' && tags.indexOf(id) > -1) || + (applyTags === 'replace' && tags.indexOf(id) === -1); + + return ( + + ); + })} + + {(applyTags === 'add' || applyTags === 'replace') && + tags.map((id) => { + const tag = tagList.find((t) => t.id === id); + + if (!tag) { + return null; + } + + if (artistTags.indexOf(id) > -1) { + return null; + } + + return ( + + ); + })} +
+
+
+
+ + + + + + +
+ ); +} + +export default TagsModalContent; diff --git a/frontend/src/Artist/Index/Table/AlbumsCell.css b/frontend/src/Artist/Index/Table/AlbumsCell.css new file mode 100644 index 000000000..307c5d406 --- /dev/null +++ b/frontend/src/Artist/Index/Table/AlbumsCell.css @@ -0,0 +1,4 @@ +.albumCount { + width: 100%; + cursor: default; +} diff --git a/frontend/src/Artist/Index/Table/AlbumsCell.css.d.ts b/frontend/src/Artist/Index/Table/AlbumsCell.css.d.ts new file mode 100644 index 000000000..93d667287 --- /dev/null +++ b/frontend/src/Artist/Index/Table/AlbumsCell.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'albumCount': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Table/AlbumsCell.tsx b/frontend/src/Artist/Index/Table/AlbumsCell.tsx new file mode 100644 index 000000000..b42298b5d --- /dev/null +++ b/frontend/src/Artist/Index/Table/AlbumsCell.tsx @@ -0,0 +1,38 @@ +import React from 'react'; +import AlbumDetails from 'Artist/Index/Select/AlbumStudio/AlbumDetails'; +import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; +import Popover from 'Components/Tooltip/Popover'; +import TooltipPosition from 'Helpers/Props/TooltipPosition'; +import translate from 'Utilities/String/translate'; +import styles from './AlbumsCell.css'; + +interface SeriesStatusCellProps { + className: string; + artistId: number; + albumCount: number; + isSelectMode: boolean; +} + +function AlbumsCell(props: SeriesStatusCellProps) { + const { className, artistId, albumCount, isSelectMode, ...otherProps } = + props; + + return ( + + {isSelectMode && albumCount > 0 ? ( + } + position={TooltipPosition.Left} + canFlip={true} + /> + ) : ( + albumCount + )} + + ); +} + +export default AlbumsCell; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexActionsCell.js b/frontend/src/Artist/Index/Table/ArtistIndexActionsCell.js deleted file mode 100644 index 3f37cd56a..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexActionsCell.js +++ /dev/null @@ -1,102 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { icons } from 'Helpers/Props'; -import IconButton from 'Components/Link/IconButton'; -import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; -import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; -import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; -import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; - -class ArtistIndexActionsCell extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: false - }; - } - - // - // Listeners - - onEditArtistPress = () => { - this.setState({ isEditArtistModalOpen: true }); - } - - onEditArtistModalClose = () => { - this.setState({ isEditArtistModalOpen: false }); - } - - onDeleteArtistPress = () => { - this.setState({ - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: true - }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - // - // Render - - render() { - const { - id, - isRefreshingArtist, - onRefreshArtistPress, - ...otherProps - } = this.props; - - const { - isEditArtistModalOpen, - isDeleteArtistModalOpen - } = this.state; - - return ( - - - - - - - - - - ); - } -} - -ArtistIndexActionsCell.propTypes = { - id: PropTypes.number.isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired -}; - -export default ArtistIndexActionsCell; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexHeader.js b/frontend/src/Artist/Index/Table/ArtistIndexHeader.js deleted file mode 100644 index aed47bafa..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexHeader.js +++ /dev/null @@ -1,86 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import classNames from 'classnames'; -import { icons } from 'Helpers/Props'; -import IconButton from 'Components/Link/IconButton'; -import VirtualTableHeader from 'Components/Table/VirtualTableHeader'; -import VirtualTableHeaderCell from 'Components/Table/VirtualTableHeaderCell'; -import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; -import hasGrowableColumns from './hasGrowableColumns'; -import ArtistIndexTableOptionsConnector from './ArtistIndexTableOptionsConnector'; -import styles from './ArtistIndexHeader.css'; - -function ArtistIndexHeader(props) { - const { - showBanners, - columns, - onTableOptionChange, - ...otherProps - } = props; - - return ( - - { - columns.map((column) => { - const { - name, - label, - isSortable, - isVisible - } = column; - - if (!isVisible) { - return null; - } - - if (name === 'actions') { - return ( - - - - - - - ); - } - - return ( - - {label} - - ); - }) - } - - ); -} - -ArtistIndexHeader.propTypes = { - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - onTableOptionChange: PropTypes.func.isRequired, - showBanners: PropTypes.bool.isRequired -}; - -export default ArtistIndexHeader; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexHeaderConnector.js b/frontend/src/Artist/Index/Table/ArtistIndexHeaderConnector.js deleted file mode 100644 index 37ddd9ef3..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexHeaderConnector.js +++ /dev/null @@ -1,13 +0,0 @@ -import { connect } from 'react-redux'; -import { setArtistTableOption } from 'Store/Actions/artistIndexActions'; -import ArtistIndexHeader from './ArtistIndexHeader'; - -function createMapDispatchToProps(dispatch, props) { - return { - onTableOptionChange(payload) { - dispatch(setArtistTableOption(payload)); - } - }; -} - -export default connect(undefined, createMapDispatchToProps)(ArtistIndexHeader); diff --git a/frontend/src/Artist/Index/Table/ArtistIndexRow.css b/frontend/src/Artist/Index/Table/ArtistIndexRow.css index 29c89c696..35d03c263 100644 --- a/frontend/src/Artist/Index/Table/ArtistIndexRow.css +++ b/frontend/src/Artist/Index/Table/ArtistIndexRow.css @@ -37,7 +37,7 @@ position: relative; display: block; height: 70px; - background-color: $defaultColor; + background-color: var(--defaultColor); } .bannerImage { @@ -55,7 +55,7 @@ padding: 5px; width: 100%; height: 100%; - color: $offWhite; + color: var(--offWhite); text-align: center; font-size: 20px; } @@ -67,6 +67,7 @@ flex: 1 0 125px; } +.monitorNewItems, .nextAlbum, .lastAlbum, .added, @@ -110,7 +111,7 @@ } .ratings { - composes: headerCell from '~Components/Table/VirtualTableHeaderCell.css'; + composes: cell from '~Components/Table/Cells/VirtualTableRowCell.css'; flex: 0 0 80px; } diff --git a/frontend/src/Artist/Index/Table/ArtistIndexRow.css.d.ts b/frontend/src/Artist/Index/Table/ArtistIndexRow.css.d.ts new file mode 100644 index 000000000..4855aec75 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexRow.css.d.ts @@ -0,0 +1,32 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'added': string; + 'albumCount': string; + 'artistType': string; + 'banner': string; + 'bannerGrow': string; + 'bannerImage': string; + 'cell': string; + 'checkInput': string; + 'genres': string; + 'lastAlbum': string; + 'link': string; + 'metadataProfileId': string; + 'monitorNewItems': string; + 'nextAlbum': string; + 'overlayTitle': string; + 'path': string; + 'qualityProfileId': string; + 'ratings': string; + 'sizeOnDisk': string; + 'sortName': string; + 'status': string; + 'tags': string; + 'trackCount': string; + 'trackProgress': string; + 'useSceneNumbering': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexRow.js b/frontend/src/Artist/Index/Table/ArtistIndexRow.js deleted file mode 100644 index 6b597509f..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexRow.js +++ /dev/null @@ -1,484 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import classNames from 'classnames'; -import getProgressBarKind from 'Utilities/Artist/getProgressBarKind'; -import formatBytes from 'Utilities/Number/formatBytes'; -import { icons } from 'Helpers/Props'; -import HeartRating from 'Components/HeartRating'; -import IconButton from 'Components/Link/IconButton'; -import Link from 'Components/Link/Link'; -import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; -import ProgressBar from 'Components/ProgressBar'; -import TagListConnector from 'Components/TagListConnector'; -// import CheckInput from 'Components/Form/CheckInput'; -import VirtualTableRow from 'Components/Table/VirtualTableRow'; -import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; -import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; -import ArtistNameLink from 'Artist/ArtistNameLink'; -import AlbumTitleLink from 'Album/AlbumTitleLink'; -import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; -import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; -import ArtistBanner from 'Artist/ArtistBanner'; -import hasGrowableColumns from './hasGrowableColumns'; -import ArtistStatusCell from './ArtistStatusCell'; -import styles from './ArtistIndexRow.css'; - -class ArtistIndexRow extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - hasBannerError: false, - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: false - }; - } - - onEditArtistPress = () => { - this.setState({ isEditArtistModalOpen: true }); - } - - onEditArtistModalClose = () => { - this.setState({ isEditArtistModalOpen: false }); - } - - onDeleteArtistPress = () => { - this.setState({ - isEditArtistModalOpen: false, - isDeleteArtistModalOpen: true - }); - } - - onDeleteArtistModalClose = () => { - this.setState({ isDeleteArtistModalOpen: false }); - } - - onUseSceneNumberingChange = () => { - // Mock handler to satisfy `onChange` being required for `CheckInput`. - // - } - - onBannerLoad = () => { - if (this.state.hasBannerError) { - this.setState({ hasBannerError: false }); - } - } - - onBannerLoadError = () => { - if (!this.state.hasBannerError) { - this.setState({ hasBannerError: true }); - } - } - - // - // Render - - render() { - const { - style, - id, - monitored, - status, - artistName, - foreignArtistId, - artistType, - qualityProfile, - metadataProfile, - nextAlbum, - lastAlbum, - added, - statistics, - genres, - ratings, - path, - tags, - images, - showBanners, - showSearchAction, - columns, - isRefreshingArtist, - isSearchingArtist, - onRefreshArtistPress, - onSearchPress - } = this.props; - - const { - albumCount, - trackCount, - trackFileCount, - totalTrackCount, - sizeOnDisk - } = statistics; - - const { - hasBannerError, - isEditArtistModalOpen, - isDeleteArtistModalOpen - } = this.state; - - return ( - - { - columns.map((column) => { - const { - name, - isVisible - } = column; - - if (!isVisible) { - return null; - } - - if (name === 'status') { - return ( - - ); - } - - if (name === 'sortName') { - return ( - - { - showBanners ? - - - - { - hasBannerError && -
- {artistName} -
- } - : - - - } -
- ); - } - - if (name === 'artistType') { - return ( - - {artistType} - - ); - } - - if (name === 'qualityProfileId') { - return ( - - {qualityProfile.name} - - ); - } - - if (name === 'metadataProfileId') { - return ( - - {metadataProfile.name} - - ); - } - - if (name === 'nextAlbum') { - if (nextAlbum) { - return ( - - - - ); - } - return ( - - None - - ); - } - - if (name === 'lastAlbum') { - if (lastAlbum) { - return ( - - - - ); - } - return ( - - None - - ); - } - - if (name === 'added') { - return ( - - ); - } - - if (name === 'albumCount') { - return ( - - {albumCount} - - ); - } - - if (name === 'trackProgress') { - const progress = trackCount ? trackFileCount / trackCount * 100 : 100; - - return ( - - - - ); - } - - if (name === 'trackCount') { - return ( - - {totalTrackCount} - - ); - } - - if (name === 'path') { - return ( - - {path} - - ); - } - - if (name === 'sizeOnDisk') { - return ( - - {formatBytes(sizeOnDisk)} - - ); - } - - if (name === 'genres') { - const joinedGenres = genres.join(', '); - - return ( - - - {joinedGenres} - - - ); - } - - if (name === 'ratings') { - return ( - - - - ); - } - - if (name === 'tags') { - return ( - - - - ); - } - - if (name === 'actions') { - return ( - - - - { - showSearchAction && - - } - - - - ); - } - - return null; - }) - } - - - - -
- ); - } -} - -ArtistIndexRow.propTypes = { - style: PropTypes.object.isRequired, - id: PropTypes.number.isRequired, - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - artistName: PropTypes.string.isRequired, - foreignArtistId: PropTypes.string.isRequired, - artistType: PropTypes.string, - qualityProfile: PropTypes.object.isRequired, - metadataProfile: PropTypes.object.isRequired, - nextAlbum: PropTypes.object, - lastAlbum: PropTypes.object, - added: PropTypes.string, - statistics: PropTypes.object.isRequired, - latestAlbum: PropTypes.object, - path: PropTypes.string.isRequired, - genres: PropTypes.arrayOf(PropTypes.string).isRequired, - ratings: PropTypes.object.isRequired, - tags: PropTypes.arrayOf(PropTypes.number).isRequired, - images: PropTypes.arrayOf(PropTypes.object).isRequired, - showBanners: PropTypes.bool.isRequired, - showSearchAction: PropTypes.bool.isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - isRefreshingArtist: PropTypes.bool.isRequired, - isSearchingArtist: PropTypes.bool.isRequired, - onRefreshArtistPress: PropTypes.func.isRequired, - onSearchPress: PropTypes.func.isRequired -}; - -ArtistIndexRow.defaultProps = { - statistics: { - albumCount: 0, - trackCount: 0, - trackFileCount: 0, - totalTrackCount: 0 - }, - genres: [], - tags: [] -}; - -export default ArtistIndexRow; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexRow.tsx b/frontend/src/Artist/Index/Table/ArtistIndexRow.tsx new file mode 100644 index 000000000..0398f5502 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexRow.tsx @@ -0,0 +1,422 @@ +import classNames from 'classnames'; +import React, { useCallback, useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import AlbumTitleLink from 'Album/AlbumTitleLink'; +import { useSelect } from 'App/SelectContext'; +import { Statistics } from 'Artist/Artist'; +import ArtistBanner from 'Artist/ArtistBanner'; +import ArtistNameLink from 'Artist/ArtistNameLink'; +import DeleteArtistModal from 'Artist/Delete/DeleteArtistModal'; +import EditArtistModalConnector from 'Artist/Edit/EditArtistModalConnector'; +import createArtistIndexItemSelector from 'Artist/Index/createArtistIndexItemSelector'; +import ArtistIndexProgressBar from 'Artist/Index/ProgressBar/ArtistIndexProgressBar'; +import ArtistStatusCell from 'Artist/Index/Table/ArtistStatusCell'; +import { ARTIST_SEARCH, REFRESH_ARTIST } from 'Commands/commandNames'; +import HeartRating from 'Components/HeartRating'; +import IconButton from 'Components/Link/IconButton'; +import Link from 'Components/Link/Link'; +import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; +import RelativeDateCellConnector from 'Components/Table/Cells/RelativeDateCellConnector'; +import VirtualTableRowCell from 'Components/Table/Cells/VirtualTableRowCell'; +import VirtualTableSelectCell from 'Components/Table/Cells/VirtualTableSelectCell'; +import Column from 'Components/Table/Column'; +import TagListConnector from 'Components/TagListConnector'; +import { icons } from 'Helpers/Props'; +import { executeCommand } from 'Store/Actions/commandActions'; +import { SelectStateInputProps } from 'typings/props'; +import formatBytes from 'Utilities/Number/formatBytes'; +import firstCharToUpper from 'Utilities/String/firstCharToUpper'; +import translate from 'Utilities/String/translate'; +import AlbumsCell from './AlbumsCell'; +import hasGrowableColumns from './hasGrowableColumns'; +import selectTableOptions from './selectTableOptions'; +import styles from './ArtistIndexRow.css'; + +interface ArtistIndexRowProps { + artistId: number; + sortKey: string; + columns: Column[]; + isSelectMode: boolean; +} + +function ArtistIndexRow(props: ArtistIndexRowProps) { + const { artistId, columns, isSelectMode } = props; + + const { + artist, + qualityProfile, + metadataProfile, + isRefreshingArtist, + isSearchingArtist, + } = useSelector(createArtistIndexItemSelector(props.artistId)); + + const { showBanners, showSearchAction } = useSelector(selectTableOptions); + + const { + artistName, + foreignArtistId, + monitored, + status, + path, + monitorNewItems, + nextAlbum, + lastAlbum, + added, + statistics = {} as Statistics, + images, + artistType, + genres = [], + ratings, + tags = [], + isSaving = false, + } = artist; + + const { + albumCount = 0, + trackCount = 0, + trackFileCount = 0, + totalTrackCount = 0, + sizeOnDisk = 0, + } = statistics; + + const dispatch = useDispatch(); + const [hasBannerError, setHasBannerError] = useState(false); + const [isEditArtistModalOpen, setIsEditArtistModalOpen] = useState(false); + const [isDeleteArtistModalOpen, setIsDeleteArtistModalOpen] = useState(false); + const [selectState, selectDispatch] = useSelect(); + + const onRefreshPress = useCallback(() => { + dispatch( + executeCommand({ + name: REFRESH_ARTIST, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onSearchPress = useCallback(() => { + dispatch( + executeCommand({ + name: ARTIST_SEARCH, + artistId, + }) + ); + }, [artistId, dispatch]); + + const onBannerLoadError = useCallback(() => { + setHasBannerError(true); + }, [setHasBannerError]); + + const onBannerLoad = useCallback(() => { + setHasBannerError(false); + }, [setHasBannerError]); + + const onEditArtistPress = useCallback(() => { + setIsEditArtistModalOpen(true); + }, [setIsEditArtistModalOpen]); + + const onEditArtistModalClose = useCallback(() => { + setIsEditArtistModalOpen(false); + }, [setIsEditArtistModalOpen]); + + const onDeleteArtistPress = useCallback(() => { + setIsEditArtistModalOpen(false); + setIsDeleteArtistModalOpen(true); + }, [setIsDeleteArtistModalOpen]); + + const onDeleteArtistModalClose = useCallback(() => { + setIsDeleteArtistModalOpen(false); + }, [setIsDeleteArtistModalOpen]); + + const onSelectedChange = useCallback( + ({ id, value, shiftKey }: SelectStateInputProps) => { + selectDispatch({ + type: 'toggleSelected', + id, + isSelected: value, + shiftKey, + }); + }, + [selectDispatch] + ); + + return ( + <> + {isSelectMode ? ( + + ) : null} + + {columns.map((column) => { + const { name, isVisible } = column; + + if (!isVisible) { + return null; + } + + if (name === 'status') { + return ( + + ); + } + + if (name === 'sortName') { + return ( + + {showBanners ? ( + + + + {hasBannerError && ( +
{artistName}
+ )} + + ) : ( + + )} +
+ ); + } + + if (name === 'artistType') { + return ( + + {artistType} + + ); + } + + if (name === 'qualityProfileId') { + return ( + + {qualityProfile?.name ?? ''} + + ); + } + + if (name === 'metadataProfileId') { + return ( + + {metadataProfile?.name ?? ''} + + ); + } + + if (name === 'monitorNewItems') { + return ( + + {translate(firstCharToUpper(monitorNewItems))} + + ); + } + + if (name === 'nextAlbum') { + if (nextAlbum) { + return ( + + + + ); + } + return ( + + {translate('None')} + + ); + } + + if (name === 'lastAlbum') { + if (lastAlbum) { + return ( + + + + ); + } + return ( + + {translate('None')} + + ); + } + + if (name === 'added') { + return ( + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore ts(2739) + + ); + } + + if (name === 'albumCount') { + return ( + + ); + } + + if (name === 'trackProgress') { + return ( + + + + ); + } + + if (name === 'trackCount') { + return ( + + {totalTrackCount} + + ); + } + + if (name === 'path') { + return ( + + {path} + + ); + } + + if (name === 'sizeOnDisk') { + return ( + + {formatBytes(sizeOnDisk)} + + ); + } + + if (name === 'genres') { + const joinedGenres = genres.join(', '); + + return ( + + {joinedGenres} + + ); + } + + if (name === 'ratings') { + return ( + + + + ); + } + + if (name === 'tags') { + return ( + + + + ); + } + + if (name === 'actions') { + return ( + + + + {showSearchAction ? ( + + ) : null} + + + + ); + } + + return null; + })} + + + + + + ); +} + +export default ArtistIndexRow; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTable.css b/frontend/src/Artist/Index/Table/ArtistIndexTable.css index 23ab127b5..0bfc5fec4 100644 --- a/frontend/src/Artist/Index/Table/ArtistIndexTable.css +++ b/frontend/src/Artist/Index/Table/ArtistIndexTable.css @@ -1,5 +1,11 @@ -.tableContainer { - composes: tableContainer from '~Components/Table/VirtualTable.css'; - - flex: 1 0 auto; +.tableScroller { + position: relative; +} + +.row { + transition: background-color 500ms; + + &:hover { + background-color: var(--tableRowHoverBackgroundColor); + } } diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTable.css.d.ts b/frontend/src/Artist/Index/Table/ArtistIndexTable.css.d.ts new file mode 100644 index 000000000..ff35c263f --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTable.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'row': string; + 'tableScroller': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTable.js b/frontend/src/Artist/Index/Table/ArtistIndexTable.js deleted file mode 100644 index fcece7a2c..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTable.js +++ /dev/null @@ -1,132 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; -import { sortDirections } from 'Helpers/Props'; -import VirtualTable from 'Components/Table/VirtualTable'; -import ArtistIndexItemConnector from 'Artist/Index/ArtistIndexItemConnector'; -import ArtistIndexHeaderConnector from './ArtistIndexHeaderConnector'; -import ArtistIndexRow from './ArtistIndexRow'; -import styles from './ArtistIndexTable.css'; - -class ArtistIndexTable extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - scrollIndex: null - }; - } - - componentDidUpdate(prevProps) { - const jumpToCharacter = this.props.jumpToCharacter; - - if (jumpToCharacter != null && jumpToCharacter !== prevProps.jumpToCharacter) { - const items = this.props.items; - - const scrollIndex = getIndexOfFirstCharacter(items, jumpToCharacter); - - if (scrollIndex != null) { - this.setState({ scrollIndex }); - } - } else if (jumpToCharacter == null && prevProps.jumpToCharacter != null) { - this.setState({ scrollIndex: null }); - } - } - - // - // Control - - rowRenderer = ({ key, rowIndex, style }) => { - const { - items, - columns, - showBanners - } = this.props; - - const artist = items[rowIndex]; - - return ( - - ); - } - - // - // Render - - render() { - const { - items, - columns, - filters, - sortKey, - sortDirection, - showBanners, - isSmallScreen, - scrollTop, - contentBody, - onSortPress, - onRender, - onScroll - } = this.props; - - return ( - - } - columns={columns} - filters={filters} - sortKey={sortKey} - sortDirection={sortDirection} - onRender={onRender} - onScroll={onScroll} - /> - ); - } -} - -ArtistIndexTable.propTypes = { - items: PropTypes.arrayOf(PropTypes.object).isRequired, - columns: PropTypes.arrayOf(PropTypes.object).isRequired, - filters: PropTypes.arrayOf(PropTypes.object).isRequired, - sortKey: PropTypes.string, - sortDirection: PropTypes.oneOf(sortDirections.all), - showBanners: PropTypes.bool.isRequired, - scrollTop: PropTypes.number.isRequired, - jumpToCharacter: PropTypes.string, - contentBody: PropTypes.object.isRequired, - isSmallScreen: PropTypes.bool.isRequired, - onSortPress: PropTypes.func.isRequired, - onRender: PropTypes.func.isRequired, - onScroll: PropTypes.func.isRequired -}; - -export default ArtistIndexTable; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTable.tsx b/frontend/src/Artist/Index/Table/ArtistIndexTable.tsx new file mode 100644 index 000000000..c3c8044ce --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTable.tsx @@ -0,0 +1,215 @@ +import { throttle } from 'lodash'; +import React, { RefObject, useEffect, useMemo, useRef, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { FixedSizeList as List, ListChildComponentProps } from 'react-window'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import Artist from 'Artist/Artist'; +import ArtistIndexRow from 'Artist/Index/Table/ArtistIndexRow'; +import ArtistIndexTableHeader from 'Artist/Index/Table/ArtistIndexTableHeader'; +import Scroller from 'Components/Scroller/Scroller'; +import Column from 'Components/Table/Column'; +import useMeasure from 'Helpers/Hooks/useMeasure'; +import ScrollDirection from 'Helpers/Props/ScrollDirection'; +import SortDirection from 'Helpers/Props/SortDirection'; +import dimensions from 'Styles/Variables/dimensions'; +import getIndexOfFirstCharacter from 'Utilities/Array/getIndexOfFirstCharacter'; +import selectTableOptions from './selectTableOptions'; +import styles from './ArtistIndexTable.css'; + +const bodyPadding = parseInt(dimensions.pageContentBodyPadding); +const bodyPaddingSmallScreen = parseInt( + dimensions.pageContentBodyPaddingSmallScreen +); + +interface RowItemData { + items: Artist[]; + sortKey: string; + columns: Column[]; + isSelectMode: boolean; +} + +interface ArtistIndexTableProps { + items: Artist[]; + sortKey: string; + sortDirection?: SortDirection; + jumpToCharacter?: string; + scrollTop?: number; + scrollerRef: RefObject; + isSelectMode: boolean; + isSmallScreen: boolean; +} + +const columnsSelector = createSelector( + (state: AppState) => state.artistIndex.columns, + (columns) => columns +); + +const Row: React.FC> = ({ + index, + style, + data, +}) => { + const { items, sortKey, columns, isSelectMode } = data; + + if (index >= items.length) { + return null; + } + + const artist = items[index]; + + return ( +
+ +
+ ); +}; + +function getWindowScrollTopPosition() { + return document.documentElement.scrollTop || document.body.scrollTop || 0; +} + +function ArtistIndexTable(props: ArtistIndexTableProps) { + const { + items, + sortKey, + sortDirection, + jumpToCharacter, + isSelectMode, + isSmallScreen, + scrollerRef, + } = props; + + const columns = useSelector(columnsSelector); + const { showBanners } = useSelector(selectTableOptions); + const listRef = useRef>(null); + const [measureRef, bounds] = useMeasure(); + const [size, setSize] = useState({ width: 0, height: 0 }); + const windowWidth = window.innerWidth; + const windowHeight = window.innerHeight; + + const rowHeight = useMemo(() => { + return showBanners ? 70 : 38; + }, [showBanners]); + + useEffect(() => { + const current = scrollerRef?.current as HTMLElement; + + if (isSmallScreen) { + setSize({ + width: windowWidth, + height: windowHeight, + }); + + return; + } + + if (current) { + const width = current.clientWidth; + const padding = + (isSmallScreen ? bodyPaddingSmallScreen : bodyPadding) - 5; + + setSize({ + width: width - padding * 2, + height: windowHeight, + }); + } + }, [isSmallScreen, windowWidth, windowHeight, scrollerRef, bounds]); + + useEffect(() => { + const currentScrollerRef = scrollerRef.current as HTMLElement; + const currentScrollListener = isSmallScreen ? window : currentScrollerRef; + + const handleScroll = throttle(() => { + const { offsetTop = 0 } = currentScrollerRef; + const scrollTop = + (isSmallScreen + ? getWindowScrollTopPosition() + : currentScrollerRef.scrollTop) - offsetTop; + + listRef.current?.scrollTo(scrollTop); + }, 10); + + currentScrollListener.addEventListener('scroll', handleScroll); + + return () => { + handleScroll.cancel(); + + if (currentScrollListener) { + currentScrollListener.removeEventListener('scroll', handleScroll); + } + }; + }, [isSmallScreen, listRef, scrollerRef]); + + useEffect(() => { + if (jumpToCharacter) { + const index = getIndexOfFirstCharacter(items, jumpToCharacter); + + if (index != null) { + let scrollTop = index * rowHeight; + + // If the offset is zero go to the top, otherwise offset + // by the approximate size of the header + padding (37 + 20). + if (scrollTop > 0) { + const offset = 57; + + scrollTop += offset; + } + + listRef.current?.scrollTo(scrollTop); + scrollerRef?.current?.scrollTo(0, scrollTop); + } + } + }, [jumpToCharacter, rowHeight, items, scrollerRef, listRef]); + + return ( +
+ + + + ref={listRef} + style={{ + width: '100%', + height: '100%', + overflow: 'none', + }} + width={size.width} + height={size.height} + itemCount={items.length} + itemSize={rowHeight} + itemData={{ + items, + sortKey, + columns, + isSelectMode, + }} + > + {Row} + + +
+ ); +} + +export default ArtistIndexTable; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableConnector.js b/frontend/src/Artist/Index/Table/ArtistIndexTableConnector.js deleted file mode 100644 index 3a97425cc..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTableConnector.js +++ /dev/null @@ -1,29 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import { setArtistSort } from 'Store/Actions/artistIndexActions'; -import ArtistIndexTable from './ArtistIndexTable'; - -function createMapStateToProps() { - return createSelector( - (state) => state.app.dimensions, - (state) => state.artistIndex.tableOptions, - (state) => state.artistIndex.columns, - (dimensions, tableOptions, columns) => { - return { - isSmallScreen: dimensions.isSmallScreen, - showBanners: tableOptions.showBanners, - columns - }; - } - ); -} - -function createMapDispatchToProps(dispatch, props) { - return { - onSortPress(sortKey) { - dispatch(setArtistSort({ sortKey })); - } - }; -} - -export default connect(createMapStateToProps, createMapDispatchToProps)(ArtistIndexTable); diff --git a/frontend/src/Artist/Index/Table/ArtistIndexHeader.css b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css similarity index 98% rename from frontend/src/Artist/Index/Table/ArtistIndexHeader.css rename to frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css index 6da0be920..7ea4e94aa 100644 --- a/frontend/src/Artist/Index/Table/ArtistIndexHeader.css +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css @@ -31,6 +31,7 @@ flex: 1 0 125px; } +.monitorNewItems, .nextAlbum, .lastAlbum, .added, diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css.d.ts b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css.d.ts new file mode 100644 index 000000000..467b401bb --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css.d.ts @@ -0,0 +1,28 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'added': string; + 'albumCount': string; + 'artistType': string; + 'banner': string; + 'bannerGrow': string; + 'genres': string; + 'lastAlbum': string; + 'latestAlbum': string; + 'metadataProfileId': string; + 'monitorNewItems': string; + 'nextAlbum': string; + 'path': string; + 'qualityProfileId': string; + 'ratings': string; + 'sizeOnDisk': string; + 'sortName': string; + 'status': string; + 'tags': string; + 'trackCount': string; + 'trackProgress': string; + 'useSceneNumbering': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.tsx b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.tsx new file mode 100644 index 000000000..1b325c225 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.tsx @@ -0,0 +1,121 @@ +import classNames from 'classnames'; +import React, { useCallback } from 'react'; +import { useDispatch } from 'react-redux'; +import { useSelect } from 'App/SelectContext'; +import ArtistIndexTableOptions from 'Artist/Index/Table/ArtistIndexTableOptions'; +import IconButton from 'Components/Link/IconButton'; +import Column from 'Components/Table/Column'; +import TableOptionsModalWrapper from 'Components/Table/TableOptions/TableOptionsModalWrapper'; +import VirtualTableHeader from 'Components/Table/VirtualTableHeader'; +import VirtualTableHeaderCell from 'Components/Table/VirtualTableHeaderCell'; +import VirtualTableSelectAllHeaderCell from 'Components/Table/VirtualTableSelectAllHeaderCell'; +import { icons } from 'Helpers/Props'; +import SortDirection from 'Helpers/Props/SortDirection'; +import { + setArtistSort, + setArtistTableOption, +} from 'Store/Actions/artistIndexActions'; +import { CheckInputChanged } from 'typings/inputs'; +import hasGrowableColumns from './hasGrowableColumns'; +import styles from './ArtistIndexTableHeader.css'; + +interface ArtistIndexTableHeaderProps { + showBanners: boolean; + columns: Column[]; + sortKey?: string; + sortDirection?: SortDirection; + isSelectMode: boolean; +} + +function ArtistIndexTableHeader(props: ArtistIndexTableHeaderProps) { + const { showBanners, columns, sortKey, sortDirection, isSelectMode } = props; + const dispatch = useDispatch(); + const [selectState, selectDispatch] = useSelect(); + + const onSortPress = useCallback( + (value: string) => { + dispatch(setArtistSort({ sortKey: value })); + }, + [dispatch] + ); + + const onTableOptionChange = useCallback( + (payload: unknown) => { + dispatch(setArtistTableOption(payload)); + }, + [dispatch] + ); + + const onSelectAllChange = useCallback( + ({ value }: CheckInputChanged) => { + selectDispatch({ + type: value ? 'selectAll' : 'unselectAll', + }); + }, + [selectDispatch] + ); + + return ( + + {isSelectMode ? ( + + ) : null} + + {columns.map((column) => { + const { name, label, isSortable, isVisible } = column; + + if (!isVisible) { + return null; + } + + if (name === 'actions') { + return ( + + + + + + ); + } + + return ( + + {typeof label === 'function' ? label() : label} + + ); + })} + + ); +} + +export default ArtistIndexTableHeader; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.js b/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.js deleted file mode 100644 index 110a024e4..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.js +++ /dev/null @@ -1,100 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component, Fragment } from 'react'; -import { inputTypes } from 'Helpers/Props'; -import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import FormInputGroup from 'Components/Form/FormInputGroup'; - -class ArtistIndexTableOptions extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - showBanners: props.showBanners, - showSearchAction: props.showSearchAction - }; - } - - componentDidUpdate(prevProps) { - const { - showBanners, - showSearchAction - } = this.props; - - if ( - showBanners !== prevProps.showBanners || - showSearchAction !== prevProps.showSearchAction - ) { - this.setState({ - showBanners, - showSearchAction - }); - } - } - - // - // Listeners - - onTableOptionChange = ({ name, value }) => { - this.setState({ - [name]: value - }, () => { - this.props.onTableOptionChange({ - tableOptions: { - ...this.state, - [name]: value - } - }); - }); - } - - // - // Render - - render() { - const { - showBanners, - showSearchAction - } = this.state; - - return ( - - - Show Banners - - - - - - Show Search - - - - - ); - } -} - -ArtistIndexTableOptions.propTypes = { - showBanners: PropTypes.bool.isRequired, - showSearchAction: PropTypes.bool.isRequired, - onTableOptionChange: PropTypes.func.isRequired -}; - -export default ArtistIndexTableOptions; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.tsx b/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.tsx new file mode 100644 index 000000000..9c10d859d --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.tsx @@ -0,0 +1,63 @@ +import React, { Fragment, useCallback } from 'react'; +import { useSelector } from 'react-redux'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import { inputTypes } from 'Helpers/Props'; +import { CheckInputChanged } from 'typings/inputs'; +import translate from 'Utilities/String/translate'; +import selectTableOptions from './selectTableOptions'; + +interface ArtistIndexTableOptionsProps { + onTableOptionChange(...args: unknown[]): unknown; +} + +function ArtistIndexTableOptions(props: ArtistIndexTableOptionsProps) { + const { onTableOptionChange } = props; + + const tableOptions = useSelector(selectTableOptions); + + const { showBanners, showSearchAction } = tableOptions; + + const onTableOptionChangeWrapper = useCallback( + ({ name, value }: CheckInputChanged) => { + onTableOptionChange({ + tableOptions: { + ...tableOptions, + [name]: value, + }, + }); + }, + [tableOptions, onTableOptionChange] + ); + + return ( + + + {translate('ShowBanners')} + + + + + + {translate('ShowSearch')} + + + + + ); +} + +export default ArtistIndexTableOptions; diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTableOptionsConnector.js b/frontend/src/Artist/Index/Table/ArtistIndexTableOptionsConnector.js deleted file mode 100644 index 0a1607cf2..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTableOptionsConnector.js +++ /dev/null @@ -1,14 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import ArtistIndexTableOptions from './ArtistIndexTableOptions'; - -function createMapStateToProps() { - return createSelector( - (state) => state.artistIndex.tableOptions, - (tableOptions) => { - return tableOptions; - } - ); -} - -export default connect(createMapStateToProps)(ArtistIndexTableOptions); diff --git a/frontend/src/Artist/Index/Table/ArtistStatusCell.css b/frontend/src/Artist/Index/Table/ArtistStatusCell.css index fbcd5eee9..a4cb08a22 100644 --- a/frontend/src/Artist/Index/Table/ArtistStatusCell.css +++ b/frontend/src/Artist/Index/Table/ArtistStatusCell.css @@ -4,6 +4,14 @@ width: 60px; } -.statusIcon { +.monitorToggle { + composes: toggleButton from '~Components/MonitorToggleButton.css'; + + margin: 0; width: 20px !important; } + +.statusIcon { + width: 20px !important; + text-align: center; +} diff --git a/frontend/src/Artist/Index/Table/ArtistStatusCell.css.d.ts b/frontend/src/Artist/Index/Table/ArtistStatusCell.css.d.ts new file mode 100644 index 000000000..eff3e0343 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistStatusCell.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'monitorToggle': string; + 'status': string; + 'statusIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/Index/Table/ArtistStatusCell.js b/frontend/src/Artist/Index/Table/ArtistStatusCell.js deleted file mode 100644 index 26fde0e12..000000000 --- a/frontend/src/Artist/Index/Table/ArtistStatusCell.js +++ /dev/null @@ -1,53 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { icons } from 'Helpers/Props'; -import Icon from 'Components/Icon'; -import VirtualTableRowCell from 'Components/Table/Cells/TableRowCell'; -import styles from './ArtistStatusCell.css'; - -function ArtistStatusCell(props) { - const { - className, - artistType, - monitored, - status, - component: Component, - ...otherProps - } = props; - - const endedString = artistType === 'Person' ? 'Deceased' : 'Ended'; - - return ( - - - - - - ); -} - -ArtistStatusCell.propTypes = { - className: PropTypes.string.isRequired, - artistType: PropTypes.string, - monitored: PropTypes.bool.isRequired, - status: PropTypes.string.isRequired, - component: PropTypes.elementType -}; - -ArtistStatusCell.defaultProps = { - className: styles.status, - component: VirtualTableRowCell -}; - -export default ArtistStatusCell; diff --git a/frontend/src/Artist/Index/Table/ArtistStatusCell.tsx b/frontend/src/Artist/Index/Table/ArtistStatusCell.tsx new file mode 100644 index 000000000..00c7ae4c8 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistStatusCell.tsx @@ -0,0 +1,75 @@ +import React, { useCallback } from 'react'; +import { useDispatch } from 'react-redux'; +import Icon from 'Components/Icon'; +import MonitorToggleButton from 'Components/MonitorToggleButton'; +import VirtualTableRowCell from 'Components/Table/Cells/TableRowCell'; +import { icons } from 'Helpers/Props'; +import { toggleArtistMonitored } from 'Store/Actions/artistActions'; +import translate from 'Utilities/String/translate'; +import styles from './ArtistStatusCell.css'; + +interface ArtistStatusCellProps { + className: string; + artistId: number; + artistType?: string; + monitored: boolean; + status: string; + isSelectMode: boolean; + isSaving: boolean; + component?: React.ElementType; +} + +function ArtistStatusCell(props: ArtistStatusCellProps) { + const { + className, + artistId, + artistType, + monitored, + status, + isSelectMode, + isSaving, + component: Component = VirtualTableRowCell, + ...otherProps + } = props; + + const endedString = + artistType === 'Person' ? translate('Deceased') : translate('Inactive'); + const dispatch = useDispatch(); + + const onMonitoredPress = useCallback(() => { + dispatch(toggleArtistMonitored({ artistId, monitored: !monitored })); + }, [artistId, monitored, dispatch]); + + return ( + + {isSelectMode ? ( + + ) : ( + + )} + + + + ); +} + +export default ArtistStatusCell; diff --git a/frontend/src/Artist/Index/Table/hasGrowableColumns.js b/frontend/src/Artist/Index/Table/hasGrowableColumns.js deleted file mode 100644 index 994436d9f..000000000 --- a/frontend/src/Artist/Index/Table/hasGrowableColumns.js +++ /dev/null @@ -1,16 +0,0 @@ -const growableColumns = [ - 'qualityProfileId', - 'path', - 'tags' -]; - -export default function hasGrowableColumns(columns) { - return columns.some((column) => { - const { - name, - isVisible - } = column; - - return growableColumns.includes(name) && isVisible; - }); -} diff --git a/frontend/src/Artist/Index/Table/hasGrowableColumns.ts b/frontend/src/Artist/Index/Table/hasGrowableColumns.ts new file mode 100644 index 000000000..ed0cc6c58 --- /dev/null +++ b/frontend/src/Artist/Index/Table/hasGrowableColumns.ts @@ -0,0 +1,11 @@ +import Column from 'Components/Table/Column'; + +const growableColumns = ['qualityProfileId', 'path', 'tags']; + +export default function hasGrowableColumns(columns: Column[]) { + return columns.some((column) => { + const { name, isVisible } = column; + + return growableColumns.includes(name) && isVisible; + }); +} diff --git a/frontend/src/Artist/Index/Table/selectTableOptions.ts b/frontend/src/Artist/Index/Table/selectTableOptions.ts new file mode 100644 index 000000000..b6a2a6a94 --- /dev/null +++ b/frontend/src/Artist/Index/Table/selectTableOptions.ts @@ -0,0 +1,9 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +const selectTableOptions = createSelector( + (state: AppState) => state.artistIndex.tableOptions, + (tableOptions) => tableOptions +); + +export default selectTableOptions; diff --git a/frontend/src/Artist/Index/createArtistIndexItemSelector.ts b/frontend/src/Artist/Index/createArtistIndexItemSelector.ts new file mode 100644 index 000000000..4388a3aeb --- /dev/null +++ b/frontend/src/Artist/Index/createArtistIndexItemSelector.ts @@ -0,0 +1,45 @@ +import { createSelector } from 'reselect'; +import Artist from 'Artist/Artist'; +import Command from 'Commands/Command'; +import { ARTIST_SEARCH, REFRESH_ARTIST } from 'Commands/commandNames'; +import createArtistMetadataProfileSelector from 'Store/Selectors/createArtistMetadataProfileSelector'; +import createArtistQualityProfileSelector from 'Store/Selectors/createArtistQualityProfileSelector'; +import { createArtistSelectorForHook } from 'Store/Selectors/createArtistSelector'; +import createExecutingCommandsSelector from 'Store/Selectors/createExecutingCommandsSelector'; + +function createArtistIndexItemSelector(artistId: number) { + return createSelector( + createArtistSelectorForHook(artistId), + createArtistQualityProfileSelector(artistId), + createArtistMetadataProfileSelector(artistId), + createExecutingCommandsSelector(), + ( + artist: Artist, + qualityProfile, + metadataProfile, + executingCommands: Command[] + ) => { + const isRefreshingArtist = executingCommands.some((command) => { + return ( + command.name === REFRESH_ARTIST && command.body.artistId === artistId + ); + }); + + const isSearchingArtist = executingCommands.some((command) => { + return ( + command.name === ARTIST_SEARCH && command.body.artistId === artistId + ); + }); + + return { + artist, + qualityProfile, + metadataProfile, + isRefreshingArtist, + isSearchingArtist, + }; + } + ); +} + +export default createArtistIndexItemSelector; diff --git a/frontend/src/Artist/Index/createArtistQueueDetailsSelector.ts b/frontend/src/Artist/Index/createArtistQueueDetailsSelector.ts new file mode 100644 index 000000000..34a9c3910 --- /dev/null +++ b/frontend/src/Artist/Index/createArtistQueueDetailsSelector.ts @@ -0,0 +1,39 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +export interface ArtistQueueDetails { + count: number; + tracksWithFiles: number; +} + +function createArtistQueueDetailsSelector(artistId: number) { + return createSelector( + (state: AppState) => state.queue.details.items, + (queueItems) => { + return queueItems.reduce( + (acc: ArtistQueueDetails, item) => { + if ( + item.trackedDownloadState === 'imported' || + item.artistId !== artistId + ) { + return acc; + } + + acc.count += item.trackFileCount ?? 0; + + if (item.trackHasFileCount) { + acc.tracksWithFiles += item.trackHasFileCount; + } + + return acc; + }, + { + count: 0, + tracksWithFiles: 0, + } + ); + } + ); +} + +export default createArtistQueueDetailsSelector; diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionModalConnector.js b/frontend/src/Artist/MonitoringOptions/MonitoringOptionModalConnector.js new file mode 100644 index 000000000..6ea9e8290 --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionModalConnector.js @@ -0,0 +1,39 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { clearPendingChanges } from 'Store/Actions/baseActions'; +import MonitoringOptionsModal from './MonitoringOptionsModal'; + +const mapDispatchToProps = { + clearPendingChanges +}; + +class MonitoringOptionsModalConnector extends Component { + + // + // Listeners + + onModalClose = () => { + this.props.clearPendingChanges({ section: 'artist' }); + this.props.onModalClose(); + }; + + // + // Render + + render() { + return ( + + ); + } +} + +MonitoringOptionsModalConnector.propTypes = { + onModalClose: PropTypes.func.isRequired, + clearPendingChanges: PropTypes.func.isRequired +}; + +export default connect(undefined, mapDispatchToProps)(MonitoringOptionsModalConnector); diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModal.js b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModal.js new file mode 100644 index 000000000..4071e7f9a --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModal.js @@ -0,0 +1,25 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import Modal from 'Components/Modal/Modal'; +import MonitoringOptionsModalContentConnector from './MonitoringOptionsModalContentConnector'; + +function MonitoringOptionsModal({ isOpen, onModalClose, ...otherProps }) { + return ( + + + + ); +} + +MonitoringOptionsModal.propTypes = { + isOpen: PropTypes.bool.isRequired, + onModalClose: PropTypes.func.isRequired +}; + +export default MonitoringOptionsModal; diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css new file mode 100644 index 000000000..3e9e3ffd0 --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css @@ -0,0 +1,9 @@ +.labelIcon { + margin-left: 8px; +} + +.message { + composes: alert from '~Components/Alert.css'; + + margin-bottom: 30px; +} diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css.d.ts b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css.d.ts new file mode 100644 index 000000000..af0f6cd46 --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'labelIcon': string; + 'message': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.js b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.js new file mode 100644 index 000000000..b1550d39e --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.js @@ -0,0 +1,156 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import ArtistMonitoringOptionsPopoverContent from 'AddArtist/ArtistMonitoringOptionsPopoverContent'; +import Alert from 'Components/Alert'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; +import SpinnerButton from 'Components/Link/SpinnerButton'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import Popover from 'Components/Tooltip/Popover'; +import { icons, inputTypes, kinds, tooltipPositions } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import styles from './MonitoringOptionsModalContent.css'; + +const NO_CHANGE = 'noChange'; + +class MonitoringOptionsModalContent extends Component { + + // + // Lifecycle + + constructor(props, context) { + super(props, context); + + this.state = { + monitor: NO_CHANGE + }; + } + + componentDidUpdate(prevProps) { + const { + isSaving, + saveError + } = this.props; + + if (prevProps.isSaving && !isSaving && !saveError) { + this.setState({ + monitor: NO_CHANGE + }); + } + } + + onInputChange = ({ name, value }) => { + this.setState({ [name]: value }); + }; + + // + // Listeners + + onSavePress = () => { + const { + onSavePress + } = this.props; + const { + monitor + } = this.state; + + if (monitor !== NO_CHANGE) { + onSavePress({ monitor }); + } + }; + + // + // Render + + render() { + const { + isSaving, + onInputChange, + onModalClose, + ...otherProps + } = this.props; + + const { + monitor + } = this.state; + + return ( + + + {translate('MonitorArtist')} + + + + + {translate('MonitorAlbumExistingOnlyWarning')} + + +
+ + + {translate('MonitorExistingAlbums')} + + + } + title={translate('MonitoringOptions')} + body={} + position={tooltipPositions.RIGHT} + /> + + + + +
+
+ + + + + + {translate('Save')} + + +
+ ); + } +} + +MonitoringOptionsModalContent.propTypes = { + artistId: PropTypes.number.isRequired, + saveError: PropTypes.object, + isSaving: PropTypes.bool.isRequired, + onInputChange: PropTypes.func.isRequired, + onSavePress: PropTypes.func.isRequired, + onModalClose: PropTypes.func.isRequired +}; + +MonitoringOptionsModalContent.defaultProps = { + isSaving: false +}; + +export default MonitoringOptionsModalContent; diff --git a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContentConnector.js b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContentConnector.js new file mode 100644 index 000000000..1901e1d21 --- /dev/null +++ b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContentConnector.js @@ -0,0 +1,77 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; +import { updateArtistsMonitor } from 'Store/Actions/artistActions'; +import MonitoringOptionsModalContent from './MonitoringOptionsModalContent'; + +function createMapStateToProps() { + return createSelector( + (state) => state.artist, + (artistState) => { + const { + isSaving, + saveError + } = artistState; + + return { + isSaving, + saveError + }; + } + ); +} + +const mapDispatchToProps = { + dispatchUpdateMonitoringOptions: updateArtistsMonitor +}; + +class MonitoringOptionsModalContentConnector extends Component { + + // + // Lifecycle + + componentDidUpdate(prevProps, prevState) { + if (prevProps.isSaving && !this.props.isSaving && !this.props.saveError) { + this.props.onModalClose(true); + } + } + + // + // Listeners + + onInputChange = ({ name, value }) => { + this.setState({ name, value }); + }; + + onSavePress = ({ monitor }) => { + this.props.dispatchUpdateMonitoringOptions({ + artistIds: [this.props.artistId], + monitor, + shouldFetchAlbumsAfterUpdate: true + }); + }; + + // + // Render + + render() { + return ( + + ); + } +} + +MonitoringOptionsModalContentConnector.propTypes = { + artistId: PropTypes.number.isRequired, + isSaving: PropTypes.bool.isRequired, + saveError: PropTypes.object, + dispatchUpdateMonitoringOptions: PropTypes.func.isRequired, + onModalClose: PropTypes.func.isRequired +}; + +export default connect(createMapStateToProps, mapDispatchToProps)(MonitoringOptionsModalContentConnector); diff --git a/frontend/src/Artist/MoveArtist/MoveArtistModal.css.d.ts b/frontend/src/Artist/MoveArtist/MoveArtistModal.css.d.ts new file mode 100644 index 000000000..0475f5a86 --- /dev/null +++ b/frontend/src/Artist/MoveArtist/MoveArtistModal.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'doNotMoveButton': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/MoveArtist/MoveArtistModal.js b/frontend/src/Artist/MoveArtist/MoveArtistModal.js index 3f78187ff..1bad51151 100644 --- a/frontend/src/Artist/MoveArtist/MoveArtistModal.js +++ b/frontend/src/Artist/MoveArtist/MoveArtistModal.js @@ -1,12 +1,12 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { kinds, sizes } from 'Helpers/Props'; import Button from 'Components/Link/Button'; import Modal from 'Components/Modal/Modal'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { kinds, sizes } from 'Helpers/Props'; import styles from './MoveArtistModal.css'; function MoveArtistModal(props) { @@ -15,6 +15,7 @@ function MoveArtistModal(props) { destinationPath, destinationRootFolder, isOpen, + onModalClose, onSavePress, onMoveArtistPress } = props; @@ -33,11 +34,11 @@ function MoveArtistModal(props) { isOpen={isOpen} size={sizes.MEDIUM} closeOnBackgroundClick={false} - onModalClose={onSavePress} + onModalClose={onModalClose} > Move Files @@ -76,6 +77,7 @@ MoveArtistModal.propTypes = { destinationPath: PropTypes.string, destinationRootFolder: PropTypes.string, isOpen: PropTypes.bool.isRequired, + onModalClose: PropTypes.func.isRequired, onSavePress: PropTypes.func.isRequired, onMoveArtistPress: PropTypes.func.isRequired }; diff --git a/frontend/src/Artist/NoArtist.css.d.ts b/frontend/src/Artist/NoArtist.css.d.ts new file mode 100644 index 000000000..054af6200 --- /dev/null +++ b/frontend/src/Artist/NoArtist.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'buttonContainer': string; + 'message': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Artist/NoArtist.js b/frontend/src/Artist/NoArtist.js index b869a8d58..ec812fc84 100644 --- a/frontend/src/Artist/NoArtist.js +++ b/frontend/src/Artist/NoArtist.js @@ -1,7 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { kinds } from 'Helpers/Props'; import Button from 'Components/Link/Button'; +import { kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './NoArtist.css'; function NoArtist(props) { @@ -11,7 +12,7 @@ function NoArtist(props) { return (
- All artists are hidden due to the applied filter. + All artists are hidden due to the applied filter.
); @@ -20,24 +21,24 @@ function NoArtist(props) { return (
- No artist found, to get started you'll want to add a new artist or import some existing ones. + No artists found, to get started you'll want to add a new artist or album or add an existing library location (Root Folder) and update.
diff --git a/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js b/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js index 0da3661a8..9ce7e8f9a 100644 --- a/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js +++ b/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; +import { sizes } from 'Helpers/Props'; import ArtistInteractiveSearchModalContent from './ArtistInteractiveSearchModalContent'; function ArtistInteractiveSearchModal(props) { @@ -13,6 +14,7 @@ function ArtistInteractiveSearchModal(props) { return ( diff --git a/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js b/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js index fe3170570..6706a27fa 100644 --- a/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js +++ b/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js @@ -1,9 +1,19 @@ +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; import { connect } from 'react-redux'; import { cancelFetchReleases, clearReleases } from 'Store/Actions/releaseActions'; import ArtistInteractiveSearchModal from './ArtistInteractiveSearchModal'; function createMapDispatchToProps(dispatch, props) { return { + dispatchCancelFetchReleases() { + dispatch(cancelFetchReleases()); + }, + + dispatchClearReleases() { + dispatch(clearReleases()); + }, + onModalClose() { dispatch(cancelFetchReleases()); dispatch(clearReleases()); @@ -12,4 +22,38 @@ function createMapDispatchToProps(dispatch, props) { }; } -export default connect(null, createMapDispatchToProps)(ArtistInteractiveSearchModal); +class ArtistInteractiveSearchModalConnector extends Component { + + // + // Lifecycle + + componentWillUnmount() { + this.props.dispatchCancelFetchReleases(); + this.props.dispatchClearReleases(); + } + + // + // Render + + render() { + const { + dispatchCancelFetchReleases, + dispatchClearReleases, + ...otherProps + } = this.props; + + return ( + + ); + } +} + +ArtistInteractiveSearchModalConnector.propTypes = { + ...ArtistInteractiveSearchModal.propTypes, + dispatchCancelFetchReleases: PropTypes.func.isRequired, + dispatchClearReleases: PropTypes.func.isRequired +}; + +export default connect(null, createMapDispatchToProps)(ArtistInteractiveSearchModalConnector); diff --git a/frontend/src/Artist/Search/ArtistInteractiveSearchModalContent.js b/frontend/src/Artist/Search/ArtistInteractiveSearchModalContent.js index 9b7f4c6ed..2a203499e 100644 --- a/frontend/src/Artist/Search/ArtistInteractiveSearchModalContent.js +++ b/frontend/src/Artist/Search/ArtistInteractiveSearchModalContent.js @@ -1,10 +1,10 @@ import PropTypes from 'prop-types'; import React from 'react'; import Button from 'Components/Link/Button'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; import InteractiveSearchConnector from 'InteractiveSearch/InteractiveSearchConnector'; function ArtistInteractiveSearchModalContent(props) { diff --git a/frontend/src/Calendar/Agenda/Agenda.css.d.ts b/frontend/src/Calendar/Agenda/Agenda.css.d.ts new file mode 100644 index 000000000..44421cc99 --- /dev/null +++ b/frontend/src/Calendar/Agenda/Agenda.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'agenda': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Agenda/AgendaEvent.css b/frontend/src/Calendar/Agenda/AgendaEvent.css index 876c9fc75..a987a4b8c 100644 --- a/frontend/src/Calendar/Agenda/AgendaEvent.css +++ b/frontend/src/Calendar/Agenda/AgendaEvent.css @@ -2,11 +2,11 @@ display: flex; overflow-x: hidden; padding: 5px; - border-bottom: 1px solid $borderColor; + border-bottom: 1px solid var(--borderColor); font-size: $defaultFontSize; &:hover { - background-color: $tableRowHoverBackgroundColor; + background-color: var(--tableRowHoverBackgroundColor); } } @@ -25,7 +25,7 @@ } .time { - flex: 0 0 120px; + flex: 0 0 125px; margin-right: 10px; border: none !important; } diff --git a/frontend/src/Calendar/Agenda/AgendaEvent.css.d.ts b/frontend/src/Calendar/Agenda/AgendaEvent.css.d.ts new file mode 100644 index 000000000..5bf39a6de --- /dev/null +++ b/frontend/src/Calendar/Agenda/AgendaEvent.css.d.ts @@ -0,0 +1,21 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'absoluteEpisodeNumber': string; + 'albumSeparator': string; + 'albumTitle': string; + 'artistName': string; + 'date': string; + 'downloaded': string; + 'downloading': string; + 'event': string; + 'eventWrapper': string; + 'missing': string; + 'partial': string; + 'seasonEpisodeNumber': string; + 'time': string; + 'unmonitored': string; + 'unreleased': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Agenda/AgendaEvent.js b/frontend/src/Calendar/Agenda/AgendaEvent.js index 44ad53063..d21b1aaa2 100644 --- a/frontend/src/Calendar/Agenda/AgendaEvent.js +++ b/frontend/src/Calendar/Agenda/AgendaEvent.js @@ -1,13 +1,14 @@ +import classNames from 'classnames'; import moment from 'moment'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import classNames from 'classnames'; -import formatTime from 'Utilities/Date/formatTime'; -import { icons } from 'Helpers/Props'; +import CalendarEventQueueDetails from 'Calendar/Events/CalendarEventQueueDetails'; import getStatusStyle from 'Calendar/getStatusStyle'; import Icon from 'Components/Icon'; import Link from 'Components/Link/Link'; -import CalendarEventQueueDetails from 'Calendar/Events/CalendarEventQueueDetails'; +import { icons } from 'Helpers/Props'; +import formatTime from 'Utilities/Date/formatTime'; +import translate from 'Utilities/String/translate'; import styles from './AgendaEvent.css'; class AgendaEvent extends Component { @@ -27,11 +28,11 @@ class AgendaEvent extends Component { onPress = () => { this.setState({ isDetailsModalOpen: true }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - } + }; // // Render @@ -110,7 +111,7 @@ class AgendaEvent extends Component { !queueItem && grabbed && } diff --git a/frontend/src/Calendar/Calendar.css.d.ts b/frontend/src/Calendar/Calendar.css.d.ts new file mode 100644 index 000000000..503034402 --- /dev/null +++ b/frontend/src/Calendar/Calendar.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'calendar': string; + 'calendarContent': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Calendar.js b/frontend/src/Calendar/Calendar.js index 6ceb1f3bb..a0b22f92f 100644 --- a/frontend/src/Calendar/Calendar.js +++ b/frontend/src/Calendar/Calendar.js @@ -1,11 +1,14 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import Alert from 'Components/Alert'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import * as calendarViews from './calendarViews'; -import CalendarHeaderConnector from './Header/CalendarHeaderConnector'; -import DaysOfWeekConnector from './Day/DaysOfWeekConnector'; -import CalendarDaysConnector from './Day/CalendarDaysConnector'; +import { kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import AgendaConnector from './Agenda/AgendaConnector'; +import * as calendarViews from './calendarViews'; +import CalendarDaysConnector from './Day/CalendarDaysConnector'; +import DaysOfWeekConnector from './Day/DaysOfWeekConnector'; +import CalendarHeaderConnector from './Header/CalendarHeaderConnector'; import styles from './Calendar.css'; class Calendar extends Component { @@ -30,7 +33,9 @@ class Calendar extends Component { { !isFetching && !!error && -
Unable to load the calendar
+ + {translate('UnableToLoadTheCalendar')} + } { diff --git a/frontend/src/Calendar/CalendarConnector.js b/frontend/src/Calendar/CalendarConnector.js index a97589c59..17221eb34 100644 --- a/frontend/src/Calendar/CalendarConnector.js +++ b/frontend/src/Calendar/CalendarConnector.js @@ -2,12 +2,12 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; +import * as calendarActions from 'Store/Actions/calendarActions'; +import { clearQueueDetails, fetchQueueDetails } from 'Store/Actions/queueActions'; +import { clearTrackFiles, fetchTrackFiles } from 'Store/Actions/trackFileActions'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; -import * as calendarActions from 'Store/Actions/calendarActions'; -import { fetchTrackFiles, clearTrackFiles } from 'Store/Actions/trackFileActions'; -import { fetchQueueDetails, clearQueueDetails } from 'Store/Actions/queueActions'; +import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; import Calendar from './Calendar'; const UPDATE_DELAY = 3600000; // 1 hour @@ -47,7 +47,7 @@ class CalendarConnector extends Component { gotoCalendarToday } = this.props; - registerPagePopulator(this.repopulate); + registerPagePopulator(this.repopulate, ['trackFileUpdated', 'trackFileDeleted']); if (useCurrentPage) { fetchCalendar(); @@ -100,43 +100,43 @@ class CalendarConnector extends Component { this.props.fetchQueueDetails({ time, view }); this.props.fetchCalendar({ time, view }); - } + }; scheduleUpdate = () => { this.clearUpdateTimeout(); this.updateTimeoutId = setTimeout(this.updateCalendar, UPDATE_DELAY); - } + }; clearUpdateTimeout = () => { if (this.updateTimeoutId) { clearTimeout(this.updateTimeoutId); } - } + }; updateCalendar = () => { this.props.gotoCalendarToday(); this.scheduleUpdate(); - } + }; // // Listeners onCalendarViewChange = (view) => { this.props.setCalendarView({ view }); - } + }; onTodayPress = () => { this.props.gotoCalendarToday(); - } + }; onPreviousPress = () => { this.props.gotoCalendarPreviousRange(); - } + }; onNextPress = () => { this.props.gotoCalendarNextRange(); - } + }; // // Render diff --git a/frontend/src/Calendar/CalendarFilterModal.tsx b/frontend/src/Calendar/CalendarFilterModal.tsx new file mode 100644 index 000000000..e26b2928b --- /dev/null +++ b/frontend/src/Calendar/CalendarFilterModal.tsx @@ -0,0 +1,54 @@ +import React, { useCallback } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterModal from 'Components/Filter/FilterModal'; +import { setCalendarFilter } from 'Store/Actions/calendarActions'; + +function createCalendarSelector() { + return createSelector( + (state: AppState) => state.calendar.items, + (calendar) => { + return calendar; + } + ); +} + +function createFilterBuilderPropsSelector() { + return createSelector( + (state: AppState) => state.calendar.filterBuilderProps, + (filterBuilderProps) => { + return filterBuilderProps; + } + ); +} + +interface CalendarFilterModalProps { + isOpen: boolean; +} + +export default function CalendarFilterModal(props: CalendarFilterModalProps) { + const sectionItems = useSelector(createCalendarSelector()); + const filterBuilderProps = useSelector(createFilterBuilderPropsSelector()); + const customFilterType = 'calendar'; + + const dispatch = useDispatch(); + + const dispatchSetFilter = useCallback( + (payload: unknown) => { + dispatch(setCalendarFilter(payload)); + }, + [dispatch] + ); + + return ( + + ); +} diff --git a/frontend/src/Calendar/CalendarPage.css.d.ts b/frontend/src/Calendar/CalendarPage.css.d.ts new file mode 100644 index 000000000..943329132 --- /dev/null +++ b/frontend/src/Calendar/CalendarPage.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'calendarInnerPageBody': string; + 'calendarPageBody': string; + 'errorMessage': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/CalendarPage.js b/frontend/src/Calendar/CalendarPage.js index 9dfe3229e..bf7f46c10 100644 --- a/frontend/src/Calendar/CalendarPage.js +++ b/frontend/src/Calendar/CalendarPage.js @@ -1,19 +1,23 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import getErrorMessage from 'Utilities/Object/getErrorMessage'; -import { align, icons } from 'Helpers/Props'; -import PageContent from 'Components/Page/PageContent'; -import Measure from 'Components/Measure'; -import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; -import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; -import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; -import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; -import FilterMenu from 'Components/Menu/FilterMenu'; import NoArtist from 'Artist/NoArtist'; -import CalendarLinkModal from './iCal/CalendarLinkModal'; -import CalendarOptionsModal from './Options/CalendarOptionsModal'; -import LegendConnector from './Legend/LegendConnector'; +import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import Measure from 'Components/Measure'; +import FilterMenu from 'Components/Menu/FilterMenu'; +import PageContent from 'Components/Page/PageContent'; +import PageContentBody from 'Components/Page/PageContentBody'; +import PageToolbar from 'Components/Page/Toolbar/PageToolbar'; +import PageToolbarButton from 'Components/Page/Toolbar/PageToolbarButton'; +import PageToolbarSection from 'Components/Page/Toolbar/PageToolbarSection'; +import PageToolbarSeparator from 'Components/Page/Toolbar/PageToolbarSeparator'; +import { align, icons } from 'Helpers/Props'; +import getErrorMessage from 'Utilities/Object/getErrorMessage'; +import translate from 'Utilities/String/translate'; import CalendarConnector from './CalendarConnector'; +import CalendarFilterModal from './CalendarFilterModal'; +import CalendarLinkModal from './iCal/CalendarLinkModal'; +import LegendConnector from './Legend/LegendConnector'; +import CalendarOptionsModal from './Options/CalendarOptionsModal'; import styles from './CalendarPage.css'; const MINIMUM_DAY_WIDTH = 120; @@ -41,23 +45,23 @@ class CalendarPage extends Component { const days = Math.max(3, Math.min(7, Math.floor(width / MINIMUM_DAY_WIDTH))); this.props.onDaysCountChange(days); - } + }; onGetCalendarLinkPress = () => { this.setState({ isCalendarLinkModalOpen: true }); - } + }; onGetCalendarLinkModalClose = () => { this.setState({ isCalendarLinkModalOpen: false }); - } + }; onOptionsPress = () => { this.setState({ isOptionsModalOpen: true }); - } + }; onOptionsModalClose = () => { this.setState({ isOptionsModalOpen: false }); - } + }; onSearchMissingPress = () => { const { @@ -66,7 +70,7 @@ class CalendarPage extends Component { } = this.props; onSearchMissingPress(missingAlbumIds); - } + }; // // Render @@ -75,11 +79,16 @@ class CalendarPage extends Component { const { selectedFilterKey, filters, + customFilters, hasArtist, artistError, + artistIsFetching, + artistIsPopulated, missingAlbumIds, + isRssSyncExecuting, isSearchingForMissing, useCurrentPage, + onRssSyncPress, onFilterSelect } = this.props; @@ -90,20 +99,27 @@ class CalendarPage extends Component { const isMeasured = this.state.width > 0; - const PageComponent = hasArtist ? CalendarConnector : NoArtist; - return ( - + + + + + @@ -123,32 +139,38 @@ class CalendarPage extends Component { isDisabled={!hasArtist} selectedFilterKey={selectedFilterKey} filters={filters} - customFilters={[]} + customFilters={customFilters} + filterModalConnectorComponent={CalendarFilterModal} onFilterSelect={onFilterSelect} /> - { - artistError && -
- {getErrorMessage(artistError, 'Failed to load artist from API')} -
+ artistIsFetching && !artistIsPopulated && + } { - !artistError && + artistError && +
+ {getErrorMessage(artistError, 'Failed to load artist from API')} +
+ } + + { + !artistError && artistIsPopulated && hasArtist && { isMeasured ? - :
@@ -156,11 +178,16 @@ class CalendarPage extends Component { } + { + !artistError && artistIsPopulated && !hasArtist && + + } + { hasArtist && !!artistError && } - + state.calendar.selectedFilterKey, (state) => state.calendar.filters, + createCustomFiltersSelector('calendar'), createArtistCountSelector(), createUISettingsSelector(), createMissingAlbumIdsSelector(), + createCommandExecutingSelector(commandNames.RSS_SYNC), createIsSearchingSelector(), ( selectedFilterKey, filters, + customFilters, artistCount, uiSettings, missingAlbumIds, + isRssSyncExecuting, isSearchingForMissing ) => { return { selectedFilterKey, filters, + customFilters, colorImpairedMode: uiSettings.enableColorImpairedMode, hasArtist: !!artistCount.count, artistError: artistCount.error, + artistIsFetching: artistCount.isFetching, + artistIsPopulated: artistCount.isPopulated, missingAlbumIds, + isRssSyncExecuting, isSearchingForMissing }; } @@ -83,9 +95,16 @@ function createMapStateToProps() { function createMapDispatchToProps(dispatch, props) { return { + onRssSyncPress() { + dispatch(executeCommand({ + name: commandNames.RSS_SYNC + })); + }, + onSearchMissingPress(albumIds) { dispatch(searchMissing({ albumIds })); }, + onDaysCountChange(dayCount) { dispatch(setCalendarDaysCount({ dayCount })); }, diff --git a/frontend/src/Calendar/Day/CalendarDay.css b/frontend/src/Calendar/Day/CalendarDay.css index 79eb67ae7..22d1b1ccf 100644 --- a/frontend/src/Calendar/Day/CalendarDay.css +++ b/frontend/src/Calendar/Day/CalendarDay.css @@ -2,8 +2,8 @@ flex: 1 0 14.28%; overflow: hidden; min-height: 70px; - border-bottom: 1px solid $calendarBorderColor; - border-left: 1px solid $calendarBorderColor; + border-bottom: 1px solid var(--calendarBorderColor); + border-left: 1px solid var(--calendarBorderColor); } .isSingleDay { @@ -12,14 +12,14 @@ .dayOfMonth { padding-right: 5px; - border-bottom: 1px solid $calendarBorderColor; + border-bottom: 1px solid var(--calendarBorderColor); text-align: right; } .isToday { - background-color: $calendarTodayBackgroundColor; + background-color: var(--calendarTodayBackgroundColor); } .isDifferentMonth { - color: $disabledColor; + color: var(--disabledColor); } diff --git a/frontend/src/Calendar/Day/CalendarDay.css.d.ts b/frontend/src/Calendar/Day/CalendarDay.css.d.ts new file mode 100644 index 000000000..f32def3dd --- /dev/null +++ b/frontend/src/Calendar/Day/CalendarDay.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'day': string; + 'dayOfMonth': string; + 'isDifferentMonth': string; + 'isSingleDay': string; + 'isToday': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Day/CalendarDay.js b/frontend/src/Calendar/Day/CalendarDay.js index bd196cc5d..50bf9fc92 100644 --- a/frontend/src/Calendar/Day/CalendarDay.js +++ b/frontend/src/Calendar/Day/CalendarDay.js @@ -1,7 +1,7 @@ +import classNames from 'classnames'; import moment from 'moment'; import PropTypes from 'prop-types'; import React from 'react'; -import classNames from 'classnames'; import * as calendarViews from 'Calendar/calendarViews'; import CalendarEventConnector from 'Calendar/Events/CalendarEventConnector'; import styles from './CalendarDay.css'; diff --git a/frontend/src/Calendar/Day/CalendarDays.css b/frontend/src/Calendar/Day/CalendarDays.css index b6dd2100c..507dd0ede 100644 --- a/frontend/src/Calendar/Day/CalendarDays.css +++ b/frontend/src/Calendar/Day/CalendarDays.css @@ -1,6 +1,6 @@ .days { display: flex; - border-right: 1px solid $calendarBorderColor; + border-right: 1px solid var(--calendarBorderColor); } .day, diff --git a/frontend/src/Calendar/Day/CalendarDays.css.d.ts b/frontend/src/Calendar/Day/CalendarDays.css.d.ts new file mode 100644 index 000000000..ae3e7aebc --- /dev/null +++ b/frontend/src/Calendar/Day/CalendarDays.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'day': string; + 'days': string; + 'forecast': string; + 'month': string; + 'week': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Day/CalendarDays.js b/frontend/src/Calendar/Day/CalendarDays.js index 0a1a36172..f2bb4c8d4 100644 --- a/frontend/src/Calendar/Day/CalendarDays.js +++ b/frontend/src/Calendar/Day/CalendarDays.js @@ -1,9 +1,9 @@ +import classNames from 'classnames'; import moment from 'moment'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import classNames from 'classnames'; -import isToday from 'Utilities/Date/isToday'; import * as calendarViews from 'Calendar/calendarViews'; +import isToday from 'Utilities/Date/isToday'; import CalendarDayConnector from './CalendarDayConnector'; import styles from './CalendarDays.css'; @@ -60,20 +60,20 @@ class CalendarDays extends Component { this.setState({ todaysDate: todaysDate.toISOString() }); this.updateTimeoutId = setTimeout(this.scheduleUpdate, diff); - } + }; clearUpdateTimeout = () => { if (this.updateTimeoutId) { clearTimeout(this.updateTimeoutId); } - } + }; // // Listeners onEventModalOpenToggle = (isEventModalOpen) => { this.setState({ isEventModalOpen }); - } + }; onTouchStart = (event) => { const touches = event.touches; @@ -92,7 +92,7 @@ class CalendarDays extends Component { } this._touchStart = touchStart; - } + }; onTouchEnd = (event) => { const touches = event.changedTouches; @@ -109,17 +109,17 @@ class CalendarDays extends Component { } this._touchStart = null; - } + }; onTouchCancel = (event) => { this._touchStart = null; - } + }; onTouchMove = (event) => { if (!this._touchStart) { return; } - } + }; // // Render diff --git a/frontend/src/Calendar/Day/CalendarDaysConnector.js b/frontend/src/Calendar/Day/CalendarDaysConnector.js index 3dea906a7..0acce70b9 100644 --- a/frontend/src/Calendar/Day/CalendarDaysConnector.js +++ b/frontend/src/Calendar/Day/CalendarDaysConnector.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { gotoCalendarPreviousRange, gotoCalendarNextRange } from 'Store/Actions/calendarActions'; +import { gotoCalendarNextRange, gotoCalendarPreviousRange } from 'Store/Actions/calendarActions'; import CalendarDays from './CalendarDays'; function createMapStateToProps() { diff --git a/frontend/src/Calendar/Day/DayOfWeek.css b/frontend/src/Calendar/Day/DayOfWeek.css index 8c3552e55..2d31a30be 100644 --- a/frontend/src/Calendar/Day/DayOfWeek.css +++ b/frontend/src/Calendar/Day/DayOfWeek.css @@ -1,6 +1,6 @@ .dayOfWeek { flex: 1 0 14.28%; - background-color: #e4eaec; + background-color: var(--calendarBackgroundColor); text-align: center; } @@ -9,5 +9,5 @@ } .isToday { - background-color: $calendarTodayBackgroundColor; + background-color: var(--calendarTodayBackgroundColor); } diff --git a/frontend/src/Calendar/Day/DayOfWeek.css.d.ts b/frontend/src/Calendar/Day/DayOfWeek.css.d.ts new file mode 100644 index 000000000..a377e4a8e --- /dev/null +++ b/frontend/src/Calendar/Day/DayOfWeek.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'dayOfWeek': string; + 'isSingleDay': string; + 'isToday': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Day/DayOfWeek.js b/frontend/src/Calendar/Day/DayOfWeek.js index d97671522..39e40fce8 100644 --- a/frontend/src/Calendar/Day/DayOfWeek.js +++ b/frontend/src/Calendar/Day/DayOfWeek.js @@ -1,9 +1,9 @@ +import classNames from 'classnames'; import moment from 'moment'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import classNames from 'classnames'; -import getRelativeDate from 'Utilities/Date/getRelativeDate'; import * as calendarViews from 'Calendar/calendarViews'; +import getRelativeDate from 'Utilities/Date/getRelativeDate'; import styles from './DayOfWeek.css'; class DayOfWeek extends Component { diff --git a/frontend/src/Calendar/Day/DaysOfWeek.css.d.ts b/frontend/src/Calendar/Day/DaysOfWeek.css.d.ts new file mode 100644 index 000000000..5bc224b68 --- /dev/null +++ b/frontend/src/Calendar/Day/DaysOfWeek.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'daysOfWeek': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Day/DaysOfWeek.js b/frontend/src/Calendar/Day/DaysOfWeek.js index a67777f7c..9f94b1079 100644 --- a/frontend/src/Calendar/Day/DaysOfWeek.js +++ b/frontend/src/Calendar/Day/DaysOfWeek.js @@ -1,8 +1,8 @@ import moment from 'moment'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import DayOfWeek from './DayOfWeek'; import * as calendarViews from 'Calendar/calendarViews'; +import DayOfWeek from './DayOfWeek'; import styles from './DaysOfWeek.css'; class DaysOfWeek extends Component { @@ -47,13 +47,13 @@ class DaysOfWeek extends Component { }); this.updateTimeoutId = setTimeout(this.scheduleUpdate, diff); - } + }; clearUpdateTimeout = () => { if (this.updateTimeoutId) { clearTimeout(this.updateTimeoutId); } - } + }; // // Render diff --git a/frontend/src/Calendar/Events/CalendarEvent.css b/frontend/src/Calendar/Events/CalendarEvent.css index 055d51882..b317c72ce 100644 --- a/frontend/src/Calendar/Events/CalendarEvent.css +++ b/frontend/src/Calendar/Events/CalendarEvent.css @@ -1,9 +1,11 @@ +$fullColorGradient: rgba(244, 245, 246, 0.2); + .event { overflow-x: hidden; margin: 4px 2px; padding: 5px; - border-bottom: 1px solid $borderColor; - border-left: 4px solid $borderColor; + border-bottom: 1px solid var(--calendarBorderColor); + border-left: 4px solid var(--calendarBorderColor); font-size: 12px; &:global(.colorImpaired) { @@ -25,7 +27,7 @@ } .artistName { - color: #3a3f51; + color: var(--calendarTextDimAlternate); font-size: $defaultFontSize; } @@ -42,38 +44,50 @@ */ .downloaded { - border-left-color: $successColor !important; + border-left-color: var(--successColor) !important; &:global(.colorImpaired) { - border-left-color: color($successColor, saturation(+15%)) !important; + border-left-color: color(#27c24c saturation(+15%)) !important; } } .downloading { - border-left-color: $purple !important; + border-left-color: var(--purple) !important; + + &:global(.fullColor) { + background-color: rgba(122, 67, 182, 0.4) !important; + } } .unmonitored { - border-left-color: $gray !important; + border-left-color: var(--gray) !important; + + &:global(.fullColor) { + background-color: rgba(173, 173, 173, 0.5) !important; + } &:global(.colorImpaired) { - background: repeating-linear-gradient(90deg, $colorImpairedGradientDark, $colorImpairedGradientDark 5px, $colorImpairedGradient 5px, $colorImpairedGradient 10px); + background: repeating-linear-gradient(45deg, var(--colorImpairedGradientDark), var(--colorImpairedGradientDark) 5px, var(--colorImpairedGradient) 5px, var(--colorImpairedGradient) 10px); + } + + &:global(.fullColor.colorImpaired) { + background: repeating-linear-gradient(45deg, $fullColorGradient, $fullColorGradient 5px, transparent 5px, transparent 10px); } } .missing { - border-left-color: $dangerColor !important; + border-left-color: var(--dangerColor) !important; &:global(.colorImpaired) { - border-left-color: color($dangerColor saturation(+15%)) !important; - background: repeating-linear-gradient(90deg, $colorImpairedGradientDark, $colorImpairedGradientDark 5px, $colorImpairedGradient 5px, $colorImpairedGradient 10px); + border-left-color: color(#f05050 saturation(+15%)) !important; + background: repeating-linear-gradient(90deg, var(--colorImpairedGradientDark), var(--colorImpairedGradientDark) 5px, var(--colorImpairedGradient) 5px, var(--colorImpairedGradient) 10px); } } .unreleased { - border-left-color: $primaryColor !important; + border-left-color: var(--primaryColor) !important; &:global(.colorImpaired) { - background: repeating-linear-gradient(90deg, $colorImpairedGradientDark, $colorImpairedGradientDark 5px, $colorImpairedGradient 5px, $colorImpairedGradient 10px); + background: repeating-linear-gradient(90deg, var(--colorImpairedGradientDark), var(--colorImpairedGradientDark) 5px, var(--colorImpairedGradient) 5px, var(--colorImpairedGradient) 10px); } } diff --git a/frontend/src/Calendar/Events/CalendarEvent.css.d.ts b/frontend/src/Calendar/Events/CalendarEvent.css.d.ts new file mode 100644 index 000000000..61bc8c539 --- /dev/null +++ b/frontend/src/Calendar/Events/CalendarEvent.css.d.ts @@ -0,0 +1,18 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'absoluteEpisodeNumber': string; + 'albumInfo': string; + 'albumTitle': string; + 'artistName': string; + 'downloaded': string; + 'downloading': string; + 'event': string; + 'info': string; + 'missing': string; + 'statusIcon': string; + 'unmonitored': string; + 'unreleased': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Events/CalendarEvent.js b/frontend/src/Calendar/Events/CalendarEvent.js index 8f04fd670..115314b92 100644 --- a/frontend/src/Calendar/Events/CalendarEvent.js +++ b/frontend/src/Calendar/Events/CalendarEvent.js @@ -1,11 +1,12 @@ +import classNames from 'classnames'; import moment from 'moment'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import classNames from 'classnames'; -import { icons } from 'Helpers/Props'; import getStatusStyle from 'Calendar/getStatusStyle'; import Icon from 'Components/Icon'; import Link from 'Components/Link/Link'; +import { icons } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import CalendarEventQueueDetails from './CalendarEventQueueDetails'; import styles from './CalendarEvent.css'; @@ -29,13 +30,13 @@ class CalendarEvent extends Component { this.setState({ isDetailsModalOpen: true }, () => { this.props.onEventModalOpenToggle(true); }); - } + }; onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }, () => { this.props.onEventModalOpenToggle(false); }); - } + }; // // Render @@ -94,11 +95,11 @@ class CalendarEvent extends Component { { !queueItem && grabbed && - + }
diff --git a/frontend/src/Calendar/Events/CalendarEventQueueDetails.js b/frontend/src/Calendar/Events/CalendarEventQueueDetails.js index 1b603fd50..5df7e8ea4 100644 --- a/frontend/src/Calendar/Events/CalendarEventQueueDetails.js +++ b/frontend/src/Calendar/Events/CalendarEventQueueDetails.js @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; -import colors from 'Styles/Variables/colors'; -import CircularProgressBar from 'Components/CircularProgressBar'; import QueueDetails from 'Activity/Queue/QueueDetails'; +import CircularProgressBar from 'Components/CircularProgressBar'; +import translate from 'Utilities/String/translate'; function CalendarEventQueueDetails(props) { const { @@ -11,10 +11,12 @@ function CalendarEventQueueDetails(props) { sizeleft, estimatedCompletionTime, status, + trackedDownloadState, + trackedDownloadStatus, errorMessage } = props; - const progress = (100 - sizeleft / size * 100); + const progress = size ? (100 - sizeleft / size * 100) : 0; return ( +
} @@ -44,6 +48,8 @@ CalendarEventQueueDetails.propTypes = { sizeleft: PropTypes.number.isRequired, estimatedCompletionTime: PropTypes.string, status: PropTypes.string.isRequired, + trackedDownloadState: PropTypes.string.isRequired, + trackedDownloadStatus: PropTypes.string.isRequired, errorMessage: PropTypes.string }; diff --git a/frontend/src/Calendar/Header/CalendarHeader.css.d.ts b/frontend/src/Calendar/Header/CalendarHeader.css.d.ts new file mode 100644 index 000000000..700b53652 --- /dev/null +++ b/frontend/src/Calendar/Header/CalendarHeader.css.d.ts @@ -0,0 +1,14 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'header': string; + 'loading': string; + 'navigationButtons': string; + 'titleDesktop': string; + 'titleMobile': string; + 'todayButton': string; + 'viewButtonsContainer': string; + 'viewMenu': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Header/CalendarHeader.js b/frontend/src/Calendar/Header/CalendarHeader.js index 97052e0c8..24b397eb4 100644 --- a/frontend/src/Calendar/Header/CalendarHeader.js +++ b/frontend/src/Calendar/Header/CalendarHeader.js @@ -2,15 +2,15 @@ import moment from 'moment'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { align, icons } from 'Helpers/Props'; -import Button from 'Components/Link/Button'; +import * as calendarViews from 'Calendar/calendarViews'; import Icon from 'Components/Icon'; +import Button from 'Components/Link/Button'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import Menu from 'Components/Menu/Menu'; import MenuButton from 'Components/Menu/MenuButton'; import MenuContent from 'Components/Menu/MenuContent'; import ViewMenuItem from 'Components/Menu/ViewMenuItem'; -import * as calendarViews from 'Calendar/calendarViews'; +import { align, icons } from 'Helpers/Props'; import CalendarHeaderViewButton from './CalendarHeaderViewButton'; import styles from './CalendarHeader.css'; @@ -71,7 +71,7 @@ class CalendarHeader extends Component { this.setState({ view }, () => { this.props.onViewChange(view); }); - } + }; // // Render diff --git a/frontend/src/Calendar/Header/CalendarHeaderConnector.js b/frontend/src/Calendar/Header/CalendarHeaderConnector.js index b73730ed9..616e48650 100644 --- a/frontend/src/Calendar/Header/CalendarHeaderConnector.js +++ b/frontend/src/Calendar/Header/CalendarHeaderConnector.js @@ -3,9 +3,9 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; +import { gotoCalendarNextRange, gotoCalendarPreviousRange, gotoCalendarToday, setCalendarView } from 'Store/Actions/calendarActions'; import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; -import { setCalendarView, gotoCalendarToday, gotoCalendarPreviousRange, gotoCalendarNextRange } from 'Store/Actions/calendarActions'; import CalendarHeader from './CalendarHeader'; function createMapStateToProps() { @@ -45,19 +45,19 @@ class CalendarHeaderConnector extends Component { onViewChange = (view) => { this.props.setCalendarView({ view }); - } + }; onTodayPress = () => { this.props.gotoCalendarToday(); - } + }; onPreviousPress = () => { this.props.gotoCalendarPreviousRange(); - } + }; onNextPress = () => { this.props.gotoCalendarNextRange(); - } + }; // // Render diff --git a/frontend/src/Calendar/Header/CalendarHeaderViewButton.js b/frontend/src/Calendar/Header/CalendarHeaderViewButton.js index 8dd5ae9f0..98958af03 100644 --- a/frontend/src/Calendar/Header/CalendarHeaderViewButton.js +++ b/frontend/src/Calendar/Header/CalendarHeaderViewButton.js @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import titleCase from 'Utilities/String/titleCase'; -import Button from 'Components/Link/Button'; import * as calendarViews from 'Calendar/calendarViews'; +import Button from 'Components/Link/Button'; +import titleCase from 'Utilities/String/titleCase'; // import styles from './CalendarHeaderViewButton.css'; class CalendarHeaderViewButton extends Component { @@ -12,7 +12,7 @@ class CalendarHeaderViewButton extends Component { onPress = () => { this.props.onPress(this.props.view); - } + }; // // Render diff --git a/frontend/src/Calendar/Legend/Legend.css.d.ts b/frontend/src/Calendar/Legend/Legend.css.d.ts new file mode 100644 index 000000000..19c0339b4 --- /dev/null +++ b/frontend/src/Calendar/Legend/Legend.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'legend': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Legend/Legend.js b/frontend/src/Calendar/Legend/Legend.js index cc69198fd..88ddc82c7 100644 --- a/frontend/src/Calendar/Legend/Legend.js +++ b/frontend/src/Calendar/Legend/Legend.js @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; import { icons, kinds } from 'Helpers/Props'; -import LegendItem from './LegendItem'; import LegendIconItem from './LegendIconItem'; +import LegendItem from './LegendItem'; import styles from './Legend.css'; function Legend(props) { diff --git a/frontend/src/Calendar/Legend/LegendIconItem.css.d.ts b/frontend/src/Calendar/Legend/LegendIconItem.css.d.ts new file mode 100644 index 000000000..5d618d24b --- /dev/null +++ b/frontend/src/Calendar/Legend/LegendIconItem.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'icon': string; + 'legendIconItem': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Legend/LegendItem.css.d.ts b/frontend/src/Calendar/Legend/LegendItem.css.d.ts new file mode 100644 index 000000000..954aafd90 --- /dev/null +++ b/frontend/src/Calendar/Legend/LegendItem.css.d.ts @@ -0,0 +1,14 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'downloaded': string; + 'downloading': string; + 'legendItem': string; + 'missing': string; + 'onAir': string; + 'partial': string; + 'unmonitored': string; + 'unreleased': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Calendar/Legend/LegendItem.js b/frontend/src/Calendar/Legend/LegendItem.js index 961f48b86..5da15baba 100644 --- a/frontend/src/Calendar/Legend/LegendItem.js +++ b/frontend/src/Calendar/Legend/LegendItem.js @@ -1,6 +1,6 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; -import classNames from 'classnames'; import titleCase from 'Utilities/String/titleCase'; import styles from './LegendItem.css'; diff --git a/frontend/src/Calendar/Options/CalendarOptionsModalContent.js b/frontend/src/Calendar/Options/CalendarOptionsModalContent.js index a25d36f9c..a291570bb 100644 --- a/frontend/src/Calendar/Options/CalendarOptionsModalContent.js +++ b/frontend/src/Calendar/Options/CalendarOptionsModalContent.js @@ -1,17 +1,18 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { inputTypes } from 'Helpers/Props'; import FieldSet from 'Components/FieldSet'; -import Button from 'Components/Link/Button'; import Form from 'Components/Form/Form'; import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; import FormInputGroup from 'Components/Form/FormInputGroup'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; +import FormLabel from 'Components/Form/FormLabel'; +import Button from 'Components/Link/Button'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; -import { firstDayOfWeekOptions, weekColumnOptions, timeFormatOptions } from 'Settings/UI/UISettings'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes } from 'Helpers/Props'; +import { firstDayOfWeekOptions, timeFormatOptions, weekColumnOptions } from 'Settings/UI/UISettings'; +import translate from 'Utilities/String/translate'; class CalendarOptionsModalContent extends Component { @@ -68,7 +69,7 @@ class CalendarOptionsModalContent extends Component { } = this.props; dispatchSetCalendarOption({ [name]: value }); - } + }; onGlobalInputChange = ({ name, value }) => { const { @@ -80,11 +81,11 @@ class CalendarOptionsModalContent extends Component { this.setState(setting, () => { dispatchSaveUISettings(setting); }); - } + }; onLinkFocus = (event) => { event.target.select(); - } + }; // // Render @@ -110,38 +111,44 @@ class CalendarOptionsModalContent extends Component {
-
+
- Collapse Multiple Albums + + {translate('CollapseMultipleAlbums')} + - Icon for Cutoff Unmet + + {translate('IconForCutoffUnmet')} +
-
+
- First Day of Week + + {translate('FirstDayOfWeek')} + - Week Column Header + + {translate('WeekColumnHeader')} + - Time Format + + {translate('TimeFormat')} + - Enable Color-Impaired Mode + + {translate('EnableColorImpairedMode')} + diff --git a/frontend/src/Calendar/Options/CalendarOptionsModalContentConnector.js b/frontend/src/Calendar/Options/CalendarOptionsModalContentConnector.js index eb979f74e..1f517b698 100644 --- a/frontend/src/Calendar/Options/CalendarOptionsModalContentConnector.js +++ b/frontend/src/Calendar/Options/CalendarOptionsModalContentConnector.js @@ -1,8 +1,8 @@ import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { setCalendarOption } from 'Store/Actions/calendarActions'; -import CalendarOptionsModalContent from './CalendarOptionsModalContent'; import { saveUISettings } from 'Store/Actions/settingsActions'; +import CalendarOptionsModalContent from './CalendarOptionsModalContent'; function createMapStateToProps() { return createSelector( diff --git a/frontend/src/Calendar/iCal/CalendarLinkModalContent.js b/frontend/src/Calendar/iCal/CalendarLinkModalContent.js index 074c66516..3473f4c31 100644 --- a/frontend/src/Calendar/iCal/CalendarLinkModalContent.js +++ b/frontend/src/Calendar/iCal/CalendarLinkModalContent.js @@ -1,18 +1,19 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons, inputTypes, kinds, sizes } from 'Helpers/Props'; +import Form from 'Components/Form/Form'; +import FormGroup from 'Components/Form/FormGroup'; +import FormInputButton from 'Components/Form/FormInputButton'; +import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; import Icon from 'Components/Icon'; import Button from 'Components/Link/Button'; import ClipboardButton from 'Components/Link/ClipboardButton'; -import Form from 'Components/Form/Form'; -import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormInputButton from 'Components/Form/FormInputButton'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { icons, inputTypes, kinds, sizes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; function getUrls(state) { const { @@ -32,7 +33,7 @@ function getUrls(state) { icalUrl += `tags=${tags.toString()}&`; } - icalUrl += `pastDays=${pastDays}&futureDays=${futureDays}&apikey=${window.Lidarr.apiKey}`; + icalUrl += `pastDays=${pastDays}&futureDays=${futureDays}&apikey=${encodeURIComponent(window.Lidarr.apiKey)}`; const iCalHttpUrl = `${window.location.protocol}//${icalUrl}`; const iCalWebCalUrl = `webcal://${icalUrl}`; @@ -81,11 +82,11 @@ class CalendarLinkModalContent extends Component { [name]: value, ...urls }); - } + }; onLinkFocus = (event) => { event.target.select(); - } + }; // // Render @@ -113,49 +114,57 @@ class CalendarLinkModalContent extends Component { - Include Unmonitored + + {translate('IncludeUnmonitored')} + - Past Days + + {translate('PastDays')} + - Future Days + + {translate('FutureDays')} + - Tags + + {translate('Tags')} + @@ -163,14 +172,16 @@ class CalendarLinkModalContent extends Component { - iCal Feed + + {translate('ICalFeed')} + +
@@ -29,12 +30,13 @@ class DescriptionListItem extends Component { > {data} - +
); } } DescriptionListItem.propTypes = { + className: PropTypes.string, titleClassName: PropTypes.string, descriptionClassName: PropTypes.string, title: PropTypes.string, diff --git a/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css b/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css index b23415a76..786123fb7 100644 --- a/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css +++ b/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css @@ -1,9 +1,7 @@ -.description { - line-height: $lineHeight; -} - .description { margin-left: 0; + line-height: $lineHeight; + overflow-wrap: break-word; } @media (min-width: 768px) { diff --git a/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css.d.ts b/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css.d.ts new file mode 100644 index 000000000..ff7055b0f --- /dev/null +++ b/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'description': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/DescriptionList/DescriptionListItemTitle.css.d.ts b/frontend/src/Components/DescriptionList/DescriptionListItemTitle.css.d.ts new file mode 100644 index 000000000..86bceec06 --- /dev/null +++ b/frontend/src/Components/DescriptionList/DescriptionListItemTitle.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'title': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/DragPreviewLayer.css.d.ts b/frontend/src/Components/DragPreviewLayer.css.d.ts new file mode 100644 index 000000000..6944a829d --- /dev/null +++ b/frontend/src/Components/DragPreviewLayer.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'dragLayer': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Error/ErrorBoundary.js b/frontend/src/Components/Error/ErrorBoundary.js index 87fb2498a..88412ad19 100644 --- a/frontend/src/Components/Error/ErrorBoundary.js +++ b/frontend/src/Components/Error/ErrorBoundary.js @@ -1,6 +1,6 @@ +import * as sentry from '@sentry/browser'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import * as sentry from '@sentry/browser'; class ErrorBoundary extends Component { diff --git a/frontend/src/Components/Error/ErrorBoundaryError.css b/frontend/src/Components/Error/ErrorBoundaryError.css index b6d1f917e..3e7a04302 100644 --- a/frontend/src/Components/Error/ErrorBoundaryError.css +++ b/frontend/src/Components/Error/ErrorBoundaryError.css @@ -25,6 +25,10 @@ white-space: pre-wrap; } +.version { + margin-top: 20px; +} + @media only screen and (max-width: $breakpointMedium) { .image { height: 250px; diff --git a/frontend/src/Components/Error/ErrorBoundaryError.css.d.ts b/frontend/src/Components/Error/ErrorBoundaryError.css.d.ts new file mode 100644 index 000000000..e19fd804d --- /dev/null +++ b/frontend/src/Components/Error/ErrorBoundaryError.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'container': string; + 'details': string; + 'image': string; + 'imageContainer': string; + 'message': string; + 'version': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Error/ErrorBoundaryError.js b/frontend/src/Components/Error/ErrorBoundaryError.js deleted file mode 100644 index f99930437..000000000 --- a/frontend/src/Components/Error/ErrorBoundaryError.js +++ /dev/null @@ -1,60 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import styles from './ErrorBoundaryError.css'; - -function ErrorBoundaryError(props) { - const { - className, - messageClassName, - detailsClassName, - message, - error, - info - } = props; - - return ( -
-
- {message} -
- -
- -
- -
- { - error && -
- {error.toString()} -
- } - -
- {info.componentStack} -
-
-
- ); -} - -ErrorBoundaryError.propTypes = { - className: PropTypes.string.isRequired, - messageClassName: PropTypes.string.isRequired, - detailsClassName: PropTypes.string.isRequired, - message: PropTypes.string.isRequired, - error: PropTypes.object.isRequired, - info: PropTypes.object.isRequired -}; - -ErrorBoundaryError.defaultProps = { - className: styles.container, - messageClassName: styles.message, - detailsClassName: styles.details, - message: 'There was an error loading this content' -}; - -export default ErrorBoundaryError; diff --git a/frontend/src/Components/Error/ErrorBoundaryError.tsx b/frontend/src/Components/Error/ErrorBoundaryError.tsx new file mode 100644 index 000000000..e7e74d10a --- /dev/null +++ b/frontend/src/Components/Error/ErrorBoundaryError.tsx @@ -0,0 +1,73 @@ +import React, { useEffect, useState } from 'react'; +import StackTrace from 'stacktrace-js'; +import translate from 'Utilities/String/translate'; +import styles from './ErrorBoundaryError.css'; + +interface ErrorBoundaryErrorProps { + className: string; + messageClassName: string; + detailsClassName: string; + message: string; + error: Error; + info: { + componentStack: string; + }; +} + +function ErrorBoundaryError(props: ErrorBoundaryErrorProps) { + const { + className = styles.container, + messageClassName = styles.message, + detailsClassName = styles.details, + message = translate('ErrorLoadingContent'), + error, + info, + } = props; + + const [detailedError, setDetailedError] = useState< + StackTrace.StackFrame[] | null + >(null); + + useEffect(() => { + if (error) { + StackTrace.fromError(error).then((de) => { + setDetailedError(de); + }); + } else { + setDetailedError(null); + } + }, [error, setDetailedError]); + + return ( +
+
{message}
+ +
+ +
+ +
+ {error ?
{error.message}
: null} + + {detailedError ? ( + detailedError.map((d, index) => { + return ( +
+ {` at ${d.functionName} (${d.fileName}:${d.lineNumber}:${d.columnNumber})`} +
+ ); + }) + ) : ( +
{info.componentStack}
+ )} + + {
Version: {window.Lidarr.version}
} +
+
+ ); +} + +export default ErrorBoundaryError; diff --git a/frontend/src/Components/FieldSet.css b/frontend/src/Components/FieldSet.css index daf3bdf2e..9ea0dbab1 100644 --- a/frontend/src/Components/FieldSet.css +++ b/frontend/src/Components/FieldSet.css @@ -13,7 +13,12 @@ width: 100%; border: 0; border-bottom: 1px solid #e5e5e5; - color: #3a3f51; + color: var(--textColor); font-size: 21px; line-height: inherit; + + &.small { + color: #909293; + font-size: 18px; + } } diff --git a/frontend/src/Components/FieldSet.css.d.ts b/frontend/src/Components/FieldSet.css.d.ts new file mode 100644 index 000000000..74e99779a --- /dev/null +++ b/frontend/src/Components/FieldSet.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'fieldSet': string; + 'legend': string; + 'small': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/FieldSet.js b/frontend/src/Components/FieldSet.js index 76e68a934..8243fd00c 100644 --- a/frontend/src/Components/FieldSet.js +++ b/frontend/src/Components/FieldSet.js @@ -1,5 +1,7 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import { sizes } from 'Helpers/Props'; import styles from './FieldSet.css'; class FieldSet extends Component { @@ -9,13 +11,14 @@ class FieldSet extends Component { render() { const { + size, legend, children } = this.props; return (
- + {legend} {children} @@ -26,8 +29,13 @@ class FieldSet extends Component { } FieldSet.propTypes = { + size: PropTypes.oneOf(sizes.all).isRequired, legend: PropTypes.oneOfType([PropTypes.node, PropTypes.string]), children: PropTypes.node }; +FieldSet.defaultProps = { + size: sizes.MEDIUM +}; + export default FieldSet; diff --git a/frontend/src/Components/FileBrowser/FileBrowserModal.css.d.ts b/frontend/src/Components/FileBrowser/FileBrowserModal.css.d.ts new file mode 100644 index 000000000..5d00cca7e --- /dev/null +++ b/frontend/src/Components/FileBrowser/FileBrowserModal.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'modal': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css index 7ddb9e806..db31d6f86 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css @@ -13,7 +13,7 @@ } .faqLink { - color: $alertWarningColor; + color: var(--alertWarningColor); font-weight: bold; } diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css.d.ts b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css.d.ts new file mode 100644 index 000000000..e83c13075 --- /dev/null +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'faqLink': string; + 'loading': string; + 'mappedDrivesWarning': string; + 'modalBody': string; + 'pathInput': string; + 'scroller': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContent.js b/frontend/src/Components/FileBrowser/FileBrowserModalContent.js index ca84ac078..dff1fbf6e 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContent.js +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContent.js @@ -1,31 +1,31 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import ReactDOM from 'react-dom'; -import { kinds, scrollDirections } from 'Helpers/Props'; import Alert from 'Components/Alert'; +import PathInput from 'Components/Form/PathInput'; import Button from 'Components/Link/Button'; -import Link from 'Components/Link/Link'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; +import InlineMarkdown from 'Components/Markdown/InlineMarkdown'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; import Scroller from 'Components/Scroller/Scroller'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; -import PathInput from 'Components/Form/PathInput'; +import { kinds, scrollDirections } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import FileBrowserRow from './FileBrowserRow'; import styles from './FileBrowserModalContent.css'; const columns = [ { name: 'type', - label: 'Type', + label: () => translate('Type'), isVisible: true }, { name: 'name', - label: 'Name', + label: () => translate('Name'), isVisible: true } ]; @@ -38,7 +38,7 @@ class FileBrowserModalContent extends Component { constructor(props, context) { super(props, context); - this._scrollerNode = null; + this._scrollerRef = React.createRef(); this.state = { isFileBrowserModalOpen: false, @@ -56,18 +56,7 @@ class FileBrowserModalContent extends Component { currentPath !== prevState.currentPath ) { this.setState({ currentPath }); - this._scrollerNode.scrollTop = 0; - } - } - - // - // Control - - setScrollerRef = (ref) => { - if (ref) { - this._scrollerNode = ReactDOM.findDOMNode(ref); - } else { - this._scrollerNode = null; + this._scrollerRef.current.scrollTop = 0; } } @@ -76,11 +65,11 @@ class FileBrowserModalContent extends Component { onPathInputChange = ({ value }) => { this.setState({ currentPath: value }); - } + }; onRowPress = (path) => { this.props.onFetchPaths(path); - } + }; onOkPress = () => { this.props.onChange({ @@ -90,7 +79,7 @@ class FileBrowserModalContent extends Component { this.props.onClearPaths(); this.props.onModalClose(); - } + }; // // Render @@ -128,13 +117,13 @@ class FileBrowserModalContent extends Component { className={styles.mappedDrivesWarning} kind={kinds.WARNING} > - Mapped network drives are not available when running as a Windows Service, see the FAQ for more information. + } { !!error && -
Error loading contents
+
+ {translate('ErrorLoadingContents')} +
} { @@ -223,13 +214,13 @@ class FileBrowserModalContent extends Component { diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js b/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js index da5ae2ab8..1a3a41ef0 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { fetchPaths, clearPaths } from 'Store/Actions/pathActions'; +import { clearPaths, fetchPaths } from 'Store/Actions/pathActions'; import createSystemStatusSelector from 'Store/Selectors/createSystemStatusSelector'; import FileBrowserModalContent from './FileBrowserModalContent'; @@ -78,16 +78,16 @@ class FileBrowserModalContentConnector extends Component { allowFoldersWithoutTrailingSlashes: true, includeFiles }); - } + }; onClearPaths = () => { // this.props.dispatchClearPaths(); - } + }; onModalClose = () => { this.props.dispatchClearPaths(); this.props.onModalClose(); - } + }; // // Render diff --git a/frontend/src/Components/FileBrowser/FileBrowserRow.css.d.ts b/frontend/src/Components/FileBrowser/FileBrowserRow.css.d.ts new file mode 100644 index 000000000..127d00928 --- /dev/null +++ b/frontend/src/Components/FileBrowser/FileBrowserRow.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'type': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/FileBrowser/FileBrowserRow.js b/frontend/src/Components/FileBrowser/FileBrowserRow.js index 42ac30405..06bb3029d 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserRow.js +++ b/frontend/src/Components/FileBrowser/FileBrowserRow.js @@ -1,9 +1,9 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons } from 'Helpers/Props'; import Icon from 'Components/Icon'; -import TableRowButton from 'Components/Table/TableRowButton'; import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import TableRowButton from 'Components/Table/TableRowButton'; +import { icons } from 'Helpers/Props'; import styles from './FileBrowserRow.css'; function getIconName(type) { @@ -28,7 +28,7 @@ class FileBrowserRow extends Component { onPress = () => { this.props.onPress(this.props.path); - } + }; // // Render diff --git a/frontend/src/Components/Filter/Builder/ArtistFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/ArtistFilterBuilderRowValue.tsx new file mode 100644 index 000000000..486027f35 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/ArtistFilterBuilderRowValue.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import Artist from 'Artist/Artist'; +import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import sortByProp from 'Utilities/Array/sortByProp'; +import FilterBuilderRowValue from './FilterBuilderRowValue'; +import FilterBuilderRowValueProps from './FilterBuilderRowValueProps'; + +function ArtistFilterBuilderRowValue(props: FilterBuilderRowValueProps) { + const allArtists: Artist[] = useSelector(createAllArtistSelector()); + + const tagList = allArtists + .map((artist) => ({ id: artist.id, name: artist.artistName })) + .sort(sortByProp('name')); + + return ; +} + +export default ArtistFilterBuilderRowValue; diff --git a/frontend/src/Components/Filter/Builder/ArtistStatusFilterBuilderRowValue.js b/frontend/src/Components/Filter/Builder/ArtistStatusFilterBuilderRowValue.js index 28070d200..2b28e0f42 100644 --- a/frontend/src/Components/Filter/Builder/ArtistStatusFilterBuilderRowValue.js +++ b/frontend/src/Components/Filter/Builder/ArtistStatusFilterBuilderRowValue.js @@ -3,7 +3,7 @@ import FilterBuilderRowValue from './FilterBuilderRowValue'; const protocols = [ { id: 'continuing', name: 'Continuing' }, - { id: 'ended', name: 'Ended' } + { id: 'ended', name: 'Inactive' } ]; function ArtistStatusFilterBuilderRowValue(props) { diff --git a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.css.d.ts b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.css.d.ts new file mode 100644 index 000000000..d391a1f30 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'container': string; + 'numberInput': string; + 'selectInput': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js index f0c2d3626..0193cf44f 100644 --- a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js +++ b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.js @@ -1,10 +1,10 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import isString from 'Utilities/String/isString'; -import { IN_LAST, IN_NEXT } from 'Helpers/Props/filterTypes'; import NumberInput from 'Components/Form/NumberInput'; import SelectInput from 'Components/Form/SelectInput'; import TextInput from 'Components/Form/TextInput'; +import { IN_LAST, IN_NEXT, NOT_IN_LAST, NOT_IN_NEXT } from 'Helpers/Props/filterTypes'; +import isString from 'Utilities/String/isString'; import { NAME } from './FilterBuilderRowValue'; import styles from './DateFilterBuilderRowValue.css'; @@ -18,7 +18,12 @@ const timeOptions = [ ]; function isInFilter(filterType) { - return filterType === IN_LAST || filterType === IN_NEXT; + return ( + filterType === IN_LAST || + filterType === NOT_IN_LAST || + filterType === IN_NEXT || + filterType === NOT_IN_NEXT + ); } class DateFilterBuilderRowValue extends Component { @@ -97,7 +102,7 @@ class DateFilterBuilderRowValue extends Component { name: NAME, value: newValue }); - } + }; onTimeChange = ({ value }) => { const { @@ -112,7 +117,7 @@ class DateFilterBuilderRowValue extends Component { value: filterValue.value } }); - } + }; // // Render @@ -155,6 +160,7 @@ class DateFilterBuilderRowValue extends Component { diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.css.d.ts b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.css.d.ts new file mode 100644 index 000000000..033d2edca --- /dev/null +++ b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'label': string; + 'labelContainer': string; + 'labelInputContainer': string; + 'rows': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js index 62c3f0197..0c4a31657 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js @@ -1,13 +1,15 @@ +import { maxBy } from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { inputTypes } from 'Helpers/Props'; import FormInputGroup from 'Components/Form/FormInputGroup'; import Button from 'Components/Link/Button'; import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton'; -import ModalContent from 'Components/Modal/ModalContent'; -import ModalHeader from 'Components/Modal/ModalHeader'; import ModalBody from 'Components/Modal/ModalBody'; +import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; +import ModalHeader from 'Components/Modal/ModalHeader'; +import { inputTypes } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import FilterBuilderRow from './FilterBuilderRow'; import styles from './FilterBuilderModalContent.css'; @@ -49,7 +51,7 @@ class FilterBuilderModalContent extends Component { if (id) { dispatchSetFilter({ selectedFilterKey: id }); } else { - const last = customFilters[customFilters.length -1]; + const last = maxBy(customFilters, 'id'); dispatchSetFilter({ selectedFilterKey: last.id }); } @@ -62,7 +64,7 @@ class FilterBuilderModalContent extends Component { onLabelChange = ({ value }) => { this.setState({ label: value }); - } + }; onFilterChange = (index, filter) => { const filters = [...this.state.filters]; @@ -71,7 +73,7 @@ class FilterBuilderModalContent extends Component { this.setState({ filters }); - } + }; onAddFilterPress = () => { const filters = [...this.state.filters]; @@ -80,7 +82,7 @@ class FilterBuilderModalContent extends Component { this.setState({ filters }); - } + }; onRemoveFilterPress = (index) => { const filters = [...this.state.filters]; @@ -89,7 +91,7 @@ class FilterBuilderModalContent extends Component { this.setState({ filters }); - } + }; onSaveFilterPress = () => { const { @@ -107,7 +109,7 @@ class FilterBuilderModalContent extends Component { this.setState({ labelErrors: [ { - message: 'Label is required' + message: translate('LabelIsRequired') } ] }); @@ -121,7 +123,7 @@ class FilterBuilderModalContent extends Component { label, filters }); - } + }; // // Render @@ -145,13 +147,13 @@ class FilterBuilderModalContent extends Component { return ( - Custom Filter + {translate('CustomFilter')}
- Label + {translate('Label')}
@@ -165,14 +167,16 @@ class FilterBuilderModalContent extends Component {
-
Filters
+
+ {translate('Filters')} +
{ filters.map((filter, index) => { return ( - Save + {translate('Save')} diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderModalContentConnector.js b/frontend/src/Components/Filter/Builder/FilterBuilderModalContentConnector.js index c94db9925..17633172b 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderModalContentConnector.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderModalContentConnector.js @@ -1,6 +1,6 @@ import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { saveCustomFilter, deleteCustomFilter } from 'Store/Actions/customFilterActions'; +import { deleteCustomFilter, saveCustomFilter } from 'Store/Actions/customFilterActions'; import FilterBuilderModalContent from './FilterBuilderModalContent'; function createMapStateToProps() { diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRow.css b/frontend/src/Components/Filter/Builder/FilterBuilderRow.css index c5471b253..bcfc3b04e 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRow.css +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRow.css @@ -3,7 +3,7 @@ margin-bottom: 5px; &:hover { - background-color: $tableRowHoverBackgroundColor; + background-color: var(--tableRowHoverBackgroundColor); } } diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRow.css.d.ts b/frontend/src/Components/Filter/Builder/FilterBuilderRow.css.d.ts new file mode 100644 index 000000000..aba698af4 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRow.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actionsContainer': string; + 'filterRow': string; + 'inputContainer': string; + 'valueInputContainer': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRow.js b/frontend/src/Components/Filter/Builder/FilterBuilderRow.js index 26bc50192..77dad7173 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRow.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRow.js @@ -1,17 +1,21 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { filterBuilderTypes, filterBuilderValueTypes, icons } from 'Helpers/Props'; import SelectInput from 'Components/Form/SelectInput'; import IconButton from 'Components/Link/IconButton'; +import { filterBuilderTypes, filterBuilderValueTypes, icons } from 'Helpers/Props'; +import sortByProp from 'Utilities/Array/sortByProp'; +import ArtistFilterBuilderRowValue from './ArtistFilterBuilderRowValue'; +import ArtistStatusFilterBuilderRowValue from './ArtistStatusFilterBuilderRowValue'; import BoolFilterBuilderRowValue from './BoolFilterBuilderRowValue'; import DateFilterBuilderRowValue from './DateFilterBuilderRowValue'; import FilterBuilderRowValueConnector from './FilterBuilderRowValueConnector'; +import HistoryEventTypeFilterBuilderRowValue from './HistoryEventTypeFilterBuilderRowValue'; import IndexerFilterBuilderRowValueConnector from './IndexerFilterBuilderRowValueConnector'; -import MetadataProfileFilterBuilderRowValueConnector from './MetadataProfileFilterBuilderRowValueConnector'; +import MetadataProfileFilterBuilderRowValue from './MetadataProfileFilterBuilderRowValue'; +import MonitorNewItemsFilterBuilderRowValue from './MonitorNewItemsFilterBuilderRowValue'; import ProtocolFilterBuilderRowValue from './ProtocolFilterBuilderRowValue'; import QualityFilterBuilderRowValueConnector from './QualityFilterBuilderRowValueConnector'; -import QualityProfileFilterBuilderRowValueConnector from './QualityProfileFilterBuilderRowValueConnector'; -import ArtistStatusFilterBuilderRowValue from './ArtistStatusFilterBuilderRowValue'; +import QualityProfileFilterBuilderRowValue from './QualityProfileFilterBuilderRowValue'; import TagFilterBuilderRowValueConnector from './TagFilterBuilderRowValueConnector'; import styles from './FilterBuilderRow.css'; @@ -57,11 +61,17 @@ function getRowValueConnector(selectedFilterBuilderProp) { case filterBuilderValueTypes.DATE: return DateFilterBuilderRowValue; + case filterBuilderValueTypes.HISTORY_EVENT_TYPE: + return HistoryEventTypeFilterBuilderRowValue; + case filterBuilderValueTypes.INDEXER: return IndexerFilterBuilderRowValueConnector; case filterBuilderValueTypes.METADATA_PROFILE: - return MetadataProfileFilterBuilderRowValueConnector; + return MetadataProfileFilterBuilderRowValue; + + case filterBuilderValueTypes.MONITOR_NEW_ITEMS: + return MonitorNewItemsFilterBuilderRowValue; case filterBuilderValueTypes.PROTOCOL: return ProtocolFilterBuilderRowValue; @@ -70,7 +80,10 @@ function getRowValueConnector(selectedFilterBuilderProp) { return QualityFilterBuilderRowValueConnector; case filterBuilderValueTypes.QUALITY_PROFILE: - return QualityProfileFilterBuilderRowValueConnector; + return QualityProfileFilterBuilderRowValue; + + case filterBuilderValueTypes.ARTIST: + return ArtistFilterBuilderRowValue; case filterBuilderValueTypes.ARTIST_STATUS: return ArtistStatusFilterBuilderRowValue; @@ -150,7 +163,7 @@ class FilterBuilderRow extends Component { this.selectedFilterBuilderProp = selectedFilterBuilderProp; onFilterChange(index, filter); - } + }; onFilterChange = ({ name, value }) => { const { @@ -170,7 +183,7 @@ class FilterBuilderRow extends Component { filter[name] = value; onFilterChange(index, filter); - } + }; onAddPress = () => { const { @@ -179,7 +192,7 @@ class FilterBuilderRow extends Component { } = this.props; onAddPress(index); - } + }; onRemovePress = () => { const { @@ -188,7 +201,7 @@ class FilterBuilderRow extends Component { } = this.props; onRemovePress(index); - } + }; // // Render @@ -206,11 +219,13 @@ class FilterBuilderRow extends Component { const selectedFilterBuilderProp = this.selectedFilterBuilderProp; const keyOptions = filterBuilderProps.map((availablePropFilter) => { + const { name, label } = availablePropFilter; + return { - key: availablePropFilter.name, - value: availablePropFilter.label + key: name, + value: typeof label === 'function' ? label() : label }; - }); + }).sort(sortByProp('value')); const ValueComponent = getRowValueConnector(selectedFilterBuilderProp); diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.js b/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.js index ef6084c02..68fa5c557 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.js @@ -1,10 +1,10 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import TagInput from 'Components/Form/TagInput'; +import { filterBuilderTypes, filterBuilderValueTypes, kinds } from 'Helpers/Props'; +import tagShape from 'Helpers/Props/Shapes/tagShape'; import convertToBytes from 'Utilities/Number/convertToBytes'; import formatBytes from 'Utilities/Number/formatBytes'; -import { kinds, filterBuilderTypes, filterBuilderValueTypes } from 'Helpers/Props'; -import tagShape from 'Helpers/Props/Shapes/tagShape'; -import TagInput from 'Components/Form/TagInput'; import FilterBuilderRowValueTag from './FilterBuilderRowValueTag'; export const NAME = 'value'; @@ -84,7 +84,7 @@ class FilterBuilderRowValue extends Component { name: NAME, value: [...filterValue, value] }); - } + }; onTagDelete = ({ index }) => { const { @@ -98,7 +98,7 @@ class FilterBuilderRowValue extends Component { name: NAME, value }); - } + }; // // Render @@ -135,7 +135,7 @@ class FilterBuilderRowValue extends Component { tagList={tagList} allowNew={!tagList.length} kind={kinds.DEFAULT} - delimiters={[9, 13]} + delimiters={['Tab', 'Enter']} maxSuggestionsLength={100} minQueryLength={0} tagComponent={FilterBuilderRowValueTag} diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueConnector.js b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueConnector.js index c8813284e..d1419327a 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueConnector.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueConnector.js @@ -1,9 +1,9 @@ import _ from 'lodash'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import sortByName from 'Utilities/Array/sortByName'; import { filterBuilderTypes } from 'Helpers/Props'; import * as filterTypes from 'Helpers/Props/filterTypes'; +import sortByProp from 'Utilities/Array/sortByProp'; import FilterBuilderRowValue from './FilterBuilderRowValue'; function createTagListSelector() { @@ -16,7 +16,7 @@ function createTagListSelector() { (selectedFilterBuilderProp.type === filterBuilderTypes.NUMBER || selectedFilterBuilderProp.type === filterBuilderTypes.STRING) && filterType !== filterTypes.EQUAL && - filterType !== filterBuilderTypes.NOT_EQUAL || + filterType !== filterTypes.NOT_EQUAL || !selectedFilterBuilderProp.optionsSelector ) { return []; @@ -38,7 +38,7 @@ function createTagListSelector() { } return acc; - }, []).sort(sortByName); + }, []).sort(sortByProp('name')); } return _.uniqBy(items, 'id'); diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueProps.ts b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueProps.ts new file mode 100644 index 000000000..5bf9e5785 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueProps.ts @@ -0,0 +1,16 @@ +import { FilterBuilderProp } from 'App/State/AppState'; + +interface FilterBuilderRowOnChangeProps { + name: string; + value: unknown[]; +} + +interface FilterBuilderRowValueProps { + filterType?: string; + filterValue: string | number | object | string[] | number[] | object[]; + selectedFilterBuilderProp: FilterBuilderProp; + sectionItem: unknown[]; + onChange: (payload: FilterBuilderRowOnChangeProps) => void; +} + +export default FilterBuilderRowValueProps; diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css index 9bf027af9..807f383dd 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css @@ -1,4 +1,6 @@ .tag { + display: flex; + &.isLastTag { .or { display: none; @@ -15,5 +17,6 @@ .or { margin: 0 3px; - color: $themeDarkColor; + color: var(--themeDarkColor); + line-height: 31px; } diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css.d.ts b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css.d.ts new file mode 100644 index 000000000..80bcf1464 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'isLastTag': string; + 'label': string; + 'or': string; + 'tag': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.js b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.js index 573e05759..6b5846594 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.js @@ -1,12 +1,12 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { kinds } from 'Helpers/Props'; import TagInputTag from 'Components/Form/TagInputTag'; +import { kinds } from 'Helpers/Props'; import styles from './FilterBuilderRowValueTag.css'; function FilterBuilderRowValueTag(props) { return ( - { - !props.isLastTag && - + props.isLastTag ? + null : +
or - +
} -
+
); } diff --git a/frontend/src/Components/Filter/Builder/HistoryEventTypeFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/HistoryEventTypeFilterBuilderRowValue.tsx new file mode 100644 index 000000000..1b3b369be --- /dev/null +++ b/frontend/src/Components/Filter/Builder/HistoryEventTypeFilterBuilderRowValue.tsx @@ -0,0 +1,69 @@ +import React from 'react'; +import translate from 'Utilities/String/translate'; +import FilterBuilderRowValue from './FilterBuilderRowValue'; +import FilterBuilderRowValueProps from './FilterBuilderRowValueProps'; + +const EVENT_TYPE_OPTIONS = [ + { + id: 1, + get name() { + return translate('Grabbed'); + }, + }, + { + id: 3, + get name() { + return translate('TrackImported'); + }, + }, + { + id: 4, + get name() { + return translate('DownloadFailed'); + }, + }, + { + id: 7, + get name() { + return translate('ImportCompleteFailed'); + }, + }, + { + id: 8, + get name() { + return translate('DownloadImported'); + }, + }, + { + id: 5, + get name() { + return translate('Deleted'); + }, + }, + { + id: 6, + get name() { + return translate('Renamed'); + }, + }, + { + id: 9, + get name() { + return translate('Retagged'); + }, + }, + { + id: 7, + get name() { + return translate('Ignored'); + }, + }, +]; + +function HistoryEventTypeFilterBuilderRowValue( + props: FilterBuilderRowValueProps +) { + return ; +} + +export default HistoryEventTypeFilterBuilderRowValue; diff --git a/frontend/src/Components/Filter/Builder/IndexerFilterBuilderRowValueConnector.js b/frontend/src/Components/Filter/Builder/IndexerFilterBuilderRowValueConnector.js index 0132ae641..e834b79a3 100644 --- a/frontend/src/Components/Filter/Builder/IndexerFilterBuilderRowValueConnector.js +++ b/frontend/src/Components/Filter/Builder/IndexerFilterBuilderRowValueConnector.js @@ -47,7 +47,7 @@ class IndexerFilterBuilderRowValueConnector extends Component { if (!this.props.isPopulated) { this.props.dispatchFetchIndexers(); } - } + }; // // Render diff --git a/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValue.tsx new file mode 100644 index 000000000..bbd9a8274 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValue.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterBuilderRowValueProps from 'Components/Filter/Builder/FilterBuilderRowValueProps'; +import sortByProp from 'Utilities/Array/sortByProp'; +import FilterBuilderRowValue from './FilterBuilderRowValue'; + +function createMetadataProfilesSelector() { + return createSelector( + (state: AppState) => state.settings.metadataProfiles.items, + (metadataProfiles) => { + return metadataProfiles; + } + ); +} + +function MetadataProfileFilterBuilderRowValue( + props: FilterBuilderRowValueProps +) { + const metadataProfiles = useSelector(createMetadataProfilesSelector()); + + const tagList = metadataProfiles + .map(({ id, name }) => ({ id, name })) + .sort(sortByProp('name')); + + return ; +} + +export default MetadataProfileFilterBuilderRowValue; diff --git a/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValueConnector.js b/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValueConnector.js deleted file mode 100644 index 89d6c06b3..000000000 --- a/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValueConnector.js +++ /dev/null @@ -1,28 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import FilterBuilderRowValue from './FilterBuilderRowValue'; - -function createMapStateToProps() { - return createSelector( - (state) => state.settings.metadataProfiles, - (metadataProfiles) => { - const tagList = metadataProfiles.items.map((metadataProfile) => { - const { - id, - name - } = metadataProfile; - - return { - id, - name - }; - }); - - return { - tagList - }; - } - ); -} - -export default connect(createMapStateToProps)(FilterBuilderRowValue); diff --git a/frontend/src/Components/Filter/Builder/MonitorNewItemsFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/MonitorNewItemsFilterBuilderRowValue.tsx new file mode 100644 index 000000000..812d8c5b1 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/MonitorNewItemsFilterBuilderRowValue.tsx @@ -0,0 +1,33 @@ +import React from 'react'; +import FilterBuilderRowValueProps from 'Components/Filter/Builder/FilterBuilderRowValueProps'; +import translate from 'Utilities/String/translate'; +import FilterBuilderRowValue from './FilterBuilderRowValue'; + +const options = [ + { + id: 'all', + get name() { + return translate('AllAlbums'); + }, + }, + { + id: 'new', + get name() { + return translate('New'); + }, + }, + { + id: 'none', + get name() { + return translate('None'); + }, + }, +]; + +function MonitorNewItemsFilterBuilderRowValue( + props: FilterBuilderRowValueProps +) { + return ; +} + +export default MonitorNewItemsFilterBuilderRowValue; diff --git a/frontend/src/Components/Filter/Builder/QualityFilterBuilderRowValueConnector.js b/frontend/src/Components/Filter/Builder/QualityFilterBuilderRowValueConnector.js index d0443bf19..fd6e466d4 100644 --- a/frontend/src/Components/Filter/Builder/QualityFilterBuilderRowValueConnector.js +++ b/frontend/src/Components/Filter/Builder/QualityFilterBuilderRowValueConnector.js @@ -2,9 +2,9 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import getQualities from 'Utilities/Quality/getQualities'; import tagShape from 'Helpers/Props/Shapes/tagShape'; import { fetchQualityProfileSchema } from 'Store/Actions/settingsActions'; +import getQualities from 'Utilities/Quality/getQualities'; import FilterBuilderRowValue from './FilterBuilderRowValue'; function createMapStateToProps() { @@ -43,7 +43,7 @@ class QualityFilterBuilderRowValueConnector extends Component { if (!this.props.isPopulated) { this.props.dispatchFetchQualityProfileSchema(); } - } + }; // // Render diff --git a/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValue.tsx new file mode 100644 index 000000000..50036cb90 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValue.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import FilterBuilderRowValueProps from 'Components/Filter/Builder/FilterBuilderRowValueProps'; +import sortByProp from 'Utilities/Array/sortByProp'; +import FilterBuilderRowValue from './FilterBuilderRowValue'; + +function createQualityProfilesSelector() { + return createSelector( + (state: AppState) => state.settings.qualityProfiles.items, + (qualityProfiles) => { + return qualityProfiles; + } + ); +} + +function QualityProfileFilterBuilderRowValue( + props: FilterBuilderRowValueProps +) { + const qualityProfiles = useSelector(createQualityProfilesSelector()); + + const tagList = qualityProfiles + .map(({ id, name }) => ({ id, name })) + .sort(sortByProp('name')); + + return ; +} + +export default QualityProfileFilterBuilderRowValue; diff --git a/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValueConnector.js b/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValueConnector.js deleted file mode 100644 index 4a8b82283..000000000 --- a/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValueConnector.js +++ /dev/null @@ -1,28 +0,0 @@ -import { connect } from 'react-redux'; -import { createSelector } from 'reselect'; -import FilterBuilderRowValue from './FilterBuilderRowValue'; - -function createMapStateToProps() { - return createSelector( - (state) => state.settings.qualityProfiles, - (qualityProfiles) => { - const tagList = qualityProfiles.items.map((qualityProfile) => { - const { - id, - name - } = qualityProfile; - - return { - id, - name - }; - }); - - return { - tagList - }; - } - ); -} - -export default connect(createMapStateToProps)(FilterBuilderRowValue); diff --git a/frontend/src/Components/Filter/CustomFilters/CustomFilter.css b/frontend/src/Components/Filter/CustomFilters/CustomFilter.css index 7acb69dc7..e2b8c72bf 100644 --- a/frontend/src/Components/Filter/CustomFilters/CustomFilter.css +++ b/frontend/src/Components/Filter/CustomFilters/CustomFilter.css @@ -4,7 +4,7 @@ padding: 5px; &:hover { - background-color: $tableRowHoverBackgroundColor; + background-color: var(--tableRowHoverBackgroundColor); } } diff --git a/frontend/src/Components/Filter/CustomFilters/CustomFilter.css.d.ts b/frontend/src/Components/Filter/CustomFilters/CustomFilter.css.d.ts new file mode 100644 index 000000000..af5bfa967 --- /dev/null +++ b/frontend/src/Components/Filter/CustomFilters/CustomFilter.css.d.ts @@ -0,0 +1,9 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'actions': string; + 'customFilter': string; + 'label': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Filter/CustomFilters/CustomFilter.js b/frontend/src/Components/Filter/CustomFilters/CustomFilter.js index c9c326d78..9f378d5a2 100644 --- a/frontend/src/Components/Filter/CustomFilters/CustomFilter.js +++ b/frontend/src/Components/Filter/CustomFilters/CustomFilter.js @@ -1,8 +1,9 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons } from 'Helpers/Props'; import IconButton from 'Components/Link/IconButton'; import SpinnerIconButton from 'Components/Link/SpinnerIconButton'; +import { icons } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; import styles from './CustomFilter.css'; class CustomFilter extends Component { @@ -36,8 +37,8 @@ class CustomFilter extends Component { dispatchSetFilter } = this.props; - // Assume that delete and then unmounting means the delete was successful. - // Moving this check to a ancestor would be more accurate, but would have + // Assume that delete and then unmounting means the deletion was successful. + // Moving this check to an ancestor would be more accurate, but would have // more boilerplate. if (this.state.isDeleting && id === selectedFilterKey) { dispatchSetFilter({ selectedFilterKey: 'all' }); @@ -54,7 +55,7 @@ class CustomFilter extends Component { } = this.props; onEditPress(id); - } + }; onRemovePress = () => { const { @@ -66,7 +67,7 @@ class CustomFilter extends Component { dispatchDeleteCustomFilter({ id }); }); - } + }; // // Render @@ -89,7 +90,7 @@ class CustomFilter extends Component { /> - Custom Filters + {translate('CustomFilters')} { - customFilters.map((customFilter) => { - return ( - - ); - }) + customFilters + .sort((a, b) => sortByProp(a, b, 'label')) + .map((customFilter) => { + return ( + + ); + }) }
@@ -58,7 +62,7 @@ function CustomFiltersModalContent(props) { diff --git a/frontend/src/Components/Filter/FilterModal.js b/frontend/src/Components/Filter/FilterModal.js index 729f380e7..d52362d7b 100644 --- a/frontend/src/Components/Filter/FilterModal.js +++ b/frontend/src/Components/Filter/FilterModal.js @@ -25,14 +25,14 @@ class FilterModal extends Component { this.setState({ filterBuilder: true }); - } + }; onEditCustomFilter = (id) => { this.setState({ filterBuilder: true, id }); - } + }; onCancelPress = () => { if (this.state.filterBuilder) { @@ -43,7 +43,7 @@ class FilterModal extends Component { } else { this.onModalClose(); } - } + }; onModalClose = () => { this.setState({ @@ -52,7 +52,7 @@ class FilterModal extends Component { }, () => { this.props.onModalClose(); }); - } + }; // // Render diff --git a/frontend/src/Components/Form/AlbumReleaseSelectInputConnector.js b/frontend/src/Components/Form/AlbumReleaseSelectInputConnector.js index b79c0db1d..4433fac6e 100644 --- a/frontend/src/Components/Form/AlbumReleaseSelectInputConnector.js +++ b/frontend/src/Components/Form/AlbumReleaseSelectInputConnector.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; +import shortenList from 'Utilities/String/shortenList'; import titleCase from 'Utilities/String/titleCase'; import SelectInput from './SelectInput'; @@ -12,13 +13,23 @@ function createMapStateToProps() { (albumReleases) => { const values = _.map(albumReleases.value, (albumRelease) => { + const { + foreignReleaseId, + title, + disambiguation, + mediumCount, + trackCount, + country, + format + } = albumRelease; + return { - key: albumRelease.foreignReleaseId, - value: `${albumRelease.title}` + - `${albumRelease.disambiguation ? ' (' : ''}${titleCase(albumRelease.disambiguation)}${albumRelease.disambiguation ? ')' : ''}` + - `, ${albumRelease.mediumCount} med, ${albumRelease.trackCount} tracks` + - `${albumRelease.country.length > 0 ? ', ' : ''}${albumRelease.country}` + - `${albumRelease.format ? ', [' : ''}${albumRelease.format}${albumRelease.format ? ']' : ''}` + key: foreignReleaseId, + value: `${title}` + + `${disambiguation ? ' (' : ''}${titleCase(disambiguation)}${disambiguation ? ')' : ''}` + + `, ${mediumCount} med, ${trackCount} tracks` + + `${country && country.length > 0 ? `, ${shortenList(country)}` : ''}` + + `${format ? `, [${format}]` : ''}` }; }); @@ -48,7 +59,7 @@ class AlbumReleaseSelectInputConnector extends Component { _.find(updatedReleases, { foreignReleaseId: value }).monitored = true; this.props.onChange({ name, value: updatedReleases }); - } + }; render() { diff --git a/frontend/src/Components/Form/ArtistTagInput.tsx b/frontend/src/Components/Form/ArtistTagInput.tsx new file mode 100644 index 000000000..3edb46ec4 --- /dev/null +++ b/frontend/src/Components/Form/ArtistTagInput.tsx @@ -0,0 +1,53 @@ +import React, { useCallback } from 'react'; +import TagInputConnector from './TagInputConnector'; + +interface ArtistTagInputProps { + name: string; + value: number | number[]; + onChange: ({ + name, + value, + }: { + name: string; + value: number | number[]; + }) => void; +} + +export default function ArtistTagInput(props: ArtistTagInputProps) { + const { value, onChange, ...otherProps } = props; + const isArray = Array.isArray(value); + + const handleChange = useCallback( + ({ name, value: newValue }: { name: string; value: number[] }) => { + if (isArray) { + onChange({ name, value: newValue }); + } else { + onChange({ + name, + value: newValue.length ? newValue[newValue.length - 1] : 0, + }); + } + }, + [isArray, onChange] + ); + + let finalValue: number[] = []; + + if (isArray) { + finalValue = value; + } else if (value === 0) { + finalValue = []; + } else { + finalValue = [value]; + } + + return ( + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore 2786 'TagInputConnector' isn't typed yet + + ); +} diff --git a/frontend/src/Components/Form/AutoCompleteInput.js b/frontend/src/Components/Form/AutoCompleteInput.js index e19700d08..d35969c4c 100644 --- a/frontend/src/Components/Form/AutoCompleteInput.js +++ b/frontend/src/Components/Form/AutoCompleteInput.js @@ -1,6 +1,6 @@ +import jdu from 'jdu'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import jdu from 'jdu'; import AutoSuggestInput from './AutoSuggestInput'; class AutoCompleteInput extends Component { @@ -35,11 +35,11 @@ class AutoCompleteInput extends Component { name: this.props.name, value: newValue }); - } + }; onInputBlur = () => { this.setState({ suggestions: [] }); - } + }; onSuggestionsFetchRequested = ({ value }) => { const { values } = this.props; @@ -50,11 +50,11 @@ class AutoCompleteInput extends Component { }); this.setState({ suggestions: filteredValues }); - } + }; onSuggestionsClearRequested = () => { this.setState({ suggestions: [] }); - } + }; // // Render diff --git a/frontend/src/Components/Form/AutoSuggestInput.css b/frontend/src/Components/Form/AutoSuggestInput.css index 0f3279cb9..7dc416960 100644 --- a/frontend/src/Components/Form/AutoSuggestInput.css +++ b/frontend/src/Components/Form/AutoSuggestInput.css @@ -27,10 +27,10 @@ overflow-y: auto; max-height: 200px; width: 100%; - border: 1px solid $inputBorderColor; + border: 1px solid var(--inputBorderColor); border-radius: 4px; - background-color: $white; - box-shadow: inset 0 1px 1px $inputBoxShadowColor; + background-color: var(--inputBackgroundColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor); } } @@ -46,5 +46,5 @@ } .suggestionHighlighted { - background-color: $menuItemHoverBackgroundColor; + background-color: var(--menuItemHoverBackgroundColor); } diff --git a/frontend/src/Components/Form/AutoSuggestInput.css.d.ts b/frontend/src/Components/Form/AutoSuggestInput.css.d.ts new file mode 100644 index 000000000..2b8f51924 --- /dev/null +++ b/frontend/src/Components/Form/AutoSuggestInput.css.d.ts @@ -0,0 +1,15 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'hasWarning': string; + 'input': string; + 'inputContainer': string; + 'suggestion': string; + 'suggestionHighlighted': string; + 'suggestionsContainer': string; + 'suggestionsContainerOpen': string; + 'suggestionsList': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/AutoSuggestInput.js b/frontend/src/Components/Form/AutoSuggestInput.js index dd5833ee0..34ec7530b 100644 --- a/frontend/src/Components/Form/AutoSuggestInput.js +++ b/frontend/src/Components/Form/AutoSuggestInput.js @@ -1,8 +1,8 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import Autosuggest from 'react-autosuggest'; import { Manager, Popper, Reference } from 'react-popper'; -import classNames from 'classnames'; import Portal from 'Components/Portal'; import styles from './AutoSuggestInput.css'; @@ -49,7 +49,7 @@ class AutoSuggestInput extends Component { }} ); - } + }; renderSuggestionsContainer = ({ containerProps, children }) => { return ( @@ -90,7 +90,7 @@ class AutoSuggestInput extends Component { ); - } + }; // // Listeners @@ -113,14 +113,14 @@ class AutoSuggestInput extends Component { data.styles.width = width; return data; - } + }; onInputChange = (event, { newValue }) => { this.props.onChange({ name: this.props.name, value: newValue }); - } + }; onInputKeyDown = (event) => { const { @@ -144,7 +144,7 @@ class AutoSuggestInput extends Component { }); } } - } + }; // // Render diff --git a/frontend/src/Components/Form/CaptchaInput.css.d.ts b/frontend/src/Components/Form/CaptchaInput.css.d.ts new file mode 100644 index 000000000..b6844144e --- /dev/null +++ b/frontend/src/Components/Form/CaptchaInput.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'captchaInputWrapper': string; + 'hasButton': string; + 'hasError': string; + 'hasWarning': string; + 'input': string; + 'recaptchaWrapper': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/CaptchaInput.js b/frontend/src/Components/Form/CaptchaInput.js index e1a5df458..b422198b5 100644 --- a/frontend/src/Components/Form/CaptchaInput.js +++ b/frontend/src/Components/Form/CaptchaInput.js @@ -1,9 +1,9 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; import ReCAPTCHA from 'react-google-recaptcha'; -import classNames from 'classnames'; -import { icons } from 'Helpers/Props'; import Icon from 'Components/Icon'; +import { icons } from 'Helpers/Props'; import FormInputButton from './FormInputButton'; import TextInput from './TextInput'; import styles from './CaptchaInput.css'; diff --git a/frontend/src/Components/Form/CaptchaInputConnector.js b/frontend/src/Components/Form/CaptchaInputConnector.js index 17b875c88..ad83bf02f 100644 --- a/frontend/src/Components/Form/CaptchaInputConnector.js +++ b/frontend/src/Components/Form/CaptchaInputConnector.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { refreshCaptcha, getCaptchaCookie, resetCaptcha } from 'Store/Actions/captchaActions'; +import { getCaptchaCookie, refreshCaptcha, resetCaptcha } from 'Store/Actions/captchaActions'; import CaptchaInput from './CaptchaInput'; function createMapStateToProps() { @@ -39,7 +39,7 @@ class CaptchaInputConnector extends Component { componentWillUnmount = () => { this.props.resetCaptcha(); - } + }; // // Listeners @@ -51,7 +51,7 @@ class CaptchaInputConnector extends Component { } = this.props; this.props.refreshCaptcha({ provider, providerData }); - } + }; onCaptchaChange = (captchaResponse) => { // If the captcha has expired `captchaResponse` will be null. @@ -68,7 +68,7 @@ class CaptchaInputConnector extends Component { } = this.props; this.props.getCaptchaCookie({ provider, providerData, captchaResponse }); - } + }; // // Render diff --git a/frontend/src/Components/Form/CheckInput.css b/frontend/src/Components/Form/CheckInput.css index e0b05eca3..cf9f27f91 100644 --- a/frontend/src/Components/Form/CheckInput.css +++ b/frontend/src/Components/Form/CheckInput.css @@ -32,21 +32,21 @@ height: 20px; border: 1px solid #ccc; border-radius: 2px; - background-color: $white; - color: $white; + background-color: var(--white); + color: var(--white); text-align: center; line-height: 20px; } .checkbox:focus + .input { outline: 0; - border-color: $inputFocusBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; + border-color: var(--inputFocusBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); } .dangerIsChecked { - border-color: $dangerColor; - background-color: $dangerColor; + border-color: var(--dangerColor); + background-color: var(--dangerColor); &.isDisabled { opacity: 0.7; @@ -54,8 +54,8 @@ } .primaryIsChecked { - border-color: $primaryColor; - background-color: $primaryColor; + border-color: var(--lidarrGreen); + background-color: var(--lidarrGreen); &.isDisabled { opacity: 0.7; @@ -63,8 +63,8 @@ } .successIsChecked { - border-color: $successColor; - background-color: $successColor; + border-color: var(--successColor); + background-color: var(--successColor); &.isDisabled { opacity: 0.7; @@ -72,8 +72,8 @@ } .warningIsChecked { - border-color: $warningColor; - background-color: $warningColor; + border-color: var(--warningColor); + background-color: var(--warningColor); &.isDisabled { opacity: 0.7; @@ -82,15 +82,15 @@ .isNotChecked { &.isDisabled { - border-color: $disabledCheckInputColor; - background-color: $disabledCheckInputColor; + border-color: var(--disabledCheckInputColor); + background-color: var(--disabledCheckInputColor); opacity: 0.7; } } .isIndeterminate { - border-color: $gray; - background-color: $gray; + border-color: var(--gray); + background-color: var(--gray); } .helpText { diff --git a/frontend/src/Components/Form/CheckInput.css.d.ts b/frontend/src/Components/Form/CheckInput.css.d.ts new file mode 100644 index 000000000..bba6b63bb --- /dev/null +++ b/frontend/src/Components/Form/CheckInput.css.d.ts @@ -0,0 +1,18 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'checkbox': string; + 'container': string; + 'dangerIsChecked': string; + 'helpText': string; + 'input': string; + 'isDisabled': string; + 'isIndeterminate': string; + 'isNotChecked': string; + 'label': string; + 'primaryIsChecked': string; + 'successIsChecked': string; + 'warningIsChecked': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/CheckInput.js b/frontend/src/Components/Form/CheckInput.js index 134290111..26d915880 100644 --- a/frontend/src/Components/Form/CheckInput.js +++ b/frontend/src/Components/Form/CheckInput.js @@ -1,8 +1,8 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import classNames from 'classnames'; -import { icons, kinds } from 'Helpers/Props'; import Icon from 'Components/Icon'; +import { icons, kinds } from 'Helpers/Props'; import FormInputHelpText from './FormInputHelpText'; import styles from './CheckInput.css'; @@ -59,14 +59,14 @@ class CheckInput extends Component { shiftKey }); } - } + }; // // Listeners setRef = (ref) => { this._checkbox = ref; - } + }; onClick = (event) => { if (this.props.isDisabled) { @@ -78,14 +78,14 @@ class CheckInput extends Component { event.preventDefault(); this.toggleChecked(checked, shiftKey); - } + }; onChange = (event) => { const checked = event.target.checked; const shiftKey = event.nativeEvent.shiftKey; this.toggleChecked(checked, shiftKey); - } + }; // // Render diff --git a/frontend/src/Components/Form/DeviceInput.css.d.ts b/frontend/src/Components/Form/DeviceInput.css.d.ts new file mode 100644 index 000000000..e44e3fce0 --- /dev/null +++ b/frontend/src/Components/Form/DeviceInput.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'deviceInputWrapper': string; + 'input': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/DeviceInput.js b/frontend/src/Components/Form/DeviceInput.js index f77c7cf29..55c239cb8 100644 --- a/frontend/src/Components/Form/DeviceInput.js +++ b/frontend/src/Components/Form/DeviceInput.js @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import Icon from 'Components/Icon'; import { icons } from 'Helpers/Props'; import tagShape from 'Helpers/Props/Shapes/tagShape'; -import Icon from 'Components/Icon'; import FormInputButton from './FormInputButton'; import TagInput from './TagInput'; import styles from './DeviceInput.css'; @@ -23,7 +23,7 @@ class DeviceInput extends Component { name, value: [...value, deviceId] }); - } + }; onTagDelete = ({ index }) => { const { @@ -39,7 +39,7 @@ class DeviceInput extends Component { name, value: newValue }); - } + }; // // Render diff --git a/frontend/src/Components/Form/DeviceInputConnector.js b/frontend/src/Components/Form/DeviceInputConnector.js index 43e313826..2af9a79f6 100644 --- a/frontend/src/Components/Form/DeviceInputConnector.js +++ b/frontend/src/Components/Form/DeviceInputConnector.js @@ -2,13 +2,13 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { fetchOptions, clearOptions } from 'Store/Actions/providerOptionActions'; +import { clearOptions, defaultState, fetchOptions } from 'Store/Actions/providerOptionActions'; import DeviceInput from './DeviceInput'; function createMapStateToProps() { return createSelector( (state, { value }) => value, - (state) => state.providerOptions, + (state) => state.providerOptions.devices || defaultState, (value, devices) => { return { @@ -48,11 +48,11 @@ class DeviceInputConnector extends Component { componentDidMount = () => { this._populate(); - } + }; componentWillUnmount = () => { - this.props.dispatchClearOptions(); - } + this.props.dispatchClearOptions({ section: 'devices' }); + }; // // Control @@ -65,6 +65,7 @@ class DeviceInputConnector extends Component { } = this.props; dispatchFetchOptions({ + section: 'devices', action: 'getDevices', provider, providerData @@ -76,7 +77,7 @@ class DeviceInputConnector extends Component { onRefreshPress = () => { this._populate(); - } + }; // // Render diff --git a/frontend/src/Components/Form/DownloadClientSelectInputConnector.js b/frontend/src/Components/Form/DownloadClientSelectInputConnector.js new file mode 100644 index 000000000..c21f0ded6 --- /dev/null +++ b/frontend/src/Components/Form/DownloadClientSelectInputConnector.js @@ -0,0 +1,102 @@ +import _ from 'lodash'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; +import { fetchDownloadClients } from 'Store/Actions/settingsActions'; +import sortByProp from 'Utilities/Array/sortByProp'; +import translate from 'Utilities/String/translate'; +import EnhancedSelectInput from './EnhancedSelectInput'; + +function createMapStateToProps() { + return createSelector( + (state) => state.settings.downloadClients, + (state, { includeAny }) => includeAny, + (state, { protocol }) => protocol, + (downloadClients, includeAny, protocolFilter) => { + const { + isFetching, + isPopulated, + error, + items + } = downloadClients; + + const filteredItems = items.filter((item) => item.protocol === protocolFilter); + + const values = _.map(filteredItems.sort(sortByProp('name')), (downloadClient) => { + return { + key: downloadClient.id, + value: downloadClient.name, + hint: `(${downloadClient.id})` + }; + }); + + if (includeAny) { + values.unshift({ + key: 0, + value: `(${translate('Any')})` + }); + } + + return { + isFetching, + isPopulated, + error, + values + }; + } + ); +} + +const mapDispatchToProps = { + dispatchFetchDownloadClients: fetchDownloadClients +}; + +class DownloadClientSelectInputConnector extends Component { + + // + // Lifecycle + + componentDidMount() { + if (!this.props.isPopulated) { + this.props.dispatchFetchDownloadClients(); + } + } + + // + // Listeners + + onChange = ({ name, value }) => { + this.props.onChange({ name, value: parseInt(value) }); + }; + + // + // Render + + render() { + return ( + + ); + } +} + +DownloadClientSelectInputConnector.propTypes = { + isFetching: PropTypes.bool.isRequired, + isPopulated: PropTypes.bool.isRequired, + name: PropTypes.string.isRequired, + value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, + values: PropTypes.arrayOf(PropTypes.object).isRequired, + includeAny: PropTypes.bool.isRequired, + onChange: PropTypes.func.isRequired, + dispatchFetchDownloadClients: PropTypes.func.isRequired +}; + +DownloadClientSelectInputConnector.defaultProps = { + includeAny: false, + protocol: 'torrent' +}; + +export default connect(createMapStateToProps, mapDispatchToProps)(DownloadClientSelectInputConnector); diff --git a/frontend/src/Components/Form/EnhancedSelectInput.css b/frontend/src/Components/Form/EnhancedSelectInput.css index 774a63517..defefb18e 100644 --- a/frontend/src/Components/Form/EnhancedSelectInput.css +++ b/frontend/src/Components/Form/EnhancedSelectInput.css @@ -1,19 +1,12 @@ .enhancedSelect { composes: input from '~Components/Form/Input.css'; - composes: link from '~Components/Link/Link.css'; - position: relative; display: flex; align-items: center; - padding: 6px 16px; +} + +.editableContainer { width: 100%; - height: 35px; - border: 1px solid $inputBorderColor; - border-radius: 4px; - background-color: $white; - box-shadow: inset 0 1px 1px $inputBoxShadowColor; - color: $black; - cursor: default; } .hasError { @@ -26,17 +19,27 @@ .isDisabled { opacity: 0.7; - cursor: not-allowed; + cursor: not-allowed !important; } .dropdownArrowContainer { margin-left: 12px; } +.dropdownArrowContainerEditable { + position: absolute; + top: 0; + right: 0; + padding-right: 17px; + width: 30%; + height: 35px; + text-align: right; +} + .dropdownArrowContainerDisabled { composes: dropdownArrowContainer; - color: $disabledInputColor; + color: var(--disabledInputColor); } .optionsContainer { @@ -47,15 +50,16 @@ .options { composes: scroller from '~Components/Scroller/Scroller.css'; - border: 1px solid $inputBorderColor; + border: 1px solid var(--inputBorderColor); border-radius: 4px; - background-color: $white; + background-color: var(--inputBackgroundColor); } .optionsModal { display: flex; justify-content: center; max-width: 90%; + max-height: 100%; width: 350px !important; height: auto !important; } @@ -72,7 +76,30 @@ .optionsModalScroller { composes: scroller from '~Components/Scroller/Scroller.css'; - border: 1px solid $inputBorderColor; + border: 1px solid var(--inputBorderColor); border-radius: 4px; - background-color: $white; + background-color: var(--inputBackgroundColor); +} + +.loading { + display: inline-block; + margin: 5px -5px 5px 0; +} + +.mobileCloseButtonContainer { + display: flex; + justify-content: flex-end; + height: 40px; + border-bottom: 1px solid var(--borderColor); +} + +.mobileCloseButton { + width: 40px; + height: 40px; + text-align: center; + line-height: 40px; + + &:hover { + color: var(--modalCloseButtonHoverColor); + } } diff --git a/frontend/src/Components/Form/EnhancedSelectInput.css.d.ts b/frontend/src/Components/Form/EnhancedSelectInput.css.d.ts new file mode 100644 index 000000000..edcf0079b --- /dev/null +++ b/frontend/src/Components/Form/EnhancedSelectInput.css.d.ts @@ -0,0 +1,22 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'dropdownArrowContainer': string; + 'dropdownArrowContainerDisabled': string; + 'dropdownArrowContainerEditable': string; + 'editableContainer': string; + 'enhancedSelect': string; + 'hasError': string; + 'hasWarning': string; + 'isDisabled': string; + 'loading': string; + 'mobileCloseButton': string; + 'mobileCloseButtonContainer': string; + 'options': string; + 'optionsContainer': string; + 'optionsModal': string; + 'optionsModalBody': string; + 'optionsModalScroller': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/EnhancedSelectInput.js b/frontend/src/Components/Form/EnhancedSelectInput.js index 80ee78e81..8327b9385 100644 --- a/frontend/src/Components/Form/EnhancedSelectInput.js +++ b/frontend/src/Components/Form/EnhancedSelectInput.js @@ -1,23 +1,27 @@ +import classNames from 'classnames'; import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { Manager, Popper, Reference } from 'react-popper'; -import classNames from 'classnames'; -import getUniqueElememtId from 'Utilities/getUniqueElementId'; -import { isMobile as isMobileUtil } from 'Utilities/mobile'; -import * as keyCodes from 'Utilities/Constants/keyCodes'; -import { icons, sizes, scrollDirections } from 'Helpers/Props'; import Icon from 'Components/Icon'; -import Portal from 'Components/Portal'; import Link from 'Components/Link/Link'; +import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import Measure from 'Components/Measure'; import Modal from 'Components/Modal/Modal'; import ModalBody from 'Components/Modal/ModalBody'; +import Portal from 'Components/Portal'; import Scroller from 'Components/Scroller/Scroller'; -import HintedSelectInputSelectedValue from './HintedSelectInputSelectedValue'; +import { icons, scrollDirections, sizes } from 'Helpers/Props'; +import { isMobile as isMobileUtil } from 'Utilities/browser'; +import * as keyCodes from 'Utilities/Constants/keyCodes'; +import getUniqueElememtId from 'Utilities/getUniqueElementId'; import HintedSelectInputOption from './HintedSelectInputOption'; +import HintedSelectInputSelectedValue from './HintedSelectInputSelectedValue'; +import TextInput from './TextInput'; import styles from './EnhancedSelectInput.css'; +const MINIMUM_DISTANCE_FROM_EDGE = 10; + function isArrowKey(keyCode) { return keyCode === keyCodes.UP_ARROW || keyCode === keyCodes.DOWN_ARROW; } @@ -58,11 +62,30 @@ function getSelectedIndex(props) { values } = props; + if (Array.isArray(value)) { + return values.findIndex((v) => { + return value.size && v.key === value[0]; + }); + } + return values.findIndex((v) => { return v.key === value; }); } +function isSelectedItem(index, props) { + const { + value, + values + } = props; + + if (Array.isArray(value)) { + return value.includes(values[index].key); + } + + return values[index].key === value; +} + function getKey(selectedIndex, values) { return values[selectedIndex].key; } @@ -92,10 +115,12 @@ class EnhancedSelectInput extends Component { this._scheduleUpdate(); } - if (prevProps.value !== this.props.value) { - this.setState({ - selectedIndex: getSelectedIndex(this.props) - }); + if (!Array.isArray(this.props.value)) { + if (prevProps.value !== this.props.value || prevProps.values !== this.props.values) { + this.setState({ + selectedIndex: getSelectedIndex(this.props) + }); + } } } @@ -114,27 +139,18 @@ class EnhancedSelectInput extends Component { // Listeners onComputeMaxHeight = (data) => { - const { - top, - bottom - } = data.offsets.reference; - const windowHeight = window.innerHeight; - if ((/^botton/).test(data.placement)) { - data.styles.maxHeight = windowHeight - bottom; - } else { - data.styles.maxHeight = top; - } + data.styles.maxHeight = windowHeight - MINIMUM_DISTANCE_FROM_EDGE; return data; - } + }; onWindowClick = (event) => { const button = document.getElementById(this._buttonId); const options = document.getElementById(this._optionsId); - if (!button || this.state.isMobile) { + if (!button || !event.target.isConnected || this.state.isMobile) { return; } @@ -147,15 +163,25 @@ class EnhancedSelectInput extends Component { this.setState({ isOpen: false }); this._removeListener(); } - } + }; + + onFocus = () => { + if (this.state.isOpen) { + this._removeListener(); + this.setState({ isOpen: false }); + } + }; onBlur = () => { - // Calling setState without this check prevents the click event from being properly handled on Chrome (it is on firefox) - const origIndex = getSelectedIndex(this.props); - if (origIndex !== this.state.selectedIndex) { - this.setState({ selectedIndex: origIndex }); + if (!this.props.isEditable) { + // Calling setState without this check prevents the click event from being properly handled on Chrome (it is on firefox) + const origIndex = getSelectedIndex(this.props); + + if (origIndex !== this.state.selectedIndex) { + this.setState({ selectedIndex: origIndex }); + } } - } + }; onKeyDown = (event) => { const { @@ -177,7 +203,7 @@ class EnhancedSelectInput extends Component { } if ( - selectedIndex == null || + selectedIndex == null || selectedIndex === -1 || getSelectedOption(selectedIndex, values).isDisabled ) { if (keyCode === keyCodes.UP_ARROW) { @@ -222,7 +248,7 @@ class EnhancedSelectInput extends Component { if (!_.isEmpty(newState)) { this.setState(newState); } - } + }; onPress = () => { if (this.state.isOpen) { @@ -231,25 +257,44 @@ class EnhancedSelectInput extends Component { this._addListener(); } + if (!this.state.isOpen && this.props.onOpen) { + this.props.onOpen(); + } + this.setState({ isOpen: !this.state.isOpen }); - } + }; onSelect = (value) => { - this.setState({ isOpen: false }); + if (Array.isArray(this.props.value)) { + let newValue = null; + const index = this.props.value.indexOf(value); + if (index === -1) { + newValue = this.props.values.map((v) => v.key).filter((v) => (v === value) || this.props.value.includes(v)); + } else { + newValue = [...this.props.value]; + newValue.splice(index, 1); + } + this.props.onChange({ + name: this.props.name, + value: newValue + }); + } else { + this.setState({ isOpen: false }); - this.props.onChange({ - name: this.props.name, - value - }); - } + this.props.onChange({ + name: this.props.name, + value + }); + } + }; onMeasure = ({ width }) => { this.setState({ width }); - } + }; onOptionsModalClose = () => { this.setState({ isOpen: false }); - } + }; // // Render @@ -258,13 +303,19 @@ class EnhancedSelectInput extends Component { const { className, disabledClassName, + name, + value, values, isDisabled, + isEditable, + isFetching, hasError, hasWarning, + valueOptions, selectedValueOptions, selectedValueComponent: SelectedValueComponent, - optionComponent: OptionComponent + optionComponent: OptionComponent, + onChange } = this.props; const { @@ -274,7 +325,13 @@ class EnhancedSelectInput extends Component { isMobile } = this.state; + const isMultiSelect = Array.isArray(value); const selectedOption = getSelectedOption(selectedIndex, values); + let selectedValue = value; + + if (!values.length) { + selectedValue = isMultiSelect ? [] : ''; + } return (
@@ -289,37 +346,98 @@ class EnhancedSelectInput extends Component { whitelist={['width']} onMeasure={this.onMeasure} > - - - {selectedOption ? selectedOption.value : null} - + { + isEditable ? +
+ + + { + isFetching ? + : + null + } -
- -
- + { + isFetching ? + null : + + } + +
: + + + {selectedOption ? selectedOption.value : null} + + +
+ + { + isFetching ? + : + null + } + + { + isFetching ? + null : + + } +
+ + }
)} @@ -332,6 +450,10 @@ class EnhancedSelectInput extends Component { order: 851, enabled: true, fn: this.onComputeMaxHeight + }, + preventOverflow: { + enabled: true, + boundariesElement: 'viewport' } }} > @@ -358,11 +480,18 @@ class EnhancedSelectInput extends Component { > { values.map((v, index) => { + const hasParent = v.parentKey !== undefined; + const depth = hasParent ? 1 : 0; + const parentSelected = hasParent && value.includes(v.parentKey); return ( { - isMobile && + isMobile ? +
+ + + +
+ { values.map((v, index) => { + const hasParent = v.parentKey !== undefined; + const depth = hasParent ? 1 : 0; + const parentSelected = hasParent && value.includes(v.parentKey); return ( -
+ : + null }
); @@ -426,14 +575,18 @@ EnhancedSelectInput.propTypes = { className: PropTypes.string, disabledClassName: PropTypes.string, name: PropTypes.string.isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)]).isRequired, values: PropTypes.arrayOf(PropTypes.object).isRequired, - isDisabled: PropTypes.bool, + isDisabled: PropTypes.bool.isRequired, + isFetching: PropTypes.bool.isRequired, + isEditable: PropTypes.bool.isRequired, hasError: PropTypes.bool, hasWarning: PropTypes.bool, + valueOptions: PropTypes.object.isRequired, selectedValueOptions: PropTypes.object.isRequired, selectedValueComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired, optionComponent: PropTypes.elementType, + onOpen: PropTypes.func, onChange: PropTypes.func.isRequired }; @@ -441,6 +594,9 @@ EnhancedSelectInput.defaultProps = { className: styles.enhancedSelect, disabledClassName: styles.isDisabled, isDisabled: false, + isFetching: false, + isEditable: false, + valueOptions: {}, selectedValueOptions: {}, selectedValueComponent: HintedSelectInputSelectedValue, optionComponent: HintedSelectInputOption diff --git a/frontend/src/Components/Form/EnhancedSelectInputConnector.js b/frontend/src/Components/Form/EnhancedSelectInputConnector.js new file mode 100644 index 000000000..f2af4a585 --- /dev/null +++ b/frontend/src/Components/Form/EnhancedSelectInputConnector.js @@ -0,0 +1,159 @@ +import _ from 'lodash'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; +import { clearOptions, defaultState, fetchOptions } from 'Store/Actions/providerOptionActions'; +import EnhancedSelectInput from './EnhancedSelectInput'; + +const importantFieldNames = [ + 'baseUrl', + 'apiPath', + 'apiKey' +]; + +function getProviderDataKey(providerData) { + if (!providerData || !providerData.fields) { + return null; + } + + const fields = providerData.fields + .filter((f) => importantFieldNames.includes(f.name)) + .map((f) => f.value); + + return fields; +} + +function getSelectOptions(items) { + if (!items) { + return []; + } + + return items.map((option) => { + return { + key: option.value, + value: option.name, + hint: option.hint, + parentKey: option.parentValue + }; + }); +} + +function createMapStateToProps() { + return createSelector( + (state, { selectOptionsProviderAction }) => state.providerOptions[selectOptionsProviderAction] || defaultState, + (options) => { + if (options) { + return { + isFetching: options.isFetching, + values: getSelectOptions(options.items) + }; + } + } + ); +} + +const mapDispatchToProps = { + dispatchFetchOptions: fetchOptions, + dispatchClearOptions: clearOptions +}; + +class EnhancedSelectInputConnector extends Component { + + // + // Lifecycle + + constructor(props, context) { + super(props, context); + + this.state = { + refetchRequired: false + }; + } + + componentDidMount = () => { + this._populate(); + }; + + componentDidUpdate = (prevProps) => { + const prevKey = getProviderDataKey(prevProps.providerData); + const nextKey = getProviderDataKey(this.props.providerData); + + if (!_.isEqual(prevKey, nextKey)) { + this.setState({ refetchRequired: true }); + } + }; + + componentWillUnmount = () => { + this._cleanup(); + }; + + // + // Listeners + + onOpen = () => { + if (this.state.refetchRequired) { + this._populate(); + } + }; + + // + // Control + + _populate() { + const { + provider, + providerData, + selectOptionsProviderAction, + dispatchFetchOptions + } = this.props; + + if (selectOptionsProviderAction) { + this.setState({ refetchRequired: false }); + dispatchFetchOptions({ + section: selectOptionsProviderAction, + action: selectOptionsProviderAction, + provider, + providerData + }); + } + } + + _cleanup() { + const { + selectOptionsProviderAction, + dispatchClearOptions + } = this.props; + + if (selectOptionsProviderAction) { + dispatchClearOptions({ section: selectOptionsProviderAction }); + } + } + + // + // Render + + render() { + return ( + + ); + } +} + +EnhancedSelectInputConnector.propTypes = { + provider: PropTypes.string.isRequired, + providerData: PropTypes.object.isRequired, + name: PropTypes.string.isRequired, + value: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])).isRequired, + values: PropTypes.arrayOf(PropTypes.object).isRequired, + selectOptionsProviderAction: PropTypes.string, + onChange: PropTypes.func.isRequired, + isFetching: PropTypes.bool.isRequired, + dispatchFetchOptions: PropTypes.func.isRequired, + dispatchClearOptions: PropTypes.func.isRequired +}; + +export default connect(createMapStateToProps, mapDispatchToProps)(EnhancedSelectInputConnector); diff --git a/frontend/src/Components/Form/EnhancedSelectInputOption.css b/frontend/src/Components/Form/EnhancedSelectInputOption.css index 18440c50d..d7f0e861b 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputOption.css +++ b/frontend/src/Components/Form/EnhancedSelectInputOption.css @@ -7,22 +7,38 @@ cursor: default; &:hover { - background-color: #f8f8f8; + background-color: var(--inputHoverBackgroundColor); + } + + &.isDisabled { + cursor: not-allowed; } } +.optionCheck { + composes: container from '~./CheckInput.css'; + + flex: 0 0 0; +} + +.optionCheckInput { + composes: input from '~./CheckInput.css'; + + margin-top: 0; +} + .isSelected { - background-color: #e2e2e2; + background-color: var(--inputSelectedBackgroundColor); &:hover { - background-color: #e2e2e2; + background-color: var(--inputSelectedBackgroundColor); } &.isMobile { background-color: inherit; .iconContainer { - color: $primaryColor; + color: var(--primaryColor); } } } @@ -37,9 +53,13 @@ .isMobile { height: 50px; - border-bottom: 1px solid $borderColor; + border-bottom: 1px solid var(--borderColor); &:last-child { border: none; } + + &:hover { + background-color: unset; + } } diff --git a/frontend/src/Components/Form/EnhancedSelectInputOption.css.d.ts b/frontend/src/Components/Form/EnhancedSelectInputOption.css.d.ts new file mode 100644 index 000000000..59675cd91 --- /dev/null +++ b/frontend/src/Components/Form/EnhancedSelectInputOption.css.d.ts @@ -0,0 +1,14 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'iconContainer': string; + 'isDisabled': string; + 'isHidden': string; + 'isMobile': string; + 'isSelected': string; + 'option': string; + 'optionCheck': string; + 'optionCheckInput': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/EnhancedSelectInputOption.js b/frontend/src/Components/Form/EnhancedSelectInputOption.js index e1b410c28..b2783dbaa 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputOption.js +++ b/frontend/src/Components/Form/EnhancedSelectInputOption.js @@ -1,9 +1,10 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import classNames from 'classnames'; -import { icons } from 'Helpers/Props'; import Icon from 'Components/Icon'; import Link from 'Components/Link/Link'; +import { icons } from 'Helpers/Props'; +import CheckInput from './CheckInput'; import styles from './EnhancedSelectInputOption.css'; class EnhancedSelectInputOption extends Component { @@ -11,14 +12,20 @@ class EnhancedSelectInputOption extends Component { // // Listeners - onPress = () => { + onPress = (e) => { + e.preventDefault(); + const { id, onSelect } = this.props; onSelect(id); - } + }; + + onCheckPress = () => { + // CheckInput requires a handler. Swallow the change event because onPress will already handle it via event propagation. + }; // // Render @@ -26,9 +33,12 @@ class EnhancedSelectInputOption extends Component { render() { const { className, + id, + depth, isSelected, isDisabled, isHidden, + isMultiSelect, isMobile, children } = this.props; @@ -37,8 +47,8 @@ class EnhancedSelectInputOption extends Component { + + { + depth !== 0 && +
+ } + + { + isMultiSelect && + + } + {children} { @@ -63,10 +91,12 @@ class EnhancedSelectInputOption extends Component { EnhancedSelectInputOption.propTypes = { className: PropTypes.string.isRequired, - id: PropTypes.string.isRequired, + id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + depth: PropTypes.number.isRequired, isSelected: PropTypes.bool.isRequired, isDisabled: PropTypes.bool.isRequired, isHidden: PropTypes.bool.isRequired, + isMultiSelect: PropTypes.bool.isRequired, isMobile: PropTypes.bool.isRequired, children: PropTypes.node.isRequired, onSelect: PropTypes.func.isRequired @@ -74,8 +104,10 @@ EnhancedSelectInputOption.propTypes = { EnhancedSelectInputOption.defaultProps = { className: styles.option, + depth: 0, isDisabled: false, - isHidden: false + isHidden: false, + isMultiSelect: false }; export default EnhancedSelectInputOption; diff --git a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css index 6b8b73af9..908126689 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css +++ b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css @@ -3,5 +3,5 @@ } .isDisabled { - color: $disabledInputColor; + color: var(--disabledInputColor); } diff --git a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css.d.ts b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css.d.ts new file mode 100644 index 000000000..5377239a8 --- /dev/null +++ b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'isDisabled': string; + 'selectedValue': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.js b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.js index c40ee93c1..21ddebb02 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.js +++ b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.js @@ -1,6 +1,6 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; -import classNames from 'classnames'; import styles from './EnhancedSelectInputSelectedValue.css'; function EnhancedSelectInputSelectedValue(props) { diff --git a/frontend/src/Components/Form/Form.css.d.ts b/frontend/src/Components/Form/Form.css.d.ts new file mode 100644 index 000000000..178f2fec1 --- /dev/null +++ b/frontend/src/Components/Form/Form.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'validationFailures': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/Form.js b/frontend/src/Components/Form/Form.js index c2c67eddf..79ad3fe8a 100644 --- a/frontend/src/Components/Form/Form.js +++ b/frontend/src/Components/Form/Form.js @@ -1,10 +1,18 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { kinds } from 'Helpers/Props'; import Alert from 'Components/Alert'; +import { kinds } from 'Helpers/Props'; import styles from './Form.css'; -function Form({ children, validationErrors, validationWarnings, ...otherProps }) { +function Form(props) { + const { + children, + validationErrors, + validationWarnings, + // eslint-disable-next-line no-unused-vars + ...otherProps + } = props; + return (
{ diff --git a/frontend/src/Components/Form/FormGroup.css.d.ts b/frontend/src/Components/Form/FormGroup.css.d.ts new file mode 100644 index 000000000..86145f643 --- /dev/null +++ b/frontend/src/Components/Form/FormGroup.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'extraSmall': string; + 'group': string; + 'large': string; + 'medium': string; + 'small': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/FormGroup.js b/frontend/src/Components/Form/FormGroup.js index d2e04c350..f538daa2f 100644 --- a/frontend/src/Components/Form/FormGroup.js +++ b/frontend/src/Components/Form/FormGroup.js @@ -1,6 +1,6 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; -import classNames from 'classnames'; import { map } from 'Helpers/elementChildren'; import { sizes } from 'Helpers/Props'; import styles from './FormGroup.css'; diff --git a/frontend/src/Components/Form/FormInputButton.css.d.ts b/frontend/src/Components/Form/FormInputButton.css.d.ts new file mode 100644 index 000000000..d469cdfe3 --- /dev/null +++ b/frontend/src/Components/Form/FormInputButton.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'button': string; + 'middleButton': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/FormInputButton.js b/frontend/src/Components/Form/FormInputButton.js index 4b6491663..a7145363a 100644 --- a/frontend/src/Components/Form/FormInputButton.js +++ b/frontend/src/Components/Form/FormInputButton.js @@ -1,6 +1,6 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; -import classNames from 'classnames'; import Button from 'Components/Link/Button'; import SpinnerButton from 'Components/Link/SpinnerButton'; import { kinds } from 'Helpers/Props'; diff --git a/frontend/src/Components/Form/FormInputGroup.css b/frontend/src/Components/Form/FormInputGroup.css index 1a1b104e6..32d91e29b 100644 --- a/frontend/src/Components/Form/FormInputGroup.css +++ b/frontend/src/Components/Form/FormInputGroup.css @@ -40,7 +40,7 @@ } .pendingChangesIcon { - color: $warningColor; + color: var(--warningColor); font-size: 20px; line-height: 35px; } diff --git a/frontend/src/Components/Form/FormInputGroup.css.d.ts b/frontend/src/Components/Form/FormInputGroup.css.d.ts new file mode 100644 index 000000000..267257c44 --- /dev/null +++ b/frontend/src/Components/Form/FormInputGroup.css.d.ts @@ -0,0 +1,14 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'helpLink': string; + 'inputContainer': string; + 'inputGroup': string; + 'inputGroupContainer': string; + 'inputUnit': string; + 'inputUnitNumber': string; + 'pendingChangesContainer': string; + 'pendingChangesIcon': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/FormInputGroup.js b/frontend/src/Components/Form/FormInputGroup.js index 5b5dd2792..3173b493d 100644 --- a/frontend/src/Components/Form/FormInputGroup.js +++ b/frontend/src/Components/Form/FormInputGroup.js @@ -1,28 +1,38 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { inputTypes } from 'Helpers/Props'; import Link from 'Components/Link/Link'; +import { inputTypes, kinds } from 'Helpers/Props'; +import translate from 'Utilities/String/translate'; +import AlbumReleaseSelectInputConnector from './AlbumReleaseSelectInputConnector'; +import ArtistTagInput from './ArtistTagInput'; import AutoCompleteInput from './AutoCompleteInput'; import CaptchaInputConnector from './CaptchaInputConnector'; import CheckInput from './CheckInput'; import DeviceInputConnector from './DeviceInputConnector'; -import PlaylistInputConnector from './PlaylistInputConnector'; +import DownloadClientSelectInputConnector from './DownloadClientSelectInputConnector'; +import EnhancedSelectInput from './EnhancedSelectInput'; +import EnhancedSelectInputConnector from './EnhancedSelectInputConnector'; +import FormInputHelpText from './FormInputHelpText'; +import IndexerFlagsSelectInput from './IndexerFlagsSelectInput'; +import IndexerSelectInputConnector from './IndexerSelectInputConnector'; import KeyValueListInput from './KeyValueListInput'; +import MetadataProfileSelectInputConnector from './MetadataProfileSelectInputConnector'; import MonitorAlbumsSelectInput from './MonitorAlbumsSelectInput'; +import MonitorNewItemsSelectInput from './MonitorNewItemsSelectInput'; import NumberInput from './NumberInput'; import OAuthInputConnector from './OAuthInputConnector'; import PasswordInput from './PasswordInput'; import PathInputConnector from './PathInputConnector'; +import PlaylistInputConnector from './PlaylistInputConnector'; import QualityProfileSelectInputConnector from './QualityProfileSelectInputConnector'; -import MetadataProfileSelectInputConnector from './MetadataProfileSelectInputConnector'; -import AlbumReleaseSelectInputConnector from './AlbumReleaseSelectInputConnector'; import RootFolderSelectInputConnector from './RootFolderSelectInputConnector'; import SeriesTypeSelectInput from './SeriesTypeSelectInput'; -import EnhancedSelectInput from './EnhancedSelectInput'; import TagInputConnector from './TagInputConnector'; -import TextTagInputConnector from './TextTagInputConnector'; +import TagSelectInputConnector from './TagSelectInputConnector'; +import TextArea from './TextArea'; import TextInput from './TextInput'; -import FormInputHelpText from './FormInputHelpText'; +import TextTagInputConnector from './TextTagInputConnector'; +import UMaskInput from './UMaskInput'; import styles from './FormInputGroup.css'; function getComponent(type) { @@ -39,15 +49,18 @@ function getComponent(type) { case inputTypes.DEVICE: return DeviceInputConnector; - case inputTypes.PLAYLIST: - return PlaylistInputConnector; - case inputTypes.KEY_VALUE_LIST: return KeyValueListInput; + case inputTypes.PLAYLIST: + return PlaylistInputConnector; + case inputTypes.MONITOR_ALBUMS_SELECT: return MonitorAlbumsSelectInput; + case inputTypes.MONITOR_NEW_ITEMS_SELECT: + return MonitorNewItemsSelectInput; + case inputTypes.NUMBER: return NumberInput; @@ -69,21 +82,45 @@ function getComponent(type) { case inputTypes.ALBUM_RELEASE_SELECT: return AlbumReleaseSelectInputConnector; + case inputTypes.INDEXER_SELECT: + return IndexerSelectInputConnector; + + case inputTypes.INDEXER_FLAGS_SELECT: + return IndexerFlagsSelectInput; + + case inputTypes.DOWNLOAD_CLIENT_SELECT: + return DownloadClientSelectInputConnector; + case inputTypes.ROOT_FOLDER_SELECT: return RootFolderSelectInputConnector; case inputTypes.SELECT: return EnhancedSelectInput; + case inputTypes.DYNAMIC_SELECT: + return EnhancedSelectInputConnector; + + case inputTypes.ARTIST_TAG: + return ArtistTagInput; + case inputTypes.SERIES_TYPE_SELECT: return SeriesTypeSelectInput; case inputTypes.TAG: return TagInputConnector; + case inputTypes.TEXT_AREA: + return TextArea; + case inputTypes.TEXT_TAG: return TextTagInputConnector; + case inputTypes.UMASK: + return UMaskInput; + + case inputTypes.TAG_SELECT: + return TagSelectInputConnector; + default: return TextInput; } @@ -160,7 +197,7 @@ function FormInputGroup(props) { }
*/} @@ -191,7 +228,7 @@ function FormInputGroup(props) { } { - !checkInput && helpTextWarning && + (!checkInput || helpText) && helpTextWarning && - More Info + {translate('MoreInfo')} } @@ -214,7 +251,7 @@ function FormInputGroup(props) { key={index} text={error.message} link={error.link} - linkTooltip={error.detailedMessage} + tooltip={error.detailedMessage} isError={true} isCheckInput={checkInput} /> @@ -229,7 +266,7 @@ function FormInputGroup(props) { key={index} text={warning.message} link={warning.link} - linkTooltip={warning.detailedMessage} + tooltip={warning.detailedMessage} isWarning={true} isCheckInput={checkInput} /> @@ -244,16 +281,30 @@ FormInputGroup.propTypes = { className: PropTypes.string.isRequired, containerClassName: PropTypes.string.isRequired, inputClassName: PropTypes.string, + name: PropTypes.string.isRequired, + value: PropTypes.any, + values: PropTypes.arrayOf(PropTypes.any), + isDisabled: PropTypes.bool, type: PropTypes.string.isRequired, + kind: PropTypes.oneOf(kinds.all), + min: PropTypes.number, + max: PropTypes.number, unit: PropTypes.string, buttons: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]), helpText: PropTypes.string, helpTexts: PropTypes.arrayOf(PropTypes.string), helpTextWarning: PropTypes.string, helpLink: PropTypes.string, + autoFocus: PropTypes.bool, + includeNoChange: PropTypes.bool, + includeNoChangeDisabled: PropTypes.bool, + includeNone: PropTypes.bool, + selectedValueOptions: PropTypes.object, + indexerFlags: PropTypes.number, pending: PropTypes.bool, errors: PropTypes.arrayOf(PropTypes.object), - warnings: PropTypes.arrayOf(PropTypes.object) + warnings: PropTypes.arrayOf(PropTypes.object), + onChange: PropTypes.func.isRequired }; FormInputGroup.defaultProps = { diff --git a/frontend/src/Components/Form/FormInputHelpText.css b/frontend/src/Components/Form/FormInputHelpText.css index 7fd957233..0a6897d27 100644 --- a/frontend/src/Components/Form/FormInputHelpText.css +++ b/frontend/src/Components/Form/FormInputHelpText.css @@ -1,14 +1,14 @@ .helpText { margin-top: 5px; - color: $helpTextColor; + color: var(--helpTextColor); line-height: 20px; } .isError { - color: $dangerColor; + color: var(--dangerColor); .link { - color: $dangerColor; + color: var(--dangerColor); &:hover { color: #e01313; @@ -17,10 +17,10 @@ } .isWarning { - color: $warningColor; + color: var(--warningColor); .link { - color: $warningColor; + color: var(--warningColor); &:hover { color: #e36c00; @@ -37,3 +37,7 @@ margin-left: 5px; } + +.details { + margin-left: 5px; +} diff --git a/frontend/src/Components/Form/FormInputHelpText.css.d.ts b/frontend/src/Components/Form/FormInputHelpText.css.d.ts new file mode 100644 index 000000000..0e163f134 --- /dev/null +++ b/frontend/src/Components/Form/FormInputHelpText.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'details': string; + 'helpText': string; + 'isCheckInput': string; + 'isError': string; + 'isWarning': string; + 'link': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/FormInputHelpText.js b/frontend/src/Components/Form/FormInputHelpText.js index d9195568b..00024684e 100644 --- a/frontend/src/Components/Form/FormInputHelpText.js +++ b/frontend/src/Components/Form/FormInputHelpText.js @@ -1,9 +1,9 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; -import classNames from 'classnames'; -import { icons } from 'Helpers/Props'; import Icon from 'Components/Icon'; import Link from 'Components/Link/Link'; +import { icons } from 'Helpers/Props'; import styles from './FormInputHelpText.css'; function FormInputHelpText(props) { @@ -11,7 +11,7 @@ function FormInputHelpText(props) { className, text, link, - linkTooltip, + tooltip, isError, isWarning, isCheckInput @@ -28,16 +28,27 @@ function FormInputHelpText(props) { {text} { - !!link && + link ? - + : + null + } + + { + !link && tooltip ? + : + null }
); @@ -47,7 +58,7 @@ FormInputHelpText.propTypes = { className: PropTypes.string.isRequired, text: PropTypes.string.isRequired, link: PropTypes.string, - linkTooltip: PropTypes.string, + tooltip: PropTypes.string, isError: PropTypes.bool, isWarning: PropTypes.bool, isCheckInput: PropTypes.bool diff --git a/frontend/src/Components/Form/FormLabel.css b/frontend/src/Components/Form/FormLabel.css index 236f4aab0..54a4678e8 100644 --- a/frontend/src/Components/Form/FormLabel.css +++ b/frontend/src/Components/Form/FormLabel.css @@ -2,16 +2,18 @@ display: flex; justify-content: flex-end; margin-right: $formLabelRightMarginWidth; + padding-top: 8px; + min-height: 35px; + text-align: end; font-weight: bold; - line-height: 35px; } .hasError { - color: $dangerColor; + color: var(--dangerColor); } .isAdvanced { - color: $advancedFormLabelColor; + color: var(--advancedFormLabelColor); } @media only screen and (max-width: $breakpointLarge) { diff --git a/frontend/src/Components/Form/FormLabel.css.d.ts b/frontend/src/Components/Form/FormLabel.css.d.ts new file mode 100644 index 000000000..c23dd30a4 --- /dev/null +++ b/frontend/src/Components/Form/FormLabel.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'isAdvanced': string; + 'label': string; + 'large': string; + 'small': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/FormLabel.js b/frontend/src/Components/Form/FormLabel.js index da7a443e3..d4a4bcffc 100644 --- a/frontend/src/Components/Form/FormLabel.js +++ b/frontend/src/Components/Form/FormLabel.js @@ -1,19 +1,21 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; -import classNames from 'classnames'; import { sizes } from 'Helpers/Props'; import styles from './FormLabel.css'; -function FormLabel({ - children, - className, - errorClassName, - size, - name, - hasError, - isAdvanced, - ...otherProps -}) { +function FormLabel(props) { + const { + children, + className, + errorClassName, + size, + name, + hasError, + isAdvanced, + ...otherProps + } = props; + return (
: + null } ); } HintedSelectInputSelectedValue.propTypes = { - value: PropTypes.string, + value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))]).isRequired, + values: PropTypes.arrayOf(PropTypes.object).isRequired, hint: PropTypes.string, + isMultiSelect: PropTypes.bool.isRequired, includeHint: PropTypes.bool.isRequired }; HintedSelectInputSelectedValue.defaultProps = { + isMultiSelect: false, includeHint: true }; diff --git a/frontend/src/Components/Form/IndexerFlagsSelectInput.tsx b/frontend/src/Components/Form/IndexerFlagsSelectInput.tsx new file mode 100644 index 000000000..8dbd27a70 --- /dev/null +++ b/frontend/src/Components/Form/IndexerFlagsSelectInput.tsx @@ -0,0 +1,62 @@ +import React, { useCallback } from 'react'; +import { useSelector } from 'react-redux'; +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; +import EnhancedSelectInput from './EnhancedSelectInput'; + +const selectIndexerFlagsValues = (selectedFlags: number) => + createSelector( + (state: AppState) => state.settings.indexerFlags, + (indexerFlags) => { + const value = indexerFlags.items.reduce((acc: number[], { id }) => { + // eslint-disable-next-line no-bitwise + if ((selectedFlags & id) === id) { + acc.push(id); + } + + return acc; + }, []); + + const values = indexerFlags.items.map(({ id, name }) => ({ + key: id, + value: name, + })); + + return { + value, + values, + }; + } + ); + +interface IndexerFlagsSelectInputProps { + name: string; + indexerFlags: number; + onChange(payload: object): void; +} + +function IndexerFlagsSelectInput(props: IndexerFlagsSelectInputProps) { + const { indexerFlags, onChange } = props; + + const { value, values } = useSelector(selectIndexerFlagsValues(indexerFlags)); + + const onChangeWrapper = useCallback( + ({ name, value }: { name: string; value: number[] }) => { + const indexerFlags = value.reduce((acc, flagId) => acc + flagId, 0); + + onChange({ name, value: indexerFlags }); + }, + [onChange] + ); + + return ( + + ); +} + +export default IndexerFlagsSelectInput; diff --git a/frontend/src/Components/Form/IndexerSelectInputConnector.js b/frontend/src/Components/Form/IndexerSelectInputConnector.js new file mode 100644 index 000000000..5f62becbb --- /dev/null +++ b/frontend/src/Components/Form/IndexerSelectInputConnector.js @@ -0,0 +1,97 @@ +import _ from 'lodash'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; +import { fetchIndexers } from 'Store/Actions/settingsActions'; +import sortByProp from 'Utilities/Array/sortByProp'; +import translate from 'Utilities/String/translate'; +import EnhancedSelectInput from './EnhancedSelectInput'; + +function createMapStateToProps() { + return createSelector( + (state) => state.settings.indexers, + (state, { includeAny }) => includeAny, + (indexers, includeAny) => { + const { + isFetching, + isPopulated, + error, + items + } = indexers; + + const values = _.map(items.sort(sortByProp('name')), (indexer) => { + return { + key: indexer.id, + value: indexer.name + }; + }); + + if (includeAny) { + values.unshift({ + key: 0, + value: `(${translate('Any')})` + }); + } + + return { + isFetching, + isPopulated, + error, + values + }; + } + ); +} + +const mapDispatchToProps = { + dispatchFetchIndexers: fetchIndexers +}; + +class IndexerSelectInputConnector extends Component { + + // + // Lifecycle + + componentDidMount() { + if (!this.props.isPopulated) { + this.props.dispatchFetchIndexers(); + } + } + + // + // Listeners + + onChange = ({ name, value }) => { + this.props.onChange({ name, value: parseInt(value) }); + }; + + // + // Render + + render() { + return ( + + ); + } +} + +IndexerSelectInputConnector.propTypes = { + isFetching: PropTypes.bool.isRequired, + isPopulated: PropTypes.bool.isRequired, + name: PropTypes.string.isRequired, + value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired, + values: PropTypes.arrayOf(PropTypes.object).isRequired, + includeAny: PropTypes.bool.isRequired, + onChange: PropTypes.func.isRequired, + dispatchFetchIndexers: PropTypes.func.isRequired +}; + +IndexerSelectInputConnector.defaultProps = { + includeAny: false +}; + +export default connect(createMapStateToProps, mapDispatchToProps)(IndexerSelectInputConnector); diff --git a/frontend/src/Components/Form/Input.css b/frontend/src/Components/Form/Input.css index e9ca23d8f..dd9ee888d 100644 --- a/frontend/src/Components/Form/Input.css +++ b/frontend/src/Components/Form/Input.css @@ -2,26 +2,27 @@ padding: 6px 16px; width: 100%; height: 35px; - border: 1px solid $inputBorderColor; + border: 1px solid var(--inputBorderColor); border-radius: 4px; - background-color: $white; - box-shadow: inset 0 1px 1px $inputBoxShadowColor; + background-color: var(--inputBackgroundColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor); + color: var(--textColor); &:focus { outline: 0; - border-color: $inputFocusBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; + border-color: var(--inputFocusBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); } } .hasError { - border-color: $inputErrorBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputErrorBoxShadowColor; + border-color: var(--inputErrorBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputErrorBoxShadowColor); } .hasWarning { - border-color: $inputWarningBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputWarningBoxShadowColor; + border-color: var(--inputWarningBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputWarningBoxShadowColor); } .hasButton { diff --git a/frontend/src/Components/Form/KeyValueListInput.css b/frontend/src/Components/Form/KeyValueListInput.css index 8bf23610b..d86e6a512 100644 --- a/frontend/src/Components/Form/KeyValueListInput.css +++ b/frontend/src/Components/Form/KeyValueListInput.css @@ -7,8 +7,8 @@ &.isFocused { outline: 0; - border-color: $inputFocusBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; + border-color: var(--inputFocusBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); } } diff --git a/frontend/src/Components/Form/KeyValueListInput.css.d.ts b/frontend/src/Components/Form/KeyValueListInput.css.d.ts new file mode 100644 index 000000000..972f108c9 --- /dev/null +++ b/frontend/src/Components/Form/KeyValueListInput.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'hasWarning': string; + 'inputContainer': string; + 'isFocused': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/KeyValueListInput.js b/frontend/src/Components/Form/KeyValueListInput.js deleted file mode 100644 index a52c76f70..000000000 --- a/frontend/src/Components/Form/KeyValueListInput.js +++ /dev/null @@ -1,152 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import classNames from 'classnames'; -import KeyValueListInputItem from './KeyValueListInputItem'; -import styles from './KeyValueListInput.css'; - -class KeyValueListInput extends Component { - - // - // Lifecycle - - constructor(props, context) { - super(props, context); - - this.state = { - isFocused: false - }; - } - - // - // Listeners - - onItemChange = (index, itemValue) => { - const { - name, - value, - onChange - } = this.props; - - const newValue = [...value]; - - if (index == null) { - newValue.push(itemValue); - } else { - newValue.splice(index, 1, itemValue); - } - - onChange({ - name, - value: newValue - }); - } - - onRemoveItem = (index) => { - const { - name, - value, - onChange - } = this.props; - - const newValue = [...value]; - newValue.splice(index, 1); - - onChange({ - name, - value: newValue - }); - } - - onFocus = () => { - this.setState({ - isFocused: true - }); - } - - onBlur = () => { - this.setState({ - isFocused: false - }); - - const { - name, - value, - onChange - } = this.props; - - const newValue = value.reduce((acc, v) => { - if (v.key || v.value) { - acc.push(v); - } - - return acc; - }, []); - - if (newValue.length !== value.length) { - onChange({ - name, - value: newValue - }); - } - } - - // - // Render - - render() { - const { - className, - value, - keyPlaceholder, - valuePlaceholder - } = this.props; - - const { isFocused } = this.state; - - return ( -
- { - [...value, { key: '', value: '' }].map((v, index) => { - return ( - - ); - }) - } -
- ); - } -} - -KeyValueListInput.propTypes = { - className: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, - value: PropTypes.arrayOf(PropTypes.object).isRequired, - hasError: PropTypes.bool, - hasWarning: PropTypes.bool, - keyPlaceholder: PropTypes.string, - valuePlaceholder: PropTypes.string, - onChange: PropTypes.func.isRequired -}; - -KeyValueListInput.defaultProps = { - className: styles.inputContainer, - value: [] -}; - -export default KeyValueListInput; diff --git a/frontend/src/Components/Form/KeyValueListInput.tsx b/frontend/src/Components/Form/KeyValueListInput.tsx new file mode 100644 index 000000000..f5c6ac19b --- /dev/null +++ b/frontend/src/Components/Form/KeyValueListInput.tsx @@ -0,0 +1,104 @@ +import classNames from 'classnames'; +import React, { useCallback, useState } from 'react'; +import { InputOnChange } from 'typings/inputs'; +import KeyValueListInputItem from './KeyValueListInputItem'; +import styles from './KeyValueListInput.css'; + +interface KeyValue { + key: string; + value: string; +} + +export interface KeyValueListInputProps { + className?: string; + name: string; + value: KeyValue[]; + hasError?: boolean; + hasWarning?: boolean; + keyPlaceholder?: string; + valuePlaceholder?: string; + onChange: InputOnChange; +} + +function KeyValueListInput({ + className = styles.inputContainer, + name, + value = [], + hasError = false, + hasWarning = false, + keyPlaceholder, + valuePlaceholder, + onChange, +}: KeyValueListInputProps): JSX.Element { + const [isFocused, setIsFocused] = useState(false); + + const handleItemChange = useCallback( + (index: number | null, itemValue: KeyValue) => { + const newValue = [...value]; + + if (index === null) { + newValue.push(itemValue); + } else { + newValue.splice(index, 1, itemValue); + } + + onChange({ name, value: newValue }); + }, + [value, name, onChange] + ); + + const handleRemoveItem = useCallback( + (index: number) => { + const newValue = [...value]; + newValue.splice(index, 1); + onChange({ name, value: newValue }); + }, + [value, name, onChange] + ); + + const onFocus = useCallback(() => setIsFocused(true), []); + + const onBlur = useCallback(() => { + setIsFocused(false); + + const newValue = value.reduce((acc: KeyValue[], v) => { + if (v.key || v.value) { + acc.push(v); + } + return acc; + }, []); + + if (newValue.length !== value.length) { + onChange({ name, value: newValue }); + } + }, [value, name, onChange]); + + return ( +
+ {[...value, { key: '', value: '' }].map((v, index) => ( + + ))} +
+ ); +} + +export default KeyValueListInput; diff --git a/frontend/src/Components/Form/KeyValueListInputItem.css b/frontend/src/Components/Form/KeyValueListInputItem.css index f77ea3470..ed82db459 100644 --- a/frontend/src/Components/Form/KeyValueListInputItem.css +++ b/frontend/src/Components/Form/KeyValueListInputItem.css @@ -1,14 +1,35 @@ .itemContainer { display: flex; margin-bottom: 3px; - border-bottom: 1px solid $inputBorderColor; + border-bottom: 1px solid var(--inputBorderColor); &:last-child { margin-bottom: 0; + border-bottom: 0; } } +.keyInputWrapper { + flex: 1 0 0; +} + +.valueInputWrapper { + flex: 1 0 0; + min-width: 40px; +} + +.buttonWrapper { + flex: 0 0 22px; +} + .keyInput, .valueInput { + width: 100%; border: none; + background-color: transparent; + color: var(--textColor); + + &::placeholder { + color: var(--helpTextColor); + } } diff --git a/frontend/src/Components/Form/KeyValueListInputItem.css.d.ts b/frontend/src/Components/Form/KeyValueListInputItem.css.d.ts new file mode 100644 index 000000000..aa0c1be13 --- /dev/null +++ b/frontend/src/Components/Form/KeyValueListInputItem.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'buttonWrapper': string; + 'itemContainer': string; + 'keyInput': string; + 'keyInputWrapper': string; + 'valueInput': string; + 'valueInputWrapper': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/KeyValueListInputItem.js b/frontend/src/Components/Form/KeyValueListInputItem.js deleted file mode 100644 index 4e465f3a9..000000000 --- a/frontend/src/Components/Form/KeyValueListInputItem.js +++ /dev/null @@ -1,117 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { icons } from 'Helpers/Props'; -import IconButton from 'Components/Link/IconButton'; -import TextInput from './TextInput'; -import styles from './KeyValueListInputItem.css'; - -class KeyValueListInputItem extends Component { - - // - // Listeners - - onKeyChange = ({ value: keyValue }) => { - const { - index, - value, - onChange - } = this.props; - - onChange(index, { key: keyValue, value }); - } - - onValueChange = ({ value }) => { - // TODO: Validate here or validate at a lower level component - - const { - index, - keyValue, - onChange - } = this.props; - - onChange(index, { key: keyValue, value }); - } - - onRemovePress = () => { - const { - index, - onRemove - } = this.props; - - onRemove(index); - } - - onFocus = () => { - this.props.onFocus(); - } - - onBlur = () => { - this.props.onBlur(); - } - - // - // Render - - render() { - const { - keyValue, - value, - keyPlaceholder, - valuePlaceholder, - isNew - } = this.props; - - return ( -
- - - - - { - !isNew && - - } -
- ); - } -} - -KeyValueListInputItem.propTypes = { - index: PropTypes.number, - keyValue: PropTypes.string.isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - keyPlaceholder: PropTypes.string.isRequired, - valuePlaceholder: PropTypes.string.isRequired, - isNew: PropTypes.bool.isRequired, - onChange: PropTypes.func.isRequired, - onRemove: PropTypes.func.isRequired, - onFocus: PropTypes.func.isRequired, - onBlur: PropTypes.func.isRequired -}; - -KeyValueListInputItem.defaultProps = { - keyPlaceholder: 'Key', - valuePlaceholder: 'Value' -}; - -export default KeyValueListInputItem; diff --git a/frontend/src/Components/Form/KeyValueListInputItem.tsx b/frontend/src/Components/Form/KeyValueListInputItem.tsx new file mode 100644 index 000000000..c63ad50a9 --- /dev/null +++ b/frontend/src/Components/Form/KeyValueListInputItem.tsx @@ -0,0 +1,89 @@ +import React, { useCallback } from 'react'; +import IconButton from 'Components/Link/IconButton'; +import { icons } from 'Helpers/Props'; +import TextInput from './TextInput'; +import styles from './KeyValueListInputItem.css'; + +interface KeyValueListInputItemProps { + index: number; + keyValue: string; + value: string; + keyPlaceholder?: string; + valuePlaceholder?: string; + isNew: boolean; + onChange: (index: number, itemValue: { key: string; value: string }) => void; + onRemove: (index: number) => void; + onFocus: () => void; + onBlur: () => void; +} + +function KeyValueListInputItem({ + index, + keyValue, + value, + keyPlaceholder = 'Key', + valuePlaceholder = 'Value', + isNew, + onChange, + onRemove, + onFocus, + onBlur, +}: KeyValueListInputItemProps): JSX.Element { + const handleKeyChange = useCallback( + ({ value: keyValue }: { value: string }) => { + onChange(index, { key: keyValue, value }); + }, + [index, value, onChange] + ); + + const handleValueChange = useCallback( + ({ value }: { value: string }) => { + onChange(index, { key: keyValue, value }); + }, + [index, keyValue, onChange] + ); + + const handleRemovePress = useCallback(() => { + onRemove(index); + }, [index, onRemove]); + + return ( +
+
+ +
+ +
+ +
+ +
+ {isNew ? null : ( + + )} +
+
+ ); +} + +export default KeyValueListInputItem; diff --git a/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js b/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js index d28876aa0..6e6aad5f9 100644 --- a/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js +++ b/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js @@ -3,27 +3,42 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import sortByName from 'Utilities/Array/sortByName'; -import SelectInput from './SelectInput'; +import { metadataProfileNames } from 'Helpers/Props'; +import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector'; +import sortByProp from 'Utilities/Array/sortByProp'; +import translate from 'Utilities/String/translate'; +import EnhancedSelectInput from './EnhancedSelectInput'; function createMapStateToProps() { return createSelector( - (state) => state.settings.metadataProfiles, + createSortedSectionSelector('settings.metadataProfiles', sortByProp('name')), (state, { includeNoChange }) => includeNoChange, + (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, (state, { includeMixed }) => includeMixed, - (metadataProfiles, includeNoChange, includeMixed) => { - const values = _.map(metadataProfiles.items.sort(sortByName), (metadataProfile) => { + (state, { includeNone }) => includeNone, + (metadataProfiles, includeNoChange, includeNoChangeDisabled = true, includeMixed, includeNone) => { + const profiles = metadataProfiles.items.filter((item) => item.name !== metadataProfileNames.NONE); + const noneProfile = metadataProfiles.items.find((item) => item.name === metadataProfileNames.NONE); + + const values = _.map(profiles, (metadataProfile) => { return { key: metadataProfile.id, value: metadataProfile.name }; }); + if (includeNone) { + values.push({ + key: noneProfile.id, + value: noneProfile.name + }); + } + if (includeNoChange) { values.unshift({ key: 'noChange', - value: 'No Change', - disabled: true + value: translate('NoChange'), + isDisabled: includeNoChangeDisabled }); } @@ -31,7 +46,7 @@ function createMapStateToProps() { values.unshift({ key: 'mixed', value: '(Mixed)', - disabled: true + isDisabled: true }); } @@ -54,8 +69,8 @@ class MetadataProfileSelectInputConnector extends Component { values } = this.props; - if (!value || !_.some(values, (option) => parseInt(option.key) === value)) { - const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key))); + if (!value || !values.some((option) => option.key === value || parseInt(option.key) === value)) { + const firstValue = values.find((option) => !isNaN(parseInt(option.key))); if (firstValue) { this.onChange({ name, value: firstValue.key }); @@ -67,15 +82,15 @@ class MetadataProfileSelectInputConnector extends Component { // Listeners onChange = ({ name, value }) => { - this.props.onChange({ name, value: parseInt(value) }); - } + this.props.onChange({ name, value: value === 'noChange' ? value : parseInt(value) }); + }; // // Render render() { return ( - @@ -88,11 +103,13 @@ MetadataProfileSelectInputConnector.propTypes = { value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), values: PropTypes.arrayOf(PropTypes.object).isRequired, includeNoChange: PropTypes.bool.isRequired, + includeNone: PropTypes.bool.isRequired, onChange: PropTypes.func.isRequired }; MetadataProfileSelectInputConnector.defaultProps = { - includeNoChange: false + includeNoChange: false, + includeNone: true }; export default connect(createMapStateToProps)(MetadataProfileSelectInputConnector); diff --git a/frontend/src/Components/Form/MonitorAlbumsSelectInput.js b/frontend/src/Components/Form/MonitorAlbumsSelectInput.js index a3780de56..d48284c38 100644 --- a/frontend/src/Components/Form/MonitorAlbumsSelectInput.js +++ b/frontend/src/Components/Form/MonitorAlbumsSelectInput.js @@ -1,11 +1,13 @@ import PropTypes from 'prop-types'; import React from 'react'; import monitorOptions from 'Utilities/Artist/monitorOptions'; +import translate from 'Utilities/String/translate'; import SelectInput from './SelectInput'; function MonitorAlbumsSelectInput(props) { const { includeNoChange, + includeNoChangeDisabled = true, includeMixed, ...otherProps } = props; @@ -15,16 +17,16 @@ function MonitorAlbumsSelectInput(props) { if (includeNoChange) { values.unshift({ key: 'noChange', - value: 'No Change', - disabled: true + value: translate('NoChange'), + isDisabled: includeNoChangeDisabled }); } if (includeMixed) { values.unshift({ key: 'mixed', - value: '(Mixed)', - disabled: true + value: `(${translate('Mixed')})`, + isDisabled: true }); } @@ -38,6 +40,7 @@ function MonitorAlbumsSelectInput(props) { MonitorAlbumsSelectInput.propTypes = { includeNoChange: PropTypes.bool.isRequired, + includeNoChangeDisabled: PropTypes.bool, includeMixed: PropTypes.bool.isRequired, onChange: PropTypes.func.isRequired }; diff --git a/frontend/src/Components/Form/MonitorNewItemsSelectInput.js b/frontend/src/Components/Form/MonitorNewItemsSelectInput.js new file mode 100644 index 000000000..0dccc44a4 --- /dev/null +++ b/frontend/src/Components/Form/MonitorNewItemsSelectInput.js @@ -0,0 +1,53 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import monitorNewItemsOptions from 'Utilities/Artist/monitorNewItemsOptions'; +import translate from 'Utilities/String/translate'; +import EnhancedSelectInput from './EnhancedSelectInput'; + +function MonitorNewItemsSelectInput(props) { + const { + includeNoChange, + includeNoChangeDisabled = true, + includeMixed, + ...otherProps + } = props; + + const values = [...monitorNewItemsOptions]; + + if (includeNoChange) { + values.unshift({ + key: 'noChange', + value: translate('NoChange'), + isDisabled: includeNoChangeDisabled + }); + } + + if (includeMixed) { + values.unshift({ + key: 'mixed', + value: '(Mixed)', + isDisabled: true + }); + } + + return ( + + ); +} + +MonitorNewItemsSelectInput.propTypes = { + includeNoChange: PropTypes.bool.isRequired, + includeNoChangeDisabled: PropTypes.bool, + includeMixed: PropTypes.bool.isRequired, + onChange: PropTypes.func.isRequired +}; + +MonitorNewItemsSelectInput.defaultProps = { + includeNoChange: false, + includeMixed: false +}; + +export default MonitorNewItemsSelectInput; diff --git a/frontend/src/Components/Form/NumberInput.js b/frontend/src/Components/Form/NumberInput.js index c4ecc7e86..cac274d95 100644 --- a/frontend/src/Components/Form/NumberInput.js +++ b/frontend/src/Components/Form/NumberInput.js @@ -10,7 +10,7 @@ function parseValue(props, value) { } = props; if (value == null || value === '') { - return min; + return null; } let newValue = isFloat ? parseFloat(value) : parseInt(value); @@ -41,7 +41,7 @@ class NumberInput extends Component { componentDidUpdate(prevProps, prevState) { const { value } = this.props; - if (value !== prevProps.value && !this.state.isFocused) { + if (!isNaN(value) && value !== prevProps.value && !this.state.isFocused) { this.setState({ value: value == null ? '' : value.toString() }); @@ -59,11 +59,11 @@ class NumberInput extends Component { value: parseValue(this.props, value) }); - } + }; onFocus = () => { this.setState({ isFocused: true }); - } + }; onBlur = () => { const { @@ -88,7 +88,7 @@ class NumberInput extends Component { name, value: parsedValue }); - } + }; // // Render diff --git a/frontend/src/Components/Form/OAuthInput.js b/frontend/src/Components/Form/OAuthInput.js index 00825b6ba..4ecd625bc 100644 --- a/frontend/src/Components/Form/OAuthInput.js +++ b/frontend/src/Components/Form/OAuthInput.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { kinds } from 'Helpers/Props'; import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton'; +import { kinds } from 'Helpers/Props'; function OAuthInput(props) { const { diff --git a/frontend/src/Components/Form/OAuthInputConnector.js b/frontend/src/Components/Form/OAuthInputConnector.js index 7568aae7a..1567c7e6c 100644 --- a/frontend/src/Components/Form/OAuthInputConnector.js +++ b/frontend/src/Components/Form/OAuthInputConnector.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { startOAuth, resetOAuth } from 'Store/Actions/oAuthActions'; +import { resetOAuth, startOAuth } from 'Store/Actions/oAuthActions'; import OAuthInput from './OAuthInput'; function createMapStateToProps() { @@ -41,7 +41,7 @@ class OAuthInputConnector extends Component { componentWillUnmount = () => { this.props.resetOAuth(); - } + }; // // Listeners @@ -60,7 +60,7 @@ class OAuthInputConnector extends Component { providerData, section }); - } + }; // // Render diff --git a/frontend/src/Components/Form/PasswordInput.css b/frontend/src/Components/Form/PasswordInput.css deleted file mode 100644 index 6cb162784..000000000 --- a/frontend/src/Components/Form/PasswordInput.css +++ /dev/null @@ -1,5 +0,0 @@ -.input { - composes: input from '~Components/Form/TextInput.css'; - - font-family: $passwordFamily; -} diff --git a/frontend/src/Components/Form/PasswordInput.js b/frontend/src/Components/Form/PasswordInput.js index adb1e7c5a..dbc4cfdb4 100644 --- a/frontend/src/Components/Form/PasswordInput.js +++ b/frontend/src/Components/Form/PasswordInput.js @@ -1,22 +1,24 @@ -import PropTypes from 'prop-types'; import React from 'react'; import TextInput from './TextInput'; -import styles from './PasswordInput.css'; + +// Prevent a user from copying (or cutting) the password from the input +function onCopy(e) { + e.preventDefault(); + e.nativeEvent.stopImmediatePropagation(); +} function PasswordInput(props) { return ( ); } PasswordInput.propTypes = { - className: PropTypes.string.isRequired -}; - -PasswordInput.defaultProps = { - className: styles.input + ...TextInput.props }; export default PasswordInput; diff --git a/frontend/src/Components/Form/PathInput.css.d.ts b/frontend/src/Components/Form/PathInput.css.d.ts new file mode 100644 index 000000000..d44c3dd56 --- /dev/null +++ b/frontend/src/Components/Form/PathInput.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'fileBrowserButton': string; + 'hasFileBrowser': string; + 'inputWrapper': string; + 'pathMatch': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/PathInput.js b/frontend/src/Components/Form/PathInput.js index 40c4840ba..972d8f99f 100644 --- a/frontend/src/Components/Form/PathInput.js +++ b/frontend/src/Components/Form/PathInput.js @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { icons } from 'Helpers/Props'; -import Icon from 'Components/Icon'; import FileBrowserModal from 'Components/FileBrowser/FileBrowserModal'; +import Icon from 'Components/Icon'; +import { icons } from 'Helpers/Props'; import AutoSuggestInput from './AutoSuggestInput'; import FormInputButton from './FormInputButton'; import styles from './PathInput.css'; @@ -62,7 +62,7 @@ class PathInput extends Component { onInputChange = ({ value }) => { this.setState({ value }); - } + }; onInputKeyDown = (event) => { if (event.key === 'Tab') { @@ -80,7 +80,7 @@ class PathInput extends Component { } } } - } + }; onInputBlur = () => { this.props.onChange({ @@ -89,28 +89,28 @@ class PathInput extends Component { }); this.props.onClearPaths(); - } + }; onSuggestionsFetchRequested = ({ value }) => { this.props.onFetchPaths(value); - } + }; onSuggestionsClearRequested = () => { // Required because props aren't always rendered, but no-op // because we don't want to reset the paths after a path is selected. - } + }; onSuggestionSelected = (event, { suggestionValue }) => { this.props.onFetchPaths(suggestionValue); - } + }; onFileBrowserOpenPress = () => { this.setState({ isFileBrowserModalOpen: true }); - } + }; onFileBrowserModalClose = () => { this.setState({ isFileBrowserModalOpen: false }); - } + }; // // Render diff --git a/frontend/src/Components/Form/PathInputConnector.js b/frontend/src/Components/Form/PathInputConnector.js index 38ea37065..3917a8d3f 100644 --- a/frontend/src/Components/Form/PathInputConnector.js +++ b/frontend/src/Components/Form/PathInputConnector.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { fetchPaths, clearPaths } from 'Store/Actions/pathActions'; +import { clearPaths, fetchPaths } from 'Store/Actions/pathActions'; import PathInput from './PathInput'; function createMapStateToProps() { @@ -47,11 +47,11 @@ class PathInputConnector extends Component { path, includeFiles }); - } + }; onClearPaths = () => { this.props.dispatchClearPaths(); - } + }; // // Render diff --git a/frontend/src/Components/Form/PlaylistInput.css.d.ts b/frontend/src/Components/Form/PlaylistInput.css.d.ts new file mode 100644 index 000000000..98431d38d --- /dev/null +++ b/frontend/src/Components/Form/PlaylistInput.css.d.ts @@ -0,0 +1,8 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'input': string; + 'playlistInputWrapper': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/PlaylistInput.js b/frontend/src/Components/Form/PlaylistInput.js index df482e7bb..0b3966f60 100644 --- a/frontend/src/Components/Form/PlaylistInput.js +++ b/frontend/src/Components/Form/PlaylistInput.js @@ -1,22 +1,22 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import tagShape from 'Helpers/Props/Shapes/tagShape'; -import getSelectedIds from 'Utilities/Table/getSelectedIds'; -import selectAll from 'Utilities/Table/selectAll'; -import toggleSelected from 'Utilities/Table/toggleSelected'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; import TableRow from 'Components/Table/TableRow'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; -import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; +import tagShape from 'Helpers/Props/Shapes/tagShape'; +import translate from 'Utilities/String/translate'; +import selectAll from 'Utilities/Table/selectAll'; +import toggleSelected from 'Utilities/Table/toggleSelected'; import styles from './PlaylistInput.css'; const columns = [ { name: 'name', - label: 'Playlist', + label: () => translate('Playlist'), isSortable: false, isVisible: true } @@ -45,7 +45,17 @@ class PlaylistInput extends Component { onChange } = this.props; - const oldSelected = getSelectedIds(prevState.selectedState, { parseIds: false }).sort(); + const oldSelected = _.reduce( + prevState.selectedState, + (result, value, id) => { + if (value) { + result.push(id); + } + + return result; + }, + [] + ).sort(); const newSelected = this.getSelectedIds().sort(); if (!_.isEqual(oldSelected, newSelected)) { @@ -60,21 +70,31 @@ class PlaylistInput extends Component { // Control getSelectedIds = () => { - return getSelectedIds(this.state.selectedState, { parseIds: false }); - } + return _.reduce( + this.state.selectedState, + (result, value, id) => { + if (value) { + result.push(id); + } + + return result; + }, + [] + ); + }; // // Listeners onSelectAllChange = ({ value }) => { this.setState(selectAll(this.state.selectedState, value)); - } + }; onSelectedChange = ({ id, value, shiftKey = false }) => { this.setState((state, props) => { return toggleSelected(state, props.items, id, value, shiftKey); }); - } + }; // // Render @@ -180,7 +200,8 @@ PlaylistInput.propTypes = { PlaylistInput.defaultProps = { className: styles.playlistInputWrapper, - inputClassName: styles.input + inputClassName: styles.input, + isPopulated: false }; export default PlaylistInput; diff --git a/frontend/src/Components/Form/PlaylistInputConnector.js b/frontend/src/Components/Form/PlaylistInputConnector.js index e70765671..f88a9f14d 100644 --- a/frontend/src/Components/Form/PlaylistInputConnector.js +++ b/frontend/src/Components/Form/PlaylistInputConnector.js @@ -3,20 +3,21 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { fetchOptions, clearOptions } from 'Store/Actions/providerOptionActions'; +import { clearOptions, defaultState, fetchOptions } from 'Store/Actions/providerOptionActions'; import PlaylistInput from './PlaylistInput'; function createMapStateToProps() { return createSelector( - (state) => state.providerOptions, - (state) => { + (state) => state.providerOptions.playlists || defaultState, + (playlists) => { const { items, ...otherState - } = state; + } = playlists; + return ({ - user: items.user ? items.user : '', - items: items.playlists ? items.playlists : [], + user: items && items.user ? items.user : '', + items: items && items.playlists ? items.playlists : [], ...otherState }); } @@ -37,7 +38,7 @@ class PlaylistInputConnector extends Component { if (this._getAccessToken(this.props)) { this._populate(); } - } + }; componentDidUpdate(prevProps, prevState) { const newToken = this._getAccessToken(this.props); @@ -48,8 +49,8 @@ class PlaylistInputConnector extends Component { } componentWillUnmount = () => { - this.props.dispatchClearOptions(); - } + this.props.dispatchClearOptions({ section: 'playlists' }); + }; // // Control @@ -62,6 +63,7 @@ class PlaylistInputConnector extends Component { } = this.props; dispatchFetchOptions({ + section: 'playlists', action: 'getPlaylists', provider, providerData diff --git a/frontend/src/Components/Form/ProviderFieldFormGroup.js b/frontend/src/Components/Form/ProviderFieldFormGroup.js index dca32aa1e..311f1bbbd 100644 --- a/frontend/src/Components/Form/ProviderFieldFormGroup.js +++ b/frontend/src/Components/Form/ProviderFieldFormGroup.js @@ -1,12 +1,12 @@ import _ from 'lodash'; import PropTypes from 'prop-types'; import React from 'react'; -import { inputTypes } from 'Helpers/Props'; import FormGroup from 'Components/Form/FormGroup'; -import FormLabel from 'Components/Form/FormLabel'; import FormInputGroup from 'Components/Form/FormInputGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import { inputTypes } from 'Helpers/Props'; -function getType(type) { +function getType({ type, selectOptionsProviderAction }) { switch (type) { case 'captcha': return inputTypes.CAPTCHA; @@ -14,6 +14,8 @@ function getType(type) { return inputTypes.CHECK; case 'device': return inputTypes.DEVICE; + case 'keyValueList': + return inputTypes.KEY_VALUE_LIST; case 'playlist': return inputTypes.PLAYLIST; case 'password': @@ -25,13 +27,26 @@ function getType(type) { case 'filePath': return inputTypes.PATH; case 'select': + if (selectOptionsProviderAction) { + return inputTypes.DYNAMIC_SELECT; + } return inputTypes.SELECT; + case 'artistTag': + return inputTypes.ARTIST_TAG; case 'tag': return inputTypes.TEXT_TAG; + case 'tagSelect': + return inputTypes.TAG_SELECT; case 'textbox': return inputTypes.TEXT; case 'oAuth': return inputTypes.OAUTH; + case 'rootFolder': + return inputTypes.ROOT_FOLDER_SELECT; + case 'qualityProfile': + return inputTypes.QUALITY_PROFILE_SELECT; + case 'metadataProfile': + return inputTypes.METADATA_PROFILE_SELECT; default: return inputTypes.TEXT; } @@ -45,7 +60,8 @@ function getSelectValues(selectOptions) { return _.reduce(selectOptions, (result, option) => { result.push({ key: option.value, - value: option.name + value: option.name, + hint: option.hint }); return result; @@ -58,7 +74,9 @@ function ProviderFieldFormGroup(props) { name, label, helpText, + helpTextWarning, helpLink, + placeholder, value, type, advanced, @@ -86,11 +104,13 @@ function ProviderFieldFormGroup(props) { {label} state.settings.qualityProfiles, + createSortedSectionSelector('settings.qualityProfiles', sortByProp('name')), (state, { includeNoChange }) => includeNoChange, + (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, (state, { includeMixed }) => includeMixed, - (qualityProfiles, includeNoChange, includeMixed) => { - const values = _.map(qualityProfiles.items.sort(sortByName), (qualityProfile) => { + (qualityProfiles, includeNoChange, includeNoChangeDisabled = true, includeMixed) => { + const values = _.map(qualityProfiles.items, (qualityProfile) => { return { key: qualityProfile.id, value: qualityProfile.name @@ -22,8 +25,8 @@ function createMapStateToProps() { if (includeNoChange) { values.unshift({ key: 'noChange', - value: 'No Change', - disabled: true + value: translate('NoChange'), + isDisabled: includeNoChangeDisabled }); } @@ -31,7 +34,7 @@ function createMapStateToProps() { values.unshift({ key: 'mixed', value: '(Mixed)', - disabled: true + isDisabled: true }); } @@ -54,8 +57,8 @@ class QualityProfileSelectInputConnector extends Component { values } = this.props; - if (!value || !_.some(values, (option) => parseInt(option.key) === value)) { - const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key))); + if (!value || !values.some((option) => option.key === value || parseInt(option.key) === value)) { + const firstValue = values.find((option) => !isNaN(parseInt(option.key))); if (firstValue) { this.onChange({ name, value: firstValue.key }); @@ -67,15 +70,15 @@ class QualityProfileSelectInputConnector extends Component { // Listeners onChange = ({ name, value }) => { - this.props.onChange({ name, value: parseInt(value) }); - } + this.props.onChange({ name, value: value === 'noChange' ? value : parseInt(value) }); + }; // // Render render() { return ( - diff --git a/frontend/src/Components/Form/RootFolderSelectInput.js b/frontend/src/Components/Form/RootFolderSelectInput.js index 08d88e5f1..7df36eee7 100644 --- a/frontend/src/Components/Form/RootFolderSelectInput.js +++ b/frontend/src/Components/Form/RootFolderSelectInput.js @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import FileBrowserModal from 'Components/FileBrowser/FileBrowserModal'; +import EditRootFolderModalConnector from 'Settings/MediaManagement/RootFolder/EditRootFolderModalConnector'; import EnhancedSelectInput from './EnhancedSelectInput'; import RootFolderSelectInputOption from './RootFolderSelectInputOption'; import RootFolderSelectInputSelectedValue from './RootFolderSelectInputSelectedValue'; @@ -14,8 +14,7 @@ class RootFolderSelectInput extends Component { super(props, context); this.state = { - isAddNewRootFolderModalOpen: false, - newRootFolderPath: '' + isAddNewRootFolderModalOpen: false }; } @@ -49,25 +48,22 @@ class RootFolderSelectInput extends Component { } else { this.props.onChange({ name, value }); } - } + }; onNewRootFolderSelect = ({ value }) => { - this.setState({ newRootFolderPath: value }, () => { - this.props.onNewRootFolderSelect(value); - }); - } + this.setState({ newRootFolderPath: value }); + }; onAddRootFolderModalClose = () => { this.setState({ isAddNewRootFolderModalOpen: false }); - } + }; // // Render render() { const { - includeNoChange, - onNewRootFolderSelect, + value, ...otherProps } = this.props; @@ -75,17 +71,16 @@ class RootFolderSelectInput extends Component {
-
); @@ -94,16 +89,11 @@ class RootFolderSelectInput extends Component { RootFolderSelectInput.propTypes = { name: PropTypes.string.isRequired, + value: PropTypes.string, values: PropTypes.arrayOf(PropTypes.object).isRequired, isSaving: PropTypes.bool.isRequired, saveError: PropTypes.object, - includeNoChange: PropTypes.bool.isRequired, - onChange: PropTypes.func.isRequired, - onNewRootFolderSelect: PropTypes.func.isRequired -}; - -RootFolderSelectInput.defaultProps = { - includeNoChange: false + onChange: PropTypes.func.isRequired }; export default RootFolderSelectInput; diff --git a/frontend/src/Components/Form/RootFolderSelectInputConnector.js b/frontend/src/Components/Form/RootFolderSelectInputConnector.js index b76501dc1..dcc2b88a6 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputConnector.js +++ b/frontend/src/Components/Form/RootFolderSelectInputConnector.js @@ -2,21 +2,26 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { addRootFolder } from 'Store/Actions/rootFolderActions'; +import createRootFoldersSelector from 'Store/Selectors/createRootFoldersSelector'; import RootFolderSelectInput from './RootFolderSelectInput'; const ADD_NEW_KEY = 'addNew'; function createMapStateToProps() { return createSelector( - (state) => state.rootFolders, + createRootFoldersSelector(), + (state, { value }) => value, + (state, { includeMissingValue }) => includeMissingValue, (state, { includeNoChange }) => includeNoChange, - (rootFolders, includeNoChange) => { + (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, + (rootFolders, value, includeMissingValue, includeNoChange, includeNoChangeDisabled = true) => { const values = rootFolders.items.map((rootFolder) => { return { key: rootFolder.path, value: rootFolder.path, - freeSpace: rootFolder.freeSpace + name: rootFolder.name, + freeSpace: rootFolder.freeSpace, + isMissing: false }; }); @@ -24,6 +29,16 @@ function createMapStateToProps() { values.unshift({ key: 'noChange', value: 'No Change', + isDisabled: includeNoChangeDisabled, + isMissing: false + }); + } + + if (includeMissingValue && !values.find((v) => v.key === value)) { + values.push({ + key: value, + value, + isMissing: true, isDisabled: true }); } @@ -51,20 +66,12 @@ function createMapStateToProps() { ); } -function createMapDispatchToProps(dispatch, props) { - return { - dispatchAddRootFolder(path) { - dispatch(addRootFolder({ path })); - } - }; -} - class RootFolderSelectInputConnector extends Component { // // Lifecycle - componentWillMount() { + UNSAFE_componentWillMount() { const { value, values, @@ -95,11 +102,25 @@ class RootFolderSelectInputConnector extends Component { } } - // - // Listeners + componentDidUpdate(prevProps) { + const { + name, + value, + values, + onChange + } = this.props; - onNewRootFolderSelect = (path) => { - this.props.dispatchAddRootFolder(path); + if (prevProps.values === values) { + return; + } + + if (!value && values.length && values.some((v) => !!v.key && v.key !== ADD_NEW_KEY)) { + const defaultValue = values[0]; + + if (defaultValue.key !== ADD_NEW_KEY) { + onChange({ name, value: defaultValue.key }); + } + } } // @@ -107,7 +128,6 @@ class RootFolderSelectInputConnector extends Component { render() { const { - dispatchAddRootFolder, ...otherProps } = this.props; @@ -125,12 +145,11 @@ RootFolderSelectInputConnector.propTypes = { value: PropTypes.string, values: PropTypes.arrayOf(PropTypes.object).isRequired, includeNoChange: PropTypes.bool.isRequired, - onChange: PropTypes.func.isRequired, - dispatchAddRootFolder: PropTypes.func.isRequired + onChange: PropTypes.func.isRequired }; RootFolderSelectInputConnector.defaultProps = { includeNoChange: false }; -export default connect(createMapStateToProps, createMapDispatchToProps)(RootFolderSelectInputConnector); +export default connect(createMapStateToProps)(RootFolderSelectInputConnector); diff --git a/frontend/src/Components/Form/RootFolderSelectInputOption.css b/frontend/src/Components/Form/RootFolderSelectInputOption.css index d8b44fcad..f63cba8d8 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputOption.css +++ b/frontend/src/Components/Form/RootFolderSelectInputOption.css @@ -13,8 +13,24 @@ } } +.value { + display: flex; +} + +.artistFolder { + flex: 0 0 auto; + color: var(--disabledColor); +} + .freeSpace { margin-left: 15px; - color: $darkGray; + color: var(--darkGray); font-size: $smallFontSize; } + +.isMissing { + margin-left: 15px; + color: var(--dangerColor); + font-size: $smallFontSize; +} + diff --git a/frontend/src/Components/Form/RootFolderSelectInputOption.css.d.ts b/frontend/src/Components/Form/RootFolderSelectInputOption.css.d.ts new file mode 100644 index 000000000..41b5a15ac --- /dev/null +++ b/frontend/src/Components/Form/RootFolderSelectInputOption.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'artistFolder': string; + 'freeSpace': string; + 'isMissing': string; + 'isMobile': string; + 'optionText': string; + 'value': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/RootFolderSelectInputOption.js b/frontend/src/Components/Form/RootFolderSelectInputOption.js index a4db9cd82..b339c84e8 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputOption.js +++ b/frontend/src/Components/Form/RootFolderSelectInputOption.js @@ -1,20 +1,30 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; -import classNames from 'classnames'; import formatBytes from 'Utilities/Number/formatBytes'; import EnhancedSelectInputOption from './EnhancedSelectInputOption'; import styles from './RootFolderSelectInputOption.css'; function RootFolderSelectInputOption(props) { const { + id, value, + name, freeSpace, + isMissing, + artistFolder, isMobile, + isWindows, ...otherProps } = props; + const slashCharacter = isWindows ? '\\' : '/'; + + const text = name === '' ? value : `[${name}] ${value}`; + return ( @@ -23,23 +33,52 @@ function RootFolderSelectInputOption(props) { isMobile && styles.isMobile )} > -
{value}
+
+ {text} + + { + artistFolder && id !== 'addNew' ? +
+ {slashCharacter} + {artistFolder} +
: + null + } +
{ - freeSpace != null && + freeSpace == null ? + null :
{formatBytes(freeSpace)} Free
} + + { + isMissing ? +
+ Missing +
: + null + }
); } RootFolderSelectInputOption.propTypes = { + id: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, value: PropTypes.string.isRequired, freeSpace: PropTypes.number, - isMobile: PropTypes.bool.isRequired + isMissing: PropTypes.bool, + artistFolder: PropTypes.string, + isMobile: PropTypes.bool.isRequired, + isWindows: PropTypes.bool +}; + +RootFolderSelectInputOption.defaultProps = { + name: '' }; export default RootFolderSelectInputOption; diff --git a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css index 6b0cf9e4f..d248416d2 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css +++ b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css @@ -7,16 +7,26 @@ overflow: hidden; } -.path { +.pathContainer { @add-mixin truncate; - + display: flex; flex: 1 0 0; } +.path { + flex: 0 1 auto; +} + +.artistFolder { + @add-mixin truncate; + flex: 0 1 auto; + color: var(--disabledColor); +} + .freeSpace { flex: 0 0 auto; margin-left: 15px; - color: $gray; + color: var(--gray); text-align: right; font-size: $smallFontSize; } diff --git a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css.d.ts b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css.d.ts new file mode 100644 index 000000000..eb2ba85c7 --- /dev/null +++ b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'artistFolder': string; + 'freeSpace': string; + 'path': string; + 'pathContainer': string; + 'selectedValue': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.js b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.js index ffd769254..58e8efbd3 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.js +++ b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.js @@ -6,19 +6,37 @@ import styles from './RootFolderSelectInputSelectedValue.css'; function RootFolderSelectInputSelectedValue(props) { const { + name, value, freeSpace, + artistFolder, includeFreeSpace, + isWindows, ...otherProps } = props; + const slashCharacter = isWindows ? '\\' : '/'; + + const text = name === '' ? value : `[${name}] ${value}`; + return ( -
- {value} +
+
+ {text} +
+ + { + artistFolder ? +
+ {slashCharacter} + {artistFolder} +
: + null + }
{ @@ -32,12 +50,16 @@ function RootFolderSelectInputSelectedValue(props) { } RootFolderSelectInputSelectedValue.propTypes = { + name: PropTypes.string, value: PropTypes.string, freeSpace: PropTypes.number, + artistFolder: PropTypes.string, + isWindows: PropTypes.bool, includeFreeSpace: PropTypes.bool.isRequired }; RootFolderSelectInputSelectedValue.defaultProps = { + name: '', includeFreeSpace: true }; diff --git a/frontend/src/Components/Form/SelectInput.css.d.ts b/frontend/src/Components/Form/SelectInput.css.d.ts new file mode 100644 index 000000000..fe8fa3069 --- /dev/null +++ b/frontend/src/Components/Form/SelectInput.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'hasWarning': string; + 'isDisabled': string; + 'select': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/SelectInput.js b/frontend/src/Components/Form/SelectInput.js index 113d50a09..d43560134 100644 --- a/frontend/src/Components/Form/SelectInput.js +++ b/frontend/src/Components/Form/SelectInput.js @@ -1,6 +1,6 @@ +import classNames from 'classnames'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import classNames from 'classnames'; import styles from './SelectInput.css'; class SelectInput extends Component { @@ -13,7 +13,7 @@ class SelectInput extends Component { name: this.props.name, value: event.target.value }); - } + }; // // Render @@ -52,6 +52,7 @@ class SelectInput extends Component { const { key, value: optionValue, + isDisabled: optionIsDisabled = false, ...otherOptionProps } = option; @@ -59,9 +60,10 @@ class SelectInput extends Component { ); }) @@ -75,7 +77,7 @@ SelectInput.propTypes = { className: PropTypes.string, disabledClassName: PropTypes.string, name: PropTypes.string.isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.func]).isRequired, values: PropTypes.arrayOf(PropTypes.object).isRequired, isDisabled: PropTypes.bool, hasError: PropTypes.bool, diff --git a/frontend/src/Components/Form/SeriesTypeSelectInput.js b/frontend/src/Components/Form/SeriesTypeSelectInput.js index 4fe0a974c..822ae9931 100644 --- a/frontend/src/Components/Form/SeriesTypeSelectInput.js +++ b/frontend/src/Components/Form/SeriesTypeSelectInput.js @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; -import SelectInput from './SelectInput'; +import translate from 'Utilities/String/translate'; +import EnhancedSelectInput from './EnhancedSelectInput'; const artistTypeOptions = [ { key: 'standard', value: 'Standard' }, @@ -13,14 +14,15 @@ function SeriesTypeSelectInput(props) { const { includeNoChange, + includeNoChangeDisabled = true, includeMixed } = props; if (includeNoChange) { values.unshift({ key: 'noChange', - value: 'No Change', - disabled: true + value: translate('NoChange'), + isDisabled: includeNoChangeDisabled }); } @@ -28,12 +30,12 @@ function SeriesTypeSelectInput(props) { values.unshift({ key: 'mixed', value: '(Mixed)', - disabled: true + isDisabled: true }); } return ( - @@ -42,6 +44,7 @@ function SeriesTypeSelectInput(props) { SeriesTypeSelectInput.propTypes = { includeNoChange: PropTypes.bool.isRequired, + includeNoChangeDisabled: PropTypes.bool, includeMixed: PropTypes.bool.isRequired }; diff --git a/frontend/src/Components/Form/TagInput.css b/frontend/src/Components/Form/TagInput.css index 1516bfb1d..eeddab5b4 100644 --- a/frontend/src/Components/Form/TagInput.css +++ b/frontend/src/Components/Form/TagInput.css @@ -7,11 +7,19 @@ &.isFocused { outline: 0; - border-color: $inputFocusBorderColor; - box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; + border-color: var(--inputFocusBorderColor); + box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); } } +.hasError { + composes: hasError from '~Components/Form/Input.css'; +} + +.hasWarning { + composes: hasWarning from '~Components/Form/Input.css'; +} + .internalInput { flex: 1 1 0%; margin-left: 3px; @@ -20,4 +28,6 @@ width: 0%; height: 31px; border: none; + background-color: var(--inputBackground); + color: var(--textColor); } diff --git a/frontend/src/Components/Form/TagInput.css.d.ts b/frontend/src/Components/Form/TagInput.css.d.ts new file mode 100644 index 000000000..8b3b412a5 --- /dev/null +++ b/frontend/src/Components/Form/TagInput.css.d.ts @@ -0,0 +1,11 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'hasWarning': string; + 'input': string; + 'internalInput': string; + 'isFocused': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/TagInput.js b/frontend/src/Components/Form/TagInput.js index 45d972631..840d627f8 100644 --- a/frontend/src/Components/Form/TagInput.js +++ b/frontend/src/Components/Form/TagInput.js @@ -1,7 +1,7 @@ +import classNames from 'classnames'; import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import classNames from 'classnames'; import { kinds } from 'Helpers/Props'; import tagShape from 'Helpers/Props/Shapes/tagShape'; import AutoSuggestInput from './AutoSuggestInput'; @@ -49,7 +49,7 @@ class TagInput extends Component { _setAutosuggestRef = (ref) => { this._autosuggestRef = ref; - } + }; getSuggestionValue({ name }) { return name; @@ -57,7 +57,7 @@ class TagInput extends Component { shouldRenderSuggestions = (value) => { return value.length >= this.props.minQueryLength; - } + }; renderSuggestion({ name }) { return name; @@ -70,14 +70,26 @@ class TagInput extends Component { value: '', suggestions: [] }); - }, 250, { leading: true, trailing: false }) + }, 250, { leading: true, trailing: false }); // // Listeners + onTagEdit = ({ value, ...otherProps }) => { + const currentValue = this.state.value; + + if (currentValue && this.props.onTagReplace) { + this.props.onTagReplace(otherProps, { name: currentValue }); + } else { + this.props.onTagDelete(otherProps); + } + + this.setState({ value }); + }; + onInputContainerPress = () => { this._autosuggestRef.input.focus(); - } + }; onInputChange = (event, { newValue, method }) => { const value = _.isObject(newValue) ? newValue.name : newValue; @@ -85,7 +97,7 @@ class TagInput extends Component { if (method === 'type') { this.setState({ value }); } - } + }; onInputKeyDown = (event) => { const { @@ -100,9 +112,9 @@ class TagInput extends Component { suggestions } = this.state; - const keyCode = event.keyCode; + const key = event.key; - if (keyCode === 8 && !value.length) { + if (key === 'Backspace' && !value.length) { const index = tags.length - 1; if (index >= 0) { @@ -116,7 +128,7 @@ class TagInput extends Component { event.preventDefault(); } - if (delimiters.includes(keyCode)) { + if (delimiters.includes(key)) { const selectedIndex = this._autosuggestRef.highlightedSuggestionIndex; const tag = getTag(value, selectedIndex, suggestions, allowNew); @@ -125,11 +137,11 @@ class TagInput extends Component { event.preventDefault(); } } - } + }; onInputFocus = () => { this.setState({ isFocused: true }); - } + }; onInputBlur = () => { this.setState({ isFocused: false }); @@ -153,7 +165,7 @@ class TagInput extends Component { if (tag) { this.addTag(tag); } - } + }; onSuggestionsFetchRequested = ({ value }) => { const lowerCaseValue = value.toLowerCase(); @@ -170,16 +182,16 @@ class TagInput extends Component { }); this.setState({ suggestions }); - } + }; onSuggestionsClearRequested = () => { // Required because props aren't always rendered, but no-op // because we don't want to reset the paths after a path is selected. - } + }; onSuggestionSelected = (event, { suggestion }) => { this.addTag(suggestion); - } + }; // // Render @@ -188,6 +200,7 @@ class TagInput extends Component { const { tags, kind, + canEdit, tagComponent, onTagDelete } = this.props; @@ -199,17 +212,21 @@ class TagInput extends Component { kind={kind} inputProps={inputProps} isFocused={this.state.isFocused} + canEdit={canEdit} tagComponent={tagComponent} onTagDelete={onTagDelete} + onTagEdit={this.onTagEdit} onInputContainerPress={this.onInputContainerPress} /> ); - } + }; render() { const { className, inputContainerClassName, + hasError, + hasWarning, ...otherProps } = this.props; @@ -223,10 +240,12 @@ class TagInput extends Component { { const { @@ -116,7 +116,7 @@ class TagInputConnector extends Component { name, value: newValue }); - } + }; onTagCreated = (tag) => { const { @@ -128,7 +128,7 @@ class TagInputConnector extends Component { newValue.push(tag.id); this.props.onChange({ name, value: newValue }); - } + }; // // Render @@ -138,6 +138,7 @@ class TagInputConnector extends Component { ); diff --git a/frontend/src/Components/Form/TagInputInput.css b/frontend/src/Components/Form/TagInputInput.css index 292f1a089..ab9d08d61 100644 --- a/frontend/src/Components/Form/TagInputInput.css +++ b/frontend/src/Components/Form/TagInputInput.css @@ -1,8 +1,5 @@ .inputContainer { - top: -1px; - right: -1px; - bottom: -1px; - left: -1px; + inset: -1px; display: flex; align-items: start; flex-wrap: wrap; diff --git a/frontend/src/Components/Form/TagInputInput.css.d.ts b/frontend/src/Components/Form/TagInputInput.css.d.ts new file mode 100644 index 000000000..d0a03ef53 --- /dev/null +++ b/frontend/src/Components/Form/TagInputInput.css.d.ts @@ -0,0 +1,7 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'inputContainer': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/TagInputInput.js b/frontend/src/Components/Form/TagInputInput.js index 3e28830e9..86628b134 100644 --- a/frontend/src/Components/Form/TagInputInput.js +++ b/frontend/src/Components/Form/TagInputInput.js @@ -19,7 +19,7 @@ class TagInputInput extends Component { } onInputContainerPress(); - } + }; render() { const { @@ -28,15 +28,16 @@ class TagInputInput extends Component { tags, inputProps, kind, + canEdit, tagComponent: TagComponent, - onTagDelete + onTagDelete, + onTagEdit } = this.props; return (
{ @@ -47,8 +48,10 @@ class TagInputInput extends Component { index={index} tag={tag} kind={kind} + canEdit={canEdit} isLastTag={index === tags.length - 1} onDelete={onTagDelete} + onEdit={onTagEdit} /> ); }) @@ -67,8 +70,10 @@ TagInputInput.propTypes = { inputProps: PropTypes.object.isRequired, kind: PropTypes.oneOf(kinds.all).isRequired, isFocused: PropTypes.bool.isRequired, + canEdit: PropTypes.bool.isRequired, tagComponent: PropTypes.elementType.isRequired, onTagDelete: PropTypes.func.isRequired, + onTagEdit: PropTypes.func.isRequired, onInputContainerPress: PropTypes.func.isRequired }; diff --git a/frontend/src/Components/Form/TagInputTag.css b/frontend/src/Components/Form/TagInputTag.css index bf08e13fc..7e66a4d12 100644 --- a/frontend/src/Components/Form/TagInputTag.css +++ b/frontend/src/Components/Form/TagInputTag.css @@ -1,5 +1,34 @@ .tag { - composes: link from '~Components/Link/Link.css'; - + display: flex; + justify-content: center; + flex-direction: column; + max-width: 100%; height: 31px; } + +.link { + max-width: 100%; +} + +.linkWithEdit { + max-width: calc(100% - 9px - 4px - 2px); +} + +.editContainer { + display: inline-block; + margin-left: 4px; + padding-left: 2px; + border-left: 1px solid #eee; +} + +.editButton { + composes: button from '~Components/Link/IconButton.css'; + + width: 9px; +} + +.label { + composes: label from '~Components/Label.css'; + + max-width: 100%; +} diff --git a/frontend/src/Components/Form/TagInputTag.css.d.ts b/frontend/src/Components/Form/TagInputTag.css.d.ts new file mode 100644 index 000000000..510189d2c --- /dev/null +++ b/frontend/src/Components/Form/TagInputTag.css.d.ts @@ -0,0 +1,12 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'editButton': string; + 'editContainer': string; + 'label': string; + 'link': string; + 'linkWithEdit': string; + 'tag': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/TagInputTag.js b/frontend/src/Components/Form/TagInputTag.js index f5935ad7b..004381924 100644 --- a/frontend/src/Components/Form/TagInputTag.js +++ b/frontend/src/Components/Form/TagInputTag.js @@ -1,9 +1,10 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import { kinds } from 'Helpers/Props'; -import tagShape from 'Helpers/Props/Shapes/tagShape'; import Label from 'Components/Label'; +import IconButton from 'Components/Link/IconButton'; import Link from 'Components/Link/Link'; +import { icons, kinds } from 'Helpers/Props'; +import tagShape from 'Helpers/Props/Shapes/tagShape'; import styles from './TagInputTag.css'; class TagInputTag extends Component { @@ -22,7 +23,21 @@ class TagInputTag extends Component { index, id: tag.id }); - } + }; + + onEdit = () => { + const { + index, + tag, + onEdit + } = this.props; + + onEdit({ + index, + id: tag.id, + value: tag.name + }); + }; // // Render @@ -30,18 +45,41 @@ class TagInputTag extends Component { render() { const { tag, - kind + kind, + canEdit } = this.props; + return ( - -
); } } @@ -50,7 +88,9 @@ TagInputTag.propTypes = { index: PropTypes.number.isRequired, tag: PropTypes.shape(tagShape), kind: PropTypes.oneOf(kinds.all).isRequired, - onDelete: PropTypes.func.isRequired + canEdit: PropTypes.bool.isRequired, + onDelete: PropTypes.func.isRequired, + onEdit: PropTypes.func.isRequired }; export default TagInputTag; diff --git a/frontend/src/Components/Form/TagSelectInputConnector.js b/frontend/src/Components/Form/TagSelectInputConnector.js new file mode 100644 index 000000000..23afe6da1 --- /dev/null +++ b/frontend/src/Components/Form/TagSelectInputConnector.js @@ -0,0 +1,102 @@ +import _ from 'lodash'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; +import { createSelector } from 'reselect'; +import TagInput from './TagInput'; + +function createMapStateToProps() { + return createSelector( + (state, { value }) => value, + (state, { values }) => values, + (tags, tagList) => { + const sortedTags = _.sortBy(tagList, 'value'); + + return { + tags: tags.reduce((acc, tag) => { + const matchingTag = _.find(tagList, { key: tag }); + + if (matchingTag) { + acc.push({ + id: tag, + name: matchingTag.value + }); + } + + return acc; + }, []), + + tagList: sortedTags.map(({ key: id, value: name }) => { + return { + id, + name + }; + }), + + allTags: sortedTags + }; + } + ); +} + +class TagSelectInputConnector extends Component { + + // + // Listeners + + onTagAdd = (tag) => { + const { + name, + value, + allTags + } = this.props; + + const existingTag =_.some(allTags, { key: tag.id }); + + const newValue = value.slice(); + + if (existingTag) { + newValue.push(tag.id); + } + + this.props.onChange({ name, value: newValue }); + }; + + onTagDelete = ({ index }) => { + const { + name, + value + } = this.props; + + const newValue = value.slice(); + newValue.splice(index, 1); + + this.props.onChange({ + name, + value: newValue + }); + }; + + // + // Render + + render() { + return ( + + ); + } +} + +TagSelectInputConnector.propTypes = { + name: PropTypes.string.isRequired, + value: PropTypes.arrayOf(PropTypes.number).isRequired, + values: PropTypes.arrayOf(PropTypes.object).isRequired, + allTags: PropTypes.arrayOf(PropTypes.object).isRequired, + onChange: PropTypes.func.isRequired +}; + +export default connect(createMapStateToProps)(TagSelectInputConnector); diff --git a/frontend/src/Components/Form/TextArea.css b/frontend/src/Components/Form/TextArea.css new file mode 100644 index 000000000..7a4961c07 --- /dev/null +++ b/frontend/src/Components/Form/TextArea.css @@ -0,0 +1,19 @@ +.input { + composes: input from '~Components/Form/Input.css'; + + flex-grow: 1; + min-height: 200px; + resize: vertical; +} + +.readOnly { + background-color: #eee; +} + +.hasError { + composes: hasError from '~Components/Form/Input.css'; +} + +.hasWarning { + composes: hasWarning from '~Components/Form/Input.css'; +} diff --git a/frontend/src/Components/Form/TextArea.css.d.ts b/frontend/src/Components/Form/TextArea.css.d.ts new file mode 100644 index 000000000..59c6aad69 --- /dev/null +++ b/frontend/src/Components/Form/TextArea.css.d.ts @@ -0,0 +1,10 @@ +// This file is automatically generated. +// Please do not change this file! +interface CssExports { + 'hasError': string; + 'hasWarning': string; + 'input': string; + 'readOnly': string; +} +export const cssExports: CssExports; +export default cssExports; diff --git a/frontend/src/Components/Form/TextArea.js b/frontend/src/Components/Form/TextArea.js new file mode 100644 index 000000000..44fd3a249 --- /dev/null +++ b/frontend/src/Components/Form/TextArea.js @@ -0,0 +1,172 @@ +import classNames from 'classnames'; +import PropTypes from 'prop-types'; +import React, { Component } from 'react'; +import styles from './TextArea.css'; + +class TextArea extends Component { + + // + // Lifecycle + + constructor(props, context) { + super(props, context); + + this._input = null; + this._selectionStart = null; + this._selectionEnd = null; + this._selectionTimeout = null; + this._isMouseTarget = false; + } + + componentDidMount() { + window.addEventListener('mouseup', this.onDocumentMouseUp); + } + + componentWillUnmount() { + window.removeEventListener('mouseup', this.onDocumentMouseUp); + + if (this._selectionTimeout) { + this._selectionTimeout = clearTimeout(this._selectionTimeout); + } + } + + // + // Control + + setInputRef = (ref) => { + this._input = ref; + }; + + selectionChange() { + if (this._selectionTimeout) { + this._selectionTimeout = clearTimeout(this._selectionTimeout); + } + + this._selectionTimeout = setTimeout(() => { + const selectionStart = this._input.selectionStart; + const selectionEnd = this._input.selectionEnd; + + const selectionChanged = ( + this._selectionStart !== selectionStart || + this._selectionEnd !== selectionEnd + ); + + this._selectionStart = selectionStart; + this._selectionEnd = selectionEnd; + + if (this.props.onSelectionChange && selectionChanged) { + this.props.onSelectionChange(selectionStart, selectionEnd); + } + }, 10); + } + + // + // Listeners + + onChange = (event) => { + const { + name, + onChange + } = this.props; + + const payload = { + name, + value: event.target.value + }; + + onChange(payload); + }; + + onFocus = (event) => { + if (this.props.onFocus) { + this.props.onFocus(event); + } + + this.selectionChange(); + }; + + onKeyUp = () => { + this.selectionChange(); + }; + + onMouseDown = () => { + this._isMouseTarget = true; + }; + + onMouseUp = () => { + this.selectionChange(); + }; + + onDocumentMouseUp = () => { + if (this._isMouseTarget) { + this.selectionChange(); + } + + this._isMouseTarget = false; + }; + + // + // Render + + render() { + const { + className, + readOnly, + autoFocus, + placeholder, + name, + value, + hasError, + hasWarning, + onBlur + } = this.props; + + return ( +