diff options
author | 2022-11-17 05:45:39 +0530 | |
---|---|---|
committer | 2022-11-17 00:15:39 +0000 | |
commit | d9502c7516bc2d4ae467c6ea8a2e4816b0885f37 (patch) | |
tree | b339c587a5529ac26d52cfc12d9972a8a00255e6 /src/features/workspaces/components/WorkspaceDrawerItem.js | |
parent | Transform JSX components to TSX (#755) (diff) | |
download | ferdium-app-d9502c7516bc2d4ae467c6ea8a2e4816b0885f37.tar.gz ferdium-app-d9502c7516bc2d4ae467c6ea8a2e4816b0885f37.tar.zst ferdium-app-d9502c7516bc2d4ae467c6ea8a2e4816b0885f37.zip |
Transfrom workspace components to ts (#775)
Diffstat (limited to 'src/features/workspaces/components/WorkspaceDrawerItem.js')
-rw-r--r-- | src/features/workspaces/components/WorkspaceDrawerItem.js | 153 |
1 files changed, 0 insertions, 153 deletions
diff --git a/src/features/workspaces/components/WorkspaceDrawerItem.js b/src/features/workspaces/components/WorkspaceDrawerItem.js deleted file mode 100644 index 22c0a39d9..000000000 --- a/src/features/workspaces/components/WorkspaceDrawerItem.js +++ /dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | import { Menu } from '@electron/remote'; | ||
2 | import { Component } from 'react'; | ||
3 | import PropTypes from 'prop-types'; | ||
4 | import { observer } from 'mobx-react'; | ||
5 | import injectSheet from 'react-jss'; | ||
6 | import classnames from 'classnames'; | ||
7 | import { defineMessages, injectIntl } from 'react-intl'; | ||
8 | import { altKey, cmdOrCtrlShortcutKey } from '../../../environment'; | ||
9 | |||
10 | const messages = defineMessages({ | ||
11 | noServicesAddedYet: { | ||
12 | id: 'workspaceDrawer.item.noServicesAddedYet', | ||
13 | defaultMessage: 'No services added yet', | ||
14 | }, | ||
15 | contextMenuEdit: { | ||
16 | id: 'workspaceDrawer.item.contextMenuEdit', | ||
17 | defaultMessage: 'edit', | ||
18 | }, | ||
19 | }); | ||
20 | |||
21 | let itemTransition = 'none'; | ||
22 | |||
23 | if (window && window.matchMedia('(prefers-reduced-motion: no-preference)')) { | ||
24 | itemTransition = 'background-color 300ms ease-out'; | ||
25 | } | ||
26 | |||
27 | const styles = theme => ({ | ||
28 | item: { | ||
29 | height: '67px', | ||
30 | padding: `15px ${theme.workspaces.drawer.padding}px`, | ||
31 | borderBottom: `1px solid ${theme.workspaces.drawer.listItem.border}`, | ||
32 | transition: itemTransition, | ||
33 | '&:first-child': { | ||
34 | borderTop: `1px solid ${theme.workspaces.drawer.listItem.border}`, | ||
35 | }, | ||
36 | '&:hover': { | ||
37 | backgroundColor: theme.workspaces.drawer.listItem.hoverBackground, | ||
38 | }, | ||
39 | }, | ||
40 | isActiveItem: { | ||
41 | backgroundColor: theme.workspaces.drawer.listItem.activeBackground, | ||
42 | '&:hover': { | ||
43 | backgroundColor: theme.workspaces.drawer.listItem.activeBackground, | ||
44 | }, | ||
45 | }, | ||
46 | name: { | ||
47 | marginTop: '4px', | ||
48 | color: theme.workspaces.drawer.listItem.name.color, | ||
49 | }, | ||
50 | activeName: { | ||
51 | color: theme.workspaces.drawer.listItem.name.activeColor, | ||
52 | }, | ||
53 | services: { | ||
54 | display: 'block', | ||
55 | fontSize: '11px', | ||
56 | marginTop: '5px', | ||
57 | color: theme.workspaces.drawer.listItem.services.color, | ||
58 | whiteSpace: 'nowrap', | ||
59 | textOverflow: 'ellipsis', | ||
60 | overflow: 'hidden', | ||
61 | lineHeight: '15px', | ||
62 | }, | ||
63 | activeServices: { | ||
64 | color: theme.workspaces.drawer.listItem.services.active, | ||
65 | }, | ||
66 | }); | ||
67 | |||
68 | class WorkspaceDrawerItem extends Component { | ||
69 | static propTypes = { | ||
70 | classes: PropTypes.object.isRequired, | ||
71 | isActive: PropTypes.bool.isRequired, | ||
72 | name: PropTypes.string.isRequired, | ||
73 | onClick: PropTypes.func.isRequired, | ||
74 | services: PropTypes.arrayOf(PropTypes.string).isRequired, | ||
75 | onContextMenuEditClick: PropTypes.func, | ||
76 | shortcutIndex: PropTypes.number.isRequired, | ||
77 | }; | ||
78 | |||
79 | static defaultProps = { | ||
80 | onContextMenuEditClick: null, | ||
81 | }; | ||
82 | |||
83 | render() { | ||
84 | const { | ||
85 | classes, | ||
86 | isActive, | ||
87 | name, | ||
88 | onClick, | ||
89 | onContextMenuEditClick, | ||
90 | services, | ||
91 | shortcutIndex, | ||
92 | } = this.props; | ||
93 | |||
94 | const { intl } = this.props; | ||
95 | |||
96 | const contextMenuTemplate = [ | ||
97 | { | ||
98 | label: name, | ||
99 | enabled: false, | ||
100 | }, | ||
101 | { | ||
102 | type: 'separator', | ||
103 | }, | ||
104 | { | ||
105 | label: intl.formatMessage(messages.contextMenuEdit), | ||
106 | click: onContextMenuEditClick, | ||
107 | }, | ||
108 | ]; | ||
109 | |||
110 | const contextMenu = Menu.buildFromTemplate(contextMenuTemplate); | ||
111 | |||
112 | return ( | ||
113 | <div | ||
114 | className={classnames([ | ||
115 | classes.item, | ||
116 | isActive ? classes.isActiveItem : null, | ||
117 | ])} | ||
118 | onClick={onClick} | ||
119 | onContextMenu={() => onContextMenuEditClick && contextMenu.popup()} | ||
120 | data-tip={`${ | ||
121 | shortcutIndex <= 9 | ||
122 | ? `(${cmdOrCtrlShortcutKey(false)}+${altKey( | ||
123 | false, | ||
124 | )}+${shortcutIndex})` | ||
125 | : '' | ||
126 | }`} | ||
127 | > | ||
128 | <span | ||
129 | className={classnames([ | ||
130 | classes.name, | ||
131 | isActive ? classes.activeName : null, | ||
132 | ])} | ||
133 | > | ||
134 | {name} | ||
135 | </span> | ||
136 | <span | ||
137 | className={classnames([ | ||
138 | classes.services, | ||
139 | isActive ? classes.activeServices : null, | ||
140 | ])} | ||
141 | > | ||
142 | {services.length > 0 | ||
143 | ? services.join(', ') | ||
144 | : intl.formatMessage(messages.noServicesAddedYet)} | ||
145 | </span> | ||
146 | </div> | ||
147 | ); | ||
148 | } | ||
149 | } | ||
150 | |||
151 | export default injectIntl( | ||
152 | injectSheet(styles, { injectTheme: true })(observer(WorkspaceDrawerItem)), | ||
153 | ); | ||