Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should redirect to show page if the 'show' option is selected", () => {
const { getByText, history } = renderWithRouter(
);
fireEvent.click(getByText('hello'));
expect(history.location.pathname).toEqual(
linkToRecord(defaultProps.basePath, defaultProps.id, 'show')
);
});
handleRedirection = (path, event) => {
const { basePath, id, push } = this.props;
switch (path) {
case 'edit':
push(linkToRecord(basePath, id));
return;
case 'show':
push(linkToRecord(basePath, id, 'show'));
return;
case 'expand':
this.handleToggleExpanded(event);
return;
case 'toggleSelection':
this.handleToggle(event);
return;
default:
if (path) push(path);
return;
}
};
const ShowButton = ({
basePath = '',
label = 'ra.action.show',
record = {},
icon: Icon = ImageEye,
...rest
}) => (
<button label="{label}">
</button>
);
{data[id].width}x{data[id].height},{" "}
}
actionIcon={
}
/>
))}
handleRedirection = (path, event) => {
const { basePath, id, push } = this.props;
switch (path) {
case 'edit':
push(linkToRecord(basePath, id));
return;
case 'show':
push(linkToRecord(basePath, id, 'show'));
return;
case 'expand':
this.handleToggleExpanded(event);
return;
case 'toggleSelection':
this.handleToggle(event);
return;
default:
if (path) push(path);
return;
}
};
const LinkOrNot = ({
linkType,
basePath,
id,
children,
}) => linkType === 'edit' || linkType === true ? (
{children}
) : linkType === 'show' ? (
{children}
) : (
<span>{children}</span>
);
handleRedirection = (path, event) => {
const { basePath, id, push } = this.props;
if (path === 'edit') {
push(linkToRecord(basePath, id));
return;
}
if (path === 'show') {
push(linkToRecord(basePath, id, 'show'));
return;
}
if (path === 'expand') {
this.handleToggleExpanded(event);
return;
}
push(path);
};
async event => {
if (!rowClick) return;
event.persist();
const effect =
typeof rowClick === 'function'
? await rowClick(id, basePath, record)
: rowClick;
switch (effect) {
case 'edit':
history.push(linkToRecord(basePath, id));
return;
case 'show':
history.push(linkToRecord(basePath, id, 'show'));
return;
case 'expand':
handleToggleExpand(event);
return;
case 'toggleSelection':
handleToggleSelection(event);
return;
default:
if (effect) history.push(effect);
return;
}
},
[
{ids.map(id => (
<img alt="" src="{data[id].thumbnail}">
{data[id].width}x{data[id].height},{' '}
{data[id].width}x{data[id].height},{' '}
}
actionIcon={
}
/>
))}