Skip to content

特性:当所有子路由存在且不可访问时,父路由也不可访问#105

Merged
sorrycc merged 1 commit intomasterfrom
feat/parent-route-access
Mar 24, 2020
Merged

特性:当所有子路由存在且不可访问时,父路由也不可访问#105
sorrycc merged 1 commit intomasterfrom
feat/parent-route-access

Conversation

@jtsang4
Copy link
Copy Markdown
Member

@jtsang4 jtsang4 commented Mar 17, 2020

变更:

  1. 在生成基本的路由权限后,再检查一遍子路由的存在与可访问性。当所有子路由存在且不可访问时,父路由也不可访问

Close umijs/umi#4171

@jtsang4 jtsang4 requested a review from sorrycc March 17, 2020 13:10
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2020

Codecov Report

Merging #105 into master will increase coverage by 1.10%.
The diff coverage is 97.05%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #105      +/-   ##
==========================================
+ Coverage   54.30%   55.40%   +1.10%     
==========================================
  Files          58       59       +1     
  Lines        1243     1276      +33     
  Branches      364      376      +12     
==========================================
+ Hits          675      707      +32     
- Misses        564      569       +5     
+ Partials        4        0       -4     
Impacted Files Coverage Δ
packages/plugin-access/src/index.ts 100.00% <ø> (ø)
packages/plugin-access/src/utils/runtimeUtil.ts 96.96% <96.96%> (ø)
...lugin-access/src/utils/getAccessProviderContent.ts 100.00% <100.00%> (ø)
packages/plugin-qiankun/src/master/index.ts 0.00% <0.00%> (ø)
packages/plugin-ant-design-pro-block/src/index.ts 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de3137c...8cf327f. Read the comment docs.

@sorrycc
Copy link
Copy Markdown
Member

sorrycc commented Mar 17, 2020

加个用例?这部分没有用例覆盖感觉容易出错。

@jtsang4
Copy link
Copy Markdown
Member Author

jtsang4 commented Mar 17, 2020

目前是在 example 里面本地配置了下手动测的,这部分感觉还不太好加测试用例,它是生成的 JS 文本里面的逻辑,不太好执行。

@sorrycc
Copy link
Copy Markdown
Member

sorrycc commented Mar 18, 2020

  1. getAccessProviderContent.ts 改成 AccessProvider.ts
  2. writeTmpFile 时读取 AccessProvider.ts 文件内容复制过去
  3. 测试 AccessProvider.ts

@jtsang4 jtsang4 force-pushed the feat/parent-route-access branch from 5d39dd1 to 7edaaae Compare March 23, 2020 18:59
@jtsang4
Copy link
Copy Markdown
Member Author

jtsang4 commented Mar 23, 2020

@sorrycc 好办法~!已经提取相关逻辑部分并增加测试用例。

@jtsang4 jtsang4 force-pushed the feat/parent-route-access branch from 7edaaae to 2e2f667 Compare March 23, 2020 19:31
@jtsang4 jtsang4 force-pushed the feat/parent-route-access branch from 2e2f667 to 8cf327f Compare March 23, 2020 19:33
import { utils } from 'umi';
import { join } from 'path';

export default function(util: typeof utils) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里通过参数传递 utils 而不是直接使用的原因是方便测试,否则在 index.test.ts 运行测试时,不方便 mock 这个模块的 utils 底层使用的 readdirSync

@sorrycc sorrycc merged commit f4e4d48 into master Mar 24, 2020
@delete-merged-branch delete-merged-branch Bot deleted the feat/parent-route-access branch March 24, 2020 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

建议access插件当子菜单都没有权限的时候是不是应该默认隐藏父菜单项

2 participants