favorite dialog

This commit is contained in:
Jan Prochazka
2020-12-12 20:02:55 +01:00
parent 1e447a8937
commit 0c0c0356a6
3 changed files with 141 additions and 21 deletions

View File

@@ -17,6 +17,7 @@ import useOpenNewTab from '../utility/useOpenNewTab';
import axios from '../utility/axios';
import tabs from '../tabs';
import uuidv1 from 'uuid/v1';
import FavoriteModal from '../modals/FavoriteModal';
const ToolbarContainer = styled.div`
display: flex;
@@ -82,28 +83,29 @@ export default function ToolBar({ toolbarPortalRef }) {
};
const addToFavorite = () => {
const tabdata = {};
showModal((modalState) => <FavoriteModal modalState={modalState} savingTab={currentTab} />);
// const tabdata = {};
const re = new RegExp(`tabdata_(.*)_${currentTab.tabid}`);
for (const key in localStorage) {
const match = key.match(re);
if (!match) continue;
if (match[1] == 'editor') continue;
tabdata[match[1]] = JSON.parse(localStorage.getItem(key));
}
// const re = new RegExp(`tabdata_(.*)_${currentTab.tabid}`);
// for (const key in localStorage) {
// const match = key.match(re);
// if (!match) continue;
// if (match[1] == 'editor') continue;
// tabdata[match[1]] = JSON.parse(localStorage.getItem(key));
// }
axios.post('files/save', {
folder: 'favorites',
file: uuidv1(),
format: 'json',
data: {
title: currentTab.title,
icon: currentTab.icon,
props: currentTab.props,
tabComponent: currentTab.tabComponent,
tabdata,
},
});
// axios.post('files/save', {
// folder: 'favorites',
// file: uuidv1(),
// format: 'json',
// data: {
// title: currentTab.title,
// icon: currentTab.icon,
// props: currentTab.props,
// tabComponent: currentTab.tabComponent,
// tabdata,
// },
// });
};
function openTabFromButton(page) {