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
60342ed3
Commit
60342ed3
authored
2 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
enhance(client): improve user menu ux
parent
504baa9d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/frontend/src/scripts/get-user-menu.ts
+32
-42
32 additions, 42 deletions
packages/frontend/src/scripts/get-user-menu.ts
with
32 additions
and
42 deletions
packages/frontend/src/scripts/get-user-menu.ts
+
32
−
42
View file @
60342ed3
...
...
@@ -12,29 +12,6 @@ import { Router } from '@/nirax';
export
function
getUserMenu
(
user
:
misskey
.
entities
.
UserDetailed
,
router
:
Router
=
mainRouter
)
{
const
meId
=
$i
?
$i
.
id
:
null
;
async
function
pushList
()
{
const
t
=
i18n
.
ts
.
selectList
;
// なぜか後で参照すると null になるので最初にメモリに確保しておく
const
lists
=
await
os
.
api
(
'
users/lists/list
'
);
if
(
lists
.
length
===
0
)
{
os
.
alert
({
type
:
'
error
'
,
text
:
i18n
.
ts
.
youHaveNoLists
,
});
return
;
}
const
{
canceled
,
result
:
listId
}
=
await
os
.
select
({
title
:
t
,
items
:
lists
.
map
(
list
=>
({
value
:
list
.
id
,
text
:
list
.
name
,
})),
});
if
(
canceled
)
return
;
os
.
apiWithDialog
(
'
users/lists/push
'
,
{
listId
:
listId
,
userId
:
user
.
id
,
});
}
async
function
toggleMute
()
{
if
(
user
.
isMuted
)
{
os
.
apiWithDialog
(
'
mute/delete
'
,
{
...
...
@@ -137,12 +114,43 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router
os
.
post
({
specified
:
user
});
},
},
null
,
{
type
:
'
parent
'
,
icon
:
'
ti ti-list
'
,
text
:
i18n
.
ts
.
addToList
,
action
:
pushList
,
children
:
async
()
=>
{
const
lists
=
await
os
.
api
(
'
users/lists/list
'
);
return
lists
.
map
(
list
=>
({
text
:
list
.
name
,
action
:
()
=>
{
os
.
apiWithDialog
(
'
users/lists/push
'
,
{
listId
:
list
.
id
,
userId
:
user
.
id
,
});
},
}));
},
}]
as
any
;
if
(
$i
&&
meId
!==
user
.
id
)
{
if
(
iAmModerator
)
{
menu
=
menu
.
concat
([{
type
:
'
parent
'
,
icon
:
'
ti ti-badges
'
,
text
:
i18n
.
ts
.
roles
,
children
:
async
()
=>
{
const
roles
=
await
os
.
api
(
'
admin/roles/list
'
);
return
roles
.
filter
(
r
=>
r
.
target
===
'
manual
'
).
map
(
r
=>
({
text
:
r
.
name
,
action
:
()
=>
{
os
.
apiWithDialog
(
'
admin/roles/assign
'
,
{
roleId
:
r
.
id
,
userId
:
user
.
id
});
},
}));
},
}]);
}
menu
=
menu
.
concat
([
null
,
{
icon
:
user
.
isMuted
?
'
ti ti-eye
'
:
'
ti ti-eye-off
'
,
text
:
user
.
isMuted
?
i18n
.
ts
.
unmute
:
i18n
.
ts
.
mute
,
...
...
@@ -166,24 +174,6 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router
text
:
i18n
.
ts
.
reportAbuse
,
action
:
reportAbuse
,
}]);
if
(
iAmModerator
)
{
menu
=
menu
.
concat
([
null
,
{
icon
:
'
ti ti-badges
'
,
text
:
i18n
.
ts
.
roles
,
action
:
async
()
=>
{
const
roles
=
await
os
.
api
(
'
admin/roles/list
'
);
const
{
canceled
,
result
:
roleId
}
=
await
os
.
select
({
title
:
i18n
.
ts
.
_role
.
chooseRoleToAssign
,
items
:
roles
.
map
(
r
=>
({
text
:
r
.
name
,
value
:
r
.
id
})),
});
if
(
canceled
)
return
;
await
os
.
apiWithDialog
(
'
admin/roles/assign
'
,
{
roleId
,
userId
:
user
.
id
});
},
}]);
}
}
if
(
$i
&&
meId
===
user
.
id
)
{
...
...
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