From de111256b2721eab4876cbefb120aa53490c0cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Nagygy=C3=B6rgy?= Date: Tue, 26 Nov 2024 15:30:00 +0100 Subject: [PATCH 1/4] feat: image order column --- .../src/components/projects/versions/version-view-list.tsx | 5 +++-- web/crux-ui/src/elements/dyo-table.tsx | 2 +- web/crux/src/app/image/image.service.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/web/crux-ui/src/components/projects/versions/version-view-list.tsx b/web/crux-ui/src/components/projects/versions/version-view-list.tsx index d968e3bb6..fa04d17a2 100644 --- a/web/crux-ui/src/components/projects/versions/version-view-list.tsx +++ b/web/crux-ui/src/components/projects/versions/version-view-list.tsx @@ -2,7 +2,7 @@ import { DyoCard } from '@app/elements/dyo-card' import DyoIcon from '@app/elements/dyo-icon' import DyoLink from '@app/elements/dyo-link' import DyoModal, { DyoConfirmationModal } from '@app/elements/dyo-modal' -import DyoTable, { DyoColumn, sortDate, sortString } from '@app/elements/dyo-table' +import DyoTable, { DyoColumn, sortDate, sortNumber, sortString } from '@app/elements/dyo-table' import useConfirmation from '@app/hooks/use-confirmation' import useTeamRoutes from '@app/hooks/use-team-routes' import { DeleteImageMessage, VersionImage, WS_TYPE_DELETE_IMAGE } from '@app/models' @@ -53,7 +53,8 @@ const VersionViewList = (props: VersionViewListProps) => { return ( <> - + + `#${(data.orders + 1)}`} /> (props: React.PropsWithChildren>) => { return ( {columns.map((col, index) => { - const cellData = col.field ? getField(it, col.field) : col.body ? col.body(it, index) : null + const cellData = col.field ? getField(it, col.field) : col.body ? col.body(it, rowIndex) : null const paddingClass = index === 0 ? 'pl-6' : index === columns.length - 1 ? 'pr-6' : null const cursorClass = click && !col.preventClickThrough ? 'cursor-pointer' : null diff --git a/web/crux/src/app/image/image.service.ts b/web/crux/src/app/image/image.service.ts index 01cc04b9d..6d1aea352 100644 --- a/web/crux/src/app/image/image.service.ts +++ b/web/crux/src/app/image/image.service.ts @@ -109,7 +109,7 @@ export default class ImageService { }, }) - const lastOrder = lastImageOrder?.order ?? 0 + const lastOrder = lastImageOrder?.order ?? -1 let order = lastOrder + 1 // we need the generated uuids, so we can't use createMany From e244b05fc9574167e0942fc759fdcf28cbaea68b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Nagygy=C3=B6rgy?= Date: Tue, 26 Nov 2024 15:55:11 +0100 Subject: [PATCH 2/4] feat: fix orders in database --- .../migration.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 web/crux/prisma/migrations/20241126252000_normalize_image_order/migration.sql diff --git a/web/crux/prisma/migrations/20241126252000_normalize_image_order/migration.sql b/web/crux/prisma/migrations/20241126252000_normalize_image_order/migration.sql new file mode 100644 index 000000000..d3007b824 --- /dev/null +++ b/web/crux/prisma/migrations/20241126252000_normalize_image_order/migration.sql @@ -0,0 +1,11 @@ +-- Create temp table +SELECT "versionId", MIN("order") "order" INTO "_prisma_migrations_NormalizeOrder" FROM "Image" GROUP BY "versionId"; + +-- Normalize orders +UPDATE "Image" "img" SET "order" = "order" - ( + SELECT "order" FROM "_prisma_migrations_NormalizeOrder" "norm" + WHERE "norm"."versionId" = "img"."versionId" +); + +-- Drop temp table +DROP TABLE "_prisma_migrations_NormalizeOrder"; From e375ba6cd11e65e66a17282d2f0984792f94f10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bence=20Nagygy=C3=B6rgy?= Date: Tue, 26 Nov 2024 15:58:42 +0100 Subject: [PATCH 3/4] fix: language & NaN order --- web/crux-ui/locales/en/images.json | 3 ++- .../components/projects/versions/version-view-list.tsx | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/web/crux-ui/locales/en/images.json b/web/crux-ui/locales/en/images.json index 51975459b..eb72e6cb4 100644 --- a/web/crux-ui/locales/en/images.json +++ b/web/crux-ui/locales/en/images.json @@ -24,5 +24,6 @@ "unknownTag": "unknown", "invalidImageFormat": "Invalid format, please use 'NAME[:TAG]'", "tagRequired": "Tag is required", - "uncheckedRegistryExplanation": "Please be aware that you are using an unchecked registry. The tag you enter will be used directly, which means if the tag does not exist, the deployment will fail." + "uncheckedRegistryExplanation": "Please be aware that you are using an unchecked registry. The tag you enter will be used directly, which means if the tag does not exist, the deployment will fail.", + "order": "Order" } diff --git a/web/crux-ui/src/components/projects/versions/version-view-list.tsx b/web/crux-ui/src/components/projects/versions/version-view-list.tsx index fa04d17a2..f813f0d59 100644 --- a/web/crux-ui/src/components/projects/versions/version-view-list.tsx +++ b/web/crux-ui/src/components/projects/versions/version-view-list.tsx @@ -54,7 +54,14 @@ const VersionViewList = (props: VersionViewListProps) => { <> - `#${(data.orders + 1)}`} /> + `#${data.order + 1}`} + /> Date: Wed, 27 Nov 2024 12:58:36 +0100 Subject: [PATCH 4/4] fix: default column --- .../src/components/projects/versions/version-view-list.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/crux-ui/src/components/projects/versions/version-view-list.tsx b/web/crux-ui/src/components/projects/versions/version-view-list.tsx index f813f0d59..da3103116 100644 --- a/web/crux-ui/src/components/projects/versions/version-view-list.tsx +++ b/web/crux-ui/src/components/projects/versions/version-view-list.tsx @@ -53,7 +53,7 @@ const VersionViewList = (props: VersionViewListProps) => { return ( <> - +