Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
5f1a54c3
Verified
Commit
5f1a54c3
authored
Apr 12, 2020
by
Florent Chehab
Browse files
fix(front): restored pending moderation
* can now moderate again * display pending moderation data correctly Closes
#183
parent
d2e97741
Changes
4
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/edition/Editor.jsx
View file @
5f1a54c3
...
...
@@ -42,6 +42,14 @@ class Editor extends React.Component {
props
.
subscribeToModuleWrapper
(
this
);
}
componentDidMount
()
{
const
{
saveOnMount
}
=
this
.
props
;
// handle moderation request
if
(
saveOnMount
)
{
this
.
performSave
(
this
.
parseRawModelData
(
this
.
props
.
rawModelData
));
}
}
/**
* Function that extracts the modelData from the raw one.
*
...
...
@@ -234,7 +242,7 @@ Editor.propTypes = {
lastUpdateTimeInModel
:
PropTypes
.
string
,
hasPendingModeration
:
PropTypes
.
bool
,
saveData
:
PropTypes
.
func
.
isRequired
,
saveOnMount
:
PropTypes
.
bool
.
isRequired
,
// should we save the data on editor mount (useful when trying to moderate)
Form
:
PropTypes
.
func
.
isRequired
,
// Components with the fields
formLevelErrors
:
PropTypes
.
array
,
license
:
PropTypes
.
string
,
...
...
frontend/src/components/edition/PendingModeration.jsx
View file @
5f1a54c3
...
...
@@ -14,6 +14,7 @@ import withNetworkWrapper, {
NetWrapParam
}
from
"
../../hoc/withNetworkWrapper
"
;
import
{
useApiInvalidateAll
}
from
"
../../hooks/wrappers/api
"
;
import
useOnComponentUnMount
from
"
../../hooks/useOnComponentUnMount
"
;
const
useStyles
=
makeStyles
(
theme
=>
({
editButton
:
{
...
...
@@ -71,7 +72,6 @@ function PendingModeration({
api
,
modelInfo
,
pendingModeration
,
moderatePendingModeration
,
editFromPendingModeration
,
renderTitle
,
renderCore
,
...
...
@@ -79,9 +79,9 @@ function PendingModeration({
})
{
const
resetData
=
useApiInvalidateAll
(
"
pendingModerationObj
"
);
use
Effec
t
(()
=>
{
return
()
=>
resetData
();
}
,
[]
);
use
OnComponentUnMoun
t
(()
=>
{
resetData
();
});
// keep the component up to date
useEffect
(()
=>
{
...
...
@@ -89,14 +89,15 @@ function PendingModeration({
},
[
modelInfo
]);
const
pendingModelData
=
useMemo
(()
=>
{
const
pending
=
pendingModeration
[
0
];
return
{
...
pending
Moderation
.
new_object
,
id
:
pending
Moderation
.
object_id
...
pending
.
new_object
,
id
:
pending
.
object_id
};
},
[
pendingModeration
]);
const
moderate
=
useCallback
(()
=>
{
moderate
PendingModeration
(
pendingModelData
);
editFrom
PendingModeration
(
pendingModelData
,
true
);
// open editor and auto save
},
[
pendingModelData
]);
const
editFromPending
=
useCallback
(()
=>
{
...
...
@@ -127,9 +128,8 @@ PendingModeration.propTypes = {
id
:
PropTypes
.
number
.
isRequired
}).
isRequired
,
editFromPendingModeration
:
PropTypes
.
func
.
isRequired
,
moderatePendingModeration
:
PropTypes
.
func
.
isRequired
,
userCanModerate
:
PropTypes
.
bool
.
isRequired
,
pendingModeration
:
PropTypes
.
object
.
isRequired
,
pendingModeration
:
PropTypes
.
array
.
isRequired
,
renderTitle
:
PropTypes
.
func
.
isRequired
,
renderCore
:
PropTypes
.
func
.
isRequired
,
api
:
getApiPropTypes
(
"
pendingModeration
"
).
isRequired
...
...
frontend/src/components/university/modules/common/ModuleWrapper.jsx
View file @
5f1a54c3
...
...
@@ -105,8 +105,6 @@ function ModuleWrapper({
id
:
rawModelData
.
id
}
}
editFromPendingModeration
=
{
openEditorTmp
}
// TODO Repare pending moderation validation
moderatePendingModeration
=
{
()
=>
{}
}
userCanModerate
=
{
rawModelData
.
obj_info
.
user_can_moderate
}
/>
);
...
...
frontend/src/hooks/useEditor.jsx
View file @
5f1a54c3
...
...
@@ -13,7 +13,7 @@ import useEditorState from "./wrappers/useEditorState";
*/
function
useEditor
(
formInfo
,
onClose
=
()
=>
{})
{
// Returns a callback that opens an editor correctly configured
return
useCallback
(
modelData
=>
{
return
useCallback
(
(
modelData
,
saveOnMount
=
false
)
=>
{
const
{
route
,
license
,
Form
,
formLevelErrors
}
=
formInfo
;
const
InternalEditor
=
React
.
memo
(()
=>
{
...
...
@@ -33,6 +33,7 @@ function useEditor(formInfo, onClose = () => {}) {
rawModelData
=
{
modelData
}
// state api related
saveData
=
{
saveData
}
saveOnMount
=
{
saveOnMount
}
clearSaveError
=
{
clearSaveError
}
savingHasError
=
{
savingHasError
}
lastUpdateTimeInModel
=
{
lastUpdateTimeInModel
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment