@rh-support/react-context 1.0.18 → 1.0.20-beta.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"EmbeddedServiceChat.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/EmbeddedServiceChat.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAInC,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAC;AAMvD,eAAO,MAAM,mBAAmB,EAAE,EAwEjC,CAAC"}
1
+ {"version":3,"file":"EmbeddedServiceChat.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/EmbeddedServiceChat.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAInC,OAAc,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AAM/D,eAAO,MAAM,mBAAmB,EAAE,EA0FjC,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import './embeddedServiceChat.css';
2
2
  import { Button, ButtonVariant, Popover, PopoverPosition, Spinner } from '@patternfly/react-core';
3
3
  import ExclamationCircleIcon from '@patternfly/react-icons/dist/js/icons/exclamation-circle-icon';
4
- import React, { useEffect, useState } from 'react';
4
+ import React, { useEffect, useRef, useState } from 'react';
5
5
  import { Trans, useTranslation } from 'react-i18next';
6
- import { useChatInit } from '../..';
6
+ import { FeatureAnnouncementKeys, NewFeaturePopoverAnnouncement, useChatInit } from '../..';
7
7
  import { ChatSVGIcon } from './ChatSVGIcon';
8
8
  export const EmbeddedServiceChat = () => {
9
+ const componentRef = useRef(null);
9
10
  const { loadingChat, isChatStarted, initEmbedChat, onStartChat, hasChatDomainsBlocked, hasBlockedByBrowser } = useChatInit();
10
11
  const [isBlockedErrorBoxVisible, setIsBlockedErrorBoxVisible] = useState(true);
11
12
  const { t } = useTranslation();
@@ -32,6 +33,8 @@ export const EmbeddedServiceChat = () => {
32
33
  // eslint-disable-next-line react-hooks/exhaustive-deps
33
34
  }, []);
34
35
  return loadingChat ? (React.createElement("div", { className: "chatButton" },
35
- React.createElement(Spinner, { isSVG: true, diameter: "28px", className: "pf-u-m-xs" }))) : hasBlockedByBrowser || hasChatDomainsBlocked ? (chatErrorMessagePopover()) : !isChatStarted ? (React.createElement("div", { className: "chatButton", onClick: onStartChat, "data-tracking-id": "embedded-service-chat" },
36
- React.createElement(ChatSVGIcon, null))) : (React.createElement(React.Fragment, null));
36
+ React.createElement(Spinner, { isSVG: true, diameter: "28px", className: "pf-u-m-xs" }))) : hasBlockedByBrowser || hasChatDomainsBlocked ? (chatErrorMessagePopover()) : !isChatStarted ? (React.createElement("div", { className: "chatButton", onClick: onStartChat, "data-tracking-id": "embedded-service-chat", ref: componentRef, id: "chat-bot-wrapper" },
37
+ React.createElement(ChatSVGIcon, null),
38
+ React.createElement(NewFeaturePopoverAnnouncement, { "aria-label": t('Support now has a chatbot (beta). Try it if you need help with a case.'), featureName: FeatureAnnouncementKeys.CHAT_BOT, sectionRef: componentRef, bodyContent: React.createElement("div", null,
39
+ React.createElement(Trans, null, "Support now has a chatbot (beta). Try it if you need help with a case.")), reference: () => document.getElementById('chat-bot-wrapper') }))) : (React.createElement(React.Fragment, null));
37
40
  };
@@ -2,7 +2,8 @@ export declare enum FeatureAnnouncementKeys {
2
2
  SEND_NOTIFICATIONS = "sendNotifications",
3
3
  MARKDOWN_INLINE_IMAGES = "markdownInlineImages",
4
4
  CASE_TYPE_FILTER = "caseTypeFilter",
5
- SHARE_HOSTNAMES = "shareHostnamesWithRHT"
5
+ SHARE_HOSTNAMES = "shareHostnamesWithRHT",
6
+ CHAT_BOT = "chatBot"
6
7
  }
7
8
  export interface IFeatureConfig {
8
9
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"useFeatureAnnouncement.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFeatureAnnouncement.ts"],"names":[],"mappings":"AAYA,oBAAY,uBAAuB;IAC/B,kBAAkB,sBAAsB;IACxC,sBAAsB,yBAAyB;IAC/C,gBAAgB,mBAAmB;IACnC,eAAe,0BAA0B;CAC5C;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,GAAG,UAAU,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CAC3B;AAOD,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,uBAAuB;;;;;;EAgG1E"}
1
+ {"version":3,"file":"useFeatureAnnouncement.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFeatureAnnouncement.ts"],"names":[],"mappings":"AAYA,oBAAY,uBAAuB;IAC/B,kBAAkB,sBAAsB;IACxC,sBAAsB,yBAAyB;IAC/C,gBAAgB,mBAAmB;IACnC,eAAe,0BAA0B;IACzC,QAAQ,YAAY;CACvB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,GAAG,UAAU,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CAC3B;AAOD,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,uBAAuB;;;;;;EAgG1E"}
@@ -9,6 +9,7 @@ export var FeatureAnnouncementKeys;
9
9
  FeatureAnnouncementKeys["MARKDOWN_INLINE_IMAGES"] = "markdownInlineImages";
10
10
  FeatureAnnouncementKeys["CASE_TYPE_FILTER"] = "caseTypeFilter";
11
11
  FeatureAnnouncementKeys["SHARE_HOSTNAMES"] = "shareHostnamesWithRHT";
12
+ FeatureAnnouncementKeys["CHAT_BOT"] = "chatBot";
12
13
  })(FeatureAnnouncementKeys || (FeatureAnnouncementKeys = {}));
13
14
  export function useFeatureAnnouncement(featureName) {
14
15
  const { globalMetadataState: { loggedInUserRights, hydraUserPreferences, pcmConfig }, } = useContext(GlobalMetadataStateContext);
@@ -50,7 +51,7 @@ export function useFeatureAnnouncement(featureName) {
50
51
  * If a feature is removed from the PCM config, then we can erase that data from the user preferences too
51
52
  */
52
53
  const cleanUpFeatureDataInUserPreference = () => {
53
- if (!featureName || isCleanupScheduled.current)
54
+ if (!featureName || hydraUserPreferences.isFetching || isCleanupScheduled.current)
54
55
  return;
55
56
  const allFeatures = userFeatureAnnouncementPreferences || {};
56
57
  const featureConfig = allFeatures[featureName];
@@ -66,7 +67,7 @@ export function useFeatureAnnouncement(featureName) {
66
67
  }
67
68
  };
68
69
  const onFeatureDismiss = () => {
69
- if (!featureName)
70
+ if (!featureName || hydraUserPreferences.isFetching)
70
71
  return;
71
72
  const allFeatures = userFeatureAnnouncementPreferences || {};
72
73
  const featureConfig = allFeatures[featureName] || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/react-context",
3
- "version": "1.0.18",
3
+ "version": "1.0.20-beta.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -44,10 +44,10 @@
44
44
  "@cee-eng/hydrajs": "4.14.53",
45
45
  "@patternfly/react-core": "4.264.0",
46
46
  "@patternfly/react-icons": "4.92.10",
47
- "@rh-support/components": "1.2.14",
47
+ "@rh-support/components": "1.2.14-beta.0",
48
48
  "@rh-support/types": "0.2.0",
49
- "@rh-support/user-permissions": "1.0.11",
50
- "@rh-support/utils": "1.0.9",
49
+ "@rh-support/user-permissions": "1.0.11-beta.0",
50
+ "@rh-support/utils": "1.0.9-beta.0",
51
51
  "i18next": "^19.0.1",
52
52
  "localforage": "^1.7.3",
53
53
  "lodash": "^4.17.21",
@@ -90,5 +90,5 @@
90
90
  "not ie <= 11",
91
91
  "not op_mini all"
92
92
  ],
93
- "gitHead": "0c83240511a0382d9e55ee1c303ddd276b8f1610"
93
+ "gitHead": "2be4bc53c57d1c9977bd9da0e7bdc16acdd86d15"
94
94
  }