rearrange columns
This commit is contained in:
parent
6450d91335
commit
114dfbe98a
@ -2,7 +2,9 @@ import React, { Fragment, useState } from "react";
|
|||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import { fade } from "@material-ui/core/styles/colorManipulator";
|
import { fade } from "@material-ui/core/styles/colorManipulator";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
|
import { Tooltip } from "@material-ui/core";
|
||||||
import {
|
import {
|
||||||
|
BooleanField,
|
||||||
BooleanInput,
|
BooleanInput,
|
||||||
Button,
|
Button,
|
||||||
DateTimeInput,
|
DateTimeInput,
|
||||||
@ -16,6 +18,7 @@ import {
|
|||||||
useRefresh,
|
useRefresh,
|
||||||
useTranslate,
|
useTranslate,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
|
import ClearIcon from "@material-ui/icons/Clear";
|
||||||
import DeleteSweepIcon from "@material-ui/icons/DeleteSweep";
|
import DeleteSweepIcon from "@material-ui/icons/DeleteSweep";
|
||||||
import Dialog from "@material-ui/core/Dialog";
|
import Dialog from "@material-ui/core/Dialog";
|
||||||
import DialogContent from "@material-ui/core/DialogContent";
|
import DialogContent from "@material-ui/core/DialogContent";
|
||||||
@ -150,6 +153,7 @@ export const DeleteMediaButton = props => {
|
|||||||
|
|
||||||
export const ProtectMediaButton = props => {
|
export const ProtectMediaButton = props => {
|
||||||
const { record } = props;
|
const { record } = props;
|
||||||
|
const translate = useTranslate();
|
||||||
const refresh = useRefresh();
|
const refresh = useRefresh();
|
||||||
const notify = useNotify();
|
const notify = useNotify();
|
||||||
const [create, { loading }] = useCreate("protect_media");
|
const [create, { loading }] = useCreate("protect_media");
|
||||||
@ -186,24 +190,54 @@ export const ProtectMediaButton = props => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
/*
|
||||||
|
Wrapping Tooltip with <div>
|
||||||
|
https://github.com/marmelab/react-admin/issues/4349#issuecomment-578594735
|
||||||
|
*/
|
||||||
<Fragment>
|
<Fragment>
|
||||||
{!record.safe_from_quarantine && !record.quarantined_by && (
|
{record.quarantined_by && (
|
||||||
<Button
|
<Tooltip
|
||||||
label="resources.protect_media.action.create"
|
title={translate("resources.protect_media.action.none", {
|
||||||
onClick={handleProtect}
|
_: "resources.protect_media.action.none",
|
||||||
disabled={loading}
|
})}
|
||||||
>
|
>
|
||||||
<LockIcon />
|
<div>
|
||||||
|
{/*
|
||||||
|
Button instead BooleanField for
|
||||||
|
consistent appearance and position in the column
|
||||||
|
*/}
|
||||||
|
<Button disabled={true}>
|
||||||
|
<ClearIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
{record.safe_from_quarantine && (
|
{record.safe_from_quarantine && (
|
||||||
<Button
|
<Tooltip
|
||||||
label="resources.protect_media.action.delete"
|
title={translate("resources.protect_media.action.delete", {
|
||||||
onClick={handleUnprotect}
|
_: "resources.protect_media.action.delete",
|
||||||
disabled={loading}
|
})}
|
||||||
|
arrow
|
||||||
>
|
>
|
||||||
|
<div>
|
||||||
|
<Button onClick={handleUnprotect} disabled={loading}>
|
||||||
|
<LockIcon />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
{!record.safe_from_quarantine && !record.quarantined_by && (
|
||||||
|
<Tooltip
|
||||||
|
title={translate("resources.protect_media.action.create", {
|
||||||
|
_: "resources.protect_media.action.create",
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<Button onClick={handleProtect} disabled={loading}>
|
||||||
<LockOpenIcon />
|
<LockOpenIcon />
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
|
@ -466,8 +466,7 @@ export const UserEdit = props => {
|
|||||||
<TextField source="media_type" />
|
<TextField source="media_type" />
|
||||||
<TextField source="upload_name" />
|
<TextField source="upload_name" />
|
||||||
<TextField source="quarantined_by" />
|
<TextField source="quarantined_by" />
|
||||||
<BooleanField source="safe_from_quarantine" />
|
<ProtectMediaButton label="resources.users_media.fields.safe_from_quarantine" />
|
||||||
<ProtectMediaButton />
|
|
||||||
<DeleteButton mutationMode="pessimistic" redirect={false} />
|
<DeleteButton mutationMode="pessimistic" redirect={false} />
|
||||||
</Datagrid>
|
</Datagrid>
|
||||||
</ReferenceManyField>
|
</ReferenceManyField>
|
||||||
|
@ -265,8 +265,9 @@ const de = {
|
|||||||
},
|
},
|
||||||
protect_media: {
|
protect_media: {
|
||||||
action: {
|
action: {
|
||||||
create: "Schützen",
|
create: "Ungeschützt, Schutz erstellen",
|
||||||
delete: "Schutz aufheben",
|
delete: "Geschützt, Schutz aufheben",
|
||||||
|
none: "In Quarantäne",
|
||||||
send_success: "Erfolgreich den Schutz-Status geändert.",
|
send_success: "Erfolgreich den Schutz-Status geändert.",
|
||||||
send_failure: "Beim Versenden ist ein Fehler aufgetreten.",
|
send_failure: "Beim Versenden ist ein Fehler aufgetreten.",
|
||||||
},
|
},
|
||||||
|
@ -261,8 +261,9 @@ const en = {
|
|||||||
},
|
},
|
||||||
protect_media: {
|
protect_media: {
|
||||||
action: {
|
action: {
|
||||||
create: "Protect",
|
create: "Unprotected, create protection",
|
||||||
delete: "Unprotect",
|
delete: "Protected, remove protection",
|
||||||
|
none: "In quarantine",
|
||||||
send_success: "Successfully changed the protection status.",
|
send_success: "Successfully changed the protection status.",
|
||||||
send_failure: "An error has occurred.",
|
send_failure: "An error has occurred.",
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user