Skip to content

Commit

Permalink
fix: remove "view source" in modal, from advisory list (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosthe19916 authored Aug 1, 2024
1 parent a834763 commit ea2c6ad
Showing 1 changed file with 8 additions and 32 deletions.
40 changes: 8 additions & 32 deletions client/src/app/pages/advisory-list/advisory-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
CardTitle,
Grid,
GridItem,
Modal,
PageSection,
PageSectionVariants,
Stack,
Expand Down Expand Up @@ -60,7 +59,6 @@ import { SeverityShieldAndText } from "@app/components/SeverityShieldAndText";
import { AdvisoryIndex } from "@app/api/models";
import { EditLabelsModal } from "@app/components/EditLabelsModal";
import { NotificationsContext } from "@app/components/NotificationsContext";
import { AdvisorySourceViewer } from "@app/components/SourceViewer";

import { AdvisoryGeneralView } from "@app/components/AdvisoryGeneralView";
import { AdvisoryIssuer } from "@app/components/AdvisoryIssuer";
Expand All @@ -74,10 +72,12 @@ export const AdvisoryList: React.FC = () => {
const { uploads, handleUpload, handleRemoveUpload } = useUploadAdvisory();

// Actions that each row can trigger
type RowAction = "editLabels" | "viewSource";
type RowAction = "editLabels";
const [selectedRowAction, setSelectedRowAction] =
React.useState<RowAction | null>(null);
const [selectedRow, setSelectedRow] = React.useState<AdvisoryIndex | null>(null);
const [selectedRow, setSelectedRow] = React.useState<AdvisoryIndex | null>(
null
);

const prepareActionOnRow = (action: RowAction, row: AdvisoryIndex) => {
setSelectedRowAction(action);
Expand All @@ -96,7 +96,10 @@ export const AdvisoryList: React.FC = () => {
onUpdateLabelsError
);

const execSaveLabels = (row: AdvisoryIndex, labels: { [key: string]: string }) => {
const execSaveLabels = (
row: AdvisoryIndex,
labels: { [key: string]: string }
) => {
updateAdvisoryLabels({ ...row, labels });
};

Expand Down Expand Up @@ -319,12 +322,6 @@ export const AdvisoryList: React.FC = () => {
prepareActionOnRow("editLabels", item);
},
},
{
title: "View source",
onClick: () => {
prepareActionOnRow("viewSource", item);
},
},
{
title: "Download",
onClick: () => {
Expand Down Expand Up @@ -440,27 +437,6 @@ export const AdvisoryList: React.FC = () => {
onClose={() => setSelectedRowAction(null)}
/>
)}

{selectedRowAction === "viewSource" && selectedRow && (
<Modal
title={selectedRow?.identifier}
isOpen
onClose={() => setSelectedRowAction(null)}
actions={[
<Button
key="cancel"
variant="link"
onClick={() => setSelectedRowAction(null)}
>
Close
</Button>,
]}
>
{selectedRow && (
<AdvisorySourceViewer advisoryId={selectedRow.uuid} />
)}
</Modal>
)}
</>
);
};

0 comments on commit ea2c6ad

Please sign in to comment.