This repository was archived by the owner on Apr 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ public struct AdminPanelConfig<U: AdminPanelUserType>: Service {
32
32
public let endpoints : AdminPanelEndpoints
33
33
public let views : AdminPanelViews
34
34
public let controllers : AdminPanelControllers < U >
35
- public let sidebarMenuPathGenerator : SidebarMenuPathGenerator
35
+ public let sidebarMenuPathGenerator : SidebarMenuPathGenerator < U . Role >
36
36
public let dashboardPath : String ?
37
37
public let resetPasswordEmail : ResetPasswordEmail
38
38
public let specifyPasswordEmail : SpecifyPasswordEmail
@@ -44,7 +44,7 @@ public struct AdminPanelConfig<U: AdminPanelUserType>: Service {
44
44
endpoints: AdminPanelEndpoints = . default,
45
45
views: AdminPanelViews = . default,
46
46
controllers: AdminPanelControllers < U > = . default,
47
- sidebarMenuPathGenerator: @escaping SidebarMenuPathGenerator = U . Role. menuPathGenerator ,
47
+ sidebarMenuPathGenerator: @escaping SidebarMenuPathGenerator < U . Role > = U . Role. sidebarMenuPathGenerator ,
48
48
dashboardPath: String ? = nil ,
49
49
resetPasswordEmail: ResetPasswordEmail = . default,
50
50
specifyPasswordEmail: SpecifyPasswordEmail = . default,
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import Reset
3
3
import Submissions
4
4
import Sugar
5
5
6
- public typealias SidebarMenuPathGenerator = ( ( AdminPanelUserRole ) -> String )
6
+ public typealias SidebarMenuPathGenerator < U : AdminPanelUserRoleType > = ( ( U ) -> String )
7
7
8
8
public protocol AdminPanelUserType :
9
9
Parameter ,
@@ -42,7 +42,7 @@ public extension AdminPanelUserType {
42
42
}
43
43
44
44
public extension AdminPanelUserRoleType {
45
- public static var menuPathGenerator : SidebarMenuPathGenerator {
45
+ public static var sidebarMenuPathGenerator : SidebarMenuPathGenerator < Self > {
46
46
return { role in
47
47
role. menuPath
48
48
}
Original file line number Diff line number Diff line change @@ -116,7 +116,8 @@ public final class AdminPanelProvider<U: AdminPanelUserType>: Provider {
116
116
117
117
services. register ( AdminPanelConfigTagData < U > (
118
118
name: config. name,
119
- baseUrl: config. baseUrl
119
+ baseUrl: config. baseUrl,
120
+ sidebarMenuPathGenerator: config. sidebarMenuPathGenerator
120
121
) )
121
122
services. register ( config)
122
123
services. register ( KeyedCacheSessions . self)
Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ public final class AdminPanelConfigTag<U: AdminPanelUserType>: TagRenderer {
10
10
let container = try tag. container. make ( CurrentUserContainer< U> . self )
11
11
12
12
return Future . map ( on: tag) {
13
- try config. viewData ( for: tag. parameters [ 0 ] , user: container. user, tag: tag)
13
+ try config. viewData (
14
+ for: tag. parameters [ 0 ] ,
15
+ user: container. user,
16
+ tag: tag
17
+ )
14
18
}
15
19
}
16
20
@@ -28,14 +32,17 @@ public final class AdminPanelConfigTagData<U: AdminPanelUserType>: Service {
28
32
public var name = " "
29
33
public var baseUrl = " "
30
34
public var dashboardPath : String ?
35
+ public var sidebarMenuPathGenerator : SidebarMenuPathGenerator < U . Role >
31
36
32
37
init (
33
38
name: String ,
34
39
baseUrl: String ,
40
+ sidebarMenuPathGenerator: @escaping SidebarMenuPathGenerator < U . Role > ,
35
41
dashboardPath: String ? = nil
36
42
) {
37
43
self . name = name
38
44
self . baseUrl = baseUrl
45
+ self . sidebarMenuPathGenerator = sidebarMenuPathGenerator
39
46
self . dashboardPath = dashboardPath
40
47
}
41
48
@@ -54,7 +61,9 @@ public final class AdminPanelConfigTagData<U: AdminPanelUserType>: Service {
54
61
case . baseUrl:
55
62
return . string( baseUrl)
56
63
case . sidebarMenuPath:
57
- return user. map { . string( $0. role. menuPath) } ?? . null
64
+ return user. map {
65
+ . string( self . sidebarMenuPathGenerator ( $0. role) )
66
+ } ?? . null
58
67
case . dashboardPath:
59
68
return dashboardPath. map { . string( $0) } ?? . null
60
69
}
You can’t perform that action at this time.
0 commit comments