@devtron-labs/devtron-fe-common-lib 0.0.45-beta-16 → 0.0.45-beta-18
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/dist/Common/AddCDButton/AddCDButton.d.ts +3 -0
- package/dist/Common/AddCDButton/index.d.ts +2 -0
- package/dist/Common/AddCDButton/types.d.ts +22 -0
- package/dist/Common/AddCDButton/utils.d.ts +2 -0
- package/dist/Common/Types.d.ts +16 -0
- package/dist/Common/index.d.ts +1 -0
- package/dist/index.js +37 -0
- package/package.json +1 -1
- package/src/Common/AddCDButton/AddCDButton.tsx +44 -0
- package/src/Common/AddCDButton/index.ts +2 -0
- package/src/Common/AddCDButton/types.ts +33 -0
- package/src/Common/AddCDButton/utils.tsx +35 -0
- package/src/Common/Types.ts +19 -0
- package/src/Common/index.ts +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AddCDPositions, AddPipelineType, EdgeEndNodeType, EdgeNodeType, Point } from '../Types';
|
|
2
|
+
export interface AddCDButtonProps {
|
|
3
|
+
position: AddCDPositions;
|
|
4
|
+
addCDButtons: AddCDPositions[];
|
|
5
|
+
endNode: Point & EdgeEndNodeType;
|
|
6
|
+
startNode: Point & EdgeNodeType;
|
|
7
|
+
handleAddCD: (position: AddCDPositions) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface HandleAddCD {
|
|
10
|
+
position: AddCDPositions;
|
|
11
|
+
handleCDSelect: (workflowId: number | string, ciPipelineId: number | string, parentPipelineType: string, parentPipelineId: number | string, isWebhookCD?: boolean, childPipelineId?: number | string, addType?: AddPipelineType) => void;
|
|
12
|
+
startNode: EdgeNodeType;
|
|
13
|
+
endNode: EdgeEndNodeType;
|
|
14
|
+
workflowId: number | string;
|
|
15
|
+
ciPipelineId: number | string;
|
|
16
|
+
isWebhookCD: boolean;
|
|
17
|
+
isParallelEdge: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface GetPipelineType {
|
|
20
|
+
isWebhookCD: boolean;
|
|
21
|
+
startNode: EdgeNodeType;
|
|
22
|
+
}
|
package/dist/Common/Types.d.ts
CHANGED
|
@@ -322,6 +322,8 @@ export interface CommonNodeAttr {
|
|
|
322
322
|
};
|
|
323
323
|
appReleaseTagNames?: string[];
|
|
324
324
|
tagsEditable?: boolean;
|
|
325
|
+
deploymentAppCreated?: boolean;
|
|
326
|
+
isLast?: boolean;
|
|
325
327
|
}
|
|
326
328
|
export declare enum DeploymentAppTypes {
|
|
327
329
|
HELM = "helm",
|
|
@@ -589,4 +591,18 @@ export declare enum AddPipelineType {
|
|
|
589
591
|
SEQUENTIAL = "SEQUENTIAL",
|
|
590
592
|
PARALLEL = "PARALLEL"
|
|
591
593
|
}
|
|
594
|
+
export interface Point {
|
|
595
|
+
x: number;
|
|
596
|
+
y: number;
|
|
597
|
+
}
|
|
598
|
+
export interface EdgeNodeType {
|
|
599
|
+
height: number;
|
|
600
|
+
width: number;
|
|
601
|
+
userApprovalConfig?: UserApprovalConfigType;
|
|
602
|
+
type?: any;
|
|
603
|
+
id?: number | string;
|
|
604
|
+
}
|
|
605
|
+
export interface EdgeEndNodeType extends EdgeNodeType {
|
|
606
|
+
userApprovalConfig?: UserApprovalConfigType;
|
|
607
|
+
}
|
|
592
608
|
export {};
|
package/dist/Common/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -26665,6 +26665,42 @@ function DevtronProgressing(_a) {
|
|
|
26665
26665
|
return (jsxRuntime.jsx("div", __assign({ className: parentClasses ? parentClasses : '' }, { children: jsxRuntime.jsx(SvgIcRotateDevtron, { className: classes ? classes : '' }) })));
|
|
26666
26666
|
}
|
|
26667
26667
|
|
|
26668
|
+
function AddCDButton(_a) {
|
|
26669
|
+
var position = _a.position, addCDButtons = _a.addCDButtons, endNode = _a.endNode, startNode = _a.startNode, handleAddCD = _a.handleAddCD;
|
|
26670
|
+
var referenceNode = position === exports.AddCDPositions.RIGHT ? endNode : startNode;
|
|
26671
|
+
var handleAddCDClick = function () {
|
|
26672
|
+
handleAddCD(position);
|
|
26673
|
+
};
|
|
26674
|
+
if (addCDButtons === null || addCDButtons === void 0 ? void 0 : addCDButtons.includes(position)) {
|
|
26675
|
+
return (jsxRuntime.jsxs("svg", __assign({ x: referenceNode.x + (position === exports.AddCDPositions.RIGHT ? -20 - 5 : referenceNode.width + 5),
|
|
26676
|
+
// Here 10 is the height of the button / 2
|
|
26677
|
+
y: referenceNode.y + referenceNode.height / 2 - 10, width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", "data-testid": "add-cd-to-".concat(position), onClick: handleAddCDClick }, { children: [jsxRuntime.jsx("rect", { width: "20", height: "20", rx: "10", fill: "#664BEE", className: "add-cd-edge-btn" }), jsxRuntime.jsx("path", { d: "M6.5 10H13.5M10 6.5V13.5", stroke: "white", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] })));
|
|
26678
|
+
}
|
|
26679
|
+
return null;
|
|
26680
|
+
}
|
|
26681
|
+
|
|
26682
|
+
var getPipelineType = function (_a) {
|
|
26683
|
+
var isWebhookCD = _a.isWebhookCD, startNode = _a.startNode;
|
|
26684
|
+
if (isWebhookCD) {
|
|
26685
|
+
return exports.PipelineType.WEBHOOK;
|
|
26686
|
+
}
|
|
26687
|
+
if (startNode.type === exports.WorkflowNodeType.CI) {
|
|
26688
|
+
return exports.PipelineType.CI_PIPELINE;
|
|
26689
|
+
}
|
|
26690
|
+
return exports.PipelineType.CD_PIPELINE;
|
|
26691
|
+
};
|
|
26692
|
+
var handleAddCD = function (_a) {
|
|
26693
|
+
var position = _a.position, handleCDSelect = _a.handleCDSelect, startNode = _a.startNode, endNode = _a.endNode, workflowId = _a.workflowId, ciPipelineId = _a.ciPipelineId, isWebhookCD = _a.isWebhookCD, isParallelEdge = _a.isParallelEdge;
|
|
26694
|
+
if (!handleCDSelect) {
|
|
26695
|
+
return;
|
|
26696
|
+
}
|
|
26697
|
+
var pipelineType = getPipelineType({ isWebhookCD: isWebhookCD, startNode: startNode });
|
|
26698
|
+
var addPipelineType = isParallelEdge && position === exports.AddCDPositions.RIGHT ? exports.AddPipelineType.PARALLEL : exports.AddPipelineType.SEQUENTIAL;
|
|
26699
|
+
var endNodeId = !isParallelEdge && position === exports.AddCDPositions.RIGHT ? endNode.id : null;
|
|
26700
|
+
handleCDSelect(workflowId, ciPipelineId, pipelineType, startNode.id, isWebhookCD, endNodeId, addPipelineType);
|
|
26701
|
+
};
|
|
26702
|
+
|
|
26703
|
+
exports.AddCDButton = AddCDButton;
|
|
26668
26704
|
exports.AppStatus = AppStatus;
|
|
26669
26705
|
exports.BreadCrumb = BreadCrumb;
|
|
26670
26706
|
exports.BreadcrumbStore = Store;
|
|
@@ -26755,6 +26791,7 @@ exports.getRedirectionProps = getRedirectionProps;
|
|
|
26755
26791
|
exports.getTeamListMin = getTeamListMin;
|
|
26756
26792
|
exports.getUrlWithSearchParams = getUrlWithSearchParams;
|
|
26757
26793
|
exports.getUserRole = getUserRole;
|
|
26794
|
+
exports.handleAddCD = handleAddCD;
|
|
26758
26795
|
exports.handleUTCTime = handleUTCTime;
|
|
26759
26796
|
exports.logExceptionToSentry = logExceptionToSentry;
|
|
26760
26797
|
exports.multiSelectStyles = multiSelectStyles;
|
package/package.json
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { AddCDButtonProps } from './types'
|
|
3
|
+
import { AddCDPositions } from '../Types'
|
|
4
|
+
|
|
5
|
+
export default function AddCDButton({
|
|
6
|
+
position,
|
|
7
|
+
addCDButtons,
|
|
8
|
+
endNode,
|
|
9
|
+
startNode,
|
|
10
|
+
handleAddCD,
|
|
11
|
+
}: Readonly<AddCDButtonProps>) {
|
|
12
|
+
const referenceNode = position === AddCDPositions.RIGHT ? endNode : startNode
|
|
13
|
+
const handleAddCDClick = () => {
|
|
14
|
+
handleAddCD(position)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (addCDButtons?.includes(position)) {
|
|
18
|
+
return (
|
|
19
|
+
<svg
|
|
20
|
+
x={referenceNode.x + (position === AddCDPositions.RIGHT ? -20 - 5 : referenceNode.width + 5)}
|
|
21
|
+
// Here 10 is the height of the button / 2
|
|
22
|
+
y={referenceNode.y + referenceNode.height / 2 - 10}
|
|
23
|
+
width="20"
|
|
24
|
+
height="20"
|
|
25
|
+
viewBox="0 0 20 20"
|
|
26
|
+
fill="none"
|
|
27
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
28
|
+
data-testid={`add-cd-to-${position}`}
|
|
29
|
+
onClick={handleAddCDClick}
|
|
30
|
+
>
|
|
31
|
+
<rect width="20" height="20" rx="10" fill="#664BEE" className="add-cd-edge-btn" />
|
|
32
|
+
<path
|
|
33
|
+
d="M6.5 10H13.5M10 6.5V13.5"
|
|
34
|
+
stroke="white"
|
|
35
|
+
strokeWidth="1.5"
|
|
36
|
+
strokeLinecap="round"
|
|
37
|
+
strokeLinejoin="round"
|
|
38
|
+
/>
|
|
39
|
+
</svg>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null
|
|
44
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AddCDPositions, AddPipelineType, EdgeEndNodeType, EdgeNodeType, Point } from '../Types'
|
|
2
|
+
|
|
3
|
+
export interface AddCDButtonProps {
|
|
4
|
+
position: AddCDPositions
|
|
5
|
+
addCDButtons: AddCDPositions[]
|
|
6
|
+
endNode: Point & EdgeEndNodeType
|
|
7
|
+
startNode: Point & EdgeNodeType
|
|
8
|
+
handleAddCD: (position: AddCDPositions) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface HandleAddCD {
|
|
12
|
+
position: AddCDPositions
|
|
13
|
+
handleCDSelect: (
|
|
14
|
+
workflowId: number | string,
|
|
15
|
+
ciPipelineId: number | string,
|
|
16
|
+
parentPipelineType: string,
|
|
17
|
+
parentPipelineId: number | string,
|
|
18
|
+
isWebhookCD?: boolean,
|
|
19
|
+
childPipelineId?: number | string,
|
|
20
|
+
addType?: AddPipelineType,
|
|
21
|
+
) => void
|
|
22
|
+
startNode: EdgeNodeType
|
|
23
|
+
endNode: EdgeEndNodeType
|
|
24
|
+
workflowId: number | string
|
|
25
|
+
ciPipelineId: number | string
|
|
26
|
+
isWebhookCD: boolean
|
|
27
|
+
isParallelEdge: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface GetPipelineType {
|
|
31
|
+
isWebhookCD: boolean
|
|
32
|
+
startNode: EdgeNodeType
|
|
33
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AddCDPositions, AddPipelineType, PipelineType, WorkflowNodeType } from '../Types'
|
|
2
|
+
import { HandleAddCD, GetPipelineType } from './types'
|
|
3
|
+
|
|
4
|
+
const getPipelineType = ({ isWebhookCD, startNode }: GetPipelineType) => {
|
|
5
|
+
if (isWebhookCD) {
|
|
6
|
+
return PipelineType.WEBHOOK
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (startNode.type === WorkflowNodeType.CI) {
|
|
10
|
+
return PipelineType.CI_PIPELINE
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return PipelineType.CD_PIPELINE
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const handleAddCD = ({
|
|
17
|
+
position,
|
|
18
|
+
handleCDSelect,
|
|
19
|
+
startNode,
|
|
20
|
+
endNode,
|
|
21
|
+
workflowId,
|
|
22
|
+
ciPipelineId,
|
|
23
|
+
isWebhookCD,
|
|
24
|
+
isParallelEdge,
|
|
25
|
+
}: HandleAddCD) => {
|
|
26
|
+
if (!handleCDSelect) {
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
const pipelineType = getPipelineType({ isWebhookCD, startNode })
|
|
30
|
+
const addPipelineType =
|
|
31
|
+
isParallelEdge && position === AddCDPositions.RIGHT ? AddPipelineType.PARALLEL : AddPipelineType.SEQUENTIAL
|
|
32
|
+
const endNodeId = !isParallelEdge && position === AddCDPositions.RIGHT ? endNode.id : null
|
|
33
|
+
|
|
34
|
+
handleCDSelect(workflowId, ciPipelineId, pipelineType, startNode.id, isWebhookCD, endNodeId, addPipelineType)
|
|
35
|
+
}
|
package/src/Common/Types.ts
CHANGED
|
@@ -354,6 +354,8 @@ export interface CommonNodeAttr {
|
|
|
354
354
|
}
|
|
355
355
|
appReleaseTagNames?: string[]
|
|
356
356
|
tagsEditable?: boolean
|
|
357
|
+
deploymentAppCreated?: boolean
|
|
358
|
+
isLast?: boolean
|
|
357
359
|
}
|
|
358
360
|
|
|
359
361
|
export enum DeploymentAppTypes {
|
|
@@ -654,3 +656,20 @@ export enum AddPipelineType {
|
|
|
654
656
|
SEQUENTIAL = 'SEQUENTIAL',
|
|
655
657
|
PARALLEL = 'PARALLEL',
|
|
656
658
|
}
|
|
659
|
+
|
|
660
|
+
export interface Point {
|
|
661
|
+
x: number
|
|
662
|
+
y: number
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
export interface EdgeNodeType {
|
|
666
|
+
height: number
|
|
667
|
+
width: number
|
|
668
|
+
userApprovalConfig?: UserApprovalConfigType
|
|
669
|
+
type?: any
|
|
670
|
+
id?: number | string
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
export interface EdgeEndNodeType extends EdgeNodeType {
|
|
674
|
+
userApprovalConfig?: UserApprovalConfigType
|
|
675
|
+
}
|
package/src/Common/index.ts
CHANGED