Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
editoria
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yannis Barlas
editoria
Commits
7b0f883c
Commit
7b0f883c
authored
8 years ago
by
chris
Committed by
john
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: on page refresh editor no longer crashes
parent
5078c76c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/components/SimpleEditor/SimpleEditor.jsx
+47
-8
47 additions, 8 deletions
app/components/SimpleEditor/SimpleEditor.jsx
app/components/SimpleEditor/SimpleEditorWrapper.jsx
+4
-27
4 additions, 27 deletions
app/components/SimpleEditor/SimpleEditorWrapper.jsx
with
51 additions
and
35 deletions
app/components/SimpleEditor/SimpleEditor.jsx
+
47
−
8
View file @
7b0f883c
...
@@ -19,6 +19,18 @@ export default class SimpleEditor extends React.Component {
...
@@ -19,6 +19,18 @@ export default class SimpleEditor extends React.Component {
super
(
props
)
super
(
props
)
this
.
save
=
this
.
save
.
bind
(
this
)
this
.
save
=
this
.
save
.
bind
(
this
)
this
.
updateTrackChangesStatus
=
this
.
updateTrackChangesStatus
.
bind
(
this
)
this
.
updateTrackChangesStatus
=
this
.
updateTrackChangesStatus
.
bind
(
this
)
this
.
_checkRights
=
this
.
_checkRights
.
bind
(
this
)
this
.
state
=
{
canEdit
:
false
}
}
componentWillMount
()
{
const
{
fragment
}
=
this
.
props
if
(
fragment
)
{
this
.
_checkRights
()
// this._acquireLock()
}
}
}
createSession
()
{
createSession
()
{
...
@@ -59,15 +71,45 @@ export default class SimpleEditor extends React.Component {
...
@@ -59,15 +71,45 @@ export default class SimpleEditor extends React.Component {
onSave
(
convertedSource
,
callback
)
onSave
(
convertedSource
,
callback
)
}
}
_checkRights
()
{
const
{
fragment
,
user
}
=
this
.
props
if
(
user
.
admin
)
return
this
.
setState
({
canEdit
:
true
})
if
((
fragment
.
progress
[
'
review
'
]
===
1
&&
user
.
teams
[
0
].
teamType
.
name
===
'
Author
'
)
||
(
fragment
.
progress
[
'
edit
'
]
===
1
&&
user
.
teams
[
0
].
teamType
.
name
===
'
Copy Editor
'
))
{
this
.
setState
({
canEdit
:
true
})
}
else
{
this
.
setState
({
canEdit
:
false
})
}
if
(
user
.
teams
[
0
].
teamType
.
name
===
'
Production Editor
'
)
{
this
.
setState
({
canEdit
:
true
})
}
}
componentWillReceiveProps
(
nextProps
)
{
const
{
fragment
}
=
this
.
props
if
(
fragment
)
return
var
self
=
this
if
(
nextProps
.
fragment
)
{
setTimeout
(
function
()
{
self
.
_checkRights
()
self
.
componentDidMount
()
},
0
)
}
}
componentDidMount
()
{
componentDidMount
()
{
const
{
canEdit
}
=
this
.
props
const
{
onSave
}
=
this
.
props
const
{
onSave
}
=
this
.
props
const
el
=
ReactDOM
.
findDOMNode
(
this
)
const
el
=
ReactDOM
.
findDOMNode
(
this
)
const
{
fragment
}
=
this
.
props
const
session
=
this
.
createSession
()
const
session
=
this
.
createSession
()
const
documentSession
=
session
.
documentSession
const
documentSession
=
session
.
documentSession
const
configurator
=
session
.
configurator
const
configurator
=
session
.
configurator
if
(
!
fragment
)
return
this
.
setState
({
this
.
setState
({
config
:
configurator
.
config
config
:
configurator
.
config
})
})
...
@@ -76,7 +118,7 @@ export default class SimpleEditor extends React.Component {
...
@@ -76,7 +118,7 @@ export default class SimpleEditor extends React.Component {
book
:
this
.
props
.
book
,
book
:
this
.
props
.
book
,
configurator
:
configurator
,
configurator
:
configurator
,
containerId
:
'
body
'
,
containerId
:
'
body
'
,
disabled
:
!
canEdit
,
// set to true read only mode
disabled
:
!
this
.
state
.
canEdit
,
// set to true read only mode
documentSession
:
documentSession
,
documentSession
:
documentSession
,
fileUpload
:
this
.
props
.
fileUpload
,
fileUpload
:
this
.
props
.
fileUpload
,
fragment
:
this
.
props
.
fragment
,
fragment
:
this
.
props
.
fragment
,
...
@@ -110,9 +152,7 @@ export default class SimpleEditor extends React.Component {
...
@@ -110,9 +152,7 @@ export default class SimpleEditor extends React.Component {
// }
// }
render
()
{
render
()
{
const
{
canEdit
}
=
this
.
props
let
viewMode
=
!
this
.
state
.
canEdit
let
viewMode
=
!
canEdit
?
(
?
(
<
Alert
bsStyle
=
'warning'
className
=
'view-mode'
>
<
Alert
bsStyle
=
'warning'
className
=
'view-mode'
>
<
span
>
Editor is in Read-Only Mode
</
span
>
<
span
>
Editor is in Read-Only Mode
</
span
>
...
@@ -131,10 +171,9 @@ export default class SimpleEditor extends React.Component {
...
@@ -131,10 +171,9 @@ export default class SimpleEditor extends React.Component {
SimpleEditor
.
propTypes
=
{
SimpleEditor
.
propTypes
=
{
book
:
React
.
PropTypes
.
object
.
isRequired
,
book
:
React
.
PropTypes
.
object
.
isRequired
,
canEdit
:
React
.
PropTypes
.
bool
,
canEdit
:
React
.
PropTypes
.
bool
,
fragment
:
React
.
PropTypes
.
object
.
isRequired
,
fragment
:
React
.
PropTypes
.
object
,
history
:
React
.
PropTypes
.
object
.
isRequired
,
history
:
React
.
PropTypes
.
object
.
isRequired
,
onSave
:
React
.
PropTypes
.
func
.
isRequired
,
onSave
:
React
.
PropTypes
.
func
.
isRequired
,
trackChanges
:
React
.
PropTypes
.
bool
.
isRequired
,
update
:
React
.
PropTypes
.
func
.
isRequired
,
update
:
React
.
PropTypes
.
func
.
isRequired
,
updateComments
:
React
.
PropTypes
.
func
.
isRequired
,
updateComments
:
React
.
PropTypes
.
func
.
isRequired
,
fileUpload
:
React
.
PropTypes
.
func
.
isRequired
,
fileUpload
:
React
.
PropTypes
.
func
.
isRequired
,
...
...
This diff is collapsed.
Click to expand it.
app/components/SimpleEditor/SimpleEditorWrapper.jsx
+
4
−
27
View file @
7b0f883c
...
@@ -16,7 +16,6 @@ export class SimpleEditorWrapper extends React.Component {
...
@@ -16,7 +16,6 @@ export class SimpleEditorWrapper extends React.Component {
this
.
updateComments
=
this
.
updateComments
.
bind
(
this
)
this
.
updateComments
=
this
.
updateComments
.
bind
(
this
)
this
.
fileUpload
=
this
.
fileUpload
.
bind
(
this
)
this
.
fileUpload
=
this
.
fileUpload
.
bind
(
this
)
this
.
_checkRights
=
this
.
_checkRights
.
bind
(
this
)
this
.
_releaseLock
=
this
.
_releaseLock
.
bind
(
this
)
this
.
_releaseLock
=
this
.
_releaseLock
.
bind
(
this
)
this
.
_acquireLock
=
this
.
_acquireLock
.
bind
(
this
)
this
.
_acquireLock
=
this
.
_acquireLock
.
bind
(
this
)
...
@@ -35,8 +34,8 @@ export class SimpleEditorWrapper extends React.Component {
...
@@ -35,8 +34,8 @@ export class SimpleEditorWrapper extends React.Component {
const
{
user
}
=
this
.
props
const
{
user
}
=
this
.
props
user
.
roles
=
this
.
getRoles
()
user
.
roles
=
this
.
getRoles
()
this
.
_checkRights
()
//
this._checkRights()
this
.
_acquireLock
()
//
this._acquireLock()
}
}
componentDidMount
()
{
componentDidMount
()
{
...
@@ -70,28 +69,6 @@ export class SimpleEditorWrapper extends React.Component {
...
@@ -70,28 +69,6 @@ export class SimpleEditorWrapper extends React.Component {
updateFragment
(
book
,
fragment
)
updateFragment
(
book
,
fragment
)
}
}
// componentDidUpdate () {
// console.log('did update wrapper')
// // this._checkRights()
// }
// TODO -- refactor
_checkRights
()
{
const
{
fragment
,
user
}
=
this
.
props
if
(
user
.
admin
)
return
this
.
setState
({
canEdit
:
true
})
if
((
fragment
.
progress
[
'
review
'
]
===
1
&&
user
.
teams
[
0
].
teamType
.
name
===
'
Author
'
)
||
(
fragment
.
progress
[
'
edit
'
]
===
1
&&
user
.
teams
[
0
].
teamType
.
name
===
'
Copy Editor
'
))
{
this
.
setState
({
canEdit
:
true
})
}
else
{
this
.
setState
({
canEdit
:
false
})
}
if
(
user
.
teams
[
0
].
teamType
.
name
===
'
Production Editor
'
)
{
this
.
setState
({
canEdit
:
true
})
}
}
save
(
source
,
callback
)
{
save
(
source
,
callback
)
{
const
{
book
,
fragment
}
=
this
.
props
const
{
book
,
fragment
}
=
this
.
props
const
{
updateFragment
}
=
this
.
props
.
actions
const
{
updateFragment
}
=
this
.
props
.
actions
...
@@ -173,10 +150,10 @@ export class SimpleEditorWrapper extends React.Component {
...
@@ -173,10 +150,10 @@ export class SimpleEditorWrapper extends React.Component {
SimpleEditorWrapper
.
propTypes
=
{
SimpleEditorWrapper
.
propTypes
=
{
actions
:
React
.
PropTypes
.
object
.
isRequired
,
actions
:
React
.
PropTypes
.
object
.
isRequired
,
book
:
React
.
PropTypes
.
object
.
isRequired
,
book
:
React
.
PropTypes
.
object
.
isRequired
,
fragment
:
React
.
PropTypes
.
object
.
isRequired
,
fragment
:
React
.
PropTypes
.
object
,
history
:
React
.
PropTypes
.
object
.
isRequired
,
history
:
React
.
PropTypes
.
object
.
isRequired
,
user
:
React
.
PropTypes
.
object
.
isRequired
,
user
:
React
.
PropTypes
.
object
.
isRequired
,
update
:
React
.
PropTypes
.
func
.
isRequired
update
:
React
.
PropTypes
.
func
}
}
function
mapStateToProps
(
state
,
ownProps
)
{
function
mapStateToProps
(
state
,
ownProps
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment