Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

Changes in trash and settings

alihamuh63e0314390be
diff --git a/apps/web/src/components/button/index.js b/apps/web/src/components/button/index.js
index 5b126b77d..c60ff00d2 100644
--- a/apps/web/src/components/button/index.js
+++ b/apps/web/src/components/button/index.js
@@ -2,6 +2,7 @@ import React from "react";
import { Flex, Text } from "rebass";
import { ButtonPressedStyle } from "../../theme";
+
const Button = props => (
<Flex
bg="primary"
diff --git a/apps/web/src/components/settings/index.js b/apps/web/src/components/settings/index.js
new file mode 100644
index 000000000..d50d6d658
--- /dev/null
+++ b/apps/web/src/components/settings/index.js
@@ -0,0 +1,28 @@
+import React from "react";
+import * as Icon from "react-feather";
+import TimeAgo from "timeago-react";
+import { db, ev } from "../../common";
+import { showSnack } from "../snackbar";
+import ListItem from "../list-item";
+import { Virtuoso as List } from "react-virtuoso";
+
+const dropdownRefs = [];
+const menuItems = [
+ { title: "Restore" },
+ {
+ title: "Delete",
+ color: "red",
+ }
+];
+
+function sendOpenNoteEvent(note) {
+ ev.emit("onOpenNote", note);
+}
+
+const Trash = () => {
+ return (
+ <div>My name is ALi.</div>
+ );
+};
+
+export default Trash;
\ No newline at end of file
diff --git a/apps/web/src/components/trash/index.js b/apps/web/src/components/trash/index.js
new file mode 100644
index 000000000..b743cbefb
--- /dev/null
+++ b/apps/web/src/components/trash/index.js
@@ -0,0 +1,37 @@
+import React from "react";
+import * as Icon from "react-feather";
+import TimeAgo from "timeago-react";
+import { db, ev } from "../../common";
+import { showSnack } from "../snackbar";
+import ListItem from "../list-item";
+
+const dropdownRefs = [];
+const menuItems = [
+ { title: "Restore" },
+ {
+ title: "Delete",
+ color: "red",
+ }
+];
+
+function sendOpenNoteEvent(note) {
+ ev.emit("onOpenNote", note);
+}
+
+const Trash = ({ item, index }) => {
+ const note = item;
+ return (
+ <ListItem
+ title={note.title}
+ body={note.headline}
+ index={index}
+ onClick={sendOpenNoteEvent.bind(this, note)}
+ info={<TimeAgo datetime={note.dateCreated} />}
+ menuData={note}
+ menuItems={menuItems}
+ dropdownRefs={dropdownRefs}
+ />
+ );
+};
+
+export default Trash;
\ No newline at end of file
diff --git a/apps/web/src/navigation/index.js b/apps/web/src/navigation/index.js
index 643e466d7..55add44be 100644
--- a/apps/web/src/navigation/index.js
+++ b/apps/web/src/navigation/index.js
@@ -2,6 +2,8 @@ import React, { useState, useEffect } from "react";
import ReactDOM from "react-dom";
import Home from "../views/Home";
import Notebooks from "../views/Notebooks";
+import Settings from "../views/Settings";
+import Trash from "../views/Trash";
import { ThemeProvider } from "emotion-theming";
import { Box, Flex, Heading } from "rebass";
import * as Icon from "react-feather";
@@ -23,13 +25,13 @@ export const routes = {
trash: {
key: "trash",
title: "Trash",
- component: undefined,
+ component: Trash,
icon: Icon.Trash
},
settings: {
key: "settings",
title: "Settings",
- component: undefined,
+ component: Settings,
icon: Icon.Settings
}
};
diff --git a/apps/web/src/views/Settings.js b/apps/web/src/views/Settings.js
new file mode 100644
index 000000000..4f5473175
--- /dev/null
+++ b/apps/web/src/views/Settings.js
@@ -0,0 +1,37 @@
+import React, { useState, useEffect } from 'react';
+import {Box, Flex, Text} from 'rebass';
+import Button from "../components/button";
+import { db } from "../common";
+import Setting from '../components/settings';
+import Search from "../components/search";
+import * as Icon from "react-feather";
+import { Virtuoso as List } from "react-virtuoso";
+
+
+
+function Settings(){
+
+ const [trash, setTrash] = useState([]);
+
+ useEffect(() => {
+ function onRefreshTrash() {
+ setTrash(db.getTrash());
+ }
+ onRefreshTrash();
+ //ev.addListener("refreshNotes", onRefreshNotes);
+ // return () => {
+ // //ev.removeListener("refreshNotes", onRefreshNotes);
+ // };
+ }, []);
+
+ return(
+ <Flex flexDirection="column" flex="1 1 auto">
+ {(<Flex flexDirection="column" flex="1 1 auto">
+ <Setting></Setting>
+ </Flex>
+ )}
+ </Flex>
+ );
+}
+
+export default Settings;
\ No newline at end of file
diff --git a/apps/web/src/views/Trash.js b/apps/web/src/views/Trash.js
new file mode 100644
index 000000000..fc6d953a5
--- /dev/null
+++ b/apps/web/src/views/Trash.js
@@ -0,0 +1,66 @@
+import React, { useState, useEffect } from 'react';
+import {Box, Flex, Text} from 'rebass';
+import Button from "../components/button";
+import { db } from "../common";
+import Trash1 from '../components/trash';
+import Search from "../components/search";
+import * as Icon from "react-feather";
+import { Virtuoso as List } from "react-virtuoso";
+
+
+
+function Trash(){
+
+ const [trash, setTrash] = useState([]);
+
+ useEffect(() => {
+ function onRefreshTrash() {
+ setTrash(db.getTrash());
+ }
+ onRefreshTrash();
+ //ev.addListener("refreshNotes", onRefreshNotes);
+ // return () => {
+ // //ev.removeListener("refreshNotes", onRefreshNotes);
+ // };
+ }, []);
+
+ return(
+ <Flex flexDirection="column" flex="1 1 auto">
+ {trash.length > 0 ? (
+ <Flex flexDirection="column" flex="1 1 auto">
+ <Search placeholder="Search" />
+ <List
+ style={{
+ width: "100%",
+ flex: "1 1 auto",
+ height: "auto",
+ overflowX: "hidden"
+ }}
+ totalCount={
+ trash.length
+ }
+ item={index => <Trash1 index={index} item={trash[index]} />}
+ />
+ <Button
+ Icon={Icon.Trash2}
+ content={"Clear Trash"}
+ onClick={db.clearTrash()}
+ />
+ </Flex>
+ ) : (
+ <Flex
+ flex="1 1 auto"
+ alignItems="center"
+ justifyContent="center"
+ color="#9b9b9b"
+ flexDirection="column"
+ >
+ <Icon.Trash size={72} strokeWidth={1.5} />
+ <Text variant="title">You have no trash.</Text>
+ </Flex>
+ )}
+ </Flex>
+ );
+}
+
+export default Trash;
\ No newline at end of file