forked from qiime2/q2studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Artifacts.jsx
62 lines (57 loc) · 2.41 KB
/
Artifacts.jsx
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
// ----------------------------------------------------------------------------
// Copyright (c) 2016-2021, QIIME 2 development team.
//
// Distributed under the terms of the Modified BSD License.
//
// The full license is in the file LICENSE, distributed with this software.
// ----------------------------------------------------------------------------
import React from 'react';
import { ipcRenderer as ipc } from 'electron';
import Artifact from './Artifact';
import ArtifactGenerator from '../containers/ArtifactGenerator';
const Artifacts = ({ data, type, dispatchDeleteArtifact, dispatchDeleteVisualization }) => (
<div>
<table className="table">
<thead>
<tr>
<th className="col-xs-3">Name</th>
<th className="col-xs-5">UUID</th>
<th className="col-xs-2">Type</th>
<th className="col-xs-2" />
</tr>
</thead>
<tbody>
{data.length ? (
data.map(item => (
<Artifact
key={item.uuid}
data={item}
onClick={() => ipc.send('open-new-page', {
url: `artifact/${item.uuid}`
})}
deleteThis={() => {
if (confirm('Are you sure you want to delete this Artifact?')) {
if (type === 'artifact') {
dispatchDeleteArtifact(item.uuid);
} else if (type === 'visualization') {
dispatchDeleteVisualization(item.uuid);
} else {
throw Error(`Unkown type '${type}'`);
}
}
}}
/>
))) : (<tr><td>{`No available ${type}s...`}</td></tr>)
}
</tbody>
</table>
{ type === 'artifact' ? <ArtifactGenerator /> : null }
</div>
);
Artifacts.propTypes = {
data: React.PropTypes.array,
type: React.PropTypes.string,
dispatchDeleteArtifact: React.PropTypes.func,
dispatchDeleteVisualization: React.PropTypes.func
};
export default Artifacts;