Skip to content

Commit 8ac858f

Browse files
authored
Merge pull request #980 from qtomlinson/qt/edit_license
Support license edit
2 parents ce90aba + d882806 commit 8ac858f

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

src/components/FileList/FileList.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import FacetsDropdown from '../../components/FacetsDropdown'
1111
import Contribution from '../../utils/contribution'
1212
import FileListSpec from '../../utils/filelist'
1313
import Attachments from '../../utils/attachments'
14+
import ModalEditor from '../ModalEditor'
15+
import EnhancedLicensePicker from '../../utils/EnhancedLicensePicker'
1416
import folderIcon from '../../images/icons/folder.svg'
1517
import fileIcon from '../../images/icons/file.svg'
1618
import FolderOpenIcon from '@material-ui/icons/FolderOpen'
@@ -235,6 +237,16 @@ export default class FileList extends PureComponent {
235237
onChange(`described.facets.${facet}`, newGlobs)
236238
}
237239

240+
onLicenseChange = (record, license) => {
241+
const { onChange, component, previewDefinition } = this.props
242+
const attributions = Contribution.getValue(component.item, previewDefinition, `files[${record.id}].attributions`)
243+
onChange(`files[${record.id}]`, license, null, license => ({
244+
path: record.path,
245+
license,
246+
...(attributions ? { attributions } : {})
247+
}))
248+
}
249+
238250
onDirectorySelect = e => {
239251
let tempdata = this.state.breadcrumbs
240252
tempdata.push(e)
@@ -281,6 +293,25 @@ export default class FileList extends PureComponent {
281293
)
282294
}
283295

296+
renderLicenseCell = (value, record) => {
297+
const { readOnly, component, previewDefinition } = this.props
298+
const field = `files[${record.id}].license`
299+
const editor = EnhancedLicensePicker
300+
return (
301+
!record.children && (
302+
<ModalEditor
303+
revertable={false}
304+
field={field}
305+
readOnly={readOnly}
306+
initialValue={get(component.item, field)}
307+
value={Contribution.getValue(component.item, previewDefinition, field)}
308+
placeholder={'SPDX license'}
309+
editor={editor}
310+
onChange={license => this.onLicenseChange(record, license)} />
311+
)
312+
)
313+
}
314+
284315
render() {
285316
const { definition, component, previewDefinition } = this.props
286317
const { expandedRows, searchText, filteredFiles, files } = this.state
@@ -359,14 +390,8 @@ export default class FileList extends PureComponent {
359390
// }}
360391
// />
361392
// ),
362-
render: (value, record) => {
363-
let license = Contribution.getValue(component.item, previewDefinition, `files[${record.id}].license`)
364-
return (
365-
!record.children &&
366-
(license ? <p className="text-black">{license}</p> : <p className="text-gray">SPDX license</p>)
367-
)
368-
},
369-
width: '15%'
393+
render: this.renderLicenseCell,
394+
width: '20%'
370395
},
371396
{
372397
title: 'Copyrights',
@@ -376,31 +401,6 @@ export default class FileList extends PureComponent {
376401
// ...this.getColumnSearchProps('attributions'),
377402
render: (value, record) => this.renderCopyrightCell(record, component, previewDefinition),
378403
width: '25%'
379-
},
380-
{
381-
title: '',
382-
dataIndex: 'edit',
383-
key: 'edit',
384-
className: 'edit-data',
385-
// ...this.getColumnSearchProps('attributions'),
386-
render: (value, record) =>
387-
!record.children && (
388-
<svg
389-
className="edit-icon"
390-
width="24"
391-
height="24"
392-
viewBox="0 0 24 24"
393-
fill="none"
394-
xmlns="http://www.w3.org/2000/svg"
395-
>
396-
<path d="M22.5 19.5H1.5V21H22.5V19.5Z" fill="#383A43" />
397-
<path
398-
d="M19.05 6.75C19.65 6.15 19.65 5.25 19.05 4.65L16.35 1.95C15.75 1.35 14.85 1.35 14.25 1.95L3 13.2V18H7.8L19.05 6.75ZM15.3 3L18 5.7L15.75 7.95L13.05 5.25L15.3 3ZM4.5 16.5V13.8L12 6.3L14.7 9L7.2 16.5H4.5Z"
399-
fill="#383A43"
400-
/>
401-
</svg>
402-
),
403-
width: '5%'
404404
}
405405
]
406406

src/styles/_FullDetailComponent.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@
291291
}
292292
}
293293

294+
.column-license .edit-icon {
295+
font-size: 0;
296+
}
297+
294298
.tile-row__definition i,
295299
.tile-row .edit-icon {
296300
position: absolute;
@@ -754,4 +758,4 @@
754758
padding: 0;
755759
}
756760
}
757-
}
761+
}

0 commit comments

Comments
 (0)