|
|
@@ -8,6 +8,9 @@ import PageContainer from '~/client/services/PageContainer';
|
|
|
|
|
|
import { withUnstatedContainers } from './UnstatedUtils';
|
|
|
|
|
|
+import { ConflictDiffModal } from '~/components/PageEditor/ConflictDiffModal';
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @author Yuki Takei <yuki@weseek.co.jp>
|
|
|
@@ -23,6 +26,7 @@ class PageStatusAlert extends React.Component {
|
|
|
super(props);
|
|
|
|
|
|
this.state = {
|
|
|
+ isConflictDiffModalOpen: false,
|
|
|
};
|
|
|
|
|
|
this.getContentsForSomeoneEditingAlert = this.getContentsForSomeoneEditingAlert.bind(this);
|
|
|
@@ -53,15 +57,15 @@ class PageStatusAlert extends React.Component {
|
|
|
getContentsForRevisionOutdated() {
|
|
|
const { t } = this.props;
|
|
|
return [
|
|
|
- ['bg-success', 'd-hackmd-none'],
|
|
|
+ ['bg-warning', 'd-hackmd-none'],
|
|
|
<>
|
|
|
<i className="icon-fw icon-pencil"></i>
|
|
|
{t('modal_resolve_conflict.file_conflicting_with_newer_remote')}
|
|
|
</>,
|
|
|
- <a href="#hackmd" className="btn btn-outline-white">
|
|
|
+ <button type="button" onClick={() => this.setState({ isConflictDiffModalOpen: true })} className="btn btn-outline-white">
|
|
|
<i className="fa fa-fw fa-file-text-o mr-1"></i>
|
|
|
{t('modal_resolve_conflict.resolve_conflict')}
|
|
|
- </a>,
|
|
|
+ </button>,
|
|
|
];
|
|
|
}
|
|
|
|
|
|
@@ -100,7 +104,7 @@ class PageStatusAlert extends React.Component {
|
|
|
|
|
|
render() {
|
|
|
const {
|
|
|
- revisionId, revisionIdHackmdSynced, remoteRevisionId, hasDraftOnHackmd, isHackmdDraftUpdatingInRealtime,
|
|
|
+ revisionId, revisionIdHackmdSynced, remoteRevisionId, hasDraftOnHackmd, isHackmdDraftUpdatingInRealtime, isConflictingOnSave,
|
|
|
} = this.props.pageContainer.state;
|
|
|
|
|
|
const isRevisionOutdated = revisionId !== remoteRevisionId;
|
|
|
@@ -108,14 +112,14 @@ class PageStatusAlert extends React.Component {
|
|
|
|
|
|
let getContentsFunc = null;
|
|
|
|
|
|
+ // when conflicting on save
|
|
|
+ if (isConflictingOnSave) {
|
|
|
+ getContentsFunc = this.getContentsForRevisionOutdated;
|
|
|
+ }
|
|
|
// when remote revision is newer than both
|
|
|
- if (isHackmdDocumentOutdated && isRevisionOutdated) {
|
|
|
+ else if (isHackmdDocumentOutdated && isRevisionOutdated) {
|
|
|
getContentsFunc = this.getContentsForUpdatedAlert;
|
|
|
}
|
|
|
- // when remote revision is newer
|
|
|
- else if (isRevisionOutdated) {
|
|
|
- getContentsFunc = this.getContentsForRevisionOutdated;
|
|
|
- }
|
|
|
// when someone editing with HackMD
|
|
|
else if (isHackmdDraftUpdatingInRealtime) {
|
|
|
getContentsFunc = this.getContentsForSomeoneEditingAlert;
|
|
|
@@ -132,16 +136,23 @@ class PageStatusAlert extends React.Component {
|
|
|
const [additionalClasses, label, btn] = getContentsFunc();
|
|
|
|
|
|
return (
|
|
|
- <div className={`card grw-page-status-alert text-white fixed-bottom animated fadeInUp faster ${additionalClasses.join(' ')}`}>
|
|
|
- <div className="card-body">
|
|
|
- <p className="card-text grw-card-label-container">
|
|
|
- {label}
|
|
|
- </p>
|
|
|
- <p className="card-text grw-card-btn-container">
|
|
|
- {btn}
|
|
|
- </p>
|
|
|
+ <>
|
|
|
+ <div className={`card grw-page-status-alert text-white fixed-bottom animated fadeInUp faster ${additionalClasses.join(' ')}`}>
|
|
|
+ <div className="card-body">
|
|
|
+ <p className="card-text grw-card-label-container">
|
|
|
+ {label}
|
|
|
+ </p>
|
|
|
+ <p className="card-text grw-card-btn-container">
|
|
|
+ {btn}
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ <ConflictDiffModal
|
|
|
+ isOpen={this.state.isConflictDiffModalOpen}
|
|
|
+ onCancel={() => this.setState({ isConflictDiffModalOpen: false })}
|
|
|
+ onResolveConflict={() => { }}
|
|
|
+ />
|
|
|
+ </>
|
|
|
);
|
|
|
}
|
|
|
|