Skip to content

Commit

Permalink
Merge pull request #1389 from hinashi/feature/uuid_item_name
Browse files Browse the repository at this point in the history
Added parameter to make item name a UUID
  • Loading branch information
userlocalhost authored Mar 11, 2025
2 parents d21ec6e + 582e585 commit 26cede2
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions frontend/src/pages/EntryEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Box } from "@mui/material";
import React, { FC, useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import { useNavigate } from "react-router";
import { v4 as uuidv4 } from "uuid";

import { useAsyncWithThrow } from "../hooks/useAsyncWithThrow";

Expand Down Expand Up @@ -33,11 +34,13 @@ import {
interface Props {
excludeAttrs?: string[];
EntryForm?: FC<EntryFormProps>;
useUUID?: boolean;
}

export const EntryEditPage: FC<Props> = ({
excludeAttrs = [],
EntryForm = DefaultEntryForm,
useUUID = false,
}) => {
const { entityId, entryId } = useTypedParams<{
entityId: number;
Expand Down Expand Up @@ -86,6 +89,7 @@ export const EntryEditPage: FC<Props> = ({
entity.value,
excludeAttrs,
);
entryInfo.name = useUUID ? uuidv4() : "";
reset(entryInfo);
setInitialized(true);
}
Expand Down
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ module.exports = {
"frontend/src",
"node_modules"
],
moduleNameMapper: {
uuid: require.resolve('uuid')
},
transformIgnorePatterns: [],
testEnvironment: "jsdom",
testEnvironmentOptions: {
Expand Down
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"@types/react-copy-to-clipboard": "^5.0.7",
"@types/react-infinite-scroller": "^1.2.5",
"@types/react-scroll": "^1.8.10",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"babel-loader": "^8.4.1",
Expand Down Expand Up @@ -113,6 +114,7 @@
"ts-loader": "^9.5.2",
"typescript": "^5.8.2",
"undici": "^5.28.5",
"uuid": "^11.1.0",
"webpack": "^5.98.0",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^4.10.0",
Expand Down

0 comments on commit 26cede2

Please sign in to comment.