From 6fcd0d8d6fb1471b8af460f6d80bdf0d0e681566 Mon Sep 17 00:00:00 2001
From: Fawn <fangrui_tong@brown.edu>
Date: Tue, 18 Jun 2019 15:17:27 -0400
Subject: added button to delete a link

---
 src/client/views/nodes/LinkEditor.tsx | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

(limited to 'src/client/views/nodes/LinkEditor.tsx')

diff --git a/src/client/views/nodes/LinkEditor.tsx b/src/client/views/nodes/LinkEditor.tsx
index 484682c22..29ead7388 100644
--- a/src/client/views/nodes/LinkEditor.tsx
+++ b/src/client/views/nodes/LinkEditor.tsx
@@ -7,14 +7,12 @@ import { Doc } from "../../../new_fields/Doc";
 import { LinkManager } from "../../util/LinkManager";
 import { Docs } from "../../documents/Documents";
 import { Utils } from "../../../Utils";
-import { faArrowLeft, faEllipsisV, faTable } from '@fortawesome/free-solid-svg-icons';
+import { faArrowLeft, faEllipsisV, faTable, faTrash } from '@fortawesome/free-solid-svg-icons';
 import { library } from "@fortawesome/fontawesome-svg-core";
 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 import { SetupDrag } from "../../util/DragManager";
 
-library.add(faArrowLeft);
-library.add(faEllipsisV);
-library.add(faTable);
+library.add(faArrowLeft, faEllipsisV, faTable, faTrash);
 
 
 interface GroupTypesDropdownProps {
@@ -162,6 +160,13 @@ export class LinkEditor extends React.Component<LinkEditorProps> {
         this._groups = groups;
     }
 
+    @action
+    deleteLink = (): void => {
+        let index = LinkManager.Instance.allLinks.indexOf(this.props.linkDoc);
+        LinkManager.Instance.allLinks.splice(index, 1);
+        this.props.showLinks();
+    }
+
     @action
     addGroup = (): void => {
         // new group only gets added if there is not already a group with type "new group"
@@ -324,7 +329,10 @@ export class LinkEditor extends React.Component<LinkEditorProps> {
         return (
             <div className="linkEditor">
                 <button className="linkEditor-back" onPointerDown={() => this.props.showLinks()}><FontAwesomeIcon icon="arrow-left" size="sm" /></button>
-                <p className="linkEditor-linkedTo">editing link to: <b>{destination.proto!.title}</b></p>
+                <div className="linkEditor-info">
+                    <p className="linkEditor-linkedTo">editing link to: <b>{destination.proto!.title}</b></p>
+                    <button className="linkEditor-delete" onPointerDown={() => this.deleteLink()} title="Delete link"><FontAwesomeIcon icon="trash" size="sm" /></button>
+                </div>
                 <div className="linkEditor-groupsLabel">
                     <b>Relationships:</b>
                     <button onClick={() => this.addGroup()} title="Add Group">+</button>
-- 
cgit v1.2.3-70-g09d2

