diff --git a/src/components/FileList/FileList.js b/src/components/FileList/FileList.js index f3677261..d271754e 100644 --- a/src/components/FileList/FileList.js +++ b/src/components/FileList/FileList.js @@ -11,6 +11,8 @@ import FacetsDropdown from '../../components/FacetsDropdown' import Contribution from '../../utils/contribution' import FileListSpec from '../../utils/filelist' import Attachments from '../../utils/attachments' +import ModalEditor from '../ModalEditor' +import EnhancedLicensePicker from '../../utils/EnhancedLicensePicker' import folderIcon from '../../images/icons/folder.svg' import fileIcon from '../../images/icons/file.svg' import FolderOpenIcon from '@material-ui/icons/FolderOpen' @@ -38,10 +40,6 @@ export default class FileList extends PureComponent { this.updateFileList(this.props) } - componentWillReceiveProps(nextProps) { - this.updateFileList(nextProps) - } - updateFileList = props => { this.setState({ files: FileListSpec.pathToTreeFolders(props.files, props.component.item, props.previewDefinition) @@ -235,6 +233,16 @@ export default class FileList extends PureComponent { onChange(`described.facets.${facet}`, newGlobs) } + onLicenseChange(record, license) { + const { onChange, component, previewDefinition } = this.props + const attributions = Contribution.getValue(component.item, previewDefinition, `files[${record.id}].attributions`) + onChange(`files[${record.id}]`, license, null, license => ({ + path: record.path, + license, + ...(attributions ? { attributions } : {}) + })) + } + onDirectorySelect = e => { let tempdata = this.state.breadcrumbs tempdata.push(e) @@ -281,6 +289,25 @@ export default class FileList extends PureComponent { ) } + renderLicenseCell(record) { + const { readOnly, component, previewDefinition } = this.props + const field = `files[${record.id}].license` + const editor = EnhancedLicensePicker + return ( + !record.children && ( + this.onLicenseChange(record, license)} /> + ) + ) + } + render() { const { definition, component, previewDefinition } = this.props const { expandedRows, searchText, filteredFiles, files } = this.state @@ -359,14 +386,8 @@ export default class FileList extends PureComponent { // }} // /> // ), - render: (value, record) => { - let license = Contribution.getValue(component.item, previewDefinition, `files[${record.id}].license`) - return ( - !record.children && - (license ?

{license}

:

SPDX license

) - ) - }, - width: '15%' + render: (value, record) => this.renderLicenseCell(record), + width: '20%' }, { title: 'Copyrights', @@ -376,31 +397,6 @@ export default class FileList extends PureComponent { // ...this.getColumnSearchProps('attributions'), render: (value, record) => this.renderCopyrightCell(record, component, previewDefinition), width: '25%' - }, - { - title: '', - dataIndex: 'edit', - key: 'edit', - className: 'edit-data', - // ...this.getColumnSearchProps('attributions'), - render: (value, record) => - !record.children && ( - - - - - ), - width: '5%' } ] diff --git a/src/styles/_FullDetailComponent.scss b/src/styles/_FullDetailComponent.scss index a4ef3cda..587d7b8b 100644 --- a/src/styles/_FullDetailComponent.scss +++ b/src/styles/_FullDetailComponent.scss @@ -291,6 +291,10 @@ } } +.column-license .edit-icon { + font-size: 0; +} + .tile-row__definition i, .tile-row .edit-icon { position: absolute; @@ -754,4 +758,4 @@ padding: 0; } } -} +} \ No newline at end of file