Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
966053b8
Commit
966053b8
authored
6 years ago
by
Ben Wheeler
Browse files
Options
Downloads
Patches
Plain Diff
added timeout reducer
parent
c326e3f0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lib/project-saver-hoc.jsx
+11
-9
11 additions, 9 deletions
src/lib/project-saver-hoc.jsx
src/reducers/gui.js
+3
-0
3 additions, 0 deletions
src/reducers/gui.js
src/reducers/timeout.js
+27
-0
27 additions, 0 deletions
src/reducers/timeout.js
with
41 additions
and
9 deletions
src/lib/project-saver-hoc.jsx
+
11
−
9
View file @
966053b8
...
...
@@ -10,6 +10,7 @@ import {
showAlertWithTimeout
,
showStandardAlert
}
from
'
../reducers/alerts
'
;
import
{
setAutoSaveTimeoutId
}
from
'
../reducers/timeout
'
;
import
{
setProjectUnchanged
}
from
'
../reducers/project-changed
'
;
import
{
LoadingStates
,
...
...
@@ -43,9 +44,6 @@ const ProjectSaverHOC = function (WrappedComponent) {
bindAll
(
this
,
[
'
tryToAutoSave
'
]);
this
.
state
=
{
autoSaveTimeoutId
:
null
};
}
componentDidUpdate
(
prevProps
)
{
if
(
this
.
props
.
projectChanged
&&
!
prevProps
.
projectChanged
)
{
...
...
@@ -88,16 +86,16 @@ const ProjectSaverHOC = function (WrappedComponent) {
this
.
clearAutoSaveTimeout
();
}
clearAutoSaveTimeout
()
{
if
(
this
.
state
.
autoSaveTimeoutId
!==
null
)
{
clearTimeout
(
this
.
state
.
autoSaveTimeoutId
);
this
.
setState
({
a
utoSaveTimeoutId
:
null
}
);
if
(
this
.
props
.
autoSaveTimeoutId
!==
null
)
{
clearTimeout
(
this
.
props
.
autoSaveTimeoutId
);
this
.
props
.
setA
utoSaveTimeoutId
(
null
);
}
}
scheduleAutoSave
()
{
if
(
this
.
props
.
isShowingSaveable
&&
this
.
state
.
autoSaveTimeoutId
===
null
)
{
if
(
this
.
props
.
isShowingSaveable
&&
this
.
props
.
autoSaveTimeoutId
===
null
)
{
const
timeoutId
=
setTimeout
(
this
.
tryToAutoSave
,
this
.
props
.
autosaveIntervalSecs
*
1000
);
this
.
setState
({
a
utoSaveTimeoutId
:
timeoutId
}
);
this
.
props
.
setA
utoSaveTimeoutId
(
timeoutId
);
}
}
tryToAutoSave
()
{
...
...
@@ -237,6 +235,7 @@ const ProjectSaverHOC = function (WrappedComponent) {
onUpdatedProject
,
reduxProjectId
,
reduxProjectTitle
,
setAutoSaveTimeoutId
:
setAutoSaveTimeoutIdProp
,
/* eslint-enable no-unused-vars */
...
componentProps
}
=
this
.
props
;
...
...
@@ -249,6 +248,7 @@ const ProjectSaverHOC = function (WrappedComponent) {
}
ProjectSaverComponent
.
propTypes
=
{
autoSaveTimeoutId
:
PropTypes
.
number
,
canCreateNew
:
PropTypes
.
bool
,
canSave
:
PropTypes
.
bool
,
isCreatingCopy
:
PropTypes
.
bool
,
...
...
@@ -283,6 +283,7 @@ const ProjectSaverHOC = function (WrappedComponent) {
const
loadingState
=
state
.
scratchGui
.
projectState
.
loadingState
;
const
isShowingWithId
=
getIsShowingWithId
(
loadingState
);
return
{
autoSaveTimeoutId
:
state
.
scratchGui
.
timeout
.
autoSaveTimeoutId
,
isCreatingCopy
:
getIsCreatingCopy
(
loadingState
),
isCreatingNew
:
getIsCreatingNew
(
loadingState
),
isRemixing
:
getIsRemixing
(
loadingState
),
...
...
@@ -309,7 +310,8 @@ const ProjectSaverHOC = function (WrappedComponent) {
onShowCreatingAlert
:
()
=>
showAlertWithTimeout
(
dispatch
,
'
creating
'
),
onShowSaveSuccessAlert
:
()
=>
showAlertWithTimeout
(
dispatch
,
'
saveSuccess
'
),
onShowSavingAlert
:
()
=>
showAlertWithTimeout
(
dispatch
,
'
saving
'
),
onUpdatedProject
:
(
projectId
,
loadingState
)
=>
dispatch
(
doneUpdatingProject
(
projectId
,
loadingState
))
onUpdatedProject
:
(
projectId
,
loadingState
)
=>
dispatch
(
doneUpdatingProject
(
projectId
,
loadingState
)),
setAutoSaveTimeoutId
:
id
=>
dispatch
(
setAutoSaveTimeoutId
(
id
))
});
// Allow incoming props to override redux-provided props. Used to mock in tests.
const
mergeProps
=
(
stateProps
,
dispatchProps
,
ownProps
)
=>
Object
.
assign
(
...
...
This diff is collapsed.
Click to expand it.
src/reducers/gui.js
+
3
−
0
View file @
966053b8
...
...
@@ -20,6 +20,7 @@ import projectTitleReducer, {projectTitleInitialState} from './project-title';
import
restoreDeletionReducer
,
{
restoreDeletionInitialState
}
from
'
./restore-deletion
'
;
import
stageSizeReducer
,
{
stageSizeInitialState
}
from
'
./stage-size
'
;
import
targetReducer
,
{
targetsInitialState
}
from
'
./targets
'
;
import
timeoutReducer
,
{
timeoutInitialState
}
from
'
./timeout
'
;
import
toolboxReducer
,
{
toolboxInitialState
}
from
'
./toolbox
'
;
import
vmReducer
,
{
vmInitialState
}
from
'
./vm
'
;
import
vmStatusReducer
,
{
vmStatusInitialState
}
from
'
./vm-status
'
;
...
...
@@ -51,6 +52,7 @@ const guiInitialState = {
projectTitle
:
projectTitleInitialState
,
restoreDeletion
:
restoreDeletionInitialState
,
targets
:
targetsInitialState
,
timeout
:
timeoutInitialState
,
toolbox
:
toolboxInitialState
,
vm
:
vmInitialState
,
vmStatus
:
vmStatusInitialState
...
...
@@ -129,6 +131,7 @@ const guiReducer = combineReducers({
projectTitle
:
projectTitleReducer
,
restoreDeletion
:
restoreDeletionReducer
,
targets
:
targetReducer
,
timeout
:
timeoutReducer
,
toolbox
:
toolboxReducer
,
vm
:
vmReducer
,
vmStatus
:
vmStatusReducer
...
...
This diff is collapsed.
Click to expand it.
src/reducers/timeout.js
0 → 100644
+
27
−
0
View file @
966053b8
const
SET_AUTOSAVE_TIMEOUT_ID
=
'
projectTitle/SET_AUTOSAVE_TIMEOUT_ID
'
;
const
initialState
=
{
autoSaveTimeoutId
:
null
};
const
reducer
=
function
(
state
,
action
)
{
if
(
typeof
state
===
'
undefined
'
)
state
=
initialState
;
switch
(
action
.
type
)
{
case
SET_AUTOSAVE_TIMEOUT_ID
:
return
Object
.
assign
({},
state
,
{
autoSaveTimeoutId
:
action
.
id
});
default
:
return
state
;
}
};
const
setAutoSaveTimeoutId
=
id
=>
({
type
:
SET_AUTOSAVE_TIMEOUT_ID
,
id
});
export
{
reducer
as
default
,
initialState
as
timeoutInitialState
,
setAutoSaveTimeoutId
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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