-
Notifications
You must be signed in to change notification settings - Fork 55
fix: sentry issues #1844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: sentry issues #1844
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,12 +92,18 @@ export default function DeploymentTemplateOverride({ | |
|
||
useEffect(() => { | ||
const fetchOptionsList = async () => { | ||
const { result } = await getOptions(+appId, +envId) | ||
const _groupedData = groupDataByType(result) | ||
setGroupedOptionsDataOverride(_groupedData) | ||
} | ||
fetchOptionsList() | ||
}, [environments]) | ||
try { //adding try and catch block to handle error | ||
const { result } = await getOptions(+appId, +envId); | ||
const _groupedData = groupDataByType(result); | ||
setGroupedOptionsDataOverride(_groupedData); | ||
} catch (error) { | ||
console.error('Error fetching options:', error); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use showError instead of console.error |
||
// You can also display an error message to the user or take any other necessary action | ||
} | ||
}; | ||
|
||
fetchOptionsList(); | ||
}, [environments]); | ||
|
||
useEffect(() => { | ||
dispatch({ type: DeploymentConfigStateActionTypes.reset }) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,7 +306,7 @@ export default function AppOverview({ appMetaInfo, getAppMetaInfoRes, filteredEn | |
{createdBy} | ||
</div> | ||
</div> | ||
{appType === 'app' && gitMaterials.length > 0 && ( | ||
{appType === 'app' && gitMaterials && gitMaterials.length > 0 && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can write as gitMaterials?.length > 0 |
||
<div> | ||
<div className="fs-13 fw-4 lh-20 cn-7 mb-4">Code source</div> | ||
<div className="flexbox-col dc__gap-4"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -539,6 +539,7 @@ export const Details: React.FC<DetailsType> = ({ | |
}, [isPollingRequired]) | ||
|
||
async function handleHibernate(e) { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this extra line |
||
try { | ||
setHibernating(true) | ||
const isUnHibernateReq = ['hibernating', 'hibernated'].includes( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,65 +88,88 @@ export default function AppDetailsPage({ isV2 }: AppDetailsProps) { | |
}, [appId]) | ||
|
||
const getSavedFilterData = async (groupId?: number): Promise<void> => { | ||
setSelectedAppList([]) | ||
setAppListLoading(true) | ||
setGroupFilterOptions([]) | ||
const { result } = await getEnvGroupList(+appId, FilterParentType.app) | ||
if (result) { | ||
const _groupFilterOption = [] | ||
let _selectedGroup | ||
setSelectedAppList([]); | ||
setAppListLoading(true); | ||
setGroupFilterOptions([]); | ||
|
||
try { | ||
const { result } = await getEnvGroupList(+appId, FilterParentType.app); | ||
|
||
if (result) { | ||
const _groupFilterOption = []; | ||
let _selectedGroup; | ||
|
||
for (const group of result) { | ||
const processedGroupData = { | ||
value: group.id.toString(), | ||
label: group.name, | ||
// @ts-ignore | ||
appIds: group.resourceIds, | ||
description: group.description, | ||
} | ||
_groupFilterOption.push(processedGroupData) | ||
if (groupId && groupId === group.id) { | ||
_selectedGroup = processedGroupData | ||
} | ||
const processedGroupData = { | ||
value: group.id.toString(), | ||
label: group.name, | ||
// @ts-ignore | ||
appIds: group.resourceIds, | ||
description: group.description, | ||
}; | ||
|
||
_groupFilterOption.push(processedGroupData); | ||
|
||
if (groupId && groupId === group.id) { | ||
_selectedGroup = processedGroupData; | ||
} | ||
} | ||
|
||
if (_selectedGroup) { | ||
const selectedAppsMap: Record<string, boolean> = {} | ||
const groupAppIds = _selectedGroup?.appIds || [] | ||
for (const appId of groupAppIds) { | ||
selectedAppsMap[appId] = true | ||
} | ||
setSelectedAppList(appListOptions.filter((app) => selectedAppsMap[app.value])) | ||
setSelectedGroupFilter([_selectedGroup]) | ||
const selectedAppsMap: Record<string, boolean> = {}; | ||
const groupAppIds = _selectedGroup?.appIds || []; | ||
|
||
for (const appId of groupAppIds) { | ||
selectedAppsMap[appId] = true; | ||
} | ||
|
||
setSelectedAppList(appListOptions.filter((app) => selectedAppsMap[app.value])); | ||
setSelectedGroupFilter([_selectedGroup]); | ||
} else { | ||
setSelectedAppList([]) | ||
setSelectedGroupFilter([]) | ||
setSelectedAppList([]); | ||
setSelectedGroupFilter([]); | ||
} | ||
_groupFilterOption.sort(sortOptionsByLabel) | ||
setGroupFilterOptions(_groupFilterOption) | ||
|
||
_groupFilterOption.sort(sortOptionsByLabel); | ||
setGroupFilterOptions(_groupFilterOption); | ||
} | ||
} catch (error) { | ||
console.error('Error fetching environment group list:', error); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can import showError and use it to show error in toast by calling showError(error) |
||
// Handle the error appropriately, e.g., show an error message to the user | ||
} finally { | ||
setAppListLoading(false); | ||
} | ||
setAppListLoading(false) | ||
} | ||
}; | ||
|
||
const getAppListData = async (): Promise<void> => { | ||
setSelectedAppList([]) | ||
setAppListLoading(true) | ||
const { result } = await getAppOtherEnvironmentMin(appId) | ||
if (result?.length) { | ||
const getAppListData = async (): Promise<void> => { | ||
setSelectedAppList([]); | ||
setAppListLoading(true); | ||
try { //added try and catch block for error handling | ||
const { result } = await getAppOtherEnvironmentMin(appId); | ||
|
||
if (result?.length) { | ||
setAppListOptions( | ||
result | ||
.map((app): OptionType => { | ||
return { | ||
value: `${app.environmentId}`, | ||
label: app.environmentName, | ||
} | ||
}) | ||
.sort(sortOptionsByLabel), | ||
) | ||
result | ||
.map((app): OptionType => { | ||
return { | ||
value: `${app.environmentId}`, | ||
label: app.environmentName, | ||
}; | ||
}) | ||
.sort(sortOptionsByLabel) | ||
); | ||
} | ||
} catch (error) { | ||
console.error('Error fetching app list data:', error); | ||
// You can also display an error message to the user or take any other necessary action | ||
} finally { | ||
setAppListLoading(false); | ||
} | ||
setAppListLoading(false) | ||
} | ||
}; | ||
|
||
const getAppMetaInfoRes = async (): Promise<AppMetaInfo> => { | ||
try { | ||
try { //added try and catch block | ||
const { result } = await getAppMetaInfo(Number(appId)) | ||
if (result) { | ||
setAppName(result.appName) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1194,7 +1194,10 @@ export const getDeploymentAppType = ( | |
return allowedDeploymentTypes[0] | ||
} | ||
|
||
export const hasApproverAccess = (email: string, approverList: string[]): boolean => { | ||
export const hasApproverAccess = (email: string = '', approverList: string[]= []): boolean => {// added null check for email and approverList | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can remove equating to '' since already checking in first if block. And can remove this comment since it is clear from the if block. |
||
if(!email ||!approverList) { | ||
return false | ||
} | ||
let hasAccess = false | ||
if (approverList?.length > 0) { | ||
for (const approver of approverList) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have we reversed the if condition, earlier we were exiting from block in case of truthy now we are nesting the conditions inside this block.