Skip to content

Commit dd73467

Browse files
chore: shift components
1 parent 4d7ec40 commit dd73467

File tree

5 files changed

+42
-34
lines changed

5 files changed

+42
-34
lines changed

src/components/ApplicationGroup/AppGroup.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export interface CreateGroupType {
311311
selectedAppGroup: GroupOptionType
312312
unAuthorizedApps?: Map<string, boolean>
313313
closePopup: (e, groupId?: number) => void
314-
isEnv: boolean
314+
filterParentType: FilterParentType
315315
}
316316

317317
export interface ApplistEnvType {

src/components/ApplicationGroup/AppGroupDetailsRoute.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,16 @@ export default function AppGroupDetailsRoute({ isSuperAdmin }: AppGroupAdminType
216216
}
217217
}
218218

219+
// opens with edit state and blank state while clicked onSave
219220
const openCreateGroup = (e, groupId?: string, _edit?: boolean) => {
221+
console.log('openCreateGroup', groupId, _edit)
220222
stopPropagation(e)
221223
const selectedAppsMap: Record<string, boolean> = {}
222224
const _allAppList: { id: string; appName: string; isSelected: boolean }[] = []
223225
let _selectedGroup
224226
const _allAppIds: number[] = []
225227
if (groupId) {
228+
// true for edit
226229
_selectedGroup = groupFilterOptions.find((group) => group.value === groupId)
227230
const groupAppIds = _selectedGroup?.appIds || []
228231
for (const appId of groupAppIds) {
@@ -249,6 +252,7 @@ export default function AppGroupDetailsRoute({ isSuperAdmin }: AppGroupAdminType
249252
envId: +envId,
250253
}
251254
if (_edit) {
255+
// true for edit
252256
getPermissionCheck({ appIds: _allAppIds }, _edit)
253257
} else {
254258
getPermissionCheck(_permissionData)
@@ -393,7 +397,7 @@ export default function AppGroupDetailsRoute({ isSuperAdmin }: AppGroupAdminType
393397
appList={allAppsList}
394398
selectedAppGroup={clickedGroup}
395399
closePopup={closeCreateGroup}
396-
isEnv={false}
400+
filterParentType={FilterParentType.app}
397401
/>
398402
)}
399403
{showDeleteGroup && isPopupBox && (

src/components/ApplicationGroup/CreateAppGroup.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ import { ReactComponent as Close } from '../../assets/icons/ic-close.svg'
1212
import { ReactComponent as Error } from '../../assets/icons/ic-warning.svg'
1313
import { ReactComponent as CheckIcon } from '../../assets/icons/ic-check.svg'
1414
import { ReactComponent as Abort } from '../../assets/icons/ic-abort.svg'
15-
import { CreateGroupType, CreateTypeOfAppListType } from './AppGroup.types'
15+
import { CreateGroupType, CreateTypeOfAppListType, FilterParentType } from './AppGroup.types'
1616
import SearchBar from './SearchBar'
1717
import { CreateGroupTabs, CREATE_GROUP_TABS } from './Constants'
1818
import { toast } from 'react-toastify'
1919
import { createEnvGroup } from './AppGroup.service'
2020
import { useParams } from 'react-router-dom'
2121
import Tippy from '@tippyjs/react'
22+
import { filter } from 'rxjs'
2223

2324
export default function CreateAppGroup({
2425
appList,
2526
selectedAppGroup,
2627
closePopup,
2728
unAuthorizedApps,
28-
isEnv,
29+
filterParentType,
2930
}: CreateGroupType) {
3031
const { envId } = useParams<{ envId: string }>()
3132
const CreateGroupRef = useRef<HTMLDivElement>(null)
@@ -335,10 +336,17 @@ export default function CreateAppGroup({
335336
<div>
336337
<ul role="tablist" className="tab-list dc__border-bottom mb-8">
337338
{renderTabItem(
338-
isEnv ? CreateGroupTabs.SELECTED_ENV : CreateGroupTabs.SELECTED_APPS,
339+
filterParentType === FilterParentType.env
340+
? CreateGroupTabs.SELECTED_ENV
341+
: CreateGroupTabs.SELECTED_APPS,
339342
selectedAppsCount,
340343
)}
341-
{renderTabItem(isEnv ? CreateGroupTabs.ALL_ENV : CreateGroupTabs.ALL_APPS, appList.length)}
344+
{renderTabItem(
345+
filterParentType === FilterParentType.env
346+
? CreateGroupTabs.ALL_ENV
347+
: CreateGroupTabs.ALL_APPS,
348+
appList.length,
349+
)}
342350
</ul>
343351
{selectedTab === CreateGroupTabs.SELECTED_APPS ? renderSelectedApps() : renderAllApps()}
344352
</div>

src/components/app/details/AppHeader.tsx

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useCallback, useRef, useEffect, useState, useMemo } from 'react'
22
import { NavLink } from 'react-router-dom'
3-
import { BreadCrumb, useBreadcrumb, noop } from '@devtron-labs/devtron-fe-common-lib'
3+
import { BreadCrumb, useBreadcrumb, noop, stopPropagation } from '@devtron-labs/devtron-fe-common-lib'
44
import { useParams, useRouteMatch, useHistory, generatePath, useLocation } from 'react-router'
55
import { URLS } from '../../../config'
66
import { AppSelector } from '../../AppSelector'
@@ -33,18 +33,13 @@ export function AppHeader({
3333
openCreateGroup,
3434
openDeleteGroup,
3535
isSuperAdmin,
36-
//@ts-ignore
37-
showCreateGroup,
3836
}: AppHeaderType) {
3937
const { appId } = useParams<{ appId }>()
4038
const match = useRouteMatch()
4139
const history = useHistory()
4240
const location = useLocation()
4341
const currentPathname = useRef('')
4442
const [isMenuOpen, setMenuOpen] = useState(false)
45-
const [mapUnauthorizedApp, setMapUnauthorizedApp] = useState<Map<string, boolean>>(new Map())
46-
const [allAppsList, setAllAppsList] = useState<CreateGroupAppListType[]>([])
47-
const [clickedGroup, setClickedGroup] = useState<GroupOptionType>(null)
4843

4944
const contextValue = useMemo(
5045
() => ({
@@ -234,12 +229,6 @@ export function AppHeader({
234229
)
235230
}
236231

237-
const closeCreateGroup = () => {
238-
// FIXME
239-
setClickedGroup(null)
240-
openCreateGroup(false)
241-
}
242-
243232
return (
244233
<>
245234
<PageHeader
@@ -248,15 +237,6 @@ export function AppHeader({
248237
showTabs={true}
249238
renderHeaderTabs={renderAppDetailsTabs}
250239
/>
251-
{showCreateGroup && (
252-
<CreateAppGroup
253-
unAuthorizedApps={mapUnauthorizedApp}
254-
appList={allAppsList}
255-
selectedAppGroup={clickedGroup}
256-
closePopup={closeCreateGroup}
257-
isEnv={true}
258-
/>
259-
)}
260240
</>
261241
)
262242
}

src/components/app/details/main.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ import './appDetails/appDetails.scss'
1414
import './app.scss'
1515
import { MultiValue } from 'react-select'
1616
import { AppFilterTabs } from '../../ApplicationGroup/Constants'
17-
import { CheckPermissionType, GroupOptionType } from '../../ApplicationGroup/AppGroup.types'
17+
import {
18+
CheckPermissionType,
19+
CreateGroupAppListType,
20+
FilterParentType,
21+
GroupOptionType,
22+
} from '../../ApplicationGroup/AppGroup.types'
1823
import { getAppOtherEnvironmentMin } from '../../../services/service'
1924
import { appGroupPermission } from '../../ApplicationGroup/AppGroup.service'
25+
import CreateAppGroup from '../../ApplicationGroup/CreateAppGroup'
2026

2127
const TriggerView = lazy(() => import('./triggerView/TriggerView'))
2228
const DeploymentMetrics = lazy(() => import('./metrics/DeploymentMetrics'))
@@ -29,7 +35,7 @@ const TestRunList = lazy(() => import('./testViewer/TestRunList'))
2935

3036
export default function AppDetailsPage({ isV2 }: AppDetailsProps) {
3137
const { path } = useRouteMatch()
32-
const { appId, envId } = useParams<{ appId; envId }>()
38+
const { appId } = useParams<{ appId }>()
3339
const [appName, setAppName] = useState('')
3440
const [appMetaInfo, setAppMetaInfo] = useState<AppMetaInfo>()
3541
const [reloadMandatoryProjects, setReloadMandatoryProjects] = useState<boolean>(true)
@@ -41,6 +47,9 @@ export default function AppDetailsPage({ isV2 }: AppDetailsProps) {
4147
const [groupFilterOptions, setGroupFilterOptions] = useState<GroupOptionType[]>([])
4248
const [selectedGroupFilter, setSelectedGroupFilter] = useState<MultiValue<GroupOptionType>>([])
4349
const [showCreateGroup, setShowCreateGroup] = useState<boolean>(false)
50+
const [mapUnauthorizedApp, setMapUnauthorizedApp] = useState<Map<string, boolean>>(new Map())
51+
const [allAppsList, setAllAppsList] = useState<CreateGroupAppListType[]>([])
52+
const [clickedGroup, setClickedGroup] = useState<GroupOptionType>(null)
4453

4554
useEffect(() => {
4655
getAppMetaInfoRes()
@@ -129,7 +138,7 @@ export default function AppDetailsPage({ isV2 }: AppDetailsProps) {
129138

130139
async function getPermissionCheck(payload: CheckPermissionType, _edit?: boolean, _delete?: boolean): Promise<void> {
131140
try {
132-
const { result } = await appGroupPermission(envId, payload)
141+
const { result } = await appGroupPermission(appId, payload)
133142
if (result && !_delete) {
134143
console.log(result)
135144
setShowCreateGroup(true)
@@ -205,9 +214,9 @@ export default function AppDetailsPage({ isV2 }: AppDetailsProps) {
205214
_allAppLists.push(+app.id)
206215
}
207216
let _permissionData = {
208-
id: +envId,
217+
id: +appId,
209218
appIds: _allAppLists,
210-
envId: +envId,
219+
envId: +appId,
211220
}
212221
if (_edit) {
213222
getPermissionCheck({ appIds: _allAppIds }, _edit)
@@ -252,8 +261,15 @@ export default function AppDetailsPage({ isV2 }: AppDetailsProps) {
252261
openCreateGroup={openCreateGroup}
253262
openDeleteGroup={openDeleteGroup}
254263
isSuperAdmin={true}
255-
//@ts-ignore
256-
showCreateGroup={showCreateGroup}
264+
/>
265+
)}
266+
{showCreateGroup && (
267+
<CreateAppGroup
268+
unAuthorizedApps={mapUnauthorizedApp}
269+
appList={allAppsList}
270+
selectedAppGroup={clickedGroup}
271+
closePopup={closeCreateGroup}
272+
filterParentType={FilterParentType.env}
257273
/>
258274
)}
259275
<ErrorBoundary>

0 commit comments

Comments
 (0)