fix: add delete permanently option, restore icon and show alerts for locked notes

This commit is contained in:
Antonella Sgarlatta
2021-05-07 15:56:35 -03:00
parent 9906cd2a20
commit 02249ebaca
9 changed files with 138 additions and 25 deletions

View File

@@ -7,6 +7,8 @@ import ArchiveIcon from '../../icons/ic-archive.svg';
import UnarchiveIcon from '../../icons/ic-unarchive.svg';
import HashtagIcon from '../../icons/ic-hashtag.svg';
import ChevronRightIcon from '../../icons/ic-chevron-right.svg';
import RestoreIcon from '../../icons/ic-restore.svg';
import CloseIcon from '../../icons/ic-close.svg';
import { toDirective } from './utils';
export enum IconType {
@@ -19,6 +21,8 @@ export enum IconType {
Unarchive = 'unarchive',
Hashtag = 'hashtag',
ChevronRight = 'chevron-right',
Restore = 'restore',
Close = 'close',
}
const ICONS = {
@@ -31,6 +35,8 @@ const ICONS = {
[IconType.Unarchive]: UnarchiveIcon,
[IconType.Hashtag]: HashtagIcon,
[IconType.ChevronRight]: ChevronRightIcon,
[IconType.Restore]: RestoreIcon,
[IconType.Close]: CloseIcon,
};
type Props = {

View File

@@ -44,8 +44,8 @@ export const NotesOptions = observer(
useEffect(() => {
const openTrashAlert = async () => {
if (shouldTrashNotes && blurLocked) {
await appState.notes.setTrashSelectedNotes(!trashed, trashButtonRef);
setShouldTrashNotes(false);
await appState.notes.setTrashSelectedNotes(!trashed, trashButtonRef);
setLockCloseOnBlur(false);
}
};
@@ -190,9 +190,23 @@ export const NotesOptions = observer(
setLockCloseOnBlur(true);
}}
>
<Icon type={IconType.Trash} className={iconClass} />
<Icon type={trashed ? IconType.Restore : IconType.Trash} className={iconClass} />
{trashed ? 'Restore' : 'Move to Trash'}
</button>
{appState.selectedTag?.isTrashTag && (
<button
onBlur={closeOnBlur}
className={`${buttonClass} py-1.5`}
onClick={async () => {
setLockCloseOnBlur(true);
await appState.notes.deleteNotesPermanently();
setLockCloseOnBlur(false);
}}
>
<Icon type={IconType.Close} className="fill-current color-danger mr-2" />
<span className="color-danger">Delete Permanently</span>
</button>
)}
</>
);
}