From e0f4b6daf2b9b325101fab0af3a434a7971107c5 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 13 Dec 2024 08:27:54 -0800 Subject: [PATCH] IO-3020 IO-3036 Remove Audit and Lifecycle feature wraps. --- .../feature-wrapper/blur-wrapper.component.jsx | 10 ++++++---- .../feature-wrapper.component.jsx | 17 ++++++++++++++++- .../job-audit-trail.component.jsx | 10 +++++----- .../job-lifecycle/job-lifecycle.component.jsx | 14 ++++++++++---- ...-detail-header-actions.toggle-production.jsx | 8 -------- .../lock-wrapper/lock-wrapper.component.jsx | 16 +++++++++++++--- .../shop-info/shop-info.component.jsx | 3 ++- .../jobs-detail/jobs-detail.page.component.jsx | 4 ++-- client/src/utils/TemplateConstants.js | 12 ++++++------ 9 files changed, 60 insertions(+), 34 deletions(-) diff --git a/client/src/components/feature-wrapper/blur-wrapper.component.jsx b/client/src/components/feature-wrapper/blur-wrapper.component.jsx index b4e4a2129..8a65673cd 100644 --- a/client/src/components/feature-wrapper/blur-wrapper.component.jsx +++ b/client/src/components/feature-wrapper/blur-wrapper.component.jsx @@ -49,7 +49,9 @@ export function BlurWrapper({ } if (bypass) { - console.trace("*** BYPASS USED", featureName); + if (import.meta.env.DEV) { + console.trace("*** Blur Wrapper BYPASS USED", featureName); + } return children; } @@ -118,7 +120,7 @@ function RandomDate() { const featureNameList = [ "mobile", "allAccess", - "audit", + //"audit", //Removing 2024-12-13. Keeping as default feature. "timetickets", "payments", "partsorders", @@ -133,8 +135,8 @@ const featureNameList = [ "checklist", "smartscheduling", "roguard", - "dashboard", - "lifecycle" + "dashboard" + //"lifecycle" //Removing 2024-12-13. Keeping as default feature. ]; export function ValidateFeatureName(featureName) { diff --git a/client/src/components/feature-wrapper/feature-wrapper.component.jsx b/client/src/components/feature-wrapper/feature-wrapper.component.jsx index 8f9cb971d..afd0eb604 100644 --- a/client/src/components/feature-wrapper/feature-wrapper.component.jsx +++ b/client/src/components/feature-wrapper/feature-wrapper.component.jsx @@ -19,9 +19,18 @@ function FeatureWrapper({ blurContent, children, upsellComponent, + bypass, ...restProps }) { const { t } = useTranslation(); + + if (bypass) { + if (import.meta.env.DEV) { + console.trace("*** Feature Wrapper BYPASS USED", featureName); + } + return children; + } + if (import.meta.env.DEV) { if (!ValidateFeatureName(featureName)) console.trace("*** INVALID FEATURE NAME", featureName); } @@ -59,10 +68,16 @@ function FeatureWrapper({ } } -export function HasFeatureAccess({ featureName, bodyshop, debug = false }) { +export function HasFeatureAccess({ featureName, bodyshop, bypass, debug = false }) { if (debug) { console.trace(`*** HasFeatureAccessFunction called with feature << ${featureName} >>`); } + if (bypass) { + if (import.meta.env.DEV) { + console.trace("*** Feature Wrapper BYPASS USED", featureName); + } + return true; + } return bodyshop?.features?.allAccess || dayjs(bodyshop?.features[featureName]).isAfter(dayjs()); } diff --git a/client/src/components/job-audit-trail/job-audit-trail.component.jsx b/client/src/components/job-audit-trail/job-audit-trail.component.jsx index 5332b709b..c3ca6f814 100644 --- a/client/src/components/job-audit-trail/job-audit-trail.component.jsx +++ b/client/src/components/job-audit-trail/job-audit-trail.component.jsx @@ -47,7 +47,7 @@ export function JobAuditTrail({ bodyshop, currentUser, jobId }) { dataIndex: "operation", key: "operation", render: (text, record) => ( - +
{text}
) @@ -77,7 +77,7 @@ export function JobAuditTrail({ bodyshop, currentUser, jobId }) { record.to && record.to.map((email, idx) => ( - +
{email}
@@ -92,7 +92,7 @@ export function JobAuditTrail({ bodyshop, currentUser, jobId }) { record.cc && record.cc.map((email, idx) => ( - +
{email}
@@ -103,7 +103,7 @@ export function JobAuditTrail({ bodyshop, currentUser, jobId }) { dataIndex: "subject", key: "subject", render: (text, record) => ( - +
{text}
) @@ -113,7 +113,7 @@ export function JobAuditTrail({ bodyshop, currentUser, jobId }) { dataIndex: "status", key: "status", render: (text, record) => ( - +
{text}
) diff --git a/client/src/components/job-lifecycle/job-lifecycle.component.jsx b/client/src/components/job-lifecycle/job-lifecycle.component.jsx index ad779b858..7f99d08b5 100644 --- a/client/src/components/job-lifecycle/job-lifecycle.component.jsx +++ b/client/src/components/job-lifecycle/job-lifecycle.component.jsx @@ -69,7 +69,12 @@ export function JobLifecycleComponent({ job, statuses, ...rest }) { dataIndex: "value", key: "value", render: (text, record) => ( - + {text} ) @@ -80,7 +85,7 @@ export function JobLifecycleComponent({ job, statuses, ...rest }) { key: "start", sorter: (a, b) => dayjs(a.start).unix() - dayjs(b.start).unix(), render: (text, record) => ( - + {DateTimeFormatterFunction(text)} ) @@ -105,7 +110,7 @@ export function JobLifecycleComponent({ job, statuses, ...rest }) { }, render: (text, record) => ( - + {isEmpty(text) ? t("job_lifecycle.content.not_available") : DateTimeFormatterFunction(text)} ) @@ -141,7 +146,7 @@ export function JobLifecycleComponent({ job, statuses, ...rest }) { - +
diff --git a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.toggle-production.jsx b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.toggle-production.jsx index 3fd361ff0..358b19900 100644 --- a/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.toggle-production.jsx +++ b/client/src/components/jobs-detail-header-actions/jobs-detail-header-actions.toggle-production.jsx @@ -148,14 +148,6 @@ export function JobsDetailHeaderActionsToggleProduction({ bodyshop, job, jobRO, -
diff --git a/client/src/components/lock-wrapper/lock-wrapper.component.jsx b/client/src/components/lock-wrapper/lock-wrapper.component.jsx index 8b8711089..2d65e3c86 100644 --- a/client/src/components/lock-wrapper/lock-wrapper.component.jsx +++ b/client/src/components/lock-wrapper/lock-wrapper.component.jsx @@ -14,10 +14,11 @@ const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop }); -const LockWrapper = ({ featureName, bodyshop, children, disabled = true }) => { +const LockWrapper = ({ featureName, bodyshop, children, disabled = true, bypass }) => { let renderedChildren = children; - if (disabled) { + //Mark the child prop as disabled. + if (disabled && !bypass) { renderedChildren = React.Children.map(children, (child) => { if (React.isValidElement(child)) { return React.cloneElement(child, { @@ -28,7 +29,16 @@ const LockWrapper = ({ featureName, bodyshop, children, disabled = true }) => { }); } - return ( + if (bypass) { + if (import.meta.env.DEV) { + console.trace("*** Lock Wrapper BYPASS USED", featureName); + } + return {children}; + } + + return HasFeatureAccess({ featureName: featureName, bodyshop }) ? ( + children + ) : ( {!HasFeatureAccess({ featureName: featureName, bodyshop }) && } {renderedChildren} diff --git a/client/src/components/shop-info/shop-info.component.jsx b/client/src/components/shop-info/shop-info.component.jsx index 6f62d8fcc..4ab800915 100644 --- a/client/src/components/shop-info/shop-info.component.jsx +++ b/client/src/components/shop-info/shop-info.component.jsx @@ -1,3 +1,4 @@ + import { useSplitTreatments } from "@splitsoftware/splitio-react"; import { Button, Card, Tabs } from "antd"; import React from "react"; @@ -94,7 +95,7 @@ export function ShopInfoComponent({ bodyshop, form, saveLoading }) { key: "checklists", label: {t("bodyshop.labels.checklists")}, children: , - disabled: HasFeatureAccess({ bodyshop, featureName: "checklist" }), + disabled: !HasFeatureAccess({ bodyshop, featureName: "checklist" }), id: "tab-shop-checklists" }, { diff --git a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx index 20dba22c7..320c2903c 100644 --- a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx +++ b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx @@ -403,7 +403,7 @@ export function JobsDetailPage({ icon: , id: "job-details-lifecycle", label: ( - {t("menus.jobsdetail.lifecycle")} + {t("menus.jobsdetail.lifecycle")} ), children: }, @@ -438,7 +438,7 @@ export function JobsDetailPage({ key: "audit", icon: , id: "job-details-audit", - label: {t("jobs.labels.audit")}, + label: {t("jobs.labels.audit")}, children: }, { diff --git a/client/src/utils/TemplateConstants.js b/client/src/utils/TemplateConstants.js index 184016c1d..9c282dc6c 100644 --- a/client/src/utils/TemplateConstants.js +++ b/client/src/utils/TemplateConstants.js @@ -589,8 +589,8 @@ export const TemplateList = (type, context) => { subject: i18n.t("printcenter.jobs.job_lifecycle_ro"), key: "job_lifecycle_ro", disabled: false, - group: "post", - featureNameRestricted: "lifecycle" + group: "post" + //featureNameRestricted: "lifecycle" }, job_tasks: { title: i18n.t("printcenter.jobs.job_tasks"), @@ -2136,8 +2136,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.jobs"), field: i18n.t("jobs.fields.date_invoiced") }, - group: "jobs", - featureNameRestricted: "lifecycle" + group: "jobs" + //featureNameRestricted: "lifecycle" }, job_lifecycle_date_summary: { title: i18n.t("reportcenter.templates.job_lifecycle_date_summary"), @@ -2149,8 +2149,8 @@ export const TemplateList = (type, context) => { object: i18n.t("reportcenter.labels.objects.jobs"), field: i18n.t("jobs.fields.date_invoiced") }, - group: "jobs", - featureNameRestricted: "lifecycle" + group: "jobs" + //featureNameRestricted: "lifecycle" }, tasks_date: { title: i18n.t("reportcenter.templates.tasks_date"),