Skip to content

Implement msadmins settings update - #53

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions src/components/settings/SettingEdit.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import React from "react";
import { Edit, SimpleForm, TextInput } from "react-admin";
import {
Edit,
SimpleForm,
TextInput,
EditController,
EditView,
BooleanInput,
} from "react-admin";

const SettingEdit = (props) => (
<Edit label="Settings" {...props}>
<SimpleForm>
<TextInput label="Requests per Minute (max)" source="maxRequestsPerMin" />
<TextInput
disabled
label="Items per Page (default)"
source="maxItemsPerPage"
/>
<TextInput label="Items per Page (max)" source="defaultItemsPerPage" />
</SimpleForm>
<Edit label="Settings" title=" " {...props}>
<EditController {...props}>
{(controllerProps) => (
<EditView title="Settings" {...controllerProps}>
<SimpleForm>
{controllerProps.record &&
Object.keys(controllerProps.record).map((key) =>
/true|false/.test(controllerProps.record[key]) ? (
<BooleanInput key={key} source={key} />
) : (
<TextInput key={key} source={key} />
)
)}
</SimpleForm>
</EditView>
)}
</EditController>
</Edit>
);

Expand Down
40 changes: 30 additions & 10 deletions src/components/settings/SettingShow.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
import React from "react";
import { Show, SimpleShowLayout, TextField } from "react-admin";
import {
Show,
SimpleShowLayout,
TextField,
ShowController,
ShowView,
BooleanField,
} from "react-admin";

const SettingShow = (props) => (
<Show label="Settings" title="Settings" {...props}>
<SimpleShowLayout>
<TextField label="Requests per Minute (max)" source="maxRequestsPerMin" />
<TextField label="Items per Page (default)" source="maxItemsPerPage" />
<TextField label="Items per Page (max)" source="defaultItemsPerPage" />
</SimpleShowLayout>
</Show>
);
const SettingShow = (props) => {
return (
<Show title="Settings" {...props}>
<ShowController {...props}>
{(controllerProps) => (
<ShowView title="Settings" {...controllerProps}>
<SimpleShowLayout>
{controllerProps.record &&
Object.keys(controllerProps.record).map((key) =>
/true|false/.test(controllerProps.record[key]) ? (
<BooleanField key={key} source={key} />
) : (
<TextField key={key} source={key} />
)
)}
</SimpleShowLayout>
</ShowView>
)}
</ShowController>
</Show>
);
};

export default SettingShow;
2 changes: 2 additions & 0 deletions src/components/settings/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import SettingShow from "./SettingShow";
import SettingEdit from "./SettingEdit";
import SettingIcon from "@material-ui/icons/Settings";

export default {
list: SettingShow,
edit: SettingEdit,
show: SettingShow,
icon: SettingIcon,
};