From 3746200f21917dd0a70adad59ae33b37ba256de3 Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 13 Jul 2019 12:15:30 +0530 Subject: Implements Bookmarks Listing Grid Adjustments Prepare for release --- icons/icon.png | Bin 0 -> 7225 bytes icons/icon.sketch | Bin 0 -> 25533 bytes icons/~`~icon.sketch | Bin 0 -> 20217 bytes package.json | 2 + src/App.css | 18 +++++++++ src/App.js | 104 ++++++++++++++++++++++++++++++++++++++++----------- yarn.lock | 10 +++++ 7 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 icons/icon.png create mode 100644 icons/icon.sketch create mode 100644 icons/~`~icon.sketch diff --git a/icons/icon.png b/icons/icon.png new file mode 100644 index 0000000..dbdf521 Binary files /dev/null and b/icons/icon.png differ diff --git a/icons/icon.sketch b/icons/icon.sketch new file mode 100644 index 0000000..68ab1c7 Binary files /dev/null and b/icons/icon.sketch differ diff --git a/icons/~`~icon.sketch b/icons/~`~icon.sketch new file mode 100644 index 0000000..0312ba4 Binary files /dev/null and b/icons/~`~icon.sketch differ diff --git a/package.json b/package.json index ce0b14c..19c165b 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "private": true, "dependencies": { "classnames": "^2.2.6", + "lodash": "^4.17.14", + "moment": "^2.24.0", "primeicons": "^1.0.0", "primereact": "^3.1.7", "react": "^16.8.6", diff --git a/src/App.css b/src/App.css index e69de29..db20a8c 100644 --- a/src/App.css +++ b/src/App.css @@ -0,0 +1,18 @@ +button.refresh{ + float: right; + background: black; + border: none; + color: #fff; + /* padding: 6px; */ + border-radius: 3px; + width: 28px; + height: 28px; + padding-top: 3px; + cursor: pointer; +} + +.header { + text-align: center; + font-size: 17px; + color: #000; +} \ No newline at end of file diff --git a/src/App.js b/src/App.js index adbdf16..11b9321 100644 --- a/src/App.js +++ b/src/App.js @@ -1,8 +1,19 @@ /*global chrome*/ -import React from 'react'; +import React, {Component} from 'react'; import { DataTable } from 'primereact/datatable'; import { Column } from 'primereact/column'; -class App extends React.Component { +import {Button} from 'primereact/button'; +import {InputText} from 'primereact/inputtext'; +import _ from 'lodash'; +import moment from 'moment'; +import './App.css'; + +class App extends Component { + + state = { + bookMarkDataRaw: [], + bookMarks: [] + } /* Open port on popup file */ port = chrome.runtime.connect({ @@ -17,41 +28,92 @@ class App extends React.Component { listenMessages = () => { this.port.onMessage.addListener(message => { - console.log(message) + if(message.bookMarkData){ + this.setState({ + bookMarkDataRaw: message.bookMarkData[0] + }, ()=>{ + let collected = this.iterateBookMarks(this.state.bookMarkDataRaw.children, []); + collected = _.map(collected, (nodes)=>{ + if(nodes.parentId){ + let parentNode = _.find(collected, {id: nodes.parentId}); + nodes.parentNode = parentNode ? parentNode.title : ""; + } + return nodes; + }) + this.setState({ + bookMarks: collected + }) + }) + } }); + this.getBookMarks(); + } + + linkTemplate = (rowData, column) => { + return {rowData.url} + } + + dateTemplate = (rowData, column) => { + if(rowData.dateAdded){ + return {moment(rowData.dateAdded).format('MM-DD-YYYY hh:ss A')} + }else if(rowData.dateGroupModified){ + return {moment(rowData.dateAdded).format('MM-DD-YYYY hh:ss A')} + }else { + return + } } componentDidMount(){ this.listenMessages(); } + iterateBookMarks = (children, consolidatedChildrens)=>{ + let bookMarkChildren = _.each(children, (child)=>{ + if(child.children && child.children.length>0){ + let currentNode = child; + let currentNodeChildren = currentNode.children; + console.log(currentNodeChildren); + delete currentNode.children; + consolidatedChildrens.push(currentNode); + console.log(currentNodeChildren); + this.iterateBookMarks(currentNodeChildren, consolidatedChildrens); + }else{ + consolidatedChildrens.push(child); + } + }); + + return consolidatedChildrens; + } + render(){ + var header =
Enabling sortable property on a column is enough to make a column sortable. Multiple column sorting is enabled using sortMode property and - used with metaKey.
+ {/*