Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove api call ID prefix for db CRUD #105

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SequenceRunDetailsDrawer: FC<SequenceRunDetailsDrawerProps> = ({

const { data: sequenceRunDetail, isFetching: isFetchingSequenceRunDetail } =
useSequenceRunDetailModel({
params: { path: { id: selectedSequenceRunId } },
params: { path: { id: selectedSequenceRunId?.split('.')[1] as string } },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this stripped the prefix out (leaving just the ULID)? umccr/orcabus#784 should basically do that so the FE don't need to this anymore.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there is a bug from that PR? But from testing in https://sequence.dev.umccr.org/schema/swagger-ui/# it does seems work with or without the prefixes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, FE will need the prefix+ULID in its url for page pathway, not for api call. when make api call, ULID will be enough to find the instance. Not sure for all, but for sequence and workflow manager, so far is okay

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there is a bug from that PR? But from testing in https://sequence.dev.umccr.org/schema/swagger-ui/# it does seems work with or without the prefixes

And also I remove the prefix because there will a conflict like this when make api call with prefix when saving the association_id. If we keep consistency when make api call with out prefix, no conflict and no need to touch BE code
image

Copy link
Member

@williamputraintan williamputraintan Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix here is for the API call not for FE page pathway? So the strip here makes no difference in the results?

FE will need the prefix+ULID in its url for page pathway,

Why the FE would need the prefix? Should it just pass the ID through the API?

Copy link
Contributor Author

@raylrui raylrui Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, actually FE don't need the prefix as well, just take it directly from db read. I will have a think to remove it all...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also I remove the prefix because there will a conflict like this when make api call with prefix when saving the association_id. If we keep consistency when make api call with out prefix, no conflict and no need to touch BE code

I think the logic should then be in BE so that any client using the API should not care about this? Perhaps if think we could just change this association_id to become OrcaBusIdField instead of CharField then the stripping will be handled automatically.

reactQuery: {
enabled: !!selectedSequenceRunId,
},
Expand Down
40 changes: 25 additions & 15 deletions src/modules/runs/components/sequenceRuns/SequenceRunTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:

const { data: sequenceRunStateDetail, isFetching: isFetchingSequenceRunStateDetail } =
useSequenceRunStateListModel({
params: { path: { orcabusId: selectedSequenceRunID } },
params: { path: { orcabusId: selectedSequenceRunID?.split('.')[1] as string } },
reactQuery: {
enabled: !!selectedSequenceRunID,
},
Expand All @@ -48,7 +48,7 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:
isFetching: isFetchingSequenceRunComments,
refetch: refetchSequenceRunComment,
} = useSequenceRunCommentListModel({
params: { path: { orcabusId: selectedSequenceRunID } },
params: { path: { orcabusId: selectedSequenceRunID?.split('.')[1] as string } },
reactQuery: {
enabled: !!selectedSequenceRunID,
},
Expand All @@ -58,7 +58,7 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:
return sequenceRunStateDetail?.map((state) => ({
id: state.orcabusId || '',
content: (
<div className='flex flex-row gap-2 text-sm text-gray-500 group'>
<div className='group flex flex-row gap-2 text-sm text-gray-500'>
<div>Status Updated</div>
<Badge status={state.status}>{state.status}</Badge>
</div>
Expand All @@ -76,15 +76,15 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:
return sequenceRunCommentsDetail?.map((comment) => ({
id: comment.orcabusId || '',
content: (
<div className='flex flex-row gap-2 text-sm text-gray-500 group'>
<div className='font-medium text-nowrap'>{`${getUsername(comment.createdBy)} `}</div>
<div className='text-gray-500 text-nowrap'>made a new</div>
<div className='group flex flex-row gap-2 text-sm text-gray-500'>
<div className='text-nowrap font-medium'>{`${getUsername(comment.createdBy)} `}</div>
<div className='text-nowrap text-gray-500'>made a new</div>
<Badge type='unknown'>Comment</Badge>
{comment.comment && (
<div className='opacity-0 group-hover:opacity-100 flex flex-row gap-2'>
<div className='flex flex-row gap-2 opacity-0 group-hover:opacity-100'>
<Tooltip text='Update' position='top' background='white'>
<WrenchIcon
className='w-4 h-4 cursor-pointer stroke-gray-500'
className='h-4 w-4 cursor-pointer stroke-gray-500'
onClick={() => {
setCommentId(comment.orcabusId);
setComment(comment.comment);
Expand All @@ -94,7 +94,7 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:
</Tooltip>
<Tooltip text='Delete' position='top' background='white'>
<TrashIcon
className='w-4 h-4 cursor-pointer stroke-gray-500'
className='h-4 w-4 cursor-pointer stroke-gray-500'
onClick={() => {
setCommentId(comment.orcabusId);
setIsOpenDeleteCommentDialog(true);
Expand Down Expand Up @@ -126,7 +126,7 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:
isError: isErrorCreatingSequenceRunComment,
reset: resetCreateSequenceRunComment,
} = useSequenceRunCommentCreateModel({
params: { path: { orcabusId: selectedSequenceRunID } },
params: { path: { orcabusId: selectedSequenceRunID?.split('.')[1] as string } },
body: {
comment: comment,
createdBy: user?.email,
Expand Down Expand Up @@ -163,7 +163,12 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:
isError: isErrorUpdatingSequenceRunComment,
reset: resetUpdateSequenceRunComment,
} = useSequenceRunCommentUpdateModel({
params: { path: { orcabusId: selectedSequenceRunID as string, id: commentId as string } },
params: {
path: {
orcabusId: selectedSequenceRunID?.split('.')[1] as string,
id: commentId?.split('.')[1] as string,
},
},
body: {
comment: comment,
createdBy: user?.email,
Expand Down Expand Up @@ -203,7 +208,12 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:
isError: isErrorDeletingSequenceRunComment,
reset: resetDeleteSequenceRunComment,
} = useSequenceRunCommentDeleteModel({
params: { path: { orcabusId: selectedSequenceRunID as string, id: commentId as string } },
params: {
path: {
orcabusId: selectedSequenceRunID?.split('.')[1] as string,
id: commentId?.split('.')[1] as string,
},
},
body: {
createdBy: user?.email,
},
Expand Down Expand Up @@ -248,7 +258,7 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:
}}
className='ring-2 ring-gray-300'
>
<PlusIcon className='w-4 h-4' />
<PlusIcon className='h-4 w-4' />
Add Comment
</Button>
</div>
Expand All @@ -263,7 +273,7 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:
<Textarea
value={comment}
onChange={(e) => setComment(e.target.value)}
className='border-gray-400 rounded-md border-[1px] py-1.5 px-3 text-sm/6'
className='rounded-md border-[1px] border-gray-400 px-3 py-1.5 text-sm/6'
/>
</div>
}
Expand All @@ -289,7 +299,7 @@ const SequenceRunTimeline = ({ selectedSequenceRunId }: { selectedSequenceRunId:
<Textarea
value={comment}
onChange={(e) => setComment(e.target.value)}
className='border-gray-400 rounded-md border-[1px] py-1.5 px-3 text-sm/6'
className='rounded-md border-[1px] border-gray-400 px-3 py-1.5 text-sm/6'
/>
</div>
}
Expand Down