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

✨ Improve Responsiveness of Action Cells in Table Component on smaller screens #2145

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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 @@ -16,6 +16,7 @@ import {
DropdownItem,
Modal,
Tooltip,
OverflowMenu,
} from "@patternfly/react-core";
import {
PencilAltIcon,
Expand Down Expand Up @@ -955,89 +956,88 @@ export const ApplicationsTable: React.FC = () => {
{application?.effort ?? "-"}
</Td>
)}

<Td isActionCell id="pencil-action">
{applicationWriteAccess && (
<Tooltip content={t("actions.edit")}>
<Button
variant="plain"
icon={<PencilAltIcon />}
onClick={() =>
setSaveApplicationModalState(application)
}
/>
</Tooltip>
)}
</Td>
<Td isActionCell id="row-actions">
<ActionsColumn
items={[
assessmentWriteAccess && {
title: t("actions.assess"),
onClick: () => assessSelectedApp(application),
},
assessmentWriteAccess &&
(application.assessments?.length ?? 0) > 0 && {
title: t("actions.discardAssessment"),
onClick: () =>
setAssessmentToDiscard(application),
<Td isActionCell id="actions">
<OverflowMenu breakpoint="sm">
{applicationWriteAccess && (
<Tooltip content={t("actions.edit")}>
<Button
variant="plain"
icon={<PencilAltIcon />}
onClick={() =>
setSaveApplicationModalState(application)
}
/>
</Tooltip>
)}
<ActionsColumn
items={[
assessmentWriteAccess && {
title: t("actions.assess"),
onClick: () => assessSelectedApp(application),
},
reviewsWriteAccess && {
title: t("actions.review"),
onClick: () => reviewSelectedApp(application),
},
reviewsWriteAccess &&
application?.review && {
title: t("actions.discardReview"),
onClick: () => setReviewToDiscard(application),
assessmentWriteAccess &&
(application.assessments?.length ?? 0) > 0 && {
title: t("actions.discardAssessment"),
onClick: () =>
setAssessmentToDiscard(application),
},
reviewsWriteAccess && {
title: t("actions.review"),
onClick: () => reviewSelectedApp(application),
},
dependenciesWriteAccess && {
title: t("actions.manageDependencies"),
onClick: () =>
setApplicationDependenciesToManage(application),
},
credentialsReadAccess &&
applicationWriteAccess && {
title: t("actions.manageCredentials"),
reviewsWriteAccess &&
application?.review && {
title: t("actions.discardReview"),
onClick: () => setReviewToDiscard(application),
},
dependenciesWriteAccess && {
title: t("actions.manageDependencies"),
onClick: () =>
setSaveApplicationsCredentialsModalState([
application,
]),
setApplicationDependenciesToManage(application),
},
analysesReadAccess &&
!!application.tasks.currentAnalyzer && {
title: t("actions.analysisDetails"),
onClick: () => {
const taskId =
application.tasks.currentAnalyzer?.id;
if (taskId && application.id) {
history.push(
formatPath(
Paths.applicationsAnalysisDetails,
{
applicationId: application.id,
taskId,
}
)
);
}
credentialsReadAccess &&
applicationWriteAccess && {
title: t("actions.manageCredentials"),
onClick: () =>
setSaveApplicationsCredentialsModalState([
application,
]),
},
analysesReadAccess &&
!!application.tasks.currentAnalyzer && {
title: t("actions.analysisDetails"),
onClick: () => {
const taskId =
application.tasks.currentAnalyzer?.id;
if (taskId && application.id) {
history.push(
formatPath(
Paths.applicationsAnalysisDetails,
{
applicationId: application.id,
taskId,
}
)
);
}
},
},
tasksReadAccess &&
tasksWriteAccess &&
isTaskCancellable(application) && {
title: t("actions.cancelAnalysis"),
onClick: () => cancelAnalysis(application),
},
applicationWriteAccess && { isSeparator: true },
applicationWriteAccess && {
title: t("actions.delete"),
onClick: () =>
setApplicationsToDelete([application]),
isDanger: true,
},
tasksReadAccess &&
tasksWriteAccess &&
isTaskCancellable(application) && {
title: t("actions.cancelAnalysis"),
onClick: () => cancelAnalysis(application),
},
applicationWriteAccess && { isSeparator: true },
applicationWriteAccess && {
title: t("actions.delete"),
onClick: () =>
setApplicationsToDelete([application]),
isDanger: true,
},
].filter(Boolean)}
/>
].filter(Boolean)}
/>
</OverflowMenu>
</Td>
</TableRowContentWithControls>
</Tr>
Expand Down
38 changes: 19 additions & 19 deletions client/src/app/pages/controls/ControlTableActionButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { useTranslation } from "react-i18next";
import { controlsWriteScopes, RBAC, RBAC_TYPE } from "@app/rbac";
import { ActionsColumn, Td } from "@patternfly/react-table";
import { Button, Tooltip } from "@patternfly/react-core";
import { Button, OverflowMenu, Tooltip } from "@patternfly/react-core";
import { PencilAltIcon } from "@patternfly/react-icons";

export interface ControlTableActionButtonsProps {
Expand All @@ -23,25 +23,25 @@ export const ControlTableActionButtons: React.FC<
const { t } = useTranslation();
return (
<RBAC allowedPermissions={controlsWriteScopes} rbacType={RBAC_TYPE.Scope}>
<Td isActionCell id="pencil-action">
<Tooltip content={t("actions.edit")}>
<Button variant="plain" icon={<PencilAltIcon />} onClick={onEdit} />
</Tooltip>
</Td>
<Td isActionCell id="row-actions">
<ActionsColumn
items={[
{
isAriaDisabled: isDeleteEnabled,
tooltipProps: {
content: isDeleteEnabled ? deleteTooltipMessage : "",
<Td isActionCell id="action">
<OverflowMenu breakpoint="sm">
<Tooltip content={t("actions.edit")}>
<Button variant="plain" icon={<PencilAltIcon />} onClick={onEdit} />
</Tooltip>
<ActionsColumn
items={[
{
isAriaDisabled: isDeleteEnabled,
tooltipProps: {
content: isDeleteEnabled ? deleteTooltipMessage : "",
},
isDanger: isDeleteEnabled == false,
title: t("actions.delete"),
onClick: onDelete,
},
isDanger: isDeleteEnabled == false,
title: t("actions.delete"),
onClick: onDelete,
},
]}
/>
]}
/>
</OverflowMenu>
</Td>
</RBAC>
);
Expand Down
Loading