Remove/mark unused parameters

All top level components should pass props to the generic react-admin
component to be more versatile.

Change-Id: I25dd099cde1aefacbc748dc4716a8b0a3db9ab93
This commit is contained in:
Manuel Stahl 2024-02-05 13:06:47 +01:00
parent 78d1d34a84
commit af453eea71
10 changed files with 142 additions and 147 deletions

View File

@ -98,26 +98,23 @@ export const ReportShow = props => {
);
};
export const ReportList = ({ ...props }) => {
return (
<List
{...props}
pagination={<ReportPagination />}
sort={{ field: "received_ts", order: "DESC" }}
bulkActionButtons={false}
>
<Datagrid rowClick="show">
<TextField source="id" sortable={false} />
<DateField
source="received_ts"
showTime
options={date_format}
sortable={true}
/>
<TextField sortable={false} source="user_id" />
<TextField sortable={false} source="name" />
<TextField sortable={false} source="score" />
</Datagrid>
</List>
);
};
export const ReportList = props => (
<List
{...props}
pagination={<ReportPagination />}
sort={{ field: "received_ts", order: "DESC" }}
>
<Datagrid rowClick="show" bulkActionButtons={false}>
<TextField source="id" sortable={false} />
<DateField
source="received_ts"
showTime
options={date_format}
sortable={true}
/>
<TextField sortable={false} source="user_id" />
<TextField sortable={false} source="name" />
<TextField sortable={false} source="score" />
</Datagrid>
</List>
);

View File

@ -32,7 +32,7 @@ function TranslatableOption({ value, text }) {
return <option value={value}>{translate(text)}</option>;
}
const FilePicker = props => {
const FilePicker = () => {
const [values, setValues] = useState(null);
const [error, setError] = useState(null);
const [stats, setStats] = useState(null);
@ -191,7 +191,7 @@ const FilePicker = props => {
return true;
};
const runImport = async e => {
const runImport = async _e => {
if (progress !== null) {
notify("import_users.errors.already_in_progress");
return;
@ -307,7 +307,7 @@ const FilePicker = props => {
let retries = 0;
const submitRecord = recordData => {
return dataProvider.getOne("users", { id: recordData.id }).then(
async alreadyExists => {
async _alreadyExists => {
if (LOGGING) console.log("already existed");
if (useridMode === "update" || conflictMode === "skip") {
@ -332,7 +332,7 @@ const FilePicker = props => {
}
}
},
async okToSubmit => {
async _okToSubmit => {
if (LOGGING)
console.log(
"OK to create record " +

View File

@ -54,30 +54,28 @@ const dateFormatter = v => {
const registrationTokenFilters = [<BooleanInput source="valid" alwaysOn />];
export const RegistrationTokenList = props => {
return (
<List
{...props}
filters={registrationTokenFilters}
filterDefaultValues={{ valid: true }}
pagination={false}
perPage={500}
>
<Datagrid rowClick="edit">
<TextField source="token" sortable={false} />
<NumberField source="uses_allowed" sortable={false} />
<NumberField source="pending" sortable={false} />
<NumberField source="completed" sortable={false} />
<DateField
source="expiry_time"
showTime
options={date_format}
sortable={false}
/>
</Datagrid>
</List>
);
};
export const RegistrationTokenList = props => (
<List
{...props}
filters={registrationTokenFilters}
filterDefaultValues={{ valid: true }}
pagination={false}
perPage={500}
>
<Datagrid rowClick="edit">
<TextField source="token" sortable={false} />
<NumberField source="uses_allowed" sortable={false} />
<NumberField source="pending" sortable={false} />
<NumberField source="completed" sortable={false} />
<DateField
source="expiry_time"
showTime
options={date_format}
sortable={false}
/>
</Datagrid>
</List>
);
export const RegistrationTokenCreate = props => (
<Create {...props}>
@ -104,24 +102,22 @@ export const RegistrationTokenCreate = props => (
</Create>
);
export const RegistrationTokenEdit = props => {
return (
<Edit {...props}>
<SimpleForm>
<TextInput source="token" disabled />
<NumberInput source="pending" disabled />
<NumberInput source="completed" disabled />
<NumberInput
source="uses_allowed"
validate={validateUsesAllowed}
step={1}
/>
<DateTimeInput
source="expiry_time"
parse={dateParser}
format={dateFormatter}
/>
</SimpleForm>
</Edit>
);
};
export const RegistrationTokenEdit = props => (
<Edit {...props}>
<SimpleForm>
<TextInput source="token" disabled />
<NumberInput source="pending" disabled />
<NumberInput source="completed" disabled />
<NumberInput
source="uses_allowed"
validate={validateUsesAllowed}
step={1}
/>
<DateTimeInput
source="expiry_time"
parse={dateParser}
format={dateFormatter}
/>
</SimpleForm>
</Edit>
);

View File

@ -102,16 +102,16 @@ export const RoomDirectorySaveButton = () => {
const refresh = useRefresh();
const [create, { isloading }] = useCreate();
const handleSend = values => {
const handleSend = () => {
create(
"room_directory",
{ data: { id: record.id } },
{
onSuccess: data => {
onSuccess: _data => {
notify("resources.room_directory.action.send_success");
refresh();
},
onError: error =>
onError: _error =>
notify("resources.room_directory.action.send_failure", {
type: "error",
}),

View File

@ -42,7 +42,7 @@ const destinationRowSx = (record, _index) => ({
const destinationFilters = [<SearchInput source="destination" alwaysOn />];
export const DestinationReconnectButton = props => {
export const DestinationReconnectButton = () => {
const record = useRecordContext();
const refresh = useRefresh();
const notify = useNotify();
@ -83,13 +83,13 @@ export const DestinationReconnectButton = props => {
);
};
const DestinationShowActions = props => (
const DestinationShowActions = () => (
<TopToolbar>
<DestinationReconnectButton />
</TopToolbar>
);
const DestinationTitle = props => {
const DestinationTitle = () => {
const record = useRecordContext();
const translate = useTranslate();
return (

View File

@ -44,6 +44,7 @@ export const DeviceRemoveButton = props => {
return (
<>
<Button
{...props}
label="ra.action.remove"
onClick={handleClick}
sx={{

View File

@ -122,6 +122,7 @@ export const DeleteMediaButton = props => {
return (
<>
<Button
{...props}
label="resources.delete_media.action.send"
onClick={handleDialogOpen}
disabled={isLoading}
@ -298,7 +299,7 @@ export const QuarantineMediaButton = props => {
})}
>
<div>
<Button disabled={true}>
<Button {...props} disabled={true}>
<ClearIcon />
</Button>
</div>
@ -311,7 +312,11 @@ export const QuarantineMediaButton = props => {
})}
>
<div>
<Button onClick={handleRemoveQuarantaine} disabled={isLoading}>
<Button
{...props}
onClick={handleRemoveQuarantaine}
disabled={isLoading}
>
<BlockIcon color="error" />
</Button>
</div>

View File

@ -54,7 +54,7 @@ const RoomPagination = props => (
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
);
const RoomTitle = props => {
const RoomTitle = () => {
const record = useRecordContext();
const translate = useTranslate();
var name = "";
@ -69,23 +69,23 @@ const RoomTitle = props => {
);
};
const RoomShowActions = ({ data, resource }) => {
const RoomShowActions = () => {
const record = useRecordContext();
var roomDirectoryStatus = "";
if (data) {
roomDirectoryStatus = data.public;
if (record) {
roomDirectoryStatus = record.public;
}
return (
<TopToolbar>
{roomDirectoryStatus === false && (
<RoomDirectorySaveButton record={data} />
<RoomDirectorySaveButton record={record} />
)}
{roomDirectoryStatus === true && (
<RoomDirectoryDeleteButton record={data} />
<RoomDirectoryDeleteButton record={record} />
)}
<DeleteButton
record={data}
resource={resource}
record={record}
mutationMode="pessimistic"
confirmTitle="resources.rooms.action.erase.title"
confirmContent="resources.rooms.action.erase.content"
@ -298,11 +298,12 @@ const RoomListActions = () => (
</TopToolbar>
);
export const RoomList = () => {
export const RoomList = props => {
const theme = useTheme();
return (
<List
{...props}
pagination={<RoomPagination />}
sort={{ field: "name", order: "ASC" }}
filters={roomFilters}

View File

@ -52,27 +52,25 @@ const UserMediaStatsPagination = props => (
const userMediaStatsFilters = [<SearchInput source="search_term" alwaysOn />];
export const UserMediaStatsList = props => {
return (
<List
{...props}
actions={<ListActions />}
filters={userMediaStatsFilters}
pagination={<UserMediaStatsPagination />}
sort={{ field: "media_length", order: "DESC" }}
export const UserMediaStatsList = props => (
<List
{...props}
actions={<ListActions />}
filters={userMediaStatsFilters}
pagination={<UserMediaStatsPagination />}
sort={{ field: "media_length", order: "DESC" }}
>
<Datagrid
rowClick={(id, resource, record) => "/users/" + id + "/media"}
bulkActionButtons={false}
>
<Datagrid
rowClick={(id, resource, record) => "/users/" + id + "/media"}
bulkActionButtons={false}
>
<TextField source="user_id" label="resources.users.fields.id" />
<TextField
source="displayname"
label="resources.users.fields.displayname"
/>
<NumberField source="media_count" />
<NumberField source="media_length" />
</Datagrid>
</List>
);
};
<TextField source="user_id" label="resources.users.fields.id" />
<TextField
source="displayname"
label="resources.users.fields.displayname"
/>
<NumberField source="media_count" />
<NumberField source="media_length" />
</Datagrid>
</List>
);

View File

@ -134,11 +134,10 @@ const userFilters = [
/>,
];
const UserBulkActionButtons = props => (
const UserBulkActionButtons = () => (
<>
<ServerNoticeBulkButton {...props} />
<ServerNoticeBulkButton />
<BulkDeleteButton
{...props}
label="resources.users.action.erase"
confirmTitle="resources.users.helper.erase"
mutationMode="pessimistic"
@ -146,37 +145,35 @@ const UserBulkActionButtons = props => (
</>
);
export const UserList = props => {
return (
<List
{...props}
filters={userFilters}
filterDefaultValues={{ guests: true, deactivated: false }}
sort={{ field: "name", order: "ASC" }}
actions={<UserListActions maxResults={10000} />}
pagination={<UserPagination />}
>
<Datagrid rowClick="edit" bulkActionButtons={<UserBulkActionButtons />}>
<AvatarField
source="avatar_src"
sx={{ height: "40px", width: "40px" }}
sortBy="avatar_url"
/>
<TextField source="id" sortBy="name" />
<TextField source="displayname" />
<BooleanField source="is_guest" />
<BooleanField source="admin" />
<BooleanField source="deactivated" />
<DateField
source="creation_ts"
label="resources.users.fields.creation_ts_ms"
showTime
options={date_format}
/>
</Datagrid>
</List>
);
};
export const UserList = props => (
<List
{...props}
filters={userFilters}
filterDefaultValues={{ guests: true, deactivated: false }}
sort={{ field: "name", order: "ASC" }}
actions={<UserListActions maxResults={10000} />}
pagination={<UserPagination />}
>
<Datagrid rowClick="edit" bulkActionButtons={<UserBulkActionButtons />}>
<AvatarField
source="avatar_src"
sx={{ height: "40px", width: "40px" }}
sortBy="avatar_url"
/>
<TextField source="id" sortBy="name" />
<TextField source="displayname" />
<BooleanField source="is_guest" />
<BooleanField source="admin" />
<BooleanField source="deactivated" />
<DateField
source="creation_ts"
label="resources.users.fields.creation_ts_ms"
showTime
options={date_format}
/>
</Datagrid>
</List>
);
// https://matrix.org/docs/spec/appendices#user-identifiers
// here only local part of user_id
@ -300,7 +297,7 @@ export const UserCreate = props => (
</Create>
);
const UserTitle = props => {
const UserTitle = () => {
const record = useRecordContext();
const translate = useTranslate();
return (