Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jschuler committed Dec 13, 2024
1 parent 55a4229 commit cee5f94
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import { DropdownItemLink } from 'src/components/actions/DropdownItemLink';
import { isPlanEditable } from 'src/modules/Plans/utils';
import { PlanVMsEditModal } from 'src/modules/Plans/views/details/tabs/VirtualMachines/modals';
import { useGetDeleteAndEditAccessReview } from 'src/modules/Providers/hooks';
import { useModal } from 'src/modules/Providers/modals';
import { getResourceUrl } from 'src/modules/Providers/utils/helpers';
import { useForkliftTranslation } from 'src/utils/i18n';

import { PlanModel, PlanModelRef } from '@kubev2v/types';
import { PlanModel /*PlanModelRef*/ } from '@kubev2v/types';
import { useActiveNamespace } from '@openshift-console/dynamic-plugin-sdk';
import { DropdownItem } from '@patternfly/react-core/deprecated';

import {
Expand All @@ -26,21 +28,21 @@ import {
export const PlanActionsDropdownItems = ({ data }: PlanActionsDropdownItemsProps) => {
const { t } = useForkliftTranslation();
const { showModal } = useModal();
const [activeNamespace] = useActiveNamespace();
const permissions = useGetDeleteAndEditAccessReview({
model: PlanModel,
namespace: activeNamespace,
});

const { obj: plan } = data;

const planURL = getResourceUrl({
reference: PlanModelRef,
name: plan?.metadata?.name,
namespace: plan?.metadata?.namespace,
});

const phase = getPlanPhase(data);

const canStart = canPlanStart(plan);
const canReStart = canPlanReStart(plan);
const isWarmAndExecuting = plan?.spec?.warm && isPlanExecuting(plan);
const isArchived = isPlanArchived(plan);
const canEditPlan = permissions.canPatch && isPlanEditable(plan);

const buttonStartLabel = canReStart ? t('Restart migration') : t('Start migration');

Expand All @@ -67,9 +69,13 @@ export const PlanActionsDropdownItems = ({ data }: PlanActionsDropdownItemsProps
};

return [
<DropdownItemLink key="EditPlan" href={planURL}>
<DropdownItem
key="EditPlan"
onClick={() => showModal(<PlanVMsEditModal plan={plan} editAction="PLAN" />)}
isDisabled={!canEditPlan}
>
{t('Edit Plan')}
</DropdownItemLink>,
</DropdownItem>,

<DropdownItem key="start" isDisabled={!canStart} onClick={onClickPlanStart}>
{buttonStartLabel}
Expand Down Expand Up @@ -111,4 +117,4 @@ export const PlanActionsDropdownItems = ({ data }: PlanActionsDropdownItemsProps

interface PlanActionsDropdownItemsProps {
data: PlanData;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { PlanEditAction } from 'src/modules/Plans/utils/types/PlanEditAction';
import { PlanEditPage } from 'src/modules/Plans/views/create/PlanEditPage';
import { PlanEditPage } from 'src/modules/Plans/views/edit/PlanEditPage';
import { useModal } from 'src/modules/Providers/modals';
import { useInventoryVms } from 'src/modules/Providers/views';
import { useForkliftTranslation } from 'src/utils/i18n';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { PlanEditAction } from 'src/modules/Plans/utils/types/PlanEditAction';
import { PlanMappingsSectionState } from 'src/modules/Plans/views/details/tabs/Mappings/PlanMappingsSection';

import { LoadingDots } from '@kubev2v/common';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { ReactNode } from 'react';
import { FilterableSelect } from 'src/components';
import SectionHeading from 'src/components/headers/SectionHeading';
import { PlanEditAction } from 'src/modules/Plans/utils/types/PlanEditAction';
import { PlanMappingsInitSection } from 'src/modules/Plans/views/details/tabs/Mappings/PlanMappings';
import { PlanMappingsSectionState } from 'src/modules/Plans/views/details/tabs/Mappings/PlanMappingsSection';
import { useForkliftTranslation } from 'src/utils/i18n';
Expand Down

0 comments on commit cee5f94

Please sign in to comment.