@devtron-labs/devtron-fe-common-lib 0.0.37-beta-2 → 0.0.37-beta-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.
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { AppStatusType } from './types';
3
+ export default function AppStatus({ appStatus, isDeploymentStatus, isJobView, isVirtualEnv, hideStatusMessage, }: AppStatusType): JSX.Element;
@@ -0,0 +1,51 @@
1
+ export declare const StatusConstants: {
2
+ NOT_DEPLOYED: {
3
+ noSpaceLower: string;
4
+ normalCase: string;
5
+ lowerCase: string;
6
+ };
7
+ APP_STATUS: {
8
+ noSpaceLower: string;
9
+ normalText: string;
10
+ };
11
+ PROJECT: {
12
+ pluralLower: string;
13
+ lowerCase: string;
14
+ };
15
+ CLUSTER: {
16
+ pluralLower: string;
17
+ lowerCase: string;
18
+ };
19
+ NAMESPACE: {
20
+ pluralLower: string;
21
+ lowerCase: string;
22
+ };
23
+ ENVIRONMENT: {
24
+ pluralLower: string;
25
+ lowerCase: string;
26
+ };
27
+ NOT_AVILABLE: {
28
+ normalCase: string;
29
+ };
30
+ };
31
+ export declare enum TIMELINE_STATUS {
32
+ DEPLOYMENT_INITIATED = "DEPLOYMENT_INITIATED",
33
+ GIT_COMMIT = "GIT_COMMIT",
34
+ GIT_COMMIT_FAILED = "GIT_COMMIT_FAILED",
35
+ KUBECTL_APPLY = "KUBECTL_APPLY",
36
+ KUBECTL_APPLY_STARTED = "KUBECTL_APPLY_STARTED",
37
+ KUBECTL_APPLY_SYNCED = "KUBECTL_APPLY_SYNCED",
38
+ HEALTHY = "HEALTHY",
39
+ APP_HEALTH = "APP_HEALTH",
40
+ DEPLOYMENT_FAILED = "FAILED",
41
+ FETCH_TIMED_OUT = "TIMED_OUT",
42
+ UNABLE_TO_FETCH_STATUS = "UNABLE_TO_FETCH_STATUS",
43
+ DEGRADED = "DEGRADED",
44
+ DEPLOYMENT_SUPERSEDED = "DEPLOYMENT_SUPERSEDED",
45
+ ABORTED = "ABORTED",
46
+ INPROGRESS = "INPROGRESS",
47
+ HELM_PACKAGE_GENERATED = "HELM_PACKAGE_GENERATED",
48
+ HELM_MANIFEST_PUSHED_TO_HELM_REPO = "HELM_MANIFEST_PUSHED_TO_HELM_REPO",
49
+ HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED = "HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED"
50
+ }
51
+ export declare const YET_TO_RUN = "Yet to run";
@@ -0,0 +1 @@
1
+ export { default as AppStatus } from './AppStatus';
@@ -0,0 +1,12 @@
1
+ export interface AppStatusType {
2
+ appStatus: string;
3
+ isDeploymentStatus?: boolean;
4
+ isJobView?: boolean;
5
+ isVirtualEnv?: boolean;
6
+ /**
7
+ * Hide the status message if true
8
+ *
9
+ * @default false
10
+ */
11
+ hideStatusMessage?: boolean;
12
+ }
@@ -0,0 +1 @@
1
+ export declare const triggerStatus: (triggerDetailStatus: string) => string;
@@ -51,4 +51,5 @@ export declare const closeOnEscKeyPressed: (e: any, actionClose: () => void) =>
51
51
  */
52
52
  export declare function copyToClipboard(str: any, callback?: typeof noop): void;
53
53
  export declare function useAsync<T>(func: (...rest: any[]) => Promise<T>, dependencyArray?: any[], shouldRun?: boolean, options?: AsyncOptions): [boolean, T, any | null, () => void, React.Dispatch<any>, any[]];
54
+ export declare const processDeployedTime: (lastDeployed: any, isArgoInstalled: any) => string;
54
55
  export {};
@@ -228,9 +228,6 @@ export interface CDMaterialType {
228
228
  imageReleaseTags?: ReleaseTag[];
229
229
  artifactStatus?: string;
230
230
  filterState: FilterStates;
231
- registryType?: string;
232
- imagePath?: string;
233
- registryName?: string;
234
231
  }
235
232
  export interface CommonNodeAttr {
236
233
  connectingCiPipelineId?: number;
@@ -39,3 +39,4 @@ export { default as DebouncedSearch } from './DebouncedSearch/DebouncedSearch';
39
39
  export { default as Grid } from './Grid/Grid';
40
40
  export { default as ClipboardButton } from './ClipboardButton/ClipboardButton';
41
41
  export * from './Hooks';
42
+ export { AppStatus } from './AppStatus';
package/dist/index.js CHANGED
@@ -10220,7 +10220,15 @@ function useAsync(func, dependencyArray, shouldRun, options) {
10220
10220
  }
10221
10221
  };
10222
10222
  return [state.loading, state.result, state.error, reload, setResult, state.dependencies];
10223
- }
10223
+ }
10224
+ var processDeployedTime = function (lastDeployed, isArgoInstalled) {
10225
+ if (lastDeployed) {
10226
+ return handleUTCTime(lastDeployed, true);
10227
+ }
10228
+ else {
10229
+ return isArgoInstalled ? '' : 'Not deployed';
10230
+ }
10231
+ };
10224
10232
 
10225
10233
  function Progressing(_a) {
10226
10234
  var pageLoader = _a.pageLoader, size = _a.size, theme = _a.theme, styles = _a.styles, fillColor = _a.fillColor;
@@ -23608,6 +23616,101 @@ var useSuperAdmin = function () {
23608
23616
  return { isSuperAdmin: isSuperAdmin };
23609
23617
  };
23610
23618
 
23619
+ var StatusConstants = {
23620
+ NOT_DEPLOYED: {
23621
+ noSpaceLower: 'notdeployed',
23622
+ normalCase: 'Not deployed',
23623
+ lowerCase: 'not-deployed',
23624
+ },
23625
+ APP_STATUS: {
23626
+ noSpaceLower: 'appStatus',
23627
+ normalText: 'App status',
23628
+ },
23629
+ PROJECT: {
23630
+ pluralLower: 'projects',
23631
+ lowerCase: 'project',
23632
+ },
23633
+ CLUSTER: {
23634
+ pluralLower: 'clusters',
23635
+ lowerCase: 'cluster',
23636
+ },
23637
+ NAMESPACE: {
23638
+ pluralLower: 'namespaces',
23639
+ lowerCase: 'namespace',
23640
+ },
23641
+ ENVIRONMENT: {
23642
+ pluralLower: 'environments',
23643
+ lowerCase: 'environment',
23644
+ },
23645
+ NOT_AVILABLE: {
23646
+ normalCase: 'Not available',
23647
+ },
23648
+ };
23649
+ var TIMELINE_STATUS;
23650
+ (function (TIMELINE_STATUS) {
23651
+ TIMELINE_STATUS["DEPLOYMENT_INITIATED"] = "DEPLOYMENT_INITIATED";
23652
+ TIMELINE_STATUS["GIT_COMMIT"] = "GIT_COMMIT";
23653
+ TIMELINE_STATUS["GIT_COMMIT_FAILED"] = "GIT_COMMIT_FAILED";
23654
+ TIMELINE_STATUS["KUBECTL_APPLY"] = "KUBECTL_APPLY";
23655
+ TIMELINE_STATUS["KUBECTL_APPLY_STARTED"] = "KUBECTL_APPLY_STARTED";
23656
+ TIMELINE_STATUS["KUBECTL_APPLY_SYNCED"] = "KUBECTL_APPLY_SYNCED";
23657
+ TIMELINE_STATUS["HEALTHY"] = "HEALTHY";
23658
+ TIMELINE_STATUS["APP_HEALTH"] = "APP_HEALTH";
23659
+ TIMELINE_STATUS["DEPLOYMENT_FAILED"] = "FAILED";
23660
+ TIMELINE_STATUS["FETCH_TIMED_OUT"] = "TIMED_OUT";
23661
+ TIMELINE_STATUS["UNABLE_TO_FETCH_STATUS"] = "UNABLE_TO_FETCH_STATUS";
23662
+ TIMELINE_STATUS["DEGRADED"] = "DEGRADED";
23663
+ TIMELINE_STATUS["DEPLOYMENT_SUPERSEDED"] = "DEPLOYMENT_SUPERSEDED";
23664
+ TIMELINE_STATUS["ABORTED"] = "ABORTED";
23665
+ TIMELINE_STATUS["INPROGRESS"] = "INPROGRESS";
23666
+ TIMELINE_STATUS["HELM_PACKAGE_GENERATED"] = "HELM_PACKAGE_GENERATED";
23667
+ TIMELINE_STATUS["HELM_MANIFEST_PUSHED_TO_HELM_REPO"] = "HELM_MANIFEST_PUSHED_TO_HELM_REPO";
23668
+ TIMELINE_STATUS["HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED"] = "HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED";
23669
+ })(TIMELINE_STATUS || (TIMELINE_STATUS = {}));
23670
+ var YET_TO_RUN = 'Yet to run';
23671
+
23672
+ var triggerStatus = function (triggerDetailStatus) {
23673
+ var triggerStatus = triggerDetailStatus === null || triggerDetailStatus === void 0 ? void 0 : triggerDetailStatus.toUpperCase();
23674
+ if (triggerStatus === TIMELINE_STATUS.ABORTED || triggerStatus === TIMELINE_STATUS.DEGRADED) {
23675
+ return 'Failed';
23676
+ }
23677
+ else if (triggerStatus === TIMELINE_STATUS.HEALTHY) {
23678
+ return 'Succeeded';
23679
+ }
23680
+ else if (triggerStatus === TIMELINE_STATUS.INPROGRESS) {
23681
+ return 'Inprogress';
23682
+ }
23683
+ else {
23684
+ return triggerDetailStatus;
23685
+ }
23686
+ };
23687
+
23688
+ function AppStatus(_a) {
23689
+ var appStatus = _a.appStatus, _b = _a.isDeploymentStatus, isDeploymentStatus = _b === void 0 ? false : _b, _c = _a.isJobView, isJobView = _c === void 0 ? false : _c, isVirtualEnv = _a.isVirtualEnv, _d = _a.hideStatusMessage, hideStatusMessage = _d === void 0 ? false : _d;
23690
+ var status = appStatus;
23691
+ if (isDeploymentStatus) {
23692
+ status = triggerStatus(appStatus);
23693
+ }
23694
+ var appStatusLowerCase = status === null || status === void 0 ? void 0 : status.toLowerCase();
23695
+ var isNotDeployed = appStatusLowerCase === StatusConstants.NOT_DEPLOYED.noSpaceLower;
23696
+ var iconClass = isNotDeployed ? StatusConstants.NOT_DEPLOYED.lowerCase : appStatusLowerCase;
23697
+ var statusMessage = status || (isVirtualEnv ? StatusConstants.NOT_AVILABLE.normalCase : '-');
23698
+ var notDeployed = isJobView ? YET_TO_RUN : StatusConstants.NOT_DEPLOYED.normalCase;
23699
+ var renderIcon = function () {
23700
+ if (iconClass) {
23701
+ return jsxRuntime.jsx("span", { className: "dc__app-summary__icon icon-dim-16 ".concat(iconClass, " ").concat(iconClass, "--node") });
23702
+ }
23703
+ else if (isVirtualEnv) {
23704
+ return (jsxRuntime.jsx("span", { className: "dc__app-summary__icon icon-dim-16 ".concat(StatusConstants.NOT_DEPLOYED.lowerCase, " ").concat(StatusConstants.NOT_DEPLOYED.lowerCase, "--node") }));
23705
+ }
23706
+ else {
23707
+ return (jsxRuntime.jsx(Tippy, __assign({ className: "default-tt w-200", arrow: false, placement: "top", content: "To fetch app status for GitOps based deployments open the app detail page" }, { children: jsxRuntime.jsx(SvgIcInfoOutlined, { className: "icon-dim-16 fcn-6" }) })));
23708
+ }
23709
+ };
23710
+ return hideStatusMessage ? (renderIcon()) : (jsxRuntime.jsxs("div", __assign({ className: "flex left" }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex mr-6" }, { children: renderIcon() })), jsxRuntime.jsx("p", __assign({ "data-testid": "".concat(status, "-app-status"), className: "dc__truncate-text dc__first-letter-capitalize cn-6 m-0" }, { children: isNotDeployed ? notDeployed : statusMessage }))] })));
23711
+ }
23712
+
23713
+ exports.AppStatus = AppStatus;
23611
23714
  exports.BreadCrumb = BreadCrumb;
23612
23715
  exports.BreadcrumbStore = Store;
23613
23716
  exports.BuildStageVariable = BuildStageVariable;
@@ -23697,6 +23800,7 @@ exports.multiSelectStyles = multiSelectStyles;
23697
23800
  exports.noop = noop$1;
23698
23801
  exports.not = not;
23699
23802
  exports.post = post;
23803
+ exports.processDeployedTime = processDeployedTime;
23700
23804
  exports.put = put;
23701
23805
  exports.setImageTags = setImageTags;
23702
23806
  exports.showError = showError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.37-beta-2",
3
+ "version": "0.0.37-beta-4",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,13 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
2
+ <g fill="none" fill-rule="evenodd">
3
+ <g fill="#06C">
4
+ <g>
5
+ <g>
6
+ <g>
7
+ <path d="M10 1.667c4.6 0 8.333 3.733 8.333 8.333S14.6 18.333 10 18.333 1.667 14.6 1.667 10 5.4 1.667 10 1.667zm0 1.666C6.32 3.333 3.333 6.32 3.333 10c0 3.68 2.987 6.667 6.667 6.667 3.68 0 6.667-2.987 6.667-6.667 0-3.68-2.987-6.667-6.667-6.667zm0 5.834c.46 0 .833.373.833.833v3.333c0 .46-.373.834-.833.834-.46 0-.833-.373-.833-.834V10c0-.46.373-.833.833-.833zm0-3.334c.46 0 .833.373.833.834 0 .46-.373.833-.833.833-.46 0-.833-.373-.833-.833 0-.46.373-.834.833-.834z" transform="translate(-315.000000, -313.000000) translate(303.000000, 256.000000) translate(4.000000, 49.000000) translate(8.000000, 8.000000)"/>
8
+ </g>
9
+ </g>
10
+ </g>
11
+ </g>
12
+ </g>
13
+ </svg>
@@ -0,0 +1,57 @@
1
+ import Tippy from '@tippyjs/react'
2
+ import { ReactComponent as InfoIcon } from '../../Assets/Icon/ic-info-outlined.svg'
3
+ import { StatusConstants, YET_TO_RUN } from './constants'
4
+ import { AppStatusType } from './types'
5
+ import { triggerStatus } from './utils'
6
+
7
+ export default function AppStatus({
8
+ appStatus,
9
+ isDeploymentStatus = false,
10
+ isJobView = false,
11
+ isVirtualEnv,
12
+ hideStatusMessage = false,
13
+ }: AppStatusType) {
14
+ let status = appStatus
15
+ if (isDeploymentStatus) {
16
+ status = triggerStatus(appStatus)
17
+ }
18
+ const appStatusLowerCase = status?.toLowerCase()
19
+ const isNotDeployed = appStatusLowerCase === StatusConstants.NOT_DEPLOYED.noSpaceLower
20
+ const iconClass = isNotDeployed ? StatusConstants.NOT_DEPLOYED.lowerCase : appStatusLowerCase
21
+ const statusMessage = status || (isVirtualEnv ? StatusConstants.NOT_AVILABLE.normalCase : '-')
22
+ const notDeployed = isJobView ? YET_TO_RUN : StatusConstants.NOT_DEPLOYED.normalCase
23
+
24
+ const renderIcon = () => {
25
+ if (iconClass) {
26
+ return <span className={`dc__app-summary__icon icon-dim-16 ${iconClass} ${iconClass}--node`} />
27
+ } else if (isVirtualEnv) {
28
+ return (
29
+ <span
30
+ className={`dc__app-summary__icon icon-dim-16 ${StatusConstants.NOT_DEPLOYED.lowerCase} ${StatusConstants.NOT_DEPLOYED.lowerCase}--node`}
31
+ />
32
+ )
33
+ } else {
34
+ return (
35
+ <Tippy
36
+ className="default-tt w-200"
37
+ arrow={false}
38
+ placement="top"
39
+ content="To fetch app status for GitOps based deployments open the app detail page"
40
+ >
41
+ <InfoIcon className="icon-dim-16 fcn-6" />
42
+ </Tippy>
43
+ )
44
+ }
45
+ }
46
+
47
+ return hideStatusMessage ? (
48
+ renderIcon()
49
+ ) : (
50
+ <div className="flex left">
51
+ <div className="flex mr-6">{renderIcon()}</div>
52
+ <p data-testid={`${status}-app-status`} className="dc__truncate-text dc__first-letter-capitalize cn-6 m-0">
53
+ {isNotDeployed ? notDeployed : statusMessage}
54
+ </p>
55
+ </div>
56
+ )
57
+ }
@@ -0,0 +1,53 @@
1
+ export const StatusConstants = {
2
+ NOT_DEPLOYED: {
3
+ noSpaceLower: 'notdeployed',
4
+ normalCase: 'Not deployed',
5
+ lowerCase: 'not-deployed',
6
+ },
7
+ APP_STATUS: {
8
+ noSpaceLower: 'appStatus',
9
+ normalText: 'App status',
10
+ },
11
+ PROJECT: {
12
+ pluralLower: 'projects',
13
+ lowerCase: 'project',
14
+ },
15
+ CLUSTER: {
16
+ pluralLower: 'clusters',
17
+ lowerCase: 'cluster',
18
+ },
19
+ NAMESPACE: {
20
+ pluralLower: 'namespaces',
21
+ lowerCase: 'namespace',
22
+ },
23
+ ENVIRONMENT: {
24
+ pluralLower: 'environments',
25
+ lowerCase: 'environment',
26
+ },
27
+ NOT_AVILABLE: {
28
+ normalCase: 'Not available',
29
+ },
30
+ }
31
+
32
+ export enum TIMELINE_STATUS {
33
+ DEPLOYMENT_INITIATED = 'DEPLOYMENT_INITIATED',
34
+ GIT_COMMIT = 'GIT_COMMIT',
35
+ GIT_COMMIT_FAILED = 'GIT_COMMIT_FAILED',
36
+ KUBECTL_APPLY = 'KUBECTL_APPLY',
37
+ KUBECTL_APPLY_STARTED = 'KUBECTL_APPLY_STARTED',
38
+ KUBECTL_APPLY_SYNCED = 'KUBECTL_APPLY_SYNCED',
39
+ HEALTHY = 'HEALTHY',
40
+ APP_HEALTH = 'APP_HEALTH',
41
+ DEPLOYMENT_FAILED = 'FAILED',
42
+ FETCH_TIMED_OUT = 'TIMED_OUT',
43
+ UNABLE_TO_FETCH_STATUS = 'UNABLE_TO_FETCH_STATUS',
44
+ DEGRADED = 'DEGRADED',
45
+ DEPLOYMENT_SUPERSEDED = 'DEPLOYMENT_SUPERSEDED',
46
+ ABORTED = 'ABORTED',
47
+ INPROGRESS = 'INPROGRESS',
48
+ HELM_PACKAGE_GENERATED = 'HELM_PACKAGE_GENERATED',
49
+ HELM_MANIFEST_PUSHED_TO_HELM_REPO = 'HELM_MANIFEST_PUSHED_TO_HELM_REPO',
50
+ HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED = 'HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED',
51
+ }
52
+
53
+ export const YET_TO_RUN = 'Yet to run'
@@ -0,0 +1 @@
1
+ export { default as AppStatus } from './AppStatus'
@@ -0,0 +1,12 @@
1
+ export interface AppStatusType {
2
+ appStatus: string
3
+ isDeploymentStatus?: boolean
4
+ isJobView?: boolean
5
+ isVirtualEnv?: boolean
6
+ /**
7
+ * Hide the status message if true
8
+ *
9
+ * @default false
10
+ */
11
+ hideStatusMessage?: boolean
12
+ }
@@ -0,0 +1,14 @@
1
+ import { TIMELINE_STATUS } from './constants'
2
+
3
+ export const triggerStatus = (triggerDetailStatus: string): string => {
4
+ let triggerStatus = triggerDetailStatus?.toUpperCase()
5
+ if (triggerStatus === TIMELINE_STATUS.ABORTED || triggerStatus === TIMELINE_STATUS.DEGRADED) {
6
+ return 'Failed'
7
+ } else if (triggerStatus === TIMELINE_STATUS.HEALTHY) {
8
+ return 'Succeeded'
9
+ } else if (triggerStatus === TIMELINE_STATUS.INPROGRESS) {
10
+ return 'Inprogress'
11
+ } else {
12
+ return triggerDetailStatus
13
+ }
14
+ }
@@ -487,3 +487,11 @@ export function useAsync<T>(
487
487
 
488
488
  return [state.loading, state.result, state.error, reload, setResult, state.dependencies]
489
489
  }
490
+
491
+ export const processDeployedTime = (lastDeployed, isArgoInstalled) => {
492
+ if (lastDeployed) {
493
+ return handleUTCTime(lastDeployed, true)
494
+ } else {
495
+ return isArgoInstalled ? '' : 'Not deployed'
496
+ }
497
+ }
@@ -252,9 +252,6 @@ export interface CDMaterialType {
252
252
  imageReleaseTags?: ReleaseTag[]
253
253
  artifactStatus?: string
254
254
  filterState: FilterStates
255
- registryType?: string;
256
- imagePath?: string
257
- registryName?: string
258
255
  }
259
256
 
260
257
  export interface CommonNodeAttr {
@@ -39,3 +39,4 @@ export { default as DebouncedSearch } from './DebouncedSearch/DebouncedSearch'
39
39
  export { default as Grid } from './Grid/Grid'
40
40
  export { default as ClipboardButton } from './ClipboardButton/ClipboardButton'
41
41
  export * from './Hooks'
42
+ export { AppStatus } from './AppStatus'