mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 23:35:45 +00:00
refactor(FE): Restrict edit and delete actions based on recording status
This commit is contained in:
@@ -104,8 +104,19 @@ const RowOptionsMenu = ({
|
|||||||
return recording.approval?.action === 'REJECTED';
|
return recording.approval?.action === 'REJECTED';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isRecordingEditable = (recording: Recording) => {
|
||||||
|
if (
|
||||||
|
recording.executed_at &&
|
||||||
|
recording.project_flock?.project_flock_category === 'GROWING'
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
const isApproved = isRecordingApproved(props.row.original);
|
const isApproved = isRecordingApproved(props.row.original);
|
||||||
const isRejected = isRecordingRejected(props.row.original);
|
const isRejected = isRecordingRejected(props.row.original);
|
||||||
|
const isEditable = isRecordingEditable(props.row.original);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='relative'>
|
<div className='relative'>
|
||||||
@@ -138,6 +149,7 @@ const RowOptionsMenu = ({
|
|||||||
View Details
|
View Details
|
||||||
</Button>
|
</Button>
|
||||||
</RequirePermission>
|
</RequirePermission>
|
||||||
|
{isEditable && (
|
||||||
<RequirePermission permissions='lti.production.recording.update'>
|
<RequirePermission permissions='lti.production.recording.update'>
|
||||||
<Button
|
<Button
|
||||||
href={`/production/recording/detail/edit/?recordingId=${props.row.original.id}`}
|
href={`/production/recording/detail/edit/?recordingId=${props.row.original.id}`}
|
||||||
@@ -150,6 +162,7 @@ const RowOptionsMenu = ({
|
|||||||
Edit
|
Edit
|
||||||
</Button>
|
</Button>
|
||||||
</RequirePermission>
|
</RequirePermission>
|
||||||
|
)}
|
||||||
{!isApproved && !isRejected && (
|
{!isApproved && !isRejected && (
|
||||||
<RequirePermission permissions='lti.production.recording.approve'>
|
<RequirePermission permissions='lti.production.recording.approve'>
|
||||||
<Button
|
<Button
|
||||||
@@ -182,6 +195,7 @@ const RowOptionsMenu = ({
|
|||||||
</Button>
|
</Button>
|
||||||
</RequirePermission>
|
</RequirePermission>
|
||||||
)}
|
)}
|
||||||
|
{isEditable && (
|
||||||
<RequirePermission permissions='lti.production.recording.delete'>
|
<RequirePermission permissions='lti.production.recording.delete'>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -196,6 +210,7 @@ const RowOptionsMenu = ({
|
|||||||
Delete
|
Delete
|
||||||
</Button>
|
</Button>
|
||||||
</RequirePermission>
|
</RequirePermission>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+1
@@ -49,6 +49,7 @@ export type BaseRecording = {
|
|||||||
project_flock: ProjectFlock;
|
project_flock: ProjectFlock;
|
||||||
record_datetime: string;
|
record_datetime: string;
|
||||||
day: number;
|
day: number;
|
||||||
|
executed_at: string;
|
||||||
} & ProductionMetrics;
|
} & ProductionMetrics;
|
||||||
|
|
||||||
export type RecordingDepletion = {
|
export type RecordingDepletion = {
|
||||||
|
|||||||
Reference in New Issue
Block a user