Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pro:table): the layout tool support visible, changeSize, resetable #1488

Merged
merged 1 commit into from Mar 6, 2023

Conversation

danranVm
Copy link
Member

@danranVm danranVm commented Mar 6, 2023

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added/updated or not needed
  • Docs and demo have been added/updated or not needed

What is the current behavior?

What is the new behavior?

布局设置面板新增功能

  • 双向绑定 visible
  • 隐藏修改大小的图标: changeSize
  • 自定义面板样式: className
  • 隐藏重置按钮: resetable
  • 重置按钮被点击后的回调: onReset

Other information

@idux-bot
Copy link

idux-bot bot commented Mar 6, 2023

This preview will be available after the AzureCI is passed.

@@ -30,6 +30,8 @@ export const defaultConfig: ProGlobalConfig = {
},
table: {
layoutTool: {
changeSize: false,
resetable: false,
searchable: false,
},
},
Copy link

Choose a reason for hiding this comment

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

the code review

The given code patch looks good. It's adding two new properties to the layoutTool object, namely changeSize and resetable, and setting them to false. There does not seem to be any bugs present in the code patch. However, one suggestion for improvement would be to add comments to the code so that it is easier to understand what each part of the code is doing.

@@ -73,6 +73,8 @@ export interface ProTableConfig {
// @deprecated please use `columnIndexable` of TableConfig instead'
columnIndexable?: Omit<ProTableColumnIndexable, 'type'>
layoutTool: {
changeSize: boolean
resetable: boolean
searchable: boolean
}
}
Copy link

Choose a reason for hiding this comment

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

the code review
1.The first point of code review is to check for any syntax errors or typos.In the given code fragment, there are no syntax errors and typos.
2.The second point in code review is to check for logical errors.In this code fragment,the logical error is not present.
3.The third point in code review is to check for security risks.In this code fragment,there are no security risks present.
4.The fourth point in code review is to check for performance issues.In this code fragment,there are no performance issues present.
5.The fifth point in code review is to check for code optimization.In this code fragment, the code can be optimized by adding comments which can help in understanding the code better.

| `placeholder` | 搜索框的占位符 | `string` | `搜索关键字` | ✅ | 通过 locale 全局配置 |
| `resetable` | 是否支持重置布局设置 | `boolean` | `true` | ✅ |- |
| `searchable` | 是否开启搜索功能 | `boolean` | `false` | ✅ | - |
| `onReset` | 点击重置按钮后的回调 | `(evt: MouseEvent) => boolean \| void` | - | - | 返回 `false` 会阻止组件内部的重置操作 |
Copy link

Choose a reason for hiding this comment

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

with code review:

  1. Make sure the variables used for v-model and placeholder are correct. For example, the placeholder should be a string value instead of a boolean value.
  2. Check to see if the types of the variables are correct and if they are consistent with their default values. For example, resetable is a boolean but the default value is a string.
  3. Check that all necessary attributes are included in the table and that they are named correctly.
  4. Ensure that all functions have the correct parameters and that they are properly documented.
  5. Check that the code is well-structured, organized, and easy to read.
  6. Verify that the code follows best practices and coding standards.
  7. Look for any potential security risks and vulnerabilities.
  8. Test the code to ensure that it works as intended.

return null
}
return <ProTableLayoutTool />
const toolProps = isObject(layoutTool) ? layoutTool : undefined
return <ProTableLayoutTool {...toolProps} />
}

const renderToolbar = () => {
Copy link

Choose a reason for hiding this comment

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

with the code review.

First, check the imports of 'lodash-es'. It looks like you're importing two functions that you're using in the code. This is good practice as it makes the code more readable and less prone to bugs.

Next, check the use of provide. It looks like you're providing props and config values for the proTableToken. This is a good practice as it ensures that all components are using the same variables.

Then, check the renderLayoutTool() function. It looks like you're checking if the layoutTool prop is present and returning null if it's not. This is good as it will prevent any errors from occurring. Additionally, you've added a check to see if layoutTool is an object and passed it as a prop if it is. This is also good practice.

Finally, check the renderToolbar() function. It looks like this function is responsible for rendering the toolbar, but there is no code present. Make sure to add the necessary code to make this function work properly.

trigger="click"
></IxPopover>
{...popoverProps}
/>
)
}
},
Copy link

Choose a reason for hiding this comment

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

with the code review:

  1. The code patch imports computed from vue, which is used to create a computed property that holds the value of props.changeSize and is used to conditionally render icons in the layout tool.
  2. The code patch adds contentProps to the IxPopover component, which contains placeholder, resetable, searchable, searchValue, onUpdate:searchValue, and onReset. This allows for the user to customize the layout tool by changing these values.
  3. The code patch adds popoverProps to the IxPopover component, which contains class, header, offset, placement, showArrow, trigger and visible. This allows for the user to customize the layout tool by changing these values.
  4. The code patch adds a suffixNode to the IxPopover component, which is used to render the icons for small, medium, and large size options. This allows for the user to select the size of the layout tool.
  5. The code patch adds a popoverHeader which includes a title and suffixNode. This allows the user to customize the layout tool with a title and the size options.

In conclusion, the code patch adds functionality to the layout tool such as customizing the layout tool with contentProps, popoverProps and popoverHeader; as well as adding the ability to select the size of the layout tool with the suffixNode.

<IxButton size="sm" mode="link" onClick={handleReset}>
{reset}
</IxButton>
)}
</div>
<div class={`${prefixCls}-tree-wrapper`}>
{hasStartFixed && (
Copy link

Choose a reason for hiding this comment

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

with the code review.

First, in line 4, you imported the wrong utility. The correct one should be useControlledProp.

In line 35, you can call the emit function from the props to handle the resetting of columns.

In line 89, it looks like you are using the "mergedSearchable" computed value, which is not defined anywhere. You probably meant to use the "props.searchable" value instead.

In line 110, you are using the "mergedPrefixCls" value, which is also not defined anywhere. You probably meant to use the "prefixCls" value instead.

Lastly, in line 120, you are using the "resetColumns" function, which is not defined anywhere. You probably meant to use the "handleReset" function instead.

I hope this helps!


export interface ProTableContext extends ColumnsContext {
props: ProTableProps
slots: Slots
config: ProTableConfig
locale: ProLocale
mergedPrefixCls: ComputedRef<string>
Copy link

Choose a reason for hiding this comment

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

the code review

  1. The code patch looks like it is changing the import type of Slots from 'vue' to be removed. This change may have an impact on the functionality of the ProTableContext as the Slots type provides a way for components to create slots for other components to fill in with their own content.

  2. It is also worth considering if the ProTableContext will be affected by the removal of the Slots type, and if so, what changes need to be made to account for this.

  3. It is also important to consider how this change will impact the performance of the ProTableContext and what optimization techniques can be applied to ensure that the application remains performant.

  4. Finally, it is important to consider the maintainability of the code patch and what measures can be taken to ensure that the code is easy to read and maintain going forward.


'onUpdate:searchValue': [Function, Array] as PropType<MaybeArray<(searchValue: string) => void>>,
onReset: [Function, Array] as PropType<MaybeArray<(evt: MouseEvent) => boolean | void>>,
} as const
Copy link

Choose a reason for hiding this comment

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

  1. It looks like the code patch is missing some necessary imports, such as the ProTableProps, ProTableBindings, and MaybeArray types.

  2. In the proTableLayoutToolProps object, the types for the changeSize and className properties appear to be incorrect. The type for changeSize should be Boolean, and the type for className should be String.

  3. In the proTableLayoutToolContentProps object, the resetable and searchable properties are marked as required, but they don't have default values set. This could lead to errors if the properties are not set.

  4. The proTableLayoutToolContentProps object does not have a visible property, which may cause problems if the component is relying on that property for visibility.

@codecov
Copy link

codecov bot commented Mar 6, 2023

Codecov Report

Merging #1488 (4210812) into main (e044390) will decrease coverage by 0.01%.
The diff coverage is 70.58%.

❗ Current head 4210812 differs from pull request most recent head 328f953. Consider uploading reports for the commit 328f953 to get more accurate results

@@            Coverage Diff             @@
##             main    #1488      +/-   ##
==========================================
- Coverage   92.74%   92.73%   -0.01%     
==========================================
  Files         331      331              
  Lines       30742    30754      +12     
  Branches     3533     3533              
==========================================
+ Hits        28511    28520       +9     
- Misses       2231     2234       +3     
Impacted Files Coverage Δ
packages/components/cascader/src/types.ts 100.00% <ø> (ø)
packages/pro/search/src/ProSearch.tsx 16.27% <16.66%> (+0.16%) ⬆️
packages/components/cascader/src/Cascader.tsx 84.68% <100.00%> (ø)
packages/pro/config/src/defaultConfig.ts 100.00% <100.00%> (ø)
packages/pro/config/src/types.ts 100.00% <100.00%> (ø)
packages/pro/search/src/token.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@danranVm danranVm merged commit 950f1b1 into IDuxFE:main Mar 6, 2023
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.

None yet

1 participant