diff --git a/README.md b/README.md index 38401cd9..8d3ad916 100644 --- a/README.md +++ b/README.md @@ -27,14 +27,21 @@ Checklist - [x] Figure out how authentication of requests from the frontend to the API works - [x] Figure out how to combine the nodejs realtime server into server.js - [x] Notifications: make sure loading states are working for popup and page +- [x] Request unreadNotificationCount +- [x] Request invite code +- [x] Request user object itself +- [x] Load the metacodes + +- [ ] create topic form +- [ ] create synapse form +- [ ] move ImportDialog lightbox into main app - [ ] Notifications: make sure notifications either look nice, or redirect - [ ] Notifications: pagination - [ ] Get actioncable working - [ ] lightboxes -- [x] Request unreadNotificationCount -- [x] Request invite code -- [x] Request user object itself - [ ] About lightbox +- [ ] Switch Metacodes lightbox / component +- [ ] Fork map lightbox / component - [ ] break up index.html into parts - [ ] Handle CSS metacode colors - [ ] Fix Request An Invite page @@ -53,7 +60,5 @@ Checklist - [ ] authorize - [ ] user passwords - [ ] Modify the RubyOnRails app to only serve JSON responses, no HTML pages anymore -- [ ] Modify the RubyOnRails app to include an endpoint that responds with basic data the front end needs to display (such as the invite code for the user, and the current metamaps build) (a bunch of the data found here: https://github.com/metamaps/metamaps/blob/frontendonly/Metamaps.ServerData.js.erb) - [ ] Modify the frontend to request that data from the API which is necessary at first to load the page -- [x] Load the metacodes -- [ ] Load the metacode sets + - [ ] Load the metacode sets diff --git a/sass/notifications.scss b/sass/notifications.scss index 3cec306b..777d724e 100644 --- a/sass/notifications.scss +++ b/sass/notifications.scss @@ -117,6 +117,7 @@ $unread_notifications_dot_size: 8px; height: 32px; border-radius: 16px; vertical-align: middle; + margin-right: 8px; } .button { @@ -127,6 +128,7 @@ $unread_notifications_dot_size: 8px; } &.decline { + margin-left: 8px; background: #DB5D5D; &:hover { background: #DC4B4B; @@ -139,6 +141,10 @@ $unread_notifications_dot_size: 8px; margin: 1em auto; line-height: 20px; } + + .accessRequestError { + color: #DB5D5D; + } } } diff --git a/src/Metamaps/Create.js b/src/Metamaps/Create.js index 454ab331..b18d71cc 100644 --- a/src/Metamaps/Create.js +++ b/src/Metamaps/Create.js @@ -19,8 +19,6 @@ const Create = { newSelectedMetacodes: [], init: function() { var self = Create - self.newTopic.init() - self.newSynapse.init() // // SWITCHING METACODE SETS diff --git a/src/Metamaps/DataFetcher.js b/src/Metamaps/DataFetcher.js index 3bea2f2c..7a9f2fae 100644 --- a/src/Metamaps/DataFetcher.js +++ b/src/Metamaps/DataFetcher.js @@ -2,6 +2,14 @@ function fetchWithCookies(url) { return fetch(url, { credentials: 'same-origin' }) } +function postWithCookies(url, data = {}) { + return fetch(url, { + credentials: 'same-origin', + method: 'POST', + body: JSON.stringify(data) + }) +} + async function getMetacodes() { const res = await fetchWithCookies('/metacodes.json') const data = await res.json() @@ -14,7 +22,19 @@ async function getCurrentUser() { return data } +async function approveAccessRequest(mapId, requestId) { + const res = await postWithCookies(`/maps/${mapId}/approve_access/${requestId}`) + return res.status === 200 +} + +async function denyAccessRequest(mapId, requestId) { + const res = await postWithCookies(`/maps/${mapId}/deny_access/${requestId}`) + return res.status === 200 +} + module.exports = { getMetacodes, - getCurrentUser + getCurrentUser, + approveAccessRequest, + denyAccessRequest } \ No newline at end of file diff --git a/src/Metamaps/GlobalUI/Notifications.js b/src/Metamaps/GlobalUI/Notifications.js index 1b93d2cd..0ab962a8 100644 --- a/src/Metamaps/GlobalUI/Notifications.js +++ b/src/Metamaps/GlobalUI/Notifications.js @@ -7,7 +7,9 @@ const Notifications = { notificationsLoading: false, unreadNotificationsCount: 0, init: serverData => { - Notifications.unreadNotificationsCount = serverData.ActiveMapper.unread_notifications_count + if (serverData.ActiveMapper) { + Notifications.unreadNotificationsCount = serverData.ActiveMapper.unread_notifications_count + } }, fetchNotifications: render => { Notifications.notificationsLoading = true diff --git a/src/Metamaps/GlobalUI/ReactApp.js b/src/Metamaps/GlobalUI/ReactApp.js index cb5dc947..08752098 100644 --- a/src/Metamaps/GlobalUI/ReactApp.js +++ b/src/Metamaps/GlobalUI/ReactApp.js @@ -10,7 +10,9 @@ import { notifyUser } from './index.js' import ImportDialog from './ImportDialog' import Notifications from './Notifications' import Active from '../Active' +import Create from '../Create' import DataModel from '../DataModel' +import DataFetcher from '../DataFetcher' import { ExploreMaps, ChatView, TopicCard, ContextMenu } from '../Views' import Filter from '../Filter' import JIT from '../JIT' @@ -107,7 +109,9 @@ const ReactApp = { fetchNotifications: apply(Notifications.fetchNotifications, ReactApp.render), fetchNotification: apply(Notifications.fetchNotification, ReactApp.render), markAsRead: apply(Notifications.markAsRead, ReactApp.render), - markAsUnread: apply(Notifications.markAsUnread, ReactApp.render) + markAsUnread: apply(Notifications.markAsUnread, ReactApp.render), + denyAccessRequest: DataFetcher.denyAccessRequest, + approveAccessRequest: DataFetcher.approveAccessRequest }, self.getMapProps(), self.getTopicProps(), @@ -134,9 +138,12 @@ const ReactApp = { toggleMapInfoBox: InfoBox.toggleBox, infoBoxHtml: InfoBox.html, openImportLightbox: () => ImportDialog.show(), + openMetacodeSwitcher: () => self.openLightbox('metacodeSwitcher'), forkMap: Map.fork, onMapStar: Map.star, - onMapUnstar: Map.unstar + onMapUnstar: Map.unstar, + initNewTopic: Create.newTopic.init, + initNewSynapse: Create.newSynapse.init } }, getCommonProps: function() { diff --git a/src/components/LightBoxes/CheatSheet.js b/src/components/LightBoxes/CheatSheet.js index c82a1504..ade782fe 100644 --- a/src/components/LightBoxes/CheatSheet.js +++ b/src/components/LightBoxes/CheatSheet.js @@ -3,7 +3,7 @@ import React, { Component } from 'react' class CheatSheet extends Component { render = () => { return ( -
For more information about Metamaps.cc, visit our Knowledge Base or skip directly to a section by clicking on one of the categories below.
diff --git a/src/components/NewSynapse.js b/src/components/NewSynapse.js new file mode 100644 index 00000000..10e926f8 --- /dev/null +++ b/src/components/NewSynapse.js @@ -0,0 +1,18 @@ +import React, { Component } from 'react' + +class NewSynapse extends Component { + componentDidMount() { + this.props.initNewSynapse() + } + + render = () => { + return ( + + ) + } +} + +export default NewSynapse \ No newline at end of file diff --git a/src/components/NewTopic.js b/src/components/NewTopic.js new file mode 100644 index 00000000..3e33af27 --- /dev/null +++ b/src/components/NewTopic.js @@ -0,0 +1,44 @@ +import React, { Component } from 'react' + +class NewTopic extends Component { + componentDidMount() { + this.props.initNewTopic() + } + + render = () => { + const metacodes = [ + { + "id": 1, + "name": "Action", + "created_at": "2017-03-04T17:33:07.394Z", + "updated_at": "2017-03-04T17:33:07.394Z", + "color": "#BD6C85", + "icon": "https://s3.amazonaws.com/metamaps-assets/metacodes/blueprint/96px/bp_action.png" + } + ] + return ( + + ) + } +} + +export default NewTopic \ No newline at end of file diff --git a/src/routes/MapView/index.js b/src/routes/MapView/index.js index 027b395d..64a1a05e 100644 --- a/src/routes/MapView/index.js +++ b/src/routes/MapView/index.js @@ -9,6 +9,8 @@ import Instructions from './Instructions' import VisualizationControls from '../../components/VisualizationControls' import MapChat from './MapChat' import TopicCard from '../../components/TopicCard' +import NewTopic from '../../components/NewTopic' +import NewSynapse from '../../components/NewSynapse' export default class MapView extends Component { @@ -82,7 +84,7 @@ export default class MapView extends Component { openImportLightbox, forkMap, openHelpLightbox, mapIsStarred, onMapStar, onMapUnstar, openTopic, onZoomExtents, onZoomIn, onZoomOut, hasLearnedTopicCreation, - contextMenu } = this.props + contextMenu, initNewTopic, initNewSynapse, openMetacodeSwitcher } = this.props const { chatOpen } = this.state const onChatOpen = () => { this.setState({chatOpen: true}) @@ -111,6 +113,8 @@ export default class MapView extends Component { filterAllMappers={filterAllMappers} filterAllSynapses={filterAllSynapses} />
- {request.answered &&
+