@devops-flow/devops-flow-pipeline-detail 0.0.53 → 0.0.55

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.
@@ -35,7 +35,7 @@ var ExecuteButton = function ExecuteButton(_ref) {
35
35
  disabled = _useState2[0],
36
36
  setDisabled = _useState2[1];
37
37
  var globalConfig = useContext(ConfigContext);
38
- var apiHost = globalConfig.replaceLinks.api;
38
+ var apiHeaderFn = globalConfig.apiHeaderFn;
39
39
  var doCallApiAndRefresh = function doCallApiAndRefresh(apiFunc, params) {
40
40
  return callApiAndRefresh(apiFunc, params, onRefresh, setLoading, setDisabled, name);
41
41
  };
@@ -51,7 +51,7 @@ var ExecuteButton = function ExecuteButton(_ref) {
51
51
  pipelineId: pipelineId,
52
52
  pipelineRunId: pipelineRunId,
53
53
  jobId: job.id,
54
- host: apiHost
54
+ apiHeaderFn: apiHeaderFn
55
55
  });
56
56
  break;
57
57
  }
@@ -61,7 +61,7 @@ var ExecuteButton = function ExecuteButton(_ref) {
61
61
  pipelineId: pipelineId,
62
62
  pipelineRunId: pipelineRunId,
63
63
  jobId: job.id,
64
- host: apiHost
64
+ apiHeaderFn: apiHeaderFn
65
65
  });
66
66
  break;
67
67
  }
@@ -71,7 +71,7 @@ var ExecuteButton = function ExecuteButton(_ref) {
71
71
  pipelineId: pipelineId,
72
72
  pipelineRunId: pipelineRunId,
73
73
  jobId: job.id,
74
- host: apiHost
74
+ apiHeaderFn: apiHeaderFn
75
75
  });
76
76
  break;
77
77
  }
@@ -71,7 +71,7 @@ var SubTree = function SubTree(props) {
71
71
  job = props.job,
72
72
  setBuildId = props.setBuildId;
73
73
  var globalConfig = useContext(ConfigContext);
74
- var apiHost = globalConfig.replaceLinks.api;
74
+ var apiHeaderFn = globalConfig.apiHeaderFn;
75
75
  var _useState = useState([]),
76
76
  tree = _useState[0],
77
77
  setTree = _useState[1];
@@ -87,7 +87,7 @@ var SubTree = function SubTree(props) {
87
87
  var getPipelineJobSteps = function getPipelineJobSteps() {
88
88
  var pipelineRunId = instance.pipelineRunId,
89
89
  pipelineId = instance.pipelineId;
90
- GetPipelineJobSteps(pipelineId, pipelineRunId, job.id, apiHost).then(function (jobSteps) {
90
+ GetPipelineJobSteps(pipelineId, pipelineRunId, job.id, apiHeaderFn).then(function (jobSteps) {
91
91
  setLoading(false);
92
92
  if (jobSteps && jobSteps[0]) {
93
93
  setTree(jobSteps);
@@ -208,7 +208,7 @@ var LogButton = function LogButton(_ref) {
208
208
  buildId = _useState14[0],
209
209
  setBuildId = _useState14[1];
210
210
  var globalConfig = useContext(ConfigContext);
211
- var apiHost = globalConfig.replaceLinks.api;
211
+ var apiHeaderFn = globalConfig.apiHeaderFn;
212
212
  var isFinishStatus = function isFinishStatus(status) {
213
213
  return ['success', 'fail'].includes(status);
214
214
  };
@@ -256,7 +256,7 @@ var LogButton = function LogButton(_ref) {
256
256
  buildId: buildId,
257
257
  offset: offset,
258
258
  stepIndex: selectNode.nodeIndex,
259
- host: apiHost
259
+ apiHeaderFn: apiHeaderFn
260
260
  }).then(function (res) {
261
261
  var logs = res.logs,
262
262
  last = res.last;
@@ -455,7 +455,7 @@ var LogButton = function LogButton(_ref) {
455
455
  jobId: job.id,
456
456
  stepIndex: context.selectNode.stepIndex,
457
457
  buildId: buildId
458
- }, apiHost).then(function (res) {
458
+ }, apiHeaderFn).then(function (res) {
459
459
  setViewLogAction(res);
460
460
  })["catch"](function () {
461
461
  setViewLogAction('');
@@ -94,7 +94,7 @@ var FlowSwitch = function FlowSwitch(_ref) {
94
94
  requesting = _useState[0],
95
95
  setRequesting = _useState[1];
96
96
  var globalConfig = useContext(ConfigContext);
97
- var apiHost = globalConfig.replaceLinks.api;
97
+ var apiHeaderFn = globalConfig.apiHeaderFn;
98
98
  var manualSwitch = function manualSwitch() {
99
99
  if (requesting || status === 'SUCCESS' && !isOld) return;
100
100
  setRequesting(true);
@@ -102,7 +102,7 @@ var FlowSwitch = function FlowSwitch(_ref) {
102
102
  pipelineId: pipelineId,
103
103
  pipelineRunId: pipelineRunId,
104
104
  jobId: pipelineJobId,
105
- host: apiHost
105
+ apiHeaderFn: apiHeaderFn
106
106
  }).then(function (res) {
107
107
  setRequesting(false);
108
108
  if (res) {
@@ -45,7 +45,7 @@ var Current = function Current(_ref) {
45
45
  canEditPipeline = _useState4[0],
46
46
  setCanEditPipeline = _useState4[1];
47
47
  var globalConfig = useContext(ConfigContext);
48
- var apiHost = globalConfig.replaceLinks.api;
48
+ var apiHeaderFn = globalConfig.apiHeaderFn;
49
49
  var checkPipelinePermission = function checkPipelinePermission() {
50
50
  permissionUtil.checkPermissionList([PERMISSION_PIPELINE_EXECUTE, PERMISSION_PIPELINE_EDIT], props.pipelineId, 'pipeline', window.AK_GLOBAL.currentUser.workid).then(function (data) {
51
51
  setCanExecutePipeline(data[PERMISSION_PIPELINE_EXECUTE]);
@@ -53,7 +53,7 @@ var Current = function Current(_ref) {
53
53
  });
54
54
  };
55
55
  var getLatestPipeline = function getLatestPipeline() {
56
- GetLatestPipelineRun(pipelineId, apiHost).then(function (res) {
56
+ GetLatestPipelineRun(pipelineId, apiHeaderFn).then(function (res) {
57
57
  setLoading(false);
58
58
  if (res.successful) {
59
59
  var _res$object;
@@ -42,12 +42,12 @@ var Current = function Current(_ref) {
42
42
  }, []);
43
43
  var getLatestPipeline = /*#__PURE__*/function () {
44
44
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
45
- var apiHost, api;
45
+ var apiHeaderFn, api;
46
46
  return _regeneratorRuntime.wrap(function _callee$(_context) {
47
47
  while (1) switch (_context.prev = _context.next) {
48
48
  case 0:
49
- apiHost = globalConfig.replaceLinks.api;
50
- api = pipelineRunId ? GetPipelineRun(pipelineId, pipelineRunId, apiHost) : GetLatestPipelineRun(pipelineId, apiHost);
49
+ apiHeaderFn = globalConfig.apiHeaderFn;
50
+ api = pipelineRunId ? GetPipelineRun(pipelineId, pipelineRunId, apiHeaderFn) : GetLatestPipelineRun(pipelineId, apiHeaderFn);
51
51
  api.then(function (res) {
52
52
  setLoading(false);
53
53
  setInstance(res);
@@ -6,5 +6,7 @@ declare const ConfigContext: import("react").Context<{
6
6
  scan: string;
7
7
  appstack: string;
8
8
  };
9
+ headers: {};
10
+ apiHeaderFn: () => void;
9
11
  }>;
10
12
  export default ConfigContext;
@@ -8,6 +8,9 @@ var ConfigContext = /*#__PURE__*/createContext({
8
8
  scan: '',
9
9
  // 扫描报告
10
10
  appstack: '' // 部署单链接
11
- }
11
+ },
12
+ headers: {},
13
+ // private
14
+ apiHeaderFn: function apiHeaderFn() {}
12
15
  });
13
16
  export default ConfigContext;
package/es/index.js CHANGED
@@ -24,6 +24,7 @@ import { locale } from "./utils";
24
24
  import enUS from '@teamix/ui/locale/en-us';
25
25
  import zhCN from '@teamix/ui/locale/zh-cn';
26
26
  import AsyncDetail from "./pages/detailSwitch";
27
+ import { flowCurryApi, getFlowDataApi } from "./utils/api";
27
28
  moment.locale('zh-cn');
28
29
  dayjs.locale(['en', 'en_US'].includes(intl.getLang()) ? 'en' : 'zh-cn');
29
30
 
@@ -85,12 +86,19 @@ var App = function App(props) {
85
86
  pipelineRunId = props.pipelineRunId,
86
87
  displayConfig = props.displayConfig,
87
88
  _props$replaceLinks = props.replaceLinks,
88
- replaceLinks = _props$replaceLinks === void 0 ? {} : _props$replaceLinks;
89
+ replaceLinks = _props$replaceLinks === void 0 ? {} : _props$replaceLinks,
90
+ headers = props.headers;
91
+ var apiHeaderFn = getFlowDataApi;
92
+ if (replaceLinks.api && headers) {
93
+ apiHeaderFn = flowCurryApi(replaceLinks.api, headers);
94
+ }
89
95
  return /*#__PURE__*/React.createElement(ConfigProvider, {
90
96
  locale: isEn ? enUS : zhCN
91
97
  }, /*#__PURE__*/React.createElement(ConfigContext.Provider, {
92
98
  value: {
93
- replaceLinks: replaceLinks
99
+ replaceLinks: replaceLinks,
100
+ headers: headers,
101
+ apiHeaderFn: apiHeaderFn
94
102
  }
95
103
  }, /*#__PURE__*/React.createElement("div", {
96
104
  className: "container"
@@ -1,45 +1,46 @@
1
1
  export declare const getFlowDataApi: (data: any, host?: string) => Promise<any>;
2
- export declare const GetLatestPipelineRun: (pipelineId: any, host: any) => Promise<any>;
3
- export declare const GetPipelineRun: (pipelineId: any, pipelineRunId: any, host: any) => Promise<any>;
2
+ export declare const flowCurryApi: (host?: string, headers?: Record<string, any>) => (data: any) => Promise<any>;
3
+ export declare const GetLatestPipelineRun: (pipelineId: any, apiHeaderFn: any) => any;
4
+ export declare const GetPipelineRun: (pipelineId: any, pipelineRunId: any, apiHeaderFn: any) => any;
4
5
  export declare const GetPipelineLogOrigin: ({ pipelineId, pipelineRunId, jobId, stepIndex, buildId }: {
5
6
  pipelineId: any;
6
7
  pipelineRunId: any;
7
8
  jobId: any;
8
9
  stepIndex: any;
9
10
  buildId: any;
10
- }, host: any) => Promise<any>;
11
- export declare const GetPipelineJobSteps: (pipelineId: any, pipelineRunId: any, jobId: any, host: any) => Promise<any>;
12
- export declare const GetPipelineJobStepLog: ({ pipelineId, pipelineRunId, jobId, buildId, stepIndex, offset, host, }: {
11
+ }, apiHeaderFn: any) => any;
12
+ export declare const GetPipelineJobSteps: (pipelineId: any, pipelineRunId: any, jobId: any, dataApi: any) => any;
13
+ export declare const GetPipelineJobStepLog: ({ pipelineId, pipelineRunId, jobId, buildId, stepIndex, offset, apiHeaderFn, }: {
13
14
  pipelineId: any;
14
15
  pipelineRunId: any;
15
16
  jobId: any;
16
17
  buildId: any;
17
18
  stepIndex: any;
18
19
  offset: any;
19
- host: any;
20
- }) => Promise<any>;
21
- export declare const RetryPipelineJobRun: ({ pipelineId, pipelineRunId, jobId, host }: {
20
+ apiHeaderFn: any;
21
+ }) => any;
22
+ export declare const RetryPipelineJobRun: ({ pipelineId, pipelineRunId, jobId, apiHeaderFn, }: {
22
23
  pipelineId: any;
23
24
  pipelineRunId: any;
24
25
  jobId: any;
25
- host: any;
26
- }) => Promise<any>;
27
- export declare const SkipPipelineJobRun: ({ pipelineId, pipelineRunId, jobId, host }: {
26
+ apiHeaderFn: any;
27
+ }) => any;
28
+ export declare const SkipPipelineJobRun: ({ pipelineId, pipelineRunId, jobId, apiHeaderFn, }: {
28
29
  pipelineId: any;
29
30
  pipelineRunId: any;
30
31
  jobId: any;
31
- host: any;
32
- }) => Promise<any>;
33
- export declare const StopPipelineJobRun: ({ pipelineId, pipelineRunId, jobId, host }: {
32
+ apiHeaderFn: any;
33
+ }) => any;
34
+ export declare const StopPipelineJobRun: ({ pipelineId, pipelineRunId, jobId, apiHeaderFn, }: {
34
35
  pipelineId: any;
35
36
  pipelineRunId: any;
36
37
  jobId: any;
37
- host: any;
38
- }) => Promise<any>;
39
- export declare const StartPipelineJobRun: ({ pipelineId, pipelineRunId, jobId, host }: {
38
+ apiHeaderFn: any;
39
+ }) => any;
40
+ export declare const StartPipelineJobRun: ({ pipelineId, pipelineRunId, jobId, apiHeaderFn, }: {
40
41
  pipelineId: any;
41
42
  pipelineRunId: any;
42
43
  jobId: any;
43
- host: any;
44
- }) => Promise<any>;
44
+ apiHeaderFn: any;
45
+ }) => any;
45
46
  export declare const callApiAndRefresh: (apiFunc: any, params: any, onRefresh: any, setLoading: any, setDisabled: any, name: any) => void;
@@ -32,9 +32,37 @@ export var getFlowDataApi = /*#__PURE__*/function () {
32
32
  return _ref.apply(this, arguments);
33
33
  };
34
34
  }();
35
+ export var flowCurryApi = function flowCurryApi(host, headers) {
36
+ return /*#__PURE__*/function () {
37
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
38
+ var res;
39
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
40
+ while (1) switch (_context2.prev = _context2.next) {
41
+ case 0:
42
+ _context2.next = 2;
43
+ return request({
44
+ method: 'POST',
45
+ url: host ? "" + host + apiHost : apiHost,
46
+ data: data,
47
+ headers: headers
48
+ });
49
+ case 2:
50
+ res = _context2.sent;
51
+ return _context2.abrupt("return", res.data);
52
+ case 4:
53
+ case "end":
54
+ return _context2.stop();
55
+ }
56
+ }, _callee2);
57
+ }));
58
+ return function (_x3) {
59
+ return _ref2.apply(this, arguments);
60
+ };
61
+ }();
62
+ };
35
63
 
36
64
  // 查询流水线最新运行
37
- export var GetLatestPipelineRun = function GetLatestPipelineRun(pipelineId, host) {
65
+ export var GetLatestPipelineRun = function GetLatestPipelineRun(pipelineId, apiHeaderFn) {
38
66
  var data = {
39
67
  action: 'GetLatestPipelineRun',
40
68
  method: 'GET',
@@ -43,11 +71,11 @@ export var GetLatestPipelineRun = function GetLatestPipelineRun(pipelineId, host
43
71
  pipelineId: pipelineId
44
72
  }
45
73
  };
46
- return getFlowDataApi(data, host);
74
+ return apiHeaderFn(data);
47
75
  };
48
76
 
49
77
  // 查询流水线运行历史
50
- export var GetPipelineRun = function GetPipelineRun(pipelineId, pipelineRunId, host) {
78
+ export var GetPipelineRun = function GetPipelineRun(pipelineId, pipelineRunId, apiHeaderFn) {
51
79
  var data = {
52
80
  action: 'GetPipelineRun',
53
81
  method: 'GET',
@@ -57,16 +85,16 @@ export var GetPipelineRun = function GetPipelineRun(pipelineId, pipelineRunId, h
57
85
  pipelineRunId: pipelineRunId
58
86
  }
59
87
  };
60
- return getFlowDataApi(data, host);
88
+ return apiHeaderFn(data);
61
89
  };
62
90
 
63
91
  // 查看原始日志
64
- export var GetPipelineLogOrigin = function GetPipelineLogOrigin(_ref2, host) {
65
- var pipelineId = _ref2.pipelineId,
66
- pipelineRunId = _ref2.pipelineRunId,
67
- jobId = _ref2.jobId,
68
- stepIndex = _ref2.stepIndex,
69
- buildId = _ref2.buildId;
92
+ export var GetPipelineLogOrigin = function GetPipelineLogOrigin(_ref3, apiHeaderFn) {
93
+ var pipelineId = _ref3.pipelineId,
94
+ pipelineRunId = _ref3.pipelineRunId,
95
+ jobId = _ref3.jobId,
96
+ stepIndex = _ref3.stepIndex,
97
+ buildId = _ref3.buildId;
70
98
  var data = {
71
99
  action: 'GetPipelineJobStepLogUrl',
72
100
  method: 'GET',
@@ -81,12 +109,12 @@ export var GetPipelineLogOrigin = function GetPipelineLogOrigin(_ref2, host) {
81
109
  buildId: buildId
82
110
  }
83
111
  };
84
- return getFlowDataApi(data, host);
112
+ return apiHeaderFn(data);
85
113
  };
86
114
 
87
115
  // 查询任务步骤列表
88
116
 
89
- export var GetPipelineJobSteps = function GetPipelineJobSteps(pipelineId, pipelineRunId, jobId, host) {
117
+ export var GetPipelineJobSteps = function GetPipelineJobSteps(pipelineId, pipelineRunId, jobId, dataApi) {
90
118
  var data = {
91
119
  action: 'GetPipelineJobSteps',
92
120
  method: 'GET',
@@ -97,19 +125,19 @@ export var GetPipelineJobSteps = function GetPipelineJobSteps(pipelineId, pipeli
97
125
  jobId: jobId
98
126
  }
99
127
  };
100
- return getFlowDataApi(data, host);
128
+ return dataApi(data);
101
129
  };
102
130
 
103
131
  // 查询任务步骤日志
104
132
 
105
- export var GetPipelineJobStepLog = function GetPipelineJobStepLog(_ref3) {
106
- var pipelineId = _ref3.pipelineId,
107
- pipelineRunId = _ref3.pipelineRunId,
108
- jobId = _ref3.jobId,
109
- buildId = _ref3.buildId,
110
- stepIndex = _ref3.stepIndex,
111
- offset = _ref3.offset,
112
- host = _ref3.host;
133
+ export var GetPipelineJobStepLog = function GetPipelineJobStepLog(_ref4) {
134
+ var pipelineId = _ref4.pipelineId,
135
+ pipelineRunId = _ref4.pipelineRunId,
136
+ jobId = _ref4.jobId,
137
+ buildId = _ref4.buildId,
138
+ stepIndex = _ref4.stepIndex,
139
+ offset = _ref4.offset,
140
+ apiHeaderFn = _ref4.apiHeaderFn;
113
141
  var data = {
114
142
  action: 'GetPipelineJobStepLog',
115
143
  method: 'GET',
@@ -130,15 +158,15 @@ export var GetPipelineJobStepLog = function GetPipelineJobStepLog(_ref3) {
130
158
  buildId: buildId
131
159
  }
132
160
  };
133
- return getFlowDataApi(data, host);
161
+ return apiHeaderFn(data);
134
162
  };
135
163
 
136
164
  // 重试任务
137
- export var RetryPipelineJobRun = function RetryPipelineJobRun(_ref4) {
138
- var pipelineId = _ref4.pipelineId,
139
- pipelineRunId = _ref4.pipelineRunId,
140
- jobId = _ref4.jobId,
141
- host = _ref4.host;
165
+ export var RetryPipelineJobRun = function RetryPipelineJobRun(_ref5) {
166
+ var pipelineId = _ref5.pipelineId,
167
+ pipelineRunId = _ref5.pipelineRunId,
168
+ jobId = _ref5.jobId,
169
+ apiHeaderFn = _ref5.apiHeaderFn;
142
170
  var data = {
143
171
  action: 'RetryPipelineJobRun',
144
172
  method: 'PUT',
@@ -149,15 +177,15 @@ export var RetryPipelineJobRun = function RetryPipelineJobRun(_ref4) {
149
177
  jobId: jobId
150
178
  }
151
179
  };
152
- return getFlowDataApi(data, host);
180
+ return apiHeaderFn(data);
153
181
  };
154
182
 
155
183
  // 跳过任务
156
- export var SkipPipelineJobRun = function SkipPipelineJobRun(_ref5) {
157
- var pipelineId = _ref5.pipelineId,
158
- pipelineRunId = _ref5.pipelineRunId,
159
- jobId = _ref5.jobId,
160
- host = _ref5.host;
184
+ export var SkipPipelineJobRun = function SkipPipelineJobRun(_ref6) {
185
+ var pipelineId = _ref6.pipelineId,
186
+ pipelineRunId = _ref6.pipelineRunId,
187
+ jobId = _ref6.jobId,
188
+ apiHeaderFn = _ref6.apiHeaderFn;
161
189
  var data = {
162
190
  action: 'SkipPipelineJobRun',
163
191
  method: 'PUT',
@@ -168,15 +196,15 @@ export var SkipPipelineJobRun = function SkipPipelineJobRun(_ref5) {
168
196
  jobId: jobId
169
197
  }
170
198
  };
171
- return getFlowDataApi(data, host);
199
+ return apiHeaderFn(data);
172
200
  };
173
201
 
174
202
  // 取消任务
175
- export var StopPipelineJobRun = function StopPipelineJobRun(_ref6) {
176
- var pipelineId = _ref6.pipelineId,
177
- pipelineRunId = _ref6.pipelineRunId,
178
- jobId = _ref6.jobId,
179
- host = _ref6.host;
203
+ export var StopPipelineJobRun = function StopPipelineJobRun(_ref7) {
204
+ var pipelineId = _ref7.pipelineId,
205
+ pipelineRunId = _ref7.pipelineRunId,
206
+ jobId = _ref7.jobId,
207
+ apiHeaderFn = _ref7.apiHeaderFn;
180
208
  var data = {
181
209
  action: 'StopPipelineJobRun',
182
210
  method: 'PUT',
@@ -187,15 +215,15 @@ export var StopPipelineJobRun = function StopPipelineJobRun(_ref6) {
187
215
  jobId: jobId
188
216
  }
189
217
  };
190
- return getFlowDataApi(data, host);
218
+ return apiHeaderFn(data);
191
219
  };
192
220
 
193
221
  // 运行任务
194
- export var StartPipelineJobRun = function StartPipelineJobRun(_ref7) {
195
- var pipelineId = _ref7.pipelineId,
196
- pipelineRunId = _ref7.pipelineRunId,
197
- jobId = _ref7.jobId,
198
- host = _ref7.host;
222
+ export var StartPipelineJobRun = function StartPipelineJobRun(_ref8) {
223
+ var pipelineId = _ref8.pipelineId,
224
+ pipelineRunId = _ref8.pipelineRunId,
225
+ jobId = _ref8.jobId,
226
+ apiHeaderFn = _ref8.apiHeaderFn;
199
227
  var data = {
200
228
  action: 'ExecutePipelineJobRun',
201
229
  method: 'POST',
@@ -206,7 +234,7 @@ export var StartPipelineJobRun = function StartPipelineJobRun(_ref7) {
206
234
  jobId: jobId
207
235
  }
208
236
  };
209
- return getFlowDataApi(data, host);
237
+ return apiHeaderFn(data);
210
238
  };
211
239
  export var callApiAndRefresh = function callApiAndRefresh(apiFunc, params, onRefresh, setLoading, setDisabled, name) {
212
240
  apiFunc(params).then(function (success) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devops-flow/devops-flow-pipeline-detail",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "description": "flow 流水线详情",
5
5
  "medusaName": "rdc-tb-cd-assets",
6
6
  "main": "dist/PipelineFlowDetail.js",