@devops-flow/devops-flow-pipeline-detail 0.0.45 → 0.0.46

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.
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
4
4
  var _excluded = ["loading", "onBuildNumberChange", "onPipelineStatusChanged", "haveHistoryPip"];
5
5
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
- import React, { useEffect, useState } from 'react';
6
+ import React, { useContext, useEffect, useState } from 'react';
7
7
  import { Loading } from '@teamix/ui';
8
8
  import imgSrc from "../../../assets/img-src";
9
9
  import intl from "../../../locale";
@@ -12,6 +12,7 @@ import { GetLatestPipelineRun, GetPipelineRun } from "../../../utils/api";
12
12
  import PipelineInstance from "../../common/teambition/pipeline-instance-new";
13
13
  import RunPipelineButton from "../../common/teambition/run-pipeline-btn";
14
14
  import MessagePage from "../../common/teambition/message-page";
15
+ import ConfigContext from "../../../contexts/config";
15
16
  var Current = function Current(_ref) {
16
17
  var parentLoading = _ref.loading,
17
18
  onBuildNumberChange = _ref.onBuildNumberChange,
@@ -33,6 +34,7 @@ var Current = function Current(_ref) {
33
34
  var _useState4 = useState(false),
34
35
  canEditPipeline = _useState4[0],
35
36
  setCanEditPipeline = _useState4[1];
37
+ var globalConfig = useContext(ConfigContext);
36
38
  useEffect(function () {
37
39
  return function () {
38
40
  return onBuildNumberChange === null || onBuildNumberChange === void 0 ? void 0 : onBuildNumberChange(undefined, false);
@@ -40,18 +42,19 @@ var Current = function Current(_ref) {
40
42
  }, []);
41
43
  var getLatestPipeline = /*#__PURE__*/function () {
42
44
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
43
- var api;
45
+ var apiHost, api;
44
46
  return _regeneratorRuntime.wrap(function _callee$(_context) {
45
47
  while (1) switch (_context.prev = _context.next) {
46
48
  case 0:
47
- api = pipelineRunId ? GetPipelineRun(pipelineId, pipelineRunId) : GetLatestPipelineRun(pipelineId);
49
+ apiHost = globalConfig.apiHost;
50
+ api = pipelineRunId ? GetPipelineRun(pipelineId, pipelineRunId, apiHost) : GetLatestPipelineRun(pipelineId, apiHost);
48
51
  api.then(function (res) {
49
52
  setLoading(false);
50
53
  setInstance(res);
51
54
  })["catch"](function () {
52
55
  setLoading(false);
53
56
  });
54
- case 2:
57
+ case 3:
55
58
  case "end":
56
59
  return _context.stop();
57
60
  }
@@ -0,0 +1,5 @@
1
+ /// <reference types="react" />
2
+ declare const ConfigContext: import("react").Context<{
3
+ apiHost: any;
4
+ }>;
5
+ export default ConfigContext;
@@ -0,0 +1,5 @@
1
+ import { createContext } from 'react';
2
+ var ConfigContext = /*#__PURE__*/createContext({
3
+ apiHost: null
4
+ });
5
+ export default ConfigContext;
package/es/index.js CHANGED
@@ -19,6 +19,7 @@ import 'dayjs/locale/zh-cn';
19
19
  import '@alife/yunxiao-member/dist/YunxiaoMember.css?fusionPrefix=.next-';
20
20
  import '@teamix/pop-confirm/dist/TeamixPopConfirm.css?fusionPrefix=.next-';
21
21
  import '@alife/yunxiao-table/dist/YunxaioTable.css?fusionPrefix=.next-';
22
+ import ConfigContext from "./contexts/config";
22
23
  import { locale } from "./utils";
23
24
  import enUS from '@teamix/ui/locale/en-us';
24
25
  import zhCN from '@teamix/ui/locale/zh-cn';
@@ -74,15 +75,20 @@ var lang = locale || window.FORCE && window.FORCE.locale || 'zh_CN';
74
75
  var isEn = lang === 'en_US';
75
76
  var App = function App(props) {
76
77
  var pipelineId = props.pipelineId,
77
- pipelineRunId = props.pipelineRunId;
78
+ pipelineRunId = props.pipelineRunId,
79
+ apiHost = props.apiHost;
78
80
  return /*#__PURE__*/React.createElement(ConfigProvider, {
79
81
  locale: isEn ? enUS : zhCN
82
+ }, /*#__PURE__*/React.createElement(ConfigContext.Provider, {
83
+ value: {
84
+ apiHost: apiHost
85
+ }
80
86
  }, /*#__PURE__*/React.createElement("div", {
81
87
  className: "container"
82
88
  }, /*#__PURE__*/React.createElement(AsyncDetail, {
83
89
  pipelineId: pipelineId,
84
90
  pipelineRunId: pipelineRunId,
85
91
  location: window.location
86
- })));
92
+ }))));
87
93
  };
88
94
  export default App;
@@ -1,6 +1,7 @@
1
- export declare const getFlowDataApi: (data: any) => Promise<any>;
2
- export declare const GetLatestPipelineRun: (pipelineId: any) => Promise<any>;
3
- export declare const GetPipelineRun: (pipelineId: any, pipelineRunId: any) => Promise<any>;
1
+ export declare const apiHost = "/devops/data/api.json";
2
+ export declare const getFlowDataApi: (data: any, host?: string) => Promise<any>;
3
+ export declare const GetLatestPipelineRun: (pipelineId: any, host: any) => Promise<any>;
4
+ export declare const GetPipelineRun: (pipelineId: any, pipelineRunId: any, host: any) => Promise<any>;
4
5
  export declare const GetPipelineJobSteps: (pipelineId: any, pipelineRunId: any, jobId: any) => Promise<any>;
5
6
  export declare const GetPipelineJobStepLog: ({ pipelineId, pipelineRunId, jobId, buildId, stepIndex, offset }: {
6
7
  pipelineId: any;
@@ -3,12 +3,12 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { Message } from '@teamix/ui';
4
4
  import axios from 'axios';
5
5
  import intl from "../../locale";
6
- var apiHost = '/devops/data/api.json';
6
+ export var apiHost = '/devops/data/api.json';
7
7
  // 默认拉取的日志行数
8
8
  var DEFAULT_LIMIT = 1000;
9
9
  var request = axios;
10
10
  export var getFlowDataApi = /*#__PURE__*/function () {
11
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
11
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(data, host) {
12
12
  var res;
13
13
  return _regeneratorRuntime.wrap(function _callee$(_context) {
14
14
  while (1) switch (_context.prev = _context.next) {
@@ -16,7 +16,7 @@ export var getFlowDataApi = /*#__PURE__*/function () {
16
16
  _context.next = 2;
17
17
  return request({
18
18
  method: 'POST',
19
- url: apiHost,
19
+ url: "" + host + apiHost,
20
20
  data: data
21
21
  });
22
22
  case 2:
@@ -28,13 +28,13 @@ export var getFlowDataApi = /*#__PURE__*/function () {
28
28
  }
29
29
  }, _callee);
30
30
  }));
31
- return function getFlowDataApi(_x) {
31
+ return function getFlowDataApi(_x, _x2) {
32
32
  return _ref.apply(this, arguments);
33
33
  };
34
34
  }();
35
35
 
36
36
  // 查询流水线最新运行
37
- export var GetLatestPipelineRun = function GetLatestPipelineRun(pipelineId) {
37
+ export var GetLatestPipelineRun = function GetLatestPipelineRun(pipelineId, host) {
38
38
  var data = {
39
39
  action: 'GetLatestPipelineRun',
40
40
  method: 'GET',
@@ -43,11 +43,11 @@ export var GetLatestPipelineRun = function GetLatestPipelineRun(pipelineId) {
43
43
  pipelineId: pipelineId
44
44
  }
45
45
  };
46
- return getFlowDataApi(data);
46
+ return getFlowDataApi(data, host);
47
47
  };
48
48
 
49
49
  // 查询流水线运行历史
50
- export var GetPipelineRun = function GetPipelineRun(pipelineId, pipelineRunId) {
50
+ export var GetPipelineRun = function GetPipelineRun(pipelineId, pipelineRunId, host) {
51
51
  var data = {
52
52
  action: 'GetPipelineRun',
53
53
  method: 'GET',
@@ -57,7 +57,7 @@ export var GetPipelineRun = function GetPipelineRun(pipelineId, pipelineRunId) {
57
57
  pipelineRunId: pipelineRunId
58
58
  }
59
59
  };
60
- return getFlowDataApi(data);
60
+ return getFlowDataApi(data, host);
61
61
  };
62
62
 
63
63
  // 查询任务步骤列表
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devops-flow/devops-flow-pipeline-detail",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "description": "flow 流水线详情",
5
5
  "medusaName": "rdc-tb-cd-assets",
6
6
  "main": "dist/PipelineFlowDetail.js",
@@ -47,5 +47,6 @@
47
47
  "peerDependencies": {
48
48
  "react": "^18.0.0",
49
49
  "react-dom": "^18.0.0"
50
- }
50
+ },
51
+ "homepage": "https://unpkg.com/@devops-flow/devops-flow-pipeline-detail@0.0.46/build/index.html"
51
52
  }