Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
a8b7961f
Commit
a8b7961f
authored
Aug 20, 2021
by
Eric Rosenbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alerts default to 6 seconds
parent
872737ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
src/components/alert/alert-provider.jsx
src/components/alert/alert-provider.jsx
+5
-3
No files found.
src/components/alert/alert-provider.jsx
View file @
a8b7961f
...
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
...
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
import
AlertStatus
from
'
./alert-status.js
'
;
import
AlertStatus
from
'
./alert-status.js
'
;
import
AlertContext
from
'
./alert-context.js
'
;
import
AlertContext
from
'
./alert-context.js
'
;
const
DEFAULT_TIMEOUT_SECONDS
=
6
;
const
AlertProvider
=
({
children
})
=>
{
const
AlertProvider
=
({
children
})
=>
{
const
defaultState
=
{
const
defaultState
=
{
status
:
AlertStatus
.
NONE
,
status
:
AlertStatus
.
NONE
,
...
@@ -19,7 +21,7 @@ const AlertProvider = ({children}) => {
...
@@ -19,7 +21,7 @@ const AlertProvider = ({children}) => {
setState
(
defaultState
);
setState
(
defaultState
);
};
};
const
handleAlert
=
(
status
,
data
,
timeoutSeconds
=
3
)
=>
{
const
handleAlert
=
(
status
,
data
,
timeoutSeconds
=
DEFAULT_TIMEOUT_SECONDS
)
=>
{
if
(
timeoutRef
.
current
)
clearTimeout
(
timeoutRef
.
current
);
if
(
timeoutRef
.
current
)
clearTimeout
(
timeoutRef
.
current
);
setState
({
status
,
data
,
showClear
:
!
timeoutSeconds
});
setState
({
status
,
data
,
showClear
:
!
timeoutSeconds
});
if
(
timeoutSeconds
)
{
if
(
timeoutSeconds
)
{
...
@@ -37,9 +39,9 @@ const AlertProvider = ({children}) => {
...
@@ -37,9 +39,9 @@ const AlertProvider = ({children}) => {
data
:
state
.
data
,
data
:
state
.
data
,
showClear
:
state
.
showClear
,
showClear
:
state
.
showClear
,
clearAlert
:
clearAlert
,
clearAlert
:
clearAlert
,
successAlert
:
(
newData
,
timeoutSeconds
=
3
)
=>
successAlert
:
(
newData
,
timeoutSeconds
=
DEFAULT_TIMEOUT_SECONDS
)
=>
handleAlert
(
AlertStatus
.
SUCCESS
,
newData
,
timeoutSeconds
),
handleAlert
(
AlertStatus
.
SUCCESS
,
newData
,
timeoutSeconds
),
errorAlert
:
(
newData
,
timeoutSeconds
=
3
)
=>
errorAlert
:
(
newData
,
timeoutSeconds
=
DEFAULT_TIMEOUT_SECONDS
)
=>
handleAlert
(
AlertStatus
.
ERROR
,
newData
,
timeoutSeconds
)
handleAlert
(
AlertStatus
.
ERROR
,
newData
,
timeoutSeconds
)
}
}
}
}
>
>
...
...
Write
Preview
Markdown
is supported
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