[SSE mobile] Add protection in comments

This commit is contained in:
SergeyEzhin 2021-10-20 21:24:08 +04:00
parent 58968edc9a
commit 6044b95c2f
4 changed files with 72 additions and 12 deletions

View file

@ -5,7 +5,7 @@ import {Device} from '../../../../../common/mobile/utils/device';
import { withTranslation} from 'react-i18next';
import { LocalStorage } from '../../../utils/LocalStorage';
import {AddComment, EditComment, AddReply, EditReply, ViewComments, ViewCurrentComments} from '../../view/collaboration/Comments';
import {AddComment, EditComment, AddReply, EditReply, ViewComments, ViewCurrentComments, ViewAllComments} from '../../view/collaboration/Comments';
// utils
const timeZoneOffsetInMs = (new Date()).getTimezoneOffset() * 60000;
@ -625,14 +625,36 @@ class ViewCommentsController extends Component {
}
}
class ViewCommentsSheetsController extends ViewCommentsController {
constructor(props) {
super(props);
}
render() {
return (
<Fragment>
{this.props.allComments && <ViewAllComments wsProps={this.props.storeWorksheets.wsProps} onCommentMenuClick={this.onCommentMenuClick} onResolveComment={this.onResolveComment}
showComment={this.showComment} />}
{this.state.isOpenViewCurComments && <ViewCurrentComments opened={this.state.isOpenViewCurComments}
closeCurComments={this.closeViewCurComments}
onCommentMenuClick={this.onCommentMenuClick}
onResolveComment={this.onResolveComment}
/>}
</Fragment>
)
}
}
const _CommentsController = inject('storeAppOptions', 'storeComments', 'users', "storeApplicationSettings")(observer(CommentsController));
const _AddCommentController = inject('storeAppOptions', 'storeComments', 'users')(observer(AddCommentController));
const _EditCommentController = inject('storeComments', 'users')(observer(EditCommentController));
const _ViewCommentsController = inject('storeComments', 'users', "storeApplicationSettings")(observer(withTranslation()(ViewCommentsController)));
const _ViewCommentsController = inject('storeComments', 'users', "storeApplicationSettings", "storeReview", "storeAppOptions")(observer(withTranslation()(ViewCommentsController)));
const _ViewCommentsSheetsController = inject('storeComments', 'users', "storeApplicationSettings", "storeWorksheets", "storeReview", "storeAppOptions")(observer(withTranslation()(ViewCommentsSheetsController)));
export {
_CommentsController as CommentsController,
_AddCommentController as AddCommentController,
_EditCommentController as EditCommentController,
_ViewCommentsController as ViewCommentsController
_ViewCommentsController as ViewCommentsController,
_ViewCommentsSheetsController as ViewCommentsSheetsController
};

View file

@ -8,7 +8,7 @@ import {Device} from "../../../utils/device";
import {ReviewController, ReviewChangeController} from "../../controller/collaboration/Review";
import {PageDisplayMode} from "./Review";
import {ViewCommentsController} from "../../controller/collaboration/Comments";
import {ViewCommentsController, ViewCommentsSheetsController} from "../../controller/collaboration/Comments";
const PageUsers = inject("users")(observer(props => {
const { t } = useTranslation();
@ -76,7 +76,7 @@ const routes = [
},
{
path: '/comments/',
component: ViewCommentsController,
component: ViewCommentsSheetsController,
options: {
props: {
allComments: true

View file

@ -628,7 +628,8 @@ const pickLink = (message) => {
}
// View comments
const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment, showComment, storeReview}) => {
// ({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment, showComment, storeReview, storeWorksheets})
const ViewComments = inject("storeComments", "storeAppOptions", "storeReview")(observer(({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment, showComment, storeReview, wsProps}) => {
const { t } = useTranslation();
const _t = t('Common.Collaboration', {returnObjects: true});
const isAndroid = Device.android;
@ -736,9 +737,9 @@ const ViewComments = ({storeComments, storeAppOptions, onCommentMenuClick, onRes
<ReplyActions comment={clickComment} reply={reply} onCommentMenuClick={onCommentMenuClick} opened={replyActionsOpened} openActionReply={openActionReply}/>
</Page>
)
};
}));
const _ViewComments = inject('storeComments', 'storeAppOptions', "storeReview")(observer(ViewComments));
// const _ViewComments = inject('storeComments', 'storeAppOptions', "storeReview")(observer(ViewComments));
const CommentList = inject("storeComments", "storeAppOptions", "storeReview")(observer(({storeComments, storeAppOptions, onCommentMenuClick, onResolveComment, storeReview}) => {
@ -925,6 +926,7 @@ const ViewCommentPopover = ({onCommentMenuClick, onResolveComment}) => {
useEffect(() => {
f7.popover.open('#view-comment-popover', '#btn-coauth');
});
return (
<Popover id='view-comment-popover' style={{height: '410px'}} closeByOutsideClick={false}>
<CommentList onCommentMenuClick={onCommentMenuClick} onResolveComment={onResolveComment} />
@ -932,6 +934,30 @@ const ViewCommentPopover = ({onCommentMenuClick, onResolveComment}) => {
)
};
const ViewCommentsPopover = ({wsProps, onCommentMenuClick, onResolveComment, showComment}) => {
useEffect(() => {
f7.popover.open('#view-comments-popover', '#btn-coauth');
});
return (
<Popover id='view-comments-popover' style={{height: '410px'}} closeByOutsideClick={false}>
<ViewComments wsProps={wsProps} onCommentMenuClick={onCommentMenuClick} onResolveComment={onResolveComment} showComment={showComment} />
</Popover>
)
}
const ViewCommentsSheet = ({wsProps, onCommentMenuClick, onResolveComment, showComment}) => {
useEffect(() => {
f7.sheet.open('#view-comments-sheet');
});
return (
<Sheet id='view-comments-sheet'>
<ViewComments wsProps={wsProps} onCommentMenuClick={onCommentMenuClick} onResolveComment={onResolveComment} showComment={showComment} />
</Sheet>
)
}
const ViewCurrentComments = props => {
return (
Device.phone ?
@ -940,11 +966,21 @@ const ViewCurrentComments = props => {
)
};
const ViewAllComments = props => {
return (
Device.phone ?
<ViewCommentsSheet {...props}/> :
<ViewCommentsPopover {...props}/>
)
}
export {
AddComment,
EditComment,
AddReply,
EditReply,
_ViewComments as ViewComments,
ViewCurrentComments
ViewComments,
// _ViewComments as ViewComments,
ViewCurrentComments,
ViewAllComments
};

View file

@ -10,7 +10,8 @@ import {
AddCommentController,
CommentsController,
EditCommentController,
ViewCommentsController
ViewCommentsController,
ViewCommentsSheetsController
} from "../../../../common/mobile/lib/controller/collaboration/Comments";
import {LocalStorage} from "../../../../common/mobile/utils/LocalStorage";
import LongActionsController from "./LongActions";
@ -887,7 +888,8 @@ class MainController extends Component {
<CommentsController />
<AddCommentController />
<EditCommentController />
<ViewCommentsController />
<ViewCommentsSheetsController />
{/* <ViewCommentsController /> */}
<PluginsController />
<EncodingController />
</Fragment>