Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Paul Walko
funkwhale
Commits
a443f943
Verified
Commit
a443f943
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
See #190: now store sidebar notifications in vuex store
parent
b3fcc421
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
front/src/components/Sidebar.vue
+10
-38
10 additions, 38 deletions
front/src/components/Sidebar.vue
front/src/store/ui.js
+27
-1
27 additions, 1 deletion
front/src/store/ui.js
with
37 additions
and
39 deletions
front/src/components/Sidebar.vue
+
10
−
38
View file @
a443f943
...
...
@@ -58,21 +58,16 @@
<
div
class
=
"
item
"
v
-
if
=
"
showAdmin
"
>
<
div
class
=
"
header
"
>
{{
$t
(
'
Administration
'
)
}}
<
/div
>
<
div
class
=
"
menu
"
>
<
router
-
link
class
=
"
item
"
v
-
if
=
"
$store.state.auth.availablePermissions['library']
"
:
to
=
"
{name: 'library.requests', query: {status: 'pending'
}}
"
>
<
i
class
=
"
download icon
"
><
/i>{{ $t
(
'Import requests'
)
}}
<
div
:
class
=
"
['ui', {'teal': notifications.importRequests > 0
}
, 'label']
"
:
title
=
"
$t('Pending import requests')
"
>
{{
notifications
.
importRequests
}}
<
/div
>
<
/router-link
>
<
router
-
link
class
=
"
item
"
v
-
if
=
"
$store.state.auth.availablePermissions['library']
"
:
to
=
"
{name: 'manage.library.files'
}
"
>
<
i
class
=
"
book icon
"
><
/i>{{ $t
(
'Library'
)
}}
<
div
:
class
=
"
['ui', {'teal': $store.state.ui.notifications.importRequests > 0
}
, 'label']
"
:
title
=
"
$t('Pending import requests')
"
>
{{
$store
.
state
.
ui
.
notifications
.
importRequests
}}
<
/div
>
<
/router-link
>
<
router
-
link
class
=
"
item
"
...
...
@@ -86,9 +81,9 @@
:
to
=
"
{path: '/manage/federation/libraries'
}
"
>
<
i
class
=
"
sitemap icon
"
><
/i>{{ $t
(
'Federation'
)
}}
<
div
:
class
=
"
['ui', {'teal': notifications.federation > 0
}
, 'label']
"
:
class
=
"
['ui', {'teal':
$store.state.ui.
notifications.federation > 0
}
, 'label']
"
:
title
=
"
$t('Pending follow requests')
"
>
{{
notifications
.
federation
}}
<
/div
>
{{
$store
.
state
.
ui
.
notifications
.
federation
}}
<
/div
>
<
/router-link
>
<
router
-
link
class
=
"
item
"
...
...
@@ -160,7 +155,6 @@
<
script
>
import
{
mapState
,
mapActions
}
from
'
vuex
'
import
axios
from
'
axios
'
import
Player
from
'
@/components/audio/Player
'
import
Logo
from
'
@/components/Logo
'
...
...
@@ -183,11 +177,7 @@ export default {
selectedTab
:
'
library
'
,
backend
:
backend
,
isCollapsed
:
true
,
fetchInterval
:
null
,
notifications
:
{
federation
:
0
,
importRequests
:
0
}
fetchInterval
:
null
}
}
,
mounted
()
{
...
...
@@ -224,26 +214,8 @@ export default {
cleanTrack
:
'
queue/cleanTrack
'
}
),
fetchNotificationsCount
()
{
this
.
fetchFederationNotificationsCount
()
this
.
fetchFederationImportRequestsCount
()
}
,
fetchFederationNotificationsCount
()
{
if
(
!
this
.
$store
.
state
.
auth
.
availablePermissions
[
'
federation
'
])
{
return
}
let
self
=
this
axios
.
get
(
'
federation/libraries/followers/
'
,
{
params
:
{
pending
:
true
}}
).
then
(
response
=>
{
self
.
notifications
.
federation
=
response
.
data
.
count
}
)
}
,
fetchFederationImportRequestsCount
()
{
if
(
!
this
.
$store
.
state
.
auth
.
availablePermissions
[
'
library
'
])
{
return
}
let
self
=
this
axios
.
get
(
'
requests/import-requests/
'
,
{
params
:
{
status
:
'
pending
'
}}
).
then
(
response
=>
{
self
.
notifications
.
importRequests
=
response
.
data
.
count
}
)
this
.
$store
.
dispatch
(
'
ui/fetchFederationNotificationsCount
'
)
this
.
$store
.
dispatch
(
'
ui/fetchImportRequestsCount
'
)
}
,
reorder
:
function
(
event
)
{
this
.
$store
.
commit
(
'
queue/reorder
'
,
{
...
...
This diff is collapsed.
Click to expand it.
front/src/store/ui.js
+
27
−
1
View file @
a443f943
import
axios
from
'
axios
'
export
default
{
namespaced
:
true
,
...
...
@@ -5,7 +6,11 @@ export default {
lastDate
:
new
Date
(),
maxMessages
:
100
,
messageDisplayDuration
:
10000
,
messages
:
[]
messages
:
[],
notifications
:
{
federation
:
0
,
importRequests
:
0
}
},
mutations
:
{
computeLastDate
:
(
state
)
=>
{
...
...
@@ -16,6 +21,27 @@ export default {
if
(
state
.
messages
.
length
>
state
.
maxMessages
)
{
state
.
messages
.
shift
()
}
},
notifications
(
state
,
{
type
,
count
})
{
state
.
notifications
[
type
]
=
count
}
},
actions
:
{
fetchFederationNotificationsCount
({
rootState
,
commit
})
{
if
(
!
rootState
.
auth
.
availablePermissions
[
'
federation
'
])
{
return
}
axios
.
get
(
'
federation/libraries/followers/
'
,
{
params
:
{
pending
:
true
}}).
then
(
response
=>
{
commit
(
'
notifications
'
,
{
type
:
'
federation
'
,
count
:
response
.
data
.
count
})
})
},
fetchImportRequestsCount
({
rootState
,
commit
})
{
if
(
!
rootState
.
auth
.
availablePermissions
[
'
library
'
])
{
return
}
axios
.
get
(
'
requests/import-requests/
'
,
{
params
:
{
status
:
'
pending
'
}}).
then
(
response
=>
{
commit
(
'
notifications
'
,
{
type
:
'
importRequests
'
,
count
:
response
.
data
.
count
})
})
}
}
}
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