@bigbinary/neeto-custom-domains-frontend 3.0.2 → 3.0.4

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.
@@ -20,6 +20,7 @@ var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
20
20
  var Button = require('@bigbinary/neetoui/Button');
21
21
  var Typography = require('@bigbinary/neetoui/Typography');
22
22
  var Tag = require('@bigbinary/neetoui/Tag');
23
+ var NoData = require('@bigbinary/neetoui/NoData');
23
24
  var Pane = require('@bigbinary/neetoui/Pane');
24
25
  var Stepper = require('@bigbinary/neetoui/Stepper');
25
26
  var Callout = require('@bigbinary/neetoui/Callout');
@@ -151,7 +152,8 @@ var DeleteAlert = reactUtils.withT(function (_ref) {
151
152
 
152
153
  var STATUS_TAG_STYLES = {
153
154
  active: "success",
154
- pending: "warning"
155
+ pending: "warning",
156
+ failed: "danger"
155
157
  };
156
158
 
157
159
  var Domain = reactUtils.withT(function (_ref) {
@@ -161,13 +163,7 @@ var Domain = reactUtils.withT(function (_ref) {
161
163
  customDomain = _ref.customDomain,
162
164
  openDeleteAlert = _ref.openDeleteAlert,
163
165
  helpDocUrl = _ref.helpDocUrl;
164
- return /*#__PURE__*/jsxRuntime.jsx(CardLayout, {
165
- actionBlock: !isCustomDomainAdded && /*#__PURE__*/jsxRuntime.jsx(Button, {
166
- label: t("neetoCustomDomains.actions.add", {
167
- what: t("neetoCustomDomains.customDomain", constants.SINGULAR)
168
- }),
169
- onClick: openPane
170
- }),
166
+ return isCustomDomainAdded ? /*#__PURE__*/jsxRuntime.jsx(CardLayout, {
171
167
  title: t("neetoCustomDomains.connectionTitle"),
172
168
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
173
169
  className: "space-y-1",
@@ -177,13 +173,13 @@ var Domain = reactUtils.withT(function (_ref) {
177
173
  className: "flex items-center space-x-2",
178
174
  children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
179
175
  style: "body2",
180
- children: isCustomDomainAdded ? customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname : t("neetoCustomDomains.noDomainConnected")
181
- }), isCustomDomainAdded && /*#__PURE__*/jsxRuntime.jsx(Tag, {
176
+ children: customDomain === null || customDomain === void 0 ? void 0 : customDomain.hostname
177
+ }), /*#__PURE__*/jsxRuntime.jsx(Tag, {
182
178
  "data-cy": "".concat(general.hyphenize(customDomain === null || customDomain === void 0 ? void 0 : customDomain.status), "-tag-container"),
183
179
  style: STATUS_TAG_STYLES[customDomain === null || customDomain === void 0 ? void 0 : customDomain.status],
184
180
  label: t("neetoCustomDomains.status.domain.".concat(customDomain === null || customDomain === void 0 ? void 0 : customDomain.status))
185
181
  })]
186
- }), isCustomDomainAdded && /*#__PURE__*/jsxRuntime.jsx(MoreDropdown, {
182
+ }), /*#__PURE__*/jsxRuntime.jsx(MoreDropdown, {
187
183
  dropdownButtonProps: {
188
184
  "data-testid": "nui-dropdown-icon-".concat(customDomain === null || customDomain === void 0 ? void 0 : customDomain.id)
189
185
  },
@@ -217,6 +213,28 @@ var Domain = reactUtils.withT(function (_ref) {
217
213
  })
218
214
  })]
219
215
  })
216
+ }) : /*#__PURE__*/jsxRuntime.jsx("div", {
217
+ className: "flex h-full w-full items-center justify-center",
218
+ children: /*#__PURE__*/jsxRuntime.jsx(NoData, {
219
+ className: "w-full",
220
+ title: t("neetoCustomDomains.noData.title"),
221
+ helpText: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
222
+ i18nKey: "neetoCustomDomains.noData.helpText",
223
+ components: {
224
+ helpLink: /*#__PURE__*/jsxRuntime.jsx(Button, {
225
+ href: helpDocUrl,
226
+ style: "link",
227
+ target: "_blank"
228
+ })
229
+ }
230
+ }),
231
+ primaryButtonProps: {
232
+ label: t("neetoCustomDomains.actions.add", {
233
+ what: t("neetoCustomDomains.customDomain", constants.SINGULAR)
234
+ }),
235
+ onClick: openPane
236
+ }
237
+ })
220
238
  });
221
239
  });
222
240
 
@@ -227,6 +245,7 @@ var INITIAL_VALUES = {
227
245
  var CURRENT_STEP = {
228
246
  notAdded: 0,
229
247
  pending: 1,
248
+ failed: 1,
230
249
  active: 2
231
250
  };
232
251
  var STEPS = [{
@@ -762,7 +781,7 @@ var dnsProviderData = function dnsProviderData(hostname) {
762
781
  };
763
782
 
764
783
  var Validation = function Validation(_ref) {
765
- var _dnsHelpDocs$dnsProvi, _dnsHelpDocs$dnsProvi2, _dnsHelpDocs$unknown;
784
+ var _dnsHelpDocs$dnsProvi, _dnsHelpDocs$dnsProvi2, _dnsHelpDocs$unknown, _dnsHelpDocs$dnsProvi3, _dnsHelpDocs$dnsProvi4, _dnsHelpDocs$unknown2, _dnsHelpDocs$dnsProvi5, _dnsHelpDocs$dnsProvi6, _dnsHelpDocs$unknown3;
766
785
  var customDomain = _ref.customDomain,
767
786
  onClose = _ref.onClose,
768
787
  url = _ref.url,
@@ -773,6 +792,7 @@ var Validation = function Validation(_ref) {
773
792
  dnsTarget = customDomain.dnsTarget,
774
793
  status = customDomain.status,
775
794
  dnsProvider = customDomain.dnsProvider;
795
+ var queryClient = reactQuery.useQueryClient();
776
796
  var _useState = React.useState(""),
777
797
  _useState2 = _slicedToArray(_useState, 2),
778
798
  errorKey = _useState2[0],
@@ -784,6 +804,9 @@ var Validation = function Validation(_ref) {
784
804
  onError: function onError(_ref2) {
785
805
  var response = _ref2.response;
786
806
  setErrorKey(response.data.error);
807
+ queryClient.invalidateQueries({
808
+ queryKey: [DOMAIN_QUERY_KEY]
809
+ });
787
810
  },
788
811
  onSuccess: function onSuccess() {
789
812
  Toastr.success(t("neetoCustomDomains.validation.successMessage"));
@@ -848,11 +871,62 @@ var Validation = function Validation(_ref) {
848
871
  x: '100%'
849
872
  }
850
873
  })
851
- }), neetoCist.isNotEmpty(errorKey) && /*#__PURE__*/jsxRuntime.jsx(Callout, {
874
+ }), status === "failed" && /*#__PURE__*/jsxRuntime.jsx(Callout, {
852
875
  style: STATUS_TAG_STYLES[status],
853
876
  children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
854
877
  style: "body2",
855
- children: t(errorKey)
878
+ children: dnsProvider !== "unknown" ? /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
879
+ i18nKey: "neetoCustomDomains.domainValidationFailedForKnownProvider",
880
+ values: {
881
+ dnsProvider: dnsProviderInfo.name
882
+ },
883
+ components: {
884
+ Login: /*#__PURE__*/jsxRuntime.jsx(Button, {
885
+ href: dnsProviderInfo.loginUrl,
886
+ rel: "noreferrer",
887
+ style: "link",
888
+ target: "_blank"
889
+ }),
890
+ Link: /*#__PURE__*/jsxRuntime.jsx(Button, {
891
+ href: (_dnsHelpDocs$dnsProvi3 = (_dnsHelpDocs$dnsProvi4 = dnsHelpDocs[dnsProvider]) === null || _dnsHelpDocs$dnsProvi4 === void 0 ? void 0 : _dnsHelpDocs$dnsProvi4[domainType]) !== null && _dnsHelpDocs$dnsProvi3 !== void 0 ? _dnsHelpDocs$dnsProvi3 : (_dnsHelpDocs$unknown2 = dnsHelpDocs.unknown) === null || _dnsHelpDocs$unknown2 === void 0 ? void 0 : _dnsHelpDocs$unknown2[domainType],
892
+ rel: "noreferrer",
893
+ style: "link",
894
+ target: "_blank"
895
+ }),
896
+ br: /*#__PURE__*/jsxRuntime.jsx("br", {})
897
+ }
898
+ }) : /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
899
+ i18nKey: "neetoCustomDomains.domainValidationFailedForUnknownProvider",
900
+ values: {
901
+ dnsProvider: dnsProviderInfo.name
902
+ },
903
+ components: {
904
+ Login: /*#__PURE__*/jsxRuntime.jsx(Button, {
905
+ href: dnsProviderInfo.loginUrl,
906
+ rel: "noreferrer",
907
+ style: "link",
908
+ target: "_blank"
909
+ }),
910
+ Link: /*#__PURE__*/jsxRuntime.jsx(Button, {
911
+ href: (_dnsHelpDocs$dnsProvi5 = (_dnsHelpDocs$dnsProvi6 = dnsHelpDocs[dnsProvider]) === null || _dnsHelpDocs$dnsProvi6 === void 0 ? void 0 : _dnsHelpDocs$dnsProvi6[domainType]) !== null && _dnsHelpDocs$dnsProvi5 !== void 0 ? _dnsHelpDocs$dnsProvi5 : (_dnsHelpDocs$unknown3 = dnsHelpDocs.unknown) === null || _dnsHelpDocs$unknown3 === void 0 ? void 0 : _dnsHelpDocs$unknown3[domainType],
912
+ rel: "noreferrer",
913
+ style: "link",
914
+ target: "_blank"
915
+ }),
916
+ br: /*#__PURE__*/jsxRuntime.jsx("br", {})
917
+ }
918
+ })
919
+ })
920
+ }), neetoCist.isNotEmpty(errorKey) && status === "pending" && /*#__PURE__*/jsxRuntime.jsx(Callout, {
921
+ style: STATUS_TAG_STYLES[status],
922
+ children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
923
+ style: "body2",
924
+ children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
925
+ i18nKey: errorKey,
926
+ components: {
927
+ br: /*#__PURE__*/jsxRuntime.jsx("br", {})
928
+ }
929
+ })
856
930
  })
857
931
  })]
858
932
  }), /*#__PURE__*/jsxRuntime.jsx(Pane.Footer, {
@@ -861,7 +935,7 @@ var Validation = function Validation(_ref) {
861
935
  children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
862
936
  "data-cy": "validate-domain-button",
863
937
  disabled: isValidating || isDomainValidated,
864
- label: t("neetoCustomDomains.validation.buttonLabel.domain"),
938
+ label: status === "failed" ? t("neetoCustomDomains.validation.buttonLabel.revalidate") : neetoCist.isNotEmpty(errorKey) ? t("neetoCustomDomains.validation.buttonLabel.validateManually") : t("neetoCustomDomains.validation.buttonLabel.domain"),
865
939
  loading: isValidating,
866
940
  onClick: validateDomain
867
941
  }), /*#__PURE__*/jsxRuntime.jsx(Button, {
@@ -1009,7 +1083,7 @@ var CustomDomain = function CustomDomain(_ref) {
1009
1083
  openPane: openPane,
1010
1084
  size: headerSize
1011
1085
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
1012
- className: "flex w-full justify-center",
1086
+ className: "flex w-full justify-center h-full",
1013
1087
  children: /*#__PURE__*/jsxRuntime.jsx(Domain, {
1014
1088
  customDomain: customDomain,
1015
1089
  helpDocUrl: helpDocUrl,