Skip to content

Commit

Permalink
Merge pull request #1143 from akvo/feature/1142-only-allow-county-and…
Browse files Browse the repository at this point in the history
…-superadmin-to-edit-data-point-in-manage-data

[#1142] Only Allow County and Super Admin to Edit Data-point in Manag…
  • Loading branch information
ifirmawan authored Feb 8, 2024
2 parents dcc0d60 + a39e416 commit dce4806
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/src/pages/manage-data/DataDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ const DataDetail = ({
))}
</div>
{!isPublic && (
<div>
<div className="button-save">
<Space>
<Button
type="primary"
Expand Down
20 changes: 16 additions & 4 deletions frontend/src/pages/manage-data/ManageData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
ExclamationCircleOutlined,
DeleteOutlined,
} from "@ant-design/icons";
import { api, store, uiText } from "../../lib";
import { api, config, store, uiText } from "../../lib";
import DataDetail from "./DataDetail";
import { DataFilters, Breadcrumbs, DescriptionPanel } from "../../components";
import { useNotification } from "../../util/hooks";
Expand All @@ -33,6 +33,7 @@ const ManageData = () => {
const [updateRecord, setUpdateRecord] = useState(false);
const [deleteData, setDeleteData] = useState(null);
const [deleting, setDeleting] = useState(false);
const [editable, setEditable] = useState(false);
const { language, advancedFilters } = store.useState((s) => s);
const { active: activeLang } = language;
const text = useMemo(() => {
Expand All @@ -49,9 +50,19 @@ const ManageData = () => {
},
];

const { administration, selectedForm, questionGroups } = store.useState(
(state) => state
);
const {
administration,
selectedForm,
questionGroups,
user: authUser,
} = store.useState((state) => state);

useEffect(() => {
const currentUser = config.roles.find(
(role) => role.name === authUser?.role_detail?.name
);
setEditable(!currentUser?.delete_data);
}, [authUser]);

const isAdministrationLoaded = administration.length;
const selectedAdministration =
Expand Down Expand Up @@ -211,6 +222,7 @@ const ManageData = () => {
updateRecord={updateRecord}
updater={setUpdateRecord}
setDeleteData={setDeleteData}
isPublic={editable}
/>
),
expandIcon: ({ expanded, onExpand, record }) =>
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/pages/manage-data/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#root {
#manageData {
tr.ant-table-expanded-row:hover > td,
tr.ant-table-expanded-row > td {
padding: 48px 16px 16px;
}
.data-detail {
height: 450px;
overflow-y: scroll;
Expand Down Expand Up @@ -59,5 +63,10 @@
}
}
}
.button-save {
position: absolute;
top: 0px;
right: 22px;
}
}
}

0 comments on commit dce4806

Please sign in to comment.