Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/components/AssetsLibrary/FilesGridView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ const FilesGridView = ({
assetsMembers={assetsMembers}
onDeletePostAttachment={onDeletePostAttachment}
loggedInUser={loggedInUser}
formatModifyDate={formatModifyDate}
/>)}
{(!subFolderContent) && (
<div styleName={cn({'assets-gridview-container-active': (linkToEdit >= 0 || linkToDelete >= 0)}, '')}>
Expand Down Expand Up @@ -130,7 +129,15 @@ const FilesGridView = ({
<li styleName="assets-gridview-row" onClick={changeSubFolder} key={'assets-gridview-folder-' + idx}>
<div styleName="flex-item item-type"><FolderIcon /></div>
<div styleName="flex-item item-name hand"><p>{formatFolderTitle(link.title)}</p></div>
<div styleName="flex-item item-created-by">—</div>
<div styleName="flex-item item-created-by">
{!owner && (<div className="user-block txt-italic">Unknown</div>)}
{owner && (
<div className="spacing">
<div className="user-block">
<UserTooltip usr={owner} id={idx} size={35} />
</div>
</div>)}
</div>
<div styleName="flex-item item-modified">{formatModifyDate(link)}</div>
<div styleName="flex-item item-action"/>
</li>)
Expand Down
13 changes: 11 additions & 2 deletions src/components/AssetsLibrary/LinksGridView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const LinksGridView = ({
link={ subFolderContent }
renderLink={ renderLink }
goBack={goBack}
formatModifyDate={formatModifyDate}
assetsMembers={assetsMembers}
isLinkSubFolder
/>)}
Expand Down Expand Up @@ -98,7 +97,17 @@ const LinksGridView = ({
<li styleName="assets-gridview-row" onClick={changeSubFolder} key={'assets-gridview-folder-' + idx}>
<div styleName="flex-item item-type"><FolderIcon /></div>
<div styleName="flex-item item-name hand"><p>{formatFolderTitle(link.title)}</p></div>
<div styleName="flex-item item-created-by">—</div>
<div styleName="flex-item item-created-by">
{!owner && !link.createdBy && (<div className="user-block">—</div>)}
{!owner && link.createdBy !== 'CoderBot' && (<div className="user-block txt-italic">Unknown</div>)}
{!owner && link.createdBy === 'CoderBot' && (<div className="user-block">CoderBot</div>)}
{owner && (
<div className="spacing">
<div className="user-block">
<UserTooltip usr={owner} id={idx} size={35} />
</div>
</div>)}
</div>
<div styleName="flex-item item-modified">{formatModifyDate(link)}</div>
<div styleName="flex-item item-action"/>
</li>)
Expand Down
10 changes: 6 additions & 4 deletions src/components/AssetsLibrary/SubFolder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import _ from 'lodash'
import cn from 'classnames'
import moment from 'moment'

import DeleteFileLinkModal from '../LinksMenu/DeleteFileLinkModal'
import ItemOperations from './ItemOperations'
Expand Down Expand Up @@ -56,8 +57,10 @@ class SubFolder extends React.Component {
}

render() {
const { link, renderLink, goBack, formatModifyDate, isLinkSubFolder, assetsMembers } = this.props
const { link, renderLink, goBack, isLinkSubFolder, assetsMembers } = this.props
const { linkToDelete } = this.state

const formatCreateDate = (link) => ((link.createdAt) ? moment(link.createdAt).format('MM/DD/YYYY h:mm A') : '—')
return (
<div styleName={cn({'assets-gridview-container-active': (linkToDelete >= 0)}, '')}>
{(linkToDelete >= 0) && <div styleName="assets-gridview-modal-overlay"/>}
Expand All @@ -67,7 +70,7 @@ class SubFolder extends React.Component {
<div styleName="flex-item-title item-type">Type</div>
<div styleName="flex-item-title item-name">Name</div>
<div styleName="flex-item-title item-created-by">Created By</div>
<div styleName="flex-item-title item-modified">Modified</div>
<div styleName="flex-item-title item-modified">Created At</div>
<div styleName="flex-item-title item-action"/>
</li>
<li styleName="assets-gridview-row" key="assets-gridview-subfolder" onClick={goBack}>
Expand Down Expand Up @@ -115,7 +118,7 @@ class SubFolder extends React.Component {
</div>
</div>)}
</div>
<div styleName="flex-item item-modified">{formatModifyDate(childLink)}</div>
<div styleName="flex-item item-modified">{formatCreateDate(childLink)}</div>
<div styleName="flex-item item-action">
{childLink.deletable && this.hasAccess(childLink.createdBy) && (
<ItemOperations
Expand All @@ -138,7 +141,6 @@ SubFolder.propTypes = {
onDeletePostAttachment: PropTypes.func,
goBack: PropTypes.func.isRequired,
loggedInUser: PropTypes.object,
formatModifyDate: PropTypes.func.isRequired,
}

export default SubFolder
30 changes: 18 additions & 12 deletions src/projects/detail/containers/AssetsInfoContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ class AssetsInfoContainer extends React.Component {
this.props.uploadProjectAttachments(project.id, attachment)
}

extractHtmlLink(str, userId) {
extractHtmlLink(post) {
const links = []
const regex = /<a[^>]+href="(.*?)"[^>]*>([\s\S]*?)<\/a>/gm
const urlRegex = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/gm // eslint-disable-line no-useless-escape
const rawLinks = regex.exec(str)
const rawLinks = regex.exec(post.rawContent)

if (Array.isArray(rawLinks)) {
let i = 0
Expand All @@ -249,7 +249,8 @@ class AssetsInfoContainer extends React.Component {
links.push({
title,
address,
createdBy: userId
createdAt: post.date,
createdBy: post.userId
})
}

Expand All @@ -260,11 +261,11 @@ class AssetsInfoContainer extends React.Component {
return links
}

extractMarkdownLink(str, userId) {
extractMarkdownLink(post) {
const links = []
const regex = /(?:__|[*#])|\[(.*?)\]\((.*?)\)/gm
const urlRegex = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/gm // eslint-disable-line no-useless-escape
const rawLinks = regex.exec(str)
const rawLinks = regex.exec(post.rawContent)

if (Array.isArray(rawLinks)) {
let i = 0
Expand All @@ -276,7 +277,8 @@ class AssetsInfoContainer extends React.Component {
links.push({
title,
address,
createdBy: userId
createdAt: post.date,
createdBy: post.userId
})
}

Expand All @@ -287,10 +289,10 @@ class AssetsInfoContainer extends React.Component {
return links
}

extractRawLink(str, userId) {
extractRawLink(post) {
let links = []
const regex = /(\s|^)(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,}[\s])(\s|$)/igm // eslint-disable-line no-useless-escape
const rawLinks = str.match(regex)
const rawLinks = post.rawContent.match(regex)

if (Array.isArray(rawLinks)) {
links = rawLinks
Expand All @@ -302,7 +304,8 @@ class AssetsInfoContainer extends React.Component {
return {
title: name,
address: url,
createdBy: userId
createdAt: post.date,
createdBy: post.userId
}
})
}
Expand All @@ -316,15 +319,16 @@ class AssetsInfoContainer extends React.Component {
let childrenLinks = []
feed.posts.forEach(post => {
childrenLinks = childrenLinks.concat([
...this.extractHtmlLink(post.rawContent, post.userId),
...this.extractMarkdownLink(post.rawContent, post.userId),
...this.extractRawLink(post.rawContent, post.userId)
...this.extractHtmlLink(post),
...this.extractMarkdownLink(post),
...this.extractRawLink(post)
])
})

if (childrenLinks.length > 0) {
links.push({
title: feed.title,
createdBy: feed.userId,
children: childrenLinks
})
}
Expand All @@ -349,6 +353,7 @@ class AssetsInfoContainer extends React.Component {
attachmentId: attachment.id,
attachment: true,
deletable: true,
createdAt: post.date,
createdBy: attachment.createdBy,
postId: post.id,
topicId: feed.id,
Expand All @@ -361,6 +366,7 @@ class AssetsInfoContainer extends React.Component {
if (attachmentLinksPerFeed.length > 0) {
attachmentLinks.push({
title: feed.title,
createdBy: feed.userId,
children: attachmentLinksPerFeed
})
}
Expand Down