Skip to content

Commit

Permalink
fix: implement logic
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Jan 16, 2025
1 parent 0be3dcf commit 585be0d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ export const OverflowMenuComponent = ({
displayChangelog,
teiId,
programAPI,
readOnlyMode,
}: PlainProps) => {
const [actionsIsOpen, setActionsIsOpen] = useState(false);
const [deleteModalIsOpen, setDeleteModalIsOpen] = useState(false);
const [changelogIsOpen, setChangelogIsOpen] = useState(false);

if (readOnlyMode && !displayChangelog) {
return null;
}

return (
<>
<OverflowButton
Expand All @@ -45,13 +50,15 @@ export const OverflowMenuComponent = ({
<MenuDivider dense />
</>
)}
<DeleteMenuItem
trackedEntityTypeName={trackedEntityTypeName}
canWriteData={canWriteData}
canCascadeDeleteTei={canCascadeDeleteTei}
setActionsIsOpen={setActionsIsOpen}
setDeleteModalIsOpen={setDeleteModalIsOpen}
/>
{!readOnlyMode && (
<DeleteMenuItem
trackedEntityTypeName={trackedEntityTypeName}
canWriteData={canWriteData}
canCascadeDeleteTei={canCascadeDeleteTei}
setActionsIsOpen={setActionsIsOpen}
setDeleteModalIsOpen={setDeleteModalIsOpen}
/>
)}
</FlyoutMenu>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const OverflowMenu = ({
displayChangelog,
teiId,
programAPI,
readOnlyMode,
}: Props) => {
const { hasAuthority } = useAuthorities({ authorities: ['F_TEI_CASCADE_DELETE'] });

Expand All @@ -27,6 +28,7 @@ export const OverflowMenu = ({
displayChangelog={displayChangelog}
teiId={teiId}
programAPI={programAPI}
readOnlyMode={readOnlyMode}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type Props = {|
displayChangelog: boolean,
teiId: string,
programAPI: any,
readOnlyMode: boolean,
|};

export type PlainProps = {|
Expand All @@ -21,4 +22,5 @@ export type PlainProps = {|
displayChangelog: boolean,
teiId: string,
programAPI: any,
readOnlyMode: boolean,
|};
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const WidgetProfilePlain = ({
trackedEntityData={clientAttributesWithSubvalues}
teiId={teiId}
programAPI={program}
readOnlyMode={readOnlyMode || false}
/>
</div>
</div>
Expand Down

0 comments on commit 585be0d

Please sign in to comment.