Skip to content

Commit 652326c

Browse files
committed
chore: enable flag
1 parent d8322c7 commit 652326c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+835
-332
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ HIDE_EXCLUDE_INCLUDE_GIT_COMMITS=true
3131
ENABLE_BUILD_CONTEXT=false
3232
CLAIR_TOOL_VERSION=
3333
ENABLE_RESTART_WORKLOAD=false
34-
ENABLE_SCOPED_VARIABLES=false
34+
ENABLE_SCOPED_VARIABLES=true

src/components/ApplicationGroup/Constants.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,16 @@ export const CREATE_GROUP_TABS = {
167167
selectedApps: 'Selected applications',
168168
allApps: 'Add/Remove applications',
169169
}
170+
171+
export const GetBranchChangeStatus = (statusText: string): BulkResponseStatus => {
172+
switch (statusText) {
173+
case BULK_VIRTUAL_RESPONSE_STATUS.pass:
174+
return BulkResponseStatus.PASS
175+
case BULK_VIRTUAL_RESPONSE_STATUS.fail:
176+
return BulkResponseStatus.FAIL
177+
case BULK_VIRTUAL_RESPONSE_STATUS.unauthorized:
178+
return BulkResponseStatus.UNAUTHORIZE
179+
default:
180+
return
181+
}
182+
}

src/components/ApplicationGroup/Details/TriggerView/EnvTriggerView.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
}
2020
}
2121

22+
.filter-divider {
23+
width: 1px;
24+
height: 20px;
25+
background-color: var(--N200);
26+
margin-left: 12px;
27+
margin-right: 12px;
28+
}
29+
2230
.bulk-ci-trigger-container {
2331
.bulk-ci-trigger {
2432
display: grid;

src/components/ApplicationGroup/Details/TriggerView/EnvTriggerView.tsx

Lines changed: 98 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
refreshGitMaterial,
4040
triggerCDNode,
4141
triggerCINode,
42+
triggerBranchChange,
4243
} from '../../../app/service'
4344
import {
4445
createGitCommitUrl,
@@ -47,6 +48,7 @@ import {
4748
preventBodyScroll,
4849
sortObjectArrayAlphabetically,
4950
} from '../../../common'
51+
import { ReactComponent as Pencil } from '../../../../assets/icons/ic-pencil.svg'
5052
import { getWorkflows, getWorkflowStatus } from '../../AppGroup.service'
5153
import { CI_MATERIAL_EMPTY_STATE_MESSAGING, TIME_STAMP_ORDER } from '../../../app/details/triggerView/Constants'
5254
import { toast } from 'react-toastify'
@@ -59,8 +61,8 @@ import {
5961
BulkResponseStatus,
6062
ENV_TRIGGER_VIEW_GA_EVENTS,
6163
BULK_CD_RESPONSE_STATUS_TEXT,
62-
responseListOrder,
6364
BULK_VIRTUAL_RESPONSE_STATUS,
65+
GetBranchChangeStatus,
6466
} from '../../Constants'
6567
import { ReactComponent as DeployIcon } from '../../../../assets/icons/ic-nav-rocket.svg'
6668
import { ReactComponent as Close } from '../../../../assets/icons/ic-cross.svg'
@@ -88,6 +90,7 @@ import Tippy from '@tippyjs/react'
8890
import { getModuleInfo } from '../../../v2/devtronStackManager/DevtronStackManager.service'
8991
import GitCommitInfoGeneric from '../../../common/GitCommitInfoGeneric'
9092
import { getDefaultConfig } from '../../../notifications/notifications.service'
93+
import BulkSourceChange from './BulkSourceChange'
9194

9295
const ApprovalMaterialModal = importComponentFromFELibrary('ApprovalMaterialModal')
9396
const getDeployManifestDownload = importComponentFromFELibrary('getDeployManifestDownload', null, 'function')
@@ -102,6 +105,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
102105
const [pageViewType, setPageViewType] = useState<string>(ViewType.LOADING)
103106
const [isCILoading, setCILoading] = useState(false)
104107
const [isCDLoading, setCDLoading] = useState(false)
108+
const [isBranchChangeLoading, setIsBranchChangeLoading] = useState(false);
105109
const [showPreDeployment, setShowPreDeployment] = useState(false)
106110
const [showPostDeployment, setShowPostDeployment] = useState(false)
107111
const [errorCode, setErrorCode] = useState(0)
@@ -110,6 +114,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
110114
const [showApprovalModal, setShowApprovalModal] = useState(false)
111115
const [showBulkCDModal, setShowBulkCDModal] = useState(false)
112116
const [showBulkCIModal, setShowBulkCIModal] = useState(false)
117+
const [showBulkSourceChangeModal, setShowBulkSourceChangeModal] = useState(false)
113118
const [showWebhookModal, setShowWebhookModal] = useState(false)
114119
const [isWebhookPayloadLoading, setWebhookPayloadLoading] = useState(false)
115120
const [invalidateCache, setInvalidateCache] = useState(false)
@@ -176,6 +181,19 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
176181
})
177182
}
178183

184+
const preserveSelection = (_workflows: WorkflowType[]) => {
185+
if (!workflows || !_workflows) {
186+
return
187+
}
188+
const workflowMap = new Map()
189+
workflows.forEach((wf) => {
190+
workflowMap.set(wf.id, wf.isSelected)
191+
})
192+
_workflows.forEach((wf) => {
193+
wf.isSelected = workflowMap.get(wf.id)
194+
})
195+
}
196+
179197
const getWorkflowsData = async (): Promise<void> => {
180198
try {
181199
const { workflows: _workflows, filteredCIPipelines } = await getWorkflows(envId, filteredAppIds)
@@ -194,6 +212,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
194212
}),
195213
)
196214
}
215+
preserveSelection(_workflows)
197216
setWorkflows(_workflows)
198217
setFilteredCIPipelines(filteredCIPipelines)
199218
setErrorCode(0)
@@ -1032,6 +1051,41 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
10321051
setFilteredWorkflows(_workflows)
10331052
}
10341053

1054+
const changeBranch = (value): void => {
1055+
let appIds = []
1056+
let appNameMap = new Map()
1057+
selectedAppList.map((app) => {
1058+
appIds.push(app.id)
1059+
appNameMap.set(app.id, app.name)
1060+
})
1061+
setIsBranchChangeLoading(true)
1062+
triggerBranchChange(appIds, +envId, value)
1063+
.then((response: any) => {
1064+
console.log(response)
1065+
const _responseList = []
1066+
response.result.apps.map((res) => {
1067+
_responseList.push({
1068+
appId: res.appId,
1069+
appName: appNameMap.get(res.appId),
1070+
statusText: res.status,
1071+
status: GetBranchChangeStatus(res.status),
1072+
envId: +envId,
1073+
message: res.message,
1074+
})
1075+
})
1076+
updateResponseListData(_responseList)
1077+
setCDLoading(false)
1078+
setCILoading(false)
1079+
preventBodyScroll(false)
1080+
})
1081+
.catch((error) => {
1082+
showError(error)
1083+
})
1084+
.finally(() => {
1085+
setIsBranchChangeLoading(false)
1086+
})
1087+
}
1088+
10351089
const selectMaterial = (materialId, pipelineId?: number): void => {
10361090
const _workflows = [...filteredWorkflows].map((workflow) => {
10371091
const nodes = workflow.nodes.map((node) => {
@@ -1295,8 +1349,19 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
12951349
}, 100)
12961350
}
12971351

1298-
const sortResponseList = (a, b) => {
1299-
return responseListOrder[a.status] - responseListOrder[b.status]
1352+
const hideChangeSourceModal = () => {
1353+
if (responseList.length > 0) {
1354+
setPageViewType(ViewType.LOADING)
1355+
inprogressStatusTimer && clearTimeout(inprogressStatusTimer)
1356+
getWorkflowsData()
1357+
}
1358+
setIsBranchChangeLoading(false)
1359+
setShowBulkSourceChangeModal(false)
1360+
setResponseList([])
1361+
}
1362+
1363+
const onShowChangeSourceModal = () => {
1364+
setShowBulkSourceChangeModal(true)
13001365
}
13011366

13021367
const updateBulkCDInputMaterial = (cdMaterialResponse: Record<string, CDMaterialResponseType>): void => {
@@ -1380,7 +1445,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
13801445
setResponseList((prevList) => {
13811446
const resultMap = new Map(_responseList.map((data) => [data.appId, data]))
13821447
const updatedArray = prevList?.map((prevItem) => resultMap.get(prevItem.appId) || prevItem)
1383-
return (updatedArray?.length > 0 ? updatedArray : _responseList).sort(sortResponseList)
1448+
return (updatedArray?.length > 0 ? updatedArray : _responseList).sort((a, b) => sortCallback('appName', a, b))
13841449
})
13851450
}
13861451

@@ -1862,6 +1927,22 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
18621927
)
18631928
}
18641929

1930+
const renderBulkSourchChange = (): JSX.Element | null => {
1931+
if (!showBulkSourceChangeModal) {
1932+
return null
1933+
}
1934+
1935+
return (
1936+
<BulkSourceChange
1937+
closePopup={hideChangeSourceModal}
1938+
responseList={responseList}
1939+
changeBranch={changeBranch}
1940+
loading={isBranchChangeLoading}
1941+
selectedAppCount={selectedAppList.length}
1942+
/>
1943+
)
1944+
}
1945+
18651946
const renderCDMaterial = (): JSX.Element | null => {
18661947
if (showCDModal) {
18671948
let node: NodeAttr, _appID
@@ -2030,6 +2111,18 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
20302111
const _showPopupMenu = showPreDeployment || showPostDeployment
20312112
return (
20322113
<div className="flex dc__min-width-fit-content">
2114+
<button
2115+
className="dc__edit_button h-36 lh-36"
2116+
type="button"
2117+
style={{ marginRight: 'auto' }}
2118+
onClick={onShowChangeSourceModal}
2119+
>
2120+
<span className="flex dc__align-items-center">
2121+
<Pencil className="icon-dim-16 scb-5 mr-4" />
2122+
Change branch
2123+
</span>
2124+
</button>
2125+
<span className="filter-divider"></span>
20332126
<button
20342127
className="cta flex h-36 mr-12"
20352128
data-testid="bulk-build-image-button"
@@ -2157,6 +2250,7 @@ export default function EnvTriggerView({ filteredAppIds, isVirtualEnv }: AppGrou
21572250
{renderBulkCDMaterial()}
21582251
{renderBulkCIMaterial()}
21592252
{renderApprovalMaterial()}
2253+
{renderBulkSourchChange()}
21602254
</TriggerViewContext.Provider>
21612255
<div></div>
21622256
</div>

src/components/ClusterNodes/ClusterOverview.tsx

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import React, { useEffect, useState } from 'react'
22
import { ClusterOverviewProps, DescriptionDataType, ERROR_TYPE } from './types'
33
import { ReactComponent as Error } from '../../assets/icons/ic-error-exclamation.svg'
4+
import { ReactComponent as QuestionFilled } from '../../assets/icons/ic-help.svg'
5+
import { ReactComponent as TippyIcon } from '../../assets/icons/ic-help-outline.svg'
46
import { getClusterNote } from './clusterNodes.service'
57
import { generatePath, useHistory, useParams, useRouteMatch } from 'react-router-dom'
68
import GenericDescription from '../common/Description/GenericDescription'
79
import { defaultClusterNote } from './constants'
810
import moment from 'moment'
9-
import { Moment12HourFormat } from '../../config'
10-
import { ErrorScreenManager, Progressing, showError } from '@devtron-labs/devtron-fe-common-lib'
11+
import { Moment12HourFormat,URLS } from '../../config'
12+
import {
13+
ErrorScreenManager,
14+
Progressing,
15+
TippyCustomized,
16+
TippyTheme,
17+
showError,
18+
} from '@devtron-labs/devtron-fe-common-lib'
1119
import { K8S_EMPTY_GROUP, SIDEBAR_KEYS } from '../ResourceBrowser/Constants'
1220
import { unauthorizedInfoText } from '../ResourceBrowser/ResourceList/ClusterSelector'
1321

@@ -32,7 +40,20 @@ export default function ClusterOverview({
3240
const history = useHistory()
3341
const { path } = useRouteMatch()
3442
const [errorCode, setErrorCode] = useState(0)
35-
43+
const metricsApiTippyContent = () => (
44+
<div className="dc__align-left dc__word-break dc__hyphens-auto fs-13 fw-4 lh-20 p-12">
45+
Devtron uses Kubernetes’s&nbsp;
46+
<a
47+
href="https://kubernetes.io/docs/tasks/debug/debug-cluster/resource-metrics-pipeline/#metrics-api"
48+
rel="noreferrer noopener"
49+
target="_blank"
50+
>
51+
Metrics API
52+
</a>
53+
&nbsp; to show CPU and Memory Capacity. Please install metrics-server in this cluster to display CPU and
54+
Memory Capacity.
55+
</div>
56+
)
3657
useEffect(() => {
3758
setIsLoading(true)
3859
if (errorStatusCode > 0) return
@@ -141,54 +162,81 @@ export default function ClusterOverview({
141162
)
142163
}
143164

165+
const tippyForMetricsApi = () => {
166+
return (
167+
<>
168+
<span>NA</span>
169+
<TippyCustomized
170+
theme={TippyTheme.white}
171+
className="w-300 h-100 fcv-5 dc__align-left"
172+
placement="bottom"
173+
Icon={QuestionFilled}
174+
heading='Metrics API is not available'
175+
showCloseButton={true}
176+
trigger="click"
177+
additionalContent={metricsApiTippyContent()}
178+
interactive={true}
179+
documentationLinkText="View metrics-server helm chart"
180+
documentationLink={`/dashboard/${URLS.CHARTS_DISCOVER}/?appStoreName=metrics-server`}
181+
>
182+
<TippyIcon className="icon-dim-20 ml-8 cursor fcn-5" />
183+
</TippyCustomized>
184+
</>
185+
)
186+
}
187+
144188
const renderCardDetails = () => {
145189
return (
146190
<div className="flexbox dc__content-space pb-16">
147191
<div className="flexbox dc__content-space mr-16 w-50 p-16 bcn-0 br-4 en-2 bw-1">
148192
<div className="mr-16 w-25">
149-
<div className="dc__align-center fs-13 fw-4 cn-7">CPU Usage</div>
150-
<div className="dc__align-center fs-24 fw-4 cn-9">
151-
{clusterCapacityData?.cpu?.usagePercentage}
193+
<div className="dc__align-left fs-13 fw-4 cn-7">CPU Usage</div>
194+
<div className="dc__align-left fs-24 fw-4 cn-9">
195+
{clusterCapacityData?.cpu?.usagePercentage
196+
? clusterCapacityData?.cpu?.usagePercentage
197+
: tippyForMetricsApi()}
152198
</div>
153199
</div>
154200
<div className="mr-16 w-25">
155-
<div className="dc__align-center fs-13 fw-4 cn-7">CPU Capacity</div>
156-
<div className="dc__align-center fs-24 fw-4 cn-9">{clusterCapacityData?.cpu?.capacity}</div>
201+
<div className="dc__align-left fs-13 fw-4 cn-7">CPU Capacity</div>
202+
<div className="dc__align-left fs-24 fw-4 cn-9">{clusterCapacityData?.cpu?.capacity}</div>
157203
</div>
158204
<div className="mr-16 w-25">
159-
<div className="dc__align-center fs-13 fw-4 cn-7">CPU Requests</div>
160-
<div className="dc__align-center fs-24 fw-4 cn-9">
205+
<div className="dc__align-left fs-13 fw-4 cn-7">CPU Requests</div>
206+
<div className="dc__align-left fs-24 fw-4 cn-9">
161207
{clusterCapacityData?.cpu?.requestPercentage}
162208
</div>
163209
</div>
164210
<div className="w-25">
165-
<div className="dc__align-center fs-13 fw-4 cn-7">CPU Limits</div>
166-
<div className="dc__align-center fs-24 fw-4 cn-9">
211+
<div className="dc__align-left fs-13 fw-4 cn-7">CPU Limits</div>
212+
<div className="dc__align-left fs-24 fw-4 cn-9">
167213
{clusterCapacityData?.cpu?.limitPercentage}
168214
</div>
169215
</div>
170216
</div>
171217

172218
<div className="flexbox dc__content-space w-50 p-16 bcn-0 br-4 en-2 bw-1">
173219
<div className="mr-16 w-25">
174-
<div className="dc__align-center fs-13 fw-4 cn-7">Memory Usage</div>
175-
<div className="dc__align-center fs-24 fw-4 cn-9">
176-
{clusterCapacityData?.memory?.usagePercentage}
220+
<div className="dc__align-left fs-13 fw-4 cn-7">Memory Usage</div>
221+
<div className="dc__align-left fs-24 fw-4 cn-9">
222+
{clusterCapacityData?.memory?.usagePercentage
223+
? clusterCapacityData?.memory?.usagePercentage
224+
: tippyForMetricsApi()}
177225
</div>
178226
</div>
179227
<div className="mr-16 w-25">
180-
<div className="dc__align-center fs-13 fw-4 cn-7">Memory Capacity</div>
181-
<div className="dc__align-center fs-24 fw-4 cn-9">{clusterCapacityData?.memory?.capacity}</div>
228+
<div className="dc__align-left fs-13 fw-4 cn-7">Memory Capacity</div>
229+
<div className="dc__align-left fs-24 fw-4 cn-9">{clusterCapacityData?.memory?.capacity}</div>
182230
</div>
183231
<div className="mr-16 w-25">
184-
<div className="dc__align-center fs-13 fw-4 cn-7">Memory Requests</div>
185-
<div className="dc__align-center fs-24 fw-4 cn-9">
232+
<div className="dc__align-left fs-13 fw-4 cn-7">Memory Requests</div>
233+
<div className="dc__align-left fs-24 fw-4 cn-9">
186234
{clusterCapacityData?.memory?.requestPercentage}
187235
</div>
188236
</div>
189237
<div className="w-25">
190-
<div className="dc__align-center fs-13 fw-4 cn-7">Memory Limits</div>
191-
<div className="dc__align-center fs-24 fw-4 cn-9">
238+
<div className="dc__align-left fs-13 fw-4 cn-7">Memory Limits</div>
239+
<div className="dc__align-left fs-24 fw-4 cn-9">
192240
{clusterCapacityData?.memory?.limitPercentage}
193241
</div>
194242
</div>

src/components/ClusterNodes/ClusterSelectionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default function ClusterSelectionList({
145145
/>
146146
</div>
147147
<div>
148-
{clusterData.errorInNodeListing ? (
148+
{errorCount > 0 ? (
149149
<Tippy className="default-tt w-200" arrow={false} content={clusterData.errorInNodeListing}>
150150
<div className="flexbox">
151151
<Error className="mt-2 mb-2 mr-8 icon-dim-18" />

0 commit comments

Comments
 (0)