diff --git a/adze-web/src/ConfigureSection.js b/adze-web/src/ConfigureSection.js index 68f37f1..e01ee49 100644 --- a/adze-web/src/ConfigureSection.js +++ b/adze-web/src/ConfigureSection.js @@ -1,3 +1,4 @@ +import React from 'react'; import Constants from './Constants.js' import { selectManifest, uploadToHub } from './state/manifestSlice.js' import { selectCredentials, validateCredentials } from './state/credentialsSlice.js' diff --git a/adze-web/src/FeedSection.js b/adze-web/src/FeedSection.js index c27fee4..f31850e 100644 --- a/adze-web/src/FeedSection.js +++ b/adze-web/src/FeedSection.js @@ -139,7 +139,7 @@ class ProvenanceDescription extends React.Component { } - return sharerParts.join(", ");; + return sharerParts.join(", "); } getFullShareDescription() { diff --git a/adze-web/src/LinksSection.js b/adze-web/src/LinksSection.js index 5d65cf2..56da427 100644 --- a/adze-web/src/LinksSection.js +++ b/adze-web/src/LinksSection.js @@ -1,37 +1,44 @@ -import React from 'react' - - +import React, { useState } from 'react' import Constants from './Constants.js' +import { selectManifest, addLinkByUrl, removeLink } from './state/manifestSlice.js' +import { selectCredentials } from './state/credentialsSlice.js' +import { useSelector, useDispatch } from 'react-redux' +import { ErrorMessageOrNull, ManifestStatusMessage } from './notifications.js' -import { selectManifest , addLinkByUrl, removeLink } from './state/manifestSlice.js' -import { selectCredentials } from './state/credentialsSlice.js' -import { useSelector, useDispatch} from 'react-redux' +const numberOfTags = 4; -import { ErrorMessageOrNull, ManifestStatusMessage} from './notifications.js' - -function SingleLinkElement({link}){ - // upvote adze it to your own list of links +function SingleLinkElement({ link }) { + // upvote adze it to your own list of links // gives you the option of following the peer if you aren't already - // downvote removes it from your feed, adze it to your list of 'no good' + // downvote removes it from your feed, adze it to your list of 'no good' // links, and gives the option of removing that peer - const dispatch = useDispatch(); - - const removeThisLink = () => { - dispatch(removeLink(link)); - } - - return ( -
  • - - {link.title} -
  • - ); + const dispatch = useDispatch(); + + const removeThisLink = () => { + dispatch(removeLink(link)); + } + + return ( +
  • + + {link.title} +
    {link.url}
    + Tags: + {link.tags && link.tags.length !== 0 && link.tags.map(tag => ( + + {tag} + + ))} +
  • + ); } -function LinksSection({isActive}) { - const className = isActive ? "" : "is-invisible"; +function LinksSection({ isActive }) { + const [inputLinkUrl, setInputLinkUrl] = useState("") + const [inputTags, setInputTags] = useState([...Array(numberOfTags)]) + const className = isActive ? "" : "is-invisible"; const styleType = isActive ? {} : Constants.invisibleStyle; const manifest = useSelector(selectManifest); const credentials = useSelector(selectCredentials); @@ -39,33 +46,77 @@ function LinksSection({isActive}) { const linkItems = manifest.content.sites.map(site => ); + const handleClear = () => { + setInputLinkUrl(""); + setInputTags([...Array(numberOfTags)]); + } - const handleAddLink = (event) => { - event.preventDefault(); - const formData = new FormData(event.currentTarget); - const { inputLinkUrl } = event.target.elements; + const updateInputTags = (value, i) => { + let updateInputTags = [...inputTags]; + updateInputTags[i] = value; + setInputTags(updateInputTags); + } - dispatch(addLinkByUrl({credentials: credentials, link: inputLinkUrl.value})); + const handleAddLink = (event) => { + event.preventDefault(); + console.log(inputLinkUrl); + let listOfTags = inputTags.filter(e => e && String(e).trim()); + console.log(listOfTags) + dispatch(addLinkByUrl({ + credentials: credentials, + link: inputLinkUrl, + tags: listOfTags + })); } + + return ( ) } diff --git a/adze-web/src/PeersSection.js b/adze-web/src/PeersSection.js index 31ce9c1..f79d964 100644 --- a/adze-web/src/PeersSection.js +++ b/adze-web/src/PeersSection.js @@ -1,4 +1,5 @@ -import Constants from './Constants.js' +import React from 'react'; +import Constants from './Constants.js'; import { selectManifest , addPeerByUrl, removePeer } from './state/manifestSlice.js' import { useSelector, useDispatch} from 'react-redux' diff --git a/adze-web/src/state/feedSlice.js b/adze-web/src/state/feedSlice.js index f813ca5..1caa9cb 100644 --- a/adze-web/src/state/feedSlice.js +++ b/adze-web/src/state/feedSlice.js @@ -36,15 +36,15 @@ async function updatePeerManifestCache(localManifest, numTimesToFollow) { var toVisitNext = []; var thisPeerOrder = 1; // make a plan to visit all the local peers - for (var peerNo in localManifest.content.peers) { - var peer = localManifest.content.peers[peerNo]; + for (let peerNo in localManifest.content.peers) { + let peer = localManifest.content.peers[peerNo]; peersSeenSoFar[peer.url] = true; toVisit.push(peer); } while (numTimesToFollow > 0) { - for (var peerNo in toVisit) { - var peer = toVisit[peerNo]; + for (let peerNo in toVisit) { + let peer = toVisit[peerNo]; var thisPeerManifest = await getPeerManifest(peer.url); peersSeenSoFar[peer.url] = true; thisPeerManifest.meta.order = thisPeerOrder; diff --git a/adze-web/src/state/manifestSlice.js b/adze-web/src/state/manifestSlice.js index 33c8f7d..149c8ad 100644 --- a/adze-web/src/state/manifestSlice.js +++ b/adze-web/src/state/manifestSlice.js @@ -55,6 +55,7 @@ export const addLinkByUrl = createAsyncThunk( title: linkDesc.title, url: linkDesc.url, timestamp_ms: new Date().getTime(), + tags: linkAndCreds.tags } } ) diff --git a/adze-web/src/store.js b/adze-web/src/store.js index bfe1be8..68e4ddf 100644 --- a/adze-web/src/store.js +++ b/adze-web/src/store.js @@ -15,7 +15,7 @@ const localStorageMiddleware = ({ getState }) => { const reHydrateStore = () => { if (localStorage.getItem('applicationState') !== null) { return JSON.parse(localStorage.getItem('applicationState')); // re-hydrate the store - }; + } }