Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pro-blocks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
pro-blocks
Commits
c859fde8
Commit
c859fde8
authored
Jan 08, 2018
by
陈帅
Committed by
偏右
Jan 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Authorized typescript (#573)
* add Authorized typescript support * add currentAuthority is undefine test
parent
5ade2230
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
+50
-0
src/components/Authorized/CheckPermissions.test.js
src/components/Authorized/CheckPermissions.test.js
+3
-0
src/components/Authorized/index.d.ts
src/components/Authorized/index.d.ts
+47
-0
No files found.
src/components/Authorized/CheckPermissions.test.js
View file @
c859fde8
...
...
@@ -13,6 +13,9 @@ describe('test CheckPermissions', () => {
it
(
'
authority is undefined , return ok
'
,
()
=>
{
expect
(
checkPermissions
(
null
,
'
NULL
'
,
target
,
error
)).
toEqual
(
'
ok
'
);
});
it
(
'
currentAuthority is undefined , return error
'
,
()
=>
{
expect
(
checkPermissions
(
'
admin
'
,
null
,
target
,
error
)).
toEqual
(
'
error
'
);
});
it
(
'
Wrong string permission authentication
'
,
()
=>
{
expect
(
checkPermissions
(
'
admin
'
,
'
user
'
,
target
,
error
)).
toEqual
(
'
error
'
);
});
...
...
src/components/Authorized/index.d.ts
0 → 100644
View file @
c859fde8
import
*
as
React
from
"
react
"
;
import
*
as
H
from
"
history
"
;
import
{
RouteProps
}
from
"
react-router
"
;
type
authorityFN
=
()
=>
string
;
type
authority
=
string
|
Array
<
string
>
|
authorityFN
|
Promise
<
any
>
;
interface
Secured
{
(
authority
:
authority
,
error
?:
React
.
ReactNode
):
(
target
:
React
.
ReactNode
)
=>
React
.
ReactNode
;
}
export
interface
AuthorizedRouteProps
extends
RouteProps
{
authority
:
authority
;
}
export
class
AuthorizedRoute
extends
React
.
Component
<
AuthorizedRouteProps
,
any
>
{
constructor
(
props
:
AuthorizedRouteProps
);
}
interface
check
{
(
authority
:
authority
,
target
:
React
.
ReactNode
,
Exception
:
React
.
ReactNode
):
React
.
ReactNode
;
}
interface
AuthorizedProps
{
authority
:
authority
;
noMatch
?:
React
.
ReactNode
;
}
export
class
Authorized
extends
React
.
Component
<
AuthorizedProps
,
any
>
{
static
Secured
:
Secured
;
static
AuthorizedRoute
:
typeof
AuthorizedRoute
;
static
check
:
check
;
constructor
(
props
:
AuthorizedProps
);
}
declare
function
renderAuthorize
(
currentAuthority
:
string
):
typeof
Authorized
;
export
default
renderAuthorize
;
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