-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathSideBar.js
More file actions
111 lines (104 loc) · 3.25 KB
/
SideBar.js
File metadata and controls
111 lines (104 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import React, { Suspense } from 'react';
import { Tabs } from 'antd';
import { Skeleton, Alert } from 'antd';
import { Copy } from 'components/topBar/controls/Copy';
const Code = React.lazy(() => import(/* webpackChunkName: "code" */ './Code'));
const DependenciesTab = React.lazy(() =>
import(/* webpackChunkName: "dependencies-tab" */ './DependenciesTab')
);
const CrumbsTab = React.lazy(() => import(/* webpackChunkName: "crumbs-tab" */ './CrumbsTab'));
const FlowChartTab = React.lazy(() =>
import(/* webpackChunkName: "flow-chart-tab" */ './FlowChartTab')
);
import './SideBar.scss';
const TabPane = Tabs.TabPane;
//TODO: Add slide from right animation
export default ({
namespace,
language,
selectedNode,
filesMap,
onClose,
selectedTabInSideBar,
dependenciesDiagramOn,
codeCrumbsDiagramOn,
fullFeaturesSupport,
onTabSelect
}) => {
const file = selectedNode && filesMap[selectedNode.path];
const standaloneNoCode = process.env.STANDALONE && (!file || !file.fileCode);
const header = standaloneNoCode ? (
<Alert
message="No code for this file in standalone mode."
description="Only files with codecrumbs have pre-fetched code. Consider to run codecrumbs locally for this project to access all code. Check instructions here https://github.com/Bogdan-Lyashenko/codecrumbs"
type="warning"
showIcon
/>
) : (
<React.Fragment>
<div>{file.path}</div>
<div className={'copyIcon'}>
<Copy copyText={file.path} />
</div>
</React.Fragment>
);
const content = (
<Tabs defaultActiveKey={selectedTabInSideBar} onChange={onTabSelect}>
<TabPane tab="Code" key="Code">
<Suspense fallback={null}>
{standaloneNoCode ? (
<Skeleton />
) : (
<Code
crumbedLines={codeCrumbsDiagramOn ? file.children.map(({ crumbNodeLines }) => crumbNodeLines) : []}
namespace={namespace}
language={language}
code={file.fileCode}
/>
)}
</Suspense>
</TabPane>
{(dependenciesDiagramOn &&
fullFeaturesSupport && (
<TabPane tab="Dependencies" key="Dependencies">
<Suspense fallback={null}>
<DependenciesTab namespace={namespace} language={language} />
</Suspense>
</TabPane>
)) ||
null}
{(codeCrumbsDiagramOn && (
<TabPane tab="Crumbs" key="Crumbs">
<Suspense fallback={null}>
<CrumbsTab namespace={namespace} language={language} />
</Suspense>
</TabPane>
)) ||
null}
{(fullFeaturesSupport && (
<TabPane tab="FlowChart" key="FlowChart">
<Suspense fallback={null}>
<FlowChartTab
namespace={namespace}
language={language}
fileCode={file.fileCode}
active={selectedTabInSideBar === 'FlowChart'}
/>
</Suspense>
</TabPane>
)) ||
null}
</Tabs>
);
return (
<div className="SideBar">
<div className="header">
<div className={'filePath'}>{header}</div>
<a href="#" onClick={onClose}>
X
</a>
</div>
<div className="bodySideBar">{content}</div>
</div>
);
};