Skip to content

[MDS-6304] Tighten up Archive/Replace docs for Major Mine Application #3352

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

Merged
merged 6 commits into from
Dec 19, 2024
Merged
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
18 changes: 10 additions & 8 deletions services/common/src/components/documents/DocumentTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ import { some } from "lodash";
import { closeModal, openModal } from "@mds/common/redux/actions/modalActions";
import DocumentCompression from "@mds/common/components/documents/DocumentCompression";
import { archiveMineDocuments } from "@mds/common/redux/actionCreators/mineActionCreator";
import { useDispatch, useSelector } from "react-redux";
import { useDispatch } from "react-redux";
import { Feature } from "@mds/common/utils/featureFlag";
import { SizeType } from "antd/lib/config-provider/SizeContext";
import { ColumnsType } from "antd/es/table";
import { FileOperations, MineDocument } from "@mds/common/models/documents/document";

import DeleteOutlined from "@ant-design/icons/DeleteOutlined";
import DownloadOutlined from "@ant-design/icons/DownloadOutlined";
import DownOutlined from "@ant-design/icons/DownOutlined";
import FileOutlined from "@ant-design/icons/FileOutlined";
import InboxOutlined from "@ant-design/icons/InboxOutlined";
import SyncOutlined from "@ant-design/icons/SyncOutlined";
import { openDocument } from "@mds/common/components/syncfusion/DocumentViewer";
import { getUserAccessData } from "@mds/common/redux/selectors/authenticationSelectors";
import { Button, Dropdown, MenuProps } from "antd";
import { Button, Col, Row } from "antd";
import { useFeatureFlag } from "@mds/common/providers/featureFlags/useFeatureFlag";
import DocumentTableProps from "@mds/common/interfaces/document/documentTableProps.interface";
import ArchiveDocumentModal from "./ArchiveDocumentModal";
Expand Down Expand Up @@ -58,7 +56,6 @@ export const DocumentTable: FC<DocumentTableProps> = ({
}: DocumentTableProps) => {
// differences from bringing over from CORE (vs the MS version): this file has doc compression & bulk actions
const dispatch = useDispatch();
const userRoles = useSelector(getUserAccessData);

const handleCloseModal = () => {
dispatch(closeModal());
Expand Down Expand Up @@ -89,11 +86,11 @@ export const DocumentTable: FC<DocumentTableProps> = ({
return docs.map((doc) => new MineDocument(doc));
}
};

const [documents, setDocuments] = useState<MineDocument[]>(parseDocuments(props.documents ?? []));

useEffect(() => {
const isBulkArchive = documents.every((doc) =>
const isBulkArchive = canArchiveDocuments && documents.every((doc) =>
doc.allowed_actions.find((a) => a === FileOperations.Archive)
);

Expand Down Expand Up @@ -306,7 +303,12 @@ export const DocumentTable: FC<DocumentTableProps> = ({
);
}

return enableBulkActions && <div style={{ float: "right" }}>{element}</div>;
const hasHeader = Boolean(props.header);

return (enableBulkActions || hasHeader) && <Row justify={hasHeader ? "space-between" : "end"} align="bottom" className="document-table-header">
{hasHeader && <Col>{props.header}</Col>}
{enableBulkActions && <Col className="document-table-actions">{element}</Col>}
</Row>;
};

const handleRowSelectionChange = (value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ const ProjectDocumentsTab: FC<ProjectDocumentsTabProps> = ({ project }) => {
.toLowerCase();
};

const canModifySummaryDocs = areDocumentFieldsDisabled(systemFlag, project?.project_summary?.status_code);
const canModifyMmaDocs = areDocumentFieldsDisabled(systemFlag, project?.major_mine_application?.status_code);
const canModifySummaryDocs = !areDocumentFieldsDisabled(systemFlag, project?.project_summary?.status_code);
const canModifyMmaDocs = !areDocumentFieldsDisabled(systemFlag, project?.major_mine_application?.status_code);

const projectSummaryDocs =
project?.project_summary?.documents?.map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,37 +325,21 @@ exports[`ProjectDocumentsTab renders properly 1`] = `
<div>
<div />
<div
style="float: right;"
class="ant-row ant-row-end ant-row-bottom document-table-header"
>
<button
class="ant-btn ant-btn-primary ant-dropdown-trigger actions-dropdown-button"
disabled=""
type="button"
<div
class="ant-col document-table-actions"
>
<span>
Action
</span>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
<button
class="ant-btn ant-btn-primary"
disabled=""
type="button"
>
<svg
aria-hidden="true"
class=""
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</button>
<div>
Download
</div>
</button>
</div>
</div>
<div
class="ant-table-wrapper core-table"
Expand Down Expand Up @@ -1425,37 +1409,41 @@ exports[`ProjectDocumentsTab renders properly 1`] = `
<div>
<div />
<div
style="float: right;"
class="ant-row ant-row-end ant-row-bottom document-table-header"
>
<button
class="ant-btn ant-btn-primary ant-dropdown-trigger actions-dropdown-button"
disabled=""
type="button"
<div
class="ant-col document-table-actions"
>
<span>
Action
</span>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
<button
class="ant-btn ant-btn-primary ant-dropdown-trigger actions-dropdown-button"
disabled=""
type="button"
>
<svg
aria-hidden="true"
class=""
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
<span>
Action
</span>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</button>
<svg
aria-hidden="true"
class=""
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</button>
</div>
</div>
<div
class="ant-table-wrapper core-table"
Expand Down Expand Up @@ -2535,37 +2523,21 @@ exports[`ProjectDocumentsTab renders properly 1`] = `
<div>
<div />
<div
style="float: right;"
class="ant-row ant-row-end ant-row-bottom document-table-header"
>
<button
class="ant-btn ant-btn-primary ant-dropdown-trigger actions-dropdown-button"
disabled=""
type="button"
<div
class="ant-col document-table-actions"
>
<span>
Action
</span>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
<button
class="ant-btn ant-btn-primary"
disabled=""
type="button"
>
<svg
aria-hidden="true"
class=""
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</button>
<div>
Download
</div>
</button>
</div>
</div>
<div
class="ant-table-wrapper core-table"
Expand Down Expand Up @@ -2946,37 +2918,41 @@ exports[`ProjectDocumentsTab renders properly 1`] = `
<div>
<div />
<div
style="float: right;"
class="ant-row ant-row-end ant-row-bottom document-table-header"
>
<button
class="ant-btn ant-btn-primary ant-dropdown-trigger actions-dropdown-button"
disabled=""
type="button"
<div
class="ant-col document-table-actions"
>
<span>
Action
</span>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
<button
class="ant-btn ant-btn-primary ant-dropdown-trigger actions-dropdown-button"
disabled=""
type="button"
>
<svg
aria-hidden="true"
class=""
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
<span>
Action
</span>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</button>
<svg
aria-hidden="true"
class=""
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</button>
</div>
</div>
<div
class="ant-table-wrapper core-table"
Expand Down Expand Up @@ -3926,37 +3902,41 @@ exports[`ProjectDocumentsTab renders properly 1`] = `
<div>
<div />
<div
style="float: right;"
class="ant-row ant-row-end ant-row-bottom document-table-header"
>
<button
class="ant-btn ant-btn-primary ant-dropdown-trigger actions-dropdown-button"
disabled=""
type="button"
<div
class="ant-col document-table-actions"
>
<span>
Action
</span>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
<button
class="ant-btn ant-btn-primary ant-dropdown-trigger actions-dropdown-button"
disabled=""
type="button"
>
<svg
aria-hidden="true"
class=""
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
<span>
Action
</span>
<span
aria-label="down"
class="anticon anticon-down"
role="img"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</button>
<svg
aria-hidden="true"
class=""
data-icon="down"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"
/>
</svg>
</span>
</button>
</div>
</div>
<div
class="ant-table-wrapper core-table"
Expand Down
Loading
Loading