openNewTab refactor

This commit is contained in:
Jan Prochazka
2020-12-12 09:07:14 +01:00
parent f7bab744e6
commit 0857757ce2
15 changed files with 83 additions and 80 deletions

View File

@@ -1,19 +1,18 @@
import React from 'react';
import { useCurrentDatabase, useSetOpenedTabs } from '../utility/globalState';
import { openNewTab } from '../utility/common';
import axios from '../utility/axios';
import useTheme from '../theme/useTheme';
import { StyledThemedLink } from '../widgets/FormStyledButton';
import useOpenNewTab from '../utility/useOpenNewTab';
export default function OpenChartLink({ file, children }) {
const setOpenedTabs = useSetOpenedTabs();
const openNewTab = useOpenNewTab();
const currentDb = useCurrentDatabase();
const theme = useTheme();
const handleClick = async () => {
const resp = await axios.post('files/load', { folder: 'charts', file, format: 'json' });
openNewTab(
setOpenedTabs,
{
title: file,
icon: 'img chart',