Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
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
Package Registry
Container 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
Dima Krasner
Sharkey
Commits
71e58923
Commit
71e58923
authored
4 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
refactor(client): Use getters to avoid watch vuex
parent
a1597047
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/client/app.ts
+0
-109
0 additions, 109 deletions
src/client/app.ts
src/client/app.vue
+4
-22
4 additions, 22 deletions
src/client/app.vue
src/client/pages/preferences/sidebar.vue
+1
-2
1 addition, 2 deletions
src/client/pages/preferences/sidebar.vue
src/client/store.ts
+107
-0
107 additions, 0 deletions
src/client/store.ts
with
112 additions
and
133 deletions
src/client/app.ts
deleted
100644 → 0
+
0
−
109
View file @
a1597047
import
{
faTerminal
,
faHashtag
,
faBroadcastTower
,
faFireAlt
,
faSearch
,
faStar
,
faAt
,
faListUl
,
faUserClock
,
faUsers
,
faCloud
,
faGamepad
,
faFileAlt
,
faSatellite
}
from
'
@fortawesome/free-solid-svg-icons
'
;
import
{
faBell
,
faEnvelope
,
faComments
}
from
'
@fortawesome/free-regular-svg-icons
'
;
export
function
createMenuDef
(
actions
)
{
return
{
notifications
:
{
title
:
'
notifications
'
,
icon
:
faBell
,
show
:
store
=>
store
.
getters
.
isSignedIn
,
indicate
:
store
=>
store
.
getters
.
isSignedIn
&&
store
.
state
.
i
.
hasUnreadNotification
,
to
:
'
/my/notifications
'
,
},
messaging
:
{
title
:
'
messaging
'
,
icon
:
faComments
,
show
:
store
=>
store
.
getters
.
isSignedIn
,
indicate
:
store
=>
store
.
getters
.
isSignedIn
&&
store
.
state
.
i
.
hasUnreadMessagingMessage
,
to
:
'
/my/messaging
'
,
},
drive
:
{
title
:
'
drive
'
,
icon
:
faCloud
,
show
:
store
=>
store
.
getters
.
isSignedIn
,
to
:
'
/my/drive
'
,
},
followRequests
:
{
title
:
'
followRequests
'
,
icon
:
faUserClock
,
show
:
store
=>
store
.
getters
.
isSignedIn
&&
store
.
state
.
i
.
isLocked
,
indicate
:
store
=>
store
.
getters
.
isSignedIn
&&
store
.
state
.
i
.
hasPendingReceivedFollowRequest
,
to
:
'
/my/follow-requests
'
,
},
featured
:
{
title
:
'
featured
'
,
icon
:
faFireAlt
,
to
:
'
/featured
'
,
},
explore
:
{
title
:
'
explore
'
,
icon
:
faHashtag
,
to
:
'
/explore
'
,
},
announcements
:
{
title
:
'
announcements
'
,
icon
:
faBroadcastTower
,
indicate
:
store
=>
store
.
getters
.
isSignedIn
&&
store
.
state
.
i
.
hasUnreadAnnouncement
,
to
:
'
/announcements
'
,
},
search
:
{
title
:
'
search
'
,
icon
:
faSearch
,
action
:
()
=>
actions
.
search
(),
},
lists
:
{
title
:
'
lists
'
,
icon
:
faListUl
,
show
:
store
=>
store
.
getters
.
isSignedIn
,
to
:
'
/my/lists
'
,
},
groups
:
{
title
:
'
groups
'
,
icon
:
faUsers
,
show
:
store
=>
store
.
getters
.
isSignedIn
,
to
:
'
/my/groups
'
,
},
antennas
:
{
title
:
'
antennas
'
,
icon
:
faSatellite
,
show
:
store
=>
store
.
getters
.
isSignedIn
,
to
:
'
/my/antennas
'
,
},
mentions
:
{
title
:
'
mentions
'
,
icon
:
faAt
,
show
:
store
=>
store
.
getters
.
isSignedIn
,
indicate
:
store
=>
store
.
getters
.
isSignedIn
&&
store
.
state
.
i
.
hasUnreadMentions
,
to
:
'
/my/mentions
'
,
},
messages
:
{
title
:
'
directNotes
'
,
icon
:
faEnvelope
,
show
:
store
=>
store
.
getters
.
isSignedIn
,
indicate
:
store
=>
store
.
getters
.
isSignedIn
&&
store
.
state
.
i
.
hasUnreadSpecifiedNotes
,
to
:
'
/my/messages
'
,
},
favorites
:
{
title
:
'
favorites
'
,
icon
:
faStar
,
show
:
store
=>
store
.
getters
.
isSignedIn
,
to
:
'
/my/favorites
'
,
},
pages
:
{
title
:
'
pages
'
,
icon
:
faFileAlt
,
show
:
store
=>
store
.
getters
.
isSignedIn
,
to
:
'
/my/pages
'
,
},
games
:
{
title
:
'
games
'
,
icon
:
faGamepad
,
to
:
'
/games
'
,
},
scratchpad
:
{
title
:
'
scratchpad
'
,
icon
:
faTerminal
,
to
:
'
/scratchpad
'
,
},
};
}
This diff is collapsed.
Click to expand it.
src/client/app.vue
+
4
−
22
View file @
71e58923
...
...
@@ -51,7 +51,7 @@
</router-link>
<template
v-for=
"item in menu"
>
<div
v-if=
"item === '-'"
class=
"divider"
></div>
<component
v-else-if=
"menuDef[item].
display
!== false"
:is=
"menuDef[item].to ? 'router-link' : 'button'"
class=
"item _button"
:class=
"item"
active-class=
"active"
@
click=
"() =>
{ if (menuDef[item].action) menuDef[item].action() }" :to="menuDef[item].to">
<component
v-else-if=
"menuDef[item].
show
!== false"
:is=
"menuDef[item].to ? 'router-link' : 'button'"
class=
"item _button"
:class=
"item"
active-class=
"active"
@
click=
"() =>
{ if (menuDef[item].action) menuDef[item].action() }" :to="menuDef[item].to">
<fa
:icon=
"menuDef[item].icon"
fixed-width
/><span
class=
"text"
>
{{
$t
(
menuDef
[
item
].
title
)
}}
</span>
<i
v-if=
"menuDef[item].indicated"
><fa
:icon=
"faCircle"
/></i>
</component>
...
...
@@ -139,7 +139,6 @@ import { v4 as uuid } from 'uuid';
import
i18n
from
'
./i18n
'
;
import
{
host
,
instanceName
}
from
'
./config
'
;
import
{
search
}
from
'
./scripts/search
'
;
import
{
createMenuDef
}
from
'
./app
'
;
const
DESKTOP_THRESHOLD
=
1100
;
...
...
@@ -164,7 +163,7 @@ export default Vue.extend({
searchQuery
:
''
,
searchWait
:
false
,
widgetsEditMode
:
false
,
menuDef
:
createMenuDef
({
menuDef
:
this
.
$store
.
getters
.
nav
({
search
:
this
.
search
}),
isDesktop
:
window
.
innerWidth
>=
DESKTOP_THRESHOLD
,
...
...
@@ -241,23 +240,6 @@ export default Vue.extend({
id
:
'
c
'
,
data
:
{}
}]);
}
this
.
$store
.
watch
(
state
=>
state
.
i
,
i
=>
{
for
(
const
def
in
this
.
menuDef
)
{
if
(
this
.
menuDef
[
def
].
indicate
)
{
Vue
.
set
(
this
.
menuDef
[
def
],
'
indicated
'
,
this
.
menuDef
[
def
].
indicate
(
this
.
$store
));
}
if
(
this
.
menuDef
[
def
].
show
)
{
Vue
.
set
(
this
.
menuDef
[
def
],
'
display
'
,
this
.
menuDef
[
def
].
show
(
this
.
$store
));
}
}
},
{
immediate
:
true
,
deep
:
true
});
}
else
{
for
(
const
def
in
this
.
menuDef
)
{
if
(
this
.
menuDef
[
def
].
show
)
{
Vue
.
set
(
this
.
menuDef
[
def
],
'
display
'
,
this
.
menuDef
[
def
].
show
(
this
.
$store
));
}
}
}
},
...
...
@@ -445,13 +427,13 @@ export default Vue.extend({
},
more
(
ev
)
{
const
items
=
Object
.
keys
(
this
.
menuDef
).
filter
(
k
=>
!
this
.
menu
.
includes
(
k
)).
map
(
k
=>
this
.
menuDef
[
k
]).
filter
(
def
=>
def
.
show
?
def
.
show
(
this
.
$store
)
:
true
).
map
(
def
=>
({
const
items
=
Object
.
keys
(
this
.
menuDef
).
filter
(
k
=>
!
this
.
menu
.
includes
(
k
)).
map
(
k
=>
this
.
menuDef
[
k
]).
filter
(
def
=>
def
.
show
==
null
?
true
:
def
.
show
).
map
(
def
=>
({
type
:
def
.
to
?
'
link
'
:
'
button
'
,
text
:
this
.
$t
(
def
.
title
),
icon
:
def
.
icon
,
to
:
def
.
to
,
action
:
def
.
action
,
indicate
:
def
.
indicate
?
def
.
indicate
(
this
.
$store
)
:
false
,
indicate
:
def
.
indicate
d
,
}));
this
.
$root
.
menu
({
items
:
[...
items
,
null
,
{
...
...
This diff is collapsed.
Click to expand it.
src/client/pages/preferences/sidebar.vue
+
1
−
2
View file @
71e58923
...
...
@@ -21,7 +21,6 @@ import MkButton from '../../components/ui/button.vue';
import
MkTextarea
from
'
../../components/ui/textarea.vue
'
;
import
i18n
from
'
../../i18n
'
;
import
{
defaultDeviceUserSettings
}
from
'
../../store
'
;
import
{
createMenuDef
}
from
'
../../app
'
;
export
default
Vue
.
extend
({
i18n
,
...
...
@@ -33,7 +32,7 @@ export default Vue.extend({
data
()
{
return
{
menuDef
:
createMenuDef
({}),
menuDef
:
this
.
$store
.
getters
.
nav
({}),
items
:
''
,
faListUl
,
faSave
,
faRedo
}
...
...
This diff is collapsed.
Click to expand it.
src/client/store.ts
+
107
−
0
View file @
71e58923
import
Vuex
from
'
vuex
'
;
import
createPersistedState
from
'
vuex-persistedstate
'
;
import
*
as
nestedProperty
from
'
nested-property
'
;
import
{
faTerminal
,
faHashtag
,
faBroadcastTower
,
faFireAlt
,
faSearch
,
faStar
,
faAt
,
faListUl
,
faUserClock
,
faUsers
,
faCloud
,
faGamepad
,
faFileAlt
,
faSatellite
,
faDoorClosed
}
from
'
@fortawesome/free-solid-svg-icons
'
;
import
{
faBell
,
faEnvelope
,
faComments
}
from
'
@fortawesome/free-regular-svg-icons
'
;
import
{
apiUrl
}
from
'
./config
'
;
export
const
defaultSettings
=
{
...
...
@@ -81,6 +83,111 @@ export default () => new Vuex.Store({
getters
:
{
isSignedIn
:
state
=>
state
.
i
!=
null
,
nav
:
(
state
,
getters
)
=>
actions
=>
({
notifications
:
{
title
:
'
notifications
'
,
icon
:
faBell
,
get
show
()
{
return
getters
.
isSignedIn
;
},
get
indicated
()
{
return
getters
.
isSignedIn
&&
state
.
i
.
hasUnreadNotification
;
},
to
:
'
/my/notifications
'
,
},
messaging
:
{
title
:
'
messaging
'
,
icon
:
faComments
,
get
show
()
{
return
getters
.
isSignedIn
;
},
get
indicated
()
{
return
getters
.
isSignedIn
&&
state
.
i
.
hasUnreadMessagingMessage
;
},
to
:
'
/my/messaging
'
,
},
drive
:
{
title
:
'
drive
'
,
icon
:
faCloud
,
get
show
()
{
return
getters
.
isSignedIn
;
},
to
:
'
/my/drive
'
,
},
followRequests
:
{
title
:
'
followRequests
'
,
icon
:
faUserClock
,
get
show
()
{
return
getters
.
isSignedIn
&&
state
.
i
.
isLocked
;
},
get
indicated
()
{
return
getters
.
isSignedIn
&&
state
.
i
.
hasPendingReceivedFollowRequest
;
},
to
:
'
/my/follow-requests
'
,
},
featured
:
{
title
:
'
featured
'
,
icon
:
faFireAlt
,
to
:
'
/featured
'
,
},
explore
:
{
title
:
'
explore
'
,
icon
:
faHashtag
,
to
:
'
/explore
'
,
},
announcements
:
{
title
:
'
announcements
'
,
icon
:
faBroadcastTower
,
get
indicated
()
{
return
getters
.
isSignedIn
&&
state
.
i
.
hasUnreadAnnouncement
;
},
to
:
'
/announcements
'
,
},
search
:
{
title
:
'
search
'
,
icon
:
faSearch
,
action
:
()
=>
actions
.
search
(),
},
lists
:
{
title
:
'
lists
'
,
icon
:
faListUl
,
get
show
()
{
return
getters
.
isSignedIn
;
},
to
:
'
/my/lists
'
,
},
groups
:
{
title
:
'
groups
'
,
icon
:
faUsers
,
get
show
()
{
return
getters
.
isSignedIn
;
},
to
:
'
/my/groups
'
,
},
antennas
:
{
title
:
'
antennas
'
,
icon
:
faSatellite
,
get
show
()
{
return
getters
.
isSignedIn
;
},
to
:
'
/my/antennas
'
,
},
mentions
:
{
title
:
'
mentions
'
,
icon
:
faAt
,
get
show
()
{
return
getters
.
isSignedIn
;
},
get
indicated
()
{
return
getters
.
isSignedIn
&&
state
.
i
.
hasUnreadMentions
;
},
to
:
'
/my/mentions
'
,
},
messages
:
{
title
:
'
directNotes
'
,
icon
:
faEnvelope
,
get
show
()
{
return
getters
.
isSignedIn
;
},
get
indicated
()
{
return
getters
.
isSignedIn
&&
state
.
i
.
hasUnreadSpecifiedNotes
;
},
to
:
'
/my/messages
'
,
},
favorites
:
{
title
:
'
favorites
'
,
icon
:
faStar
,
get
show
()
{
return
getters
.
isSignedIn
;
},
to
:
'
/my/favorites
'
,
},
pages
:
{
title
:
'
pages
'
,
icon
:
faFileAlt
,
get
show
()
{
return
getters
.
isSignedIn
;
},
to
:
'
/my/pages
'
,
},
games
:
{
title
:
'
games
'
,
icon
:
faGamepad
,
to
:
'
/games
'
,
},
scratchpad
:
{
title
:
'
scratchpad
'
,
icon
:
faTerminal
,
to
:
'
/scratchpad
'
,
},
}),
},
mutations
:
{
...
...
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