Skip to content

Commit 2206419

Browse files
author
vikasrohit
authored
Merge pull request #3810 from appirio-tech/feature/link-attachments
Links as Attachments + Tags
2 parents 805f754 + dfe536c commit 2206419

File tree

19 files changed

+492
-157
lines changed

19 files changed

+492
-157
lines changed

src/api/projectAttachments.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@ import { axiosInstance as axios } from './requestInterceptor'
22
import { PROJECTS_API_URL, FILE_PICKER_SUBMISSION_CONTAINER_NAME } from '../config/constants'
33

44
export function addProjectAttachment(projectId, fileData) {
5-
// add s3 bucket prop
6-
fileData.s3Bucket = FILE_PICKER_SUBMISSION_CONTAINER_NAME
5+
6+
if (fileData.type === 'file') {
7+
// add s3 bucket prop
8+
fileData.s3Bucket = FILE_PICKER_SUBMISSION_CONTAINER_NAME
9+
}
10+
11+
// The api takes only arrays
12+
if (!fileData.tags) {
13+
fileData.tags = []
14+
}
15+
716
return axios.post(`${PROJECTS_API_URL}/v5/projects/${projectId}/attachments`, fileData)
817
.then( resp => {
918
resp.data.downloadUrl = `/projects/${projectId}/attachments/${resp.data.id}`
@@ -19,6 +28,14 @@ export function updateProjectAttachment(projectId, attachmentId, attachment) {
1928
}
2029
}
2130

31+
// The api takes only arrays
32+
if (attachment && !attachment.tags) {
33+
attachment = {
34+
...attachment,
35+
tags: []
36+
}
37+
}
38+
2239
return axios.patch(
2340
`${PROJECTS_API_URL}/v5/projects/${projectId}/attachments/${attachmentId}`, attachment)
2441
.then ( resp => {

src/components/AssetsLibrary/AddLink.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const TCFormFields = FormsyForm.Fields
77
const Formsy = FormsyForm.Formsy
88

99
import './AddLink.scss'
10+
import { TagSelect } from '../TagSelect/TagSelect'
1011

1112
class AddLink extends React.Component {
1213
constructor(props) {
@@ -75,6 +76,14 @@ class AddLink extends React.Component {
7576
}}
7677
wrapperClass="form-group"
7778
/>
79+
<div className="form-group">
80+
<label className="tc-label">Tags</label>
81+
<TagSelect
82+
useFormsySelect
83+
name="tags"
84+
/>
85+
</div>
86+
7887
<div className="button-area center-buttons">
7988
<button className="tc-btn tc-btn-primary tc-btn-sm" type="submit" disabled={!canSubmit}>
8089
Add Link

src/components/AssetsLibrary/FilesGridView.jsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const FilesGridView = ({
4040
onEditIntent,
4141
title,
4242
selectedUsers,
43+
selectedTags,
4344
onAddAttachment,
4445
assetsMembers,
4546
isSharingAttachment,
@@ -106,12 +107,13 @@ const FilesGridView = ({
106107
}
107108
}
108109

109-
const onAddingAttachmentPermissions = (allowedUsers) => {
110+
const onAddingAttachmentPermissions = (allowedUsers, tags) => {
110111
const { attachments, projectId } = pendingAttachments
111112
_.forEach(attachments, f => {
112113
const attachment = {
113114
...f,
114-
allowedUsers
115+
allowedUsers,
116+
tags
115117
}
116118
onAddAttachment(projectId, attachment)
117119
})
@@ -195,6 +197,7 @@ const FilesGridView = ({
195197
onSubmit={onAddingAttachmentPermissions}
196198
onChange={onChangePermissions}
197199
selectedUsers={selectedUsers}
200+
selectedTags={selectedTags}
198201
projectMembers={projectMembers}
199202
loggedInUser={loggedInUser}
200203
isSharingAttachment={isSharingAttachment}
@@ -207,8 +210,9 @@ const FilesGridView = ({
207210
ref={(comp) => nameFieldRef = comp}
208211
title="Name"
209212
setFilter={setFilter}
210-
filterName="name"
211-
value={getFilterValue('name')}
213+
type="name"
214+
name={getFilterValue('name.name')}
215+
tag={getFilterValue('name.tag')}
212216
/>
213217
</div>
214218
<div styleName="flex-item-title item-shared-with">
@@ -241,8 +245,8 @@ const FilesGridView = ({
241245
const onDeleteCancel = () => onDeleteIntent(-1)
242246
const handleDeleteClick = () => onDeleteIntent(idx)
243247

244-
const onEditConfirm = (title, allowedUsers) => {
245-
onEdit(link.id, title, allowedUsers)
248+
const onEditConfirm = (title, allowedUsers, tags) => {
249+
onEdit(link, title, allowedUsers, tags)
246250
onEditIntent(-1)
247251
}
248252
const onEditCancel = () => onEditIntent(-1)
@@ -303,7 +307,14 @@ const FilesGridView = ({
303307
<div styleName="flex-item item-type">
304308
<FileIcon type={link.title.split('.')[1]} />
305309
</div>
306-
<div styleName="flex-item item-name"><p>{renderLink(link)}</p></div>
310+
<div styleName="flex-item item-name">
311+
<div styleName="item-name-tag-wrapper">
312+
<p>{renderLink(link)}</p>
313+
{
314+
link.tags && link.tags.map((t, i) => <span styleName="tag" key={i}>{t}</span>)
315+
}
316+
</div>
317+
</div>
307318
<div styleName="flex-item item-shared-with">
308319
{renderSharedWith(link)}
309320
</div>
@@ -338,6 +349,7 @@ FilesGridView.propTypes = {
338349
canEdit: PropTypes.bool,
339350
links: PropTypes.array.isRequired,
340351
selectedUsers: PropTypes.string,
352+
selectedTags: PropTypes.arrayOf(PropTypes.string),
341353
projectMembers: PropTypes.object,
342354
pendingAttachments: PropTypes.object,
343355
onUploadAttachment: PropTypes.func,

src/components/AssetsLibrary/FilterColHeader.jsx

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,25 @@ const Formsy = FormsyForm.Formsy
99
const TCFormFields = FormsyForm.Fields
1010

1111
class FilterColHeader extends React.Component {
12-
12+
1313
constructor(props) {
1414
super(props)
15-
this.state = {value: '', from: '', to: ''}
15+
this.state = {value: '', from: '', to: '', name: '', tag: ''}
1616
this.setFilter = this.setFilter.bind(this)
1717
this.onChange = this.onChange.bind(this)
1818
this.onFromDateChange = this.onFromDateChange.bind(this)
1919
this.onToDateChange = this.onToDateChange.bind(this)
20+
this.onNameChange = this.onNameChange.bind(this)
21+
this.onTagChange = this.onTagChange.bind(this)
2022
}
21-
23+
2224
setFilter(newfilter) {
2325
this.props.setFilter(this.props.filterName, newfilter)
2426
}
25-
27+
2628
onChange(event) {
2729
this.setState({value: event.target.value})
28-
30+
2931
setTimeout(() => {
3032
this.setFilter(this.state.value)
3133
})
@@ -39,36 +41,56 @@ class FilterColHeader extends React.Component {
3941

4042
onFromDateChange(name, value) {
4143
this.setState({from: value})
42-
44+
4345
setTimeout(() => {
4446
this.props.setFilter('date.from', this.state.from)
4547
})
4648
}
47-
49+
4850
onToDateChange(name, value) {
4951
this.setState({to: value})
50-
52+
5153
setTimeout(() => {
5254
this.props.setFilter('date.to', this.state.to)
5355
})
5456
}
55-
57+
58+
onNameChange(name, value) {
59+
this.setState({ name: value})
60+
61+
setTimeout(() => {
62+
this.props.setFilter('name.name', this.state.name)
63+
})
64+
}
65+
66+
onTagChange(name, value) {
67+
this.setState({tag: value})
68+
69+
setTimeout(() => {
70+
this.props.setFilter('name.tag', this.state.tag)
71+
})
72+
}
73+
5674
componentDidMount() {
5775
this.setState({
5876
value: this.props.value || '',
5977
from: this.props.from || '',
60-
to: this.props.to || ''
78+
to: this.props.to || '',
79+
name: this.props.name || '',
80+
tag: this.props.tag || ''
6181
})
6282
}
63-
83+
6484
clearFilter() {
6585
this.setState({
6686
value: '',
6787
from: '',
68-
to: ''
88+
to: '',
89+
name: '',
90+
tag: ''
6991
})
7092
}
71-
93+
7294
renderByType() {
7395
switch (this.props.type) {
7496
case 'date': {
@@ -93,7 +115,30 @@ class FilterColHeader extends React.Component {
93115
</Formsy.Form>
94116
)
95117
}
96-
118+
119+
case 'name': {
120+
return (
121+
<Formsy.Form>
122+
<TCFormFields.TextInput
123+
inputRef={(input) => { this.textInputFilter = input }}
124+
label="Name"
125+
type="text"
126+
name="name.name"
127+
onChange={this.onNameChange}
128+
value={this.state.name}
129+
/>
130+
131+
<TCFormFields.TextInput
132+
label="Tag"
133+
type="text"
134+
name="name.tag"
135+
onChange={this.onTagChange}
136+
value={this.state.tag}
137+
/>
138+
</Formsy.Form>
139+
)
140+
}
141+
97142
default: {
98143
return (
99144
<input
@@ -108,12 +153,12 @@ class FilterColHeader extends React.Component {
108153
}
109154
}
110155
}
111-
156+
112157
render() {
113158
const {
114159
title,
115160
} = this.props
116-
161+
117162
return (
118163
<div styleName="FilterColHeader">
119164
<Dropdown className="filter-drop-down" noAutoclose>

src/components/AssetsLibrary/GridView.scss

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,14 @@
6565
-ms-flex: none;
6666
flex: none;
6767
width: 60px;
68+
line-height: 30px;
69+
align-items: flex-start;
6870

6971
svg, img {
7072
height: 30px;
7173
width: 30px;
7274
margin-left: 4px;
75+
margin-top: 8px;
7376
}
7477
}
7578

@@ -82,6 +85,8 @@
8285
line-height: 30px;
8386
min-width: 0;
8487
text-align: left;
88+
align-items: flex-start;
89+
padding-right: 4px;
8590

8691
> p {
8792
overflow: hidden;
@@ -90,10 +95,16 @@
9095
}
9196
}
9297

98+
.item-name-tag-wrapper {
99+
overflow: hidden;
100+
}
101+
93102
.item-shared-with {
94103
flex: none;
95104
width: 140px;
96105
word-break: keep-all;
106+
align-items: flex-start;
107+
line-height: 30px;
97108
}
98109

99110
.item-modified, .item-created-by {
@@ -114,6 +125,7 @@
114125
width: 50px;
115126
justify-content: flex-end;
116127
padding-right: 4px;
128+
align-items: flex-start;
117129
}
118130

119131
.item-action .link-buttons {
@@ -145,6 +157,24 @@
145157
position: relative;
146158
}
147159

160+
.tag {
161+
@include roboto-medium;
162+
background-color: $tc-gray-10;
163+
border-radius: 4px;
164+
color: $tc-gray-50;
165+
font-size: 13px;
166+
height: 20px;
167+
line-height: 20px;
168+
padding: 0 2 * $base-unit;
169+
margin-top: $base-unit;
170+
margin-right: $base-unit;
171+
white-space: nowrap;
172+
overflow: hidden;
173+
text-overflow: ellipsis;
174+
max-width: 100%;
175+
display: inline-block;
176+
}
177+
148178
:global {
149179
.user-block .tooltip-container {
150180
text-align: left;

0 commit comments

Comments
 (0)