@bigbinary/neeto-github-frontend 1.0.11 → 1.0.13
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/app/javascript/src/translations/en.json +1 -0
- package/dist/index.cjs.js +143 -13
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +142 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"neetoGithub": {
|
|
3
3
|
"connect": "Connect",
|
|
4
4
|
"github": "GitHub",
|
|
5
|
+
"fetchingRepos": "Please wait for a moment while we fetch your repositories",
|
|
5
6
|
"noRepos": "No repositories found",
|
|
6
7
|
"noReposDescription": "Connect a GitHub repository to begin using your existing repos for new services.",
|
|
7
8
|
"notConnectedDescription": "Connect your {{appName, anyCase}} account to GitHub to begin using your existing repos for new services.",
|
package/dist/index.cjs.js
CHANGED
|
@@ -4,27 +4,115 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var classNames = require('classnames');
|
|
7
|
+
var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
|
|
8
|
+
var PageLoader = require('@bigbinary/neeto-molecules/PageLoader');
|
|
9
|
+
var reactI18next = require('react-i18next');
|
|
10
|
+
var ramda = require('ramda');
|
|
11
|
+
var reactQuery = require('react-query');
|
|
12
|
+
var axios = require('axios');
|
|
13
|
+
var constants = require('@bigbinary/neeto-commons-frontend/constants');
|
|
7
14
|
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
8
15
|
var neetoIcons = require('@bigbinary/neeto-icons');
|
|
9
16
|
var neetoui = require('@bigbinary/neetoui');
|
|
10
17
|
var misc = require('@bigbinary/neeto-icons/misc');
|
|
11
18
|
var neetoCist = require('@bigbinary/neeto-cist');
|
|
12
19
|
var Search = require('@bigbinary/neeto-molecules/Search');
|
|
13
|
-
var reactI18next = require('react-i18next');
|
|
14
20
|
var Scrollable = require('@bigbinary/neeto-molecules/Scrollable');
|
|
15
21
|
var DateFormat = require('@bigbinary/neeto-molecules/DateFormat');
|
|
16
|
-
var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
|
|
17
22
|
var require$$0 = require('util');
|
|
18
23
|
|
|
19
24
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
25
|
|
|
21
26
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
27
|
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
28
|
+
var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
|
|
29
|
+
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
23
30
|
var Search__default = /*#__PURE__*/_interopDefaultLegacy(Search);
|
|
24
31
|
var Scrollable__default = /*#__PURE__*/_interopDefaultLegacy(Scrollable);
|
|
25
32
|
var DateFormat__default = /*#__PURE__*/_interopDefaultLegacy(DateFormat);
|
|
26
33
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
27
34
|
|
|
35
|
+
function _typeof(o) {
|
|
36
|
+
"@babel/helpers - typeof";
|
|
37
|
+
|
|
38
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
39
|
+
return typeof o;
|
|
40
|
+
} : function (o) {
|
|
41
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
42
|
+
}, _typeof(o);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function _toPrimitive(input, hint) {
|
|
46
|
+
if (_typeof(input) !== "object" || input === null) return input;
|
|
47
|
+
var prim = input[Symbol.toPrimitive];
|
|
48
|
+
if (prim !== undefined) {
|
|
49
|
+
var res = prim.call(input, hint || "default");
|
|
50
|
+
if (_typeof(res) !== "object") return res;
|
|
51
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
52
|
+
}
|
|
53
|
+
return (hint === "string" ? String : Number)(input);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function _toPropertyKey(arg) {
|
|
57
|
+
var key = _toPrimitive(arg, "string");
|
|
58
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _defineProperty(obj, key, value) {
|
|
62
|
+
key = _toPropertyKey(key);
|
|
63
|
+
if (key in obj) {
|
|
64
|
+
Object.defineProperty(obj, key, {
|
|
65
|
+
value: value,
|
|
66
|
+
enumerable: true,
|
|
67
|
+
configurable: true,
|
|
68
|
+
writable: true
|
|
69
|
+
});
|
|
70
|
+
} else {
|
|
71
|
+
obj[key] = value;
|
|
72
|
+
}
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var _globalProps$organiza$1;
|
|
77
|
+
var GITHUB_INTEGRATIONS_BASE_API_URL = "/github_integrations";
|
|
78
|
+
({
|
|
79
|
+
integrator_id: initializers.globalProps === null || initializers.globalProps === void 0 || (_globalProps$organiza$1 = initializers.globalProps.organization) === null || _globalProps$organiza$1 === void 0 ? void 0 : _globalProps$organiza$1.id,
|
|
80
|
+
integrator_type: "Organization"
|
|
81
|
+
});
|
|
82
|
+
var GITHUB_INTEGRATOR_PARAMS = {
|
|
83
|
+
integratorId: initializers.globalProps.organization.id,
|
|
84
|
+
integratorType: "Organization"
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
var baseUrl = "".concat(GITHUB_INTEGRATIONS_BASE_API_URL, "/app_installations");
|
|
88
|
+
var githubAppUrl = function githubAppUrl(id) {
|
|
89
|
+
return "".concat(baseUrl, "/").concat(id);
|
|
90
|
+
};
|
|
91
|
+
var repositories = function repositories() {
|
|
92
|
+
return axios__default["default"].get("".concat(githubAppUrl(initializers.globalProps.githubAppInstallationId), "/repositories"), {
|
|
93
|
+
params: GITHUB_INTEGRATOR_PARAMS
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
var githubAccountsApi = {
|
|
97
|
+
repositories: repositories
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
var QUERY_KEYS = {
|
|
101
|
+
GITHUB_REPOSITORIES_LIST: "github-repositories-list"
|
|
102
|
+
};
|
|
103
|
+
var STALE_TIME_CONFIG = {
|
|
104
|
+
staleTime: constants.DEFAULT_STALE_TIME
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
108
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
109
|
+
var useFetchGithubRepositories = function useFetchGithubRepositories(_ref) {
|
|
110
|
+
var isConnected = _ref.isConnected;
|
|
111
|
+
return reactQuery.useQuery([QUERY_KEYS.GITHUB_REPOSITORIES_LIST], githubAccountsApi.repositories, _objectSpread(_objectSpread({}, STALE_TIME_CONFIG), {}, {
|
|
112
|
+
enabled: isConnected && ramda.isNotNil(initializers.globalProps.githubAppInstallationId)
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
|
|
28
116
|
var Configure = reactUtils.withT(function (_ref) {
|
|
29
117
|
var t = _ref.t,
|
|
30
118
|
isConnected = _ref.isConnected,
|
|
@@ -459,8 +547,12 @@ var Repositories = function Repositories(_ref) {
|
|
|
459
547
|
};
|
|
460
548
|
|
|
461
549
|
var NeetoGithubNanoContainer = function NeetoGithubNanoContainer(_ref) {
|
|
462
|
-
var _ref$
|
|
463
|
-
|
|
550
|
+
var _ref$isPaneLoading = _ref.isPaneLoading,
|
|
551
|
+
isPaneLoading = _ref$isPaneLoading === void 0 ? false : _ref$isPaneLoading,
|
|
552
|
+
_ref$shouldFetchRepos = _ref.shouldFetchRepositories,
|
|
553
|
+
shouldFetchRepositories = _ref$shouldFetchRepos === void 0 ? true : _ref$shouldFetchRepos,
|
|
554
|
+
_ref$paneAccounts = _ref.paneAccounts,
|
|
555
|
+
paneAccounts = _ref$paneAccounts === void 0 ? [] : _ref$paneAccounts,
|
|
464
556
|
installationUrl = _ref.installationUrl,
|
|
465
557
|
isConnected = _ref.isConnected,
|
|
466
558
|
_ref$isConnecting = _ref.isConnecting,
|
|
@@ -468,11 +560,33 @@ var NeetoGithubNanoContainer = function NeetoGithubNanoContainer(_ref) {
|
|
|
468
560
|
_ref$isPublicRepoAllo = _ref.isPublicRepoAllowed,
|
|
469
561
|
isPublicRepoAllowed = _ref$isPublicRepoAllo === void 0 ? false : _ref$isPublicRepoAllo,
|
|
470
562
|
onConnect = _ref.onConnect,
|
|
471
|
-
_ref$
|
|
472
|
-
|
|
563
|
+
_ref$paneRepositories = _ref.paneRepositories,
|
|
564
|
+
paneRepositories = _ref$paneRepositories === void 0 ? [] : _ref$paneRepositories,
|
|
473
565
|
troubleshootUrl = _ref.troubleshootUrl,
|
|
474
566
|
_ref$isPane = _ref.isPane,
|
|
475
567
|
isPane = _ref$isPane === void 0 ? false : _ref$isPane;
|
|
568
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
569
|
+
t = _useTranslation.t;
|
|
570
|
+
var _useFetchGithubReposi = useFetchGithubRepositories({
|
|
571
|
+
isConnected: shouldFetchRepositories && initializers.globalProps.isGithubIntegrated
|
|
572
|
+
}),
|
|
573
|
+
_useFetchGithubReposi2 = _useFetchGithubReposi.data,
|
|
574
|
+
_useFetchGithubReposi3 = _useFetchGithubReposi2 === void 0 ? {} : _useFetchGithubReposi2,
|
|
575
|
+
_useFetchGithubReposi4 = _useFetchGithubReposi3.repositories,
|
|
576
|
+
containerRepositories = _useFetchGithubReposi4 === void 0 ? [] : _useFetchGithubReposi4,
|
|
577
|
+
_useFetchGithubReposi5 = _useFetchGithubReposi3.accounts,
|
|
578
|
+
containerAccounts = _useFetchGithubReposi5 === void 0 ? [] : _useFetchGithubReposi5,
|
|
579
|
+
isContainerLoading = _useFetchGithubReposi.isLoading;
|
|
580
|
+
var repositories = shouldFetchRepositories ? containerRepositories : paneRepositories;
|
|
581
|
+
var accounts = shouldFetchRepositories ? containerAccounts : paneAccounts;
|
|
582
|
+
var isLoading = shouldFetchRepositories ? isContainerLoading : isPaneLoading;
|
|
583
|
+
if (isLoading) {
|
|
584
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
585
|
+
className: "flex h-96 w-full flex-col items-center"
|
|
586
|
+
}, /*#__PURE__*/React__default["default"].createElement(PageLoader__default["default"], {
|
|
587
|
+
text: t("neetoGithub.fetchingRepos")
|
|
588
|
+
}), ";");
|
|
589
|
+
}
|
|
476
590
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
477
591
|
className: classNames__default["default"]("flex w-full flex-col-reverse", {
|
|
478
592
|
"2xl:flex-row": isPane,
|
|
@@ -2757,16 +2871,14 @@ var NeetoGithubNanoPane = function NeetoGithubNanoPane(_ref) {
|
|
|
2757
2871
|
isConnected = _ref$isConnected === void 0 ? false : _ref$isConnected,
|
|
2758
2872
|
_ref$isPublicRepoAllo = _ref.isPublicRepoAllowed,
|
|
2759
2873
|
isPublicRepoAllowed = _ref$isPublicRepoAllo === void 0 ? false : _ref$isPublicRepoAllo,
|
|
2760
|
-
_ref$repositories = _ref.repositories,
|
|
2761
|
-
repositories = _ref$repositories === void 0 ? [] : _ref$repositories,
|
|
2762
|
-
_ref$accounts = _ref.accounts,
|
|
2763
|
-
accounts = _ref$accounts === void 0 ? [] : _ref$accounts,
|
|
2764
2874
|
_ref$installationUrl = _ref.installationUrl,
|
|
2765
2875
|
installationUrl = _ref$installationUrl === void 0 ? NEW_INSTALLATION_URL : _ref$installationUrl,
|
|
2766
2876
|
_ref$troubleshootUrl = _ref.troubleshootUrl,
|
|
2767
2877
|
troubleshootUrl = _ref$troubleshootUrl === void 0 ? TROUBLESHOOT_URL : _ref$troubleshootUrl,
|
|
2768
2878
|
_ref$onConnect = _ref.onConnect,
|
|
2769
2879
|
onConnect = _ref$onConnect === void 0 ? neetoCist.noop : _ref$onConnect,
|
|
2880
|
+
_ref$projects = _ref.projects,
|
|
2881
|
+
projects = _ref$projects === void 0 ? [] : _ref$projects,
|
|
2770
2882
|
_ref$title = _ref.title,
|
|
2771
2883
|
title = _ref$title === void 0 ? "" : _ref$title,
|
|
2772
2884
|
_ref$description = _ref.description,
|
|
@@ -2774,6 +2886,22 @@ var NeetoGithubNanoPane = function NeetoGithubNanoPane(_ref) {
|
|
|
2774
2886
|
var _useTranslation = reactI18next.useTranslation(),
|
|
2775
2887
|
t = _useTranslation.t;
|
|
2776
2888
|
var initialFocusRef = React.useRef(null);
|
|
2889
|
+
var _useFetchGithubReposi = useFetchGithubRepositories({
|
|
2890
|
+
isConnected: isOpen && isConnected
|
|
2891
|
+
}),
|
|
2892
|
+
_useFetchGithubReposi2 = _useFetchGithubReposi.data,
|
|
2893
|
+
_useFetchGithubReposi3 = _useFetchGithubReposi2 === void 0 ? {} : _useFetchGithubReposi2,
|
|
2894
|
+
_useFetchGithubReposi4 = _useFetchGithubReposi3.repositories,
|
|
2895
|
+
repositories = _useFetchGithubReposi4 === void 0 ? [] : _useFetchGithubReposi4,
|
|
2896
|
+
_useFetchGithubReposi5 = _useFetchGithubReposi3.accounts,
|
|
2897
|
+
accounts = _useFetchGithubReposi5 === void 0 ? [] : _useFetchGithubReposi5,
|
|
2898
|
+
isPaneLoading = _useFetchGithubReposi.isLoading;
|
|
2899
|
+
var paneRepositories = repositories.filter(function (repository) {
|
|
2900
|
+
return !neetoCist.findBy({
|
|
2901
|
+
repository: repository.fullName
|
|
2902
|
+
}, projects);
|
|
2903
|
+
});
|
|
2904
|
+
var paneAccounts = isConnected ? accounts : [];
|
|
2777
2905
|
return /*#__PURE__*/React__default["default"].createElement(neetoui.Pane, {
|
|
2778
2906
|
initialFocusRef: initialFocusRef,
|
|
2779
2907
|
isOpen: isOpen,
|
|
@@ -2786,15 +2914,17 @@ var NeetoGithubNanoPane = function NeetoGithubNanoPane(_ref) {
|
|
|
2786
2914
|
className: "mt-4",
|
|
2787
2915
|
style: "body2"
|
|
2788
2916
|
}, neetoCist.isPresent(description) ? description : t("neetoGithub.modal.description"))), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Body, null, /*#__PURE__*/React__default["default"].createElement(NeetoGithubNanoContainer, {
|
|
2789
|
-
accounts: accounts,
|
|
2790
2917
|
installationUrl: installationUrl,
|
|
2791
2918
|
isConnected: isConnected,
|
|
2792
2919
|
isConnecting: isConnecting,
|
|
2920
|
+
isPaneLoading: isPaneLoading,
|
|
2793
2921
|
isPublicRepoAllowed: isPublicRepoAllowed,
|
|
2794
2922
|
onConnect: onConnect,
|
|
2795
|
-
|
|
2923
|
+
paneAccounts: paneAccounts,
|
|
2924
|
+
paneRepositories: paneRepositories,
|
|
2796
2925
|
troubleshootUrl: troubleshootUrl,
|
|
2797
|
-
isPane: true
|
|
2926
|
+
isPane: true,
|
|
2927
|
+
shouldFetchRepositories: false
|
|
2798
2928
|
})));
|
|
2799
2929
|
};
|
|
2800
2930
|
|