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
f4855c29
Commit
f4855c29
authored
Apr 05, 2018
by
Erwin Zhang
Committed by
陈帅
Apr 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix menu typos
parent
f60ee6e7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
32 deletions
+32
-32
src/components/SiderMenu/BaseMenu.js
src/components/SiderMenu/BaseMenu.js
+3
-3
src/components/SiderMenu/SiderMenu.js
src/components/SiderMenu/SiderMenu.js
+3
-3
src/components/SiderMenu/SiderMenu.test.js
src/components/SiderMenu/SiderMenu.test.js
+24
-0
src/components/SiderMenu/SilderMenu.test.js
src/components/SiderMenu/SilderMenu.test.js
+0
-24
src/components/TopNavHeader/index.js
src/components/TopNavHeader/index.js
+2
-2
No files found.
src/components/SiderMenu/BaseMe
un
.js
→
src/components/SiderMenu/BaseMe
nu
.js
View file @
f4855c29
...
@@ -21,13 +21,13 @@ const getIcon = icon => {
...
@@ -21,13 +21,13 @@ const getIcon = icon => {
return
icon
;
return
icon
;
};
};
export
const
getMe
unMatchey
s
=
(
flatMenuKeys
,
path
)
=>
{
export
const
getMe
nuMatche
s
=
(
flatMenuKeys
,
path
)
=>
{
return
flatMenuKeys
.
filter
(
item
=>
{
return
flatMenuKeys
.
filter
(
item
=>
{
return
pathToRegexp
(
item
).
test
(
path
);
return
pathToRegexp
(
item
).
test
(
path
);
});
});
};
};
export
default
class
BaseMe
un
extends
PureComponent
{
export
default
class
BaseMe
nu
extends
PureComponent
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
menus
=
props
.
menuData
;
this
.
menus
=
props
.
menuData
;
...
@@ -68,7 +68,7 @@ export default class BaseMeun extends PureComponent {
...
@@ -68,7 +68,7 @@ export default class BaseMeun extends PureComponent {
// Get the currently selected menu
// Get the currently selected menu
getSelectedMenuKeys
=
()
=>
{
getSelectedMenuKeys
=
()
=>
{
const
{
location
:
{
pathname
}
}
=
this
.
props
;
const
{
location
:
{
pathname
}
}
=
this
.
props
;
return
urlToList
(
pathname
).
map
(
itemPath
=>
getMe
unMatchey
s
(
this
.
flatMenuKeys
,
itemPath
).
pop
());
return
urlToList
(
pathname
).
map
(
itemPath
=>
getMe
nuMatche
s
(
this
.
flatMenuKeys
,
itemPath
).
pop
());
};
};
/**
/**
* get SubMenu or Item
* get SubMenu or Item
...
...
src/components/SiderMenu/SiderMenu.js
View file @
f4855c29
...
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
...
@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import
{
Layout
,
Menu
,
Icon
}
from
'
antd
'
;
import
{
Layout
,
Menu
,
Icon
}
from
'
antd
'
;
import
{
Link
}
from
'
dva/router
'
;
import
{
Link
}
from
'
dva/router
'
;
import
styles
from
'
./index.less
'
;
import
styles
from
'
./index.less
'
;
import
BaseMe
un
,
{
getMeunMatcheys
}
from
'
./BaseMeun
'
;
import
BaseMe
nu
,
{
getMenuMatches
}
from
'
./BaseMenu
'
;
import
{
urlToList
}
from
'
../_utils/pathTools
'
;
import
{
urlToList
}
from
'
../_utils/pathTools
'
;
const
{
Sider
}
=
Layout
;
const
{
Sider
}
=
Layout
;
...
@@ -131,7 +131,7 @@ export default class SiderMenu extends PureComponent {
...
@@ -131,7 +131,7 @@ export default class SiderMenu extends PureComponent {
const
{
location
:
{
pathname
}
}
=
props
||
this
.
props
;
const
{
location
:
{
pathname
}
}
=
props
||
this
.
props
;
return
urlToList
(
pathname
)
return
urlToList
(
pathname
)
.
map
(
item
=>
{
.
map
(
item
=>
{
return
getMe
unMatchey
s
(
this
.
flatMenuKeys
,
item
)[
0
];
return
getMe
nuMatche
s
(
this
.
flatMenuKeys
,
item
)[
0
];
})
})
.
filter
(
item
=>
item
);
.
filter
(
item
=>
item
);
}
}
...
@@ -165,7 +165,7 @@ export default class SiderMenu extends PureComponent {
...
@@ -165,7 +165,7 @@ export default class SiderMenu extends PureComponent {
<
h1
>
Ant
Design
Pro
<
/h1
>
<
h1
>
Ant
Design
Pro
<
/h1
>
<
/Link
>
<
/Link
>
<
/div
>
<
/div
>
<
BaseMe
un
<
BaseMe
nu
{...
this
.
props
}
{...
this
.
props
}
key
=
"
Menu
"
key
=
"
Menu
"
mode
=
"
inline
"
mode
=
"
inline
"
...
...
src/components/SiderMenu/SiderMenu.test.js
0 → 100644
View file @
f4855c29
import
{
getMenuMatches
}
from
'
./BaseMenu
'
;
const
menu
=
[
'
/dashboard
'
,
'
/userinfo
'
,
'
/dashboard/name
'
,
'
/userinfo/:id
'
,
'
/userinfo/:id/info
'
];
describe
(
'
test menu match
'
,
()
=>
{
it
(
'
simple path
'
,
()
=>
{
expect
(
getMenuMatches
(
menu
,
'
/dashboard
'
)).
toEqual
([
'
/dashboard
'
]);
});
it
(
'
error path
'
,
()
=>
{
expect
(
getMenuMatches
(
menu
,
'
/dashboardname
'
)).
toEqual
([]);
});
it
(
'
Secondary path
'
,
()
=>
{
expect
(
getMenuMatches
(
menu
,
'
/dashboard/name
'
)).
toEqual
([
'
/dashboard/name
'
]);
});
it
(
'
Parameter path
'
,
()
=>
{
expect
(
getMenuMatches
(
menu
,
'
/userinfo/2144
'
)).
toEqual
([
'
/userinfo/:id
'
]);
});
it
(
'
three parameter path
'
,
()
=>
{
expect
(
getMenuMatches
(
menu
,
'
/userinfo/2144/info
'
)).
toEqual
([
'
/userinfo/:id/info
'
]);
});
});
src/components/SiderMenu/SilderMenu.test.js
deleted
100644 → 0
View file @
f60ee6e7
import
{
getMeunMatcheys
}
from
'
./BaseMeun
'
;
const
meun
=
[
'
/dashboard
'
,
'
/userinfo
'
,
'
/dashboard/name
'
,
'
/userinfo/:id
'
,
'
/userinfo/:id/info
'
];
describe
(
'
test meun match
'
,
()
=>
{
it
(
'
simple path
'
,
()
=>
{
expect
(
getMeunMatcheys
(
meun
,
'
/dashboard
'
)).
toEqual
([
'
/dashboard
'
]);
});
it
(
'
error path
'
,
()
=>
{
expect
(
getMeunMatcheys
(
meun
,
'
/dashboardname
'
)).
toEqual
([]);
});
it
(
'
Secondary path
'
,
()
=>
{
expect
(
getMeunMatcheys
(
meun
,
'
/dashboard/name
'
)).
toEqual
([
'
/dashboard/name
'
]);
});
it
(
'
Parameter path
'
,
()
=>
{
expect
(
getMeunMatcheys
(
meun
,
'
/userinfo/2144
'
)).
toEqual
([
'
/userinfo/:id
'
]);
});
it
(
'
three parameter path
'
,
()
=>
{
expect
(
getMeunMatcheys
(
meun
,
'
/userinfo/2144/info
'
)).
toEqual
([
'
/userinfo/:id/info
'
]);
});
});
src/components/TopNavHeader/index.js
View file @
f4855c29
import
React
,
{
PureComponent
}
from
'
react
'
;
import
React
,
{
PureComponent
}
from
'
react
'
;
import
{
Link
}
from
'
dva/router
'
;
import
{
Link
}
from
'
dva/router
'
;
import
RightContent
from
'
../GlobalHeader/RightContent
'
;
import
RightContent
from
'
../GlobalHeader/RightContent
'
;
import
BaseMe
un
from
'
../SiderMenu/BaseMeun
'
;
import
BaseMe
nu
from
'
../SiderMenu/BaseMenu
'
;
import
styles
from
'
./index.less
'
;
import
styles
from
'
./index.less
'
;
export
default
class
TopNavHeader
extends
PureComponent
{
export
default
class
TopNavHeader
extends
PureComponent
{
...
@@ -24,7 +24,7 @@ export default class TopNavHeader extends PureComponent {
...
@@ -24,7 +24,7 @@ export default class TopNavHeader extends PureComponent {
<
h1
>
Ant
Design
Pro
<
/h1
>
<
h1
>
Ant
Design
Pro
<
/h1
>
<
/Link
>
<
/Link
>
<
/div
>
<
/div
>
<
BaseMe
un
<
BaseMe
nu
{...
this
.
props
}
{...
this
.
props
}
style
=
{{
padding
:
'
9px 0
'
,
border
:
'
none
'
}}
style
=
{{
padding
:
'
9px 0
'
,
border
:
'
none
'
}}
/
>
/
>
...
...
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