Added ability to change auth level IO-550
This commit is contained in:
@@ -21,6 +21,7 @@ const ret = {
|
||||
"jobs:intake": 1,
|
||||
"jobs:close": 5,
|
||||
"jobs:detail": 1,
|
||||
"jobs:partsqueue": 4,
|
||||
|
||||
"bills:enter": 2,
|
||||
"bills:view": 2,
|
||||
@@ -49,5 +50,8 @@ const ret = {
|
||||
|
||||
"timetickets:enter": 3,
|
||||
"timetickets:list": 3,
|
||||
"timetickets:edit": 4,
|
||||
|
||||
"users:editaccess": 4,
|
||||
};
|
||||
export default ret;
|
||||
|
||||
@@ -476,6 +476,18 @@ export default function ShopInfoRbacComponent({ form }) {
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("bodyshop.fields.rbac.users.editaccess")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
name={["md_rbac", "users:editaccess"]}
|
||||
>
|
||||
<InputNumber />
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { InputNumber, notification } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useMutation } from "react-apollo";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { UPDATE_ASSOCIATION } from "../../graphql/user.queries";
|
||||
|
||||
export default function ShopUsersAuthEdit({ association }) {
|
||||
const { t } = useTranslation();
|
||||
const [updateAssociation] = useMutation(UPDATE_ASSOCIATION);
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [value, setValue] = useState(association.authlevel);
|
||||
|
||||
const handleSave = async () => {
|
||||
setVisible(false);
|
||||
const result = await updateAssociation({
|
||||
variables: {
|
||||
assocId: association.id,
|
||||
assoc: { authlevel: value },
|
||||
},
|
||||
});
|
||||
|
||||
if (!!result.errors) {
|
||||
notification["error"]({
|
||||
message: t("user.errors.updating", {
|
||||
message: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
{visible && (
|
||||
<div>
|
||||
<InputNumber
|
||||
min={0}
|
||||
value={value}
|
||||
onChange={(val) => setValue(val)}
|
||||
defaultValue={association.authlevel}
|
||||
onBlur={handleSave}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{!visible && (
|
||||
<div style={{ cursor: "pointer" }} onClick={() => setVisible(true)}>
|
||||
{association.authlevel || t("general.labels.na")}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
59
client/src/components/shop-users/shop-users.component.jsx
Normal file
59
client/src/components/shop-users/shop-users.component.jsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import { Button, Table } from "antd";
|
||||
import React from "react";
|
||||
import { useQuery } from "react-apollo";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { QUERY_SHOP_ASSOCIATIONS } from "../../graphql/user.queries";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
|
||||
import ShopUsersAuthEdit from "../shop-users-auth-edit/shop-users-auth-edit.component";
|
||||
|
||||
export default function ShopInfoUsersComponent() {
|
||||
const { t } = useTranslation();
|
||||
const { loading, error, data } = useQuery(QUERY_SHOP_ASSOCIATIONS);
|
||||
const columns = [
|
||||
{
|
||||
title: t("user.fields.email"),
|
||||
dataIndex: "email",
|
||||
key: "email",
|
||||
render: (text, record) => record.user.email,
|
||||
},
|
||||
{
|
||||
title: t("user.fields.authlevel"),
|
||||
dataIndex: "authlevel",
|
||||
key: "authlevel",
|
||||
render: (text, record) => (
|
||||
<RbacWrapper action="users:editaccess">
|
||||
<ShopUsersAuthEdit association={record} />
|
||||
</RbacWrapper>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t("user.labels.actions"),
|
||||
dataIndex: "actions",
|
||||
key: "actions",
|
||||
render: (text, record) => (
|
||||
<div>
|
||||
<Button disabled onClick={() => {}}>
|
||||
{t("general.actions.delete")}
|
||||
</Button>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
if (error) {
|
||||
return <AlertComponent type="error" message={JSON.stringify(error)} />;
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<Table
|
||||
loading={loading}
|
||||
size="small"
|
||||
pagination={{ position: "top" }}
|
||||
columns={columns.map((item) => ({ ...item }))}
|
||||
rowKey="id"
|
||||
dataSource={data && data.associations}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user