Skip to content

Commit

Permalink
Revert "fix: disable button and add tooltip"
Browse files Browse the repository at this point in the history
This reverts commit 8cfb4a6.
  • Loading branch information
henrikmv committed Oct 25, 2024
1 parent 8cfb4a6 commit 3c078b7
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 47 deletions.
7 changes: 2 additions & 5 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-10-25T17:42:56.394Z\n"
"PO-Revision-Date: 2024-10-25T17:42:56.394Z\n"
"POT-Creation-Date: 2024-10-25T14:57:43.514Z\n"
"PO-Revision-Date: 2024-10-25T14:57:43.514Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -1136,9 +1136,6 @@ msgstr "Mark as cancelled"
msgid "Mark incomplete"
msgstr "Mark incomplete"

msgid "You do not have access to delete this enrollment"
msgstr "You do not have access to delete this enrollment"

msgid "Delete enrollment"
msgstr "Delete enrollment"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const ActionsPlain = ({
onUpdate,
onDelete,
onUpdateOwnership,
canCascadeDeleteEnrollment,
isTransferLoading,
onAddNew,
loading,
Expand Down Expand Up @@ -116,7 +115,6 @@ export const ActionsPlain = ({
onUpdate={handleOnUpdateStatus}
/>
<Delete
canCascadeDeleteEnrollment={canCascadeDeleteEnrollment}
enrollment={enrollment}
onDelete={handleOnDelete}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ActionsComponent } from './Actions.component';
import type { Props } from './actions.types';
import { useUpdateEnrollment, useDeleteEnrollment } from '../dataMutation/dataMutation';
import { useUpdateOwnership } from './Transfer/hooks';
import { useAuthorities } from '../hooks/useAuthorities';

export const Actions = ({
enrollment = {},
Expand All @@ -21,7 +20,6 @@ export const Actions = ({
}: Props) => {
const { updateMutation, updateLoading } = useUpdateEnrollment(refetchEnrollment, refetchTEI, onError, onSuccess);
const { deleteMutation, deleteLoading } = useDeleteEnrollment(onDelete, onError, onSuccess);
const { canCasacdeDeleteEnrollment } = useAuthorities();
const { updateEnrollmentOwnership, isTransferLoading } = useUpdateOwnership({
teiId: enrollment.trackedEntity,
programId: enrollment.program,
Expand Down Expand Up @@ -54,7 +52,6 @@ export const Actions = ({
onUpdate={updateMutation}
onUpdateStatus={handleUpdateStatus}
onDelete={deleteMutation}
canCascadeDeleteEnrollment={canCasacdeDeleteEnrollment}
loading={updateLoading || deleteLoading || updateStatusLoading}
onUpdateOwnership={updateEnrollmentOwnership}
isTransferLoading={isTransferLoading}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @flow
import React, { useState, useMemo } from 'react';
import {
IconDelete16,
MenuItem,
Expand All @@ -10,21 +9,18 @@ import {
ButtonStrip,
Button,
} from '@dhis2/ui';
import React, { useState } from 'react';
import i18n from '@dhis2/d2-i18n';
import type { Props } from './delete.types';
import { ConditionalTooltip } from '../../../Tooltips/ConditionalTooltip/';

export const Delete = ({ canCascadeDeleteEnrollment, enrollment, onDelete }: Props) => {
export const Delete = ({ enrollment, onDelete }: Props) => {
const [toggle, setToggle] = useState(false);
const disabled = useMemo(() => !canCascadeDeleteEnrollment, [canCascadeDeleteEnrollment]);
const tooltipContent = i18n.t('You do not have access to delete this enrollment');

return (
<ConditionalTooltip content={tooltipContent} enabled={disabled}>
<div>
<MenuItem
dense
dataTest="widget-enrollment-actions-delete"
disabled={disabled}
icon={<IconDelete16 />}
destructive
label={i18n.t('Delete')}
Expand Down Expand Up @@ -58,6 +54,6 @@ export const Delete = ({ canCascadeDeleteEnrollment, enrollment, onDelete }: Pro
</ModalActions>
</Modal>
)}
</ConditionalTooltip>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

export type Props = {|
canCascadeDeleteEnrollment: boolean,
enrollment: Object,
onDelete: (arg: Object) => void,
|};
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export type PlainProps = {|
onDelete: (arg: Object) => void,
onAddNew: (arg: Object) => void,
onUpdateOwnership: UpdateEnrollmentOwnership,
canCascadeDeleteEnrollment: boolean,
isTransferLoading: boolean,
loading: boolean,
canAddNew: boolean,
Expand Down

This file was deleted.

0 comments on commit 3c078b7

Please sign in to comment.