Skip to content

Commit 0217ed9

Browse files
authored
Merge pull request #123 from parteekcoder/flash_msg
Flash msg
2 parents 323e8ee + d877cb8 commit 0217ed9

5 files changed

Lines changed: 50 additions & 8 deletions

File tree

package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"react-modal": "^3.13.1",
3232
"react-scripts": "4.0.3",
3333
"react-simple-code-editor": "^0.13.0",
34+
"react-toastify": "^8.0.0",
3435
"react-tooltip": "^4.2.21",
3536
"web-vitals": "^0.2.4",
3637
"workbox-background-sync": "^5.1.3",

src/App.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React, { useEffect, useReducer } from 'react';
2+
import { ToastContainer } from 'react-toastify';
3+
import 'react-toastify/dist/ReactToastify.css';
24
import './App.css';
35
import ReactTooltip from 'react-tooltip';
46
import GraphWorkspace from './GraphWorkspace';
@@ -47,6 +49,7 @@ const app = () => {
4749
</div>
4850
</section>
4951
<ReactTooltip place="bottom" type="dark" effect="solid" />
52+
<ToastContainer position="top-right" autoClose={5000} pauseOnHover={false} />
5053
</div>
5154
);
5255
};

src/graph-builder/graph-core/5-load-save.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { saveAs } from 'file-saver';
2+
import { toast } from 'react-toastify';
23
import localStorageManager from '../local-storage-manager';
34
import graphmlBuilder from '../graphml/builder';
45
import BendingDistanceWeight from '../calculations/bending-dist-weight';
@@ -125,9 +126,15 @@ class GraphLoadSave extends GraphUndoRedo {
125126
const fileName = prompt('Filename:');
126127
saveAs(blob, `${fileName || `${this.getName()}-concore`}.graphml`);
127128
}
129+
toast.success('File saved Successfully');
128130
}
129131

130132
async saveWithoutFileHandle() {
133+
const { userAgent } = navigator;
134+
if (userAgent.match(/firefox|fxios/i)) {
135+
toast.info('Switch to Edge/Chrome!');
136+
return;
137+
}
131138
const str = graphmlBuilder(this.jsonifyGraph());
132139
const bytes = new TextEncoder().encode(str);
133140
const blob = new Blob([bytes], { type: 'application/json;charset=utf-8' });
@@ -149,8 +156,7 @@ class GraphLoadSave extends GraphUndoRedo {
149156
const stream = await handle.createWritable();
150157
await stream.write(blob);
151158
await stream.close();
152-
// eslint-disable-next-line no-alert
153-
alert('File saved Successfully');
159+
toast.success('File saved Successfully');
154160
}
155161

156162
saveToFolder() {

src/toolbarActions/toolbarFunctions.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { toast } from 'react-toastify';
12
import { actionType as T } from '../reducer';
23

34
const getGraphFun = (superState) => superState.curGraphInstance;
@@ -88,17 +89,14 @@ async function saveGraphMLFile(state) {
8889
const stream = await graph.fileHandle.createWritable();
8990
await stream.write(getGraphFun(state).saveToFolder());
9091
await stream.close();
91-
// eslint-disable-next-line no-alert
92-
alert('File saved Successfully');
92+
toast.success('File saved Successfully');
9393
} else if (graph.fileHandle === null) {
9494
getGraphFun(state).saveWithoutFileHandle();
9595
} else {
96-
// eslint-disable-next-line no-alert
97-
alert('Switch to Edge/Chrome!');
96+
toast.info('Switch to Edge/Chrome!');
9897
}
9998
} else {
100-
// eslint-disable-next-line no-alert
101-
alert('Switch to Edge/Chrome!');
99+
toast.info('Switch to Edge/Chrome!');
102100
}
103101
}
104102

0 commit comments

Comments
 (0)