diff --git a/.devcontainer/Lidarr.code-workspace b/.devcontainer/Lidarr.code-workspace deleted file mode 100644 index a46158e44..000000000 --- a/.devcontainer/Lidarr.code-workspace +++ /dev/null @@ -1,13 +0,0 @@ -// 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 deleted file mode 100644 index d0fa03d5f..000000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,19 +0,0 @@ -// 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 57d971bc4..5e19cc2d6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,275 +2,14 @@ # editorconfig.org root = true -# NOTE: Requires **VS2019 16.3** or later - -# Stylecop.ruleset -# Description: Rules for Lidarr - -# Code files -[*.cs] +[*.{cs}] charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true indent_style = space indent_size = 4 -# 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}] +[*.{js,html,js,hbs,less,css}] charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true diff --git a/.esprintrc b/.esprintrc new file mode 100644 index 000000000..9330e00d1 --- /dev/null +++ b/.esprintrc @@ -0,0 +1,9 @@ +{ + "paths": [ + "frontend/src/**/*.js" + ], + "ignored": [ + "**/node_modules/**/*" + ], + "port": 5004 +} diff --git a/.gitattributes b/.gitattributes index d98f8fb96..2998943f4 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,9 @@ # Auto detect text files and perform LF normalization -* text=auto +*text eol=lf # Explicitly set bash scripts to have unix endings *.sh text eol=lf -distribution/osx/Lidarr text eol=lf +macOS/Lidarr text eol=lf # Custom for Visual Studio *.cs diff=csharp diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 49c3e2d71..8988a141d 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: lidarr # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: # 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 new file mode 100644 index 000000000..87d054fc8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,41 @@ + + + +## 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 new file mode 100644 index 000000000..985b66efd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,32 @@ +--- +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 deleted file mode 100644 index 491815370..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,83 +0,0 @@ -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 deleted file mode 100644 index 880a682f4..000000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -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 new file mode 100644 index 000000000..99bb9a009 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,7 @@ +--- +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 new file mode 100644 index 000000000..066b2d920 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +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 deleted file mode 100644 index ef142b0ad..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ /dev/null @@ -1,38 +0,0 @@ -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 2fcae05cc..e0d682009 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,16 +1,14 @@ #### Database Migration -YES - XXXX | NO +YES | NO #### Description A few sentences describing the overall goals of the pull request's commits. -#### Screenshot (if UI related) - #### Todos - [ ] Tests -- [ ] Translation Keys (./src/NzbDrone.Core/Localization/Core/en.json) -- [ ] [Wiki Updates](https://wiki.servarr.com) +- [ ] Documentation + #### 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 deleted file mode 100644 index f33a02cd1..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -# 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 deleted file mode 100644 index 3979401b1..000000000 --- a/.github/label-actions.yml +++ /dev/null @@ -1,16 +0,0 @@ -# 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 deleted file mode 100644 index 4203e4418..000000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,28 +0,0 @@ -'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 deleted file mode 100644 index a6246a6b3..000000000 --- a/.github/workflows/label-actions.yml +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index 857cfb4a7..000000000 --- a/.github/workflows/labeler.yml +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index 1d50cb1f1..000000000 --- a/.github/workflows/lock.yml +++ /dev/null @@ -1,21 +0,0 @@ -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 a5d6bb7c8..ed6772d69 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ src/**/[Oo]bj/ *.user *.sln.docstates .vs/ -.vscode/ # Build results *_i.c @@ -85,6 +84,7 @@ TestResults [Tt]est[Rr]esult* *.Cache ClientBin +[Ss]tyle[Cc]op.* ~$* *.dbmdl Generated_Code #added for RIA/Silverlight projects @@ -121,49 +121,25 @@ _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 -# macOS metadata files +#OS X metadata files ._* .DS_Store _start _temp_*/**/* -# 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/ +## Merge any idea folder +*/**/.idea +*.iml diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 7a36fefe1..000000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "recommendations": [ - "esbenp.prettier-vscode", - "ms-dotnettools.csdevkit", - "ms-vscode-remote.remote-containers" - ] -} diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 74b8d418b..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "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 deleted file mode 100644 index 4b3b00b89..000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "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 deleted file mode 100644 index 52e67a0a4..000000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,132 +0,0 @@ -# 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 36d901f18..fa439931f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,13 +1,50 @@ -# 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. -This file has been moved to the wiki for the latest details please see the [contributing wiki page](https://wiki.servarr.com/lidarr/contributing). +## Documentation ## +Setup guides, FAQ, the more information we have on the wiki the better. -## Documentation +## Development ## -Setup guides, [FAQ](https://wiki.servarr.com/lidarr/faq), the more information we have on the [wiki](https://wiki.servarr.com/lidarr) the better. +### 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. -## Development +### Getting started ### -See the [Wiki Page](https://wiki.servarr.com/lidarr/contributing) +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. diff --git a/Logo/dottrace.svg b/Logo/dottrace.svg deleted file mode 100644 index b879517cd..000000000 --- a/Logo/dottrace.svg +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Logo/jetbrains.svg b/Logo/jetbrains.svg deleted file mode 100644 index 75d4d2177..000000000 --- a/Logo/jetbrains.svg +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Logo/resharper.svg b/Logo/resharper.svg deleted file mode 100644 index 24c987a78..000000000 --- a/Logo/resharper.svg +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Logo/rider.svg b/Logo/rider.svg deleted file mode 100644 index 82da35b0b..000000000 --- a/Logo/rider.svg +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - rider - - - - - - - - - - - - - - diff --git a/Logo/webstorm.svg b/Logo/webstorm.svg deleted file mode 100644 index 39ab7eb97..000000000 --- a/Logo/webstorm.svg +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/README.md b/README.md index 7a6da3158..746516867 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,13 @@ # 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) -[![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) +[![BrowserStack Status](https://automate.browserstack.com/badge.svg?badge_key=Z1I4SVZOMitOdENIMHpkMlN3djJiRVJkTzBpdUJ5Q2ZtWVhnYTFvYS9qcz0tLTM5THJZRkVCZlk0blp5cXFBK1BDYWc9PQ==--67f41b00af03ab78148d3d711f22ca42ab348a52)](https://automate.browserstack.com/public-build/Z1I4SVZOMitOdENIMHpkMlN3djJiRVJkTzBpdUJ5Q2ZtWVhnYTFvYS9qcz0tLTM5THJZRkVCZlk0blp5cXFBK1BDYWc9PQ==--67f41b00af03ab78148d3d711f22ca42ab348a52) +[![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/lidarr.svg)](https://github.com/lidarr/Lidarr/wiki/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. @@ -26,52 +22,46 @@ 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 -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) +[![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) ## 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-2021 +* Copyright 2010-2019 diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 765e24fbc..000000000 --- a/SECURITY.md +++ /dev/null @@ -1,8 +0,0 @@ -# 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 new file mode 100644 index 000000000..a12a1e32f --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,3 @@ +skip_commits: + files: + - '**/**' \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 85d13499a..8fcb8f6c8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -7,189 +7,100 @@ variables: outputFolder: './_output' artifactsFolder: './_artifacts' testsFolder: './_tests' - yarnCacheFolder: $(Pipeline.Workspace)/.yarn - nugetCacheFolder: $(Pipeline.Workspace)/.nuget/packages - majorVersion: '2.13.3' + majorVersion: '0.7.2' minorVersion: $[counter('minorVersion', 1076)] lidarrVersion: '$(majorVersion).$(minorVersion)' buildName: '$(Build.SourceBranchName).$(lidarrVersion)' - 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' + 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' trigger: branches: include: - develop - master - paths: - exclude: - - .github - - src/Lidarr.Api.*/openapi.json pr: - branches: - include: - - develop - paths: - exclude: - - .github - - src/NzbDrone.Core/Localization/Core - - src/Lidarr.Api.*/openapi.json +- develop 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: ${{ variables.linuxImage }} - enableAnalysis: 'true' + imageName: 'ubuntu-16.04' Mac: osName: 'Mac' - imageName: ${{ variables.macImage }} - enableAnalysis: 'false' + imageName: 'macos-10.14' Windows: osName: 'Windows' - imageName: ${{ variables.windowsImage }} - enableAnalysis: 'false' + imageName: 'vs2017-win2016' 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 - - 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 + - bash: ./build.sh --backend 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)/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 + - publish: $(testsFolder) + artifact: '$(osName)Tests' + displayName: Publish Test Package condition: and(succeeded(), eq(variables['osName'], 'Windows')) - stage: Build_Frontend displayName: Frontend - dependsOn: Setup + dependsOn: [] + jobs: - job: Build strategy: matrix: Linux: osName: 'Linux' - imageName: ${{ variables.linuxImage }} + imageName: 'ubuntu-16.04' Mac: osName: 'Mac' - imageName: ${{ variables.macImage }} + imageName: 'macos-10.14' Windows: osName: 'Windows' - imageName: ${{ variables.windowsImage }} + imageName: 'vs2017-win2016' pool: vmImage: $(imageName) steps: - - task: UseNode@1 + - task: NodeTool@0 displayName: Set Node.js version inputs: - version: $(nodeVersion) + versionSpec: '10.x' - 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 --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: Installer dependsOn: - Build_Backend @@ -198,7 +109,7 @@ stages: - job: Windows_Installer displayName: Create Installer pool: - vmImage: ${{ variables.windowsImage }} + vmImage: 'vs2017-win2016' steps: - checkout: self fetchDepth: 1 @@ -214,11 +125,12 @@ stages: artifactName: WindowsFrontend targetPath: _output displayName: Fetch Frontend + - bash: ./build.sh --packages + displayName: Create Packages - bash: | - ./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 + ./setup/inno/ISCC.exe "./setup/lidarr.iss" + cp ./setup/output/Lidarr.*windows.exe ${BUILD_ARTIFACTSTAGINGDIRECTORY}/${WINDOWSINSTALLER} + displayName: Create Windows installer - publish: $(Build.ArtifactStagingDirectory) artifact: 'WindowsInstaller' displayName: Publish Installer @@ -231,7 +143,7 @@ stages: - job: Other_Packages displayName: Create Standard Packages pool: - vmImage: ${{ variables.linuxImage }} + vmImage: 'ubuntu-16.04' steps: - checkout: self fetchDepth: 1 @@ -247,128 +159,51 @@ stages: artifactName: WindowsFrontend targetPath: _output displayName: Fetch Frontend - - bash: ./build.sh --packages --enable-extra-platforms + - bash: ./build.sh --packages displayName: Create Packages - bash: | - 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 + 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 - task: ArchiveFiles@2 - displayName: Create win-x64 zip + displayName: Create Windows zip inputs: - archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).windows-core-x64.zip' + archiveFile: '$(Build.ArtifactStagingDirectory)/$(windowsZip)' archiveType: 'zip' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/win-x64/net6.0 + rootFolderOrFile: $(artifactsFolder)/windows - task: ArchiveFiles@2 - displayName: Create win-x86 zip + displayName: Create MacOS app inputs: - archiveFile: '$(Build.ArtifactStagingDirectory)/Lidarr.$(buildName).windows-core-x86.zip' + archiveFile: '$(Build.ArtifactStagingDirectory)/$(macOsApp)' archiveType: 'zip' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/win-x86/net6.0 + rootFolderOrFile: $(artifactsFolder)/macos-app - task: ArchiveFiles@2 - displayName: Create osx-x64 app + displayName: Create MacOS tar inputs: - 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' + archiveFile: '$(Build.ArtifactStagingDirectory)/$(macOsTar)' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - rootFolderOrFile: $(artifactsFolder)/osx-x64/net6.0 + rootFolderOrFile: $(artifactsFolder)/macos - task: ArchiveFiles@2 - displayName: Create osx-arm64 app + displayName: Create Linux tar inputs: - 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' + archiveFile: '$(Build.ArtifactStagingDirectory)/$(linuxTar)' archiveType: 'tar' tarCompression: 'gz' includeRootFolder: false - 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 + rootFolderOrFile: $(artifactsFolder)/linux - publish: $(Build.ArtifactStagingDirectory) artifact: 'Packages' displayName: Publish Packages - bash: | echo "Uploading source maps to sentry" curl -sL https://sentry.io/get-cli/ | bash - RELEASENAME="Lidarr@${LIDARRVERSION}-${BUILD_SOURCEBRANCHNAME}" + RELEASENAME="${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}" @@ -377,10 +212,6 @@ stages: 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 @@ -389,152 +220,101 @@ stages: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) ) env: - SENTRY_AUTH_TOKEN: $(sentryAuthTokenServarr) + SENTRY_AUTH_TOKEN: $(sentryAuthToken) 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: - MacCore: - osName: 'Mac' - testName: 'osx-x64' - poolName: 'Azure Pipelines' - imageName: ${{ variables.macImage }} - WindowsCore: + Windows: osName: 'Windows' - 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: + imageName: 'vs2017-win2016' 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: '$(testName)-tests' + artifactName: WindowsTests targetPath: $(testsFolder) - powershell: Set-Service SCardSvr -StartupType Manual displayName: Enable Windows Test Service condition: and(succeeded(), eq(variables['osName'], 'Windows')) - bash: | + SYMLINK=5_18_1 + MONOPREFIX=/Library/Frameworks/Mono.framework/Versions/$SYMLINK + echo "##vso[task.setvariable variable=MONOPREFIX;]$MONOPREFIX" + 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" chmod a+x _tests/fpcalc - displayName: Make fpcalc Executable - 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: Set Mono Version and make fpcalc Executable + condition: and(succeeded(), eq(variables['osName'], 'Mac')) + - task: Bash@3 displayName: Run Tests env: TEST_DIR: $(Build.SourcesDirectory)/_tests + inputs: + targetType: 'filePath' + filePath: '$(testsFolder)/test.sh' + arguments: '$(osName) Unit Test' - task: PublishTestResults@2 displayName: Publish Test Results inputs: testResultsFormat: 'NUnit' testResultsFiles: '**/TestResult.xml' - testRunTitle: '$(testName) Unit Tests' + testRunTitle: '$(osName) Unit Tests' failTaskOnFailedTests: true - job: Unit_Docker displayName: Unit Docker - dependsOn: Prepare - condition: and(succeeded(), eq(dependencies.Prepare.outputs['setVar.backendNotUpdated'], '0')) strategy: matrix: - 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 + mono518: + testName: 'Mono 5.18' + containerImage: servarr/testimages:mono-5.18 + mono520: + testName: 'Mono 5.20' + containerImage: servarr/testimages:mono-5.20 + mono600: + testName: 'Mono 6.0' + containerImage: servarr/testimages:mono-6.10 + mono604: + testName: 'Mono 6.4' + containerImage: servarr/testimages:mono-6.12 pool: - vmImage: ${{ variables.linuxImage }} - + vmImage: 'ubuntu-16.04' + container: $[ variables['containerImage'] ] timeoutInMinutes: 10 - + 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')) + - bash: mono --version + displayName: Check Mono version - checkout: none - task: DownloadPipelineArtifact@2 displayName: Download Test Artifact inputs: buildType: 'current' - artifactName: $(artifactName) + artifactName: WindowsTests 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 + - task: Bash@3 displayName: Run Tests + inputs: + targetType: 'filePath' + filePath: '$(testsFolder)/test.sh' + arguments: 'Linux Unit Test' - task: PublishTestResults@2 displayName: Publish Test Results inputs: @@ -543,174 +323,38 @@ stages: 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: + Windows: 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' + imageName: 'vs2017-win2016' + pattern: 'Lidarr.**.windows.zip' pool: vmImage: $(imageName) - + steps: - - task: UseDotNet@2 - displayName: 'Install .net core' - inputs: - version: $(dotnetVersion) + - bash: | + SYMLINK=5_18_1 + MONOPREFIX=/Library/Frameworks/Mono.framework/Versions/$SYMLINK + echo "##vso[task.setvariable variable=MONOPREFIX;]$MONOPREFIX" + 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')) - checkout: none - task: DownloadPipelineArtifact@2 displayName: Download Test Artifact inputs: buildType: 'current' - artifactName: '$(testName)-tests' + artifactName: WindowsTests targetPath: $(testsFolder) - task: DownloadPipelineArtifact@2 displayName: Download Build Artifact @@ -721,236 +365,63 @@ 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 - - bash: | - chmod a+x ${TESTSFOLDER}/test.sh - ${TESTSFOLDER}/test.sh ${OSNAME} Integration Test + - task: Bash@3 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: '$(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' + testRunTitle: '$(osName) 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' + mono518: + testName: 'Mono 5.18' + containerImage: servarr/testimages:mono-5.18 + mono520: + testName: 'Mono 5.20' + containerImage: servarr/testimages:mono-5.20 + mono600: + testName: 'Mono 6.0' + containerImage: servarr/testimages:mono-6.10 + mono604: + testName: 'Mono 6.4' + containerImage: servarr/testimages:mono-6.12 + + variables: + pattern: 'Lidarr.**.linux.tar.gz' + pool: - vmImage: ${{ variables.linuxImage }} + vmImage: 'ubuntu-16.04' 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')) + - bash: mono --version + displayName: Check Mono version - checkout: none - task: DownloadPipelineArtifact@2 displayName: Download Test Artifact inputs: buildType: 'current' - artifactName: $(artifactName) + artifactName: WindowsTests targetPath: $(testsFolder) - task: DownloadPipelineArtifact@2 displayName: Download Build Artifact @@ -961,17 +432,20 @@ 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/ + ls -lR displayName: Move Package Contents - - bash: | - chmod a+x ${TESTSFOLDER}/test.sh - ${TESTSFOLDER}/test.sh Linux Integration Test + - task: Bash@3 displayName: Run Integration Tests + inputs: + targetType: 'filePath' + filePath: '$(testsFolder)/test.sh' + arguments: Linux Integration Test - task: PublishTestResults@2 inputs: testResultsFormat: 'NUnit' @@ -983,44 +457,37 @@ stages: - stage: Automation displayName: Automation dependsOn: Packages - + jobs: - job: Automation strategy: matrix: Linux: osName: 'Linux' - artifactName: 'linux-x64' - imageName: ${{ variables.linuxImage }} - pattern: 'Lidarr.*.linux-core-x64.tar.gz' + imageName: 'ubuntu-16.04' + pattern: 'Lidarr.**.linux.tar.gz' failBuild: true Mac: osName: 'Mac' - artifactName: 'osx-x64' - imageName: ${{ variables.macImage }} - pattern: 'Lidarr.*.osx-core-x64.tar.gz' - failBuild: true + imageName: 'macos-10.14' # Fails due to firefox not being installed on image + pattern: 'Lidarr.**.osx.tar.gz' + failBuild: false Windows: osName: 'Windows' - artifactName: 'win-x64' - imageName: ${{ variables.windowsImage }} - pattern: 'Lidarr.*.windows-core-x64.zip' + imageName: 'vs2017-win2016' + pattern: 'Lidarr.**.windows.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: '$(artifactName)-tests' + artifactName: WindowsTests targetPath: $(testsFolder) - task: DownloadPipelineArtifact@2 displayName: Download Build Artifact @@ -1031,7 +498,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: | @@ -1039,20 +506,26 @@ stages: cp -r -v ${BUILD_ARTIFACTSTAGINGDIRECTORY}/bin/Lidarr/. ./bin/ displayName: Move Package Contents - bash: | - chmod a+x ${TESTSFOLDER}/test.sh - ${TESTSFOLDER}/test.sh ${OSNAME} Automation Test + 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 displayName: Run Automation Tests - - task: CopyFiles@2 - displayName: 'Copy Screenshot to: $(Build.ArtifactStagingDirectory)' inputs: - 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')) + targetType: 'filePath' + filePath: '$(testsFolder)/test.sh' + arguments: $(osName) Automation Test - task: PublishTestResults@2 inputs: testResultsFormat: 'NUnit' @@ -1062,208 +535,87 @@ stages: displayName: Publish Test Results - stage: Analyze - dependsOn: - - Setup + dependsOn: [] 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 }} + imageName: 'ubuntu-16.04' Windows: osName: 'Windows' - imageName: ${{ variables.windowsImage }} + imageName: 'vs2017-win2016' pool: vmImage: $(imageName) steps: - - task: UseNode@1 + - task: NodeTool@0 displayName: Set Node.js version inputs: - version: $(nodeVersion) + versionSpec: '10.x' - 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: ${{ variables.windowsImage }} + vmImage: vs2017-win2016 steps: - checkout: self # Need history for Sonar analysis - - task: SonarCloudPrepare@3 + - task: SonarCloudPrepare@1 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@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')) + - task: SonarCloudAnalyze@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: ${{ variables.windowsImage }} - + vmImage: vs2017-win2016 steps: - - task: UseDotNet@2 - displayName: 'Install .net core' - inputs: - version: $(dotnetVersion) - checkout: self # Need history for Sonar analysis submodules: true - - powershell: Set-Service SCardSvr -StartupType Manual - displayName: Enable Windows Test Service - - task: SonarCloudPrepare@3 - condition: eq(variables['System.PullRequest.IsFork'], 'False') + - task: SonarCloudPrepare@1 inputs: SonarCloud: 'SonarCloud' organization: 'lidarr' - scannerMode: 'dotnet' + scannerMode: 'MSBuild' 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/**/* - sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/CoverageResults/**/coverage.opencover.xml + sonar.coverage.exclusions=**/Lidarr.Api.V1/**/*,**/MonoTorrent/**/*,**/Marr.Data/**/* + sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/_tests/CoverageResults/coverage.opencover.xml sonar.cs.nunit.reportsPaths=$(Build.SourcesDirectory)/TestResult.xml - - bash: | - ./build.sh --backend -f net6.0 -r win-x64 - TEST_DIR=_tests/net6.0/win-x64/publish/ ./test.sh Windows Unit Coverage + - bash: ./build.sh --backend + displayName: Build Lidarr Backend + - task: Bash@3 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: - 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) - + 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 diff --git a/build.sh b/build.sh index ca2ab01ef..5756f1b00 100755 --- a/build.sh +++ b/build.sh @@ -1,9 +1,35 @@ -#! /usr/bin/env bash -set -e +#! /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 -outputFolder='_output' -testPackageFolder='_tests' -artifactsFolder="_artifacts"; +#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 +} ProgressStart() { @@ -19,42 +45,74 @@ UpdateVersionNumber() { if [ "$LIDARRVERSION" != "" ]; then echo "Updating Version Info" - 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 + 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 fi } -EnableExtraPlatformsInSDK() +CleanFolder() { - 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 + local path=$1 + local keepConfigFiles=$2 + + find $path -name "*.transform" -exec rm "{}" \; + + if [ $keepConfigFiles != true ] ; then + find $path -name "*.dll.config" -exec rm "{}" \; 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 "{}" \; } -EnableExtraPlatforms() +BuildWithMSBuild() { - 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 + 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 } LintUI() { ProgressStart 'ESLint' - yarn lint + CheckExitCode yarn lint ProgressEnd 'ESLint' ProgressStart 'Stylelint' - if [ "$os" = "windows" ]; then - yarn stylelint-windows + if [ $runtime = "dotnet" ] ; then + CheckExitCode yarn stylelint-windows else - yarn stylelint-linux + CheckExitCode yarn stylelint-linux fi ProgressEnd 'Stylelint' } @@ -66,23 +124,19 @@ Build() rm -rf $outputFolder rm -rf $testPackageFolder - slnFile=src/Lidarr.sln - - if [ $os = "windows" ]; then - platform=Windows + if [ $runtime = "dotnet" ] ; then + BuildWithMSBuild else - platform=Posix + BuildWithXbuild fi - dotnet clean $slnFile -c Debug - dotnet clean $slnFile -c Release + CleanFolder $outputFolder false - 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 + echo "Removing Mono.Posix.dll" + rm $outputFolder/Mono.Posix.dll + + echo "Adding LICENSE.md" + cp LICENSE.md $outputFolder ProgressEnd 'Build' } @@ -90,204 +144,167 @@ Build() YarnInstall() { ProgressStart 'yarn install' - yarn install --frozen-lockfile --network-timeout 120000 + yarn install + #npm-cache install npm || CheckExitCode npm install --no-optional --no-bin-links ProgressEnd 'yarn install' } -RunWebpack() +RunGulp() { - ProgressStart 'Running webpack' - yarn run build --env production - ProgressEnd 'Running webpack' + ProgressStart 'Running gulp' + CheckExitCode yarn run build --production + ProgressEnd 'Running gulp' } -PackageFiles() +PackageMono() { - local folder="$1" - local framework="$2" - local runtime="$3" + ProgressStart 'Creating Mono Package' - 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 + rm -rf $outputFolderLinux - echo "Adding LICENSE" - cp LICENSE.md $folder -} + echo "Copying Binaries" + cp -r $outputFolder $outputFolderLinux -PackageLinux() -{ - local framework="$1" - local runtime="$2" - - ProgressStart "Creating $runtime Package for $framework" - - local folder=$artifactsFolder/$runtime/$framework/Lidarr - - PackageFiles "$folder" "$framework" "$runtime" + echo "Replacing System.Numerics.Vectors.dll" + cp $sourceFolder/Libraries/Mono/System.Numerics.Vectors.dll $outputFolderLinux echo "Removing Service helpers" - rm -f $folder/ServiceUninstall.* - rm -f $folder/ServiceInstall.* + 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 echo "Removing Lidarr.Windows" - rm $folder/Lidarr.Windows.* + rm $outputFolderLinux/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 + cp $outputFolderLinux/Lidarr.Mono.* $updateFolderMono - ProgressEnd "Creating $runtime Package for $framework" + ProgressEnd 'Creating Mono Package' } PackageMacOS() { - local framework="$1" - local runtime="$2" - - ProgressStart "Creating $runtime Package for $framework" + ProgressStart 'Creating MacOS Package' - local folder=$artifactsFolder/$runtime/$framework/Lidarr + rm -rf $outputFolderMacOS + mkdir $outputFolderMacOS - PackageFiles "$folder" "$framework" "$runtime" + echo "Adding Startup script" + cp ./macOS/Lidarr $outputFolderMacOS - echo "Removing Service helpers" - rm -f $folder/ServiceUninstall.* - rm -f $folder/ServiceInstall.* + echo "Copying Binaries" + cp -r $outputFolderLinux/* $outputFolderMacOS + cp $outputFolder/fpcalc $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 + echo "Adding sqlite dylibs" + cp $sourceFolder/Libraries/Sqlite/*.dylib $outputFolderMacOS ProgressEnd 'Creating MacOS Package' } PackageMacOSApp() { - local framework="$1" - local runtime="$2" - - ProgressStart "Creating $runtime App Package for $framework" + ProgressStart 'Creating macOS App Package' - local folder=$artifactsFolder/$runtime-app/$framework + rm -rf $outputFolderMacOSApp + mkdir $outputFolderMacOSApp + cp -r ./macOS/Lidarr.app $outputFolderMacOSApp + mkdir -p $outputFolderMacOSApp/Lidarr.app/Contents/MacOS - rm -rf $folder - mkdir -p $folder - cp -r distribution/osx/Lidarr.app $folder - mkdir -p $folder/Lidarr.app/Contents/MacOS + echo "Adding Startup script" + cp ./macOS/Lidarr $outputFolderMacOSApp/Lidarr.app/Contents/MacOS + dos2unix $outputFolderMacOSApp/Lidarr.app/Contents/MacOS/Lidarr echo "Copying Binaries" - cp -r $artifactsFolder/$runtime/$framework/Lidarr/* $folder/Lidarr.app/Contents/MacOS + 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 echo "Removing Update Folder" - rm -r $folder/Lidarr.app/Contents/MacOS/Lidarr.Update + rm -r $outputFolderMacOSApp/Lidarr.app/Contents/MacOS/Lidarr.Update ProgressEnd 'Creating macOS App Package' } -PackageWindows() -{ - local framework="$1" - local runtime="$2" - - ProgressStart "Creating Windows Package for $framework" - - local folder=$artifactsFolder/$runtime/$framework/Lidarr - - PackageFiles "$folder" "$framework" "$runtime" - cp -r $outputFolder/$framework-windows/$runtime/publish/* $folder - - echo "Removing Lidarr.Mono" - rm -f $folder/Lidarr.Mono.* - rm -f $folder/Mono.Posix.NETStandard.* - rm -f $folder/libMonoPosixHelper.* - - echo "Adding Lidarr.Windows to UpdatePackage" - cp $folder/Lidarr.Windows.* $folder/Lidarr.Update - - ProgressEnd "Creating $runtime Package for $framework" -} - -Package() -{ - 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" - - ./_inno/ISCC.exe distribution/windows/setup/lidarr.iss "//DFramework=$framework" "//DRuntime=$runtime" -} - -InstallInno() -{ - ProgressStart "Installing portable Inno Setup" - - 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 - - ProgressEnd "Installed portable Inno Setup" -} - -RemoveInno() -{ - rm -rf _inno -} - PackageTests() { - local framework="$1" - local runtime="$2" + ProgressStart 'Creating Test Package' - cp test.sh "$testPackageFolder/$framework/$runtime/publish" + 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 - rm -f $testPackageFolder/$framework/$runtime/*.log.config + 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' + + echo "Removing Lidarr.Mono" + rm -f $outputFolder/Lidarr.Mono.* + + echo "Adding Lidarr.Windows to UpdatePackage" + cp $outputFolder/Lidarr.Windows.* $updateFolder + + echo "Removing MacOS fpcalc" + rm $outputFolder/fpcalc + + ProgressEnd 'Cleaning Windows Package' +} + +PackageArtifacts() +{ + echo "Creating Artifact Directories" + + rm -rf $artifactsFolder + mkdir $artifactsFolder + + mkdir $artifactsFolderWindows + mkdir $artifactsFolderMacOS + mkdir $artifactsFolderLinux + mkdir $artifactsFolderWindows/Lidarr + mkdir $artifactsFolderMacOS/Lidarr + mkdir $artifactsFolderLinux/Lidarr + mkdir $artifactsFolderMacOSApp + + cp -r $outputFolder/* $artifactsFolderWindows/Lidarr + cp -r $outputFolderMacOSApp/* $artifactsFolderMacOSApp + cp -r $outputFolderMacOS/* $artifactsFolderMacOS/Lidarr + cp -r $outputFolderLinux/* $artifactsFolderLinux/Lidarr +} + # Use mono or .net depending on OS case "$(uname -s)" in CYGWIN*|MINGW32*|MINGW64*|MSYS*) # on windows, use dotnet - os="windows" + runtime="dotnet" ;; *) # otherwise use mono - os="posix" + runtime="mono" ;; esac @@ -298,10 +315,7 @@ if [ $# -eq 0 ]; then BACKEND=YES FRONTEND=YES PACKAGES=YES - INSTALLER=NO LINT=YES - ENABLE_EXTRA_PLATFORMS=NO - ENABLE_EXTRA_PLATFORMS_IN_SDK=NO fi while [[ $# -gt 0 ]] @@ -313,24 +327,6 @@ case $key in BACKEND=YES shift # past argument ;; - --enable-bsd|--enable-extra-platforms) - ENABLE_EXTRA_PLATFORMS=YES - shift # past argument - ;; - --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 @@ -339,10 +335,6 @@ case $key in PACKAGES=YES shift # past argument ;; - --installer) - INSTALLER=YES - shift # past argument - ;; --lint) LINT=YES shift # past argument @@ -362,81 +354,35 @@ esac done set -- "${POSITIONAL[@]}" # restore positional parameters -if [ "$ENABLE_EXTRA_PLATFORMS_IN_SDK" = "YES" ]; -then - EnableExtraPlatformsInSDK -fi - -if [ "$BACKEND" = "YES" ]; +if [ "$BACKEND" == "YES" ]; then UpdateVersionNumber - if [ "$ENABLE_EXTRA_PLATFORMS" = "YES" ]; - then - EnableExtraPlatforms - fi Build - 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 + PackageTests fi -if [[ "$LINT" = "YES" || "$FRONTEND" = "YES" ]]; +if [ "$FRONTEND" == "YES" ]; then YarnInstall + RunGulp fi -if [ "$LINT" = "YES" ]; +if [ "$LINT" == "YES" ]; then + if [ -z "$FRONTEND" ]; + then + YarnInstall + fi + LintUI fi -if [ "$FRONTEND" = "YES" ]; -then - RunWebpack -fi - -if [ "$PACKAGES" = "YES" ]; +if [ "$PACKAGES" == "YES" ]; then UpdateVersionNumber - - 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 + PackageMono + PackageMacOS + PackageMacOSApp + CleanupWindowsPackage + PackageArtifacts fi diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 000000000..eb8f841a6 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +nzbdrone {version} {branch}; urgency=low + + * Automatic Release. + + -- NzbDrone Mon, 26 Aug 2013 00:00:00 -0700 diff --git a/debian/compat b/debian/compat new file mode 100644 index 000000000..45a4fb75d --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +8 diff --git a/debian/control b/debian/control new file mode 100644 index 000000000..34586f51d --- /dev/null +++ b/debian/control @@ -0,0 +1,12 @@ +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 new file mode 100755 index 000000000..667d82a43 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,24 @@ +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 new file mode 100755 index 000000000..106b06a9b --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +nzbdrone_bin/* opt/NzbDrone diff --git a/debian/rules b/debian/rules new file mode 100755 index 000000000..b760bee7f --- /dev/null +++ b/debian/rules @@ -0,0 +1,13 @@ +#!/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 deleted file mode 100644 index b71eb20c9..000000000 --- a/distribution/debian/install.sh +++ /dev/null @@ -1,182 +0,0 @@ -#!/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 deleted file mode 100644 index 8ec5b5b1d..000000000 --- a/distribution/debian/lidarr.service +++ /dev/null @@ -1,20 +0,0 @@ -# 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/distribution/windows/setup/lidarr.iss b/distribution/windows/setup/lidarr.iss deleted file mode 100644 index f5c0cf791..000000000 --- a/distribution/windows/setup/lidarr.iss +++ /dev/null @@ -1,84 +0,0 @@ -; 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 deleted file mode 100644 index a44dc90ce..000000000 --- a/docs.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/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 new file mode 100644 index 000000000..a82e49732 --- /dev/null +++ b/frontend/.csscomb.json @@ -0,0 +1,25 @@ +{ + "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 new file mode 100644 index 000000000..c14ef65ef --- /dev/null +++ b/frontend/.editorconfig @@ -0,0 +1,6 @@ +[*] +insert_final_newline = true + +[*.{js,css}] +indent_style = space +indent_size = 2 diff --git a/frontend/.esformatter b/frontend/.esformatter new file mode 100644 index 000000000..600bb0751 --- /dev/null +++ b/frontend/.esformatter @@ -0,0 +1,335 @@ +{ + "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 e6d49ec4d..d4b43f836 100644 --- a/frontend/.eslintignore +++ b/frontend/.eslintignore @@ -1,2 +1 @@ **/JsLibraries/** -**/*.css.d.ts diff --git a/frontend/.eslintrc b/frontend/.eslintrc new file mode 100644 index 000000000..8593e9f61 --- /dev/null +++ b/frontend/.eslintrc @@ -0,0 +1,293 @@ +{ + "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 deleted file mode 100644 index cc26a2633..000000000 --- a/frontend/.eslintrc.js +++ /dev/null @@ -1,393 +0,0 @@ -// 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 new file mode 100644 index 000000000..50aa6aa29 --- /dev/null +++ b/frontend/.jsbeautifyrc @@ -0,0 +1,12 @@ +{ + "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 deleted file mode 100644 index 3e6367c54..000000000 --- a/frontend/.prettierignore +++ /dev/null @@ -1,10 +0,0 @@ -# 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 deleted file mode 100644 index 2f91ee691..000000000 --- a/frontend/.prettierrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "arrowParens": "always", - "endOfLine": "auto", - "singleQuote": true, - "trailingComma": "es5" -} diff --git a/frontend/.stylelintrc b/frontend/.stylelintrc index f19357a4c..5587e5d4d 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,6 +15,9 @@ ] } ], + "at-rule-name-case": "lower", + "at-rule-name-newline-after": "always-multi-line", + "at-rule-name-space-after": "always", "at-rule-no-unknown": [ true, { @@ -25,36 +28,83 @@ } ], "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-disallowed-list": [ + "function-url-scheme-blacklist": [ "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", @@ -82,7 +132,6 @@ "right", "bottom", "left", - "inset", "z-index", "display", "visibility", @@ -294,33 +343,54 @@ ] } ], + "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 deleted file mode 100644 index 0e005a3cd..000000000 --- a/frontend/.vscode/extensions.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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 deleted file mode 100644 index 8da95337f..000000000 --- a/frontend/.vscode/settings.json +++ /dev/null @@ -1,23 +0,0 @@ -// 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 ade9f24a2..fe855af63 100644 --- a/frontend/babel.config.js +++ b/frontend/babel.config.js @@ -2,25 +2,22 @@ const loose = true; module.exports = { plugins: [ - '@babel/plugin-transform-logical-assignment-operators', - // Stage 1 '@babel/plugin-proposal-export-default-from', - ['@babel/plugin-transform-optional-chaining', { loose }], - ['@babel/plugin-transform-nullish-coalescing-operator', { loose }], + ['@babel/plugin-proposal-optional-chaining', { loose }], + ['@babel/plugin-proposal-nullish-coalescing-operator', { loose }], // Stage 2 - '@babel/plugin-transform-export-namespace-from', + '@babel/plugin-proposal-export-namespace-from', // Stage 3 - ['@babel/plugin-transform-class-properties', { loose }], + ['@babel/plugin-proposal-class-properties', { loose }], '@babel/plugin-syntax-dynamic-import' ], env: { development: { presets: [ - ['@babel/preset-react', { development: true }], - '@babel/preset-typescript' + ['@babel/preset-react', { development: true }] ], plugins: [ 'babel-plugin-inline-classnames' @@ -28,8 +25,7 @@ module.exports = { }, production: { presets: [ - '@babel/preset-react', - '@babel/preset-typescript' + '@babel/preset-react' ], plugins: [ 'babel-plugin-transform-react-remove-prop-types' diff --git a/frontend/build/webpack.config.js b/frontend/build/webpack.config.js deleted file mode 100644 index d1873380e..000000000 --- a/frontend/build/webpack.config.js +++ /dev/null @@ -1,291 +0,0 @@ -/* 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/build.js b/frontend/gulp/build.js new file mode 100644 index 000000000..de2da698f --- /dev/null +++ b/frontend/gulp/build.js @@ -0,0 +1,18 @@ +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 new file mode 100644 index 000000000..ac2e4026f --- /dev/null +++ b/frontend/gulp/clean.js @@ -0,0 +1,8 @@ +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 new file mode 100644 index 000000000..8d58ac4a4 --- /dev/null +++ b/frontend/gulp/copy.js @@ -0,0 +1,45 @@ +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 new file mode 100644 index 000000000..64f14f654 --- /dev/null +++ b/frontend/gulp/gulpFile.js @@ -0,0 +1,5 @@ +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 new file mode 100644 index 000000000..9c542398d --- /dev/null +++ b/frontend/gulp/helpers/errorHandler.js @@ -0,0 +1,6 @@ +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 new file mode 100644 index 000000000..8707faec4 --- /dev/null +++ b/frontend/gulp/helpers/paths.js @@ -0,0 +1,23 @@ +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 new file mode 100644 index 000000000..f83a4bba4 --- /dev/null +++ b/frontend/gulp/watch.js @@ -0,0 +1,18 @@ +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 new file mode 100644 index 000000000..bbef74e58 --- /dev/null +++ b/frontend/gulp/webpack.js @@ -0,0 +1,202 @@ +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/build/webpack/css-variables-loader.js b/frontend/gulp/webpack/css-variables-loader.js similarity index 83% rename from frontend/build/webpack/css-variables-loader.js rename to frontend/gulp/webpack/css-variables-loader.js index 717d7d323..5683c98be 100644 --- a/frontend/build/webpack/css-variables-loader.js +++ b/frontend/gulp/webpack/css-variables-loader.js @@ -1,4 +1,3 @@ -// eslint-disable-next-line filenames/match-exported const loaderUtils = require('loader-utils'); module.exports = function cssVariablesLoader(source) { diff --git a/frontend/jsconfig.json b/frontend/jsconfig.json deleted file mode 100644 index 329edb2e3..000000000 --- a/frontend/jsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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 89db00f8c..b0391ec6a 100644 --- a/frontend/postcss.config.js +++ b/frontend/postcss.config.js @@ -1,32 +1,23 @@ const reload = require('require-nocache')(module); -const cssVarsFiles = [ - './src/Styles/Variables/dimensions', - './src/Styles/Variables/fonts', - './src/Styles/Variables/animations', - './src/Styles/Variables/zIndexes' -].map(require.resolve); +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 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' - ] + return config; }; diff --git a/frontend/src/.vscode/settings.json b/frontend/src/.vscode/settings.json new file mode 100644 index 000000000..0fb2bf460 --- /dev/null +++ b/frontend/src/.vscode/settings.json @@ -0,0 +1,4 @@ +// 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 new file mode 100644 index 000000000..d93bec0bf --- /dev/null +++ b/frontend/src/Activity/Blacklist/Blacklist.js @@ -0,0 +1,123 @@ +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 new file mode 100644 index 000000000..466cc40b7 --- /dev/null +++ b/frontend/src/Activity/Blacklist/BlacklistConnector.js @@ -0,0 +1,146 @@ +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/BlocklistDetailsModal.js b/frontend/src/Activity/Blacklist/BlacklistDetailsModal.js similarity index 84% rename from frontend/src/Activity/Blocklist/BlocklistDetailsModal.js rename to frontend/src/Activity/Blacklist/BlacklistDetailsModal.js index 506fa0129..356512a9d 100644 --- a/frontend/src/Activity/Blocklist/BlocklistDetailsModal.js +++ b/frontend/src/Activity/Blacklist/BlacklistDetailsModal.js @@ -1,16 +1,15 @@ 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 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'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalFooter from 'Components/Modal/ModalFooter'; -class BlocklistDetailsModal extends Component { +class BlacklistDetailsModal extends Component { // // Render @@ -40,19 +39,19 @@ class BlocklistDetailsModal extends Component { { !!message && } @@ -60,7 +59,7 @@ class BlocklistDetailsModal extends Component { { !!message && } @@ -78,7 +77,7 @@ class BlocklistDetailsModal extends Component { } } -BlocklistDetailsModal.propTypes = { +BlacklistDetailsModal.propTypes = { isOpen: PropTypes.bool.isRequired, sourceTitle: PropTypes.string.isRequired, protocol: PropTypes.string.isRequired, @@ -87,4 +86,4 @@ BlocklistDetailsModal.propTypes = { onModalClose: PropTypes.func.isRequired }; -export default BlocklistDetailsModal; +export default BlacklistDetailsModal; diff --git a/frontend/src/Activity/Blocklist/BlocklistRow.css b/frontend/src/Activity/Blacklist/BlacklistRow.css similarity index 100% rename from frontend/src/Activity/Blocklist/BlocklistRow.css rename to frontend/src/Activity/Blacklist/BlacklistRow.css diff --git a/frontend/src/Activity/Blocklist/BlocklistRow.js b/frontend/src/Activity/Blacklist/BlacklistRow.js similarity index 77% rename from frontend/src/Activity/Blocklist/BlocklistRow.js rename to frontend/src/Activity/Blacklist/BlacklistRow.js index 9dcfc47cd..31813a41d 100644 --- a/frontend/src/Activity/Blocklist/BlocklistRow.js +++ b/frontend/src/Activity/Blacklist/BlacklistRow.js @@ -1,19 +1,16 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import AlbumFormats from 'Album/AlbumFormats'; -import TrackQuality from 'Album/TrackQuality'; -import ArtistNameLink from 'Artist/ArtistNameLink'; +import { icons, kinds } from 'Helpers/Props'; 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'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; +import TrackQuality from 'Album/TrackQuality'; +import ArtistNameLink from 'Artist/ArtistNameLink'; +import BlacklistDetailsModal from './BlacklistDetailsModal'; +import styles from './BlacklistRow.css'; -class BlocklistRow extends Component { +class BlacklistRow extends Component { // // Lifecycle @@ -31,29 +28,25 @@ class BlocklistRow 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; @@ -63,12 +56,6 @@ class BlocklistRow extends Component { return ( - - { columns.map((column) => { const { @@ -80,7 +67,7 @@ class BlocklistRow extends Component { return null; } - if (name === 'artists.sortName') { + if (name === 'artist.sortName') { return ( - - - ); - } - if (name === 'date') { return ( { - 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 deleted file mode 100644 index d810d1c0f..000000000 --- a/frontend/src/Activity/Blocklist/BlocklistConnector.js +++ /dev/null @@ -1,155 +0,0 @@ -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/Blocklist/BlocklistRow.css.d.ts b/frontend/src/Activity/Blocklist/BlocklistRow.css.d.ts deleted file mode 100644 index a608ab3d2..000000000 --- a/frontend/src/Activity/Blocklist/BlocklistRow.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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/History/Details/HistoryDetails.css.d.ts b/frontend/src/Activity/History/Details/HistoryDetails.css.d.ts deleted file mode 100644 index ff7055b0f..000000000 --- a/frontend/src/Activity/History/Details/HistoryDetails.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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/Activity/History/Details/HistoryDetails.js b/frontend/src/Activity/History/Details/HistoryDetails.js index 84aa3e0f2..ca6e49d22 100644 --- a/frontend/src/Activity/History/Details/HistoryDetails.js +++ b/frontend/src/Activity/History/Details/HistoryDetails.js @@ -1,16 +1,14 @@ import PropTypes from 'prop-types'; import React from 'react'; -import DescriptionList from 'Components/DescriptionList/DescriptionList'; -import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; -import DescriptionListItemDescription from 'Components/DescriptionList/DescriptionListItemDescription'; -import DescriptionListItemTitle from 'Components/DescriptionList/DescriptionListItemTitle'; -import Icon from 'Components/Icon'; -import Link from 'Components/Link/Link'; -import { icons } from 'Helpers/Props'; import formatDateTime from 'Utilities/Date/formatDateTime'; import formatAge from 'Utilities/Number/formatAge'; -import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; -import translate from 'Utilities/String/translate'; +import Link from 'Components/Link/Link'; +import DescriptionList from 'Components/DescriptionList/DescriptionList'; +import DescriptionListItem from 'Components/DescriptionList/DescriptionListItem'; +import DescriptionListItemTitle from 'Components/DescriptionList/DescriptionListItemTitle'; +import DescriptionListItemDescription from 'Components/DescriptionList/DescriptionListItemDescription'; +import { icons } from 'Helpers/Props'; +import Icon from 'Components/Icon'; import styles from './HistoryDetails.css'; function getDetailedList(statusMessages) { @@ -49,9 +47,7 @@ function formatMissing(value) { function formatChange(oldValue, newValue) { return ( -
- {formatMissing(oldValue)} {formatMissing(newValue)} -
+
{formatMissing(oldValue)} {formatMissing(newValue)}
); } @@ -60,7 +56,6 @@ function HistoryDetails(props) { eventType, sourceTitle, data, - downloadId, shortDateFormat, timeFormat } = props; @@ -69,102 +64,83 @@ function HistoryDetails(props) { const { indexer, releaseGroup, - customFormatScore, nzbInfoUrl, downloadClient, - downloadClientName, + downloadId, age, ageHours, ageMinutes, publishedDate } = data; - const downloadClientNameInfo = downloadClientName ?? downloadClient; - return ( { - indexer ? + !!indexer && : - null + /> } { - releaseGroup ? + !!releaseGroup && : - null + /> } { - customFormatScore && customFormatScore !== '0' ? - : - null - } - - { - nzbInfoUrl ? + !!nzbInfoUrl && - {translate('InfoUrl')} + Info URL {nzbInfoUrl} - : - null + } { - downloadClientNameInfo ? + !!downloadClient && : - null + title="Download Client" + data={downloadClient} + /> } { - downloadId ? + !!downloadId && : - null + /> } { - age || ageHours || ageMinutes ? + !!indexer && : - null + /> } { - publishedDate ? + !!publishedDate && : - null + /> } ); @@ -172,42 +148,23 @@ function HistoryDetails(props) { if (eventType === 'downloadFailed') { const { - message, - indexer + message } = data; return ( { - downloadId ? + !!message && : - null - } - - { - indexer ? ( - - ) : null} - - { - message ? - : - null + /> } ); @@ -215,7 +172,6 @@ function HistoryDetails(props) { if (eventType === 'trackFileImported') { const { - customFormatScore, droppedPath, importedPath } = data; @@ -224,37 +180,26 @@ function HistoryDetails(props) { { - droppedPath ? + !!droppedPath && : - null + /> } { - importedPath ? + !!importedPath && : - null - } - - { - customFormatScore && customFormatScore !== '0' ? - : - null + /> } ); @@ -262,8 +207,7 @@ function HistoryDetails(props) { if (eventType === 'trackFileDeleted') { const { - reason, - customFormatScore + reason } = data; let reasonMessage = ''; @@ -273,7 +217,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 the file was unlinked from the album/track in the database'; + reasonMessage = 'Lidarr was unable to find the file on disk so it was removed'; break; case 'Upgrade': reasonMessage = 'File was deleted to import an upgrade'; @@ -285,23 +229,14 @@ function HistoryDetails(props) { return ( - - { - customFormatScore && customFormatScore !== '0' ? - : - null - } ); } @@ -309,20 +244,32 @@ function HistoryDetails(props) { if (eventType === 'trackFileRenamed') { const { sourcePath, - path + sourceRelativePath, + path, + relativePath } = data; return ( + + + + ); } @@ -336,7 +283,7 @@ function HistoryDetails(props) { return ( { @@ -351,7 +298,7 @@ function HistoryDetails(props) { }) } : } /> @@ -366,14 +313,14 @@ function HistoryDetails(props) { return ( { !!statusMessages && } @@ -385,9 +332,9 @@ function HistoryDetails(props) { const { indexer, releaseGroup, - customFormatScore, nzbInfoUrl, downloadClient, + downloadId, age, ageHours, ageMinutes, @@ -397,119 +344,69 @@ function HistoryDetails(props) { return ( { - indexer ? + !!indexer && : - null + /> } { - releaseGroup ? + !!releaseGroup && : - null + /> } { - customFormatScore && customFormatScore !== '0' ? - : - null - } - - { - nzbInfoUrl ? + !!nzbInfoUrl && - {translate('InfoUrl')} + Info URL {nzbInfoUrl} - : - null + } { - downloadClient ? + !!downloadClient && : - null + /> } { - downloadId ? + !!downloadId && : - null + /> } { - age || ageHours || ageMinutes ? + !!indexer && : - null + /> } { - publishedDate ? + !!publishedDate && : - null - } - - ); - } - - if (eventType === 'downloadIgnored') { - const { - message - } = data; - - return ( - - - - { - downloadId ? - : - null - } - - { - message ? - : - null + /> } ); @@ -519,7 +416,7 @@ function HistoryDetails(props) { @@ -530,7 +427,6 @@ 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 deleted file mode 100644 index a8cc499e2..000000000 --- a/frontend/src/Activity/History/Details/HistoryDetailsModal.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 5362a2f43..865024491 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 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 ModalBody from 'Components/Modal/ModalBody'; +import ModalFooter from 'Components/Modal/ModalFooter'; import HistoryDetails from './HistoryDetails'; import styles from './HistoryDetailsModal.css'; @@ -29,8 +29,6 @@ function getHeaderTitle(eventType) { return 'Album Import Incomplete'; case 'downloadImported': return 'Download Completed'; - case 'downloadIgnored': - return 'Download Ignored'; default: return 'Unknown'; } @@ -42,7 +40,6 @@ function HistoryDetailsModal(props) { eventType, sourceTitle, data, - downloadId, isMarkingAsFailed, shortDateFormat, timeFormat, @@ -65,7 +62,6 @@ function HistoryDetailsModal(props) { eventType={eventType} sourceTitle={sourceTitle} data={data} - downloadId={downloadId} shortDateFormat={shortDateFormat} timeFormat={timeFormat} /> @@ -100,7 +96,6 @@ 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 d144a5402..a525d9988 100644 --- a/frontend/src/Activity/History/History.js +++ b/frontend/src/Activity/History/History.js @@ -1,21 +1,18 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import Alert from 'Components/Alert'; +import { align, icons } from 'Helpers/Props'; +import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; 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 { align, icons, kinds } from 'Helpers/Props'; -import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; -import translate from 'Utilities/String/translate'; -import HistoryFilterModal from './HistoryFilterModal'; +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 HistoryRowConnector from './HistoryRowConnector'; class History extends Component { @@ -53,10 +50,7 @@ class History extends Component { columns, selectedFilterKey, filters, - customFilters, totalRecords, - isArtistFetching, - isArtistPopulated, isAlbumsFetching, isAlbumsPopulated, albumsError, @@ -65,16 +59,16 @@ class History extends Component { ...otherProps } = this.props; - const isFetchingAny = isFetching || isArtistFetching || isAlbumsFetching; - const isAllPopulated = isPopulated && ((isArtistPopulated && isAlbumsPopulated) || !items.length); + const isFetchingAny = isFetching || isAlbumsFetching; + const isAllPopulated = isPopulated && (isAlbumsPopulated || !items.length); const hasError = error || albumsError; return ( - + @@ -96,14 +90,13 @@ class History extends Component { alignMenu={align.RIGHT} selectedFilterKey={selectedFilterKey} filters={filters} - customFilters={customFilters} - filterModalConnectorComponent={HistoryFilterModal} + customFilters={[]} onFilterSelect={onFilterSelect} /> - + { isFetchingAny && !isAllPopulated && @@ -111,9 +104,7 @@ class History extends Component { { !isFetchingAny && hasError && - - {translate('UnableToLoadHistory')} - +
Unable to load history
} { @@ -121,9 +112,9 @@ class History extends Component { // wait for the albums to populate because they are never coming. isPopulated && !hasError && !items.length && - - {translate('NoHistory')} - +
+ No history found +
} { @@ -156,7 +147,7 @@ class History extends Component { /> } -
+
); } @@ -168,12 +159,9 @@ History.propTypes = { error: PropTypes.object, items: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired, - selectedFilterKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, + selectedFilterKey: PropTypes.string.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 2b3354bc5..d8ca60839 100644 --- a/frontend/src/Activity/History/HistoryConnector.js +++ b/frontend/src/Activity/History/HistoryConnector.js @@ -2,34 +2,28 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -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 { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; -import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; +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 History from './History'; function createMapStateToProps() { return createSelector( (state) => state.history, - (state) => state.artist, (state) => state.albums, (state) => state.tracks, - createCustomFiltersSelector('history'), - (history, artist, albums, tracks, customFilters) => { + (history, albums, tracks) => { 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 }; } @@ -94,38 +88,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); @@ -133,7 +127,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 deleted file mode 100644 index c748f6f97..000000000 --- a/frontend/src/Activity/History/HistoryEventTypeCell.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 937cedd98..172796cd4 100644 --- a/frontend/src/Activity/History/HistoryEventTypeCell.js +++ b/frontend/src/Activity/History/HistoryEventTypeCell.js @@ -1,12 +1,11 @@ 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, data) { +function getIconName(eventType) { switch (eventType) { case 'grabbed': return icons.DOWNLOADING; @@ -17,7 +16,7 @@ function getIconName(eventType, data) { case 'downloadFailed': return icons.DOWNLOADING; case 'trackFileDeleted': - return data.reason === 'MissingFromDisk' ? icons.FILE_MISSING : icons.DELETE; + return icons.DELETE; case 'trackFileRenamed': return icons.ORGANIZE; case 'trackFileRetagged': @@ -26,8 +25,6 @@ function getIconName(eventType, data) { return icons.DOWNLOADED; case 'downloadImported': return icons.DOWNLOADED; - case 'downloadIgnored': - return icons.IGNORE; default: return icons.UNKNOWN; } @@ -55,24 +52,22 @@ function getTooltip(eventType, data) { case 'downloadFailed': return 'Album download failed'; case 'trackFileDeleted': - return data.reason === 'MissingFromDisk' ? translate('TrackFileMissingTooltip') : translate('TrackFileDeletedTooltip'); + return 'Track file deleted'; case 'trackFileRenamed': - return translate('TrackFileRenamedTooltip'); + return 'Track file renamed'; case 'trackFileRetagged': - return translate('TrackFileTagsUpdatedTooltip'); + return 'Track file tags updated'; 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, data); + const iconName = getIconName(eventType); 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 deleted file mode 100644 index f4ad2e57c..000000000 --- a/frontend/src/Activity/History/HistoryFilterModal.tsx +++ /dev/null @@ -1,54 +0,0 @@ -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 039804b63..669377fdb 100644 --- a/frontend/src/Activity/History/HistoryRow.css +++ b/frontend/src/Activity/History/HistoryRow.css @@ -10,12 +10,6 @@ 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 deleted file mode 100644 index e1f54bc96..000000000 --- a/frontend/src/Activity/History/HistoryRow.css.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 9f2da78d0..62b83ed93 100644 --- a/frontend/src/Activity/History/HistoryRow.js +++ b/frontend/src/Activity/History/HistoryRow.js @@ -1,18 +1,15 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import AlbumFormats from 'Album/AlbumFormats'; +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 AlbumTitleLink from 'Album/AlbumTitleLink'; import TrackQuality from 'Album/TrackQuality'; import ArtistNameLink from 'Artist/ArtistNameLink'; -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 HistoryDetailsModal from './Details/HistoryDetailsModal'; import styles from './HistoryRow.css'; class HistoryRow extends Component { @@ -43,11 +40,11 @@ class HistoryRow extends Component { onDetailsPress = () => { this.setState({ isDetailsModalOpen: true }); - }; + } onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - }; + } // // Render @@ -58,14 +55,11 @@ class HistoryRow extends Component { album, track, quality, - customFormats, - customFormatScore, qualityCutoffNotMet, eventType, sourceTitle, date, data, - downloadId, isMarkingAsFailed, columns, shortDateFormat, @@ -100,7 +94,7 @@ class HistoryRow extends Component { ); } - if (name === 'artists.sortName') { + if (name === 'artist.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 110c7e01c..259fd5c65 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: var(--torrentColor); - background-color: var(--torrentColor); + border-color: $torrentColor; + background-color: $torrentColor; } .usenet { composes: label from '~Components/Label.css'; - border-color: var(--usenetColor); - background-color: var(--usenetColor); + border-color: $usenetColor; + background-color: $usenetColor; } diff --git a/frontend/src/Activity/Queue/ProtocolLabel.css.d.ts b/frontend/src/Activity/Queue/ProtocolLabel.css.d.ts deleted file mode 100644 index f3b389e3d..000000000 --- a/frontend/src/Activity/Queue/ProtocolLabel.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 0efc29f21..9169927a3 100644 --- a/frontend/src/Activity/Queue/Queue.js +++ b/frontend/src/Activity/Queue/Queue.js @@ -1,31 +1,26 @@ 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 QueueFilterModal from './QueueFilterModal'; +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 QueueOptionsConnector from './QueueOptionsConnector'; import QueueRowConnector from './QueueRowConnector'; -import RemoveQueueItemModal from './RemoveQueueItemModal'; class Queue extends Component { @@ -35,21 +30,30 @@ 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, - items: props.items + isConfirmRemoveModalOpen: false }; } - shouldComponentUpdate() { - if (this._shouldBlockRefresh) { + 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) { return false; } @@ -57,44 +61,21 @@ class Queue extends Component { } componentDidUpdate(prevProps) { - const { - items, - isFetching, - isAlbumsFetching - } = this.props; - - if ( - (!isAlbumsFetching && prevProps.isAlbumsFetching) || - (!isFetching && prevProps.isFetching) || - (hasDifferentItems(prevProps.items, items) && !items.some((e) => e.albumId)) - ) { + if (hasDifferentItems(prevProps.items, this.props.items)) { this.setState((state) => { - return { - ...removeOldSelectedState(state, getRemovedItems(prevProps.items, items)), - items - }; + return removeOldSelectedState(state, prevProps.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) { - nextState.isPendingSelected = isPendingSelected; - } - - if (!_.isEmpty(nextState)) { - this.setState(nextState); + this.setState({ isPendingSelected }); } } @@ -103,45 +84,37 @@ 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._shouldBlockRefresh = true; - }); - }; + this.setState({ isConfirmRemoveModalOpen: true }); + } - onRemoveSelectedConfirmed = (payload) => { - this._shouldBlockRefresh = false; - this.props.onRemoveSelectedPress({ ids: this.getSelectedIds(), ...payload }); + onRemoveSelectedConfirmed = (blacklist, skipredownload) => { + this.props.onRemoveSelectedPress(this.getSelectedIds(), blacklist, skipredownload); this.setState({ isConfirmRemoveModalOpen: false }); - }; + } onConfirmRemoveModalClose = () => { - this._shouldBlockRefresh = false; this.setState({ isConfirmRemoveModalOpen: false }); - }; + } // // Render @@ -151,22 +124,16 @@ class Queue extends Component { isFetching, isPopulated, error, - isArtistFetching, - isArtistPopulated, + items, isAlbumsFetching, isAlbumsPopulated, albumsError, columns, - selectedFilterKey, - filters, - customFilters, - count, totalRecords, isGrabbing, isRemoving, - isRefreshMonitoredDownloadsExecuting, + isCheckForFinishedDownloadExecuting, onRefreshPress, - onFilterSelect, ...otherProps } = this.props; @@ -175,23 +142,21 @@ class Queue extends Component { allUnselected, selectedState, isConfirmRemoveModalOpen, - isPendingSelected, - items + isPendingSelected } = this.state; - const isRefreshing = isFetching || isArtistFetching || isAlbumsFetching || isRefreshMonitoredDownloadsExecuting; - const isAllPopulated = isPopulated && ((isArtistPopulated && isAlbumsPopulated) || !items.length || items.every((e) => !e.albumId)); + const isRefreshing = isFetching || isAlbumsFetching || isCheckForFinishedDownloadExecuting; + const isAllPopulated = isPopulated && (isAlbumsPopulated || !items.length || items.every((e) => !e.albumId)); const hasError = error || albumsError; - const selectedIds = this.getSelectedIds(); - const selectedCount = selectedIds.length; + const selectedCount = this.getSelectedIds().length; const disableSelectedActions = selectedCount === 0; return ( - + - - - + { - isRefreshing && !isAllPopulated ? - : - null + isRefreshing && !isAllPopulated && + } { - !isRefreshing && hasError ? - - {translate('FailedToLoadQueue')} - : - null + !isRefreshing && hasError && +
+ Failed to load Queue +
} { - isAllPopulated && !hasError && !items.length ? - - { - selectedFilterKey !== 'all' && count > 0 ? - translate('QueueFilterHasNoItems') : - translate('QueueIsEmpty') - } - : - null + isPopulated && !hasError && !items.length && +
+ Queue is empty +
} { - isAllPopulated && !hasError && !!items.length ? + isAllPopulated && !hasError && !!items.length &&
); }) @@ -304,39 +252,13 @@ 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} /> @@ -350,28 +272,17 @@ 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, - isRefreshMonitoredDownloadsExecuting: PropTypes.bool.isRequired, + isCheckForFinishedDownloadExecuting: PropTypes.bool.isRequired, onRefreshPress: PropTypes.func.isRequired, onGrabSelectedPress: PropTypes.func.isRequired, - onRemoveSelectedPress: PropTypes.func.isRequired, - onFilterSelect: PropTypes.func.isRequired -}; - -Queue.defaultProps = { - count: 0 + onRemoveSelectedPress: PropTypes.func.isRequired }; export default Queue; diff --git a/frontend/src/Activity/Queue/QueueConnector.js b/frontend/src/Activity/Queue/QueueConnector.js index fc0bb4699..ea571e8af 100644 --- a/frontend/src/Activity/Queue/QueueConnector.js +++ b/frontend/src/Activity/Queue/QueueConnector.js @@ -2,37 +2,29 @@ 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 { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; -import { executeCommand } from 'Store/Actions/commandActions'; -import * as queueActions from 'Store/Actions/queueActions'; -import { createCustomFiltersSelector } from 'Store/Selectors/createClientSideCollectionSelector'; -import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; -import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; +import withCurrentPage from 'Components/withCurrentPage'; +import createCommandExecutingSelector from 'Store/Selectors/createCommandExecutingSelector'; +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 Queue from './Queue'; function createMapStateToProps() { return createSelector( - (state) => state.artist, (state) => state.albums, (state) => state.queue.options, (state) => state.queue.paged, - (state) => state.queue.status.item, - createCustomFiltersSelector('queue'), - createCommandExecutingSelector(commandNames.REFRESH_MONITORED_DOWNLOADS), - (artist, albums, options, queue, status, customFilters, isRefreshMonitoredDownloadsExecuting) => { + createCommandExecutingSelector(commandNames.CHECK_FOR_FINISHED_DOWNLOAD), + (albums, options, queue, isCheckForFinishedDownloadExecuting) => { return { - count: options.includeUnknownArtistItems ? status.totalCount : status.count, - isArtistFetching: artist.isFetching, - isArtistPopulated: artist.isPopulated, isAlbumsFetching: albums.isFetching, isAlbumsPopulated: albums.isPopulated, albumsError: albums.error, - customFilters, - isRefreshMonitoredDownloadsExecuting, + isCheckForFinishedDownloadExecuting, ...options, ...queue }; @@ -56,7 +48,6 @@ class QueueConnector extends Component { const { useCurrentPage, fetchQueue, - fetchQueueStatus, gotoQueueFirstPage } = this.props; @@ -67,8 +58,6 @@ class QueueConnector extends Component { } else { gotoQueueFirstPage(); } - - fetchQueueStatus(); } componentDidUpdate(prevProps) { @@ -101,38 +90,34 @@ 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); @@ -140,21 +125,21 @@ class QueueConnector extends Component { if (payload.pageSize) { this.props.gotoQueueFirstPage(); } - }; + } onRefreshPress = () => { this.props.executeCommand({ - name: commandNames.REFRESH_MONITORED_DOWNLOADS + name: commandNames.CHECK_FOR_FINISHED_DOWNLOAD }); - }; + } onGrabSelectedPress = (ids) => { this.props.grabQueueItems({ ids }); - }; + } - onRemoveSelectedPress = (payload) => { - this.props.removeQueueItems(payload); - }; + onRemoveSelectedPress = (ids, blacklist, skipredownload) => { + this.props.removeQueueItems({ ids, blacklist, skipredownload }); + } // // Render @@ -168,7 +153,6 @@ 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} @@ -184,14 +168,12 @@ 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 208f50f4c..8256b8af3 100644 --- a/frontend/src/Activity/Queue/QueueDetails.js +++ b/frontend/src/Activity/Queue/QueueDetails.js @@ -1,9 +1,8 @@ import moment from 'moment'; import PropTypes from 'prop-types'; import React from 'react'; -import Icon from 'Components/Icon'; import { icons, kinds } from 'Helpers/Props'; -import translate from 'Utilities/String/translate'; +import Icon from 'Components/Icon'; function QueueDetails(props) { const { @@ -11,20 +10,20 @@ function QueueDetails(props) { size, sizeleft, estimatedCompletionTime, - status, - trackedDownloadState, - trackedDownloadStatus, + status: queueStatus, errorMessage, progressBar } = props; + const status = queueStatus.toLowerCase(); + const progress = (100 - sizeleft / size * 100); if (status === 'pending') { return ( ); } @@ -35,40 +34,12 @@ function QueueDetails(props) { ); } - if (trackedDownloadStatus === 'warning') { - return ( - - ); - } - - if (trackedDownloadState === 'importPending') { - return ( - - ); - } - - if (trackedDownloadState === 'importing') { - return ( - - ); - } + // TODO: show an icon when download is complete, but not imported yet? } if (errorMessage) { @@ -76,7 +47,7 @@ function QueueDetails(props) { ); } @@ -86,7 +57,7 @@ function QueueDetails(props) { ); } @@ -96,7 +67,7 @@ function QueueDetails(props) { ); } @@ -105,7 +76,7 @@ function QueueDetails(props) { return ( ); } @@ -119,8 +90,6 @@ 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 deleted file mode 100644 index 3fce6c166..000000000 --- a/frontend/src/Activity/Queue/QueueFilterModal.tsx +++ /dev/null @@ -1,54 +0,0 @@ -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 2ca0d7663..835be52b3 100644 --- a/frontend/src/Activity/Queue/QueueOptions.js +++ b/frontend/src/Activity/Queue/QueueOptions.js @@ -1,10 +1,9 @@ import PropTypes from 'prop-types'; import React, { Component, Fragment } from 'react'; -import FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; import { inputTypes } from 'Helpers/Props'; -import translate from 'Utilities/String/translate'; +import FormGroup from 'Components/Form/FormGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import FormInputGroup from 'Components/Form/FormInputGroup'; class QueueOptions extends Component { @@ -42,7 +41,7 @@ class QueueOptions extends Component { [name]: value }); }); - }; + } // // Render @@ -55,15 +54,13 @@ class QueueOptions extends Component { return ( - - {translate('ShowUnknownArtistItems')} - + Show Unknown Artist Items diff --git a/frontend/src/Activity/Queue/QueueRow.css b/frontend/src/Activity/Queue/QueueRow.css index 2a0df3595..16805dbf6 100644 --- a/frontend/src/Activity/Queue/QueueRow.css +++ b/frontend/src/Activity/Queue/QueueRow.css @@ -16,15 +16,8 @@ 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 deleted file mode 100644 index 13d67ea3a..000000000 --- a/frontend/src/Activity/Queue/QueueRow.css.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 d0f1fbacf..06cf16f70 100644 --- a/frontend/src/Activity/Queue/QueueRow.js +++ b/frontend/src/Activity/Queue/QueueRow.js @@ -1,28 +1,23 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -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 { icons, kinds, tooltipPositions } from 'Helpers/Props'; 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 TableRow from 'Components/Table/TableRow'; +import Icon from 'Components/Icon'; import Popover from 'Components/Tooltip/Popover'; -import Tooltip from 'Components/Tooltip/Tooltip'; -import { icons, kinds, tooltipPositions } from 'Helpers/Props'; +import ProtocolLabel from 'Activity/Queue/ProtocolLabel'; +import AlbumTitleLink from 'Album/AlbumTitleLink'; +import TrackQuality from 'Album/TrackQuality'; import InteractiveImportModal from 'InteractiveImport/InteractiveImportModal'; -import formatBytes from 'Utilities/Number/formatBytes'; -import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; -import translate from 'Utilities/String/translate'; +import ArtistNameLink from 'Artist/ArtistNameLink'; import QueueStatusCell from './QueueStatusCell'; -import RemoveQueueItemModal from './RemoveQueueItemModal'; import TimeleftCell from './TimeleftCell'; +import RemoveQueueItemModal from './RemoveQueueItemModal'; import styles from './QueueRow.css'; class QueueRow extends Component { @@ -44,37 +39,24 @@ 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 @@ -86,22 +68,17 @@ 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, @@ -123,8 +100,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 ( @@ -152,14 +129,13 @@ class QueueRow extends Component { sourceTitle={title} status={status} trackedDownloadStatus={trackedDownloadStatus} - trackedDownloadState={trackedDownloadState} statusMessages={statusMessages} errorMessage={errorMessage} /> ); } - if (name === 'artists.sortName') { + if (name === 'artist.sortName') { return ( { @@ -174,7 +150,7 @@ class QueueRow extends Component { ); } - if (name === 'albums.title') { + if (name === 'album.title') { return ( { @@ -190,7 +166,7 @@ class QueueRow extends Component { ); } - if (name === 'albums.releaseDate') { + if (name === 'album.releaseDate') { if (album) { return ( - { - quality ? - : - null - } - - ); - } - - if (name === 'customFormats') { - return ( - - - - ); - } - - if (name === 'customFormatScore') { - return ( - - } - position={tooltipPositions.BOTTOM} + ); @@ -283,12 +227,6 @@ class QueueRow extends Component { ); } - if (name === 'size') { - return ( - {formatBytes(size)} - ); - } - if (name === 'outputPath') { return ( @@ -330,15 +268,6 @@ class QueueRow extends Component { ); } - if (name === 'added') { - return ( - - ); - } - if (name === 'actions') { return ( } - title={translate('ManualDownload')} + title="Manual Download" body="This release failed parsing checks and was manually downloaded from an interactive search. Import is likely to fail." position={tooltipPositions.LEFT} /> @@ -379,7 +308,7 @@ class QueueRow extends Component { } @@ -422,22 +348,17 @@ 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, @@ -451,12 +372,10 @@ QueueRow.propTypes = { columns: PropTypes.arrayOf(PropTypes.object).isRequired, onSelectedChange: PropTypes.func.isRequired, onGrabPress: PropTypes.func.isRequired, - onRemoveQueueItemPress: PropTypes.func.isRequired, - onQueueRowModalOpenOrClose: PropTypes.func.isRequired + onRemoveQueueItemPress: 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 e2a5ba368..6bbbde361 100644 --- a/frontend/src/Activity/Queue/QueueRowConnector.js +++ b/frontend/src/Activity/Queue/QueueRowConnector.js @@ -1,10 +1,11 @@ +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 createAlbumSelector from 'Store/Selectors/createAlbumSelector'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; +import createAlbumSelector from 'Store/Selectors/createAlbumSelector'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; import QueueRow from './QueueRow'; @@ -14,11 +15,11 @@ function createMapStateToProps() { createAlbumSelector(), createUISettingsSelector(), (artist, album, uiSettings) => { - const result = { - showRelativeDates: uiSettings.showRelativeDates, - shortDateFormat: uiSettings.shortDateFormat, - timeFormat: uiSettings.timeFormat - }; + const result = _.pick(uiSettings, [ + 'showRelativeDates', + 'shortDateFormat', + 'timeFormat' + ]); result.artist = artist; result.album = album; @@ -40,11 +41,11 @@ class QueueRowConnector extends Component { onGrabPress = () => { this.props.grabQueueItem({ id: this.props.id }); - }; + } - onRemoveQueueItemPress = (payload) => { - this.props.removeQueueItem({ id: this.props.id, ...payload }); - }; + onRemoveQueueItemPress = (blacklist, skipredownload) => { + this.props.removeQueueItem({ id: this.props.id, blacklist, skipredownload }); + } // // Render diff --git a/frontend/src/Activity/Queue/QueueStatusCell.css b/frontend/src/Activity/Queue/QueueStatusCell.css index 538d5a15d..e1b9a23e9 100644 --- a/frontend/src/Activity/Queue/QueueStatusCell.css +++ b/frontend/src/Activity/Queue/QueueStatusCell.css @@ -3,7 +3,3 @@ 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 deleted file mode 100644 index aefdc03b9..000000000 --- a/frontend/src/Activity/Queue/QueueStatusCell.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 d4dcdfeee..552fa1444 100644 --- a/frontend/src/Activity/Queue/QueueStatusCell.js +++ b/frontend/src/Activity/Queue/QueueStatusCell.js @@ -1,10 +1,9 @@ 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) { @@ -13,10 +12,7 @@ function getDetailedPopoverBody(statusMessages) { { statusMessages.map(({ title, messages }) => { return ( -
+
{title}
    { @@ -41,98 +37,70 @@ function QueueStatusCell(props) { const { sourceTitle, status, - trackedDownloadStatus, - trackedDownloadState, + trackedDownloadStatus = 'Ok', 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 = 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; - } - } + let title = 'Downloading'; if (hasWarning) { iconKind = kinds.WARNING; } - if (status === 'delay') { - iconName = icons.PENDING; - title = translate('Pending'); + if (status === 'Paused') { + iconName = icons.PAUSED; + title = 'Paused'; } - if (status === 'downloadClientUnavailable') { + if (status === 'Queued') { + iconName = icons.QUEUED; + title = 'Queued'; + } + + if (status === 'Completed') { + iconName = icons.DOWNLOADED; + title = 'Downloaded'; + } + + if (status === 'Delay') { + iconName = icons.PENDING; + title = 'Pending'; + } + + if (status === 'DownloadClientUnavailable') { iconName = icons.PENDING; iconKind = kinds.WARNING; - title = translate('PendingDownloadClientUnavailable'); + title = 'Pending - Download client is unavailable'; } - if (status === 'failed') { + if (status === 'Failed') { iconName = icons.DOWNLOADING; iconKind = kinds.DANGER; - title = translate('DownloadFailed'); + title = 'Download failed'; } - if (status === 'warning') { + if (status === 'Warning') { iconName = icons.DOWNLOADING; iconKind = kinds.WARNING; - const warningMessage = - errorMessage || translate('CheckDownloadClientForDetails'); - title = translate('DownloadWarning', { warningMessage }); + title = `Download warning: ${errorMessage || 'check download client for more details'}`; } if (hasError) { - if (status === 'completed') { + if (status === 'Completed') { iconName = icons.DOWNLOAD; iconKind = kinds.DANGER; - title = translate('ImportFailed', { sourceTitle }); + title = `Import failed: ${sourceTitle}`; } else { iconName = icons.DOWNLOADING; iconKind = kinds.DANGER; - title = translate('DownloadFailed'); + title = 'Download failed'; } } @@ -157,15 +125,9 @@ function QueueStatusCell(props) { QueueStatusCell.propTypes = { sourceTitle: PropTypes.string.isRequired, status: PropTypes.string.isRequired, - trackedDownloadStatus: PropTypes.string.isRequired, - trackedDownloadState: PropTypes.string.isRequired, + trackedDownloadStatus: PropTypes.string, 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 c9ef59ec1..d7a643463 100644 --- a/frontend/src/Activity/Queue/RemoveQueueItemModal.css +++ b/frontend/src/Activity/Queue/RemoveQueueItemModal.css @@ -1,3 +1,4 @@ -.message { +.messageRemove { 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 deleted file mode 100644 index 65c237dff..000000000 --- a/frontend/src/Activity/Queue/RemoveQueueItemModal.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 new file mode 100644 index 000000000..d2f929aee --- /dev/null +++ b/frontend/src/Activity/Queue/RemoveQueueItemModal.js @@ -0,0 +1,145 @@ +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 deleted file mode 100644 index f25bb0d1b..000000000 --- a/frontend/src/Activity/Queue/RemoveQueueItemModal.tsx +++ /dev/null @@ -1,231 +0,0 @@ -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 new file mode 100644 index 000000000..c9ef59ec1 --- /dev/null +++ b/frontend/src/Activity/Queue/RemoveQueueItemsModal.css @@ -0,0 +1,3 @@ +.message { + margin-bottom: 30px; +} diff --git a/frontend/src/Activity/Queue/RemoveQueueItemsModal.js b/frontend/src/Activity/Queue/RemoveQueueItemsModal.js new file mode 100644 index 000000000..b573c5cbd --- /dev/null +++ b/frontend/src/Activity/Queue/RemoveQueueItemsModal.js @@ -0,0 +1,141 @@ +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 7f58f2810..090b8fc96 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 PageSidebarStatus from 'Components/Page/Sidebar/PageSidebarStatus'; import { fetchQueueStatus } from 'Store/Actions/queueActions'; +import PageSidebarStatus from 'Components/Page/Sidebar/PageSidebarStatus'; function createMapStateToProps() { return createSelector( diff --git a/frontend/src/Activity/Queue/TimeleftCell.css.d.ts b/frontend/src/Activity/Queue/TimeleftCell.css.d.ts deleted file mode 100644 index f5c9402d1..000000000 --- a/frontend/src/Activity/Queue/TimeleftCell.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 b280b5a06..c9515f172 100644 --- a/frontend/src/Activity/Queue/TimeleftCell.js +++ b/frontend/src/Activity/Queue/TimeleftCell.js @@ -1,14 +1,10 @@ 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 translate from 'Utilities/String/translate'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; import styles from './TimeleftCell.css'; function TimeleftCell(props) { @@ -23,39 +19,35 @@ 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 || status === 'completed' || status === 'failed') { + if (!timeleft) { return ( - diff --git a/frontend/src/Search/AddNewItem.css b/frontend/src/AddArtist/AddNewArtist/AddNewArtist.css similarity index 76% rename from frontend/src/Search/AddNewItem.css rename to frontend/src/AddArtist/AddNewArtist/AddNewArtist.css index 131f8ec5f..7c558d6d0 100644 --- a/frontend/src/Search/AddNewItem.css +++ b/frontend/src/AddArtist/AddNewArtist/AddNewArtist.css @@ -6,12 +6,12 @@ .searchIconContainer { width: 58px; height: 46px; - border: 1px solid var(--inputBorderColor); + border: 1px solid $inputBorderColor; border-right: none; border-radius: 4px; border-top-right-radius: 0; border-bottom-right-radius: 0; - background-color: var(--searchIconContainerBackgroundColor); + background-color: #edf1f2; text-align: center; line-height: 46px; } @@ -25,7 +25,7 @@ } .clearLookupButton { - border: 1px solid var(--inputBorderColor); + border: 1px solid $inputBorderColor; border-left: none; border-top-right-radius: 4px; border-bottom-right-radius: 4px; @@ -35,20 +35,14 @@ .message { margin-top: 30px; text-align: center; - font-weight: 300; - font-size: $largeFontSize; } .helpText { margin-bottom: 10px; + font-weight: 300; font-size: 24px; } -.noArtistsText { - margin-top: 80px; - margin-bottom: 20px; -} - .noResults { margin-bottom: 10px; font-weight: 300; diff --git a/frontend/src/AddArtist/AddNewArtist/AddNewArtist.js b/frontend/src/AddArtist/AddNewArtist/AddNewArtist.js new file mode 100644 index 000000000..23affe605 --- /dev/null +++ b/frontend/src/AddArtist/AddNewArtist/AddNewArtist.js @@ -0,0 +1,183 @@ +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 new file mode 100644 index 000000000..50cc07cd2 --- /dev/null +++ b/frontend/src/AddArtist/AddNewArtist/AddNewArtistConnector.js @@ -0,0 +1,102 @@ +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/Search/Artist/AddNewArtistModal.js b/frontend/src/AddArtist/AddNewArtist/AddNewArtistModal.js similarity index 100% rename from frontend/src/Search/Artist/AddNewArtistModal.js rename to frontend/src/AddArtist/AddNewArtist/AddNewArtistModal.js diff --git a/frontend/src/Search/Artist/AddNewArtistModalContent.css b/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.css similarity index 83% rename from frontend/src/Search/Artist/AddNewArtistModalContent.css rename to frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.css index 642947851..4c5c747a8 100644 --- a/frontend/src/Search/Artist/AddNewArtistModalContent.css +++ b/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.css @@ -4,7 +4,7 @@ .year { margin-left: 5px; - color: var(--disabledColor); + color: $disabledColor; } .poster { @@ -17,24 +17,16 @@ flex-grow: 1; } -.name { - font-weight: 300; - font-size: 36px; -} - -.disambiguation { - margin-bottom: 20px; - color: var(--disabledColor); - font-weight: 300; - font-size: 20px; -} - .overview { margin-bottom: 30px; max-height: 230px; text-align: justify; } +.labelIcon { + margin-left: 8px; +} + .searchForMissingAlbumsLabelContainer { display: flex; margin-top: 2px; @@ -66,6 +58,12 @@ composes: button from '~Components/Link/SpinnerButton.css'; } +.hideMetadataProfile { + composes: group from '~Components/Form/FormGroup.css'; + + display: none; +} + @media only screen and (max-width: $breakpointSmall) { .modalFooter { display: block; diff --git a/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.js b/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.js new file mode 100644 index 000000000..2278812b8 --- /dev/null +++ b/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContent.js @@ -0,0 +1,241 @@ +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/Search/Artist/AddNewArtistModalContentConnector.js b/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContentConnector.js similarity index 70% rename from frontend/src/Search/Artist/AddNewArtistModalContentConnector.js rename to frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContentConnector.js index a33c4bbf7..049d05813 100644 --- a/frontend/src/Search/Artist/AddNewArtistModalContentConnector.js +++ b/frontend/src/AddArtist/AddNewArtist/AddNewArtistModalContentConnector.js @@ -2,24 +2,22 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { addArtist, setAddDefault } from 'Store/Actions/searchActions'; +import { setAddArtistDefault, addArtist } from 'Store/Actions/addArtistActions'; import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; -import createSystemStatusSelector from 'Store/Selectors/createSystemStatusSelector'; import selectSettings from 'Store/Selectors/selectSettings'; import AddNewArtistModalContent from './AddNewArtistModalContent'; function createMapStateToProps() { return createSelector( - (state) => state.search, + (state) => state.addArtist, (state) => state.settings.metadataProfiles, createDimensionsSelector(), - createSystemStatusSelector(), - (searchState, metadataProfiles, dimensions, systemStatus) => { + (addArtistState, metadataProfiles, dimensions) => { const { isAdding, addError, defaults - } = searchState; + } = addArtistState; const { settings, @@ -30,11 +28,10 @@ function createMapStateToProps() { return { isAdding, addError, - showMetadataProfile: metadataProfiles.items.length > 2, // NONE (not allowed for artists) and one other + showMetadataProfile: metadataProfiles.items.length > 1, isSmallScreen: dimensions.isSmallScreen, validationErrors, validationWarnings, - isWindows: systemStatus.isWindows, ...settings }; } @@ -42,7 +39,7 @@ function createMapStateToProps() { } const mapDispatchToProps = { - setAddDefault, + setAddArtistDefault, addArtist }; @@ -52,18 +49,17 @@ class AddNewArtistModalContentConnector extends Component { // Listeners onInputChange = ({ name, value }) => { - this.props.setAddDefault({ [name]: value }); - }; + this.props.setAddArtistDefault({ [name]: value }); + } - onAddArtistPress = () => { + onAddArtistPress = (searchForMissingAlbums) => { const { foreignArtistId, rootFolderPath, monitor, - monitorNewItems, qualityProfileId, metadataProfileId, - searchForMissingAlbums, + albumFolder, tags } = this.props; @@ -71,13 +67,13 @@ class AddNewArtistModalContentConnector extends Component { foreignArtistId, rootFolderPath: rootFolderPath.value, monitor: monitor.value, - monitorNewItems: monitorNewItems.value, qualityProfileId: qualityProfileId.value, metadataProfileId: metadataProfileId.value, - searchForMissingAlbums: searchForMissingAlbums.value, - tags: tags.value + albumFolder: albumFolder.value, + tags: tags.value, + searchForMissingAlbums }); - }; + } // // Render @@ -97,13 +93,12 @@ AddNewArtistModalContentConnector.propTypes = { foreignArtistId: PropTypes.string.isRequired, rootFolderPath: PropTypes.object, monitor: PropTypes.object.isRequired, - monitorNewItems: PropTypes.object.isRequired, qualityProfileId: PropTypes.object, metadataProfileId: PropTypes.object, - searchForMissingAlbums: PropTypes.object.isRequired, + albumFolder: PropTypes.object.isRequired, tags: PropTypes.object.isRequired, onModalClose: PropTypes.func.isRequired, - setAddDefault: PropTypes.func.isRequired, + setAddArtistDefault: PropTypes.func.isRequired, addArtist: PropTypes.func.isRequired }; diff --git a/frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResult.css b/frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResult.css new file mode 100644 index 000000000..c56765538 --- /dev/null +++ b/frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResult.css @@ -0,0 +1,42 @@ +.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/Search/Artist/AddNewArtistSearchResult.js b/frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResult.js similarity index 68% rename from frontend/src/Search/Artist/AddNewArtistSearchResult.js rename to frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResult.js index 83e287b5e..8c5e54cbc 100644 --- a/frontend/src/Search/Artist/AddNewArtistSearchResult.js +++ b/frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResult.js @@ -1,15 +1,14 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import TextTruncate from 'react-text-truncate'; -import ArtistPoster from 'Artist/ArtistPoster'; +import dimensions from 'Styles/Variables/dimensions'; +import fonts from 'Styles/Variables/fonts'; +import { icons, kinds, sizes } from 'Helpers/Props'; import HeartRating from 'Components/HeartRating'; import Icon from 'Components/Icon'; import Label from 'Components/Label'; import Link from 'Components/Link/Link'; -import { icons, kinds, sizes } from 'Helpers/Props'; -import dimensions from 'Styles/Variables/dimensions'; -import fonts from 'Styles/Variables/fonts'; -import translate from 'Utilities/String/translate'; +import ArtistPoster from 'Artist/ArtistPoster'; import AddNewArtistModal from './AddNewArtistModal'; import styles from './AddNewArtistSearchResult.css'; @@ -54,15 +53,11 @@ class AddNewArtistSearchResult extends Component { onPress = () => { this.setState({ isNewAddArtistModalOpen: true }); - }; + } onAddArtistModalClose = () => { this.setState({ isNewAddArtistModalOpen: false }); - }; - - onMBLinkPress = (event) => { - event.stopPropagation(); - }; + } // // Render @@ -77,7 +72,6 @@ class AddNewArtistSearchResult extends Component { status, overview, ratings, - folder, images, isExistingArtist, isSmallScreen @@ -89,18 +83,16 @@ class AddNewArtistSearchResult extends Component { const linkProps = isExistingArtist ? { to: `/artist/${foreignArtistId}` } : { onPress: this.onPress }; - const endedString = artistType === 'Person' ? translate('Deceased') : translate('Inactive'); + const endedString = artistType === 'Person' ? 'Deceased' : 'Ended'; const height = calculateHeight(230, isSmallScreen); return ( -
    +
    - -
    + > { isSmallScreen ? null : @@ -109,54 +101,36 @@ class AddNewArtistSearchResult extends Component { images={images} size={250} overflow={true} - lazy={false} /> } -
    -
    -
    -
    - {artistName} +
    +
    + {artistName} - { - !artistName.contains(year) && year ? - - ({year}) - : - null - } - { - !!disambiguation && - ({disambiguation}) - } -
    -
    + { + !name.contains(year) && year ? + + ({year}) + : + null + } -
    - { - isExistingArtist ? - : - null - } + { + !!disambiguation && + ({disambiguation}) + } - + { + isExistingArtist ? - -
    + className={styles.alreadyExistsIcon} + name={icons.CHECK_CIRCLE} + size={36} + title="Already in your library" + /> : + null + }
    @@ -200,16 +174,14 @@ class AddNewArtistSearchResult extends Component { />
    -
    + @@ -227,7 +199,6 @@ AddNewArtistSearchResult.propTypes = { status: PropTypes.string.isRequired, overview: PropTypes.string, ratings: PropTypes.object.isRequired, - folder: PropTypes.string.isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired, isExistingArtist: PropTypes.bool.isRequired, isSmallScreen: PropTypes.bool.isRequired diff --git a/frontend/src/Search/Artist/AddNewArtistSearchResultConnector.js b/frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResultConnector.js similarity index 100% rename from frontend/src/Search/Artist/AddNewArtistSearchResultConnector.js rename to frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResultConnector.js index b2d58fb37..45165c04d 100644 --- a/frontend/src/Search/Artist/AddNewArtistSearchResultConnector.js +++ b/frontend/src/AddArtist/AddNewArtist/AddNewArtistSearchResultConnector.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; import createExistingArtistSelector from 'Store/Selectors/createExistingArtistSelector'; +import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; import AddNewArtistSearchResult from './AddNewArtistSearchResult'; function createMapStateToProps() { diff --git a/frontend/src/AddArtist/ArtistMetadataProfilePopoverContent.js b/frontend/src/AddArtist/ArtistMetadataProfilePopoverContent.js deleted file mode 100644 index d7c663674..000000000 --- a/frontend/src/AddArtist/ArtistMetadataProfilePopoverContent.js +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index cda224e2f..000000000 --- a/frontend/src/AddArtist/ArtistMonitorNewItemsOptionsPopoverContent.js +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 7393b9c35..000000000 --- a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css +++ /dev/null @@ -1,5 +0,0 @@ -.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 deleted file mode 100644 index 65c237dff..000000000 --- a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 d53bda8e3..5b53425a4 100644 --- a/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.js +++ b/frontend/src/AddArtist/ArtistMonitoringOptionsPopoverContent.js @@ -1,55 +1,45 @@ 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 new file mode 100644 index 000000000..3ed2459d1 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtist.js @@ -0,0 +1,173 @@ +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 new file mode 100644 index 000000000..4ce182bbd --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistConnector.js @@ -0,0 +1,170 @@ +/* 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 new file mode 100644 index 000000000..616aeaf3c --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.css @@ -0,0 +1,33 @@ +.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 new file mode 100644 index 000000000..a0feaad89 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooter.js @@ -0,0 +1,261 @@ +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 new file mode 100644 index 000000000..873d13b28 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistFooterConnector.js @@ -0,0 +1,61 @@ +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 new file mode 100644 index 000000000..52b918403 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistHeader.css @@ -0,0 +1,38 @@ +.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 new file mode 100644 index 000000000..fb0a01cb7 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistHeader.js @@ -0,0 +1,96 @@ +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 new file mode 100644 index 000000000..f5e6ed2e5 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRow.css @@ -0,0 +1,45 @@ +.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 new file mode 100644 index 000000000..ca3f32132 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRow.js @@ -0,0 +1,109 @@ +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 new file mode 100644 index 000000000..2480bfdb6 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistRowConnector.js @@ -0,0 +1,87 @@ +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 new file mode 100644 index 000000000..51fe4ce39 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistSelected.css @@ -0,0 +1,3 @@ +.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 new file mode 100644 index 000000000..f2c5f92eb --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistTable.js @@ -0,0 +1,194 @@ +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 new file mode 100644 index 000000000..fd7bf4fe2 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/ImportArtistTableConnector.js @@ -0,0 +1,43 @@ +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 new file mode 100644 index 000000000..fc86c41d1 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistName.css @@ -0,0 +1,19 @@ +.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 new file mode 100644 index 000000000..1d9fb21b7 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistName.js @@ -0,0 +1,41 @@ +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 new file mode 100644 index 000000000..f7bc065b5 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResult.css @@ -0,0 +1,8 @@ +.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 new file mode 100644 index 000000000..aa489f0fb --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResult.js @@ -0,0 +1,52 @@ +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 new file mode 100644 index 000000000..cdbcc03b3 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSearchResultConnector.js @@ -0,0 +1,17 @@ +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 new file mode 100644 index 000000000..6bdfd093e --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtist.css @@ -0,0 +1,77 @@ +.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 new file mode 100644 index 000000000..68c448d1c --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtist.js @@ -0,0 +1,303 @@ +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 new file mode 100644 index 000000000..21e2bcab2 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/Import/SelectArtist/ImportArtistSelectArtistConnector.js @@ -0,0 +1,76 @@ +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 new file mode 100644 index 000000000..ce5ec27ee --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/ImportArtist.js @@ -0,0 +1,30 @@ +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 new file mode 100644 index 000000000..030da96fb --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolder.css @@ -0,0 +1,32 @@ +.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 new file mode 100644 index 000000000..9a7253ec7 --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolder.js @@ -0,0 +1,147 @@ +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 new file mode 100644 index 000000000..8354ed4da --- /dev/null +++ b/frontend/src/AddArtist/ImportArtist/SelectFolder/ImportArtistSelectFolderConnector.js @@ -0,0 +1,84 @@ +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 deleted file mode 100644 index 86f1ed5fe..000000000 --- a/frontend/src/Album/Album.ts +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 1591fa714..000000000 --- a/frontend/src/Album/AlbumFormats.js +++ /dev/null @@ -1,33 +0,0 @@ -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 deleted file mode 100644 index 154740212..000000000 --- a/frontend/src/Album/AlbumSearchCell.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 f9ca44800..9cd41f3f1 100644 --- a/frontend/src/Album/AlbumSearchCell.js +++ b/frontend/src/Album/AlbumSearchCell.js @@ -1,10 +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 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'; @@ -26,11 +25,11 @@ class AlbumSearchCell extends Component { onManualSearchPress = () => { this.setState({ isDetailsModalOpen: true }); - }; + } onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - }; + } // // Render @@ -50,13 +49,11 @@ class AlbumSearchCell extends Component { name={icons.SEARCH} isSpinning={isSearching} onPress={onSearchPress} - title={translate('AutomaticSearch')} /> - {albumTitle} + + {title}{disambiguation ? ` (${disambiguation})` : ''} ); } diff --git a/frontend/src/Album/Delete/DeleteAlbumModalContent.css b/frontend/src/Album/Delete/DeleteAlbumModalContent.css deleted file mode 100644 index df8e4822e..000000000 --- a/frontend/src/Album/Delete/DeleteAlbumModalContent.css +++ /dev/null @@ -1,12 +0,0 @@ -.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 deleted file mode 100644 index e55686abe..000000000 --- a/frontend/src/Album/Delete/DeleteAlbumModalContent.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 deleted file mode 100644 index 28505ea75..000000000 --- a/frontend/src/Album/Delete/DeleteAlbumModalContent.js +++ /dev/null @@ -1,164 +0,0 @@ -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 deleted file mode 100644 index 45ae4ceb3..000000000 --- a/frontend/src/Album/Delete/DeleteAlbumModalContentConnector.js +++ /dev/null @@ -1,62 +0,0 @@ -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 a676ae574..1e590835a 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: var(--black); + background: $black; opacity: 0.7; } @@ -29,7 +29,7 @@ padding: 30px; width: 100%; height: 100%; - color: var(--white); + color: $white; } .cover { @@ -47,7 +47,6 @@ } .titleRow { - position: relative; display: flex; justify-content: space-between; flex: 0 0 auto; @@ -75,7 +74,7 @@ width: 40px; &:hover { - color: var(--iconButtonHoverLightColor); + color: $iconButtonHoverLightColor; } } @@ -85,8 +84,6 @@ } .albumNavigationButtons { - position: absolute; - right: 0; white-space: nowrap; } @@ -99,7 +96,7 @@ white-space: nowrap; &:hover { - color: var(--iconButtonHoverLightColor); + color: $iconButtonHoverLightColor; } } @@ -119,10 +116,7 @@ margin: 5px 10px 5px 0; } -.releaseDate, .sizeOnDisk, -.albumType, -.secondaryTypes, .qualityProfileName, .links, .tags { @@ -150,12 +144,6 @@ .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 deleted file mode 100644 index 1d14a0ccf..000000000 --- a/frontend/src/Album/Details/AlbumDetails.css.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -// 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 fe007e168..f2288b00f 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 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 Label from 'Components/Label'; -import IconButton from 'Components/Link/IconButton'; -import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -import MonitorToggleButton from 'Components/MonitorToggleButton'; -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 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 { align, icons, kinds, sizes, tooltipPositions } from 'Helpers/Props'; +import fonts from 'Styles/Variables/fonts'; +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 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 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 TrackFileEditorModal from 'TrackFile/Editor/TrackFileEditorModal'; +import AlbumDetailsLinks from './AlbumDetailsLinks'; import styles from './AlbumDetails.css'; -const intermediateFontSize = parseInt(fonts.intermediateFontSize); +const defaultFontSize = parseInt(fonts.defaultFontSize); const lineHeight = parseFloat(fonts.lineHeight); function getFanartUrl(images) { - return _.find(images, { coverType: 'fanart' })?.url; + const fanartImage = _.find(images, { coverType: 'fanart' }); + if (fanartImage) { + // Remove protocol + return fanartImage.url.replace(/^https?:/, ''); + } } function formatDuration(timeSpan) { @@ -88,7 +88,6 @@ class AlbumDetails extends Component { isInteractiveSearchModalOpen: false, isManageTracksOpen: false, isEditAlbumModalOpen: false, - isDeleteAlbumModalOpen: false, allExpanded: false, allCollapsed: false, expandedState: {} @@ -100,62 +99,51 @@ 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 { @@ -164,7 +152,7 @@ class AlbumDetails extends Component { } = this.state; this.setState(getExpandedState(selectAll(expandedState, !allExpanded))); - }; + } onExpandPress = (albumId, isExpanded) => { this.setState((state) => { @@ -178,7 +166,7 @@ class AlbumDetails extends Component { return getExpandedState(newState); }); - }; + } // // Render @@ -192,20 +180,17 @@ class AlbumDetails extends Component { duration, overview, albumType, - secondaryTypes, statistics = {}, monitored, releaseDate, ratings, images, - genres, links, media, isSaving, isFetching, isPopulated, albumsError, - tracksError, trackFilesError, hasTrackFiles, shortDateFormat, @@ -217,34 +202,19 @@ 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; @@ -257,14 +227,14 @@ class AlbumDetails extends Component { @@ -272,28 +242,28 @@ class AlbumDetails extends Component { @@ -301,36 +271,28 @@ class AlbumDetails extends Component { - - - +
    @@ -357,14 +319,8 @@ class AlbumDetails extends Component { />
    -
    - +
    + {title}{disambiguation ? ` (${disambiguation})` : ''}
    @@ -373,7 +329,7 @@ class AlbumDetails extends Component { className={styles.albumNavigationButton} name={icons.ARROW_LEFT} size={30} - title={translate('GoToInterp', [previousAlbum.title])} + title={`Go to ${previousAlbum.title}`} to={`/album/${previousAlbum.foreignAlbumId}`} /> @@ -381,7 +337,7 @@ class AlbumDetails extends Component { className={styles.albumNavigationButton} name={icons.ARROW_UP} size={30} - title={translate('GoToInterp', [artist.artistName])} + title={`Go to ${artist.artistName}`} to={`/artist/${artist.foreignArtistId}`} /> @@ -389,7 +345,7 @@ class AlbumDetails extends Component { className={styles.albumNavigationButton} name={icons.ARROW_RIGHT} size={30} - title={translate('GoToInterp', [nextAlbum.title])} + title={`Go to ${nextAlbum.title}`} to={`/album/${nextAlbum.foreignAlbumId}`} />
    @@ -398,19 +354,16 @@ class AlbumDetails extends Component {
    { - duration ? + !!duration && {formatDuration(duration)} - : - null + } - -
    @@ -418,99 +371,66 @@ class AlbumDetails extends Component { + - -
    - - - {formatBytes(sizeOnDisk)} - -
    - - } - tooltip={ - - {trackFilesCountMessage} - - } - kind={kinds.INVERSE} - position={tooltipPositions.BOTTOM} - /> + + { + moment(releaseDate).format(shortDateFormat) + } + + + + { - albumType ? + !!albumType && : - null - } + - { - secondaryTypes.length ? - : - null + + {albumType} + + } -
    - - - {translate('Links')} - -
    + + + + Links + } tooltip={ @@ -541,9 +460,9 @@ class AlbumDetails extends Component { />
    -
    +
    @@ -553,38 +472,24 @@ class AlbumDetails extends Component {
    { - !isPopulated && !albumsError && !tracksError && !trackFilesError ? - : - null + !isPopulated && !albumsError && !trackFilesError && + } { - !isFetching && albumsError ? - - {translate('AlbumsLoadError')} - : - null + !isFetching && albumsError && +
    Loading albums failed
    } { - !isFetching && tracksError ? - - {translate('TracksLoadError')} - : - null - } - - { - !isFetching && trackFilesError ? - - {translate('TrackFilesLoadError')} - : - null + !isFetching && trackFilesError && +
    Loading track files failed
    } { isPopulated && !!media.length &&
    + { media.slice(0).map((medium) => { return ( @@ -602,14 +507,6 @@ class AlbumDetails extends Component {
    } - { - isPopulated && !media.length ? - - {translate('NoMediumInformation')} - : - null - } -
    - - - + ); } @@ -676,12 +565,10 @@ 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, @@ -703,8 +590,6 @@ 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 7a5dbc95e..3bcbfd06b 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 * as commandNames from 'Commands/commandNames'; -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 { 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 createAllArtistSelector from 'Store/Selectors/createAllArtistSelector'; +import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; const selectTrackFiles = createSelector( (state) => state.trackFiles, @@ -65,17 +65,7 @@ function createMapStateToProps() { const previousAlbum = sortedAlbums[albumIndex - 1] || _.last(sortedAlbums); const nextAlbum = sortedAlbums[albumIndex + 1] || _.first(sortedAlbums); - 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 isSearching = !!findCommand(commands, { name: commandNames.ALBUM_SEARCH }); const isFetching = tracks.isFetching || isTrackFilesFetching; const isPopulated = tracks.isPopulated && isTrackFilesPopulated; @@ -86,8 +76,6 @@ function createMapStateToProps() { shortDateFormat: uiSettings.shortDateFormat, artist, isSearching, - isRenamingFiles, - isRenamingArtist, isFetching, isPopulated, tracksError, @@ -121,27 +109,8 @@ class AlbumDetailsConnector extends Component { } componentDidUpdate(prevProps) { - 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) { + if (!_.isEqual(getMonitoredReleases(prevProps), getMonitoredReleases(this.props)) || + (prevProps.anyReleaseOk === false && this.props.anyReleaseOk === true)) { this.unpopulate(); this.populate(); } @@ -160,12 +129,12 @@ class AlbumDetailsConnector extends Component { this.props.fetchTracks({ albumId }); this.props.fetchTrackFiles({ albumId }); - }; + } unpopulate = () => { this.props.clearTracks(); this.props.clearTrackFiles(); - }; + } // // Listeners @@ -175,14 +144,14 @@ class AlbumDetailsConnector extends Component { albumIds: [this.props.id], monitored }); - }; + } onSearchPress = () => { this.props.executeCommand({ name: commandNames.ALBUM_SEARCH, albumIds: [this.props.id] }); - }; + } // // Render @@ -201,8 +170,6 @@ 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 deleted file mode 100644 index 9f91f93a4..000000000 --- a/frontend/src/Album/Details/AlbumDetailsLinks.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 241836bd4..265a7c4ff 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 2bf1f6b1e..67418316d 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 var(--borderColor); + border: 1px solid $borderColor; border-radius: 4px; - background-color: var(--cardBackgroundColor); + background-color: $white; &:last-of-type { margin-bottom: 0; @@ -72,16 +72,16 @@ .tracks { padding-top: 15px; - border-top: 1px solid var(--borderColor); + border-top: 1px solid $borderColor; } .collapseButtonContainer { padding: 10px 15px; width: 100%; - border-top: 1px solid var(--borderColor); + border-top: 1px solid $borderColor; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; - background-color: var(--cardBackgroundColor); + background-color: #fafafa; text-align: center; } diff --git a/frontend/src/Album/Details/AlbumDetailsMedium.css.d.ts b/frontend/src/Album/Details/AlbumDetailsMedium.css.d.ts deleted file mode 100644 index 94964280a..000000000 --- a/frontend/src/Album/Details/AlbumDetailsMedium.css.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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 9e80e2c7a..33d6efb80 100644 --- a/frontend/src/Album/Details/AlbumDetailsMedium.js +++ b/frontend/src/Album/Details/AlbumDetailsMedium.js @@ -1,24 +1,26 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; +import { icons, kinds, sizes } from 'Helpers/Props'; import Icon from 'Components/Icon'; -import Label from 'Components/Label'; import IconButton from 'Components/Link/IconButton'; +import Label from 'Components/Label'; 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) { - const trackCount = tracks.length; + let trackCount = 0; let trackFileCount = 0; let totalTrackCount = 0; tracks.forEach((track) => { if (track.trackFileId) { + trackCount++; trackFileCount++; + } else { + trackCount++; } totalTrackCount++; @@ -80,7 +82,7 @@ class AlbumDetailsMedium extends Component { } = this.props; this.props.onExpandPress(mediumNumber, !isExpanded); - }; + } // // Render @@ -118,7 +120,7 @@ class AlbumDetailsMedium extends Component { }
:
- {translate('NoTracksInThisMedium')} + No tracks in this medium
}
diff --git a/frontend/src/Album/Details/AlbumDetailsMediumConnector.js b/frontend/src/Album/Details/AlbumDetailsMediumConnector.js index 17c6969e3..e05d9870d 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 { executeCommand } from 'Store/Actions/commandActions'; -import { setTracksTableOption } from 'Store/Actions/trackActions'; import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; +import { setTracksTableOption } from 'Store/Actions/trackActions'; +import { executeCommand } from 'Store/Actions/commandActions'; 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 ad0cdbdb7..fffd014ad 100644 --- a/frontend/src/Album/Details/AlbumDetailsPageConnector.js +++ b/frontend/src/Album/Details/AlbumDetailsPageConnector.js @@ -1,15 +1,13 @@ -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 LoadingIndicator from 'Components/Loading/LoadingIndicator'; +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 PageContentBody from 'Components/Page/PageContentBody'; -import { clearAlbums, fetchAlbums } from 'Store/Actions/albumActions'; -import translate from 'Utilities/String/translate'; +import PageContentBodyConnector from 'Components/Page/PageContentBodyConnector'; +import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import AlbumDetailsConnector from './AlbumDetailsConnector'; function createMapStateToProps() { @@ -22,18 +20,6 @@ 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, @@ -76,11 +62,11 @@ class AlbumDetailsPageConnector extends Component { foreignAlbumId, includeAllArtistAlbums: true }); - }; + } unpopulate = () => { this.props.clearAlbums(); - }; + } // // Render @@ -95,7 +81,7 @@ class AlbumDetailsPageConnector extends Component { if (!foreignAlbumId) { return ( ); } @@ -103,10 +89,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 deleted file mode 100644 index 0f432ca4c..000000000 --- a/frontend/src/Album/Details/TrackActionsCell.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 8e2a2ade4..db73b35b7 100644 --- a/frontend/src/Album/Details/TrackActionsCell.js +++ b/frontend/src/Album/Details/TrackActionsCell.js @@ -1,11 +1,10 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import IconButton from 'Components/Link/IconButton'; -import ConfirmModal from 'Components/Modal/ConfirmModal'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; 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 FileDetailsModal from 'TrackFile/FileDetailsModal'; -import translate from 'Utilities/String/translate'; import styles from './TrackActionsCell.css'; class TrackActionsCell extends Component { @@ -27,24 +26,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 @@ -72,10 +71,10 @@ class TrackActionsCell extends Component { } { trackFilePath && - + } diff --git a/frontend/src/Album/Details/TrackRow.css b/frontend/src/Album/Details/TrackRow.css index 912c00101..c77d215f2 100644 --- a/frontend/src/Album/Details/TrackRow.css +++ b/frontend/src/Album/Details/TrackRow.css @@ -19,25 +19,12 @@ .audio { composes: cell from '~Components/Table/Cells/TableRowCell.css'; - width: 300px; + width: 250px; } .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 deleted file mode 100644 index 79bbdaf43..000000000 --- a/frontend/src/Album/Details/TrackRow.css.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 db128d493..217215f5c 100644 --- a/frontend/src/Album/Details/TrackRow.js +++ b/frontend/src/Album/Details/TrackRow.js @@ -1,21 +1,13 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -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 * as mediaInfoTypes from 'TrackFile/mediaInfoTypes'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; 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 EpisodeStatusConnector from 'Album/EpisodeStatusConnector'; +import MediaInfoConnector from 'TrackFile/MediaInfoConnector'; import TrackActionsCell from './TrackActionsCell'; +import * as mediaInfoTypes from 'TrackFile/mediaInfoTypes'; + import styles from './TrackRow.css'; class TrackRow extends Component { @@ -33,10 +25,7 @@ class TrackRow extends Component { title, duration, trackFilePath, - trackFileSize, - customFormats, - customFormatScore, - indexerFlags, + trackFileRelativePath, columns, deleteTrackFile } = this.props; @@ -97,6 +86,16 @@ 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, - trackFileSize: trackFile ? trackFile.size : null, - customFormats: trackFile ? trackFile.customFormats : [], - customFormatScore: trackFile ? trackFile.customFormatScore : 0, - indexerFlags: trackFile ? trackFile.indexerFlags : 0 + trackFileRelativePath: trackFile ? trackFile.relativePath : null }; } ); diff --git a/frontend/src/Album/Edit/EditAlbumModalConnector.js b/frontend/src/Album/Edit/EditAlbumModalConnector.js index 2aadcd955..7c2383f0f 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 dafc0312d..949feee08 100644 --- a/frontend/src/Album/Edit/EditAlbumModalContent.js +++ b/frontend/src/Album/Edit/EditAlbumModalContent.js @@ -1,17 +1,16 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -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 { inputTypes } from 'Helpers/Props'; 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'; +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'; class EditAlbumModalContent extends Component { @@ -25,7 +24,7 @@ class EditAlbumModalContent extends Component { onSavePress(false); - }; + } // // Render @@ -35,7 +34,7 @@ class EditAlbumModalContent extends Component { title, artistName, albumType, - statistics = {}, + statistics, item, isSaving, onInputChange, @@ -43,10 +42,6 @@ class EditAlbumModalContent extends Component { ...otherProps } = this.props; - const { - trackFileCount = 0 - } = statistics; - const { monitored, anyReleaseOk, @@ -63,44 +58,38 @@ class EditAlbumModalContent extends Component {
- - - {translate('Monitored')} - + + Monitored - - - {translate('AutomaticallySwitchRelease')} - + + Automatically Switch Release - - - {translate('Release')} - + + Release 0} + helpText="Change release for this album" + isDisabled={anyReleaseOk.value && statistics.trackFileCount > 0} albumReleases={releases} onChange={onInputChange} /> @@ -112,14 +101,14 @@ class EditAlbumModalContent extends Component { - {translate('Save')} + Save diff --git a/frontend/src/Album/Edit/EditAlbumModalContentConnector.js b/frontend/src/Album/Edit/EditAlbumModalContentConnector.js index e9c49bd75..f6329f8e8 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 { saveAlbum, setAlbumValue } from 'Store/Actions/albumActions'; +import selectSettings from 'Store/Selectors/selectSettings'; import createAlbumSelector from 'Store/Selectors/createAlbumSelector'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; -import selectSettings from 'Store/Selectors/selectSettings'; +import { setAlbumValue, saveAlbum } from 'Store/Actions/albumActions'; 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 37d46686c..73e105376 100644 --- a/frontend/src/Album/EpisodeNumber.js +++ b/frontend/src/Album/EpisodeNumber.js @@ -1,9 +1,8 @@ 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'; @@ -41,7 +40,7 @@ function EpisodeNumber(props) { } } - title={translate('SceneInformation')} + title="Scene Information" body={ } @@ -81,7 +80,7 @@ function EpisodeNumber(props) { className={styles.warning} name={icons.WARNING} kind={kinds.WARNING} - title={translate('EpisodeDoesNotHaveAnAbsoluteEpisodeNumber')} + title="Episode does not have an absolute episode number" /> } diff --git a/frontend/src/Album/EpisodeStatus.css.d.ts b/frontend/src/Album/EpisodeStatus.css.d.ts deleted file mode 100644 index a49c06d3a..000000000 --- a/frontend/src/Album/EpisodeStatus.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 fc976103b..a2c792752 100644 --- a/frontend/src/Album/EpisodeStatus.js +++ b/frontend/src/Album/EpisodeStatus.js @@ -1,11 +1,10 @@ import PropTypes from 'prop-types'; import React from 'react'; -import QueueDetails from 'Activity/Queue/QueueDetails'; +import isBefore from 'Utilities/Date/isBefore'; +import { icons, kinds, sizes } from 'Helpers/Props'; import Icon from 'Components/Icon'; import ProgressBar from 'Components/ProgressBar'; -import { icons, kinds, sizes } from 'Helpers/Props'; -import isBefore from 'Utilities/Date/isBefore'; -import translate from 'Utilities/String/translate'; +import QueueDetails from 'Activity/Queue/QueueDetails'; import TrackQuality from './TrackQuality'; import styles from './EpisodeStatus.css'; @@ -28,7 +27,7 @@ function EpisodeStatus(props) { size } = queueItem; - const progress = size ? (100 - sizeleft / size * 100) : 0; + const progress = (100 - sizeleft / size * 100); return (
@@ -36,7 +35,7 @@ function EpisodeStatus(props) { {...queueItem} progressBar={
); @@ -68,7 +67,7 @@ function EpisodeStatus(props) { quality={quality} size={trackFile.size} isCutoffNotMet={isCutoffNotMet} - title={translate('TrackDownloaded')} + title="Track Downloaded" />
); @@ -79,7 +78,7 @@ function EpisodeStatus(props) {
); @@ -90,7 +89,7 @@ function EpisodeStatus(props) {
); @@ -101,7 +100,7 @@ function EpisodeStatus(props) {
); @@ -111,7 +110,7 @@ function EpisodeStatus(props) {
); diff --git a/frontend/src/Album/IndexerFlags.tsx b/frontend/src/Album/IndexerFlags.tsx deleted file mode 100644 index 74e2e033c..000000000 --- a/frontend/src/Album/IndexerFlags.tsx +++ /dev/null @@ -1,26 +0,0 @@ -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 6f1155494..8a5f4bccd 100644 --- a/frontend/src/Album/SceneInfo.css +++ b/frontend/src/Album/SceneInfo.css @@ -15,8 +15,3 @@ 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 061c54c10..ed171248a 100644 --- a/frontend/src/Album/SceneInfo.js +++ b/frontend/src/Album/SceneInfo.js @@ -2,7 +2,6 @@ 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) { @@ -21,7 +20,7 @@ function SceneInfo(props) { } @@ -31,7 +30,7 @@ function SceneInfo(props) { } @@ -41,7 +40,7 @@ function SceneInfo(props) { } @@ -51,7 +50,7 @@ function SceneInfo(props) { { diff --git a/frontend/src/Album/Search/AlbumInteractiveSearchModal.js b/frontend/src/Album/Search/AlbumInteractiveSearchModal.js index 6ce488615..52e825bab 100644 --- a/frontend/src/Album/Search/AlbumInteractiveSearchModal.js +++ b/frontend/src/Album/Search/AlbumInteractiveSearchModal.js @@ -1,7 +1,6 @@ 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) { @@ -15,7 +14,6 @@ function AlbumInteractiveSearchModal(props) { return ( diff --git a/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js b/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js index ac10cd146..5b23395fb 100644 --- a/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js +++ b/frontend/src/Album/Search/AlbumInteractiveSearchModalConnector.js @@ -1,19 +1,9 @@ -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()); @@ -22,38 +12,4 @@ function createMapDispatchToProps(dispatch, props) { }; } -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); +export default connect(null, createMapDispatchToProps)(AlbumInteractiveSearchModal); diff --git a/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js b/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js index 370f67ab1..ff8cbe384 100644 --- a/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js +++ b/frontend/src/Album/Search/AlbumInteractiveSearchModalContent.js @@ -1,13 +1,12 @@ import PropTypes from 'prop-types'; import React from 'react'; -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 { 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 ModalFooter from 'Components/Modal/ModalFooter'; import InteractiveSearchConnector from 'InteractiveSearch/InteractiveSearchConnector'; -import translate from 'Utilities/String/translate'; function AlbumInteractiveSearchModalContent(props) { const { @@ -19,10 +18,7 @@ function AlbumInteractiveSearchModalContent(props) { return ( - {albumTitle === undefined ? - translate('InteractiveSearchModalHeader') : - translate('InteractiveSearchModalHeaderTitle', { title: albumTitle }) - } + Interactive Search {albumId != null && `- ${albumTitle}`} @@ -36,7 +32,7 @@ function AlbumInteractiveSearchModalContent(props) { diff --git a/frontend/src/Album/TrackQuality.js b/frontend/src/Album/TrackQuality.js index 6eac5d2f8..866e7d11f 100644 --- a/frontend/src/Album/TrackQuality.js +++ b/frontend/src/Album/TrackQuality.js @@ -1,9 +1,8 @@ import PropTypes from 'prop-types'; import React from 'react'; -import Label from 'Components/Label'; -import { kinds } from 'Helpers/Props'; import formatBytes from 'Utilities/Number/formatBytes'; -import translate from 'Utilities/String/translate'; +import { kinds } from 'Helpers/Props'; +import Label from 'Components/Label'; function getTooltip(title, quality, size) { if (!title) { @@ -27,60 +26,23 @@ 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, - showRevision + isCutoffNotMet } = props; - if (!quality) { - return null; - } - return ( - - {revisionLabel(className, quality, showRevision)} - + ); } @@ -89,13 +51,11 @@ TrackQuality.propTypes = { title: PropTypes.string, quality: PropTypes.object.isRequired, size: PropTypes.number, - isCutoffNotMet: PropTypes.bool, - showRevision: PropTypes.bool + isCutoffNotMet: PropTypes.bool }; TrackQuality.defaultProps = { - title: '', - showRevision: false + title: '' }; export default TrackQuality; diff --git a/frontend/src/AlbumStudio/AlbumStudio.js b/frontend/src/AlbumStudio/AlbumStudio.js new file mode 100644 index 000000000..39222a9e2 --- /dev/null +++ b/frontend/src/AlbumStudio/AlbumStudio.js @@ -0,0 +1,218 @@ +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 new file mode 100644 index 000000000..f3c9f6102 --- /dev/null +++ b/frontend/src/AlbumStudio/AlbumStudioAlbum.css @@ -0,0 +1,37 @@ +.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 new file mode 100644 index 000000000..8bec82840 --- /dev/null +++ b/frontend/src/AlbumStudio/AlbumStudioAlbum.js @@ -0,0 +1,101 @@ +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 new file mode 100644 index 000000000..12e863c24 --- /dev/null +++ b/frontend/src/AlbumStudio/AlbumStudioConnector.js @@ -0,0 +1,91 @@ +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 new file mode 100644 index 000000000..655601cca --- /dev/null +++ b/frontend/src/AlbumStudio/AlbumStudioFilterModalConnector.js @@ -0,0 +1,24 @@ +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 new file mode 100644 index 000000000..11ea5496a --- /dev/null +++ b/frontend/src/AlbumStudio/AlbumStudioFooter.css @@ -0,0 +1,14 @@ +.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 new file mode 100644 index 000000000..d5eb300cd --- /dev/null +++ b/frontend/src/AlbumStudio/AlbumStudioFooter.js @@ -0,0 +1,145 @@ +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 new file mode 100644 index 000000000..7b9d1f52b --- /dev/null +++ b/frontend/src/AlbumStudio/AlbumStudioRow.css @@ -0,0 +1,20 @@ +.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 new file mode 100644 index 000000000..f6a146999 --- /dev/null +++ b/frontend/src/AlbumStudio/AlbumStudioRow.js @@ -0,0 +1,100 @@ +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 new file mode 100644 index 000000000..901f9407e --- /dev/null +++ b/frontend/src/AlbumStudio/AlbumStudioRowConnector.js @@ -0,0 +1,83 @@ +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 9e8d508ac..ecd3ea533 100644 --- a/frontend/src/App/App.js +++ b/frontend/src/App/App.js @@ -1,18 +1,16 @@ -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 c1004d36d..ed55547e0 100644 --- a/frontend/src/App/AppRoutes.js +++ b/frontend/src/App/AppRoutes.js @@ -1,39 +1,41 @@ import PropTypes from 'prop-types'; import React from 'react'; -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 AlbumDetailsPageConnector from 'Album/Details/AlbumDetailsPageConnector'; -import ArtistDetailsPageConnector from 'Artist/Details/ArtistDetailsPageConnector'; -import ArtistIndex from 'Artist/Index/ArtistIndex'; -import CalendarPageConnector from 'Calendar/CalendarPageConnector'; +import { Route, Redirect } from 'react-router-dom'; +import getPathWithUrlBase from 'Utilities/getPathWithUrlBase'; 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 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 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 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 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 UISettingsConnector from 'Settings/UI/UISettingsConnector'; -import BackupsConnector from 'System/Backup/BackupsConnector'; -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'; +import BackupsConnector from 'System/Backup/BackupsConnector'; +import UpdatesConnector from 'System/Updates/UpdatesConnector'; +import LogsTableConnector from 'System/Events/LogsTableConnector'; +import Logs from 'System/Logs/Logs'; function AppRoutes(props) { const { @@ -49,7 +51,7 @@ function AppRoutes(props) { { @@ -70,34 +72,23 @@ function AppRoutes(props) { } + + { - return ( - - ); - }} + component={ArtistEditorConnector} /> { - return ( - - ); - }} + component={AlbumStudioConnector} /> {/* @@ -179,12 +170,7 @@ 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, @@ -60,17 +20,17 @@ function AppUpdatedModalContent(props) { onModalClose } = props; - const update = mergeUpdates(items, version, prevVersion); + const update = items[0]; return ( - {translate('AppUpdated')} + Lidarr Updated
- + Version {version} of Lidarr has been installed, in order to get the latest changes you'll need to reload Lidarr.
{ @@ -78,23 +38,23 @@ function AppUpdatedModalContent(props) {
{ !update.changes && -
{translate('MaintenanceRelease')}
+
Maintenance release
} { !!update.changes &&
- {translate('WhatsNew')} + What's new?
@@ -112,14 +72,14 @@ function AppUpdatedModalContent(props) { @@ -128,7 +88,6 @@ 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 5a991f236..7cf649b65 100644 --- a/frontend/src/App/AppUpdatedModalContentConnector.js +++ b/frontend/src/App/AppUpdatedModalContentConnector.js @@ -8,9 +8,8 @@ import AppUpdatedModalContent from './AppUpdatedModalContent'; function createMapStateToProps() { return createSelector( (state) => state.app.version, - (state) => state.app.prevVersion, (state) => state.system.updates, - (version, prevVersion, updates) => { + (version, updates) => { const { isPopulated, error, @@ -19,7 +18,6 @@ function createMapStateToProps() { return { version, - prevVersion, isPopulated, error, items diff --git a/frontend/src/App/ApplyTheme.tsx b/frontend/src/App/ApplyTheme.tsx deleted file mode 100644 index e04dda8c4..000000000 --- a/frontend/src/App/ApplyTheme.tsx +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index 027f2a9a3..000000000 --- a/frontend/src/App/ConnectionLostModal.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 5c08f491f..9178d2ab8 100644 --- a/frontend/src/App/ConnectionLostModal.js +++ b/frontend/src/App/ConnectionLostModal.js @@ -1,13 +1,12 @@ 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 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 ModalBody from 'Components/Modal/ModalBody'; +import ModalFooter from 'Components/Modal/ModalFooter'; import styles from './ConnectionLostModal.css'; function ConnectionLostModal(props) { @@ -23,16 +22,16 @@ function ConnectionLostModal(props) { > - {translate('ConnectionLost')} + Connnection Lost
- {translate('ConnectionLostToBackend')} + Lidarr has lost it's connection to the backend and will need to be reloaded to restore functionality.
- {translate('ConnectionLostReconnect')} + Lidarr will try to connect automatically, or you can click reload below.
@@ -40,7 +39,7 @@ function ConnectionLostModal(props) { kind={kinds.PRIMARY} onPress={onModalClose} > - {translate('Reload')} + Reload
diff --git a/frontend/src/App/ModelBase.ts b/frontend/src/App/ModelBase.ts deleted file mode 100644 index 187b12fb2..000000000 --- a/frontend/src/App/ModelBase.ts +++ /dev/null @@ -1,5 +0,0 @@ -interface ModelBase { - id: number; -} - -export default ModelBase; diff --git a/frontend/src/App/SelectContext.tsx b/frontend/src/App/SelectContext.tsx deleted file mode 100644 index 66be388ce..000000000 --- a/frontend/src/App/SelectContext.tsx +++ /dev/null @@ -1,83 +0,0 @@ -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 deleted file mode 100644 index e03d4a497..000000000 --- a/frontend/src/App/State/AlbumAppState.ts +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index cabc39b1c..000000000 --- a/frontend/src/App/State/AppSectionState.ts +++ /dev/null @@ -1,53 +0,0 @@ -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 deleted file mode 100644 index cb8da5987..000000000 --- a/frontend/src/App/State/AppState.ts +++ /dev/null @@ -1,72 +0,0 @@ -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 deleted file mode 100644 index 9e0628df7..000000000 --- a/frontend/src/App/State/ArtistAppState.ts +++ /dev/null @@ -1,72 +0,0 @@ -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 deleted file mode 100644 index 503d2c25b..000000000 --- a/frontend/src/App/State/CalendarAppState.ts +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index f4110ef73..000000000 --- a/frontend/src/App/State/ClientSideCollectionAppState.ts +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index 1bde37371..000000000 --- a/frontend/src/App/State/CommandAppState.ts +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 6ac4820c7..000000000 --- a/frontend/src/App/State/CustomFiltersAppState.ts +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index e368ff86e..000000000 --- a/frontend/src/App/State/HistoryAppState.ts +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 827d5b1a7..000000000 --- a/frontend/src/App/State/ParseAppState.ts +++ /dev/null @@ -1,35 +0,0 @@ -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 deleted file mode 100644 index 05d74acac..000000000 --- a/frontend/src/App/State/QueueAppState.ts +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index b387e13fd..000000000 --- a/frontend/src/App/State/SettingsAppState.ts +++ /dev/null @@ -1,76 +0,0 @@ -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 deleted file mode 100644 index 3c150fcfb..000000000 --- a/frontend/src/App/State/SystemAppState.ts +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index edaf3a158..000000000 --- a/frontend/src/App/State/TagsAppState.ts +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index 403ba904d..000000000 --- a/frontend/src/App/State/TrackFilesAppState.ts +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 22aaabed9..000000000 --- a/frontend/src/App/State/TracksAppState.ts +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 813dbea08..000000000 --- a/frontend/src/Artist/Artist.ts +++ /dev/null @@ -1,51 +0,0 @@ -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 5483912e1..b409667b1 100644 --- a/frontend/src/Artist/ArtistBanner.js +++ b/frontend/src/Artist/ArtistBanner.js @@ -15,10 +15,6 @@ 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 669cba8d8..6ae479a18 100644 --- a/frontend/src/Artist/ArtistImage.js +++ b/frontend/src/Artist/ArtistImage.js @@ -7,10 +7,13 @@ function findImage(images, coverType) { } function getUrl(image, coverType, size) { - const imageUrl = image?.url; + if (image) { + // Remove protocol + let url = image.url.replace(/^https?:/, ''); - if (imageUrl) { - return imageUrl.replace(`${coverType}.jpg`, `${coverType}-${size}.jpg`); + url = url.replace(`${coverType}.jpg`, `${coverType}-${size}.jpg`); + + return url; } } @@ -96,7 +99,7 @@ class ArtistImage extends Component { if (this.props.onError) { this.props.onError(); } - }; + } onLoad = () => { this.setState({ @@ -107,7 +110,7 @@ class ArtistImage extends Component { if (this.props.onLoad) { this.props.onLoad(); } - }; + } // // Render @@ -158,7 +161,6 @@ 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 93b91c2da..05e665186 100644 --- a/frontend/src/Artist/ArtistLogo.js +++ b/frontend/src/Artist/ArtistLogo.js @@ -10,10 +10,12 @@ function findLogo(images) { } function getLogoUrl(logo, size) { - const logoUrl = logo?.url; + if (logo) { + // Remove protocol + let url = logo.url.replace(/^https?:/, ''); + url = url.replace('logo.jpg', `logo-${size}.jpg`); - if (logoUrl) { - return logoUrl.replace('logo.jpg', `logo-${size}.jpg`); + return url; } } @@ -70,11 +72,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 de594e5b9..4eebd9ca4 100644 --- a/frontend/src/Artist/ArtistPoster.js +++ b/frontend/src/Artist/ArtistPoster.js @@ -15,10 +15,6 @@ 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 c647b7735..5b6490c66 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 Modal from 'Components/Modal/Modal'; import { sizes } from 'Helpers/Props'; +import Modal from 'Components/Modal/Modal'; import DeleteArtistModalContentConnector from './DeleteArtistModalContentConnector'; function DeleteArtistModal(props) { @@ -26,7 +26,6 @@ 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 df8e4822e..dbfef0871 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModalContent.css +++ b/frontend/src/Artist/Delete/DeleteArtistModalContent.css @@ -8,5 +8,5 @@ .deleteFilesMessage { margin-top: 20px; - color: var(--dangerColor); + color: $dangerColor; } diff --git a/frontend/src/Artist/Delete/DeleteArtistModalContent.css.d.ts b/frontend/src/Artist/Delete/DeleteArtistModalContent.css.d.ts deleted file mode 100644 index e55686abe..000000000 --- a/frontend/src/Artist/Delete/DeleteArtistModalContent.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 ac1e2b041..a242a1e20 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModalContent.js +++ b/frontend/src/Artist/Delete/DeleteArtistModalContent.js @@ -1,17 +1,16 @@ 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 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 { 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 ModalBody from 'Components/Modal/ModalBody'; +import ModalFooter from 'Components/Modal/ModalFooter'; import styles from './DeleteArtistModalContent.css'; class DeleteArtistModalContent extends Component { @@ -23,7 +22,8 @@ class DeleteArtistModalContent extends Component { super(props, context); this.state = { - deleteFiles: false + deleteFiles: false, + addImportListExclusion: false }; } @@ -32,15 +32,20 @@ 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.props.deleteOptions.addImportListExclusion; + const addImportListExclusion = this.state.addImportListExclusion; this.setState({ deleteFiles: false }); + this.setState({ addImportListExclusion: false }); this.props.onDeletePress(deleteFiles, addImportListExclusion); - }; + } // // Render @@ -50,21 +55,19 @@ class DeleteArtistModalContent extends Component { artistName, path, statistics, - deleteOptions, - onModalClose, - onDeleteOptionChange + onModalClose } = this.props; const { - trackFileCount = 0, - sizeOnDisk = 0 + trackFileCount, + sizeOnDisk } = statistics; const deleteFiles = this.state.deleteFiles; - const addImportListExclusion = deleteOptions.addImportListExclusion; + const addImportListExclusion = this.state.addImportListExclusion; let deleteFilesLabel = `Delete ${trackFileCount} Track Files`; - let deleteFilesHelpText = translate('DeleteFilesHelpText'); + let deleteFilesHelpText = 'Delete the track files and artist folder'; if (trackFileCount === 0) { deleteFilesLabel = 'Delete Artist Folder'; @@ -103,26 +106,22 @@ class DeleteArtistModalContent extends Component { - - {translate('AddListExclusion')} - + Add List Exclusion { deleteFiles &&
-
- {translate('TheArtistFolderStrongpathstrongAndAllOfItsContentWillBeDeleted', [path])} -
+
The artist folder {path} and all of its content will be deleted.
{ !!trackFileCount && @@ -135,14 +134,14 @@ class DeleteArtistModalContent extends Component { @@ -154,14 +153,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: {} + statistics: { + trackFileCount: 0 + } }; export default DeleteArtistModalContent; diff --git a/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js b/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js index 321dc63a6..e0ea034ab 100644 --- a/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js +++ b/frontend/src/Artist/Delete/DeleteArtistModalContentConnector.js @@ -1,44 +1,56 @@ +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(), - (deleteOptions, artist) => { - return { - ...artist, - deleteOptions - }; + (artist) => { + return artist; } ); } -function createMapDispatchToProps(dispatch, props) { - return { - onDeleteOptionChange(option) { - dispatch( - setDeleteOption({ - [option.name]: option.value - }) - ); - }, +const mapDispatchToProps = { + deleteArtist +}; - onDeletePress(deleteFiles, addImportListExclusion) { - dispatch( - deleteArtist({ - id: props.artistId, - deleteFiles, - addImportListExclusion - }) - ); +class DeleteArtistModalContentConnector extends Component { - props.onModalClose(true); - } - }; + // + // Listeners + + onDeletePress = (deleteFiles, addImportListExclusion) => { + this.props.deleteArtist({ + id: this.props.artistId, + deleteFiles, + addImportListExclusion + }); + + this.props.onModalClose(true); + } + + // + // Render + + render() { + return ( + + ); + } } -export default connect(createMapStateToProps, createMapDispatchToProps)(DeleteArtistModalContent); +DeleteArtistModalContentConnector.propTypes = { + artistId: PropTypes.number.isRequired, + onModalClose: PropTypes.func.isRequired, + deleteArtist: PropTypes.func.isRequired +}; + +export default connect(createMapStateToProps, mapDispatchToProps)(DeleteArtistModalContentConnector); diff --git a/frontend/src/Artist/Details/AlbumGroupInfo.css b/frontend/src/Artist/Details/AlbumGroupInfo.css deleted file mode 100644 index 9a414e728..000000000 --- a/frontend/src/Artist/Details/AlbumGroupInfo.css +++ /dev/null @@ -1,11 +0,0 @@ -.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 deleted file mode 100644 index e0d8c2f6b..000000000 --- a/frontend/src/Artist/Details/AlbumGroupInfo.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 139cd7765..000000000 --- a/frontend/src/Artist/Details/AlbumGroupInfo.js +++ /dev/null @@ -1,66 +0,0 @@ -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 383d97746..e29f491d7 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'; - word-break: break-word; + white-space: nowrap; } .monitored { @@ -10,7 +10,6 @@ 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 deleted file mode 100644 index 90377b53b..000000000 --- a/frontend/src/Artist/Details/AlbumRow.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 b5c8fa2cf..e2d6cf65e 100644 --- a/frontend/src/Artist/Details/AlbumRow.js +++ b/frontend/src/Artist/Details/AlbumRow.js @@ -1,17 +1,15 @@ 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) { @@ -45,23 +43,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 @@ -86,10 +84,9 @@ class AlbumRow extends Component { } = this.props; const { - trackCount = 0, - trackFileCount = 0, - totalTrackCount = 0, - sizeOnDisk = 0 + trackCount, + trackFileCount, + totalTrackCount } = statistics; return ( @@ -149,7 +146,9 @@ class AlbumRow extends Component { if (name === 'secondaryTypes') { return ( - {secondaryTypes.join(', ')} + { + secondaryTypes + } ); } @@ -158,7 +157,7 @@ class AlbumRow extends Component { return ( { - totalTrackCount + statistics.totalTrackCount } ); @@ -196,17 +195,6 @@ class AlbumRow extends Component { ); } - if (name === 'size') { - return ( - - {!!sizeOnDisk && formatBytes(sizeOnDisk)} - - ); - } - if (name === 'status') { return (
@@ -469,36 +445,26 @@ class ArtistDetails extends Component { - - + - } - tooltip={ - - {trackFilesCountMessage} - - } - kind={kinds.INVERSE} - position={tooltipPositions.BOTTOM} - /> + + { + formatBytes(sizeOnDisk) + } + + @@ -556,7 +522,7 @@ class ArtistDetails extends Component { /> - {translate('Links')} + Links } @@ -612,19 +578,13 @@ class ArtistDetails extends Component { } { - !isFetching && albumsError ? - - {translate('AlbumsLoadError')} - : - null + !isFetching && albumsError && +
Loading albums failed
} { - !isFetching && trackFilesError ? - - {translate('TrackFilesLoadError')} - : - null + !isFetching && trackFilesError && +
Loading track files failed
} { @@ -651,11 +611,7 @@ class ArtistDetails extends Component {
- Missing Albums, Singles, or Other Types? Modify or create a new - Metadata Profile - or manually - Search - for new items! + Missing Albums, Singles, or Other Types? Modify or Create a New Metadata Profile!
- - -
+
); } @@ -733,7 +682,6 @@ 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 bed30a937..2e5ba1d11 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 * 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 { findCommand, isCommandExecuting } from 'Utilities/Command'; import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; +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 ArtistDetails from './ArtistDetails'; const selectAlbums = createSelector( @@ -28,15 +28,13 @@ 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, - albumTypes + hasMonitoredAlbums }; } ); @@ -67,12 +65,20 @@ function createMapStateToProps() { (state, { foreignArtistId }) => foreignArtistId, selectAlbums, selectTrackFiles, + (state) => state.settings.metadataProfiles, createAllArtistSelector(), createCommandsSelector(), - (foreignArtistId, albums, trackFiles, allArtists, commands) => { + (foreignArtistId, albums, trackFiles, metadataProfiles, 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 {}; @@ -83,8 +89,7 @@ function createMapStateToProps() { isAlbumsPopulated, albumsError, hasAlbums, - hasMonitoredAlbums, - albumTypes + hasMonitoredAlbums } = albums; const { @@ -107,6 +112,7 @@ 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) && @@ -211,13 +217,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 @@ -227,21 +233,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 deleted file mode 100644 index 9f91f93a4..000000000 --- a/frontend/src/Artist/Details/ArtistDetailsLinks.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 d6229b484..23941d06b 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 cb379af26..61b1a0f4c 100644 --- a/frontend/src/Artist/Details/ArtistDetailsPageConnector.js +++ b/frontend/src/Artist/Details/ArtistDetailsPageConnector.js @@ -1,15 +1,14 @@ -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'; @@ -74,10 +73,10 @@ class ArtistDetailsPageConnector extends Component { if (isFetching && !isPopulated) { return ( - - + + - + ); } @@ -93,7 +92,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 4421fe7a7..127f0c772 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 var(--borderColor); + border: 1px solid $borderColor; border-radius: 4px; - background-color: var(--cardBackgroundColor); + background-color: $white; &:last-of-type { margin-bottom: 0; @@ -15,10 +15,11 @@ align-items: center; width: 100%; font-size: 24px; + cursor: pointer; } .albumTypeLabel { - margin-right: 10px; + margin-right: 5px; margin-left: 5px; } @@ -28,16 +29,10 @@ font-size: 18px; } -.albumCountTooltip { +.episodeCountTooltip { display: flex; } -.sizeOnDisk { - margin-left: 10px; - color: #777; - font-size: $defaultFontSize; -} - .expandButton { composes: link from '~Components/Link/Link.css'; @@ -49,7 +44,7 @@ .left { display: flex; align-items: center; - flex: 0 1 350px; + flex: 0 1 300px; } .left, @@ -82,7 +77,7 @@ .albums { padding-top: 15px; - border-top: 1px solid var(--borderColor); + border-top: 1px solid $borderColor; } .collapseButtonContainer { @@ -91,10 +86,10 @@ justify-content: center; padding: 10px 15px; width: 100%; - border-top: 1px solid var(--borderColor); + border-top: 1px solid $borderColor; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; - background-color: var(--collapseButtonBackgroundColor); + background-color: #fafafa; } .collapseButtonIcon { @@ -108,7 +103,7 @@ top: 50%; left: 50%; margin-top: -12px; - margin-left: -12px; + margin-left: -15px; } .noAlbums { @@ -127,8 +122,4 @@ 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 deleted file mode 100644 index c3c20ac42..000000000 --- a/frontend/src/Artist/Details/ArtistDetailsSeason.css.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -// 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 004613e30..f9968a8e9 100644 --- a/frontend/src/Artist/Details/ArtistDetailsSeason.js +++ b/frontend/src/Artist/Details/ArtistDetailsSeason.js @@ -1,84 +1,18 @@ 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 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 OrganizePreviewModalConnector from 'Organize/OrganizePreviewModalConnector'; 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 { // @@ -135,19 +69,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 { @@ -156,7 +90,7 @@ class ArtistDetailsSeason extends Component { } = this.props; this.props.onExpandPress(name, !isExpanded); - }; + } onMonitorAlbumPress = (albumId, monitored, { shiftKey }) => { const lastToggled = this.state.lastToggledAlbum; @@ -173,14 +107,8 @@ class ArtistDetailsSeason extends Component { this.setState({ lastToggledAlbum: albumId }); - this.props.onMonitorAlbumsPress(_.uniq(albumIds), monitored); - }; - - onMonitorAlbumsPress = (monitored, { shiftKey }) => { - const albumIds = this.props.items.map((a) => a.id); - - this.props.onMonitorAlbumsPress(_.uniq(albumIds), monitored); - }; + this.props.onMonitorAlbumPress(_.uniq(albumIds), monitored); + } // // Render @@ -191,9 +119,7 @@ class ArtistDetailsSeason extends Component { label, items, columns, - isSaving, isExpanded, - artistMonitored, sortKey, sortDirection, onSortPress, @@ -201,16 +127,6 @@ class ArtistDetailsSeason extends Component { onTableOptionChange } = this.props; - const { - albumCount, - albumFileCount, - totalAlbumCount, - trackFileCount, - monitoredAlbumCount, - hasMonitoredAlbums, - sizeOnDisk = 0 - } = getAlbumStatistics(items); - const { isOrganizeModalOpen, isManageTracksOpen @@ -220,62 +136,30 @@ class ArtistDetailsSeason extends Component {
-
-
- - - {label} - - - {albumFileCount} / {albumCount} - - } - title={translate('GroupInformation')} - body={ + +
+
+ {
- + + {label} + + + + ({items.length} Releases) +
} - position={tooltipPositions.BOTTOM} - /> - { - sizeOnDisk ? -
- {formatBytes(sizeOnDisk)} -
: - null - } -
- - +
@@ -283,9 +167,9 @@ class ArtistDetailsSeason extends Component { !isSmallScreen &&   } - -
+
+
{ @@ -325,7 +209,7 @@ class ArtistDetailsSeason extends Component { iconClassName={styles.collapseButtonIcon} name={icons.COLLAPSE} size={20} - title={translate('HideAlbums')} + title="Hide albums" onPress={this.onExpandPress} />
@@ -353,18 +237,16 @@ 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, - onMonitorAlbumsPress: PropTypes.func.isRequired, + onMonitorAlbumPress: PropTypes.func.isRequired, uiSettings: PropTypes.object.isRequired }; diff --git a/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js b/frontend/src/Artist/Details/ArtistDetailsSeasonConnector.js index 6eb98cd52..ffb84ba2c 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 { 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 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 { executeCommand } from 'Store/Actions/commandActions'; 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 }); - }; + } - onMonitorAlbumsPress = (albumIds, monitored) => { + onMonitorAlbumPress = (albumIds, monitored) => { this.props.toggleAlbumsMonitored({ albumIds, monitored }); - }; + } // // Render @@ -82,7 +82,7 @@ class ArtistDetailsSeasonConnector extends Component { {...this.props} onSortPress={this.onSortPress} onTableOptionChange={this.onTableOptionChange} - onMonitorAlbumsPress={this.onMonitorAlbumsPress} + onMonitorAlbumPress={this.onMonitorAlbumPress} /> ); } diff --git a/frontend/src/Artist/Details/ArtistGenres.css b/frontend/src/Artist/Details/ArtistGenres.css deleted file mode 100644 index 93a028748..000000000 --- a/frontend/src/Artist/Details/ArtistGenres.css +++ /dev/null @@ -1,3 +0,0 @@ -.genres { - margin-right: 15px; -} diff --git a/frontend/src/Artist/Details/ArtistGenres.css.d.ts b/frontend/src/Artist/Details/ArtistGenres.css.d.ts deleted file mode 100644 index 83399e63b..000000000 --- a/frontend/src/Artist/Details/ArtistGenres.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 deleted file mode 100644 index 15f3505d8..000000000 --- a/frontend/src/Artist/Details/ArtistGenres.js +++ /dev/null @@ -1,53 +0,0 @@ -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 b5f8a6e89..7ea841a36 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 Label from 'Components/Label'; import { kinds, sizes } from 'Helpers/Props'; +import Label from 'Components/Label'; function ArtistTags({ tags }) { return ( diff --git a/frontend/src/Artist/Details/ArtistTagsConnector.js b/frontend/src/Artist/Details/ArtistTagsConnector.js index 1d24a5755..1ecde26cd 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,11 +10,15 @@ function createMapStateToProps() { createArtistSelector(), createTagsSelector(), (artist, tagList) => { - const tags = artist.tags - .map((tagId) => tagList.find((tag) => tag.id === tagId)) - .filter((tag) => !!tag) - .sort(sortByProp('label')) - .map((tag) => tag.label); + const tags = _.reduce(artist.tags, (acc, tag) => { + const matchingTag = _.find(tagList, { id: tag }); + + if (matchingTag) { + acc.push(matchingTag.label); + } + + return acc; + }, []); return { tags diff --git a/frontend/src/Artist/Edit/EditArtistModal.js b/frontend/src/Artist/Edit/EditArtistModal.js index f221e728c..6e99a2f53 100644 --- a/frontend/src/Artist/Edit/EditArtistModal.js +++ b/frontend/src/Artist/Edit/EditArtistModal.js @@ -18,7 +18,6 @@ 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 9c4e6325f..9e62a4780 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,7 +32,6 @@ 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 fd7ddf093..a2b6014df 100644 --- a/frontend/src/Artist/Edit/EditArtistModalContent.css +++ b/frontend/src/Artist/Edit/EditArtistModalContent.css @@ -3,7 +3,3 @@ 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 deleted file mode 100644 index 238343ae5..000000000 --- a/frontend/src/Artist/Edit/EditArtistModalContent.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 bca6e3ea6..73dd652e8 100644 --- a/frontend/src/Artist/Edit/EditArtistModalContent.js +++ b/frontend/src/Artist/Edit/EditArtistModalContent.js @@ -1,22 +1,17 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -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 FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; -import Icon from 'Components/Icon'; +import { inputTypes, kinds } from 'Helpers/Props'; 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 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 MoveArtistModal from 'Artist/MoveArtist/MoveArtistModal'; import styles from './EditArtistModalContent.css'; class EditArtistModalContent extends Component { @@ -35,10 +30,6 @@ class EditArtistModalContent extends Component { // // Listeners - onCancelPress = () => { - this.setState({ isConfirmMoveModalOpen: false }); - }; - onSavePress = () => { const { isPathChanging, @@ -52,13 +43,13 @@ class EditArtistModalContent extends Component { onSavePress(false); } - }; + } onMoveArtistPress = () => { this.setState({ isConfirmMoveModalOpen: false }); this.props.onSavePress(true); - }; + } // // Render @@ -78,7 +69,7 @@ class EditArtistModalContent extends Component { const { monitored, - monitorNewItems, + albumFolder, qualityProfileId, metadataProfileId, path, @@ -93,50 +84,32 @@ class EditArtistModalContent extends Component { - - - {translate('Monitored')} - + + Monitored - - - {translate('MonitorNewItems')} - - - } - title={translate('MonitorNewItems')} - body={} - position={tooltipPositions.RIGHT} - /> - + + Use Album Folder - - - {translate('QualityProfile')} - + + Quality Profile { - showMetadataProfile ? - - - {translate('MetadataProfile')} - - - } - title={translate('MetadataProfile')} - body={} - position={tooltipPositions.RIGHT} - /> - - + showMetadataProfile && + + Metadata Profile - : - null + } - - - {translate('Path')} - + + Path - - - {translate('Tags')} - + + Tags - {translate('Delete')} + Delete - {translate('Save')} + Save @@ -232,7 +184,6 @@ 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 bd9592d42..351bc7d34 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 { saveArtist, setArtistValue } from 'Store/Actions/artistActions'; -import createArtistSelector from 'Store/Selectors/createArtistSelector'; import selectSettings from 'Store/Selectors/selectSettings'; +import createArtistSelector from 'Store/Selectors/createArtistSelector'; +import { setArtistValue, saveArtist } from 'Store/Actions/artistActions'; import EditArtistModalContent from './EditArtistModalContent'; function createIsPathChangingSelector() { @@ -39,7 +39,7 @@ function createMapStateToProps() { const artistSettings = _.pick(artist, [ 'monitored', - 'monitorNewItems', + 'albumFolder', '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 new file mode 100644 index 000000000..d4f6b282c --- /dev/null +++ b/frontend/src/Artist/Editor/ArtistEditor.js @@ -0,0 +1,309 @@ +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 new file mode 100644 index 000000000..c0188ee6d --- /dev/null +++ b/frontend/src/Artist/Editor/ArtistEditorConnector.js @@ -0,0 +1,92 @@ +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 new file mode 100644 index 000000000..4aff2df06 --- /dev/null +++ b/frontend/src/Artist/Editor/ArtistEditorFilterModalConnector.js @@ -0,0 +1,24 @@ +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 new file mode 100644 index 000000000..3785f88d3 --- /dev/null +++ b/frontend/src/Artist/Editor/ArtistEditorFooter.css @@ -0,0 +1,70 @@ +.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 new file mode 100644 index 000000000..ccf044c53 --- /dev/null +++ b/frontend/src/Artist/Editor/ArtistEditorFooter.js @@ -0,0 +1,349 @@ +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 new file mode 100644 index 000000000..9b4b40be6 --- /dev/null +++ b/frontend/src/Artist/Editor/ArtistEditorFooterLabel.css @@ -0,0 +1,8 @@ +.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 new file mode 100644 index 000000000..1c6be745d --- /dev/null +++ b/frontend/src/Artist/Editor/ArtistEditorFooterLabel.js @@ -0,0 +1,40 @@ +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 new file mode 100644 index 000000000..aeb9776ca --- /dev/null +++ b/frontend/src/Artist/Editor/ArtistEditorRow.css @@ -0,0 +1,5 @@ +.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 new file mode 100644 index 000000000..cfead73be --- /dev/null +++ b/frontend/src/Artist/Editor/ArtistEditorRow.js @@ -0,0 +1,120 @@ +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 new file mode 100644 index 000000000..32694a6b9 --- /dev/null +++ b/frontend/src/Artist/Editor/ArtistEditorRowConnector.js @@ -0,0 +1,34 @@ +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/Search/Album/AddNewAlbumModal.js b/frontend/src/Artist/Editor/AudioTags/RetagArtistModal.js similarity index 69% rename from frontend/src/Search/Album/AddNewAlbumModal.js rename to frontend/src/Artist/Editor/AudioTags/RetagArtistModal.js index 7f1d678a9..636ca6618 100644 --- a/frontend/src/Search/Album/AddNewAlbumModal.js +++ b/frontend/src/Artist/Editor/AudioTags/RetagArtistModal.js @@ -1,9 +1,9 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; -import AddNewAlbumModalContentConnector from './AddNewAlbumModalContentConnector'; +import RetagArtistModalContentConnector from './RetagArtistModalContentConnector'; -function AddNewAlbumModal(props) { +function RetagArtistModal(props) { const { isOpen, onModalClose, @@ -15,7 +15,7 @@ function AddNewAlbumModal(props) { isOpen={isOpen} onModalClose={onModalClose} > - @@ -23,9 +23,9 @@ function AddNewAlbumModal(props) { ); } -AddNewAlbumModal.propTypes = { +RetagArtistModal.propTypes = { isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; -export default AddNewAlbumModal; +export default RetagArtistModal; diff --git a/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css b/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.css similarity index 100% rename from frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css rename to frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.css diff --git a/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.js b/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.js new file mode 100644 index 000000000..015112556 --- /dev/null +++ b/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContent.js @@ -0,0 +1,73 @@ +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 new file mode 100644 index 000000000..1c104db00 --- /dev/null +++ b/frontend/src/Artist/Editor/AudioTags/RetagArtistModalContentConnector.js @@ -0,0 +1,67 @@ +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/Album/Delete/DeleteAlbumModal.js b/frontend/src/Artist/Editor/Delete/DeleteArtistModal.js similarity index 60% rename from frontend/src/Album/Delete/DeleteAlbumModal.js rename to frontend/src/Artist/Editor/Delete/DeleteArtistModal.js index 303010ca3..11fd79d5d 100644 --- a/frontend/src/Album/Delete/DeleteAlbumModal.js +++ b/frontend/src/Artist/Editor/Delete/DeleteArtistModal.js @@ -1,10 +1,9 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; -import { sizes } from 'Helpers/Props'; -import DeleteAlbumModalContentConnector from './DeleteAlbumModalContentConnector'; +import DeleteArtistModalContentConnector from './DeleteArtistModalContentConnector'; -function DeleteAlbumModal(props) { +function DeleteArtistModal(props) { const { isOpen, onModalClose, @@ -14,10 +13,9 @@ function DeleteAlbumModal(props) { return ( - @@ -25,9 +23,9 @@ function DeleteAlbumModal(props) { ); } -DeleteAlbumModal.propTypes = { +DeleteArtistModal.propTypes = { isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; -export default DeleteAlbumModal; +export default DeleteArtistModal; diff --git a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css b/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.css similarity index 81% rename from frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css rename to frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.css index 02a0514be..950fdc27d 100644 --- a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css +++ b/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.css @@ -9,5 +9,5 @@ .path { margin-left: 5px; - color: var(--dangerColor); + color: $dangerColor; } diff --git a/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.js b/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.js new file mode 100644 index 000000000..87088b472 --- /dev/null +++ b/frontend/src/Artist/Editor/Delete/DeleteArtistModalContent.js @@ -0,0 +1,123 @@ +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 new file mode 100644 index 000000000..8c61976e8 --- /dev/null +++ b/frontend/src/Artist/Editor/Delete/DeleteArtistModalContentConnector.js @@ -0,0 +1,45 @@ +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/Settings/Quality/Reset/ResetQualityDefinitionsModal.js b/frontend/src/Artist/Editor/Organize/OrganizeArtistModal.js similarity index 54% rename from frontend/src/Settings/Quality/Reset/ResetQualityDefinitionsModal.js rename to frontend/src/Artist/Editor/Organize/OrganizeArtistModal.js index ee9caa260..412396355 100644 --- a/frontend/src/Settings/Quality/Reset/ResetQualityDefinitionsModal.js +++ b/frontend/src/Artist/Editor/Organize/OrganizeArtistModal.js @@ -1,10 +1,9 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; -import { sizes } from 'Helpers/Props'; -import ResetQualityDefinitionsModalContentConnector from './ResetQualityDefinitionsModalContentConnector'; +import OrganizeArtistModalContentConnector from './OrganizeArtistModalContentConnector'; -function ResetQualityDefinitionsModal(props) { +function OrganizeArtistModal(props) { const { isOpen, onModalClose, @@ -14,10 +13,9 @@ function ResetQualityDefinitionsModal(props) { return ( - @@ -25,9 +23,9 @@ function ResetQualityDefinitionsModal(props) { ); } -ResetQualityDefinitionsModal.propTypes = { +OrganizeArtistModal.propTypes = { isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; -export default ResetQualityDefinitionsModal; +export default OrganizeArtistModal; diff --git a/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css b/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.css similarity index 100% rename from frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css rename to frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.css diff --git a/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.js b/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.js new file mode 100644 index 000000000..5f90eca90 --- /dev/null +++ b/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContent.js @@ -0,0 +1,74 @@ +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 new file mode 100644 index 000000000..6be1eb961 --- /dev/null +++ b/frontend/src/Artist/Editor/Organize/OrganizeArtistModalContentConnector.js @@ -0,0 +1,67 @@ +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/Settings/Tags/AutoTagging/Specifications/AddSpecificationModal.js b/frontend/src/Artist/Editor/Tags/TagsModal.js similarity index 58% rename from frontend/src/Settings/Tags/AutoTagging/Specifications/AddSpecificationModal.js rename to frontend/src/Artist/Editor/Tags/TagsModal.js index 1a8c115f0..0f6c2d7ec 100644 --- a/frontend/src/Settings/Tags/AutoTagging/Specifications/AddSpecificationModal.js +++ b/frontend/src/Artist/Editor/Tags/TagsModal.js @@ -1,15 +1,21 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; -import AddSpecificationModalContent from './AddSpecificationModalContent'; +import TagsModalContentConnector from './TagsModalContentConnector'; + +function TagsModal(props) { + const { + isOpen, + onModalClose, + ...otherProps + } = props; -function AddSpecificationModal({ isOpen, onModalClose, ...otherProps }) { return ( - @@ -17,9 +23,9 @@ function AddSpecificationModal({ isOpen, onModalClose, ...otherProps }) { ); } -AddSpecificationModal.propTypes = { +TagsModal.propTypes = { isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; -export default AddSpecificationModal; +export default TagsModal; diff --git a/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css b/frontend/src/Artist/Editor/Tags/TagsModalContent.css similarity index 100% rename from frontend/src/Artist/Index/Select/Tags/TagsModalContent.css rename to frontend/src/Artist/Editor/Tags/TagsModalContent.css diff --git a/frontend/src/Artist/Editor/Tags/TagsModalContent.js b/frontend/src/Artist/Editor/Tags/TagsModalContent.js new file mode 100644 index 000000000..b982fee0e --- /dev/null +++ b/frontend/src/Artist/Editor/Tags/TagsModalContent.js @@ -0,0 +1,187 @@ +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 new file mode 100644 index 000000000..6741e8b5c --- /dev/null +++ b/frontend/src/Artist/Editor/Tags/TagsModalContentConnector.js @@ -0,0 +1,36 @@ +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 a4362484c..7139d7633 100644 --- a/frontend/src/Artist/History/ArtistHistoryModal.js +++ b/frontend/src/Artist/History/ArtistHistoryModal.js @@ -1,7 +1,6 @@ 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) { @@ -14,7 +13,6 @@ function ArtistHistoryModal(props) { return ( translate('Album'), + label: 'Album', isVisible: true }, { name: 'sourceTitle', - label: () => translate('SourceTitle'), + label: 'Source Title', isVisible: true }, { name: '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, + label: 'Quality', isVisible: true }, { name: 'date', - label: () => translate('Date'), + label: 'Date', + isVisible: true + }, + { + name: 'details', + label: 'Details', isVisible: true }, { name: 'actions', + label: 'Actions', isVisible: true } ]; @@ -93,16 +80,12 @@ class ArtistHistoryModalContent extends Component { { !isFetching && !!error && - - {translate('UnableToLoadHistory')} - +
Unable to load history.
} { isPopulated && !hasItems && !error && - - {translate('NoHistory')} - +
No history.
} { diff --git a/frontend/src/Artist/History/ArtistHistoryModalContentConnector.js b/frontend/src/Artist/History/ArtistHistoryModalContentConnector.js index f5f93ed7d..a989361f5 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 { artistHistoryMarkAsFailed, clearArtistHistory, fetchArtistHistory } from 'Store/Actions/artistHistoryActions'; +import { fetchArtistHistory, clearArtistHistory, artistHistoryMarkAsFailed } 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 33dba8df9..deafecb81 100644 --- a/frontend/src/Artist/History/ArtistHistoryRow.css +++ b/frontend/src/Artist/History/ArtistHistoryRow.css @@ -1,9 +1,4 @@ -.sourceTitle { - composes: cell from '~Components/Table/Cells/TableRowCell.css'; - - word-break: break-word; -} - +.details, .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 deleted file mode 100644 index b0b91a6b8..000000000 --- a/frontend/src/Artist/History/ArtistHistoryRow.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 fe8326378..e69f8395b 100644 --- a/frontend/src/Artist/History/ArtistHistoryRow.js +++ b/frontend/src/Artist/History/ArtistHistoryRow.js @@ -1,19 +1,16 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import HistoryDetailsConnector from 'Activity/History/Details/HistoryDetailsConnector'; -import HistoryEventTypeCell from 'Activity/History/HistoryEventTypeCell'; -import AlbumFormats from 'Album/AlbumFormats'; -import TrackQuality from 'Album/TrackQuality'; +import { icons, kinds, tooltipPositions } from 'Helpers/Props'; 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 TableRowCell from 'Components/Table/Cells/TableRowCell'; import TableRow from 'Components/Table/TableRow'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; import Popover from 'Components/Tooltip/Popover'; -import { icons, kinds, tooltipPositions } from 'Helpers/Props'; -import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore'; -import translate from 'Utilities/String/translate'; +import TrackQuality from 'Album/TrackQuality'; +import HistoryDetailsConnector from 'Activity/History/Details/HistoryDetailsConnector'; +import HistoryEventTypeCell from 'Activity/History/HistoryEventTypeCell'; import styles from './ArtistHistoryRow.css'; function getTitle(eventType) { @@ -57,16 +54,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 @@ -77,11 +74,8 @@ class ArtistHistoryRow extends Component { sourceTitle, quality, qualityCutoffNotMet, - customFormats, - customFormatScore, date, data, - downloadId, album } = this.props; @@ -100,7 +94,7 @@ class ArtistHistoryRow extends Component { {album.title} - + {sourceTitle} @@ -111,19 +105,11 @@ class ArtistHistoryRow extends Component { /> - - - - - - {formatCustomFormatScore(customFormatScore, customFormats.length)} - - - + } position={tooltipPositions.LEFT} /> + + { eventType === 'grabbed' && } @@ -156,9 +142,9 @@ class ArtistHistoryRow extends Component { @@ -173,19 +159,12 @@ 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 65249aca6..2bcfc7cb6 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 createAlbumSelector from 'Store/Selectors/createAlbumSelector'; import createArtistSelector from 'Store/Selectors/createArtistSelector'; +import createAlbumSelector from 'Store/Selectors/createAlbumSelector'; import ArtistHistoryRow from './ArtistHistoryRow'; function createMapStateToProps() { diff --git a/frontend/src/Artist/Index/ArtistIndex.css b/frontend/src/Artist/Index/ArtistIndex.css index 908cb2d16..43b445c3c 100644 --- a/frontend/src/Artist/Index/ArtistIndex.css +++ b/frontend/src/Artist/Index/ArtistIndex.css @@ -13,7 +13,6 @@ .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 deleted file mode 100644 index ec08fc921..000000000 --- a/frontend/src/Artist/Index/ArtistIndex.css.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 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 new file mode 100644 index 000000000..f88ffda52 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndex.js @@ -0,0 +1,429 @@ +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 deleted file mode 100644 index 2fcc0fadf..000000000 --- a/frontend/src/Artist/Index/ArtistIndex.tsx +++ /dev/null @@ -1,375 +0,0 @@ -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 new file mode 100644 index 000000000..a9e0b7dcc --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexConnector.js @@ -0,0 +1,162 @@ +/* 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 deleted file mode 100644 index 07e454fc2..000000000 --- a/frontend/src/Artist/Index/ArtistIndexFilterModal.tsx +++ /dev/null @@ -1,56 +0,0 @@ -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 new file mode 100644 index 000000000..412f3df34 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexFilterModalConnector.js @@ -0,0 +1,24 @@ +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 bf3fedfd6..71d0439b6 100644 --- a/frontend/src/Artist/Index/ArtistIndexFooter.css +++ b/frontend/src/Artist/Index/ArtistIndexFooter.css @@ -21,41 +21,35 @@ .continuing { composes: legendItemColor; - background-color: var(--primaryColor); + background-color: $primaryColor; } .ended { composes: legendItemColor; - background-color: var(--successColor); + background-color: $successColor; } .missingMonitored { composes: legendItemColor; - background-color: var(--dangerColor); + background-color: $dangerColor; &:global(.colorImpaired) { - background: repeating-linear-gradient(90deg, color(#f05050 shade(5%)), color(#f05050 shade(5%)) 5px, color(#f05050 shade(15%)) 5px, color(#f05050 shade(15%)) 10px); + background: repeating-linear-gradient(90deg, color($dangerColor shade(5%)), color($dangerColor shade(5%)) 5px, color($dangerColor shade(15%)) 5px, color($dangerColor shade(15%)) 10px); } } .missingUnmonitored { composes: legendItemColor; - background-color: var(--warningColor); + background-color: $warningColor; &:global(.colorImpaired) { - background: repeating-linear-gradient(45deg, #ffa500, #ffa500 5px, color(#ffa500 tint(15%)) 5px, color(#ffa500 tint(15%)) 10px); + background: repeating-linear-gradient(45deg, $warningColor, $warningColor 5px, color($warningColor tint(15%)) 5px, color($warningColor 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 deleted file mode 100644 index 29f693a8c..000000000 --- a/frontend/src/Artist/Index/ArtistIndexFooter.css.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 new file mode 100644 index 000000000..245312ae6 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexFooter.js @@ -0,0 +1,158 @@ +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 deleted file mode 100644 index 47241b224..000000000 --- a/frontend/src/Artist/Index/ArtistIndexFooter.tsx +++ /dev/null @@ -1,179 +0,0 @@ -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 new file mode 100644 index 000000000..9d7afc298 --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexFooterConnector.js @@ -0,0 +1,46 @@ +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 new file mode 100644 index 000000000..aef6a8e5e --- /dev/null +++ b/frontend/src/Artist/Index/ArtistIndexItemConnector.js @@ -0,0 +1,141 @@ +/* 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 deleted file mode 100644 index 07a180857..000000000 --- a/frontend/src/Artist/Index/ArtistIndexRefreshArtistsButton.tsx +++ /dev/null @@ -1,74 +0,0 @@ -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 7f1fc71c6..3f9bfdd8b 100644 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css @@ -1,11 +1,15 @@ $hoverScale: 1.05; +.container { + padding: 10px; +} + .content { transition: all 200ms ease-in; &:hover { z-index: 2; - box-shadow: 0 0 12px var(--black); + box-shadow: 0 0 12px $black; transition: all 200ms ease-in; .controls { @@ -22,29 +26,12 @@ $hoverScale: 1.05; .link { composes: link from '~Components/Link/Link.css'; - position: relative; display: block; - height: 50px; - background-color: var(--defaultColor); + background-color: $defaultColor; } -.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); +.nextAiring { + background-color: #fafbfc; text-align: center; font-size: $smallFontSize; } @@ -52,7 +39,8 @@ $hoverScale: 1.05; .title { @add-mixin truncate; - background-color: var(--artistBackgroundColor); + background-color: $defaultColor; + color: $white; text-align: center; font-size: $smallFontSize; } @@ -61,13 +49,12 @@ $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 var(--dangerColor) transparent transparent; - color: var(--white); + border-color: transparent $dangerColor transparent transparent; + color: $white; } .controls { @@ -77,7 +64,7 @@ $hoverScale: 1.05; z-index: 3; border-radius: 4px; background-color: #216044; - color: var(--white); + color: $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 deleted file mode 100644 index bd6cb4ac9..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.css.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// 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 new file mode 100644 index 000000000..42883da51 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanner.js @@ -0,0 +1,272 @@ +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 deleted file mode 100644 index f6a03c521..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanner.tsx +++ /dev/null @@ -1,263 +0,0 @@ -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 22ed2d528..aab27d827 100644 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css @@ -1,5 +1,5 @@ .info { - background-color: var(--artistBackgroundColor); + background-color: #fafbfc; 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 deleted file mode 100644 index 062365d36..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 new file mode 100644 index 000000000..f641de0e1 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.js @@ -0,0 +1,115 @@ +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 deleted file mode 100644 index a93b0bafc..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBannerInfo.tsx +++ /dev/null @@ -1,187 +0,0 @@ -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 deleted file mode 100644 index b97436b41..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 new file mode 100644 index 000000000..28cfdf14c --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBanners.js @@ -0,0 +1,326 @@ +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 deleted file mode 100644 index 3582da097..000000000 --- a/frontend/src/Artist/Index/Banners/ArtistIndexBanners.tsx +++ /dev/null @@ -1,304 +0,0 @@ -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 new file mode 100644 index 000000000..bac56ebd2 --- /dev/null +++ b/frontend/src/Artist/Index/Banners/ArtistIndexBannersConnector.js @@ -0,0 +1,24 @@ +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/Settings/CustomFormats/CustomFormats/Specifications/AddSpecificationModal.js b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.js similarity index 52% rename from frontend/src/Settings/CustomFormats/CustomFormats/Specifications/AddSpecificationModal.js rename to frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.js index 19d8a4335..34c8abfcf 100644 --- a/frontend/src/Settings/CustomFormats/CustomFormats/Specifications/AddSpecificationModal.js +++ b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.js @@ -1,15 +1,15 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; -import AddSpecificationModalContentConnector from './AddSpecificationModalContentConnector'; +import ArtistIndexBannerOptionsModalContentConnector from './ArtistIndexBannerOptionsModalContentConnector'; -function AddSpecificationModal({ isOpen, onModalClose, ...otherProps }) { +function ArtistIndexBannerOptionsModal({ isOpen, onModalClose, ...otherProps }) { return ( - @@ -17,9 +17,9 @@ function AddSpecificationModal({ isOpen, onModalClose, ...otherProps }) { ); } -AddSpecificationModal.propTypes = { +ArtistIndexBannerOptionsModal.propTypes = { isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; -export default AddSpecificationModal; +export default ArtistIndexBannerOptionsModal; diff --git a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.tsx b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.tsx deleted file mode 100644 index 156e06079..000000000 --- a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModal.tsx +++ /dev/null @@ -1,21 +0,0 @@ -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 new file mode 100644 index 000000000..6bfcad0bb --- /dev/null +++ b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.js @@ -0,0 +1,213 @@ +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 deleted file mode 100644 index f889ea450..000000000 --- a/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContent.tsx +++ /dev/null @@ -1,167 +0,0 @@ -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 new file mode 100644 index 000000000..884edd05d --- /dev/null +++ b/frontend/src/Artist/Index/Banners/Options/ArtistIndexBannerOptionsModalContentConnector.js @@ -0,0 +1,23 @@ +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 deleted file mode 100644 index 529c15e06..000000000 --- a/frontend/src/Artist/Index/Banners/selectBannerOptions.ts +++ /dev/null @@ -1,9 +0,0 @@ -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 new file mode 100644 index 000000000..818e83311 --- /dev/null +++ b/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.js @@ -0,0 +1,41 @@ +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 deleted file mode 100644 index 91ebbef2d..000000000 --- a/frontend/src/Artist/Index/Menus/ArtistIndexFilterMenu.tsx +++ /dev/null @@ -1,41 +0,0 @@ -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.tsx b/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.js similarity index 70% rename from frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.tsx rename to frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.js index 1b72d0f4c..fc5854648 100644 --- a/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.tsx +++ b/frontend/src/Artist/Index/Menus/ArtistIndexSortMenu.js @@ -1,23 +1,23 @@ +import PropTypes from 'prop-types'; import React from 'react'; -import MenuContent from 'Components/Menu/MenuContent'; +import { align, sortDirections } from 'Helpers/Props'; import SortMenu from 'Components/Menu/SortMenu'; +import MenuContent from 'Components/Menu/MenuContent'; import SortMenuItem from 'Components/Menu/SortMenuItem'; -import { align } from 'Helpers/Props'; -import SortDirection from 'Helpers/Props/SortDirection'; -import translate from 'Utilities/String/translate'; -interface SeriesIndexSortMenuProps { - sortKey?: string; - sortDirection?: SortDirection; - isDisabled: boolean; - onSortSelect(sortKey: string): unknown; -} - -function ArtistIndexSortMenu(props: SeriesIndexSortMenuProps) { - const { sortKey, sortDirection, isDisabled, onSortSelect } = props; +function ArtistIndexSortMenu(props) { + const { + sortKey, + sortDirection, + isDisabled, + onSortSelect + } = props; return ( - + - {translate('MonitoredStatus')} + Monitored/Status - {translate('Name')} + Name - {translate('Type')} + Type - {translate('QualityProfile')} + Quality Profile - {translate('MetadataProfile')} + Metadata Profile - {translate('NextAlbum')} + Next Album - {translate('LastAlbum')} + Last Album - {translate('Added')} + Added - {translate('Albums')} + Albums - {translate('Tracks')} + Tracks - {translate('TrackCount')} + Track Count - {translate('Path')} + Path - {translate('SizeOnDisk')} - - - - {translate('Tags')} + Size on Disk ); } +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 new file mode 100644 index 000000000..46ca03b9f --- /dev/null +++ b/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.js @@ -0,0 +1,63 @@ +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 deleted file mode 100644 index bb88d9149..000000000 --- a/frontend/src/Artist/Index/Menus/ArtistIndexViewMenu.tsx +++ /dev/null @@ -1,44 +0,0 @@ -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 1f482a2d6..054319ebc 100644 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css @@ -1,5 +1,13 @@ $hoverScale: 1.05; +.container { + &:hover { + .content { + background-color: $tableRowHoverBackgroundColor; + } + } +} + .content { display: flex; flex-grow: 1; @@ -17,10 +25,10 @@ $hoverScale: 1.05; composes: link from '~Components/Link/Link.css'; display: block; - color: var(--defaultColor); + color: $defaultColor; &:hover { - color: var(--defaultColor); + color: $defaultColor; text-decoration: none; } } @@ -34,8 +42,8 @@ $hoverScale: 1.05; height: 0; border-width: 0 25px 25px 0; border-style: solid; - border-color: transparent var(--dangerColor) transparent transparent; - color: var(--white); + border-color: transparent $dangerColor transparent transparent; + color: $white; } .info { diff --git a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css.d.ts b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css.d.ts deleted file mode 100644 index de94277cc..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.css.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -// 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 new file mode 100644 index 000000000..6be34d622 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverview.js @@ -0,0 +1,284 @@ +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 deleted file mode 100644 index ebef28264..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverview.tsx +++ /dev/null @@ -1,249 +0,0 @@ -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 deleted file mode 100644 index eb2309a64..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 new file mode 100644 index 000000000..f7839cab5 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.js @@ -0,0 +1,250 @@ +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 deleted file mode 100644 index c95d34b84..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfo.tsx +++ /dev/null @@ -1,260 +0,0 @@ -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 deleted file mode 100644 index 04f22fc2e..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 new file mode 100644 index 000000000..b04029b88 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.js @@ -0,0 +1,35 @@ +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 deleted file mode 100644 index 5d9b4a069..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviewInfoRow.tsx +++ /dev/null @@ -1,24 +0,0 @@ -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 deleted file mode 100644 index b97436b41..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 new file mode 100644 index 000000000..8b23cdf95 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.js @@ -0,0 +1,289 @@ +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 deleted file mode 100644 index 11285c1b3..000000000 --- a/frontend/src/Artist/Index/Overview/ArtistIndexOverviews.tsx +++ /dev/null @@ -1,213 +0,0 @@ -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 new file mode 100644 index 000000000..595a471b1 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/ArtistIndexOverviewsConnector.js @@ -0,0 +1,25 @@ +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/Settings/MediaManagement/RootFolder/EditRootFolderModal.js b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.js similarity index 51% rename from frontend/src/Settings/MediaManagement/RootFolder/EditRootFolderModal.js rename to frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.js index 6adc8046c..9ca575185 100644 --- a/frontend/src/Settings/MediaManagement/RootFolder/EditRootFolderModal.js +++ b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.js @@ -1,15 +1,15 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; -import EditRootFolderModalContentConnector from './EditRootFolderModalContentConnector'; +import ArtistIndexOverviewOptionsModalContentConnector from './ArtistIndexOverviewOptionsModalContentConnector'; -function EditRootFolderModal({ isOpen, onModalClose, ...otherProps }) { +function ArtistIndexOverviewOptionsModal({ isOpen, onModalClose, ...otherProps }) { return ( - @@ -17,9 +17,9 @@ function EditRootFolderModal({ isOpen, onModalClose, ...otherProps }) { ); } -EditRootFolderModal.propTypes = { +ArtistIndexOverviewOptionsModal.propTypes = { isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; -export default EditRootFolderModal; +export default ArtistIndexOverviewOptionsModal; diff --git a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.tsx b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.tsx deleted file mode 100644 index bc999cee4..000000000 --- a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModal.tsx +++ /dev/null @@ -1,25 +0,0 @@ -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 new file mode 100644 index 000000000..2fe569965 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.js @@ -0,0 +1,287 @@ +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 deleted file mode 100644 index 4ab9391e3..000000000 --- a/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContent.tsx +++ /dev/null @@ -1,197 +0,0 @@ -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 new file mode 100644 index 000000000..70c30dba6 --- /dev/null +++ b/frontend/src/Artist/Index/Overview/Options/ArtistIndexOverviewOptionsModalContentConnector.js @@ -0,0 +1,23 @@ +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 deleted file mode 100644 index 5875163c8..000000000 --- a/frontend/src/Artist/Index/Overview/selectOverviewOptions.ts +++ /dev/null @@ -1,9 +0,0 @@ -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 aaccec8a8..cd378e34c 100644 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css @@ -1,11 +1,15 @@ $hoverScale: 1.05; +.container { + padding: 10px; +} + .content { transition: all 200ms ease-in; &:hover { z-index: 2; - box-shadow: 0 0 12px var(--black); + box-shadow: 0 0 12px $black; transition: all 200ms ease-in; .controls { @@ -25,7 +29,7 @@ $hoverScale: 1.05; position: relative; display: block; height: 70px; - background-color: var(--defaultColor); + background-color: $defaultColor; } .overlayTitle { @@ -38,13 +42,13 @@ $hoverScale: 1.05; padding: 5px; width: 100%; height: 100%; - color: var(--offWhite); + color: $offWhite; text-align: center; font-size: 20px; } -.nextAlbum { - background-color: var(--artistBackgroundColor); +.nextAiring { + background-color: #fafbfc; text-align: center; font-size: $smallFontSize; } @@ -52,7 +56,8 @@ $hoverScale: 1.05; .title { @add-mixin truncate; - background-color: var(--artistBackgroundColor); + background-color: $defaultColor; + color: $white; text-align: center; font-size: $smallFontSize; } @@ -66,8 +71,8 @@ $hoverScale: 1.05; height: 0; border-width: 0 25px 25px 0; border-style: solid; - border-color: transparent var(--dangerColor) transparent transparent; - color: var(--white); + border-color: transparent $dangerColor transparent transparent; + color: $white; } .controls { @@ -77,7 +82,7 @@ $hoverScale: 1.05; z-index: 3; border-radius: 4px; background-color: #216044; - color: var(--white); + color: $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 deleted file mode 100644 index b1eeccf08..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.css.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -// 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 new file mode 100644 index 000000000..101b49f7b --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPoster.js @@ -0,0 +1,295 @@ +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 deleted file mode 100644 index 67c37c00d..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPoster.tsx +++ /dev/null @@ -1,263 +0,0 @@ -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 22ed2d528..aab27d827 100644 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css @@ -1,5 +1,5 @@ .info { - background-color: var(--artistBackgroundColor); + background-color: #fafbfc; 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 deleted file mode 100644 index 062365d36..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 new file mode 100644 index 000000000..591961605 --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.js @@ -0,0 +1,115 @@ +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 deleted file mode 100644 index 0d4ff9135..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosterInfo.tsx +++ /dev/null @@ -1,187 +0,0 @@ -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 deleted file mode 100644 index b97436b41..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 new file mode 100644 index 000000000..3650db93e --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPosters.js @@ -0,0 +1,326 @@ +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 deleted file mode 100644 index c478ac1ae..000000000 --- a/frontend/src/Artist/Index/Posters/ArtistIndexPosters.tsx +++ /dev/null @@ -1,313 +0,0 @@ -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 new file mode 100644 index 000000000..04c187e4e --- /dev/null +++ b/frontend/src/Artist/Index/Posters/ArtistIndexPostersConnector.js @@ -0,0 +1,24 @@ +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/MonitoringOptions/MonitoringOptionsModal.js b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.js similarity index 52% rename from frontend/src/Artist/MonitoringOptions/MonitoringOptionsModal.js rename to frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.js index 4071e7f9a..e1b0a257a 100644 --- a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModal.js +++ b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.js @@ -1,15 +1,15 @@ import PropTypes from 'prop-types'; import React from 'react'; import Modal from 'Components/Modal/Modal'; -import MonitoringOptionsModalContentConnector from './MonitoringOptionsModalContentConnector'; +import ArtistIndexPosterOptionsModalContentConnector from './ArtistIndexPosterOptionsModalContentConnector'; -function MonitoringOptionsModal({ isOpen, onModalClose, ...otherProps }) { +function ArtistIndexPosterOptionsModal({ isOpen, onModalClose, ...otherProps }) { return ( - @@ -17,9 +17,9 @@ function MonitoringOptionsModal({ isOpen, onModalClose, ...otherProps }) { ); } -MonitoringOptionsModal.propTypes = { +ArtistIndexPosterOptionsModal.propTypes = { isOpen: PropTypes.bool.isRequired, onModalClose: PropTypes.func.isRequired }; -export default MonitoringOptionsModal; +export default ArtistIndexPosterOptionsModal; diff --git a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.tsx b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.tsx deleted file mode 100644 index 69368807a..000000000 --- a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModal.tsx +++ /dev/null @@ -1,21 +0,0 @@ -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 new file mode 100644 index 000000000..6918436a6 --- /dev/null +++ b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.js @@ -0,0 +1,213 @@ +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 deleted file mode 100644 index 2560d855a..000000000 --- a/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContent.tsx +++ /dev/null @@ -1,167 +0,0 @@ -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 new file mode 100644 index 000000000..72af268ad --- /dev/null +++ b/frontend/src/Artist/Index/Posters/Options/ArtistIndexPosterOptionsModalContentConnector.js @@ -0,0 +1,23 @@ +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 deleted file mode 100644 index 1a53a0add..000000000 --- a/frontend/src/Artist/Index/Posters/selectPosterOptions.ts +++ /dev/null @@ -1,9 +0,0 @@ -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 9b5777117..b98bb33d5 100644 --- a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css +++ b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css @@ -3,7 +3,8 @@ border-radius: 0; background-color: #5b5b5b; - color: var(--white); + color: $white; + transition: width 200ms ease; } .progressBar { diff --git a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css.d.ts b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css.d.ts deleted file mode 100644 index dab280261..000000000 --- a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 new file mode 100644 index 000000000..6be32a46d --- /dev/null +++ b/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.js @@ -0,0 +1,47 @@ +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 deleted file mode 100644 index 2a8167b99..000000000 --- a/frontend/src/Artist/Index/ProgressBar/ArtistIndexProgressBar.tsx +++ /dev/null @@ -1,72 +0,0 @@ -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 deleted file mode 100644 index 5f6ee37c1..000000000 --- a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css +++ /dev/null @@ -1,10 +0,0 @@ -.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 deleted file mode 100644 index 13c576f2c..000000000 --- a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 255bd9ba4..000000000 --- a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumDetails.tsx +++ /dev/null @@ -1,89 +0,0 @@ -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 deleted file mode 100644 index c568a2489..000000000 --- a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css +++ /dev/null @@ -1,39 +0,0 @@ -.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 deleted file mode 100644 index 31142374e..000000000 --- a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.css.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 deleted file mode 100644 index 3e7e0578f..000000000 --- a/frontend/src/Artist/Index/Select/AlbumStudio/AlbumStudioAlbum.tsx +++ /dev/null @@ -1,87 +0,0 @@ -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 deleted file mode 100644 index b48717af0..000000000 --- a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModal.tsx +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index 29dc69dc4..000000000 --- a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css +++ /dev/null @@ -1,26 +0,0 @@ -.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 deleted file mode 100644 index 4c59f6545..000000000 --- a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 deleted file mode 100644 index b3c2abbbe..000000000 --- a/frontend/src/Artist/Index/Select/AlbumStudio/ChangeMonitoringModalContent.tsx +++ /dev/null @@ -1,96 +0,0 @@ -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 deleted file mode 100644 index eccb80f87..000000000 --- a/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css +++ /dev/null @@ -1,38 +0,0 @@ -.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 deleted file mode 100644 index d4de0b5f5..000000000 --- a/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 deleted file mode 100644 index 86b41e8ba..000000000 --- a/frontend/src/Artist/Index/Select/ArtistIndexPosterSelect.tsx +++ /dev/null @@ -1,45 +0,0 @@ -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 deleted file mode 100644 index 2b3e9c01c..000000000 --- a/frontend/src/Artist/Index/Select/ArtistIndexSelectAllButton.tsx +++ /dev/null @@ -1,40 +0,0 @@ -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 deleted file mode 100644 index 2340b65b6..000000000 --- a/frontend/src/Artist/Index/Select/ArtistIndexSelectAllMenuItem.tsx +++ /dev/null @@ -1,41 +0,0 @@ -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 deleted file mode 100644 index d385923ef..000000000 --- a/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css +++ /dev/null @@ -1,72 +0,0 @@ -.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 deleted file mode 100644 index 7f02229e3..000000000 --- a/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.css.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 deleted file mode 100644 index f0569d607..000000000 --- a/frontend/src/Artist/Index/Select/ArtistIndexSelectFooter.tsx +++ /dev/null @@ -1,300 +0,0 @@ -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 deleted file mode 100644 index 8679bba99..000000000 --- a/frontend/src/Artist/Index/Select/ArtistIndexSelectModeButton.tsx +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index b5a7a6de4..000000000 --- a/frontend/src/Artist/Index/Select/ArtistIndexSelectModeMenuItem.tsx +++ /dev/null @@ -1,38 +0,0 @@ -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 deleted file mode 100644 index 5d5f1fb6a..000000000 --- a/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModal.tsx +++ /dev/null @@ -1,21 +0,0 @@ -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/Index/Select/AudioTags/RetagArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css.d.ts deleted file mode 100644 index c2556006e..000000000 --- a/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index b67ee60aa..000000000 --- a/frontend/src/Artist/Index/Select/AudioTags/RetagArtistModalContent.tsx +++ /dev/null @@ -1,91 +0,0 @@ -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 deleted file mode 100644 index c909d7406..000000000 --- a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModal.tsx +++ /dev/null @@ -1,24 +0,0 @@ -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/Index/Select/Delete/DeleteArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css.d.ts deleted file mode 100644 index bcc2e2492..000000000 --- a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 deleted file mode 100644 index 4accc9f0e..000000000 --- a/frontend/src/Artist/Index/Select/Delete/DeleteArtistModalContent.tsx +++ /dev/null @@ -1,166 +0,0 @@ -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 deleted file mode 100644 index bdb6726be..000000000 --- a/frontend/src/Artist/Index/Select/Edit/EditArtistModal.tsx +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index ea406894e..000000000 --- a/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css +++ /dev/null @@ -1,16 +0,0 @@ -.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 deleted file mode 100644 index cbf2d6328..000000000 --- a/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 993be8ce5..000000000 --- a/frontend/src/Artist/Index/Select/Edit/EditArtistModalContent.tsx +++ /dev/null @@ -1,264 +0,0 @@ -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 deleted file mode 100644 index bec35222b..000000000 --- a/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModal.tsx +++ /dev/null @@ -1,21 +0,0 @@ -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/Index/Select/Organize/OrganizeArtistModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css.d.ts deleted file mode 100644 index ae2303476..000000000 --- a/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 8184abba7..000000000 --- a/frontend/src/Artist/Index/Select/Organize/OrganizeArtistModalContent.tsx +++ /dev/null @@ -1,91 +0,0 @@ -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 deleted file mode 100644 index 8635867e4..000000000 --- a/frontend/src/Artist/Index/Select/Tags/TagsModal.tsx +++ /dev/null @@ -1,22 +0,0 @@ -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/Index/Select/Tags/TagsModalContent.css.d.ts b/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css.d.ts deleted file mode 100644 index 9b4321dcc..000000000 --- a/frontend/src/Artist/Index/Select/Tags/TagsModalContent.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 deleted file mode 100644 index 95a7eaae2..000000000 --- a/frontend/src/Artist/Index/Select/Tags/TagsModalContent.tsx +++ /dev/null @@ -1,189 +0,0 @@ -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 deleted file mode 100644 index 307c5d406..000000000 --- a/frontend/src/Artist/Index/Table/AlbumsCell.css +++ /dev/null @@ -1,4 +0,0 @@ -.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 deleted file mode 100644 index 93d667287..000000000 --- a/frontend/src/Artist/Index/Table/AlbumsCell.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 deleted file mode 100644 index b42298b5d..000000000 --- a/frontend/src/Artist/Index/Table/AlbumsCell.tsx +++ /dev/null @@ -1,38 +0,0 @@ -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 new file mode 100644 index 000000000..3f37cd56a --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexActionsCell.js @@ -0,0 +1,102 @@ +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/ArtistIndexTableHeader.css b/frontend/src/Artist/Index/Table/ArtistIndexHeader.css similarity index 98% rename from frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css rename to frontend/src/Artist/Index/Table/ArtistIndexHeader.css index 7ea4e94aa..6da0be920 100644 --- a/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css +++ b/frontend/src/Artist/Index/Table/ArtistIndexHeader.css @@ -31,7 +31,6 @@ flex: 1 0 125px; } -.monitorNewItems, .nextAlbum, .lastAlbum, .added, diff --git a/frontend/src/Artist/Index/Table/ArtistIndexHeader.js b/frontend/src/Artist/Index/Table/ArtistIndexHeader.js new file mode 100644 index 000000000..aed47bafa --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexHeader.js @@ -0,0 +1,86 @@ +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 new file mode 100644 index 000000000..37ddd9ef3 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexHeaderConnector.js @@ -0,0 +1,13 @@ +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 35d03c263..29c89c696 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: var(--defaultColor); + background-color: $defaultColor; } .bannerImage { @@ -55,7 +55,7 @@ padding: 5px; width: 100%; height: 100%; - color: var(--offWhite); + color: $offWhite; text-align: center; font-size: 20px; } @@ -67,7 +67,6 @@ flex: 1 0 125px; } -.monitorNewItems, .nextAlbum, .lastAlbum, .added, @@ -111,7 +110,7 @@ } .ratings { - composes: cell from '~Components/Table/Cells/VirtualTableRowCell.css'; + composes: headerCell from '~Components/Table/VirtualTableHeaderCell.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 deleted file mode 100644 index 4855aec75..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexRow.css.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -// 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 new file mode 100644 index 000000000..6b597509f --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexRow.js @@ -0,0 +1,484 @@ +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 deleted file mode 100644 index 0398f5502..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexRow.tsx +++ /dev/null @@ -1,422 +0,0 @@ -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 0bfc5fec4..23ab127b5 100644 --- a/frontend/src/Artist/Index/Table/ArtistIndexTable.css +++ b/frontend/src/Artist/Index/Table/ArtistIndexTable.css @@ -1,11 +1,5 @@ -.tableScroller { - position: relative; -} +.tableContainer { + composes: tableContainer from '~Components/Table/VirtualTable.css'; -.row { - transition: background-color 500ms; - - &:hover { - background-color: var(--tableRowHoverBackgroundColor); - } + flex: 1 0 auto; } diff --git a/frontend/src/Artist/Index/Table/ArtistIndexTable.css.d.ts b/frontend/src/Artist/Index/Table/ArtistIndexTable.css.d.ts deleted file mode 100644 index ff35c263f..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTable.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 new file mode 100644 index 000000000..fcece7a2c --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTable.js @@ -0,0 +1,132 @@ +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 deleted file mode 100644 index c3c8044ce..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTable.tsx +++ /dev/null @@ -1,215 +0,0 @@ -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 new file mode 100644 index 000000000..3a97425cc --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableConnector.js @@ -0,0 +1,29 @@ +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/ArtistIndexTableHeader.css.d.ts b/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css.d.ts deleted file mode 100644 index 467b401bb..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.css.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -// 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 deleted file mode 100644 index 1b325c225..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTableHeader.tsx +++ /dev/null @@ -1,121 +0,0 @@ -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 new file mode 100644 index 000000000..110a024e4 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.js @@ -0,0 +1,100 @@ +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 deleted file mode 100644 index 9c10d859d..000000000 --- a/frontend/src/Artist/Index/Table/ArtistIndexTableOptions.tsx +++ /dev/null @@ -1,63 +0,0 @@ -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 new file mode 100644 index 000000000..0a1607cf2 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistIndexTableOptionsConnector.js @@ -0,0 +1,14 @@ +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 a4cb08a22..fbcd5eee9 100644 --- a/frontend/src/Artist/Index/Table/ArtistStatusCell.css +++ b/frontend/src/Artist/Index/Table/ArtistStatusCell.css @@ -4,14 +4,6 @@ width: 60px; } -.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 deleted file mode 100644 index eff3e0343..000000000 --- a/frontend/src/Artist/Index/Table/ArtistStatusCell.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 new file mode 100644 index 000000000..26fde0e12 --- /dev/null +++ b/frontend/src/Artist/Index/Table/ArtistStatusCell.js @@ -0,0 +1,53 @@ +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 deleted file mode 100644 index 00c7ae4c8..000000000 --- a/frontend/src/Artist/Index/Table/ArtistStatusCell.tsx +++ /dev/null @@ -1,75 +0,0 @@ -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 new file mode 100644 index 000000000..994436d9f --- /dev/null +++ b/frontend/src/Artist/Index/Table/hasGrowableColumns.js @@ -0,0 +1,16 @@ +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 deleted file mode 100644 index ed0cc6c58..000000000 --- a/frontend/src/Artist/Index/Table/hasGrowableColumns.ts +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index b6a2a6a94..000000000 --- a/frontend/src/Artist/Index/Table/selectTableOptions.ts +++ /dev/null @@ -1,9 +0,0 @@ -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 deleted file mode 100644 index 4388a3aeb..000000000 --- a/frontend/src/Artist/Index/createArtistIndexItemSelector.ts +++ /dev/null @@ -1,45 +0,0 @@ -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 deleted file mode 100644 index 34a9c3910..000000000 --- a/frontend/src/Artist/Index/createArtistQueueDetailsSelector.ts +++ /dev/null @@ -1,39 +0,0 @@ -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 deleted file mode 100644 index 6ea9e8290..000000000 --- a/frontend/src/Artist/MonitoringOptions/MonitoringOptionModalConnector.js +++ /dev/null @@ -1,39 +0,0 @@ -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/MonitoringOptionsModalContent.css b/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css deleted file mode 100644 index 3e9e3ffd0..000000000 --- a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css +++ /dev/null @@ -1,9 +0,0 @@ -.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 deleted file mode 100644 index af0f6cd46..000000000 --- a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index b1550d39e..000000000 --- a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContent.js +++ /dev/null @@ -1,156 +0,0 @@ -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 deleted file mode 100644 index 1901e1d21..000000000 --- a/frontend/src/Artist/MonitoringOptions/MonitoringOptionsModalContentConnector.js +++ /dev/null @@ -1,77 +0,0 @@ -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 deleted file mode 100644 index 0475f5a86..000000000 --- a/frontend/src/Artist/MoveArtist/MoveArtistModal.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 1bad51151..3f78187ff 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 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 ModalBody from 'Components/Modal/ModalBody'; +import ModalFooter from 'Components/Modal/ModalFooter'; import styles from './MoveArtistModal.css'; function MoveArtistModal(props) { @@ -15,7 +15,6 @@ function MoveArtistModal(props) { destinationPath, destinationRootFolder, isOpen, - onModalClose, onSavePress, onMoveArtistPress } = props; @@ -34,11 +33,11 @@ function MoveArtistModal(props) { isOpen={isOpen} size={sizes.MEDIUM} closeOnBackgroundClick={false} - onModalClose={onModalClose} + onModalClose={onSavePress} > Move Files @@ -77,7 +76,6 @@ 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 deleted file mode 100644 index 054af6200..000000000 --- a/frontend/src/Artist/NoArtist.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 ec812fc84..b869a8d58 100644 --- a/frontend/src/Artist/NoArtist.js +++ b/frontend/src/Artist/NoArtist.js @@ -1,8 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; -import Button from 'Components/Link/Button'; import { kinds } from 'Helpers/Props'; -import translate from 'Utilities/String/translate'; +import Button from 'Components/Link/Button'; import styles from './NoArtist.css'; function NoArtist(props) { @@ -12,7 +11,7 @@ function NoArtist(props) { return (
- All artists are hidden due to the applied filter. + All artists are hidden due to the applied filter.
); @@ -21,24 +20,24 @@ function NoArtist(props) { return (
- 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. + No artist found, to get started you'll want to add a new artist or import some existing ones.
diff --git a/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js b/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js index 9ce7e8f9a..0da3661a8 100644 --- a/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js +++ b/frontend/src/Artist/Search/ArtistInteractiveSearchModal.js @@ -1,7 +1,6 @@ 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) { @@ -14,7 +13,6 @@ function ArtistInteractiveSearchModal(props) { return ( diff --git a/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js b/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js index 6706a27fa..fe3170570 100644 --- a/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js +++ b/frontend/src/Artist/Search/ArtistInteractiveSearchModalConnector.js @@ -1,19 +1,9 @@ -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()); @@ -22,38 +12,4 @@ function createMapDispatchToProps(dispatch, props) { }; } -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); +export default connect(null, createMapDispatchToProps)(ArtistInteractiveSearchModal); diff --git a/frontend/src/Artist/Search/ArtistInteractiveSearchModalContent.js b/frontend/src/Artist/Search/ArtistInteractiveSearchModalContent.js index 2a203499e..9b7f4c6ed 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 ModalBody from 'Components/Modal/ModalBody'; import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalFooter from 'Components/Modal/ModalFooter'; 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 deleted file mode 100644 index 44421cc99..000000000 --- a/frontend/src/Calendar/Agenda/Agenda.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 a987a4b8c..876c9fc75 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 var(--borderColor); + border-bottom: 1px solid $borderColor; font-size: $defaultFontSize; &:hover { - background-color: var(--tableRowHoverBackgroundColor); + background-color: $tableRowHoverBackgroundColor; } } @@ -25,7 +25,7 @@ } .time { - flex: 0 0 125px; + flex: 0 0 120px; 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 deleted file mode 100644 index 5bf39a6de..000000000 --- a/frontend/src/Calendar/Agenda/AgendaEvent.css.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -// 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 d21b1aaa2..44ad53063 100644 --- a/frontend/src/Calendar/Agenda/AgendaEvent.js +++ b/frontend/src/Calendar/Agenda/AgendaEvent.js @@ -1,14 +1,13 @@ -import classNames from 'classnames'; import moment from 'moment'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import CalendarEventQueueDetails from 'Calendar/Events/CalendarEventQueueDetails'; +import classNames from 'classnames'; +import formatTime from 'Utilities/Date/formatTime'; +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 formatTime from 'Utilities/Date/formatTime'; -import translate from 'Utilities/String/translate'; +import CalendarEventQueueDetails from 'Calendar/Events/CalendarEventQueueDetails'; import styles from './AgendaEvent.css'; class AgendaEvent extends Component { @@ -28,11 +27,11 @@ class AgendaEvent extends Component { onPress = () => { this.setState({ isDetailsModalOpen: true }); - }; + } onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }); - }; + } // // Render @@ -111,7 +110,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 deleted file mode 100644 index 503034402..000000000 --- a/frontend/src/Calendar/Calendar.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 a0b22f92f..6ceb1f3bb 100644 --- a/frontend/src/Calendar/Calendar.js +++ b/frontend/src/Calendar/Calendar.js @@ -1,14 +1,11 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import Alert from 'Components/Alert'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; -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 DaysOfWeekConnector from './Day/DaysOfWeekConnector'; +import CalendarDaysConnector from './Day/CalendarDaysConnector'; +import AgendaConnector from './Agenda/AgendaConnector'; import styles from './Calendar.css'; class Calendar extends Component { @@ -33,9 +30,7 @@ class Calendar extends Component { { !isFetching && !!error && - - {translate('UnableToLoadTheCalendar')} - +
Unable to load the calendar
} { diff --git a/frontend/src/Calendar/CalendarConnector.js b/frontend/src/Calendar/CalendarConnector.js index 17221eb34..a97589c59 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 * as calendarActions from 'Store/Actions/calendarActions'; -import { clearQueueDetails, fetchQueueDetails } from 'Store/Actions/queueActions'; -import { clearTrackFiles, fetchTrackFiles } from 'Store/Actions/trackFileActions'; +import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; import hasDifferentItems from 'Utilities/Object/hasDifferentItems'; import selectUniqueIds from 'Utilities/Object/selectUniqueIds'; -import { registerPagePopulator, unregisterPagePopulator } from 'Utilities/pagePopulator'; +import * as calendarActions from 'Store/Actions/calendarActions'; +import { fetchTrackFiles, clearTrackFiles } from 'Store/Actions/trackFileActions'; +import { fetchQueueDetails, clearQueueDetails } from 'Store/Actions/queueActions'; import Calendar from './Calendar'; const UPDATE_DELAY = 3600000; // 1 hour @@ -47,7 +47,7 @@ class CalendarConnector extends Component { gotoCalendarToday } = this.props; - registerPagePopulator(this.repopulate, ['trackFileUpdated', 'trackFileDeleted']); + registerPagePopulator(this.repopulate); 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 deleted file mode 100644 index e26b2928b..000000000 --- a/frontend/src/Calendar/CalendarFilterModal.tsx +++ /dev/null @@ -1,54 +0,0 @@ -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 deleted file mode 100644 index 943329132..000000000 --- a/frontend/src/Calendar/CalendarPage.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 bf7f46c10..9dfe3229e 100644 --- a/frontend/src/Calendar/CalendarPage.js +++ b/frontend/src/Calendar/CalendarPage.js @@ -1,23 +1,19 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import NoArtist from 'Artist/NoArtist'; -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 { 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 LegendConnector from './Legend/LegendConnector'; import CalendarOptionsModal from './Options/CalendarOptionsModal'; +import LegendConnector from './Legend/LegendConnector'; +import CalendarConnector from './CalendarConnector'; import styles from './CalendarPage.css'; const MINIMUM_DAY_WIDTH = 120; @@ -45,23 +41,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 { @@ -70,7 +66,7 @@ class CalendarPage extends Component { } = this.props; onSearchMissingPress(missingAlbumIds); - }; + } // // Render @@ -79,16 +75,11 @@ class CalendarPage extends Component { const { selectedFilterKey, filters, - customFilters, hasArtist, artistError, - artistIsFetching, - artistIsPopulated, missingAlbumIds, - isRssSyncExecuting, isSearchingForMissing, useCurrentPage, - onRssSyncPress, onFilterSelect } = this.props; @@ -99,27 +90,20 @@ class CalendarPage extends Component { const isMeasured = this.state.width > 0; + const PageComponent = hasArtist ? CalendarConnector : NoArtist; + return ( - + - - - - @@ -139,38 +123,32 @@ class CalendarPage extends Component { isDisabled={!hasArtist} selectedFilterKey={selectedFilterKey} filters={filters} - customFilters={customFilters} - filterModalConnectorComponent={CalendarFilterModal} + customFilters={[]} onFilterSelect={onFilterSelect} /> - - { - artistIsFetching && !artistIsPopulated && - - } - { artistError && -
- {getErrorMessage(artistError, 'Failed to load artist from API')} -
+
+ {getErrorMessage(artistError, 'Failed to load artist from API')} +
} { - !artistError && artistIsPopulated && hasArtist && + !artistError && { isMeasured ? - :
@@ -178,16 +156,11 @@ 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 }; } @@ -95,16 +83,9 @@ 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 22d1b1ccf..79eb67ae7 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 var(--calendarBorderColor); - border-left: 1px solid var(--calendarBorderColor); + border-bottom: 1px solid $calendarBorderColor; + border-left: 1px solid $calendarBorderColor; } .isSingleDay { @@ -12,14 +12,14 @@ .dayOfMonth { padding-right: 5px; - border-bottom: 1px solid var(--calendarBorderColor); + border-bottom: 1px solid $calendarBorderColor; text-align: right; } .isToday { - background-color: var(--calendarTodayBackgroundColor); + background-color: $calendarTodayBackgroundColor; } .isDifferentMonth { - color: var(--disabledColor); + color: $disabledColor; } diff --git a/frontend/src/Calendar/Day/CalendarDay.css.d.ts b/frontend/src/Calendar/Day/CalendarDay.css.d.ts deleted file mode 100644 index f32def3dd..000000000 --- a/frontend/src/Calendar/Day/CalendarDay.css.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 50bf9fc92..bd196cc5d 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 507dd0ede..b6dd2100c 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 var(--calendarBorderColor); + border-right: 1px solid $calendarBorderColor; } .day, diff --git a/frontend/src/Calendar/Day/CalendarDays.css.d.ts b/frontend/src/Calendar/Day/CalendarDays.css.d.ts deleted file mode 100644 index ae3e7aebc..000000000 --- a/frontend/src/Calendar/Day/CalendarDays.css.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 f2bb4c8d4..0a1a36172 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 * as calendarViews from 'Calendar/calendarViews'; +import classNames from 'classnames'; import isToday from 'Utilities/Date/isToday'; +import * as calendarViews from 'Calendar/calendarViews'; 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 0acce70b9..3dea906a7 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 { gotoCalendarNextRange, gotoCalendarPreviousRange } from 'Store/Actions/calendarActions'; +import { gotoCalendarPreviousRange, gotoCalendarNextRange } 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 2d31a30be..8c3552e55 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: var(--calendarBackgroundColor); + background-color: #e4eaec; text-align: center; } @@ -9,5 +9,5 @@ } .isToday { - background-color: var(--calendarTodayBackgroundColor); + background-color: $calendarTodayBackgroundColor; } diff --git a/frontend/src/Calendar/Day/DayOfWeek.css.d.ts b/frontend/src/Calendar/Day/DayOfWeek.css.d.ts deleted file mode 100644 index a377e4a8e..000000000 --- a/frontend/src/Calendar/Day/DayOfWeek.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 39e40fce8..d97671522 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 * as calendarViews from 'Calendar/calendarViews'; +import classNames from 'classnames'; import getRelativeDate from 'Utilities/Date/getRelativeDate'; +import * as calendarViews from 'Calendar/calendarViews'; 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 deleted file mode 100644 index 5bc224b68..000000000 --- a/frontend/src/Calendar/Day/DaysOfWeek.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 9f94b1079..a67777f7c 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 * as calendarViews from 'Calendar/calendarViews'; import DayOfWeek from './DayOfWeek'; +import * as calendarViews from 'Calendar/calendarViews'; 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 b317c72ce..055d51882 100644 --- a/frontend/src/Calendar/Events/CalendarEvent.css +++ b/frontend/src/Calendar/Events/CalendarEvent.css @@ -1,11 +1,9 @@ -$fullColorGradient: rgba(244, 245, 246, 0.2); - .event { overflow-x: hidden; margin: 4px 2px; padding: 5px; - border-bottom: 1px solid var(--calendarBorderColor); - border-left: 4px solid var(--calendarBorderColor); + border-bottom: 1px solid $borderColor; + border-left: 4px solid $borderColor; font-size: 12px; &:global(.colorImpaired) { @@ -27,7 +25,7 @@ $fullColorGradient: rgba(244, 245, 246, 0.2); } .artistName { - color: var(--calendarTextDimAlternate); + color: #3a3f51; font-size: $defaultFontSize; } @@ -44,50 +42,38 @@ $fullColorGradient: rgba(244, 245, 246, 0.2); */ .downloaded { - border-left-color: var(--successColor) !important; + border-left-color: $successColor !important; &:global(.colorImpaired) { - border-left-color: color(#27c24c saturation(+15%)) !important; + border-left-color: color($successColor, saturation(+15%)) !important; } } .downloading { - border-left-color: var(--purple) !important; - - &:global(.fullColor) { - background-color: rgba(122, 67, 182, 0.4) !important; - } + border-left-color: $purple !important; } .unmonitored { - border-left-color: var(--gray) !important; - - &:global(.fullColor) { - background-color: rgba(173, 173, 173, 0.5) !important; - } + border-left-color: $gray !important; &:global(.colorImpaired) { - 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); + background: repeating-linear-gradient(90deg, $colorImpairedGradientDark, $colorImpairedGradientDark 5px, $colorImpairedGradient 5px, $colorImpairedGradient 10px); } } .missing { - border-left-color: var(--dangerColor) !important; + border-left-color: $dangerColor !important; &:global(.colorImpaired) { - border-left-color: color(#f05050 saturation(+15%)) !important; - background: repeating-linear-gradient(90deg, var(--colorImpairedGradientDark), var(--colorImpairedGradientDark) 5px, var(--colorImpairedGradient) 5px, var(--colorImpairedGradient) 10px); + border-left-color: color($dangerColor saturation(+15%)) !important; + background: repeating-linear-gradient(90deg, $colorImpairedGradientDark, $colorImpairedGradientDark 5px, $colorImpairedGradient 5px, $colorImpairedGradient 10px); } } .unreleased { - border-left-color: var(--primaryColor) !important; + border-left-color: $primaryColor !important; &:global(.colorImpaired) { - background: repeating-linear-gradient(90deg, var(--colorImpairedGradientDark), var(--colorImpairedGradientDark) 5px, var(--colorImpairedGradient) 5px, var(--colorImpairedGradient) 10px); + background: repeating-linear-gradient(90deg, $colorImpairedGradientDark, $colorImpairedGradientDark 5px, $colorImpairedGradient 5px, $colorImpairedGradient 10px); } } diff --git a/frontend/src/Calendar/Events/CalendarEvent.css.d.ts b/frontend/src/Calendar/Events/CalendarEvent.css.d.ts deleted file mode 100644 index 61bc8c539..000000000 --- a/frontend/src/Calendar/Events/CalendarEvent.css.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// 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 115314b92..8f04fd670 100644 --- a/frontend/src/Calendar/Events/CalendarEvent.js +++ b/frontend/src/Calendar/Events/CalendarEvent.js @@ -1,12 +1,11 @@ -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'; @@ -30,13 +29,13 @@ class CalendarEvent extends Component { this.setState({ isDetailsModalOpen: true }, () => { this.props.onEventModalOpenToggle(true); }); - }; + } onDetailsModalClose = () => { this.setState({ isDetailsModalOpen: false }, () => { this.props.onEventModalOpenToggle(false); }); - }; + } // // Render @@ -95,11 +94,11 @@ class CalendarEvent extends Component { { !queueItem && grabbed && - + }
diff --git a/frontend/src/Calendar/Events/CalendarEventQueueDetails.js b/frontend/src/Calendar/Events/CalendarEventQueueDetails.js index 5df7e8ea4..1b603fd50 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 QueueDetails from 'Activity/Queue/QueueDetails'; +import colors from 'Styles/Variables/colors'; import CircularProgressBar from 'Components/CircularProgressBar'; -import translate from 'Utilities/String/translate'; +import QueueDetails from 'Activity/Queue/QueueDetails'; function CalendarEventQueueDetails(props) { const { @@ -11,12 +11,10 @@ function CalendarEventQueueDetails(props) { sizeleft, estimatedCompletionTime, status, - trackedDownloadState, - trackedDownloadStatus, errorMessage } = props; - const progress = size ? (100 - sizeleft / size * 100) : 0; + const progress = (100 - sizeleft / size * 100); return ( +
} @@ -48,8 +44,6 @@ 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 deleted file mode 100644 index 700b53652..000000000 --- a/frontend/src/Calendar/Header/CalendarHeader.css.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// 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 24b397eb4..97052e0c8 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 * as calendarViews from 'Calendar/calendarViews'; -import Icon from 'Components/Icon'; +import { align, icons } from 'Helpers/Props'; import Button from 'Components/Link/Button'; +import Icon from 'Components/Icon'; 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 { align, icons } from 'Helpers/Props'; +import * as calendarViews from 'Calendar/calendarViews'; 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 616e48650..b73730ed9 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 98958af03..8dd5ae9f0 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 * as calendarViews from 'Calendar/calendarViews'; -import Button from 'Components/Link/Button'; import titleCase from 'Utilities/String/titleCase'; +import Button from 'Components/Link/Button'; +import * as calendarViews from 'Calendar/calendarViews'; // 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 deleted file mode 100644 index 19c0339b4..000000000 --- a/frontend/src/Calendar/Legend/Legend.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 88ddc82c7..cc69198fd 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 LegendIconItem from './LegendIconItem'; import LegendItem from './LegendItem'; +import LegendIconItem from './LegendIconItem'; 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 deleted file mode 100644 index 5d618d24b..000000000 --- a/frontend/src/Calendar/Legend/LegendIconItem.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 954aafd90..000000000 --- a/frontend/src/Calendar/Legend/LegendItem.css.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// 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 5da15baba..961f48b86 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 a291570bb..a25d36f9c 100644 --- a/frontend/src/Calendar/Options/CalendarOptionsModalContent.js +++ b/frontend/src/Calendar/Options/CalendarOptionsModalContent.js @@ -1,18 +1,17 @@ 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 FormInputGroup from 'Components/Form/FormInputGroup'; import FormLabel from 'Components/Form/FormLabel'; -import Button from 'Components/Link/Button'; -import ModalBody from 'Components/Modal/ModalBody'; +import FormInputGroup from 'Components/Form/FormInputGroup'; import ModalContent from 'Components/Modal/ModalContent'; -import ModalFooter from 'Components/Modal/ModalFooter'; 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'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalFooter from 'Components/Modal/ModalFooter'; +import { firstDayOfWeekOptions, weekColumnOptions, timeFormatOptions } from 'Settings/UI/UISettings'; class CalendarOptionsModalContent extends Component { @@ -69,7 +68,7 @@ class CalendarOptionsModalContent extends Component { } = this.props; dispatchSetCalendarOption({ [name]: value }); - }; + } onGlobalInputChange = ({ name, value }) => { const { @@ -81,11 +80,11 @@ class CalendarOptionsModalContent extends Component { this.setState(setting, () => { dispatchSaveUISettings(setting); }); - }; + } onLinkFocus = (event) => { event.target.select(); - }; + } // // Render @@ -111,44 +110,38 @@ class CalendarOptionsModalContent extends Component {
-
+
- - {translate('CollapseMultipleAlbums')} - + Collapse Multiple Albums - - {translate('IconForCutoffUnmet')} - + Icon for Cutoff Unmet
-
+
- - {translate('FirstDayOfWeek')} - + First Day of Week - - {translate('WeekColumnHeader')} - + Week Column Header - - {translate('TimeFormat')} - + Time Format - - {translate('EnableColorImpairedMode')} - + Enable Color-Impaired Mode diff --git a/frontend/src/Calendar/Options/CalendarOptionsModalContentConnector.js b/frontend/src/Calendar/Options/CalendarOptionsModalContentConnector.js index 1f517b698..eb979f74e 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 { saveUISettings } from 'Store/Actions/settingsActions'; import CalendarOptionsModalContent from './CalendarOptionsModalContent'; +import { saveUISettings } from 'Store/Actions/settingsActions'; function createMapStateToProps() { return createSelector( diff --git a/frontend/src/Calendar/iCal/CalendarLinkModalContent.js b/frontend/src/Calendar/iCal/CalendarLinkModalContent.js index 3473f4c31..074c66516 100644 --- a/frontend/src/Calendar/iCal/CalendarLinkModalContent.js +++ b/frontend/src/Calendar/iCal/CalendarLinkModalContent.js @@ -1,19 +1,18 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -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 { icons, inputTypes, kinds, sizes } from 'Helpers/Props'; import Icon from 'Components/Icon'; import Button from 'Components/Link/Button'; import ClipboardButton from 'Components/Link/ClipboardButton'; -import ModalBody from 'Components/Modal/ModalBody'; +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 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'; +import ModalBody from 'Components/Modal/ModalBody'; +import ModalFooter from 'Components/Modal/ModalFooter'; function getUrls(state) { const { @@ -33,7 +32,7 @@ function getUrls(state) { icalUrl += `tags=${tags.toString()}&`; } - icalUrl += `pastDays=${pastDays}&futureDays=${futureDays}&apikey=${encodeURIComponent(window.Lidarr.apiKey)}`; + icalUrl += `pastDays=${pastDays}&futureDays=${futureDays}&apikey=${window.Lidarr.apiKey}`; const iCalHttpUrl = `${window.location.protocol}//${icalUrl}`; const iCalWebCalUrl = `webcal://${icalUrl}`; @@ -82,11 +81,11 @@ class CalendarLinkModalContent extends Component { [name]: value, ...urls }); - }; + } onLinkFocus = (event) => { event.target.select(); - }; + } // // Render @@ -114,57 +113,49 @@ class CalendarLinkModalContent extends Component { - - {translate('IncludeUnmonitored')} - + Include Unmonitored - - {translate('PastDays')} - + Past Days - - {translate('FutureDays')} - + Future Days - - {translate('Tags')} - + Tags @@ -172,16 +163,14 @@ class CalendarLinkModalContent extends Component { - - {translate('ICalFeed')} - + iCal Feed + @@ -30,13 +29,12 @@ 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 786123fb7..b23415a76 100644 --- a/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css +++ b/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css @@ -1,7 +1,9 @@ +.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 deleted file mode 100644 index ff7055b0f..000000000 --- a/frontend/src/Components/DescriptionList/DescriptionListItemDescription.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 deleted file mode 100644 index 86bceec06..000000000 --- a/frontend/src/Components/DescriptionList/DescriptionListItemTitle.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 deleted file mode 100644 index 6944a829d..000000000 --- a/frontend/src/Components/DragPreviewLayer.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 88412ad19..87fb2498a 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 3e7a04302..b6d1f917e 100644 --- a/frontend/src/Components/Error/ErrorBoundaryError.css +++ b/frontend/src/Components/Error/ErrorBoundaryError.css @@ -25,10 +25,6 @@ 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 deleted file mode 100644 index e19fd804d..000000000 --- a/frontend/src/Components/Error/ErrorBoundaryError.css.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 new file mode 100644 index 000000000..f99930437 --- /dev/null +++ b/frontend/src/Components/Error/ErrorBoundaryError.js @@ -0,0 +1,60 @@ +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 deleted file mode 100644 index e7e74d10a..000000000 --- a/frontend/src/Components/Error/ErrorBoundaryError.tsx +++ /dev/null @@ -1,73 +0,0 @@ -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 9ea0dbab1..daf3bdf2e 100644 --- a/frontend/src/Components/FieldSet.css +++ b/frontend/src/Components/FieldSet.css @@ -13,12 +13,7 @@ width: 100%; border: 0; border-bottom: 1px solid #e5e5e5; - color: var(--textColor); + color: #3a3f51; 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 deleted file mode 100644 index 74e99779a..000000000 --- a/frontend/src/Components/FieldSet.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 8243fd00c..76e68a934 100644 --- a/frontend/src/Components/FieldSet.js +++ b/frontend/src/Components/FieldSet.js @@ -1,7 +1,5 @@ -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 { @@ -11,14 +9,13 @@ class FieldSet extends Component { render() { const { - size, legend, children } = this.props; return (
- + {legend} {children} @@ -29,13 +26,8 @@ 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 deleted file mode 100644 index 5d00cca7e..000000000 --- a/frontend/src/Components/FileBrowser/FileBrowserModal.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 db31d6f86..7ddb9e806 100644 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css +++ b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css @@ -13,7 +13,7 @@ } .faqLink { - color: var(--alertWarningColor); + color: $alertWarningColor; font-weight: bold; } diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css.d.ts b/frontend/src/Components/FileBrowser/FileBrowserModalContent.css.d.ts deleted file mode 100644 index e83c13075..000000000 --- a/frontend/src/Components/FileBrowser/FileBrowserModalContent.css.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 dff1fbf6e..ca84ac078 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 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 ModalBody from 'Components/Modal/ModalBody'; +import ModalFooter from 'Components/Modal/ModalFooter'; import Scroller from 'Components/Scroller/Scroller'; import Table from 'Components/Table/Table'; import TableBody from 'Components/Table/TableBody'; -import { kinds, scrollDirections } from 'Helpers/Props'; -import translate from 'Utilities/String/translate'; +import PathInput from 'Components/Form/PathInput'; import FileBrowserRow from './FileBrowserRow'; import styles from './FileBrowserModalContent.css'; const columns = [ { name: 'type', - label: () => translate('Type'), + label: 'Type', isVisible: true }, { name: 'name', - label: () => translate('Name'), + label: 'Name', isVisible: true } ]; @@ -38,7 +38,7 @@ class FileBrowserModalContent extends Component { constructor(props, context) { super(props, context); - this._scrollerRef = React.createRef(); + this._scrollerNode = null; this.state = { isFileBrowserModalOpen: false, @@ -56,7 +56,18 @@ class FileBrowserModalContent extends Component { currentPath !== prevState.currentPath ) { this.setState({ currentPath }); - this._scrollerRef.current.scrollTop = 0; + this._scrollerNode.scrollTop = 0; + } + } + + // + // Control + + setScrollerRef = (ref) => { + if (ref) { + this._scrollerNode = ReactDOM.findDOMNode(ref); + } else { + this._scrollerNode = null; } } @@ -65,11 +76,11 @@ class FileBrowserModalContent extends Component { onPathInputChange = ({ value }) => { this.setState({ currentPath: value }); - }; + } onRowPress = (path) => { this.props.onFetchPaths(path); - }; + } onOkPress = () => { this.props.onChange({ @@ -79,7 +90,7 @@ class FileBrowserModalContent extends Component { this.props.onClearPaths(); this.props.onModalClose(); - }; + } // // Render @@ -117,13 +128,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 && -
- {translate('ErrorLoadingContents')} -
+
Error loading contents
} { @@ -214,13 +223,13 @@ class FileBrowserModalContent extends Component { diff --git a/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js b/frontend/src/Components/FileBrowser/FileBrowserModalContentConnector.js index 1a3a41ef0..da5ae2ab8 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 { clearPaths, fetchPaths } from 'Store/Actions/pathActions'; +import { fetchPaths, clearPaths } 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 deleted file mode 100644 index 127d00928..000000000 --- a/frontend/src/Components/FileBrowser/FileBrowserRow.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 06bb3029d..42ac30405 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 Icon from 'Components/Icon'; -import TableRowCell from 'Components/Table/Cells/TableRowCell'; -import TableRowButton from 'Components/Table/TableRowButton'; import { icons } from 'Helpers/Props'; +import Icon from 'Components/Icon'; +import TableRowButton from 'Components/Table/TableRowButton'; +import TableRowCell from 'Components/Table/Cells/TableRowCell'; 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 deleted file mode 100644 index 486027f35..000000000 --- a/frontend/src/Components/Filter/Builder/ArtistFilterBuilderRowValue.tsx +++ /dev/null @@ -1,19 +0,0 @@ -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 2b28e0f42..28070d200 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: 'Inactive' } + { id: 'ended', name: 'Ended' } ]; 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 deleted file mode 100644 index d391a1f30..000000000 --- a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 0193cf44f..f0c2d3626 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,12 +18,7 @@ const timeOptions = [ ]; function isInFilter(filterType) { - return ( - filterType === IN_LAST || - filterType === NOT_IN_LAST || - filterType === IN_NEXT || - filterType === NOT_IN_NEXT - ); + return filterType === IN_LAST || filterType === IN_NEXT; } class DateFilterBuilderRowValue extends Component { @@ -102,7 +97,7 @@ class DateFilterBuilderRowValue extends Component { name: NAME, value: newValue }); - }; + } onTimeChange = ({ value }) => { const { @@ -117,7 +112,7 @@ class DateFilterBuilderRowValue extends Component { value: filterValue.value } }); - }; + } // // Render @@ -160,7 +155,6 @@ 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 deleted file mode 100644 index 033d2edca..000000000 --- a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 0c4a31657..62c3f0197 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.js @@ -1,15 +1,13 @@ -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 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 ModalBody from 'Components/Modal/ModalBody'; +import ModalFooter from 'Components/Modal/ModalFooter'; import FilterBuilderRow from './FilterBuilderRow'; import styles from './FilterBuilderModalContent.css'; @@ -51,7 +49,7 @@ class FilterBuilderModalContent extends Component { if (id) { dispatchSetFilter({ selectedFilterKey: id }); } else { - const last = maxBy(customFilters, 'id'); + const last = customFilters[customFilters.length -1]; dispatchSetFilter({ selectedFilterKey: last.id }); } @@ -64,7 +62,7 @@ class FilterBuilderModalContent extends Component { onLabelChange = ({ value }) => { this.setState({ label: value }); - }; + } onFilterChange = (index, filter) => { const filters = [...this.state.filters]; @@ -73,7 +71,7 @@ class FilterBuilderModalContent extends Component { this.setState({ filters }); - }; + } onAddFilterPress = () => { const filters = [...this.state.filters]; @@ -82,7 +80,7 @@ class FilterBuilderModalContent extends Component { this.setState({ filters }); - }; + } onRemoveFilterPress = (index) => { const filters = [...this.state.filters]; @@ -91,7 +89,7 @@ class FilterBuilderModalContent extends Component { this.setState({ filters }); - }; + } onSaveFilterPress = () => { const { @@ -109,7 +107,7 @@ class FilterBuilderModalContent extends Component { this.setState({ labelErrors: [ { - message: translate('LabelIsRequired') + message: 'Label is required' } ] }); @@ -123,7 +121,7 @@ class FilterBuilderModalContent extends Component { label, filters }); - }; + } // // Render @@ -147,13 +145,13 @@ class FilterBuilderModalContent extends Component { return ( - {translate('CustomFilter')} + Custom Filter
- {translate('Label')} + Label
@@ -167,16 +165,14 @@ class FilterBuilderModalContent extends Component {
-
- {translate('Filters')} -
+
Filters
{ filters.map((filter, index) => { return ( - {translate('Save')} + Save diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderModalContentConnector.js b/frontend/src/Components/Filter/Builder/FilterBuilderModalContentConnector.js index 17633172b..c94db9925 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 { deleteCustomFilter, saveCustomFilter } from 'Store/Actions/customFilterActions'; +import { saveCustomFilter, deleteCustomFilter } 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 bcfc3b04e..c5471b253 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: var(--tableRowHoverBackgroundColor); + background-color: $tableRowHoverBackgroundColor; } } diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRow.css.d.ts b/frontend/src/Components/Filter/Builder/FilterBuilderRow.css.d.ts deleted file mode 100644 index aba698af4..000000000 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRow.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 77dad7173..26bc50192 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRow.js +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRow.js @@ -1,21 +1,17 @@ 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 MetadataProfileFilterBuilderRowValue from './MetadataProfileFilterBuilderRowValue'; -import MonitorNewItemsFilterBuilderRowValue from './MonitorNewItemsFilterBuilderRowValue'; +import MetadataProfileFilterBuilderRowValueConnector from './MetadataProfileFilterBuilderRowValueConnector'; import ProtocolFilterBuilderRowValue from './ProtocolFilterBuilderRowValue'; import QualityFilterBuilderRowValueConnector from './QualityFilterBuilderRowValueConnector'; -import QualityProfileFilterBuilderRowValue from './QualityProfileFilterBuilderRowValue'; +import QualityProfileFilterBuilderRowValueConnector from './QualityProfileFilterBuilderRowValueConnector'; +import ArtistStatusFilterBuilderRowValue from './ArtistStatusFilterBuilderRowValue'; import TagFilterBuilderRowValueConnector from './TagFilterBuilderRowValueConnector'; import styles from './FilterBuilderRow.css'; @@ -61,17 +57,11 @@ 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 MetadataProfileFilterBuilderRowValue; - - case filterBuilderValueTypes.MONITOR_NEW_ITEMS: - return MonitorNewItemsFilterBuilderRowValue; + return MetadataProfileFilterBuilderRowValueConnector; case filterBuilderValueTypes.PROTOCOL: return ProtocolFilterBuilderRowValue; @@ -80,10 +70,7 @@ function getRowValueConnector(selectedFilterBuilderProp) { return QualityFilterBuilderRowValueConnector; case filterBuilderValueTypes.QUALITY_PROFILE: - return QualityProfileFilterBuilderRowValue; - - case filterBuilderValueTypes.ARTIST: - return ArtistFilterBuilderRowValue; + return QualityProfileFilterBuilderRowValueConnector; case filterBuilderValueTypes.ARTIST_STATUS: return ArtistStatusFilterBuilderRowValue; @@ -163,7 +150,7 @@ class FilterBuilderRow extends Component { this.selectedFilterBuilderProp = selectedFilterBuilderProp; onFilterChange(index, filter); - }; + } onFilterChange = ({ name, value }) => { const { @@ -183,7 +170,7 @@ class FilterBuilderRow extends Component { filter[name] = value; onFilterChange(index, filter); - }; + } onAddPress = () => { const { @@ -192,7 +179,7 @@ class FilterBuilderRow extends Component { } = this.props; onAddPress(index); - }; + } onRemovePress = () => { const { @@ -201,7 +188,7 @@ class FilterBuilderRow extends Component { } = this.props; onRemovePress(index); - }; + } // // Render @@ -219,13 +206,11 @@ class FilterBuilderRow extends Component { const selectedFilterBuilderProp = this.selectedFilterBuilderProp; const keyOptions = filterBuilderProps.map((availablePropFilter) => { - const { name, label } = availablePropFilter; - return { - key: name, - value: typeof label === 'function' ? label() : label + key: availablePropFilter.name, + value: availablePropFilter.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 68fa5c557..ef6084c02 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={['Tab', 'Enter']} + delimiters={[9, 13]} 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 d1419327a..c8813284e 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 !== filterTypes.NOT_EQUAL || + filterType !== filterBuilderTypes.NOT_EQUAL || !selectedFilterBuilderProp.optionsSelector ) { return []; @@ -38,7 +38,7 @@ function createTagListSelector() { } return acc; - }, []).sort(sortByProp('name')); + }, []).sort(sortByName); } return _.uniqBy(items, 'id'); diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueProps.ts b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueProps.ts deleted file mode 100644 index 5bf9e5785..000000000 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueProps.ts +++ /dev/null @@ -1,16 +0,0 @@ -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 807f383dd..9bf027af9 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css @@ -1,6 +1,4 @@ .tag { - display: flex; - &.isLastTag { .or { display: none; @@ -17,6 +15,5 @@ .or { margin: 0 3px; - color: var(--themeDarkColor); - line-height: 31px; + color: $themeDarkColor; } diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css.d.ts b/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css.d.ts deleted file mode 100644 index 80bcf1464..000000000 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValueTag.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 6b5846594..573e05759 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 TagInputTag from 'Components/Form/TagInputTag'; import { kinds } from 'Helpers/Props'; +import TagInputTag from 'Components/Form/TagInputTag'; import styles from './FilterBuilderRowValueTag.css'; function FilterBuilderRowValueTag(props) { return ( -
{ - props.isLastTag ? - null : -
+ !props.isLastTag && + or -
+ } -
+ ); } diff --git a/frontend/src/Components/Filter/Builder/HistoryEventTypeFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/HistoryEventTypeFilterBuilderRowValue.tsx deleted file mode 100644 index 1b3b369be..000000000 --- a/frontend/src/Components/Filter/Builder/HistoryEventTypeFilterBuilderRowValue.tsx +++ /dev/null @@ -1,69 +0,0 @@ -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 e834b79a3..0132ae641 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 deleted file mode 100644 index bbd9a8274..000000000 --- a/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValue.tsx +++ /dev/null @@ -1,30 +0,0 @@ -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 new file mode 100644 index 000000000..89d6c06b3 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/MetadataProfileFilterBuilderRowValueConnector.js @@ -0,0 +1,28 @@ +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 deleted file mode 100644 index 812d8c5b1..000000000 --- a/frontend/src/Components/Filter/Builder/MonitorNewItemsFilterBuilderRowValue.tsx +++ /dev/null @@ -1,33 +0,0 @@ -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 fd6e466d4..d0443bf19 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 deleted file mode 100644 index 50036cb90..000000000 --- a/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValue.tsx +++ /dev/null @@ -1,30 +0,0 @@ -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 new file mode 100644 index 000000000..4a8b82283 --- /dev/null +++ b/frontend/src/Components/Filter/Builder/QualityProfileFilterBuilderRowValueConnector.js @@ -0,0 +1,28 @@ +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 e2b8c72bf..7acb69dc7 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: var(--tableRowHoverBackgroundColor); + background-color: $tableRowHoverBackgroundColor; } } diff --git a/frontend/src/Components/Filter/CustomFilters/CustomFilter.css.d.ts b/frontend/src/Components/Filter/CustomFilters/CustomFilter.css.d.ts deleted file mode 100644 index af5bfa967..000000000 --- a/frontend/src/Components/Filter/CustomFilters/CustomFilter.css.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// 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 9f378d5a2..c9c326d78 100644 --- a/frontend/src/Components/Filter/CustomFilters/CustomFilter.js +++ b/frontend/src/Components/Filter/CustomFilters/CustomFilter.js @@ -1,9 +1,8 @@ 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 { @@ -37,8 +36,8 @@ class CustomFilter extends Component { dispatchSetFilter } = this.props; - // Assume that delete and then unmounting means the deletion was successful. - // Moving this check to an ancestor would be more accurate, but would have + // Assume that delete and then unmounting means the delete was successful. + // Moving this check to a ancestor would be more accurate, but would have // more boilerplate. if (this.state.isDeleting && id === selectedFilterKey) { dispatchSetFilter({ selectedFilterKey: 'all' }); @@ -55,7 +54,7 @@ class CustomFilter extends Component { } = this.props; onEditPress(id); - }; + } onRemovePress = () => { const { @@ -67,7 +66,7 @@ class CustomFilter extends Component { dispatchDeleteCustomFilter({ id }); }); - }; + } // // Render @@ -90,7 +89,7 @@ class CustomFilter extends Component { /> - {translate('CustomFilters')} + Custom Filters { - customFilters - .sort((a, b) => sortByProp(a, b, 'label')) - .map((customFilter) => { - return ( - - ); - }) + customFilters.map((customFilter) => { + return ( + + ); + }) }
@@ -62,7 +58,7 @@ function CustomFiltersModalContent(props) { diff --git a/frontend/src/Components/Filter/FilterModal.js b/frontend/src/Components/Filter/FilterModal.js index d52362d7b..729f380e7 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 4433fac6e..b79c0db1d 100644 --- a/frontend/src/Components/Form/AlbumReleaseSelectInputConnector.js +++ b/frontend/src/Components/Form/AlbumReleaseSelectInputConnector.js @@ -3,7 +3,6 @@ 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'; @@ -13,23 +12,13 @@ function createMapStateToProps() { (albumReleases) => { const values = _.map(albumReleases.value, (albumRelease) => { - const { - foreignReleaseId, - title, - disambiguation, - mediumCount, - trackCount, - country, - format - } = albumRelease; - return { - key: foreignReleaseId, - value: `${title}` + - `${disambiguation ? ' (' : ''}${titleCase(disambiguation)}${disambiguation ? ')' : ''}` + - `, ${mediumCount} med, ${trackCount} tracks` + - `${country && country.length > 0 ? `, ${shortenList(country)}` : ''}` + - `${format ? `, [${format}]` : ''}` + 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 ? ']' : ''}` }; }); @@ -59,7 +48,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 deleted file mode 100644 index 3edb46ec4..000000000 --- a/frontend/src/Components/Form/ArtistTagInput.tsx +++ /dev/null @@ -1,53 +0,0 @@ -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 d35969c4c..e19700d08 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 7dc416960..0f3279cb9 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 var(--inputBorderColor); + border: 1px solid $inputBorderColor; border-radius: 4px; - background-color: var(--inputBackgroundColor); - box-shadow: inset 0 1px 1px var(--inputBoxShadowColor); + background-color: $white; + box-shadow: inset 0 1px 1px $inputBoxShadowColor; } } @@ -46,5 +46,5 @@ } .suggestionHighlighted { - background-color: var(--menuItemHoverBackgroundColor); + background-color: $menuItemHoverBackgroundColor; } diff --git a/frontend/src/Components/Form/AutoSuggestInput.css.d.ts b/frontend/src/Components/Form/AutoSuggestInput.css.d.ts deleted file mode 100644 index 2b8f51924..000000000 --- a/frontend/src/Components/Form/AutoSuggestInput.css.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -// 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 34ec7530b..dd5833ee0 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 deleted file mode 100644 index b6844144e..000000000 --- a/frontend/src/Components/Form/CaptchaInput.css.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 b422198b5..e1a5df458 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 Icon from 'Components/Icon'; +import classNames from 'classnames'; import { icons } from 'Helpers/Props'; +import Icon from 'Components/Icon'; 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 ad83bf02f..17b875c88 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 { getCaptchaCookie, refreshCaptcha, resetCaptcha } from 'Store/Actions/captchaActions'; +import { refreshCaptcha, getCaptchaCookie, 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 cf9f27f91..e0b05eca3 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: var(--white); - color: var(--white); + background-color: $white; + color: $white; text-align: center; line-height: 20px; } .checkbox:focus + .input { outline: 0; - border-color: var(--inputFocusBorderColor); - box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); + border-color: $inputFocusBorderColor; + box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; } .dangerIsChecked { - border-color: var(--dangerColor); - background-color: var(--dangerColor); + border-color: $dangerColor; + background-color: $dangerColor; &.isDisabled { opacity: 0.7; @@ -54,8 +54,8 @@ } .primaryIsChecked { - border-color: var(--lidarrGreen); - background-color: var(--lidarrGreen); + border-color: $primaryColor; + background-color: $primaryColor; &.isDisabled { opacity: 0.7; @@ -63,8 +63,8 @@ } .successIsChecked { - border-color: var(--successColor); - background-color: var(--successColor); + border-color: $successColor; + background-color: $successColor; &.isDisabled { opacity: 0.7; @@ -72,8 +72,8 @@ } .warningIsChecked { - border-color: var(--warningColor); - background-color: var(--warningColor); + border-color: $warningColor; + background-color: $warningColor; &.isDisabled { opacity: 0.7; @@ -82,15 +82,15 @@ .isNotChecked { &.isDisabled { - border-color: var(--disabledCheckInputColor); - background-color: var(--disabledCheckInputColor); + border-color: $disabledCheckInputColor; + background-color: $disabledCheckInputColor; opacity: 0.7; } } .isIndeterminate { - border-color: var(--gray); - background-color: var(--gray); + border-color: $gray; + background-color: $gray; } .helpText { diff --git a/frontend/src/Components/Form/CheckInput.css.d.ts b/frontend/src/Components/Form/CheckInput.css.d.ts deleted file mode 100644 index bba6b63bb..000000000 --- a/frontend/src/Components/Form/CheckInput.css.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// 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 26d915880..134290111 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 Icon from 'Components/Icon'; +import classNames from 'classnames'; import { icons, kinds } from 'Helpers/Props'; +import Icon from 'Components/Icon'; 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 deleted file mode 100644 index e44e3fce0..000000000 --- a/frontend/src/Components/Form/DeviceInput.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 55c239cb8..f77c7cf29 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 2af9a79f6..43e313826 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 { clearOptions, defaultState, fetchOptions } from 'Store/Actions/providerOptionActions'; +import { fetchOptions, clearOptions } from 'Store/Actions/providerOptionActions'; import DeviceInput from './DeviceInput'; function createMapStateToProps() { return createSelector( (state, { value }) => value, - (state) => state.providerOptions.devices || defaultState, + (state) => state.providerOptions, (value, devices) => { return { @@ -48,11 +48,11 @@ class DeviceInputConnector extends Component { componentDidMount = () => { this._populate(); - }; + } componentWillUnmount = () => { - this.props.dispatchClearOptions({ section: 'devices' }); - }; + this.props.dispatchClearOptions(); + } // // Control @@ -65,7 +65,6 @@ class DeviceInputConnector extends Component { } = this.props; dispatchFetchOptions({ - section: 'devices', action: 'getDevices', provider, providerData @@ -77,7 +76,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 deleted file mode 100644 index c21f0ded6..000000000 --- a/frontend/src/Components/Form/DownloadClientSelectInputConnector.js +++ /dev/null @@ -1,102 +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 { 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 defefb18e..774a63517 100644 --- a/frontend/src/Components/Form/EnhancedSelectInput.css +++ b/frontend/src/Components/Form/EnhancedSelectInput.css @@ -1,12 +1,19 @@ .enhancedSelect { composes: input from '~Components/Form/Input.css'; + composes: link from '~Components/Link/Link.css'; + position: relative; display: flex; align-items: center; -} - -.editableContainer { + padding: 6px 16px; 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 { @@ -19,27 +26,17 @@ .isDisabled { opacity: 0.7; - cursor: not-allowed !important; + cursor: not-allowed; } .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: var(--disabledInputColor); + color: $disabledInputColor; } .optionsContainer { @@ -50,16 +47,15 @@ .options { composes: scroller from '~Components/Scroller/Scroller.css'; - border: 1px solid var(--inputBorderColor); + border: 1px solid $inputBorderColor; border-radius: 4px; - background-color: var(--inputBackgroundColor); + background-color: $white; } .optionsModal { display: flex; justify-content: center; max-width: 90%; - max-height: 100%; width: 350px !important; height: auto !important; } @@ -76,30 +72,7 @@ .optionsModalScroller { composes: scroller from '~Components/Scroller/Scroller.css'; - border: 1px solid var(--inputBorderColor); + border: 1px solid $inputBorderColor; border-radius: 4px; - 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); - } + background-color: $white; } diff --git a/frontend/src/Components/Form/EnhancedSelectInput.css.d.ts b/frontend/src/Components/Form/EnhancedSelectInput.css.d.ts deleted file mode 100644 index edcf0079b..000000000 --- a/frontend/src/Components/Form/EnhancedSelectInput.css.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -// 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 8327b9385..80ee78e81 100644 --- a/frontend/src/Components/Form/EnhancedSelectInput.js +++ b/frontend/src/Components/Form/EnhancedSelectInput.js @@ -1,27 +1,23 @@ -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 { 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 HintedSelectInputOption from './HintedSelectInputOption'; import styles from './EnhancedSelectInput.css'; -const MINIMUM_DISTANCE_FROM_EDGE = 10; - function isArrowKey(keyCode) { return keyCode === keyCodes.UP_ARROW || keyCode === keyCodes.DOWN_ARROW; } @@ -62,30 +58,11 @@ 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; } @@ -115,12 +92,10 @@ class EnhancedSelectInput extends Component { this._scheduleUpdate(); } - if (!Array.isArray(this.props.value)) { - if (prevProps.value !== this.props.value || prevProps.values !== this.props.values) { - this.setState({ - selectedIndex: getSelectedIndex(this.props) - }); - } + if (prevProps.value !== this.props.value) { + this.setState({ + selectedIndex: getSelectedIndex(this.props) + }); } } @@ -139,18 +114,27 @@ class EnhancedSelectInput extends Component { // Listeners onComputeMaxHeight = (data) => { + const { + top, + bottom + } = data.offsets.reference; + const windowHeight = window.innerHeight; - data.styles.maxHeight = windowHeight - MINIMUM_DISTANCE_FROM_EDGE; + if ((/^botton/).test(data.placement)) { + data.styles.maxHeight = windowHeight - bottom; + } else { + data.styles.maxHeight = top; + } return data; - }; + } onWindowClick = (event) => { const button = document.getElementById(this._buttonId); const options = document.getElementById(this._optionsId); - if (!button || !event.target.isConnected || this.state.isMobile) { + if (!button || this.state.isMobile) { return; } @@ -163,25 +147,15 @@ class EnhancedSelectInput extends Component { this.setState({ isOpen: false }); this._removeListener(); } - }; - - onFocus = () => { - if (this.state.isOpen) { - this._removeListener(); - this.setState({ isOpen: false }); - } - }; + } onBlur = () => { - 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 }); - } + // 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 { @@ -203,7 +177,7 @@ class EnhancedSelectInput extends Component { } if ( - selectedIndex == null || selectedIndex === -1 || + selectedIndex == null || getSelectedOption(selectedIndex, values).isDisabled ) { if (keyCode === keyCodes.UP_ARROW) { @@ -248,7 +222,7 @@ class EnhancedSelectInput extends Component { if (!_.isEmpty(newState)) { this.setState(newState); } - }; + } onPress = () => { if (this.state.isOpen) { @@ -257,44 +231,25 @@ class EnhancedSelectInput extends Component { this._addListener(); } - if (!this.state.isOpen && this.props.onOpen) { - this.props.onOpen(); - } - this.setState({ isOpen: !this.state.isOpen }); - }; + } onSelect = (value) => { - 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.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 @@ -303,19 +258,13 @@ class EnhancedSelectInput extends Component { const { className, disabledClassName, - name, - value, values, isDisabled, - isEditable, - isFetching, hasError, hasWarning, - valueOptions, selectedValueOptions, selectedValueComponent: SelectedValueComponent, - optionComponent: OptionComponent, - onChange + optionComponent: OptionComponent } = this.props; const { @@ -325,13 +274,7 @@ 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 (
@@ -346,98 +289,37 @@ class EnhancedSelectInput extends Component { whitelist={['width']} onMeasure={this.onMeasure} > - { - isEditable ? -
- - - { - isFetching ? - : - null - } + + + {selectedOption ? selectedOption.value : null} + - { - isFetching ? - null : - - } - -
: - - - {selectedOption ? selectedOption.value : null} - - -
- - { - isFetching ? - : - null - } - - { - isFetching ? - null : - - } -
- - } +
+ +
+
)} @@ -450,10 +332,6 @@ class EnhancedSelectInput extends Component { order: 851, enabled: true, fn: this.onComputeMaxHeight - }, - preventOverflow: { - enabled: true, - boundariesElement: 'viewport' } }} > @@ -480,18 +358,11 @@ 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 + }
); @@ -575,18 +426,14 @@ EnhancedSelectInput.propTypes = { className: PropTypes.string, disabledClassName: PropTypes.string, name: PropTypes.string.isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.arrayOf(PropTypes.string), PropTypes.arrayOf(PropTypes.number)]).isRequired, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, values: PropTypes.arrayOf(PropTypes.object).isRequired, - isDisabled: PropTypes.bool.isRequired, - isFetching: PropTypes.bool.isRequired, - isEditable: PropTypes.bool.isRequired, + isDisabled: PropTypes.bool, 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 }; @@ -594,9 +441,6 @@ 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 deleted file mode 100644 index f2af4a585..000000000 --- a/frontend/src/Components/Form/EnhancedSelectInputConnector.js +++ /dev/null @@ -1,159 +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 { 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 d7f0e861b..18440c50d 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputOption.css +++ b/frontend/src/Components/Form/EnhancedSelectInputOption.css @@ -7,38 +7,22 @@ cursor: default; &:hover { - background-color: var(--inputHoverBackgroundColor); + background-color: #f8f8f8; } - - &.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: var(--inputSelectedBackgroundColor); + background-color: #e2e2e2; &:hover { - background-color: var(--inputSelectedBackgroundColor); + background-color: #e2e2e2; } &.isMobile { background-color: inherit; .iconContainer { - color: var(--primaryColor); + color: $primaryColor; } } } @@ -53,13 +37,9 @@ .isMobile { height: 50px; - border-bottom: 1px solid var(--borderColor); + border-bottom: 1px solid $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 deleted file mode 100644 index 59675cd91..000000000 --- a/frontend/src/Components/Form/EnhancedSelectInputOption.css.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// 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 b2783dbaa..e1b410c28 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputOption.js +++ b/frontend/src/Components/Form/EnhancedSelectInputOption.js @@ -1,10 +1,9 @@ -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 { @@ -12,20 +11,14 @@ class EnhancedSelectInputOption extends Component { // // Listeners - onPress = (e) => { - e.preventDefault(); - + onPress = () => { 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 @@ -33,12 +26,9 @@ class EnhancedSelectInputOption extends Component { render() { const { className, - id, - depth, isSelected, isDisabled, isHidden, - isMultiSelect, isMobile, children } = this.props; @@ -47,8 +37,8 @@ class EnhancedSelectInputOption extends Component { - - { - depth !== 0 && -
- } - - { - isMultiSelect && - - } - {children} { @@ -91,12 +63,10 @@ class EnhancedSelectInputOption extends Component { EnhancedSelectInputOption.propTypes = { className: PropTypes.string.isRequired, - id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, - depth: PropTypes.number.isRequired, + id: PropTypes.string.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 @@ -104,10 +74,8 @@ EnhancedSelectInputOption.propTypes = { EnhancedSelectInputOption.defaultProps = { className: styles.option, - depth: 0, isDisabled: false, - isHidden: false, - isMultiSelect: false + isHidden: false }; export default EnhancedSelectInputOption; diff --git a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css index 908126689..6b8b73af9 100644 --- a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css +++ b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css @@ -3,5 +3,5 @@ } .isDisabled { - color: var(--disabledInputColor); + color: $disabledInputColor; } diff --git a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css.d.ts b/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css.d.ts deleted file mode 100644 index 5377239a8..000000000 --- a/frontend/src/Components/Form/EnhancedSelectInputSelectedValue.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 21ddebb02..c40ee93c1 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 deleted file mode 100644 index 178f2fec1..000000000 --- a/frontend/src/Components/Form/Form.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 79ad3fe8a..c2c67eddf 100644 --- a/frontend/src/Components/Form/Form.js +++ b/frontend/src/Components/Form/Form.js @@ -1,18 +1,10 @@ import PropTypes from 'prop-types'; import React from 'react'; -import Alert from 'Components/Alert'; import { kinds } from 'Helpers/Props'; +import Alert from 'Components/Alert'; import styles from './Form.css'; -function Form(props) { - const { - children, - validationErrors, - validationWarnings, - // eslint-disable-next-line no-unused-vars - ...otherProps - } = props; - +function Form({ children, validationErrors, validationWarnings, ...otherProps }) { return (
{ diff --git a/frontend/src/Components/Form/FormGroup.css.d.ts b/frontend/src/Components/Form/FormGroup.css.d.ts deleted file mode 100644 index 86145f643..000000000 --- a/frontend/src/Components/Form/FormGroup.css.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 f538daa2f..d2e04c350 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 deleted file mode 100644 index d469cdfe3..000000000 --- a/frontend/src/Components/Form/FormInputButton.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 a7145363a..4b6491663 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 32d91e29b..1a1b104e6 100644 --- a/frontend/src/Components/Form/FormInputGroup.css +++ b/frontend/src/Components/Form/FormInputGroup.css @@ -40,7 +40,7 @@ } .pendingChangesIcon { - color: var(--warningColor); + color: $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 deleted file mode 100644 index 267257c44..000000000 --- a/frontend/src/Components/Form/FormInputGroup.css.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -// 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 3173b493d..5b5dd2792 100644 --- a/frontend/src/Components/Form/FormInputGroup.js +++ b/frontend/src/Components/Form/FormInputGroup.js @@ -1,38 +1,28 @@ 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 DownloadClientSelectInputConnector from './DownloadClientSelectInputConnector'; -import EnhancedSelectInput from './EnhancedSelectInput'; -import EnhancedSelectInputConnector from './EnhancedSelectInputConnector'; -import FormInputHelpText from './FormInputHelpText'; -import IndexerFlagsSelectInput from './IndexerFlagsSelectInput'; -import IndexerSelectInputConnector from './IndexerSelectInputConnector'; +import PlaylistInputConnector from './PlaylistInputConnector'; 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 TagSelectInputConnector from './TagSelectInputConnector'; -import TextArea from './TextArea'; -import TextInput from './TextInput'; import TextTagInputConnector from './TextTagInputConnector'; -import UMaskInput from './UMaskInput'; +import TextInput from './TextInput'; +import FormInputHelpText from './FormInputHelpText'; import styles from './FormInputGroup.css'; function getComponent(type) { @@ -49,18 +39,15 @@ function getComponent(type) { case inputTypes.DEVICE: return DeviceInputConnector; - case inputTypes.KEY_VALUE_LIST: - return KeyValueListInput; - case inputTypes.PLAYLIST: return PlaylistInputConnector; + case inputTypes.KEY_VALUE_LIST: + return KeyValueListInput; + case inputTypes.MONITOR_ALBUMS_SELECT: return MonitorAlbumsSelectInput; - case inputTypes.MONITOR_NEW_ITEMS_SELECT: - return MonitorNewItemsSelectInput; - case inputTypes.NUMBER: return NumberInput; @@ -82,45 +69,21 @@ 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; } @@ -197,7 +160,7 @@ function FormInputGroup(props) { }
*/} @@ -228,7 +191,7 @@ function FormInputGroup(props) { } { - (!checkInput || helpText) && helpTextWarning && + !checkInput && helpTextWarning && - {translate('MoreInfo')} + More Info } @@ -251,7 +214,7 @@ function FormInputGroup(props) { key={index} text={error.message} link={error.link} - tooltip={error.detailedMessage} + linkTooltip={error.detailedMessage} isError={true} isCheckInput={checkInput} /> @@ -266,7 +229,7 @@ function FormInputGroup(props) { key={index} text={warning.message} link={warning.link} - tooltip={warning.detailedMessage} + linkTooltip={warning.detailedMessage} isWarning={true} isCheckInput={checkInput} /> @@ -281,30 +244,16 @@ 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), - onChange: PropTypes.func.isRequired + warnings: PropTypes.arrayOf(PropTypes.object) }; FormInputGroup.defaultProps = { diff --git a/frontend/src/Components/Form/FormInputHelpText.css b/frontend/src/Components/Form/FormInputHelpText.css index 0a6897d27..7fd957233 100644 --- a/frontend/src/Components/Form/FormInputHelpText.css +++ b/frontend/src/Components/Form/FormInputHelpText.css @@ -1,14 +1,14 @@ .helpText { margin-top: 5px; - color: var(--helpTextColor); + color: $helpTextColor; line-height: 20px; } .isError { - color: var(--dangerColor); + color: $dangerColor; .link { - color: var(--dangerColor); + color: $dangerColor; &:hover { color: #e01313; @@ -17,10 +17,10 @@ } .isWarning { - color: var(--warningColor); + color: $warningColor; .link { - color: var(--warningColor); + color: $warningColor; &:hover { color: #e36c00; @@ -37,7 +37,3 @@ 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 deleted file mode 100644 index 0e163f134..000000000 --- a/frontend/src/Components/Form/FormInputHelpText.css.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 00024684e..d9195568b 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, - tooltip, + linkTooltip, isError, isWarning, isCheckInput @@ -28,27 +28,16 @@ function FormInputHelpText(props) { {text} { - link ? + !!link && - : - null - } - - { - !link && tooltip ? - : - null + }
); @@ -58,7 +47,7 @@ FormInputHelpText.propTypes = { className: PropTypes.string.isRequired, text: PropTypes.string.isRequired, link: PropTypes.string, - tooltip: PropTypes.string, + linkTooltip: 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 54a4678e8..236f4aab0 100644 --- a/frontend/src/Components/Form/FormLabel.css +++ b/frontend/src/Components/Form/FormLabel.css @@ -2,18 +2,16 @@ 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: var(--dangerColor); + color: $dangerColor; } .isAdvanced { - color: var(--advancedFormLabelColor); + color: $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 deleted file mode 100644 index c23dd30a4..000000000 --- a/frontend/src/Components/Form/FormLabel.css.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 d4a4bcffc..da7a443e3 100644 --- a/frontend/src/Components/Form/FormLabel.js +++ b/frontend/src/Components/Form/FormLabel.js @@ -1,21 +1,19 @@ -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(props) { - const { - children, - className, - errorClassName, - size, - name, - hasError, - isAdvanced, - ...otherProps - } = props; - +function FormLabel({ + children, + className, + errorClassName, + size, + name, + hasError, + isAdvanced, + ...otherProps +}) { return (
} ); } HintedSelectInputSelectedValue.propTypes = { - value: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number]))]).isRequired, - values: PropTypes.arrayOf(PropTypes.object).isRequired, + value: PropTypes.string, 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 deleted file mode 100644 index 8dbd27a70..000000000 --- a/frontend/src/Components/Form/IndexerFlagsSelectInput.tsx +++ /dev/null @@ -1,62 +0,0 @@ -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 deleted file mode 100644 index 5f62becbb..000000000 --- a/frontend/src/Components/Form/IndexerSelectInputConnector.js +++ /dev/null @@ -1,97 +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 { 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 dd9ee888d..e9ca23d8f 100644 --- a/frontend/src/Components/Form/Input.css +++ b/frontend/src/Components/Form/Input.css @@ -2,27 +2,26 @@ padding: 6px 16px; width: 100%; height: 35px; - border: 1px solid var(--inputBorderColor); + border: 1px solid $inputBorderColor; border-radius: 4px; - background-color: var(--inputBackgroundColor); - box-shadow: inset 0 1px 1px var(--inputBoxShadowColor); - color: var(--textColor); + background-color: $white; + box-shadow: inset 0 1px 1px $inputBoxShadowColor; &:focus { outline: 0; - border-color: var(--inputFocusBorderColor); - box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); + border-color: $inputFocusBorderColor; + box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; } } .hasError { - border-color: var(--inputErrorBorderColor); - box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputErrorBoxShadowColor); + border-color: $inputErrorBorderColor; + box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputErrorBoxShadowColor; } .hasWarning { - border-color: var(--inputWarningBorderColor); - box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputWarningBoxShadowColor); + border-color: $inputWarningBorderColor; + box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputWarningBoxShadowColor; } .hasButton { diff --git a/frontend/src/Components/Form/KeyValueListInput.css b/frontend/src/Components/Form/KeyValueListInput.css index d86e6a512..8bf23610b 100644 --- a/frontend/src/Components/Form/KeyValueListInput.css +++ b/frontend/src/Components/Form/KeyValueListInput.css @@ -7,8 +7,8 @@ &.isFocused { outline: 0; - border-color: var(--inputFocusBorderColor); - box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); + border-color: $inputFocusBorderColor; + box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $inputFocusBoxShadowColor; } } diff --git a/frontend/src/Components/Form/KeyValueListInput.css.d.ts b/frontend/src/Components/Form/KeyValueListInput.css.d.ts deleted file mode 100644 index 972f108c9..000000000 --- a/frontend/src/Components/Form/KeyValueListInput.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 new file mode 100644 index 000000000..a52c76f70 --- /dev/null +++ b/frontend/src/Components/Form/KeyValueListInput.js @@ -0,0 +1,152 @@ +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 deleted file mode 100644 index f5c6ac19b..000000000 --- a/frontend/src/Components/Form/KeyValueListInput.tsx +++ /dev/null @@ -1,104 +0,0 @@ -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 ed82db459..f77ea3470 100644 --- a/frontend/src/Components/Form/KeyValueListInputItem.css +++ b/frontend/src/Components/Form/KeyValueListInputItem.css @@ -1,35 +1,14 @@ .itemContainer { display: flex; margin-bottom: 3px; - border-bottom: 1px solid var(--inputBorderColor); + border-bottom: 1px solid $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 deleted file mode 100644 index aa0c1be13..000000000 --- a/frontend/src/Components/Form/KeyValueListInputItem.css.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 new file mode 100644 index 000000000..4e465f3a9 --- /dev/null +++ b/frontend/src/Components/Form/KeyValueListInputItem.js @@ -0,0 +1,117 @@ +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 deleted file mode 100644 index c63ad50a9..000000000 --- a/frontend/src/Components/Form/KeyValueListInputItem.tsx +++ /dev/null @@ -1,89 +0,0 @@ -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 6e6aad5f9..d28876aa0 100644 --- a/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js +++ b/frontend/src/Components/Form/MetadataProfileSelectInputConnector.js @@ -3,42 +3,27 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -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'; +import sortByName from 'Utilities/Array/sortByName'; +import SelectInput from './SelectInput'; function createMapStateToProps() { return createSelector( - createSortedSectionSelector('settings.metadataProfiles', sortByProp('name')), + (state) => state.settings.metadataProfiles, (state, { includeNoChange }) => includeNoChange, - (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, (state, { includeMixed }) => includeMixed, - (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) => { + (metadataProfiles, includeNoChange, includeMixed) => { + const values = _.map(metadataProfiles.items.sort(sortByName), (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: translate('NoChange'), - isDisabled: includeNoChangeDisabled + value: 'No Change', + disabled: true }); } @@ -46,7 +31,7 @@ function createMapStateToProps() { values.unshift({ key: 'mixed', value: '(Mixed)', - isDisabled: true + disabled: true }); } @@ -69,8 +54,8 @@ class MetadataProfileSelectInputConnector extends Component { values } = this.props; - if (!value || !values.some((option) => option.key === value || parseInt(option.key) === value)) { - const firstValue = values.find((option) => !isNaN(parseInt(option.key))); + if (!value || !_.some(values, (option) => parseInt(option.key) === value)) { + const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key))); if (firstValue) { this.onChange({ name, value: firstValue.key }); @@ -82,15 +67,15 @@ class MetadataProfileSelectInputConnector extends Component { // Listeners onChange = ({ name, value }) => { - this.props.onChange({ name, value: value === 'noChange' ? value : parseInt(value) }); - }; + this.props.onChange({ name, value: parseInt(value) }); + } // // Render render() { return ( - @@ -103,13 +88,11 @@ 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, - includeNone: true + includeNoChange: false }; export default connect(createMapStateToProps)(MetadataProfileSelectInputConnector); diff --git a/frontend/src/Components/Form/MonitorAlbumsSelectInput.js b/frontend/src/Components/Form/MonitorAlbumsSelectInput.js index d48284c38..a3780de56 100644 --- a/frontend/src/Components/Form/MonitorAlbumsSelectInput.js +++ b/frontend/src/Components/Form/MonitorAlbumsSelectInput.js @@ -1,13 +1,11 @@ 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; @@ -17,16 +15,16 @@ function MonitorAlbumsSelectInput(props) { if (includeNoChange) { values.unshift({ key: 'noChange', - value: translate('NoChange'), - isDisabled: includeNoChangeDisabled + value: 'No Change', + disabled: true }); } if (includeMixed) { values.unshift({ key: 'mixed', - value: `(${translate('Mixed')})`, - isDisabled: true + value: '(Mixed)', + disabled: true }); } @@ -40,7 +38,6 @@ 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 deleted file mode 100644 index 0dccc44a4..000000000 --- a/frontend/src/Components/Form/MonitorNewItemsSelectInput.js +++ /dev/null @@ -1,53 +0,0 @@ -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 cac274d95..c4ecc7e86 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 null; + return min; } let newValue = isFloat ? parseFloat(value) : parseInt(value); @@ -41,7 +41,7 @@ class NumberInput extends Component { componentDidUpdate(prevProps, prevState) { const { value } = this.props; - if (!isNaN(value) && value !== prevProps.value && !this.state.isFocused) { + if (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 4ecd625bc..00825b6ba 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 SpinnerErrorButton from 'Components/Link/SpinnerErrorButton'; import { kinds } from 'Helpers/Props'; +import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton'; function OAuthInput(props) { const { diff --git a/frontend/src/Components/Form/OAuthInputConnector.js b/frontend/src/Components/Form/OAuthInputConnector.js index 1567c7e6c..7568aae7a 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 { resetOAuth, startOAuth } from 'Store/Actions/oAuthActions'; +import { startOAuth, resetOAuth } 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 new file mode 100644 index 000000000..6cb162784 --- /dev/null +++ b/frontend/src/Components/Form/PasswordInput.css @@ -0,0 +1,5 @@ +.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 dbc4cfdb4..adb1e7c5a 100644 --- a/frontend/src/Components/Form/PasswordInput.js +++ b/frontend/src/Components/Form/PasswordInput.js @@ -1,24 +1,22 @@ +import PropTypes from 'prop-types'; import React from 'react'; import TextInput from './TextInput'; - -// Prevent a user from copying (or cutting) the password from the input -function onCopy(e) { - e.preventDefault(); - e.nativeEvent.stopImmediatePropagation(); -} +import styles from './PasswordInput.css'; function PasswordInput(props) { return ( ); } PasswordInput.propTypes = { - ...TextInput.props + className: PropTypes.string.isRequired +}; + +PasswordInput.defaultProps = { + className: styles.input }; export default PasswordInput; diff --git a/frontend/src/Components/Form/PathInput.css.d.ts b/frontend/src/Components/Form/PathInput.css.d.ts deleted file mode 100644 index d44c3dd56..000000000 --- a/frontend/src/Components/Form/PathInput.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 972d8f99f..40c4840ba 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 FileBrowserModal from 'Components/FileBrowser/FileBrowserModal'; -import Icon from 'Components/Icon'; import { icons } from 'Helpers/Props'; +import Icon from 'Components/Icon'; +import FileBrowserModal from 'Components/FileBrowser/FileBrowserModal'; 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 3917a8d3f..38ea37065 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 { clearPaths, fetchPaths } from 'Store/Actions/pathActions'; +import { fetchPaths, clearPaths } 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 deleted file mode 100644 index 98431d38d..000000000 --- a/frontend/src/Components/Form/PlaylistInput.css.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// 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 0b3966f60..df482e7bb 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 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 TableRowCell from 'Components/Table/Cells/TableRowCell'; +import TableSelectCell from 'Components/Table/Cells/TableSelectCell'; import styles from './PlaylistInput.css'; const columns = [ { name: 'name', - label: () => translate('Playlist'), + label: 'Playlist', isSortable: false, isVisible: true } @@ -45,17 +45,7 @@ class PlaylistInput extends Component { onChange } = this.props; - const oldSelected = _.reduce( - prevState.selectedState, - (result, value, id) => { - if (value) { - result.push(id); - } - - return result; - }, - [] - ).sort(); + const oldSelected = getSelectedIds(prevState.selectedState, { parseIds: false }).sort(); const newSelected = this.getSelectedIds().sort(); if (!_.isEqual(oldSelected, newSelected)) { @@ -70,31 +60,21 @@ class PlaylistInput extends Component { // Control getSelectedIds = () => { - return _.reduce( - this.state.selectedState, - (result, value, id) => { - if (value) { - result.push(id); - } - - return result; - }, - [] - ); - }; + return getSelectedIds(this.state.selectedState, { parseIds: false }); + } // // 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 @@ -200,8 +180,7 @@ PlaylistInput.propTypes = { PlaylistInput.defaultProps = { className: styles.playlistInputWrapper, - inputClassName: styles.input, - isPopulated: false + inputClassName: styles.input }; export default PlaylistInput; diff --git a/frontend/src/Components/Form/PlaylistInputConnector.js b/frontend/src/Components/Form/PlaylistInputConnector.js index f88a9f14d..e70765671 100644 --- a/frontend/src/Components/Form/PlaylistInputConnector.js +++ b/frontend/src/Components/Form/PlaylistInputConnector.js @@ -3,21 +3,20 @@ 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 { fetchOptions, clearOptions } from 'Store/Actions/providerOptionActions'; import PlaylistInput from './PlaylistInput'; function createMapStateToProps() { return createSelector( - (state) => state.providerOptions.playlists || defaultState, - (playlists) => { + (state) => state.providerOptions, + (state) => { const { items, ...otherState - } = playlists; - + } = state; return ({ - user: items && items.user ? items.user : '', - items: items && items.playlists ? items.playlists : [], + user: items.user ? items.user : '', + items: items.playlists ? items.playlists : [], ...otherState }); } @@ -38,7 +37,7 @@ class PlaylistInputConnector extends Component { if (this._getAccessToken(this.props)) { this._populate(); } - }; + } componentDidUpdate(prevProps, prevState) { const newToken = this._getAccessToken(this.props); @@ -49,8 +48,8 @@ class PlaylistInputConnector extends Component { } componentWillUnmount = () => { - this.props.dispatchClearOptions({ section: 'playlists' }); - }; + this.props.dispatchClearOptions(); + } // // Control @@ -63,7 +62,6 @@ 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 311f1bbbd..dca32aa1e 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 FormGroup from 'Components/Form/FormGroup'; -import FormInputGroup from 'Components/Form/FormInputGroup'; -import FormLabel from 'Components/Form/FormLabel'; import { inputTypes } from 'Helpers/Props'; +import FormGroup from 'Components/Form/FormGroup'; +import FormLabel from 'Components/Form/FormLabel'; +import FormInputGroup from 'Components/Form/FormInputGroup'; -function getType({ type, selectOptionsProviderAction }) { +function getType(type) { switch (type) { case 'captcha': return inputTypes.CAPTCHA; @@ -14,8 +14,6 @@ function getType({ type, selectOptionsProviderAction }) { return inputTypes.CHECK; case 'device': return inputTypes.DEVICE; - case 'keyValueList': - return inputTypes.KEY_VALUE_LIST; case 'playlist': return inputTypes.PLAYLIST; case 'password': @@ -27,26 +25,13 @@ function getType({ type, selectOptionsProviderAction }) { 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; } @@ -60,8 +45,7 @@ function getSelectValues(selectOptions) { return _.reduce(selectOptions, (result, option) => { result.push({ key: option.value, - value: option.name, - hint: option.hint + value: option.name }); return result; @@ -74,9 +58,7 @@ function ProviderFieldFormGroup(props) { name, label, helpText, - helpTextWarning, helpLink, - placeholder, value, type, advanced, @@ -104,13 +86,11 @@ function ProviderFieldFormGroup(props) { {label} state.settings.qualityProfiles, (state, { includeNoChange }) => includeNoChange, - (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, (state, { includeMixed }) => includeMixed, - (qualityProfiles, includeNoChange, includeNoChangeDisabled = true, includeMixed) => { - const values = _.map(qualityProfiles.items, (qualityProfile) => { + (qualityProfiles, includeNoChange, includeMixed) => { + const values = _.map(qualityProfiles.items.sort(sortByName), (qualityProfile) => { return { key: qualityProfile.id, value: qualityProfile.name @@ -25,8 +22,8 @@ function createMapStateToProps() { if (includeNoChange) { values.unshift({ key: 'noChange', - value: translate('NoChange'), - isDisabled: includeNoChangeDisabled + value: 'No Change', + disabled: true }); } @@ -34,7 +31,7 @@ function createMapStateToProps() { values.unshift({ key: 'mixed', value: '(Mixed)', - isDisabled: true + disabled: true }); } @@ -57,8 +54,8 @@ class QualityProfileSelectInputConnector extends Component { values } = this.props; - if (!value || !values.some((option) => option.key === value || parseInt(option.key) === value)) { - const firstValue = values.find((option) => !isNaN(parseInt(option.key))); + if (!value || !_.some(values, (option) => parseInt(option.key) === value)) { + const firstValue = _.find(values, (option) => !isNaN(parseInt(option.key))); if (firstValue) { this.onChange({ name, value: firstValue.key }); @@ -70,15 +67,15 @@ class QualityProfileSelectInputConnector extends Component { // Listeners onChange = ({ name, value }) => { - this.props.onChange({ name, value: value === 'noChange' ? value : parseInt(value) }); - }; + this.props.onChange({ name, value: parseInt(value) }); + } // // Render render() { return ( - diff --git a/frontend/src/Components/Form/RootFolderSelectInput.js b/frontend/src/Components/Form/RootFolderSelectInput.js index 7df36eee7..08d88e5f1 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 EditRootFolderModalConnector from 'Settings/MediaManagement/RootFolder/EditRootFolderModalConnector'; +import FileBrowserModal from 'Components/FileBrowser/FileBrowserModal'; import EnhancedSelectInput from './EnhancedSelectInput'; import RootFolderSelectInputOption from './RootFolderSelectInputOption'; import RootFolderSelectInputSelectedValue from './RootFolderSelectInputSelectedValue'; @@ -14,7 +14,8 @@ class RootFolderSelectInput extends Component { super(props, context); this.state = { - isAddNewRootFolderModalOpen: false + isAddNewRootFolderModalOpen: false, + newRootFolderPath: '' }; } @@ -48,22 +49,25 @@ class RootFolderSelectInput extends Component { } else { this.props.onChange({ name, value }); } - }; + } onNewRootFolderSelect = ({ value }) => { - this.setState({ newRootFolderPath: value }); - }; + this.setState({ newRootFolderPath: value }, () => { + this.props.onNewRootFolderSelect(value); + }); + } onAddRootFolderModalClose = () => { this.setState({ isAddNewRootFolderModalOpen: false }); - }; + } // // Render render() { const { - value, + includeNoChange, + onNewRootFolderSelect, ...otherProps } = this.props; @@ -71,16 +75,17 @@ class RootFolderSelectInput extends Component {
-
); @@ -89,11 +94,16 @@ 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, - onChange: PropTypes.func.isRequired + includeNoChange: PropTypes.bool.isRequired, + onChange: PropTypes.func.isRequired, + onNewRootFolderSelect: PropTypes.func.isRequired +}; + +RootFolderSelectInput.defaultProps = { + includeNoChange: false }; export default RootFolderSelectInput; diff --git a/frontend/src/Components/Form/RootFolderSelectInputConnector.js b/frontend/src/Components/Form/RootFolderSelectInputConnector.js index dcc2b88a6..b76501dc1 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputConnector.js +++ b/frontend/src/Components/Form/RootFolderSelectInputConnector.js @@ -2,26 +2,21 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import createRootFoldersSelector from 'Store/Selectors/createRootFoldersSelector'; +import { addRootFolder } from 'Store/Actions/rootFolderActions'; import RootFolderSelectInput from './RootFolderSelectInput'; const ADD_NEW_KEY = 'addNew'; function createMapStateToProps() { return createSelector( - createRootFoldersSelector(), - (state, { value }) => value, - (state, { includeMissingValue }) => includeMissingValue, + (state) => state.rootFolders, (state, { includeNoChange }) => includeNoChange, - (state, { includeNoChangeDisabled }) => includeNoChangeDisabled, - (rootFolders, value, includeMissingValue, includeNoChange, includeNoChangeDisabled = true) => { + (rootFolders, includeNoChange) => { const values = rootFolders.items.map((rootFolder) => { return { key: rootFolder.path, value: rootFolder.path, - name: rootFolder.name, - freeSpace: rootFolder.freeSpace, - isMissing: false + freeSpace: rootFolder.freeSpace }; }); @@ -29,16 +24,6 @@ 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 }); } @@ -66,12 +51,20 @@ function createMapStateToProps() { ); } +function createMapDispatchToProps(dispatch, props) { + return { + dispatchAddRootFolder(path) { + dispatch(addRootFolder({ path })); + } + }; +} + class RootFolderSelectInputConnector extends Component { // // Lifecycle - UNSAFE_componentWillMount() { + componentWillMount() { const { value, values, @@ -102,25 +95,11 @@ class RootFolderSelectInputConnector extends Component { } } - componentDidUpdate(prevProps) { - const { - name, - value, - values, - onChange - } = this.props; + // + // Listeners - 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 }); - } - } + onNewRootFolderSelect = (path) => { + this.props.dispatchAddRootFolder(path); } // @@ -128,6 +107,7 @@ class RootFolderSelectInputConnector extends Component { render() { const { + dispatchAddRootFolder, ...otherProps } = this.props; @@ -145,11 +125,12 @@ RootFolderSelectInputConnector.propTypes = { value: PropTypes.string, values: PropTypes.arrayOf(PropTypes.object).isRequired, includeNoChange: PropTypes.bool.isRequired, - onChange: PropTypes.func.isRequired + onChange: PropTypes.func.isRequired, + dispatchAddRootFolder: PropTypes.func.isRequired }; RootFolderSelectInputConnector.defaultProps = { includeNoChange: false }; -export default connect(createMapStateToProps)(RootFolderSelectInputConnector); +export default connect(createMapStateToProps, createMapDispatchToProps)(RootFolderSelectInputConnector); diff --git a/frontend/src/Components/Form/RootFolderSelectInputOption.css b/frontend/src/Components/Form/RootFolderSelectInputOption.css index f63cba8d8..d8b44fcad 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputOption.css +++ b/frontend/src/Components/Form/RootFolderSelectInputOption.css @@ -13,24 +13,8 @@ } } -.value { - display: flex; -} - -.artistFolder { - flex: 0 0 auto; - color: var(--disabledColor); -} - .freeSpace { margin-left: 15px; - color: var(--darkGray); + color: $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 deleted file mode 100644 index 41b5a15ac..000000000 --- a/frontend/src/Components/Form/RootFolderSelectInputOption.css.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 b339c84e8..a4db9cd82 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputOption.js +++ b/frontend/src/Components/Form/RootFolderSelectInputOption.js @@ -1,30 +1,20 @@ -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 ( @@ -33,52 +23,23 @@ function RootFolderSelectInputOption(props) { isMobile && styles.isMobile )} > -
- {text} - - { - artistFolder && id !== 'addNew' ? -
- {slashCharacter} - {artistFolder} -
: - null - } -
+
{value}
{ - freeSpace == null ? - null : + freeSpace != null &&
{formatBytes(freeSpace)} Free
} - - { - isMissing ? -
- Missing -
: - null - }
); } RootFolderSelectInputOption.propTypes = { - id: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, value: PropTypes.string.isRequired, freeSpace: PropTypes.number, - isMissing: PropTypes.bool, - artistFolder: PropTypes.string, - isMobile: PropTypes.bool.isRequired, - isWindows: PropTypes.bool -}; - -RootFolderSelectInputOption.defaultProps = { - name: '' + isMobile: PropTypes.bool.isRequired }; export default RootFolderSelectInputOption; diff --git a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css index d248416d2..6b0cf9e4f 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css +++ b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css @@ -7,26 +7,16 @@ overflow: hidden; } -.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); + + flex: 1 0 0; } .freeSpace { flex: 0 0 auto; margin-left: 15px; - color: var(--gray); + color: $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 deleted file mode 100644 index eb2ba85c7..000000000 --- a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.css.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 58e8efbd3..ffd769254 100644 --- a/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.js +++ b/frontend/src/Components/Form/RootFolderSelectInputSelectedValue.js @@ -6,37 +6,19 @@ 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 ( -
-
- {text} -
- - { - artistFolder ? -
- {slashCharacter} - {artistFolder} -
: - null - } +
+ {value}
{ @@ -50,16 +32,12 @@ 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 deleted file mode 100644 index fe8fa3069..000000000 --- a/frontend/src/Components/Form/SelectInput.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 d43560134..113d50a09 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,7 +52,6 @@ class SelectInput extends Component { const { key, value: optionValue, - isDisabled: optionIsDisabled = false, ...otherOptionProps } = option; @@ -60,10 +59,9 @@ class SelectInput extends Component { ); }) @@ -77,7 +75,7 @@ SelectInput.propTypes = { className: PropTypes.string, disabledClassName: PropTypes.string, name: PropTypes.string.isRequired, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.func]).isRequired, + value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).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 822ae9931..4fe0a974c 100644 --- a/frontend/src/Components/Form/SeriesTypeSelectInput.js +++ b/frontend/src/Components/Form/SeriesTypeSelectInput.js @@ -1,7 +1,6 @@ import PropTypes from 'prop-types'; import React from 'react'; -import translate from 'Utilities/String/translate'; -import EnhancedSelectInput from './EnhancedSelectInput'; +import SelectInput from './SelectInput'; const artistTypeOptions = [ { key: 'standard', value: 'Standard' }, @@ -14,15 +13,14 @@ function SeriesTypeSelectInput(props) { const { includeNoChange, - includeNoChangeDisabled = true, includeMixed } = props; if (includeNoChange) { values.unshift({ key: 'noChange', - value: translate('NoChange'), - isDisabled: includeNoChangeDisabled + value: 'No Change', + disabled: true }); } @@ -30,12 +28,12 @@ function SeriesTypeSelectInput(props) { values.unshift({ key: 'mixed', value: '(Mixed)', - isDisabled: true + disabled: true }); } return ( - @@ -44,7 +42,6 @@ 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 eeddab5b4..1516bfb1d 100644 --- a/frontend/src/Components/Form/TagInput.css +++ b/frontend/src/Components/Form/TagInput.css @@ -7,19 +7,11 @@ &.isFocused { outline: 0; - border-color: var(--inputFocusBorderColor); - box-shadow: inset 0 1px 1px var(--inputBoxShadowColor), 0 0 8px var(--inputFocusBoxShadowColor); + border-color: $inputFocusBorderColor; + box-shadow: inset 0 1px 1px $inputBoxShadowColor, 0 0 8px $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; @@ -28,6 +20,4 @@ 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 deleted file mode 100644 index 8b3b412a5..000000000 --- a/frontend/src/Components/Form/TagInput.css.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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 840d627f8..45d972631 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,26 +70,14 @@ 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; @@ -97,7 +85,7 @@ class TagInput extends Component { if (method === 'type') { this.setState({ value }); } - }; + } onInputKeyDown = (event) => { const { @@ -112,9 +100,9 @@ class TagInput extends Component { suggestions } = this.state; - const key = event.key; + const keyCode = event.keyCode; - if (key === 'Backspace' && !value.length) { + if (keyCode === 8 && !value.length) { const index = tags.length - 1; if (index >= 0) { @@ -128,7 +116,7 @@ class TagInput extends Component { event.preventDefault(); } - if (delimiters.includes(key)) { + if (delimiters.includes(keyCode)) { const selectedIndex = this._autosuggestRef.highlightedSuggestionIndex; const tag = getTag(value, selectedIndex, suggestions, allowNew); @@ -137,11 +125,11 @@ class TagInput extends Component { event.preventDefault(); } } - }; + } onInputFocus = () => { this.setState({ isFocused: true }); - }; + } onInputBlur = () => { this.setState({ isFocused: false }); @@ -165,7 +153,7 @@ class TagInput extends Component { if (tag) { this.addTag(tag); } - }; + } onSuggestionsFetchRequested = ({ value }) => { const lowerCaseValue = value.toLowerCase(); @@ -182,16 +170,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 @@ -200,7 +188,6 @@ class TagInput extends Component { const { tags, kind, - canEdit, tagComponent, onTagDelete } = this.props; @@ -212,21 +199,17 @@ 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; @@ -240,12 +223,10 @@ 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,7 +138,6 @@ class TagInputConnector extends Component { ); diff --git a/frontend/src/Components/Form/TagInputInput.css b/frontend/src/Components/Form/TagInputInput.css index ab9d08d61..292f1a089 100644 --- a/frontend/src/Components/Form/TagInputInput.css +++ b/frontend/src/Components/Form/TagInputInput.css @@ -1,5 +1,8 @@ .inputContainer { - inset: -1px; + top: -1px; + right: -1px; + bottom: -1px; + left: -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 deleted file mode 100644 index d0a03ef53..000000000 --- a/frontend/src/Components/Form/TagInputInput.css.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -// 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 86628b134..3e28830e9 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,16 +28,15 @@ class TagInputInput extends Component { tags, inputProps, kind, - canEdit, tagComponent: TagComponent, - onTagDelete, - onTagEdit + onTagDelete } = this.props; return (
{ @@ -48,10 +47,8 @@ class TagInputInput extends Component { index={index} tag={tag} kind={kind} - canEdit={canEdit} isLastTag={index === tags.length - 1} onDelete={onTagDelete} - onEdit={onTagEdit} /> ); }) @@ -70,10 +67,8 @@ 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 7e66a4d12..bf08e13fc 100644 --- a/frontend/src/Components/Form/TagInputTag.css +++ b/frontend/src/Components/Form/TagInputTag.css @@ -1,34 +1,5 @@ .tag { - display: flex; - justify-content: center; - flex-direction: column; - max-width: 100%; + composes: link from '~Components/Link/Link.css'; + 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 deleted file mode 100644 index 510189d2c..000000000 --- a/frontend/src/Components/Form/TagInputTag.css.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -// 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 004381924..f5935ad7b 100644 --- a/frontend/src/Components/Form/TagInputTag.js +++ b/frontend/src/Components/Form/TagInputTag.js @@ -1,10 +1,9 @@ import PropTypes from 'prop-types'; import React, { Component } from 'react'; -import Label from 'Components/Label'; -import IconButton from 'Components/Link/IconButton'; -import Link from 'Components/Link/Link'; -import { icons, kinds } from 'Helpers/Props'; +import { kinds } from 'Helpers/Props'; import tagShape from 'Helpers/Props/Shapes/tagShape'; +import Label from 'Components/Label'; +import Link from 'Components/Link/Link'; import styles from './TagInputTag.css'; class TagInputTag extends Component { @@ -23,21 +22,7 @@ class TagInputTag extends Component { index, id: tag.id }); - }; - - onEdit = () => { - const { - index, - tag, - onEdit - } = this.props; - - onEdit({ - index, - id: tag.id, - value: tag.name - }); - }; + } // // Render @@ -45,41 +30,18 @@ class TagInputTag extends Component { render() { const { tag, - kind, - canEdit + kind } = this.props; - return ( -
-
+ ); } } @@ -88,9 +50,7 @@ TagInputTag.propTypes = { index: PropTypes.number.isRequired, tag: PropTypes.shape(tagShape), kind: PropTypes.oneOf(kinds.all).isRequired, - canEdit: PropTypes.bool.isRequired, - onDelete: PropTypes.func.isRequired, - onEdit: PropTypes.func.isRequired + onDelete: PropTypes.func.isRequired }; export default TagInputTag; diff --git a/frontend/src/Components/Form/TagSelectInputConnector.js b/frontend/src/Components/Form/TagSelectInputConnector.js deleted file mode 100644 index 23afe6da1..000000000 --- a/frontend/src/Components/Form/TagSelectInputConnector.js +++ /dev/null @@ -1,102 +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 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 deleted file mode 100644 index 7a4961c07..000000000 --- a/frontend/src/Components/Form/TextArea.css +++ /dev/null @@ -1,19 +0,0 @@ -.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 deleted file mode 100644 index 59c6aad69..000000000 --- a/frontend/src/Components/Form/TextArea.css.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -// 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 deleted file mode 100644 index 44fd3a249..000000000 --- a/frontend/src/Components/Form/TextArea.js +++ /dev/null @@ -1,172 +0,0 @@ -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 ( -