diff --git a/pkg/interface/link/src/css/custom.css b/pkg/interface/link/src/css/custom.css index 35ed6b0ea..550fcfd0b 100644 --- a/pkg/interface/link/src/css/custom.css +++ b/pkg/interface/link/src/css/custom.css @@ -214,4 +214,7 @@ a { a { color: #fff; } + .hover-bg-gray1-d:hover { + background-color: #4d4d4d; + } } \ No newline at end of file diff --git a/pkg/interface/link/src/js/components/lib/channel-sidebar.js b/pkg/interface/link/src/js/components/lib/channel-sidebar.js index f14792c68..315d9f53d 100644 --- a/pkg/interface/link/src/js/components/lib/channel-sidebar.js +++ b/pkg/interface/link/src/js/components/lib/channel-sidebar.js @@ -1,9 +1,10 @@ import React, { Component } from 'react'; import { Route, Link } from 'react-router-dom'; -import { ChannelsItem } from '/components/lib/channels-item'; +import { GroupItem } from './group-item'; import { SidebarInvite } from '/components/lib/sidebar-invite'; import { Welcome } from '/components/lib/welcome'; +import { alphabetiseAssociations } from '../../lib/util'; export class ChannelsSidebar extends Component { // drawer to the left @@ -21,34 +22,75 @@ export class ChannelsSidebar extends Component { ); }); - const channelItems = - [...props.listening].map((path) => { - const meta = props.associations[path]; - if (!meta) return null; - const selected = (props.selected === path); - const linkCount = !!props.links[path] ? props.links[path].totalItems : 0; - const unseenCount = !!props.links[path] - ? props.links[path].unseenCount - : linkCount + let associations = !!props.associations.contacts ? alphabetiseAssociations(props.associations.contacts) : {}; - return ( - - ); - }); + let groupedChannels = {}; + [...props.listening].map((path) => { + let groupPath = !!props.associations.link[path] ? + props.associations.link[path]["group-path"] : ""; + + console.log(path); + console.log(groupPath); + + if (groupPath.startsWith("/~/")) { + if (groupedChannels["/~/"]) { + let array = groupedChannels["/~/"]; + array.push(path); + groupedChannels["/~/"] = array; + } else { + groupedChannels["/~/"] = [path]; + }; + } + if (groupPath in associations) { + if (groupedChannels[groupPath]) { + let array = groupedChannels[groupPath]; + array.push[path]; + groupedChannels[groupPath] = array; + } else { + groupedChannels[groupPath] = [path]; + } + } + }); + + let i = -1; + const groupedItems = Object.keys(associations).map((each) => { + let channels = groupedChannels[each]; + if (!channels || channels.length === 0) return; + i++; + if (groupedChannels["/~/"] && groupedChannels["/~/"].length !== 0) { + i++; + } + + return ( + + ) + }); + if (groupedChannels["/~/"] && groupedChannels["/~/"].length !== 0) { + groupedItems.unshift( + + ) + } let activeClasses = (this.props.active === "collections") ? " " : "dn-s "; let hiddenClasses = true; - // probably a more concise way to write this - if (this.props.popout) { hiddenClasses = false; } else { @@ -63,17 +105,16 @@ export class ChannelsSidebar extends Component { : "dn")}> ⟵ Landscape
-
+
New Collection
{sidebarInvites} - {channelItems} + {groupedItems}
); diff --git a/pkg/interface/link/src/js/components/lib/channels-item.js b/pkg/interface/link/src/js/components/lib/channels-item.js index 3514421ae..8235bde92 100644 --- a/pkg/interface/link/src/js/components/lib/channels-item.js +++ b/pkg/interface/link/src/js/components/lib/channels-item.js @@ -7,25 +7,18 @@ export class ChannelsItem extends Component { const { props } = this; let selectedClass = (props.selected) - ? "bg-gray5 bg-gray1-d b--gray4 b--gray2-d" - : "b--gray4 b--gray2-d"; + ? "bg-gray5 bg-gray1-d" + : "pointer hover-bg-gray5 hover-bg-gray1-d"; - let memberCount = props.memberList - ? props.memberList.size - : 0; const unseenCount = props.unseenCount > 0 - ? {" " + props.unseenCount + " unread"} + ? {props.unseenCount} : null; return ( -
-

{props.name}

-

- {memberCount + " contributor" + ((memberCount === 1) ? "" : "s")} -

-

- {props.linkCount + " link" + ((props.linkCount === 1) ? "" : "s")} +

+

{props.name}

+

{unseenCount}

diff --git a/pkg/interface/link/src/js/components/lib/group-item.js b/pkg/interface/link/src/js/components/lib/group-item.js new file mode 100644 index 000000000..161477830 --- /dev/null +++ b/pkg/interface/link/src/js/components/lib/group-item.js @@ -0,0 +1,45 @@ +import React, { Component } from 'react'; +import { ChannelsItem } from './channels-item'; + +export class GroupItem extends Component { + render() { + const { props, state } = this; + let association = !!props.association ? props.association : {}; + + let title = association["app-path"] ? association["app-path"] : "Unmanaged Collections"; + + if (association.metadata && association.metadata.title) { + title = association.metadata.title !== "" + ? association.metadata.title : title; + } + + let channels = !!props.channels ? props.channels : []; + let first = (props.index === 0) ? "pt1" : "pt4"; + + let channelItems = channels.map((each, i) => { + const meta = props.linkMetadata[each]; + if (!meta) return null; + const selected = (props.selected === each); + const unseenCount = !!props.links[each] + ? props.links[each].unseenCount + : 0; + return ( + + ) + }) + return ( +
+

{title}

+ {channelItems} +
+ ) + } +} + +export default GroupItem; \ No newline at end of file diff --git a/pkg/interface/link/src/js/components/root.js b/pkg/interface/link/src/js/components/root.js index 030dcc190..c458299c0 100644 --- a/pkg/interface/link/src/js/components/root.js +++ b/pkg/interface/link/src/js/components/root.js @@ -49,7 +49,7 @@ export class Root extends Component { { + let aName = a.substr(1); + let bName = b.substr(1); + if (a.metadata && a.metadata.title) { + aName = a.metadata.title !== "" + ? a.metadata.title + : a.substr(1); + } + if (b.metadata && b.metadata.title) { + bName = b.metadata.title !== "" + ? b.metadata.title + : b.substr(1); + } + return aName.toLowerCase().localeCompare(bName.toLowerCase()); + }).map((each) => { + result[each] = associations[each]; + }) + return result; } \ No newline at end of file