gpt4 book ai didi

react-admin - React Admin - ListView ⋮ "More Options"按钮

转载 作者:行者123 更新时间:2023-12-03 23:54:02 25 4
gpt4 key购买 nike

我正在使用 React-Admin框架并希望将按钮操作合并为一个 选项按钮。
基本上,我想把这个:
enter image description here
进入这个!
enter image description here
我认为它看起来不那么杂乱,按钮被广泛用于更多选项。
有没有现有的解决方案?或者如何轻松完成?
编辑:我的解决方案:
更多选项.jsx

import * as React from "react";
import { Link, DeleteButton } from "react-admin";
import IconButton from "@material-ui/core/IconButton";
import QueueIcon from "@material-ui/icons/Queue";
import EditIcon from "@material-ui/icons/Edit";

import _objectWithoutProperties from "babel-runtime/helpers/objectWithoutProperties";

const MyEditButton = (props) => (
<IconButton
component={Link}
to={props.basePath + "/" + props.record.id}
color="primary"
aria-label="Edit"
>
<EditIcon style={{ fontSize: '20px' }} />
</IconButton >
);

const MyCloneButton = (props) => (
<IconButton component={Link} to={{
pathname: props.basePath + '/create',
state: {
record: _objectWithoutProperties(props.record, ['id', 'paxDbName'])
}
}} color="primary" aria-label="Clone">
<QueueIcon style={{ fontSize: '20px' }} />
</IconButton>
);

const EditCloneDelete = (props) => {
let a = props;
return <div>
<MyEditButton {...props} />
<MyCloneButton {...props} />
<DeleteButton basePath={props.basePath} record={props.record} resource={props.resource} label=""/>
</div>;
};

export default EditCloneDelete
帖子.jsx
import EditCloneDelete from './MoreOptions.jsx';
效果很好!

最佳答案

我的解决方案是创建一个新组件,将所有按钮封装到一个单元格中。我也不显示标签。我确定有一个更清洁的解决方案,但我的快速方法是:

const MyEditButton = (props) => (
<IconButton classes={{root: props.classes.buttonSize}} component={Link} to={
${props.basePath} + "/" + ${props.record.id}
} color="primary" aria-label="Edit" ><EditIcon style={{fontSize: '20px'}}/></IconButton>
);

const MyCloneButton = (props) => (
<IconButton classes={{root: props.classes.buttonSize}} component={Link} to={{
pathname: props.basePath + '/create',
state: {record: _objectWithoutProperties(props.record, ['id', 'paxDbName'])}
}} color="primary" aria-label="Clone"><QueueIcon style={{fontSize: '20px'}}/></IconButton>
);

const styles = {
buttonSize: {
width: "28px",
height: "28px",
},
};

const EditCloneDelete = (props) => {
let a = props;
return (
<div>
<a href={
`http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=${props.record.customerName ? props.record.customerName : props.record.name}`
} target="dashboard">
<IconButton classes={{root: props.classes.buttonSize}} color="primary" aria-label="Edit"><img src={K8sIcon} style={{width: '20px', height: '20px'}}/></IconButton>
</a>
<MyEditButton {...props}/>
<MyCloneButton {...props}/>
<OptionalDeleteButton {...props} classes={{deleteButton: props.classes.buttonSize}} label={""} disabled={
!props.showDelete(props.record)
}/>
</div>
);
};

export default compose(withStyles(styles))(EditCloneDelete)

你可以很容易地创建一个一流的 React 组件,它是一个按钮容器,可以使这个子表更易于重用。

关于react-admin - React Admin - ListView ⋮ "More Options"按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52398289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com