Skip to content

Timeline wall final fix #6696

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

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
2 changes: 1 addition & 1 deletion src/shared/components/GUIKit/PhotoVideoItem/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}

.img-container {
max-height: 100%;
height: 100%;
width: 100%;
object-fit: cover;
}
Expand Down
89 changes: 51 additions & 38 deletions src/shared/components/GUIKit/PhotoVideoPicker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ function PhotoVideoPicker({
inputOptions,
file,
}) {
const renderUpload = () => (
<React.Fragment>
<p styleName="infoText hide-mobile">
{infoText}
</p>
<button styleName="btn hide-mobile" type="button">{btnText}</button>
</React.Fragment>
);

return (
<React.Fragment>
<Dropzone
Expand Down Expand Up @@ -66,7 +75,7 @@ function PhotoVideoPicker({
<React.Fragment>

<section
styleName={cn('container', { hasError: !!errorMsg, hasFile: !!file && !!file.length })}
styleName={cn('container', { hasError: !!errorMsg, hasFile: !!file && !!file.length, 'hide-mobile': file.length === 3 })}
{...getRootProps()}
className={cn(className, getRootProps().className)}
>
Expand All @@ -76,44 +85,48 @@ function PhotoVideoPicker({
})}
/>
{
file && file.length ? (
<div styleName="photo-list hide-mobile">
{file.map((fileInfo, index) => (
<div
styleName="photo-item"
key={fileInfo.name}
><PhotoVideoItem notSelectable file={fileInfo} />
<button
type="button"
styleName="btn-delete"
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
const newFile = [...file];
newFile.splice(index, 1);
onFilePick(newFile);
}}
><BtnDeletePhoto />
</button>
</div>
))}
</div>
) : (
<React.Fragment>
<p styleName="infoText hide-mobile">
{infoText}
</p>
<button styleName="btn hide-mobile" type="button">{btnText}</button>
</React.Fragment>
)
}
file && file.length ? (
<div styleName="photo-list hide-mobile">
{file.map((fileInfo, index) => (
<div
styleName="photo-item"
key={fileInfo.name}
><PhotoVideoItem notSelectable file={fileInfo} />
<button
type="button"
styleName="btn-delete"
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
const newFile = [...file];
newFile.splice(index, 1);
onFilePick(newFile);
}}
><BtnDeletePhoto />
</button>
</div>
))}
{
file.length < 3 && (
<div styleName="photo-item browse-button">
{renderUpload()}
</div>
)
}
</div>
) : renderUpload()
}

<React.Fragment>
<p styleName="infoText hide-desktop show-mobile">
{infoTextMobile}
</p>
<button styleName="btn hide-desktop show-mobile" type="button">{btnText}</button>
</React.Fragment>
{
(file || []).length < 3 && (
<React.Fragment>
<p styleName="infoText hide-desktop show-mobile">
{infoTextMobile}
</p>
<button styleName="btn hide-desktop show-mobile" type="button">{btnText}</button>
</React.Fragment>
)
}
</section>

</React.Fragment>
Expand Down
7 changes: 7 additions & 0 deletions src/shared/components/GUIKit/PhotoVideoPicker/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@
justify-content: center;
position: relative;

&.browse-button {
display: flex;
flex-direction: column;
width: 100%;
padding: 0 10px;
}

@media (max-width: 768px) {
height: 100px;
border: none;
Expand Down
12 changes: 10 additions & 2 deletions src/shared/containers/timeline-wall/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function TimelineWallContainer(props) {
const deleteEvent = (id) => {
deleteEventById(authToken, id, () => {
getPendingApprovals(authToken);
getTimelineEvents();
});
};

Expand All @@ -115,9 +116,15 @@ function TimelineWallContainer(props) {
});
};

const removeEvent = (id, body) => {
rejectEventById(authToken, id, body, () => {
const removeEvent = (event = {}, body) => {
const rejectBody = body;
const id = event.id ? event.id : event;
if (!body.reason) {
rejectBody.reason = 'Deleted by admin.';
}
rejectEventById(authToken, id, rejectBody, () => {
getPendingApprovals(authToken);
getTimelineEvents();
});
};

Expand Down Expand Up @@ -188,6 +195,7 @@ function TimelineWallContainer(props) {
getAvatar={getAvatar}
userAvatars={userAvatars}
uploading={uploading}
deleteEvent={deleteEvent}
/>
<React.Fragment>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function ApprovalItem({
<PhotoVideoItem
key={photo.id}
styleName="photo-item"
url={photo.url}
url={photo.previewUrl || photo.url}
videoThumnailUrl={photo.videoThumnailUrl}
isUrlPhoto={!photo.videoThumnailUrl}
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 16px;
margin-top: 36px;

.btn-trash {
border: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function AddEvents({
files: files.slice(0, 3),
});
}}
infoText={'Drag & drop your photo or video here\nYou can upload only up to 3 photos/videos'}
infoText={'Drag & drop your photo or video here\nYou can upload up to 3 photos/videos'}
infoTextMobile="Drag & drop your photo or video here"
btnText="BROWSE"
options={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import './styles.scss';
import { DEFAULT_AVATAR_URL } from '../../../../../utils/url';

function EventItem({
className, isLeft, eventItem, removeEvent, isAdmin, userAvatars,
className, isLeft, eventItem, removeEvent, deleteEvent, isAdmin, userAvatars,
}) {
const [isExpanded, setIsExpanded] = useState(false);
const [showModalPhoto, setShowModalPhoto] = useState(false);
Expand Down Expand Up @@ -112,13 +112,15 @@ function EventItem({

{showModalDelete ? (
<ModalDeleteConfirmation
id={eventItem.id}
eventItem={showModalDelete}
onClose={(result) => {
if (result === true) {
removeEvent(showModalDelete);
}
setShowModalDelete(false);
}}
deleteEvent={deleteEvent}
/>
) : null}
</div>
Expand Down Expand Up @@ -150,6 +152,7 @@ EventItem.propTypes = {
removeEvent: PT.func,
isAdmin: PT.bool,
userAvatars: PT.shape(),
deleteEvent: PT.func.isRequired,
};

export default EventItem;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import EventItem from './event-item';
const colors = ['green', 'red', 'purple'];

function Events({
events, removeEvent, isAuthenticated, getAvatar, userAvatars,
events, removeEvent, isAuthenticated, getAvatar, userAvatars, isAdmin, deleteEvent,
}) {
const [leftItems, setLeftItems] = useState([]);
const [rightItems, setRightItems] = useState([]);
Expand Down Expand Up @@ -65,6 +65,8 @@ function Events({
}}
getAvatar={getAvatar}
userAvatars={userAvatars}
isAdmin={isAdmin}
deleteEvent={deleteEvent}
/>
))}
</div>
Expand All @@ -80,6 +82,8 @@ function Events({
}}
getAvatar={getAvatar}
userAvatars={userAvatars}
isAdmin={isAdmin}
deleteEvent={deleteEvent}
/>
))}
</div>
Expand All @@ -95,6 +99,8 @@ function Events({
}}
getAvatar={getAvatar}
userAvatars={userAvatars}
isAdmin={isAdmin}
deleteEvent={deleteEvent}
/>
))}
</div>
Expand All @@ -110,6 +116,7 @@ Events.defaultProps = {
removeEvent: () => { },
isAuthenticated: false,
userAvatars: {},
isAdmin: false,
};

/**
Expand All @@ -121,6 +128,8 @@ Events.propTypes = {
isAuthenticated: PT.bool,
getAvatar: PT.func.isRequired,
userAvatars: PT.shape(),
isAdmin: PT.bool,
deleteEvent: PT.func.isRequired,
};

export default Events;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function TimelineEvents({
userAvatars,
onDoneAddEvent,
uploading,
deleteEvent,
}) {
return (
<div className={className} styleName="container">
Expand All @@ -44,6 +45,7 @@ function TimelineEvents({
}}
getAvatar={getAvatar}
userAvatars={userAvatars}
deleteEvent={deleteEvent}
/>
)
: null}
Expand Down Expand Up @@ -112,6 +114,7 @@ TimelineEvents.propTypes = {
onDoneAddEvent: PT.func.isRequired,
userAvatars: PT.shape(),
uploading: PT.bool,
deleteEvent: PT.func.isRequired,
};

export default TimelineEvents;
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
width: 120px;
border-radius: 8px;
padding: 10px 0;
position: fixed;
right: 0;
max-height: 70%;
overflow: scroll;

@media (max-width: 768px) {
border-radius: 0;
Expand Down