From 9d44540ca898515d4c15c2740b87eeb1307e5463 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Thu, 30 Jan 2025 15:06:52 -0500 Subject: [PATCH] feature/IO-2681-Share-To-Teams-Button - Final revisions. --- .../jobs-detail-header-actions.component.jsx | 6 +-- .../parts-order-list-table.component.jsx | 2 +- ...production-board-kanban-card.component.jsx | 2 +- .../production-list-columns.data.jsx | 2 +- ...utton.jsx => share-to-teams.component.jsx} | 41 +++++++------------ .../task-list/task-list.component.jsx | 2 +- client/src/translations/es/common.json | 7 +++- client/src/translations/fr/common.json | 6 ++- 8 files changed, 30 insertions(+), 38 deletions(-) rename client/src/components/share-to-teams/{share-to-teams-button.jsx => share-to-teams.component.jsx} (82%) diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx index 3bb6fb271..da7636648 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.component.jsx @@ -31,7 +31,7 @@ import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util"; import DuplicateJob from "./jobs-detail-header-actions.duplicate.util"; import JobsDetailHeaderActionsToggleProduction from "./jobs-detail-header-actions.toggle-production"; import SocketContext from "../../contexts/SocketIO/socketContext.jsx"; -import ShareToTeamsButton from "../share-to-teams/share-to-teams-button.jsx"; +import ShareToTeamsButton from "../share-to-teams/share-to-teams.component.jsx"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -963,9 +963,7 @@ export function JobsDetailHeaderActions({ } ); - // TODO REMEMBER TO REVERT - // if (Share_To_Teams?.treatment === "on") { - if (true) { + if (Share_To_Teams?.treatment === "on") { menuItems.push({ key: "sharetoteams", id: "job-actions-sharetoteams", diff --git a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx index 39949d2ee..81d033e69 100644 --- a/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx +++ b/client/src/components/parts-order-list-table/parts-order-list-table.component.jsx @@ -19,7 +19,7 @@ import LockWrapperComponent from "../lock-wrapper/lock-wrapper.component"; import PartsReceiveModalContainer from "../parts-receive-modal/parts-receive-modal.container"; import PrintWrapper from "../print-wrapper/print-wrapper.component"; import PartsOrderDrawer from "./parts-order-list-table-drawer.component"; -import ShareToTeamsButton from "../share-to-teams/share-to-teams-button.jsx"; +import ShareToTeamsButton from "../share-to-teams/share-to-teams.component.jsx"; const mapStateToProps = createStructuredSelector({ jobRO: selectJobReadOnly, diff --git a/client/src/components/production-board-kanban/production-board-kanban-card.component.jsx b/client/src/components/production-board-kanban/production-board-kanban-card.component.jsx index d31ac6aae..4ae675a81 100644 --- a/client/src/components/production-board-kanban/production-board-kanban-card.component.jsx +++ b/client/src/components/production-board-kanban/production-board-kanban-card.component.jsx @@ -20,7 +20,7 @@ import dayjs from "../../utils/day"; import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.component"; import OwnerNameDisplay from "../owner-name-display/owner-name-display.component"; -import ShareToTeamsButton from "../share-to-teams/share-to-teams-button.jsx"; +import ShareToTeamsButton from "../share-to-teams/share-to-teams.component.jsx"; import { SiMicrosoftteams } from "react-icons/si"; const cardColor = (ssbuckets, totalHrs) => { diff --git a/client/src/components/production-list-columns/production-list-columns.data.jsx b/client/src/components/production-list-columns/production-list-columns.data.jsx index fc4aabb16..f26733c36 100644 --- a/client/src/components/production-list-columns/production-list-columns.data.jsx +++ b/client/src/components/production-list-columns/production-list-columns.data.jsx @@ -27,7 +27,7 @@ import ProductionListColumnNote from "./production-list-columns.productionnote.c import ProductionListColumnCategory from "./production-list-columns.status.category"; import ProductionListColumnStatus from "./production-list-columns.status.component"; import ProductionListColumnTouchTime from "./prodution-list-columns.touchtime.component"; -import ShareToTeamsButton from "../share-to-teams/share-to-teams-button.jsx"; +import ShareToTeamsButton from "../share-to-teams/share-to-teams.component.jsx"; const getEmployeeName = (employeeId, employees) => { const employee = employees.find((e) => e.id === employeeId); diff --git a/client/src/components/share-to-teams/share-to-teams-button.jsx b/client/src/components/share-to-teams/share-to-teams.component.jsx similarity index 82% rename from client/src/components/share-to-teams/share-to-teams-button.jsx rename to client/src/components/share-to-teams/share-to-teams.component.jsx index e2a506b3b..fbc22648e 100644 --- a/client/src/components/share-to-teams/share-to-teams-button.jsx +++ b/client/src/components/share-to-teams/share-to-teams.component.jsx @@ -1,4 +1,4 @@ -import React, { useMemo } from "react"; +import React from "react"; import PropTypes from "prop-types"; import { Button } from "antd"; import { useLocation } from "react-router-dom"; @@ -31,7 +31,7 @@ const mapStateToProps = createStructuredSelector({ * @param {Object} [props.additionalProps] - Additional props to pass to the rendered component. * @returns {React.ReactElement} A button or text link for sharing to Microsoft Teams. */ -const ShareToTeamsButton = ({ +const ShareToTeamsComponent = ({ bodyshop, messageTextOverride, urlOverride, @@ -54,24 +54,13 @@ const ShareToTeamsButton = ({ splitKey: bodyshop && bodyshop.imexshopid }); - const currentUrl = useMemo( - () => - urlOverride || - encodeURIComponent(`${window.location.origin}${location.pathname}${location.search}${location.hash}`), - [urlOverride, location] - ); - - const pageTitle = useMemo( - () => - pageTitleOverride || - encodeURIComponent(typeof document !== "undefined" ? document.title : t("general.actions.sharetoteams")), - [pageTitleOverride, t] - ); - - const messageText = useMemo( - () => messageTextOverride || encodeURIComponent(t("general.actions.sharetoteams")), - [messageTextOverride, t] - ); + const currentUrl = + urlOverride || + encodeURIComponent(`${window.location.origin}${location.pathname}${location.search}${location.hash}`); + const pageTitle = + pageTitleOverride || + encodeURIComponent(typeof document !== "undefined" ? document.title : t("general.actions.sharetoteams")); + const messageText = messageTextOverride || encodeURIComponent(t("general.actions.sharetoteams")); // Construct the Teams share URL with parameters const teamsShareUrl = `https://teams.microsoft.com/share?href=${currentUrl}&preText=${messageText}&title=${pageTitle}`; @@ -92,9 +81,9 @@ const ShareToTeamsButton = ({ window.open(teamsShareUrl, "_blank", windowFeatures); }; - // if (Share_To_Teams?.treatment !== "on") { - // return null; - // } + if (Share_To_Teams?.treatment !== "on") { + return null; + } if (noIcon) { return ( @@ -120,7 +109,7 @@ const ShareToTeamsButton = ({ ); }; -ShareToTeamsButton.propTypes = { +ShareToTeamsComponent.propTypes = { messageTextOverride: PropTypes.string, urlOverride: PropTypes.string, pageTitleOverride: PropTypes.string, @@ -129,7 +118,7 @@ ShareToTeamsButton.propTypes = { buttonStyle: PropTypes.object, buttonIconStyle: PropTypes.object, linkText: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), - additionalProps: PropTypes.object + additionalProps: PropTypes.oneOfType([PropTypes.object, PropTypes.node]) }; -export default connect(mapStateToProps)(ShareToTeamsButton); +export default connect(mapStateToProps)(ShareToTeamsComponent); diff --git a/client/src/components/task-list/task-list.component.jsx b/client/src/components/task-list/task-list.component.jsx index 95b664001..3711981c7 100644 --- a/client/src/components/task-list/task-list.component.jsx +++ b/client/src/components/task-list/task-list.component.jsx @@ -18,7 +18,7 @@ import { setModalContext } from "../../redux/modals/modals.actions"; import { pageLimit } from "../../utils/config"; import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter.jsx"; import dayjs from "../../utils/day"; -import ShareToTeamsButton from "../share-to-teams/share-to-teams-button.jsx"; +import ShareToTeamsButton from "../share-to-teams/share-to-teams.component.jsx"; /** * Task List Component diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index c39122001..d1f03fcd7 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1193,7 +1193,9 @@ "submit": "", "tryagain": "", "view": "", - "viewreleasenotes": "" + "viewreleasenotes": "", + "sharetoteams": "", + "ok": "" }, "errors": { "fcm": "", @@ -3183,7 +3185,8 @@ "tasks": { "actions": { "edit": "", - "new": "" + "new": "", + "view": "" }, "buttons": { "allTasks": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 0fd5d7cfa..86cfe7e39 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1193,7 +1193,8 @@ "submit": "", "tryagain": "", "view": "", - "viewreleasenotes": "" + "viewreleasenotes": "", + "ok": "" }, "errors": { "fcm": "", @@ -3183,7 +3184,8 @@ "tasks": { "actions": { "edit": "", - "new": "" + "new": "", + "view": "" }, "buttons": { "allTasks": "",