-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEntryOverviewItem.js
More file actions
116 lines (109 loc) · 3.97 KB
/
EntryOverviewItem.js
File metadata and controls
116 lines (109 loc) · 3.97 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
112
113
114
115
116
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { observer } from 'mobx-react';
import {
EntryItem,
EntryItemTime,
EntryItemActions,
EntryItemWBSO,
} from 'component/EntryList';
import SimpleDuration from 'component/SimpleDuration';
import Icon from 'component/Icon';
import { ProjectStore } from 'store/Project';
import { UserStore } from 'store/User';
import { Entry } from 'store/Entry';
import View from 'store/View';
import IconDelete from 'image/icon-delete.svg';
import IconCopy from 'image/icon-copy.svg';
import IconTicketLink from 'image/icon-ticket-link.svg';
import EntryDescription from 'component/Entry/Description';
import EntryProject from 'component/Entry/Project';
import EntryTicket from 'component/Entry/Ticket';
import EntryStartTime from 'component/Entry/StartTime';
import EntryEndTime from 'component/Entry/EndTime';
import EntryWBSO from 'component/Entry/WBSO';
@observer
export default class EntryOverviewItem extends Component {
static propTypes = {
entry: PropTypes.instanceOf(Entry).isRequired,
onCopy: PropTypes.func.isRequired,
projectStore: PropTypes.instanceOf(ProjectStore).isRequired,
userStore: PropTypes.instanceOf(UserStore),
viewStore: PropTypes.instanceOf(View).isRequired,
allowEdit: PropTypes.bool,
};
handleCopy = () => {
const { onCopy, entry } = this.props;
if (onCopy) {
onCopy(entry);
}
};
handleDelete = () => {
if (!window.confirm('Are you sure you want to delete this?')) {
return;
}
this.props.entry.delete();
};
render() {
const { entry, allowEdit, projectStore, viewStore } = this.props;
const diffMinutes = entry.differenceInMinutes;
const wbso = entry.wbso;
const ticketLink = this.props.entry.ticket
? 'https://phabricator.codeyellow.nl/T' + this.props.entry.ticket
: null;
let userColumn = null;
if (this.props.userStore) {
const user = entry.user
? this.props.userStore.get(entry.user)
: null;
userColumn = <EntryItemTime>{user.displayName}</EntryItemTime>;
}
const ticketLinkStyle = {
visibility: ticketLink ? 'visible' : 'hidden',
};
return (
<EntryItem>
<EntryProject
entry={entry}
projectStore={projectStore}
allowEdit={allowEdit}
viewStore={viewStore}
/>
<EntryItemActions>
<a
href={ticketLink}
target="_blank"
style={ticketLinkStyle}
>
<Icon icon={IconTicketLink} />
</a>
</EntryItemActions>
<EntryTicket entry={entry} allowEdit={allowEdit} />
<EntryDescription entry={entry} allowEdit={allowEdit} />
<EntryStartTime
entry={entry}
allowEdit={allowEdit}
viewStore={this.props.viewStore}
/>
<div>—</div>
<EntryEndTime
entry={entry}
allowEdit={allowEdit}
viewStore={this.props.viewStore}
/>
<EntryItemTime>
<SimpleDuration minutes={diffMinutes} />
</EntryItemTime>
{userColumn}
<EntryWBSO entry={entry} allowEdit={allowEdit} />
<EntryItemWBSO />
<EntryItemActions>
<Icon onClick={this.handleCopy} icon={IconCopy} />
{allowEdit
? <Icon onClick={this.handleDelete} icon={IconDelete} />
: null}
</EntryItemActions>
</EntryItem>
);
}
}