diff --git a/services/common/src/constants/strings.tsx b/services/common/src/constants/strings.tsx index 7c1d62e34b..dd8c9ffa90 100755 --- a/services/common/src/constants/strings.tsx +++ b/services/common/src/constants/strings.tsx @@ -173,6 +173,7 @@ export const NOTICE_OF_DEPARTURE_STATUS_VALUES = { determined_non_substantial: "determined_non_substantial", determined_substantial: "determined_substantial", withdrawn: "withdrawn", + self_authorized: "self_authorized", }; export const NOD_TYPE_FIELD_VALUE = { diff --git a/services/core-web/common/components/tailings/AssociatedDams.tsx b/services/core-web/common/components/tailings/AssociatedDams.tsx index 3cac154dce..34a6f025df 100644 --- a/services/core-web/common/components/tailings/AssociatedDams.tsx +++ b/services/core-web/common/components/tailings/AssociatedDams.tsx @@ -51,32 +51,28 @@ const AssociatedDams: FC = (props) => { history.push(url); }; - const renderDamActions = () => { - let actions = [ - { - key: "view", - label: "View Dam", - icon: , - clickFunction: (_event, record) => { - handleNavigateToEdit(event, record, false); - }, - }, - { - key: "edit", - label: "Edit Dam", - icon: , - clickFunction: (_event, record) => { - handleNavigateToEdit(event, record, true); - }, + const actions = [ + { + key: "view", + label: "View Dam", + icon: , + clickFunction: (_event, record) => { + handleNavigateToEdit(event, record, false); }, - ]; - - if (!isEditMode) { - actions = actions.filter((a) => a.key !== "edit"); - } - - return renderActionsColumn(actions); - }; + }, + ...(isEditMode + ? [ + { + key: "edit", + label: "Edit Dam", + icon: , + clickFunction: (_event, record) => { + handleNavigateToEdit(event, record, true); + }, + }, + ] + : []), + ]; const columns: ColumnsType = [ { @@ -118,7 +114,7 @@ const AssociatedDams: FC = (props) => { dataIndex: "max_pond_elevation", key: "max_pond_elevation", }, - ...[renderDamActions()], + renderActionsColumn({ actions }), ]; const mostRecentUpdatedDate = moment( diff --git a/services/core-web/src/components/mine/Tailings/MineTailingsTable.tsx b/services/core-web/src/components/mine/Tailings/MineTailingsTable.tsx index 1c7b6085b0..11072a4556 100644 --- a/services/core-web/src/components/mine/Tailings/MineTailingsTable.tsx +++ b/services/core-web/src/components/mine/Tailings/MineTailingsTable.tsx @@ -126,21 +126,25 @@ const MineTailingsTable: FC = (pro }); }, }, - { - key: "edit", - label: "Edit TSF", - icon: , - clickFunction: (_event, record) => { - props.history.push({ - pathname: MINE_TAILINGS_DETAILS.dynamicRoute( - record.mine_tailings_storage_facility_guid, - record.mine_guid, - "basic-information", - true - ), - }); - }, - }, + ...(canEditTSF + ? [ + { + key: "edit", + label: "Edit TSF", + icon: , + clickFunction: (_event, record) => { + props.history.push({ + pathname: MINE_TAILINGS_DETAILS.dynamicRoute( + record.mine_tailings_storage_facility_guid, + record.mine_guid, + "basic-information", + true + ), + }); + }, + }, + ] + : []), ]; const damActions = [ @@ -152,26 +156,21 @@ const MineTailingsTable: FC = (pro handleEditDam(event, record, false, false); }, }, - { - key: "edit", - label: "Edit Dam", - icon: , - clickFunction: (_event, record) => { - handleEditDam(event, record, true, true); - }, - }, + ...(canEditTSF + ? [ + { + key: "edit", + label: "Edit Dam", + icon: , + clickFunction: (_event, record) => { + handleEditDam(event, record, true, true); + }, + }, + ] + : []), ]; - const renderActions = (actions) => { - let filteredActions = actions; - if (!canEditTSF) { - filteredActions = actions.filter((a) => a.key !== "edit"); - } - - return renderActionsColumn(filteredActions); - }; - - const columns: ColumnsType = [ + const columns = [ { title: "Name", dataIndex: "mine_tailings_storage_facility_name", @@ -227,7 +226,7 @@ const MineTailingsTable: FC = (pro dataIndex: "longitude", render: (text) =>
{text || EMPTY_FIELD}
, }, - ...(tsfV2Enabled ? [renderActions(newTSFActions)] : [renderOldTSFActions()]), + ...(tsfV2Enabled ? [renderActionsColumn({ actions: newTSFActions })] : [renderOldTSFActions()]), ]; const damColumns = [ @@ -238,14 +237,14 @@ const MineTailingsTable: FC = (pro "Consequence Classification", CONSEQUENCE_CLASSIFICATION_CODE_HASH ), - ...[renderActions(damActions)], + renderActionsColumn({ actions: damActions }), ]; return ( } rowKey="mine_tailings_storage_facility_guid" classPrefix="tailings" expandProps={ diff --git a/services/minespace-web/common/components/tailings/AssociatedDams.tsx b/services/minespace-web/common/components/tailings/AssociatedDams.tsx index 3cac154dce..34a6f025df 100644 --- a/services/minespace-web/common/components/tailings/AssociatedDams.tsx +++ b/services/minespace-web/common/components/tailings/AssociatedDams.tsx @@ -51,32 +51,28 @@ const AssociatedDams: FC = (props) => { history.push(url); }; - const renderDamActions = () => { - let actions = [ - { - key: "view", - label: "View Dam", - icon: , - clickFunction: (_event, record) => { - handleNavigateToEdit(event, record, false); - }, - }, - { - key: "edit", - label: "Edit Dam", - icon: , - clickFunction: (_event, record) => { - handleNavigateToEdit(event, record, true); - }, + const actions = [ + { + key: "view", + label: "View Dam", + icon: , + clickFunction: (_event, record) => { + handleNavigateToEdit(event, record, false); }, - ]; - - if (!isEditMode) { - actions = actions.filter((a) => a.key !== "edit"); - } - - return renderActionsColumn(actions); - }; + }, + ...(isEditMode + ? [ + { + key: "edit", + label: "Edit Dam", + icon: , + clickFunction: (_event, record) => { + handleNavigateToEdit(event, record, true); + }, + }, + ] + : []), + ]; const columns: ColumnsType = [ { @@ -118,7 +114,7 @@ const AssociatedDams: FC = (props) => { dataIndex: "max_pond_elevation", key: "max_pond_elevation", }, - ...[renderDamActions()], + renderActionsColumn({ actions }), ]; const mostRecentUpdatedDate = moment( diff --git a/services/minespace-web/src/components/dashboard/mine/tailings/TailingsTable.js b/services/minespace-web/src/components/dashboard/mine/tailings/TailingsTable.js index 3e96d77ecd..4c5024379a 100644 --- a/services/minespace-web/src/components/dashboard/mine/tailings/TailingsTable.js +++ b/services/minespace-web/src/components/dashboard/mine/tailings/TailingsTable.js @@ -96,7 +96,7 @@ export const TailingsTable = (props) => { }; }; - let newTSFActions = [ + const newTSFActions = [ { key: "view", label: "View TSF", @@ -105,17 +105,21 @@ export const TailingsTable = (props) => { editTailings(event, record, false); }, }, - { - key: "edit", - label: "Edit TSF", - icon: , - clickFunction: (_event, record) => { - editTailings(event, record, true); - }, - }, + ...(canEditTSF + ? [ + { + key: "edit", + label: "Edit TSF", + icon: , + clickFunction: (_event, record) => { + editTailings(event, record, true); + }, + }, + ] + : []), ]; - let damActions = [ + const damActions = [ { key: "view", label: "View Dam", @@ -124,25 +128,20 @@ export const TailingsTable = (props) => { handleEditDam(event, record, false, false); }, }, - { - key: "edit", - label: "Edit Dam", - icon: , - clickFunction: (_event, record) => { - handleEditDam(event, record, true, true); - }, - }, + ...(canEditTSF + ? [ + { + key: "edit", + label: "Edit Dam", + icon: , + clickFunction: (_event, record) => { + handleEditDam(event, record, true, true); + }, + }, + ] + : []), ]; - const renderActions = (actions) => { - let filteredActions = actions; - if (!canEditTSF) { - filteredActions = actions.filter((a) => a.key !== "edit"); - } - - return renderActionsColumn(filteredActions); - }; - // const handleRowExpand = (record) => { // const key = record.mine_tailings_storage_facility_guid; // const expandedRowKeys = expandedRows.includes(key) @@ -224,7 +223,7 @@ export const TailingsTable = (props) => { render: (text) =>
{text || EMPTY_FIELD}
, sorter: (a, b) => (a.notes > b.notes ? -1 : 1), }, - ...(tsfV2Enabled ? [renderActions(newTSFActions)] : [renderOldTSFActions()]), + ...(tsfV2Enabled ? [renderActionsColumn({ actions: newTSFActions })] : [renderOldTSFActions()]), ]; const expandedColumns = [ @@ -245,7 +244,7 @@ export const TailingsTable = (props) => { ), }, - ...[renderActions(damActions)], + renderActionsColumn({ actions: damActions }), ]; return (