@corva/ui 0.66.0-rc.0 → 0.66.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs-bundle/components/StatusBadge/index.js +1 -1
- package/cjs-bundle/components/StatusBadge/utils.js +1 -1
- package/cjs-bundle/effects/useWellnessAlerts.js +1 -1
- package/components/StatusBadge/index.d.ts +5 -2
- package/components/StatusBadge/index.d.ts.map +1 -1
- package/components/StatusBadge/index.js +1 -1
- package/components/StatusBadge/utils.d.ts +2 -0
- package/components/StatusBadge/utils.d.ts.map +1 -1
- package/components/StatusBadge/utils.js +1 -1
- package/effects/useWellnessAlerts.d.ts +2 -0
- package/effects/useWellnessAlerts.d.ts.map +1 -1
- package/effects/useWellnessAlerts.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require('./../../ext-esm/tslib/tslib.es6.js'),t=require("react/jsx-runtime"),n=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require('./../../ext-esm/tslib/tslib.es6.js'),t=require("react/jsx-runtime"),n=require("react"),a=require("moment"),o=require("classnames"),s=require("@material-ui/core"),i=require("../Tooltip/Tooltip.js");require("../Tooltip/ScrollableTooltip.js");var r=require("./constants.js"),c=require("./components/DQStatusIcon.js"),u=require("./components/DQUnvalidatedContent.js"),l=require("./components/ReportIssueModal.js"),p=require("./api.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=d(a),m=d(o),f=window.innerHeight-212,x=s.makeStyles((function(e){return{statusBadgeWrapper:{backgroundColor:e.palette.background.b4,display:"flex",height:30},statusBadgeContent:{display:"flex",padding:function(e){var t=e.isSuccessTypeIcon,n=e.isErrorTypeIcon,a=e.isIssueTypeIcon;return"12px 0 2px ".concat(t||n||a?6:2,"px")},whiteSpace:"nowrap",width:"calc(100% - 140px)"},text:{fontSize:"10px",lineHeight:"12px",alignSelf:"center"},timestamp:{color:e.palette.primary.text6,marginLeft:function(e){return e.isIconExist&&4}},warningMessage:{color:e.palette.primary.text1,marginLeft:4,textOverflow:"ellipsis",overflow:"hidden",fontSize:"12px"},badgeIconWarning:{marginLeft:8},popper:{zIndex:function(e){return e.maximized?500:400},"& .MuiTooltip-tooltip":{position:"absolute",bottom:function(e){return e.tooltipPlacement.includes("top")?0:"auto"},top:function(e){return e.tooltipPlacement.includes("bottom")?0:"auto"},left:function(e){return e.tooltipPlacement.includes("right")?0:"auto"},right:function(e){return e.tooltipPlacement.includes("left")?0:"auto"},width:"max-content",transformOrigin:"center top",maxWidth:"none",padding:4,fontSize:12,boxShadow:"0px 0px 4px 2px rgb(0 0 0 / 12%)",fontWeight:400,lineHeight:"16px",letterSpacing:"0.4px",backgroundColor:e.palette.background.b9}},DQIconWrapper:{display:"flex",alignItems:"center",alignSelf:"center",justifyContent:"center",height:24,width:24,minWidth:24,borderRadius:12,"&:hover":{backgroundColor:function(e){var t=e.isErrorTypeIcon,n=e.isSuccessTypeIcon,a=e.isIssueTypeIcon;return t?"rgba(244, 67, 54, 0.1)":n?"rgba(117, 219, 41, 0.2)":a?"rgba(255, 193, 7, 0.16)":"transparent"}}}}}));exports.StatusBadge=function(a){var o=a.assetsData,d=void 0===o?{}:o,_=a.setAssetsData,S=void 0===_?function(){}:_,I=a.appWidth,T=a.DQIssueTooltipMaxHeight,h=void 0===T?f:T,b=a.iconType,v=a.className,y=a.lastTimestamp,j=a.onReportErrorClick,E=a.warningData,D=a.hasSubscriptionsData,N=a.currentUser,C=a.segment,w=a.maximized,A=a.statusBadgeContentClassName,W=a.tooltipPlacement,M=void 0===W?"top-start":W,q=n.useState(!1),B=q[0],R=q[1],k=n.useState(!1),O=k[0],L=k[1],Q=n.useRef(null),G=null==E?void 0:E.message,P=b===r.BADGE_ICON_STATUSES.error,U=b===r.BADGE_ICON_STATUSES.success,z=b===r.BADGE_ICON_STATUSES.issue,H=I<r.MAX_MOBILE_WIDTH,Y=x({isIconExist:!!b,isSuccessTypeIcon:U,isErrorTypeIcon:P,isIssueTypeIcon:z,maximized:w,tooltipPlacement:M}),F=n.useRef(null),J=function(e){Q.current&&!Q.current.contains(e.target)&&L(!1)};n.useEffect((function(){return function(){S((function(t){return e.__assign(e.__assign({},t),{hasSubscriptionsData:!1})}))}}),[]),n.useEffect((function(){return document.addEventListener("click",J),function(){document.removeEventListener("click",J),clearTimeout(F.current)}}),[]);var X=function(){clearTimeout(F.current),L(!0)},K=function(e,t){void 0===t&&(t=700),F.current=setTimeout((function(){return L(!1)}),t)};return n.useEffect((function(){D&&(X(),K(0,1e4))}),[JSON.stringify(d)]),t.jsxs("div",e.__assign({"data-testid":"Status_badge",className:m.default(Y.statusBadgeWrapper,"c-status-badge--".concat(b),v)},{children:[t.jsxs("div",e.__assign({className:m.default(Y.statusBadgeContent,A),ref:Q},{children:[b&&t.jsx(i.Tooltip,e.__assign({disableHoverListener:!0,open:O,onMouseEnter:X,onMouseLeave:K,PopperProps:{className:Y.popper},placement:M,title:t.jsx(u.DQUnvalidatedContent,{tooltipRef:Q,onMouseEnter:X,onMouseLeave:K,assetsData:d,maxHeight:h,onClick:function(){return R(!0)}})},{children:t.jsx("div",e.__assign({className:Y.DQIconWrapper,"data-testid":"".concat("Status_badge","__DQ_icon_").concat(b)},{children:t.jsx(c.DQStatusIcon,{color:b,iconType:b})}))})),y&&t.jsxs(s.Typography,e.__assign({className:m.default(Y.text,Y.timestamp),variant:"body1"},{children:["Last Update: ",g.default.unix(y).format("M/D/YYYY h:mm a")]})),E&&t.jsxs(t.Fragment,{children:[t.jsx(i.Tooltip,e.__assign({placement:"top",title:G?"".concat(r.WARNING,". ").concat(G):r.WARNING},{children:t.jsx("div",e.__assign({"data-testid":"".concat("Status_badge","__DQ_icon_warning")},{children:t.jsx(c.DQStatusIcon,{className:Y.badgeIconWarning,color:r.BADGE_ICON_STATUSES.warning,iconType:r.BADGE_ICON_STATUSES.warning})}))})),!H&&t.jsx(s.Typography,e.__assign({className:m.default(Y.text,Y.warningMessage),variant:"body1"},{children:G?"".concat(r.WARNING,". ").concat(G):r.WARNING}))]})]})),B&&t.jsx(l.ReportIssueModal,{assets:Object.keys(d).map((function(e){return{name:e,id:d[e][0].alert.assetId}})),onSave:j||function(e,t){p.postReportError(t,e,N,C)},onClose:function(){return R(!1)}})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require('./../../ext-esm/tslib/tslib.es6.js'),e=require("./constants.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require('./../../ext-esm/tslib/tslib.es6.js'),e=require("lodash"),s=require("./constants.js"),n=function(t){return void 0===t&&(t=""),t.toLowerCase()===s.ALERT_STATUSES.RESOLVED};var a=function(t){var e=t.assetId,s=t.wellHubSlug;return"/assets/".concat(e,"/").concat(s,"/Data Quality")},r=function(t,e){return t.reduce((function(t,n){if(!n)return t;if([s.ALERT_STATUSES.FLAGGED,s.ALERT_STATUSES.INVESTIGATION,s.ALERT_STATUSES.ON_HOLD].includes(n.status))return t;var a=e.find((function(t){return t.id===n.assetId})).name;return t[a]||(t[a]=[]),t[a].push(n),t}),{})};exports.findUpdatedFields=function(t,s){return e.omitBy(s,(function(s,n){return e.isEqual(s,t[n])}))},exports.getDeductsFromScoreClass=function(t,e,s){return s||!e?"":e>40?t.error:e>10?t.warn:e>5?t.ok:t.good},exports.getDeductsFromScoreValue=function(t,e){return!e&&t>=0?"".concat(t,"%"):"—"},exports.getIconType=function(t,e){return t.filter((function(t){return e[t].every((function(t){return t.isResolved}))})).length===t.length?s.BADGE_ICON_STATUSES.success:t.filter((function(t){return e[t].some((function(t){return t.missingNum}))})).length?s.BADGE_ICON_STATUSES.error:t.filter((function(t){return e[t].some((function(t){return t.issuesNum}))})).length?s.BADGE_ICON_STATUSES.issue:""},exports.getLinkToDQPage=a,exports.getNewWellnessAlerts=function(e,u,i){return u.reduce((function(u,o){if(!(null==o?void 0:o.length))return u;var d=r(o,e);return Object.keys(d).forEach((function(e){var r=d[e],o=r.find((function(t){return t.status===s.ALERT_STATUSES.OPEN||t.status===s.ALERT_STATUSES.EXPIRED})),l=r.every((function(t){return n(t.status)}));u[e]||(u[e]=[]),u[e].push({alert:l?t.__assign(t.__assign({},r.sort((function(t,e){return e.statusUpdatedAt-t.statusUpdatedAt}))[0]),{emptyMessage:s.DATA_QUALITY_CHECK_PASSED}):o,isResolved:l,id:r[0].id,issuesNum:r.filter((function(t){return t.state===s.ALERT_STATES.issue&&!n(t.status)})).length,name:r[0].name,missingNum:r.filter((function(t){return t.state===s.ALERT_STATES.missing&&!n(t.status)})).length,linkToDQPage:a({assetId:r[0].assetId,wellHubSlug:i})})})),u}),{})},exports.groupAlertsByAssetName=r,exports.hasOnlyLastCheckedAtKey=function(t){return e.isEqual(e.keys(t),["lastCheckedAt"])},exports.isResolved=n,exports.parseWellnessAlertFromJson=function(t){var e,s,n,a;return"Issue"===t.data.state&&"Manual Alert"!==t.data.name&&"User Created"!==t.data.category?null:{id:t._id,assetId:t.asset_id,name:t.data.name,category:t.data.category,lastCheckedAt:t.data.last_checked_at,message:t.data.message,status:(a=t.data.status,"under investigation"===a?"investigation":["not available","resolved"].includes(a)?"resolved":a),statusReason:t.data.status_reason,statusUpdatedAt:t.data.status_updated_at,state:(n=t.data.state,["Fatal","Critical","Issue","Manual"].includes(n)?"Issue":["Missing Data"].includes(n)?"Missing":"Unknown"),createdAt:t.timestamp,note:t.data.note,isThrottled:t.data.is_throttled,segment:t.data.segment,metrics:{holeDepth:null===(e=t.data.metrics)||void 0===e?void 0:e.hole_depth,state:null===(s=t.data.metrics)||void 0===s?void 0:s.state},deductsFromScore:t.data.deducts_from_score}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require('./../ext-esm/tslib/tslib.es6.js'),t=require("react"),s=require("uuid"),n=require("lodash"),r=require("../utils/resolveWellHubSlug.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require('./../ext-esm/tslib/tslib.es6.js'),t=require("react"),s=require("uuid"),n=require("lodash"),r=require("../utils/resolveWellHubSlug.js"),a=require("../utils/env.js"),i=require("../components/StatusBadge/api.js"),u=require("../components/StatusBadge/utils.js"),l=require("../components/StatusBadge/constants.js"),o=require("../clients/index.js"),d=function(e,t,s){return void 0===s&&(s=""),{provider:l.METADATA.recordProvider,dataset:t,assetId:e,event:s}};function c(e,s,r){var a=t.useState([]),i=a[0],c=a[1];return t.useEffect((function(){if(!n.isEmpty(e.filter((function(e){return e})))){var t=function(e){var t=e.data.map(u.parseWellnessAlertFromJson);c(t)},s=e.map((function(e){return o.socketClient.subscribe(d(e,l.METADATA.recordCollections.wellnessAlerts),{onDataReceive:t})})),r=e.map((function(e){return o.socketClient.subscribe(d(e,l.METADATA.recordCollections.wellnessAlerts,"update"),{onDataReceive:t})}));return function(){s.forEach((function(e){return e()})),r.forEach((function(e){return e()}))}}}),[JSON.stringify(e),s,r]),i}exports.useAlertsSubscription=c,exports.useWellnessAlerts=function(o){var d=o.asset,_=o.multiRigAssets,A=void 0===_?[]:_,v=o.appId,f=o.dashboards,m=o.isDCApp,g=o.maximized,p=t.useState({}),S=p[0],T=p[1],E=t.useState(""),D=E[0],I=E[1],R=c(d?[d.id]:A.map((function(e){return e.id})),v,g);return t.useEffect((function(){if(S.alertsData&&!n.isEmpty(R)){var t=!0,s=Object.keys(S.alertsData).reduce((function(s,n){var r;return e.__assign(e.__assign({},s),((r={})[n]=S.alertsData[n].map((function(s){var n=R.find((function(e){return(null==e?void 0:e.name)===s.name&&(null==e?void 0:e.assetId)===s.alert.assetId}));if(!n)return s;if([l.ALERT_STATUSES.FLAGGED,l.ALERT_STATUSES.INVESTIGATION,l.ALERT_STATUSES.ON_HOLD].includes(n.status))return s;var r=e.__assign(e.__assign({},n),{emptyMessage:u.isResolved(n.status)&&l.DATA_QUALITY_CHECK_PASSED}),a=u.isResolved(n.status);if(s.alert.id===n.id){var i=u.findUpdatedFields(s.alert,n);return u.hasOnlyLastCheckedAtKey(i)&&(t=!1),e.__assign(e.__assign({},s),{isResolved:a,alert:r})}return e.__assign(e.__assign({},s),{isResolved:a,issuesNum:n.state===l.ALERT_STATES.issue?s.issuesNum+1:0,missingNum:n.state===l.ALERT_STATES.missing?s.missingNum+1:0,alert:r})})),r))}),{}),r=Object.keys(s);I(u.getIconType(r,s)),T((function(n){return e.__assign(e.__assign({},n),{alertsData:s,hasSubscriptionsData:t})}))}}),[R]),t.useEffect((function(){var t=a.isDevOrQAEnv?l.ENABLING_ON_QA_APP_IDS_LIST:l.ENABLING_ON_PROD_APP_IDS_LIST,n={id:null==d?void 0:d.id,name:null==d?void 0:d.name},o=n.id?[n]:A;try{o.length&&(t.includes(v)||m)?function(t){e.__awaiter(void 0,void 0,void 0,(function(){var n,a,o,d,c,_,A,m,g,p,S;return e.__generator(this,(function(E){switch(E.label){case 0:return[4,i.getWCURuleMapping(v)];case 1:return n=E.sent(),[4,i.getWellnessRuleSettings(null===(g=n[0])||void 0===g?void 0:g.rule_id)];case 2:return(a=E.sent()).length?[4,r(f)]:[2];case 3:return o=E.sent(),d=t.map((function(e){return e.id})),[4,Promise.all(a.map((function(e){var t=e.data.name;return i.getWellnessAlerts(d,t)}))).then((function(e){return e.map((function(e){return e.map((function(e){return u.parseWellnessAlertFromJson(e)}))}))}))];case 4:return c=E.sent(),_=u.getNewWellnessAlerts(t,c,o),A=t.reduce((function(t,n){var r,i=n.id;return e.__assign(e.__assign({},t),((r={})[n.name]=a.map((function(e){var r;return(null===(r=t[n.name])||void 0===r?void 0:r.find((function(t){return t.name===e.data.name})))||{alert:{assetId:i,category:e.data.category,status:l.ALERT_STATUSES.RESOLVED,emptyMessage:l.DATA_QUALITY_CHECK_PASSED},id:s.v4(),isResolved:!0,name:e.data.name,linkToDQPage:u.getLinkToDQPage({assetId:i,wellHubSlug:o})}})),r))}),e.__assign({},_)),m=Object.keys(A),I(u.getIconType(m,A)),T({alertsData:A,lastTimestamp:null===(S=null===(p=A[m[0]][0])||void 0===p?void 0:p.alert)||void 0===S?void 0:S.statusUpdatedAt}),[2]}}))}))}(o):(T({}),I(""))}catch(e){console.error(e)}}),[null==d?void 0:d.id,A.length]),{wellnessAlerts:S,statusBadgeIconType:D,setWellnessAlerts:T}};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import { TooltipProps } from '@material-ui/core';
|
|
3
3
|
import { AssetData } from './constants';
|
|
4
4
|
declare type StatusBadgeProps = {
|
|
@@ -16,7 +16,10 @@ declare type StatusBadgeProps = {
|
|
|
16
16
|
maximized?: boolean;
|
|
17
17
|
statusBadgeContentClassName?: string;
|
|
18
18
|
tooltipPlacement?: TooltipProps['placement'];
|
|
19
|
+
setAssetsData: Dispatch<SetStateAction<AssetData | {
|
|
20
|
+
hasSubscriptionsData?: boolean;
|
|
21
|
+
}>>;
|
|
19
22
|
};
|
|
20
|
-
export declare const StatusBadge: ({ assetsData, appWidth, DQIssueTooltipMaxHeight, iconType, className, lastTimestamp, onReportErrorClick: customOnReportErrorClick, warningData, hasSubscriptionsData, currentUser, segment, maximized, statusBadgeContentClassName, tooltipPlacement, }: StatusBadgeProps) => JSX.Element;
|
|
23
|
+
export declare const StatusBadge: ({ assetsData, setAssetsData, appWidth, DQIssueTooltipMaxHeight, iconType, className, lastTimestamp, onReportErrorClick: customOnReportErrorClick, warningData, hasSubscriptionsData, currentUser, segment, maximized, statusBadgeContentClassName, tooltipPlacement, }: StatusBadgeProps) => JSX.Element;
|
|
21
24
|
export {};
|
|
22
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/StatusBadge/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/StatusBadge/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG9E,OAAO,EAAiC,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGhF,OAAO,EAAkD,SAAS,EAAE,MAAM,aAAa,CAAC;AA0FxF,aAAK,gBAAgB,GAAG;IACtB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,EAAE,CAAC;IAC9C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAClC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,OAAO,EAAE,UAAU,GAAG,YAAY,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,gBAAgB,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IAC7C,aAAa,EAAE,QAAQ,CAAC,cAAc,CAAC,SAAS,GAAG;QAAE,oBAAoB,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC,CAAC;CACzF,CAAC;AAEF,eAAO,MAAM,WAAW,2QAgBrB,gBAAgB,KAAG,WAwIrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t}from'./../../ext-esm/tslib/tslib.es6.js';import{jsxs as e,jsx as n,Fragment as o}from"react/jsx-runtime";import{useState as i,useRef as r,useEffect as a}from"react";import s from"moment";import c from"classnames";import{makeStyles as p,Typography as l}from"@material-ui/core";import{Tooltip as u}from"../Tooltip/Tooltip.js";import"../Tooltip/ScrollableTooltip.js";import{WARNING as m,BADGE_ICON_STATUSES as d,MAX_MOBILE_WIDTH as f}from"./constants.js";import{DQStatusIcon as g}from"./components/DQStatusIcon.js";import{DQUnvalidatedContent as x}from"./components/DQUnvalidatedContent.js";import{ReportIssueModal as h}from"./components/ReportIssueModal.js";import{postReportError as b}from"./api.js";var v=window.innerHeight-212,I=p((function(t){return{statusBadgeWrapper:{backgroundColor:t.palette.background.b4,display:"flex",height:30},statusBadgeContent:{display:"flex",padding:function(t){var e=t.isSuccessTypeIcon,n=t.isErrorTypeIcon,o=t.isIssueTypeIcon;return"12px 0 2px ".concat(e||n||o?6:2,"px")},whiteSpace:"nowrap",width:"calc(100% - 140px)"},text:{fontSize:"10px",lineHeight:"12px",alignSelf:"center"},timestamp:{color:t.palette.primary.text6,marginLeft:function(t){return t.isIconExist&&4}},warningMessage:{color:t.palette.primary.text1,marginLeft:4,textOverflow:"ellipsis",overflow:"hidden",fontSize:"12px"},badgeIconWarning:{marginLeft:8},popper:{zIndex:function(t){return t.maximized?500:400},"& .MuiTooltip-tooltip":{position:"absolute",bottom:function(t){return t.tooltipPlacement.includes("top")?0:"auto"},top:function(t){return t.tooltipPlacement.includes("bottom")?0:"auto"},left:function(t){return t.tooltipPlacement.includes("right")?0:"auto"},right:function(t){return t.tooltipPlacement.includes("left")?0:"auto"},width:"max-content",transformOrigin:"center top",maxWidth:"none",padding:4,fontSize:12,boxShadow:"0px 0px 4px 2px rgb(0 0 0 / 12%)",fontWeight:400,lineHeight:"16px",letterSpacing:"0.4px",backgroundColor:t.palette.background.b9}},DQIconWrapper:{display:"flex",alignItems:"center",alignSelf:"center",justifyContent:"center",height:24,width:24,minWidth:24,borderRadius:12,"&:hover":{backgroundColor:function(t){var e=t.isErrorTypeIcon,n=t.isSuccessTypeIcon,o=t.isIssueTypeIcon;return e?"rgba(244, 67, 54, 0.1)":n?"rgba(117, 219, 41, 0.2)":o?"rgba(255, 193, 7, 0.16)":"transparent"}}}}})),y=function(p){var y=p.assetsData,T=void 0===y?{}:y,S=p.
|
|
1
|
+
import{__assign as t}from'./../../ext-esm/tslib/tslib.es6.js';import{jsxs as e,jsx as n,Fragment as o}from"react/jsx-runtime";import{useState as i,useRef as r,useEffect as a}from"react";import s from"moment";import c from"classnames";import{makeStyles as p,Typography as l}from"@material-ui/core";import{Tooltip as u}from"../Tooltip/Tooltip.js";import"../Tooltip/ScrollableTooltip.js";import{WARNING as m,BADGE_ICON_STATUSES as d,MAX_MOBILE_WIDTH as f}from"./constants.js";import{DQStatusIcon as g}from"./components/DQStatusIcon.js";import{DQUnvalidatedContent as x}from"./components/DQUnvalidatedContent.js";import{ReportIssueModal as h}from"./components/ReportIssueModal.js";import{postReportError as b}from"./api.js";var v=window.innerHeight-212,I=p((function(t){return{statusBadgeWrapper:{backgroundColor:t.palette.background.b4,display:"flex",height:30},statusBadgeContent:{display:"flex",padding:function(t){var e=t.isSuccessTypeIcon,n=t.isErrorTypeIcon,o=t.isIssueTypeIcon;return"12px 0 2px ".concat(e||n||o?6:2,"px")},whiteSpace:"nowrap",width:"calc(100% - 140px)"},text:{fontSize:"10px",lineHeight:"12px",alignSelf:"center"},timestamp:{color:t.palette.primary.text6,marginLeft:function(t){return t.isIconExist&&4}},warningMessage:{color:t.palette.primary.text1,marginLeft:4,textOverflow:"ellipsis",overflow:"hidden",fontSize:"12px"},badgeIconWarning:{marginLeft:8},popper:{zIndex:function(t){return t.maximized?500:400},"& .MuiTooltip-tooltip":{position:"absolute",bottom:function(t){return t.tooltipPlacement.includes("top")?0:"auto"},top:function(t){return t.tooltipPlacement.includes("bottom")?0:"auto"},left:function(t){return t.tooltipPlacement.includes("right")?0:"auto"},right:function(t){return t.tooltipPlacement.includes("left")?0:"auto"},width:"max-content",transformOrigin:"center top",maxWidth:"none",padding:4,fontSize:12,boxShadow:"0px 0px 4px 2px rgb(0 0 0 / 12%)",fontWeight:400,lineHeight:"16px",letterSpacing:"0.4px",backgroundColor:t.palette.background.b9}},DQIconWrapper:{display:"flex",alignItems:"center",alignSelf:"center",justifyContent:"center",height:24,width:24,minWidth:24,borderRadius:12,"&:hover":{backgroundColor:function(t){var e=t.isErrorTypeIcon,n=t.isSuccessTypeIcon,o=t.isIssueTypeIcon;return e?"rgba(244, 67, 54, 0.1)":n?"rgba(117, 219, 41, 0.2)":o?"rgba(255, 193, 7, 0.16)":"transparent"}}}}})),y=function(p){var y=p.assetsData,T=void 0===y?{}:y,S=p.setAssetsData,w=void 0===S?function(){}:S,D=p.appWidth,C=p.DQIssueTooltipMaxHeight,_=void 0===C?v:C,j=p.iconType,k=p.className,E=p.lastTimestamp,M=p.onReportErrorClick,N=p.warningData,W=p.hasSubscriptionsData,L=p.currentUser,P=p.segment,z=p.maximized,Q=p.statusBadgeContentClassName,H=p.tooltipPlacement,B=void 0===H?"top-start":H,O=i(!1),R=O[0],Y=O[1],U=i(!1),A=U[0],J=U[1],q=r(null),F=null==N?void 0:N.message,G=j===d.error,K=j===d.success,V=j===d.issue,X=D<f,Z=I({isIconExist:!!j,isSuccessTypeIcon:K,isErrorTypeIcon:G,isIssueTypeIcon:V,maximized:z,tooltipPlacement:B}),$=r(null),tt=function(t){q.current&&!q.current.contains(t.target)&&J(!1)};a((function(){return function(){w((function(e){return t(t({},e),{hasSubscriptionsData:!1})}))}}),[]),a((function(){return document.addEventListener("click",tt),function(){document.removeEventListener("click",tt),clearTimeout($.current)}}),[]);var et=function(){clearTimeout($.current),J(!0)},nt=function(t,e){void 0===e&&(e=700),$.current=setTimeout((function(){return J(!1)}),e)};return a((function(){W&&(et(),nt(0,1e4))}),[JSON.stringify(T)]),e("div",t({"data-testid":"Status_badge",className:c(Z.statusBadgeWrapper,"c-status-badge--".concat(j),k)},{children:[e("div",t({className:c(Z.statusBadgeContent,Q),ref:q},{children:[j&&n(u,t({disableHoverListener:!0,open:A,onMouseEnter:et,onMouseLeave:nt,PopperProps:{className:Z.popper},placement:B,title:n(x,{tooltipRef:q,onMouseEnter:et,onMouseLeave:nt,assetsData:T,maxHeight:_,onClick:function(){return Y(!0)}})},{children:n("div",t({className:Z.DQIconWrapper,"data-testid":"".concat("Status_badge","__DQ_icon_").concat(j)},{children:n(g,{color:j,iconType:j})}))})),E&&e(l,t({className:c(Z.text,Z.timestamp),variant:"body1"},{children:["Last Update: ",s.unix(E).format("M/D/YYYY h:mm a")]})),N&&e(o,{children:[n(u,t({placement:"top",title:F?"".concat(m,". ").concat(F):m},{children:n("div",t({"data-testid":"".concat("Status_badge","__DQ_icon_warning")},{children:n(g,{className:Z.badgeIconWarning,color:d.warning,iconType:d.warning})}))})),!X&&n(l,t({className:c(Z.text,Z.warningMessage),variant:"body1"},{children:F?"".concat(m,". ").concat(F):m}))]})]})),R&&n(h,{assets:Object.keys(T).map((function(t){return{name:t,id:T[t][0].alert.assetId}})),onSave:M||function(t,e){b(e,t,L,P)},onClose:function(){return Y(!1)}})]}))};export{y as StatusBadge};
|
|
@@ -10,4 +10,6 @@ export declare const getLinkToDQPage: ({ assetId, wellHubSlug, }: {
|
|
|
10
10
|
export declare const groupAlertsByAssetName: (alerts: any, assetsList: any) => any;
|
|
11
11
|
export declare const getNewWellnessAlerts: (assetsList: any, parsedWellnessAlerts: any, wellHubSlug: any) => any;
|
|
12
12
|
export declare const getIconType: (alertsFromAssetsListKeys: any, wellnessAlertsFromAssetsList: any) => "" | "success" | "error" | "issue";
|
|
13
|
+
export declare const findUpdatedFields: (oldAlert: any, newAlert: any) => Partial<any>;
|
|
14
|
+
export declare const hasOnlyLastCheckedAtKey: (alert: any) => boolean;
|
|
13
15
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/StatusBadge/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/components/StatusBadge/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,gCAAgC,CAAC;AAExC,eAAO,MAAM,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OACK,CAAC;AAEnD,eAAO,MAAM,wBAAwB,EAAE,wBAYtC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,wBAKtC,CAAC;AA6BF,eAAO,MAAM,0BAA0B,EAAE,0BA8BxC,CAAC;AAEF,eAAO,MAAM,eAAe;aAIjB,MAAM;iBACF,MAAM;MACjB,MAA0D,CAAC;AAE/D,eAAO,MAAM,sBAAsB,uCAkB3B,CAAC;AAET,eAAO,MAAM,oBAAoB,uEAwChC,CAAC;AAEF,eAAO,MAAM,WAAW,0GAoBvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,gDACmC,CAAC;AAElE,eAAO,MAAM,uBAAuB,yBAAmD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t}from'./../../ext-esm/tslib/tslib.es6.js';import{
|
|
1
|
+
import{__assign as t}from'./../../ext-esm/tslib/tslib.es6.js';import{omitBy as e,isEqual as n,keys as s}from"lodash";import{ALERT_STATUSES as a,BADGE_ICON_STATUSES as r,DATA_QUALITY_CHECK_PASSED as u,ALERT_STATES as i}from"./constants.js";var o=function(t){return void 0===t&&(t=""),t.toLowerCase()===a.RESOLVED},d=function(t,e,n){return n||!e?"":e>40?t.error:e>10?t.warn:e>5?t.ok:t.good},c=function(t,e){return!e&&t>=0?"".concat(t,"%"):"—"};var l=function(t){var e,n,s,a;return"Issue"===t.data.state&&"Manual Alert"!==t.data.name&&"User Created"!==t.data.category?null:{id:t._id,assetId:t.asset_id,name:t.data.name,category:t.data.category,lastCheckedAt:t.data.last_checked_at,message:t.data.message,status:(a=t.data.status,"under investigation"===a?"investigation":["not available","resolved"].includes(a)?"resolved":a),statusReason:t.data.status_reason,statusUpdatedAt:t.data.status_updated_at,state:(s=t.data.state,["Fatal","Critical","Issue","Manual"].includes(s)?"Issue":["Missing Data"].includes(s)?"Missing":"Unknown"),createdAt:t.timestamp,note:t.data.note,isThrottled:t.data.is_throttled,segment:t.data.segment,metrics:{holeDepth:null===(e=t.data.metrics)||void 0===e?void 0:e.hole_depth,state:null===(n=t.data.metrics)||void 0===n?void 0:n.state},deductsFromScore:t.data.deducts_from_score}},f=function(t){var e=t.assetId,n=t.wellHubSlug;return"/assets/".concat(e,"/").concat(n,"/Data Quality")},m=function(t,e){return t.reduce((function(t,n){if(!n)return t;if([a.FLAGGED,a.INVESTIGATION,a.ON_HOLD].includes(n.status))return t;var s=e.find((function(t){return t.id===n.assetId})).name;return t[s]||(t[s]=[]),t[s].push(n),t}),{})},g=function(e,n,s){return n.reduce((function(n,r){if(!(null==r?void 0:r.length))return n;var d=m(r,e);return Object.keys(d).forEach((function(e){var r=d[e],c=r.find((function(t){return t.status===a.OPEN||t.status===a.EXPIRED})),l=r.every((function(t){return o(t.status)}));n[e]||(n[e]=[]),n[e].push({alert:l?t(t({},r.sort((function(t,e){return e.statusUpdatedAt-t.statusUpdatedAt}))[0]),{emptyMessage:u}):c,isResolved:l,id:r[0].id,issuesNum:r.filter((function(t){return t.state===i.issue&&!o(t.status)})).length,name:r[0].name,missingNum:r.filter((function(t){return t.state===i.missing&&!o(t.status)})).length,linkToDQPage:f({assetId:r[0].assetId,wellHubSlug:s})})})),n}),{})},v=function(t,e){return t.filter((function(t){return e[t].every((function(t){return t.isResolved}))})).length===t.length?r.success:t.filter((function(t){return e[t].some((function(t){return t.missingNum}))})).length?r.error:t.filter((function(t){return e[t].some((function(t){return t.issuesNum}))})).length?r.issue:""},h=function(t,s){return e(s,(function(e,s){return n(e,t[s])}))},p=function(t){return n(s(t),["lastCheckedAt"])};export{h as findUpdatedFields,d as getDeductsFromScoreClass,c as getDeductsFromScoreValue,v as getIconType,f as getLinkToDQPage,g as getNewWellnessAlerts,m as groupAlertsByAssetName,p as hasOnlyLastCheckedAtKey,o as isResolved,l as parseWellnessAlertFromJson};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { AssetData } from '~/components/StatusBadge/constants';
|
|
2
3
|
export declare function useAlertsSubscription(assetIds: any, appId: any, maximized: any): any[];
|
|
3
4
|
declare type WellnessAlerts = {
|
|
@@ -15,6 +16,7 @@ export declare const useWellnessAlerts: ({ asset, multiRigAssets, appId, dashboa
|
|
|
15
16
|
}) => {
|
|
16
17
|
wellnessAlerts: WellnessAlerts;
|
|
17
18
|
statusBadgeIconType: "" | "success" | "error" | "issue";
|
|
19
|
+
setWellnessAlerts: import("react").Dispatch<import("react").SetStateAction<WellnessAlerts>>;
|
|
18
20
|
};
|
|
19
21
|
export {};
|
|
20
22
|
//# sourceMappingURL=useWellnessAlerts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWellnessAlerts.d.ts","sourceRoot":"","sources":["../../src/effects/useWellnessAlerts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useWellnessAlerts.d.ts","sourceRoot":"","sources":["../../src/effects/useWellnessAlerts.ts"],"names":[],"mappings":";AAiBA,OAAO,EAIL,SAAS,EAIV,MAAM,oCAAoC,CAAC;AAW5C,wBAAgB,qBAAqB,CAAC,QAAQ,KAAA,EAAE,KAAK,KAAA,EAAE,SAAS,KAAA,SA+B/D;AAED,aAAK,cAAc,GACf;IAAE,UAAU,EAAE,SAAS,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,oBAAoB,EAAE,OAAO,CAAA;CAAE,GAC/E,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAEvB,eAAO,MAAM,iBAAiB;;;;;;;;;;;CAqJ7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t,__awaiter as e,__generator as n}from'./../ext-esm/tslib/tslib.es6.js';import{useState as r,useEffect as s}from"react";import{v4 as a}from"uuid";import{isEmpty as i}from"lodash";import o from"../utils/resolveWellHubSlug.js";import{isDevOrQAEnv as u}from"../utils/env.js";import{getWellnessAlerts as l,getWellnessRuleSettings as d,getWCURuleMapping as c}from"../components/StatusBadge/api.js";import{isResolved as m,
|
|
1
|
+
import{__assign as t,__awaiter as e,__generator as n}from'./../ext-esm/tslib/tslib.es6.js';import{useState as r,useEffect as s}from"react";import{v4 as a}from"uuid";import{isEmpty as i}from"lodash";import o from"../utils/resolveWellHubSlug.js";import{isDevOrQAEnv as u}from"../utils/env.js";import{getWellnessAlerts as l,getWellnessRuleSettings as d,getWCURuleMapping as c}from"../components/StatusBadge/api.js";import{isResolved as m,findUpdatedFields as f,hasOnlyLastCheckedAtKey as v,getIconType as p,parseWellnessAlertFromJson as g,getNewWellnessAlerts as b,getLinkToDQPage as D}from"../components/StatusBadge/utils.js";import{ALERT_STATUSES as h,DATA_QUALITY_CHECK_PASSED as j,ALERT_STATES as y,ENABLING_ON_QA_APP_IDS_LIST as I,ENABLING_ON_PROD_APP_IDS_LIST as A,METADATA as S}from"../components/StatusBadge/constants.js";import{socketClient as N}from"../clients/index.js";var O=function(t,e,n){return void 0===n&&(n=""),{provider:S.recordProvider,dataset:e,assetId:t,event:n}};function R(t,e,n){var a=r([]),o=a[0],u=a[1];return s((function(){if(!i(t.filter((function(t){return t})))){var e=function(t){var e=t.data.map(g);u(e)},n=t.map((function(t){return N.subscribe(O(t,S.recordCollections.wellnessAlerts),{onDataReceive:e})})),r=t.map((function(t){return N.subscribe(O(t,S.recordCollections.wellnessAlerts,"update"),{onDataReceive:e})}));return function(){n.forEach((function(t){return t()})),r.forEach((function(t){return t()}))}}}),[JSON.stringify(t),e,n]),o}var E=function(S){var N=S.asset,O=S.multiRigAssets,E=void 0===O?[]:O,w=S.appId,T=S.dashboards,k=S.isDCApp,B=S.maximized,x=r({}),C=x[0],G=x[1],H=r(""),L=H[0],P=H[1],_=R(N?[N.id]:E.map((function(t){return t.id})),w,B);return s((function(){if(C.alertsData&&!i(_)){var e=!0,n=Object.keys(C.alertsData).reduce((function(n,r){var s;return t(t({},n),((s={})[r]=C.alertsData[r].map((function(n){var r=_.find((function(t){return(null==t?void 0:t.name)===n.name&&(null==t?void 0:t.assetId)===n.alert.assetId}));if(!r)return n;if([h.FLAGGED,h.INVESTIGATION,h.ON_HOLD].includes(r.status))return n;var s=t(t({},r),{emptyMessage:m(r.status)&&j}),a=m(r.status);if(n.alert.id===r.id){var i=f(n.alert,r);return v(i)&&(e=!1),t(t({},n),{isResolved:a,alert:s})}return t(t({},n),{isResolved:a,issuesNum:r.state===y.issue?n.issuesNum+1:0,missingNum:r.state===y.missing?n.missingNum+1:0,alert:s})})),s))}),{}),r=Object.keys(n);P(p(r,n)),G((function(r){return t(t({},r),{alertsData:n,hasSubscriptionsData:e})}))}}),[_]),s((function(){var r=u?I:A,s={id:null==N?void 0:N.id,name:null==N?void 0:N.name},i=s.id?[s]:E;try{i.length&&(r.includes(w)||k)?function(r){e(void 0,void 0,void 0,(function(){var e,s,i,u,m,f,v,y,I,A,S;return n(this,(function(n){switch(n.label){case 0:return[4,c(w)];case 1:return e=n.sent(),[4,d(null===(I=e[0])||void 0===I?void 0:I.rule_id)];case 2:return(s=n.sent()).length?[4,o(T)]:[2];case 3:return i=n.sent(),u=r.map((function(t){return t.id})),[4,Promise.all(s.map((function(t){var e=t.data.name;return l(u,e)}))).then((function(t){return t.map((function(t){return t.map((function(t){return g(t)}))}))}))];case 4:return m=n.sent(),f=b(r,m,i),v=r.reduce((function(e,n){var r,o=n.id;return t(t({},e),((r={})[n.name]=s.map((function(t){var r;return(null===(r=e[n.name])||void 0===r?void 0:r.find((function(e){return e.name===t.data.name})))||{alert:{assetId:o,category:t.data.category,status:h.RESOLVED,emptyMessage:j},id:a(),isResolved:!0,name:t.data.name,linkToDQPage:D({assetId:o,wellHubSlug:i})}})),r))}),t({},f)),y=Object.keys(v),P(p(y,v)),G({alertsData:v,lastTimestamp:null===(S=null===(A=v[y[0]][0])||void 0===A?void 0:A.alert)||void 0===S?void 0:S.statusUpdatedAt}),[2]}}))}))}(i):(G({}),P(""))}catch(t){console.error(t)}}),[null==N?void 0:N.id,E.length]),{wellnessAlerts:C,statusBadgeIconType:L,setWellnessAlerts:G}};export{R as useAlertsSubscription,E as useWellnessAlerts};
|