-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/#485 files menu option - sidebar #491
Merged
sidmohanty11
merged 13 commits into
RocketChat:develop
from
umangutkarsh:feat/#485-files-menu
Mar 12, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9fa5b09
add-rest-api-endpoint
umangutkarsh fef40eb
menu-option-ui
umangutkarsh fafd5c2
files-menu-sidebar-ui
umangutkarsh f32e8ca
menu-sidebar-components
umangutkarsh 4065f7b
finalize-code
umangutkarsh 78970e9
format-fixes
umangutkarsh c9ba1f2
api-change/linting+format-fix
umangutkarsh a468e2e
Merge branch 'develop' into feat/#485-files-menu
umangutkarsh b21245a
format-fix
umangutkarsh cccf273
Merge branch 'develop' into feat/#485-files-menu
umangutkarsh d85fda1
Merge branch 'develop' into feat/#485-files-menu
umangutkarsh 918813f
Merge branch 'develop' into feat/#485-files-menu
umangutkarsh 2f117b3
revert-lint-changes
umangutkarsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import { css } from '@emotion/react'; | ||
import { formatDistance } from 'date-fns'; | ||
import useComponentOverrides from '../../theme/useComponentOverrides'; | ||
import { Box } from '../Box'; | ||
import { appendClassNames } from '../../lib/appendClassNames'; | ||
import { Icon } from '../Icon'; | ||
|
||
const FileMetricsCss = css` | ||
display: flex; | ||
margin-left: -0.25rem; | ||
margin-right: -0.25rem; | ||
margin-inline: -0.25rem; | ||
margin-top: 0.5rem; | ||
`; | ||
|
||
const FileMetricsItemCss = css` | ||
letter-spacing: 0rem; | ||
font-size: 0.625rem; | ||
font-weight: 700; | ||
line-height: 0.75rem; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
margin-left: 0.25rem; | ||
color: #6c727a; | ||
`; | ||
|
||
const FileMetricsItemLabelCss = css` | ||
margin: 0.25rem; | ||
margin-inline-start: 0.25rem; | ||
white-space: nowrap; | ||
`; | ||
|
||
export const FileMetrics = ({ className = '', file, style = {}, ...props }) => { | ||
const { styleOverrides, classNames } = useComponentOverrides( | ||
'MessageMetrics', | ||
className, | ||
style | ||
); | ||
return ( | ||
<Box | ||
css={FileMetricsCss} | ||
className={appendClassNames('ec-message-metrics', classNames)} | ||
style={styleOverrides} | ||
{...props} | ||
> | ||
<div | ||
css={FileMetricsItemCss} | ||
title={new Date(file.uploadedAt).toLocaleString()} | ||
> | ||
<Icon size="1.25rem" name="clock" /> | ||
<div css={FileMetricsItemLabelCss}> | ||
{formatDistance(new Date(file.uploadedAt), new Date(), { | ||
addSuffix: true, | ||
})} | ||
</div> | ||
</div> | ||
</Box> | ||
); | ||
}; |
27 changes: 27 additions & 0 deletions
27
packages/react/src/components/Files/FilePreviewContainer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { css } from '@emotion/react'; | ||
import { Avatar } from '../Avatar'; | ||
import { Box } from '../Box'; | ||
import { Icon } from '../Icon'; | ||
|
||
const FilePreviewContainer = ({ file, sequential, isStarred }) => { | ||
const FilePreviewContainerCss = css` | ||
margin: 3px; | ||
width: 2.25em; | ||
max-height: 2.25em; | ||
display: flex; | ||
justify-content: flex-end; | ||
`; | ||
|
||
return ( | ||
<Box css={FilePreviewContainerCss}> | ||
{!sequential ? ( | ||
<Avatar url={file.url} alt="file" size="2.25em" /> | ||
) : isStarred ? ( | ||
<Icon style={{ opacity: 0.5 }} name="star-filled" size="1.2em" /> | ||
) : null} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default FilePreviewContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { css } from '@emotion/react'; | ||
import { format } from 'date-fns'; | ||
import { useUserStore } from '../../store'; | ||
import { Icon } from '../Icon'; | ||
import useComponentOverrides from '../../theme/useComponentOverrides'; | ||
import { Box } from '../Box'; | ||
import { appendClassNames } from '../../lib/appendClassNames'; | ||
|
||
const FilePreviewHeaderCss = css` | ||
display: flex; | ||
overflow-x: hidden; | ||
flex-direction: row; | ||
flex-grow: 0; | ||
flex-shrink: 1; | ||
min-width: 1px; | ||
padding-right: 3px; | ||
margin-top: 0.125rem; | ||
margin-bottom: 0.125rem; | ||
margin-block: 0.125rem; | ||
gap: 0.125rem; | ||
align-items: center; | ||
max-width: 85%; | ||
`; | ||
|
||
const FilePreviewHeaderNameCss = css` | ||
letter-spacing: 0rem; | ||
display: inline-block; | ||
font-size: 0.875rem; | ||
font-weight: 700; | ||
line-height: 1.25rem; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
flex-shrink: 1; | ||
color: #2f343d; | ||
`; | ||
|
||
const FilePreviewHeaderTimestapCss = css` | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
letter-spacing: 0rem; | ||
font-size: 0.75rem; | ||
font-weight: 400; | ||
line-height: 1rem; | ||
flex-shrink: 0; | ||
color: #9ea2a8; | ||
`; | ||
|
||
const FilePreviewHeader = ({ file, isTimeStamped = true }) => { | ||
const { styleOverrides, classNames } = useComponentOverrides('MessageHeader'); | ||
const authenticatedUserId = useUserStore((state) => state.userId); | ||
const isStarred = | ||
file.starred && file.starred.find((u) => u._id === authenticatedUserId); | ||
|
||
return ( | ||
<Box | ||
css={FilePreviewHeaderCss} | ||
className={appendClassNames('ec-file-header', classNames)} | ||
style={styleOverrides} | ||
> | ||
<Box | ||
is="span" | ||
css={FilePreviewHeaderNameCss} | ||
className={appendClassNames('ec-file-header-name')} | ||
> | ||
{file.name} | ||
</Box> | ||
|
||
{isTimeStamped && ( | ||
<Box | ||
is="span" | ||
css={FilePreviewHeaderTimestapCss} | ||
className={appendClassNames('ec-file-header-timestamp')} | ||
> | ||
{format(new Date(file.ts), 'h:mm a')} | ||
</Box> | ||
)} | ||
{isStarred ? ( | ||
<Icon | ||
style={{ marginInlineEnd: '0.4rem', opacity: 0.5 }} | ||
name="star-filled" | ||
size="1em" | ||
/> | ||
) : null} | ||
</Box> | ||
); | ||
}; | ||
|
||
export default FilePreviewHeader; | ||
|
||
FilePreviewHeader.propTypes = { | ||
file: PropTypes.any, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it will cause an issue here with dependencies, still confirm it
Also confirm, there is no console errors. Rest LGTM!