Skip to content

Commit

Permalink
rename now working
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathanko52 committed Jan 4, 2024
1 parent f8abd9f commit 85c730b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/src/components/Projects/ProjectContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const ProjectContextMenu = ({
</li>
) : null}

{!project.dateSnapshotted ? (
{!project.dateSnapshotted && project.loginId == account.id ? (
<li
className={classes.listItem}
onClick={() => handleClick(handleSnapshotModalOpen)}
Expand Down
16 changes: 16 additions & 0 deletions server/app/controllers/project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ const snapshot = async (req, res) => {
}
};

const renameSnapshot = async (req, res) => {
try {
const { id, name } = req.body;

const result = await projectService.renameSnapshot(id, req.user.id, name);
if (result === 1) {
res.sendStatus(403);
} else {
res.sendStatus(204);
}
} catch (err) {
res.status(500).send(err);
}
};

const getAllArchivedProjects = async (req, res) => {
try {
if (!req.user.isSecurityAdmin) {
Expand All @@ -141,5 +156,6 @@ module.exports = {
hide,
trash,
snapshot,
renameSnapshot,
getAllArchivedProjects
};
5 changes: 5 additions & 0 deletions server/app/routes/project.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,10 @@ router.post("/", jwtSession.validateUser, projectController.post);
router.put("/hide", jwtSession.validateUser, projectController.hide);
router.put("/trash", jwtSession.validateUser, projectController.trash);
router.put("/snapshot", jwtSession.validateUser, projectController.snapshot);
router.put(
"/renameSnapshot",
jwtSession.validateUser,
projectController.renameSnapshot
);
router.put("/:id", jwtSession.validateUser, projectController.put);
router.delete("/:id", jwtSession.validateUser, projectController.del);
18 changes: 18 additions & 0 deletions server/app/services/project.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ const snapshot = async (id, loginId, name) => {
}
};

const renameSnapshot = async (id, loginId, name) => {
try {
await poolConnect;
const request = pool.request();

request.input("id", id);
request.input("loginId", loginId);
request.input("name", name);

const response = await request.execute("Project_Rename");
return response.returnValue;
} catch (err) {
console.log("err:", err);
return Promise.reject(err);
}
};

const getAllArchivedProjects = async () => {
try {
await poolConnect;
Expand All @@ -159,5 +176,6 @@ module.exports = {
hide,
trash,
snapshot,
renameSnapshot,
getAllArchivedProjects
};

0 comments on commit 85c730b

Please sign in to comment.