Skip to content

Commit

Permalink
fix: ignore trash, fav for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Mason committed Jul 15, 2020
1 parent 8ad1faa commit 3fe4570
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ jobs:
if: matrix.os == 'windows-latest'
run: New-Item -Path "./source/common/assets" -Name "handlebars" -ItemType "directory" # Hello, PowerShell ._.

- name: Set up build environment and compile the assets
if: matrix.os != 'ubuntu-18.04'
- name: "[All except docker] Set up build environment and compile the assets"
if: matrix.os != 'ubuntu-18.04' # all except the docker build
run: |
yarn
# WINDOWS ==============================================================
Expand Down
11 changes: 9 additions & 2 deletions app/components/MainMenu/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export default function MainMenu({
hideFinderModal,
showNotebookModal,
hideNotebookModal,
searchNotesGlobal
searchNotesGlobal,
cacheParentId
}) {
const finderRef = useRef(null);
const createNotebookModalRef = useRef(2);
Expand Down Expand Up @@ -97,29 +98,34 @@ export default function MainMenu({

<MenuItem
label="All notes"
droppable
icon={<FontAwesomeIcon icon={faBook} />}
compKey="MenuItem"
onClickHandler={e=> selectNotebook("ALL")}
selected={selectedNotebook === "ALL"}

cacheParentId={e=>cacheParentId("ALL")}
/>


<ContextMenuTrigger id="trash_trigger">
<MenuItem
label="Trash"
droppable
icon={<FontAwesomeIcon icon={faTrash} />}
compKey="trashMenuItem"
onClickHandler={e=> selectNotebook("TRASH")}
selected={selectedNotebook === "TRASH"}
cacheParentId={e=>cacheParentId("TRASH")}
/>
</ContextMenuTrigger>
<MenuItem
label="Favourites"
droppable
icon={<FontAwesomeIcon icon={faStar} />}
compKey="favMenuItem"
onClickHandler={e=> selectNotebook("FAV")}
selected={selectedNotebook === "FAV"}
cacheParentId={e=>cacheParentId("FAV")}
/>
<ContextMenuTrigger id="mainmenu_notebooks">
<MenuItem
Expand Down Expand Up @@ -168,6 +174,7 @@ export default function MainMenu({
selected={selectedNotebook === "tag::" + n}
compKey={`tag-menu-item-${n}`}
key={`tag-menu-item-${n}`}
//cacheParentId={e=>cacheParentId(("tag::" + n)}
/>
))}
</MenuItem>
Expand Down
25 changes: 13 additions & 12 deletions app/components/MainMenu/MenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useState} from 'react';
import { MenuItemStyle, MenuItemIcon, MenuItemLabel, MenuItemNormal, MenuItemSelected } from './style';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { useDrop } from 'react-dnd'
import { faCaretSquareRight, faCaretSquareDown } from '@fortawesome/free-solid-svg-icons';
import { useDrop } from 'react-dnd';
import { faCaretSquareRight, faCaretSquareDown, faCaretSquareLeft } from '@fortawesome/free-solid-svg-icons';
import { DragItemTypes } from '../../utils/DragItemTypes';

export default function MenuItem({
Expand All @@ -23,7 +23,6 @@ export default function MenuItem({
}) {
const MenuItemComponent = (selected) ? MenuItemSelected : MenuItemNormal;
const [v, setVis] = useState(visible )
const [id, setId] = useState( )
const handleClick = () => {
setVis(!v)
}
Expand All @@ -32,7 +31,7 @@ export default function MenuItem({
accept: DragItemTypes.NOTE,
drop: (data) => {
cacheParentId()
return { name: id}
return { name: noteId}
},
collect: (monitor) => {
return {
Expand All @@ -41,15 +40,17 @@ export default function MenuItem({
}
},
})
// const isActive = canDrop && isOver
// let style = {}
// if (isActive) {
// style.backgroundColor = 'darkgreen'
// } else if (canDrop && droppable) {
// style.backgroundColor = 'darkkhaki'
// }
const isActive = canDrop && isOver && droppable
let style = {};
if (isActive) {
style.backgroundColor = '#292d4e';
// style.border= '1px solid white';
} else if (canDrop && droppable) {
// style.backgroundColor = 'blue'
}
return (
<MenuItemComponent
style={style}
ref={drop}
>
<MenuItemStyle
Expand All @@ -63,7 +64,7 @@ export default function MenuItem({
icon={v ? faCaretSquareDown : faCaretSquareRight}
/>}</MenuItemIcon>}
<MenuItemLabel>{label}</MenuItemLabel>
{right}
{ right }
</MenuItemStyle>
{v ? children : <></>}
</MenuItemComponent>
Expand Down
7 changes: 6 additions & 1 deletion app/components/MiddleMenu/MiddleMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ export default function MiddleMenu({
note={i}
selected={i._id === selectedNote}
handleClick={selectNoteAction}
handleDrag={(id) => moveNote(id, dropNoteCache)}
handleDrag={(id) => {
if (dropNoteCache != "ALL" && dropNoteCache != "TRASH" && dropNoteCache != "FAV") {
moveNote(id, dropNoteCache)
}
}
}
handlers={notecardContextHandlers}
/>
))
Expand Down
2 changes: 1 addition & 1 deletion app/components/MiddleMenu/NoteCard/NoteCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Truncate from 'react-truncate'
import { Tag } from 'antd';
import Moment from 'react-moment';
import styled from 'styled-components';
import { useDrag } from 'react-dnd'
import { useDrag } from 'react-dnd';
import {
ContextMenu,
ContextMenuTrigger,
Expand Down
5 changes: 3 additions & 2 deletions app/containers/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { hot } from 'react-hot-loader/root';
import { History } from 'history';
import { ThemeProvider } from 'styled-components';
import { Store } from '../reducers/types';

import Routes from '../Routes';
import darkTheme from '../utils/dark_theme.json';
import { DndProvider } from 'react-dnd'
import { HTML5Backend } from 'react-dnd-html5-backend'
import { DndProvider } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
type Props = {
store: Store;
history: History;
Expand Down
4 changes: 2 additions & 2 deletions app/reducers/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const notesReducer = createReducer(initialState, {
[CREATE_NOTE]: (state, action) => {
const noteId = action.id

const newState = addChildToParent(newState, action.id, action.parent)
const newState = addChildToParent(state, action.id, action.parent)
const newNote = {_id: noteId,
title: "",
createdAt: Date.now(),
Expand Down Expand Up @@ -54,7 +54,7 @@ const notesReducer = createReducer(initialState, {
[UPDATE_NOTE]: (state, action) => {
console.log(action)

return updateNoteAttributesInArray(newState, action.id, action.attributes)
return updateNoteAttributesInArray(state, action.id, action.attributes)

},
[MOVE_NOTE]: (state, action) => {
Expand Down
2 changes: 2 additions & 0 deletions app/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ export const hasChildren = ( children ) => {
return false;
}
}

// Immutable state updaters for Notes
export const updateNoteAttributesInArray = (state, noteId, attributes) => {
return state.map((item, id) => {
if (item._id !== noteId) { return item }
Expand Down

0 comments on commit 3fe4570

Please sign in to comment.