diff --git a/public/components/BatchTag.react.js b/public/components/BatchTag.react.js index 3ab4dcd7..457a0801 100644 --- a/public/components/BatchTag.react.js +++ b/public/components/BatchTag.react.js @@ -3,6 +3,7 @@ import ContentList from './ContentList/ContentList'; import PageNavigator from './utils/PageNavigator.react'; import BatchTagControls from './BatchTagControls/BatchTagControls'; import BatchFilters from './BatchTag/BatchFilters.react'; +import {BatchTagArbitraryUrls} from "./BatchTagControls/BatchTagArbitraryUrls"; import R from 'ramda'; const CAPI_PAGE_SIZE = 10; @@ -35,7 +36,7 @@ export class BatchTag extends React.Component { window.onbeforeunload = function() { return 'Unsaved batch tag changes, are you sure you want to leave?'; }; - } + } if (prevCount > 0 && newCount === 0) { window.onbeforeunload = null; @@ -196,6 +197,7 @@ export class BatchTag extends React.Component { + {" OR "} this.setState({selectedContent: R.union(this.state.selectedContent, paths)})}/>
{ this.state.showFilters ? 'Hide Filters' : 'Show Filters'}
diff --git a/public/components/BatchTagControls/BatchTagArbitraryUrls.js b/public/components/BatchTagControls/BatchTagArbitraryUrls.js new file mode 100644 index 00000000..d019d420 --- /dev/null +++ b/public/components/BatchTagControls/BatchTagArbitraryUrls.js @@ -0,0 +1,68 @@ +import React, {useState} from "react"; + +export const BatchTagArbitraryUrls = ({addPathsToSelection}) => { + + const [isModalDisplayed, setIsModalDisplayed] = useState(false); + + const [input, setInput] = useState("") // string + const [cleaned, setCleaned] = useState(); // string[] + + const close = () => { + setInput(""); + setCleaned(null); + setIsModalDisplayed(false); + } + const clean = () => setCleaned([...new Set( + input.split("\n").map(url => { + if(url.startsWith("http")){ + return url.trim().split("/").slice(3).join("/"); + } + return url.trim(); // already just the path + }).filter(_ => !!_) // remove empty + )]); + + const complete = () => { + addPathsToSelection(cleaned); + close(); + } + + return ( + + {isModalDisplayed && ( +
+
+
{cleaned + ? "Please check the paths extracted from the web URLs you entered" + : "Enter web URLs (one per line)" + }
+