Skip to content

Commit

Permalink
Merge branch 'release-3.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Nov 18, 2019
2 parents a38950a + 5850b36 commit 8fd5c9c
Show file tree
Hide file tree
Showing 36 changed files with 1,819 additions and 1,333 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [3.0.1](2019-11-18)

### Fixed

- [#820](https://github.com/dadi/publish/pull/820): fix routing issue in single-document collections

## [3.0.0](2019-10-29)

### Added
Expand Down
170 changes: 170 additions & 0 deletions app/components/MediaList/MediaList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import * as Constants from 'lib/constants'
import {connectRedux} from 'lib/redux'
import DocumentGridList from 'components/DocumentGridList/DocumentGridList'
import DocumentTableList from 'containers/DocumentTableList/DocumentTableList'
import DropArea from 'components/DropArea/DropArea'
import FieldMediaItem from 'components/FieldMedia/FieldMediaItem'
import MediaGridCard from 'containers/MediaGridCard/MediaGridCard'
import MediaListController from 'components/MediaListController/MediaListController'
import proptypes from 'prop-types'
import React from 'react'

const MEDIA_TABLE_FIELDS = ['url', 'fileName', 'mimeType', 'width', 'height']

class MediaList extends React.Component {
static propTypes = {
/**
* The list of documents shown in the list.
*/
documents: proptypes.array,

/**
* Whether any documents are selected.
*/
hasSelection: proptypes.bool,

/**
* Whether the view is filtered to only show selected documents.
*/
isFilteringSelection: proptypes.bool,

/**
* Whether to display the items in a table or grid form.
*/
mode: proptypes.oneOf(['table', 'grid']),

/**
* Callback to be called to obtain the base URL for the given page, as
* determined by the view.
*/
onBuildBaseUrl: proptypes.func,

/**
* Callback to be called when the user changes the list display mode.
*/
onListModeUpdate: proptypes.func,

/**
* Callback to be called when files are uploaded.
*/
onMediaUpload: proptypes.func,

/**
* Callback to be called when the selection changes.
*/
onSelect: proptypes.func,

/**
* Callback to be called when the user sorts the list.
*/
onSort: proptypes.func,

/**
* The order used to sort the documents by the `sort` field.
*/
order: proptypes.oneOf(['asc', 'desc']),

/**
* The list of currently selected documents.
*/
selectedDocuments: proptypes.object,

/**
* The name of the field currently being used to sort the documents.
*/
sort: proptypes.string
}

constructor(props) {
super(props)

this.renderFieldMediaItem = this.renderFieldMediaItem.bind(this)
}

render() {
const {
documents,
hasSelection,
isFilteringSelection,
mode,
onBuildBaseUrl,
onListModeUpdate,
onMediaUpload,
onSelect,
onSort,
order,
selectedDocuments,
sort
} = this.props
const schema = {
...Constants.MEDIA_COLLECTION_SCHEMA,
fields: {
...Constants.MEDIA_COLLECTION_SCHEMA.fields,
url: {label: 'Thumbnail', FieldComponentList: this.renderFieldMediaItem}
}
}

const contents = (
<>
{!isFilteringSelection && (
<MediaListController
documents={documents}
mode={mode}
onListModeUpdate={onListModeUpdate}
onSelect={onSelect}
onUpload={onMediaUpload}
selectedDocuments={selectedDocuments}
/>
)}

{mode === 'grid' && (
<DocumentGridList
documents={documents}
onRenderCard={({item, isSelected, onSelect}) => (
<MediaGridCard
href={`/media/${item._id}`}
isSelected={isSelected}
isSelectMode={hasSelection}
item={item}
key={item._id}
onSelect={onSelect}
/>
)}
onSelect={onSelect}
selectedDocuments={selectedDocuments}
/>
)}

{mode === 'table' && (
<DocumentTableList
collection={schema}
documents={documents}
fields={MEDIA_TABLE_FIELDS}
onBuildBaseUrl={onBuildBaseUrl}
onSelect={onSelect}
onSort={onSort}
order={order}
selectedDocuments={selectedDocuments}
sort={sort}
/>
)}
</>
)

return onMediaUpload ? (
<DropArea onDrop={onMediaUpload}>{contents}</DropArea>
) : (
contents
)
}

renderFieldMediaItem({document}) {
return <FieldMediaItem config={this.props.config} isList value={document} />
}
}

const mapState = state => ({
config: state.app.config
})

export default connectRedux(mapState)(MediaList)
3 changes: 3 additions & 0 deletions app/components/Notification/Notification.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.container {
position: absolute;
bottom: 100%;
width: 100%;
opacity: 0;
transform: translateY(100%);
transition: opacity 0.3s ease-in-out 0.05s, transform 0.3s ease-in-out;
Expand Down
Loading

0 comments on commit 8fd5c9c

Please sign in to comment.