diff --git a/package.json b/package.json index 556a7d7122..7377dd014a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "homepage": "/dashboard", "dependencies": { - "@devtron-labs/devtron-fe-common-lib": "1.0.4", + "@devtron-labs/devtron-fe-common-lib": "1.0.5", "@esbuild-plugins/node-globals-polyfill": "0.2.3", "@rjsf/core": "^5.13.3", "@rjsf/utils": "^5.13.3", diff --git a/src/Pages/ResourceBrowser/ClusterList/ClusterMap/ClusterMap.tsx b/src/Pages/ResourceBrowser/ClusterList/ClusterMap/ClusterMap.tsx deleted file mode 100644 index a0089ea2f3..0000000000 --- a/src/Pages/ResourceBrowser/ClusterList/ClusterMap/ClusterMap.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import { Link } from 'react-router-dom' -import { ResponsiveContainer, Treemap, TreemapProps } from 'recharts' -import { followCursor } from 'tippy.js' - -import { ClusterStatusType, ConditionalWrap, Tooltip } from '@devtron-labs/devtron-fe-common-lib' - -import { getVisibleSvgTextWithEllipsis } from './utils' -import { ClusterMapProps } from './types' - -import './clustermap.scss' - -const renderWithLink = (href: string) => (children: JSX.Element) => ( - - {children} - -) - -const ClusterTreeMapContent = ({ - x, - y, - width, - height, - status, - name, - value, - href, -}: TreemapProps['content']['props']) => ( - - -
- {name} - {`${value} Nodes`} -
- - {status} - - - } - followCursor - plugins={[followCursor]} - > - - - - {getVisibleSvgTextWithEllipsis({ text: name, maxWidth: width, fontSize: 13, fontWeight: 600 })} - - - {value} - - -
-
-) - -export const ClusterMap = ({ treeMapData = [], isLoading = false }: ClusterMapProps) => - treeMapData.length ? ( -
-
- {isLoading ? ( -
-
-
-
- ) : ( - treeMapData.map(({ id, label, data }) => ( -
- {label && ( - -

{label}

-
- )} -
- - } - isAnimationActive={false} - /> - -
-
- )) - )} -
-
- ) : null diff --git a/src/Pages/ResourceBrowser/ClusterList/ClusterMap/clustermap.scss b/src/Pages/ResourceBrowser/ClusterList/ClusterMap/clustermap.scss deleted file mode 100644 index 905ad97709..0000000000 --- a/src/Pages/ResourceBrowser/ClusterList/ClusterMap/clustermap.scss +++ /dev/null @@ -1,35 +0,0 @@ -.cluster-map { - $parent-selector: &; - - &__container { - height: 165px; - } - - &__bar:hover { - #{$parent-selector}__rect { - fill: var(--G400); - - &--unhealthy { - fill: var(--R400); - } - } - - #{$parent-selector}__text { - fill: var(--N0); - } - } - - &__rect { - stroke: var(--N0); - stroke-width: 2; - fill: var(--G200); - - &--unhealthy { - fill: var(--R200); - } - } - - &__text { - stroke-width: 0; - } -} diff --git a/src/Pages/ResourceBrowser/ClusterList/ClusterMap/index.ts b/src/Pages/ResourceBrowser/ClusterList/ClusterMap/index.ts deleted file mode 100644 index 6f0b565fbd..0000000000 --- a/src/Pages/ResourceBrowser/ClusterList/ClusterMap/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './ClusterMap' -export * from './types' diff --git a/src/Pages/ResourceBrowser/ClusterList/ClusterMap/types.ts b/src/Pages/ResourceBrowser/ClusterList/ClusterMap/types.ts deleted file mode 100644 index 9f48bd5358..0000000000 --- a/src/Pages/ResourceBrowser/ClusterList/ClusterMap/types.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ClusterStatusType } from '@devtron-labs/devtron-fe-common-lib' - -interface MapData { - name: string - value: number - status: Extract - href?: string -} - -export interface ClusterTreeMapData { - id: number - label?: string - data: MapData[] -} - -export interface ClusterMapProps { - isLoading?: boolean - treeMapData: ClusterTreeMapData[] -} diff --git a/src/Pages/ResourceBrowser/ClusterList/ClusterMap/utils.ts b/src/Pages/ResourceBrowser/ClusterList/ClusterMap/utils.ts deleted file mode 100644 index 1c230d2e71..0000000000 --- a/src/Pages/ResourceBrowser/ClusterList/ClusterMap/utils.ts +++ /dev/null @@ -1,58 +0,0 @@ -const createMeasurementSvg = (fontSize: number, fontWeight: number) => { - const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg') - svg.setAttribute('width', '0') - svg.setAttribute('height', '0') - // Hide it from view - svg.style.position = 'absolute' - - const textElement = document.createElementNS('http://www.w3.org/2000/svg', 'text') - textElement.setAttribute('x', '0') - textElement.setAttribute('y', '0') - textElement.setAttribute('font-size', `${fontSize}px`) - textElement.setAttribute('font-weight', `${fontWeight}`) - textElement.setAttribute( - 'font-family', - "'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif", - ) - - svg.appendChild(textElement) - document.body.appendChild(svg) - - return { svg, textElement } -} - -export const getVisibleSvgTextWithEllipsis = (() => { - let svgInstance: SVGSVGElement | null = null - let textElementInstance: SVGTextElement | null = null - - return ({ text = '', maxWidth = 0, fontSize = 16, fontWeight = 400 }) => { - if (!svgInstance || !textElementInstance) { - const { svg, textElement } = createMeasurementSvg(fontSize, fontWeight) - svgInstance = svg - textElementInstance = textElement - } - - const textElement = textElementInstance - textElement.textContent = '...' - const ellipsisWidth = textElement.getBBox().width - - let start = 0 - let end = text.length - - while (start < end) { - const mid = Math.floor((start + end) / 2) - textElement.textContent = text.slice(0, mid + 1) - - const currentWidth = textElement.getBBox().width - if (currentWidth + ellipsisWidth > maxWidth - 8) { - end = mid - } else { - start = mid + 1 - } - } - - const visibleText = text.slice(0, start) + (start < text.length ? '...' : '') - - return visibleText - } -})() diff --git a/src/Pages/ResourceBrowser/ClusterList/index.ts b/src/Pages/ResourceBrowser/ClusterList/index.ts deleted file mode 100644 index 6b83e86ba6..0000000000 --- a/src/Pages/ResourceBrowser/ClusterList/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ClusterMap' diff --git a/src/Pages/ResourceBrowser/index.ts b/src/Pages/ResourceBrowser/index.ts deleted file mode 100644 index 771c6b4ca1..0000000000 --- a/src/Pages/ResourceBrowser/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ClusterList' diff --git a/src/components/ApplicationGroup/Details/TriggerView/BulkCITrigger.tsx b/src/components/ApplicationGroup/Details/TriggerView/BulkCITrigger.tsx index 9e949f8565..7916a24a00 100644 --- a/src/components/ApplicationGroup/Details/TriggerView/BulkCITrigger.tsx +++ b/src/components/ApplicationGroup/Details/TriggerView/BulkCITrigger.tsx @@ -248,7 +248,9 @@ const BulkCITrigger = ({ } } - return () => getCIBlockState(appDetails.ciPipelineId, appDetails.appId, branchNames, appDetails.name) + return !branchNames + ? () => null + : () => getCIBlockState(appDetails.ciPipelineId, appDetails.appId, branchNames, appDetails.name) }) if (policyPromiseFunctionList?.length) { diff --git a/src/components/CIPipelineN/CIPipeline.tsx b/src/components/CIPipelineN/CIPipeline.tsx index febf893a01..a0496e2dba 100644 --- a/src/components/CIPipelineN/CIPipeline.tsx +++ b/src/components/CIPipelineN/CIPipeline.tsx @@ -241,7 +241,8 @@ export default function CIPipeline({ } } - const areMandatoryPluginPossible = !isJobCard && !!processPluginData + // mandatory plugins are applicable for job ci but not jobs + const areMandatoryPluginPossible = !isJobView && !!processPluginData // NOTE: Wrap this method in try catch block to handle error const getMandatoryPluginData = async ( @@ -249,7 +250,7 @@ export default function CIPipeline({ /** * ids required to fetch in case we have a plugin in step */ - requiredPluginIds?: PluginDetailPayloadType['pluginId'], + requiredPluginIds?: PluginDetailPayloadType['pluginIds'], ): Promise => { if (areMandatoryPluginPossible) { let branchName = '' diff --git a/src/components/CIPipelineN/Sidebar.tsx b/src/components/CIPipelineN/Sidebar.tsx index 2c920cd56c..ff537a5533 100644 --- a/src/components/CIPipelineN/Sidebar.tsx +++ b/src/components/CIPipelineN/Sidebar.tsx @@ -89,7 +89,8 @@ export const Sidebar = ({ const showMandatoryWarning = (): boolean => { return ( !!MandatoryPluginWarning && - !isJobCard && + // mandatory plugins are applicable for Job CI but not Jobs + !isJobView && mandatoryPluginData && ((isPreBuildTab && !mandatoryPluginData.isValidPre) || (activeStageName === BuildStageVariable.PostBuild && !mandatoryPluginData.isValidPost)) diff --git a/src/components/ClusterNodes/ClusterSelectionList.tsx b/src/components/ClusterNodes/ClusterSelectionList.tsx index ed1bae4f00..3d9be753fc 100644 --- a/src/components/ClusterNodes/ClusterSelectionList.tsx +++ b/src/components/ClusterNodes/ClusterSelectionList.tsx @@ -32,7 +32,6 @@ import { AddClusterButton } from '@Components/ResourceBrowser/PageHeader.buttons import { ReactComponent as Error } from '@Icons/ic-error-exclamation.svg' import { ReactComponent as Success } from '@Icons/appstatus/healthy.svg' import { ReactComponent as TerminalIcon } from '@Icons/ic-terminal-fill.svg' -import { ClusterMap, ClusterTreeMapData } from '@Pages/ResourceBrowser' import { ClusterDetail } from './types' import ClusterNodeEmptyState from './ClusterNodeEmptyStates' import { ClusterSelectionType } from '../ResourceBrowser/Types' @@ -45,11 +44,12 @@ import './clusterNodes.scss' const KubeConfigButton = importComponentFromFELibrary('KubeConfigButton', null, 'function') const ClusterStatusCell = importComponentFromFELibrary('ClusterStatus', null, 'function') const ClusterFilters = importComponentFromFELibrary('ClusterFilters', null, 'function') +const ClusterMap = importComponentFromFELibrary('ClusterMap', null, 'function') -const getClusterMapData = (data: ClusterDetail[]): ClusterTreeMapData['data'] => +const getClusterMapData = (data: ClusterDetail[]) => data.map(({ name, id, nodeCount, status }) => ({ name, - status: status as ClusterTreeMapData['data'][0]['status'], + status, href: `${URLS.RESOURCE_BROWSER}/${id}/${ALL_NAMESPACE_OPTION.value}/${SIDEBAR_KEYS.nodeGVK.Kind.toLowerCase()}/${K8S_EMPTY_GROUP}`, value: nodeCount ?? 0, })) @@ -86,7 +86,7 @@ const ClusterSelectionList: React.FC = ({ }) }, [searchKey, clusterOptions, `${clusterFilter}`]) - const treeMapData = useMemo(() => { + const treeMapData = useMemo(() => { const { prodClusters, nonProdClusters } = filteredList.reduce( (acc, curr) => { if (curr.status && curr.status !== ClusterStatusType.CONNECTION_FAILED) { diff --git a/src/components/app/details/triggerView/TriggerView.tsx b/src/components/app/details/triggerView/TriggerView.tsx index 32b33e687a..7478b4065c 100644 --- a/src/components/app/details/triggerView/TriggerView.tsx +++ b/src/components/app/details/triggerView/TriggerView.tsx @@ -33,6 +33,7 @@ import { ToastVariantType, TOAST_ACCESS_DENIED, BlockedStateData, + getEnvironmentListMinPublic, } from '@devtron-labs/devtron-fe-common-lib' import ReactGA from 'react-ga4' import { withRouter, NavLink, Route, Switch } from 'react-router-dom' @@ -65,7 +66,7 @@ import { NO_COMMIT_SELECTED, } from '../../../../config' import { AppNotConfigured } from '../appDetails/AppDetails' -import { getEnvironmentListMinPublic, getHostURLConfiguration } from '../../../../services/service' +import { getHostURLConfiguration } from '../../../../services/service' import { ReactComponent as ICError } from '../../../../assets/icons/ic-error-exclamation.svg' import { ReactComponent as CloseIcon } from '../../../../assets/icons/ic-close.svg' import { getCIWebhookRes } from './ciWebhook.service' diff --git a/src/components/app/details/triggerView/ciMaterial.tsx b/src/components/app/details/triggerView/ciMaterial.tsx index a3e41ed7d2..d6d1b1d409 100644 --- a/src/components/app/details/triggerView/ciMaterial.tsx +++ b/src/components/app/details/triggerView/ciMaterial.tsx @@ -230,6 +230,7 @@ class CIMaterial extends Component { showTriggerButton onTrigger={this.handleStartBuildAction} nodeType={nodeType} + isJobView={this.props.isJobCI} > { isLoading={this.props.isLoading} onClick={noop} > - - Start Build + {this.props.isJobCI ? ( + <> + + Run Job + + ) : ( + <> + + Start Build + + )} ) diff --git a/src/components/app/list-new/AppListFilters.tsx b/src/components/app/list-new/AppListFilters.tsx index 5888fe6742..9c57e592b3 100644 --- a/src/components/app/list-new/AppListFilters.tsx +++ b/src/components/app/list-new/AppListFilters.tsx @@ -239,6 +239,7 @@ const AppListFilters = ({ namespaceListResponse?.result, appListFiltersResponse?.appListFilters.result.clusters, appListFiltersResponse?.appListFilters.result.teams, + appCount, ) } fileName={FILE_NAMES.Apps} diff --git a/src/components/app/list-new/AppListService.ts b/src/components/app/list-new/AppListService.ts index a51ac132ba..ca685ca248 100644 --- a/src/components/app/list-new/AppListService.ts +++ b/src/components/app/list-new/AppListService.ts @@ -57,8 +57,9 @@ export const getDevtronAppListDataToExport = ( namespaceList: EnvironmentListHelmResult[], clusterList: Cluster[], projectList: Teams[], + appCount: number ) => { - const appListPayload: AppListPayloadType = getDevtronAppListPayload(filterConfig, environmentList, namespaceList) + const appListPayload: AppListPayloadType = {...getDevtronAppListPayload(filterConfig, environmentList, namespaceList), offset: 0, size: appCount} // Over riding size and offset as we need all list (no pagination) const clusterMap = new Map() clusterList.forEach((cluster) => clusterMap.set(cluster.cluster_name, cluster.id)) return getAppList(appListPayload).then(({ result }) => { diff --git a/src/components/app/list/DevtronAppListContainer.tsx b/src/components/app/list/DevtronAppListContainer.tsx index adb4dfdcdf..69b9e58153 100644 --- a/src/components/app/list/DevtronAppListContainer.tsx +++ b/src/components/app/list/DevtronAppListContainer.tsx @@ -109,7 +109,7 @@ const DevtronAppList = ({ ...expandedState, isAllExpandable: parsedAppList.some((app) => app.environments.length > 1), }) - setAppCount(parsedAppList.length) + setAppCount(appListResponse?.result?.appCount || 0) }, [appListResponseLoading]) const handleEditApp = (appId: number): void => { diff --git a/src/components/cdPipeline/CDPipeline.tsx b/src/components/cdPipeline/CDPipeline.tsx index 2db6074bc6..9621564097 100644 --- a/src/components/cdPipeline/CDPipeline.tsx +++ b/src/components/cdPipeline/CDPipeline.tsx @@ -48,6 +48,7 @@ import { ProcessPluginDataParamsType, ProcessPluginDataReturnType, ResourceKindType, + getEnvironmentListMinPublic, } from '@devtron-labs/devtron-fe-common-lib' import { useEffect, useMemo, useRef, useState } from 'react' import { Redirect, Route, Switch, useParams, useRouteMatch } from 'react-router-dom' @@ -71,7 +72,6 @@ import { saveCDPipeline, updateCDPipeline, } from './cdPipeline.service' -import { getEnvironmentListMinPublic } from '../../services/service' import { Sidebar } from '../CIPipelineN/Sidebar' import DeleteCDNode from './DeleteCDNode' import { PreBuild } from '../CIPipelineN/PreBuild' diff --git a/src/components/cdPipeline/cdPipeline.service.ts b/src/components/cdPipeline/cdPipeline.service.ts index cb8a84daae..c798784e22 100644 --- a/src/components/cdPipeline/cdPipeline.service.ts +++ b/src/components/cdPipeline/cdPipeline.service.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import { post, get, sortCallback } from '@devtron-labs/devtron-fe-common-lib' +import { post, get, sortCallback, getEnvironmentListMinPublic } from '@devtron-labs/devtron-fe-common-lib' import { Routes, TriggerType } from '../../config' -import { getEnvironmentSecrets, getEnvironmentListMinPublic, getEnvironmentConfigs } from '../../services/service' +import { getEnvironmentSecrets, getEnvironmentConfigs } from '../../services/service' export function getCDPipelineNameSuggestion(appId: string | number): Promise { const URL = `app/pipeline/suggest/cd/${appId}` diff --git a/src/components/cdPipeline/types.ts b/src/components/cdPipeline/types.ts index 352a200dcd..77b46e8df7 100644 --- a/src/components/cdPipeline/types.ts +++ b/src/components/cdPipeline/types.ts @@ -77,6 +77,6 @@ export interface BuildCDProps releaseMode: ReleaseMode getMandatoryPluginData: ( form: PipelineFormType, - requiredPluginIds?: PluginDetailPayloadType['pluginId'], + requiredPluginIds?: PluginDetailPayloadType['pluginIds'], ) => Promise } diff --git a/src/components/common/GitInfoMaterial.tsx b/src/components/common/GitInfoMaterial.tsx index 2edaf82654..a83049246f 100644 --- a/src/components/common/GitInfoMaterial.tsx +++ b/src/components/common/GitInfoMaterial.tsx @@ -448,7 +448,11 @@ export default function GitInfoMaterial({ <> {(!fromBulkCITrigger || showWebhookModal) && renderMaterialHeader()} {MissingPluginBlockState && isCITriggerBlocked ? ( - + ) : (
{showWebhookModal == true ? ( diff --git a/src/components/security/SecurityPolicyEnvironment.tsx b/src/components/security/SecurityPolicyEnvironment.tsx index 1f42232edb..07ba08b48b 100644 --- a/src/components/security/SecurityPolicyEnvironment.tsx +++ b/src/components/security/SecurityPolicyEnvironment.tsx @@ -16,9 +16,15 @@ import React, { Component } from 'react' import { RouteComponentProps, NavLink } from 'react-router-dom' -import { showError, Progressing, sortCallback, Reload, SearchBar } from '@devtron-labs/devtron-fe-common-lib' +import { + showError, + Progressing, + sortCallback, + Reload, + SearchBar, + getEnvironmentListMinPublic, +} from '@devtron-labs/devtron-fe-common-lib' import { SecurityPolicyEdit } from './SecurityPolicyEdit' -import { getEnvironmentListMinPublic } from '../../services/service' import { ViewType } from '../../config' import { SecurityPolicyEnvironmentState } from './security.types' diff --git a/src/services/service.ts b/src/services/service.ts index 1471d3f1e8..fe332489ca 100644 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -219,15 +219,6 @@ export const getAppFilters = (): Promise> => }, })) -/** - * @deprecated Use getEnvironmentListMinPublic form common lib instead - */ -export function getEnvironmentListMinPublic(includeAllowedDeploymentTypes?: boolean) { - return get( - `${Routes.ENVIRONMENT_LIST_MIN}?auth=false${includeAllowedDeploymentTypes ? '&showDeploymentOptions=true' : ''}`, - ) -} - export function getDockerRegistryStatus(isStorageActionPush?: boolean): Promise { const URL = `${Routes.DOCKER_REGISTRY_CONFIG}/configure/status${isStorageActionPush ? '?storageType=CHART&storageAction=PUSH' : ''}` return get(URL) diff --git a/yarn.lock b/yarn.lock index 2691c8bc9e..21a87848cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -974,10 +974,10 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@devtron-labs/devtron-fe-common-lib@1.0.4": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-1.0.4.tgz#0fdb512afe4567ca5424d28718b638bed2e687d0" - integrity sha512-3wNFvPJUAYwpNnamXoaMqFKsxbphJbZiUIsxL5ErLHxqP0+cPF1NC5PShZBxGMr5IBnzZBhj5TM6aMI9Jswp9A== +"@devtron-labs/devtron-fe-common-lib@1.0.5": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-1.0.5.tgz#0da88fc1b5db524388018ca1c4f7cefd46612c4f" + integrity sha512-bYvOBj/lckFS+8sC25x1ue5/68rQEW4nQzXZZMKluMYmTXQQRAUnM/2M4vWddmk0WradA+3AkW4KjnxHXsnfQQ== dependencies: "@types/react-dates" "^21.8.6" ansi_up "^5.2.1"