@rh-support/manage 1.0.39-beta.33 → 1.0.39-beta.35

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.
@@ -32,7 +32,7 @@ export function ConfigInLineEdit(props) {
32
32
  }, [props.fieldValue]);
33
33
  return (React.createElement(React.Fragment, null,
34
34
  React.createElement(InlineEdit, { labelProps: { htmlFor: 'case-details-custom-email' }, allowInlineEdit: true, initialIsEditing: false, onSave: onSave, onCancel: onCancel, saveDisabled: input === props.fieldValue || props.isUpdating || hasLargeInput, loadingIndicator: React.createElement(LoadingIndicator, { show: props.isUpdating, isInline: true }) },
35
- React.createElement(TextAreaAutosize, { id: `config-value-${props.id}`, name: `config-value-${props.id}`, "aria-invalid": hasLargeInput, className: `form-control${hasLargeInput ? ' form-invalid' : ''}`, value: input, "data-tracking-id": "open-case-describe-ktQ1-issue", onChange: onChange, disabled: props.isUpdating }),
35
+ React.createElement(TextAreaAutosize, { id: `config-value-${props.id}`, name: `config-value-${props.id}`, "aria-invalid": hasLargeInput, className: `form-control${hasLargeInput ? ' form-invalid' : ''}`, value: input, "data-tracking-id": "manage-case-describe-ktQ1-issue", onChange: onChange, disabled: props.isUpdating }),
36
36
  hasLargeInput && (React.createElement("p", { className: "form-instructions form-invalid" },
37
37
  "Config value cannot be more than ",
38
38
  CONFIG_FIELD_VALUE_LIMIT,
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentSuggestion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.tsx"],"names":[],"mappings":"AACA,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAC;AAOvD,UAAU,MAAM;CAAG;AAEnB,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,MAAM,CAiC3C,CAAC"}
1
+ {"version":3,"file":"TopContentSuggestion.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestion.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,EAAE,EAAuB,MAAM,OAAO,CAAC;AAOvD,UAAU,MAAM;CAAG;AAEnB,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,MAAM,CAoC3C,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { ExpandableSection, Panel, PanelMain, PanelMainBody, Title } from '@patternfly/react-core';
2
+ import { isEmpty } from 'lodash';
2
3
  import React, { useEffect, useState } from 'react';
3
4
  import { Trans } from 'react-i18next';
4
5
  import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
@@ -15,6 +16,8 @@ export const TopContentSuggestion = () => {
15
16
  fetchTopContentSuggestions(topContentDispatch, selectedProduct.name, selectedVersion);
16
17
  }
17
18
  }, [topContentDispatch, selectedProduct, selectedVersion]);
19
+ if (isEmpty(suggestion.linkedResources))
20
+ return React.createElement(React.Fragment, null);
18
21
  return (React.createElement(Panel, { variant: "raised", className: "pf-u-mx-md pf-u-p-md" },
19
22
  React.createElement(PanelMain, null,
20
23
  React.createElement(PanelMainBody, null,
@@ -1 +1 @@
1
- {"version":3,"file":"TopContentSuggestionHintAccept.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAgBrH,OAAc,EAAE,EAAE,EAAgC,MAAM,OAAO,CAAC;AAahE,UAAU,MAAM;IACZ,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,SAAS,EAAE,mBAAmB,CAAC;CAClC;AAED,eAAO,MAAM,8BAA8B,EAAE,EAAE,CAAC,MAAM,CA8KrD,CAAC"}
1
+ {"version":3,"file":"TopContentSuggestionHintAccept.d.ts","sourceRoot":"","sources":["../../../../../../src/components/TopContentManagement/TopContentEditor/TopContentSuggestion/TopContentSuggestionHintAccept.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,MAAM,2DAA2D,CAAC;AAkBrH,OAAc,EAAE,EAAE,EAAgC,MAAM,OAAO,CAAC;AAgBhE,UAAU,MAAM;IACZ,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,SAAS,EAAE,mBAAmB,CAAC;CAClC;AAED,eAAO,MAAM,8BAA8B,EAAE,EAAE,CAAC,MAAM,CAkPrD,CAAC"}
@@ -7,23 +7,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { ActionGroup, Button, Card, CardBody, Form, FormGroup, Select, SelectOption, SelectVariant, TextInput, } from '@patternfly/react-core';
10
+ import { Button, Card, CardBody, Form, FormGroup, Select, SelectOption, SelectVariant, TextInput, Tooltip, ValidatedOptions, } from '@patternfly/react-core';
11
+ import PencilAltIcon from '@patternfly/react-icons/dist/js/icons/pencil-alt-icon';
11
12
  import { ToastNotification } from '@rh-support/components';
12
- import { getVersion, isRegularVersion } from '@rh-support/utils';
13
- import { isEmpty, isUndefined } from 'lodash';
13
+ import { getVersion, isRegularVersion, isValidUrl } from '@rh-support/utils';
14
+ import { isEmpty, isUndefined, trim } from 'lodash';
14
15
  import React, { useEffect, useMemo, useState } from 'react';
15
16
  import { Trans, useTranslation } from 'react-i18next';
17
+ import { CATEGORY_LIMIT } from '../../../../constants/TopContent';
16
18
  import { useTopContentContext, useTopContentDispatchContext } from '../../../../context/TopContentProvider';
19
+ import { flagContentUsage } from '../../../../reducers/TopContentHelpers';
17
20
  import { ContentMode, deleteTopContentSuggestion, fetchCategories, saveAddedNewSectionContents, saveAddToTopContent, } from '../../../../reducers/TopContentReducer';
21
+ import CategoryLimit from '../../CategoryLimit/CategoryLimit';
18
22
  export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
19
23
  const { t } = useTranslation();
20
- const { categories, topContentResponse, topContentEditState, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, isAddingCategory, suggestion, } = useTopContentContext();
24
+ const { categories, topContentResponse, topContentEditState, selectedProduct, selectedVersion, isCatOnlyForMajorVersion, isAddingCategory, suggestion, categoryUsage, } = useTopContentContext();
21
25
  const topContentDispatch = useTopContentDispatchContext();
22
26
  const [isSelectOpen, setSelectOpen] = useState(false);
23
27
  const [selected, setSelected] = useState();
24
28
  const [isSaving, setIsSaving] = useState(false);
25
29
  const [resourceTitle, setResourceTitle] = useState('');
30
+ const [linkToContent, setLinkToContent] = useState('');
31
+ const [isEditClicked, setIsEditClicked] = useState(false);
26
32
  const categoryToSave = useMemo(() => topContentEditState.find((category) => category.categoryId === (selected === null || selected === void 0 ? void 0 : selected.id)), [topContentEditState, selected]);
33
+ const flagContentEditState = useMemo(() => flagContentUsage(topContentEditState, categoryUsage, selectedVersion), [topContentEditState, categoryUsage, selectedVersion]);
27
34
  const isMajorVersionOnly = isUndefined(getVersion(selectedVersion).minor);
28
35
  const minorSelectedNoMinorContentButAvailableMajorContent = !topContentResponse.isFetching &&
29
36
  !isEmpty(topContentResponse.data) &&
@@ -31,6 +38,8 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
31
38
  isRegularVersion(selectedVersion) &&
32
39
  isCatOnlyForMajorVersion &&
33
40
  !isAddingCategory;
41
+ const isCategoryLimitReached = (minorSelectedNoMinorContentButAvailableMajorContent ? [] : flagContentEditState).length >= CATEGORY_LIMIT.MAX;
42
+ const isCategoryInList = flagContentEditState.some((c) => c.categoryId === (selected === null || selected === void 0 ? void 0 : selected.id));
34
43
  const onToggle = () => {
35
44
  setSelectOpen((previousToggleState) => !previousToggleState);
36
45
  };
@@ -38,13 +47,18 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
38
47
  setSelected(selection);
39
48
  onToggle();
40
49
  };
50
+ const isDisabled = isEmpty(linkToContent) ||
51
+ isEmpty(trim(resourceTitle)) ||
52
+ isUndefined(selected) ||
53
+ !isValidUrl(linkToContent) ||
54
+ (isCategoryLimitReached && !isCategoryInList);
41
55
  const addContentToCategory = () => __awaiter(void 0, void 0, void 0, function* () {
42
56
  try {
43
57
  setIsSaving(true);
44
58
  const newContent = {
45
59
  contentTitle: resourceTitle,
46
60
  contentRank: categoryToSave === null || categoryToSave === void 0 ? void 0 : categoryToSave.content.length,
47
- contentUrl: resources.resourceViewUri,
61
+ contentUrl: linkToContent,
48
62
  mode: ContentMode.ADD,
49
63
  };
50
64
  yield saveAddToTopContent(topContentDispatch, topContentEditState, categoryToSave.id, categoryToSave === null || categoryToSave === void 0 ? void 0 : categoryToSave.categoryId, newContent, -1);
@@ -63,7 +77,7 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
63
77
  setIsSaving(true);
64
78
  const newContent = {
65
79
  contentTitle: resourceTitle,
66
- contentUrl: resources.resourceViewUri,
80
+ contentUrl: linkToContent,
67
81
  isAttentionNeeded: false,
68
82
  mode: ContentMode.NEW_SECTION_CONTENT,
69
83
  };
@@ -91,7 +105,8 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
91
105
  });
92
106
  useEffect(() => {
93
107
  setResourceTitle(resources.resourceTitle);
94
- }, [resources.resourceTitle]);
108
+ setLinkToContent(resources.resourceViewUri);
109
+ }, [resources.resourceTitle, resources.resourceViewUri]);
95
110
  useEffect(() => {
96
111
  try {
97
112
  fetchCategories(topContentDispatch);
@@ -100,17 +115,27 @@ export const TopContentSuggestionHintAccept = ({ onCancel, resources }) => {
100
115
  ToastNotification.addDangerMessage(t('There was an error loading top content categories'));
101
116
  }
102
117
  }, [topContentDispatch, t]);
103
- return (React.createElement(Card, null,
118
+ return (React.createElement(Card, { className: "pf-u-m-sm" },
104
119
  React.createElement(CardBody, { className: "card-hint" },
105
- React.createElement("span", { className: "hint-title" }, resources.resourceTitle),
106
120
  React.createElement(Form, null,
121
+ isEditClicked ? (React.createElement(React.Fragment, null,
122
+ React.createElement(FormGroup, { label: t('Link to content'), isRequired: true, fieldId: "top-content-link" },
123
+ React.createElement(TextInput, { isRequired: true, type: "text", id: "top-content-resource-link", name: "top-content-resource-link", "data-tracking-id": "top-content-resource-link", value: linkToContent, onChange: setLinkToContent, validated: isEmpty(linkToContent) || !isValidUrl(linkToContent)
124
+ ? ValidatedOptions.error
125
+ : ValidatedOptions.default })),
126
+ React.createElement(FormGroup, { label: t('Headline'), isRequired: true, fieldId: "simple-form-email-01" },
127
+ React.createElement(TextInput, { isRequired: true, type: "text", id: "top-content-headline-category", name: "top-content-headline-category", "data-tracking-id": "top-content-headline-category", value: resourceTitle, onChange: setResourceTitle, validated: isEmpty(trim(resourceTitle)) ? ValidatedOptions.error : ValidatedOptions.default })))) : (React.createElement("span", null,
128
+ React.createElement(Button, { variant: "link", isInline: true },
129
+ React.createElement("u", null,
130
+ React.createElement("a", { className: "hint-title pf-u-font-size-md", target: "_blank", href: linkToContent, rel: "noreferrer" }, resources.resourceTitle))),
131
+ React.createElement(Tooltip, { content: t('Edit Link to content and Headline'), position: "top" },
132
+ React.createElement(Button, { variant: "link", icon: React.createElement(PencilAltIcon, null), onClick: () => setIsEditClicked((pre) => !pre) })))),
107
133
  React.createElement(FormGroup, { label: t('Category'), isRequired: true, fieldId: "simple-form-email-01" },
108
- React.createElement(Select, { variant: SelectVariant.single, id: "category-selection", name: "category-selection", "data-testid": "category-selection", placeholderText: "Select a category", onToggle: onToggle, isOpen: isSelectOpen, onSelect: onSelect, selections: selected === null || selected === void 0 ? void 0 : selected.categoryName, isDisabled: categories.isFetching || categories.isError }, categories.data.map((category, id) => (React.createElement(SelectOption, { key: id, value: category },
134
+ React.createElement(Select, Object.assign({ variant: SelectVariant.single, id: "category-selection", name: "category-selection", "data-testid": "category-selection", placeholderText: "Select a category", onToggle: onToggle, isOpen: isSelectOpen, onSelect: onSelect, selections: selected === null || selected === void 0 ? void 0 : selected.categoryName, isDisabled: categories.isError, loadingVariant: 'spinner' }, (categories.isFetching && { loadingVariant: 'spinner' })), categories.data.map((category, id) => (React.createElement(SelectOption, { key: id, value: category },
109
135
  React.createElement("div", null, category.categoryName)))))),
110
- React.createElement(FormGroup, { label: t('Headline'), isRequired: true, fieldId: "simple-form-email-01" },
111
- React.createElement(TextInput, { isRequired: true, type: "text", id: "top-content-hind-category", name: "top-content-hind-category", "data-tracking-id": "top-content-hind-category", value: resourceTitle, onChange: setResourceTitle })),
112
- React.createElement(ActionGroup, null,
113
- React.createElement(Button, { variant: "primary", onClick: onSaveContent, isDisabled: isSaving || isUndefined(selected), isLoading: isSaving, "data-tracking-id": "suggested-content-save-button" },
136
+ React.createElement("div", { className: "pf-u-mt-sm" },
137
+ isCategoryLimitReached && !isCategoryInList && !isUndefined(selected) && React.createElement(CategoryLimit, null),
138
+ React.createElement(Button, { variant: "primary", onClick: onSaveContent, isDisabled: isSaving || isDisabled, isLoading: isSaving, "data-tracking-id": "suggested-content-save-button" },
114
139
  React.createElement(Trans, null, "Save")),
115
140
  React.createElement(Button, { variant: "link", onClick: () => onCancel(false) },
116
141
  React.createElement(Trans, null, "Cancel")))))));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/manage",
3
- "version": "1.0.39-beta.33",
3
+ "version": "1.0.39-beta.35",
4
4
  "description": "Customer Support Manage App",
5
5
  "author": "Jordan Eudy <jeudy100@gmail.com>",
6
6
  "homepage": "",
@@ -51,7 +51,7 @@
51
51
  "not op_mini all"
52
52
  ],
53
53
  "peerDependencies": {
54
- "@cee-eng/hydrajs": "4.14.53",
54
+ "@cee-eng/hydrajs": "4.15.64",
55
55
  "@patternfly/patternfly": "4.196.7",
56
56
  "@patternfly/pfe-accordion": "1.12.3",
57
57
  "@patternfly/pfe-collapse": "1.12.3",
@@ -87,19 +87,19 @@
87
87
  "typescript": "4.3.5"
88
88
  },
89
89
  "dependencies": {
90
- "@cee-eng/hydrajs": "4.14.53",
90
+ "@cee-eng/hydrajs": "4.15.64",
91
91
  "@patternfly/patternfly": "4.196.7",
92
92
  "@patternfly/pfe-accordion": "1.12.3",
93
93
  "@patternfly/pfe-collapse": "1.12.3",
94
94
  "@patternfly/pfe-tabs": "1.12.3",
95
95
  "@patternfly/react-core": "4.264.0",
96
96
  "@patternfly/react-table": "4.111.33",
97
- "@rh-support/components": "1.2.22-beta.33",
98
- "@rh-support/configs": "1.0.2-beta.33",
99
- "@rh-support/react-context": "1.0.30-beta.33",
97
+ "@rh-support/components": "1.2.22-beta.34",
98
+ "@rh-support/configs": "1.0.2-beta.34",
99
+ "@rh-support/react-context": "1.0.30-beta.34",
100
100
  "@rh-support/types": "0.2.1-beta.33",
101
- "@rh-support/user-permissions": "1.0.12-beta.33",
102
- "@rh-support/utils": "1.0.10-beta.33",
101
+ "@rh-support/user-permissions": "1.0.12-beta.34",
102
+ "@rh-support/utils": "1.0.10-beta.34",
103
103
  "@types/react-beautiful-dnd": "^13.0.0",
104
104
  "i18next": ">=17.0.1",
105
105
  "lodash": ">=4.17.15",
@@ -109,5 +109,5 @@
109
109
  "react-i18next": ">=10.11.0",
110
110
  "react-router-dom": ">=5.1.2"
111
111
  },
112
- "gitHead": "c3fb875701950cd1d42175d1d526af01c1398ecf"
112
+ "gitHead": "d297610dca64fe9c0f85a49e7bb260301dd056cf"
113
113
  }