Skip to content

Commit

Permalink
refactor: Renamed props
Browse files Browse the repository at this point in the history
  • Loading branch information
y-lohse committed May 15, 2020
1 parent a605f32 commit dfeb56e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const CreateShortcutWrapper = ({ openModal }) => {
const mapDispatchToProps = (dispatch, ownProps) => ({
openModal: () =>
dispatch(
showModal(
<ShortcutCreationModal afterCreation={ownProps.afterCreation} />
)
showModal(<ShortcutCreationModal onCreated={ownProps.onCreated} />)
)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const makeURLValid = str => {
else if (isURLValid(`https://${str}`)) return `https://${str}`
return false
}
const ShortcutCreationModal = ({ onClose, afterCreation, displayedFolder }) => {
const ShortcutCreationModal = ({ onClose, onCreated, displayedFolder }) => {
const { t } = useI18n()
const [filename, setFilename] = useState('')
const [url, setUrl] = useState('')
Expand All @@ -56,7 +56,7 @@ const ShortcutCreationModal = ({ onClose, afterCreation, displayedFolder }) => {
try {
await client.collection('io.cozy.files.shortcuts').create(data)
Alerter.success('Shortcut.created')
afterCreation()
onCreated()
onClose()
} catch (e) {
Alerter.error('Shortcut.errored')
Expand Down
2 changes: 1 addition & 1 deletion src/drive/web/modules/public/LightFolderView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class DumbFolderView extends React.Component {
files={[this.props.displayedFolder]}
isFile={false}
hasWriteAccess={hasWriteAccess}
reloadView={this.loadCurrentFolder}
refreshFolderContent={this.loadCurrentFolder}
/>
</Topbar>
<Content>
Expand Down
26 changes: 14 additions & 12 deletions src/drive/web/modules/public/PublicToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const MoreMenu = withBreakpoints()(
onCreateCozy,
isFile,
hasWriteAccess,
reloadView,
refreshFolderContent,
breakpoints: { isMobile }
}) => {
const anchorRef = React.createRef()
Expand Down Expand Up @@ -108,8 +108,10 @@ const MoreMenu = withBreakpoints()(
</ActionMenuItem>
{hasWriteAccess && <AddFolderItem />}
{hasWriteAccess && <CreateNoteItem />}
{hasWriteAccess && <CreateShortcut afterCreation={reloadView} />}
{hasWriteAccess && <UploadItem afterUpload={reloadView} />}
{hasWriteAccess && (
<CreateShortcut onCreated={refreshFolderContent} />
)}
{hasWriteAccess && <UploadItem onUploaded={refreshFolderContent} />}
<SelectableItem />
</ActionMenu>
)}
Expand All @@ -130,12 +132,12 @@ const toolbarProptypes = {
discoveryLink: PropTypes.string,
isFile: PropTypes.bool.isRequired,
hasWriteAccess: PropTypes.bool,
reloadView: PropTypes.func.isRequired
refreshFolderContent: PropTypes.func.isRequired
}
const openExternalLink = url => (window.location = url)

const MobileToolbar = (
{ onDownload, discoveryLink, isFile, hasWriteAccess, reloadView },
{ onDownload, discoveryLink, isFile, hasWriteAccess, refreshFolderContent },
{ store }
) => {
const client = useClient()
Expand All @@ -147,7 +149,7 @@ const MobileToolbar = (
isFile={isFile}
hasWriteAccess={hasWriteAccess}
t={t}
reloadView={reloadView}
refreshFolderContent={refreshFolderContent}
onDownload={onDownload}
onOpenInCozy={
discoveryLink ? () => openExternalLink(discoveryLink) : false
Expand Down Expand Up @@ -203,7 +205,7 @@ CozybarToolbar.contextTypes = {
CozybarToolbar.propTypes = toolbarProptypes

const DesktopToolbar = (
{ onDownload, discoveryLink, isFile, hasWriteAccess, reloadView },
{ onDownload, discoveryLink, isFile, hasWriteAccess, refreshFolderContent },
{ t }
) => (
<div
Expand All @@ -219,7 +221,7 @@ const DesktopToolbar = (
<MoreMenu
isFile={isFile}
hasWriteAccess={hasWriteAccess}
reloadView={reloadView}
refreshFolderContent={refreshFolderContent}
t={t}
onDownload={onDownload}
onOpenInCozy={
Expand Down Expand Up @@ -281,7 +283,7 @@ class PublicToolbar extends React.Component {
renderInBar = false,
isFile,
hasWriteAccess,
reloadView
refreshFolderContent
} = this.props
const { discoveryLink } = this.state

Expand All @@ -292,7 +294,7 @@ class PublicToolbar extends React.Component {
discoveryLink={discoveryLink}
isFile={isFile}
hasWriteAccess={hasWriteAccess}
reloadView={reloadView}
refreshFolderContent={refreshFolderContent}
/>
)
} else if (renderInBar) {
Expand All @@ -310,7 +312,7 @@ class PublicToolbar extends React.Component {
discoveryLink={discoveryLink}
isFile={isFile}
hasWriteAccess={hasWriteAccess}
reloadView={reloadView}
refreshFolderContent={refreshFolderContent}
/>
)
}
Expand All @@ -322,7 +324,7 @@ PublicToolbar.propTypes = {
breakpoints: PropTypes.object.isRequired,
files: PropTypes.array.isRequired,
hasWriteAccess: PropTypes.bool,
reloadView: PropTypes.func.isRequired
refreshFolderContent: PropTypes.func.isRequired
}
const mapDispatchToProps = dispatch => ({
onDownload: files => dispatch(downloadFiles(files))
Expand Down

0 comments on commit dfeb56e

Please sign in to comment.