Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 35 additions & 27 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -180,41 +180,49 @@ export default function App() {
}
}, [])

const serviceWorkerTimeout = (()=> {
const parsedTimeout = parseInt(window._env_.SERVICE_WORKER_TIMEOUT, 10)

const serviceWorkerTimeout = (() => {
const parsedTimeout = parseInt(window._env_.SERVICE_WORKER_TIMEOUT, 10);
if (parsedTimeout) {
return parsedTimeout
return parsedTimeout;
}

return 1
})()

const {
return 1;
})();
const {
needRefresh: [needRefresh],
updateServiceWorker,
} = useRegisterSW({
} = useRegisterSW({
onRegisteredSW(swUrl, r) {
console.log(`Service Worker at: ${swUrl}`)
r &&
setInterval(async () => {
if (!(!r.installing && navigator)) return
if ('connection' in navigator && !navigator.onLine) return
const resp = await fetch(swUrl, {
cache: 'no-store',
headers: {
cache: 'no-store',
'cache-control': 'no-cache',
},
})

if (resp?.status === 200) await r.update()
}, serviceWorkerTimeout * 1000 * 60)
console.log(`Service Worker at: ${swUrl}`);
if (r) {
setInterval(async () => {
if (!r.installing && navigator) {
Copy link
Member

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.

if ('connection' in navigator && !navigator.onLine) return;

try { //added try and catch for error handling
const resp = await fetch(swUrl, {
cache: 'no-store',
headers: {
cache: 'no-store',
'cache-control': 'no-cache',
},
});

if (resp?.status === 200) await r.update();
} catch (error) {
console.error('Error updating service worker:', error);
}
}
}, serviceWorkerTimeout * 1000 * 60);
}
},
onRegisterError(error) {
console.log('SW registration error', error)
console.log('SW registration error', error);
},
})
});


function update() {
updateServiceWorker(true)
2 changes: 1 addition & 1 deletion src/components/ClusterNodes/ClusterTerminal.tsx
Original file line number Diff line number Diff line change
@@ -535,7 +535,7 @@ const ClusterTerminal = ({
`user/terminal/get?namespace=${selectedNamespace.value}&shellName=${
selectedTerminalType.value
}&terminalAccessId=${terminalAccessIdRef.current}&containerName=${
resourceData?.containers?.[0].containerName || ''
resourceData?.containers?.[0]?.containerName || '' // this is the extra check for the case when we have no containers in the pod
}`,
terminalAccessIdRef.current,
window?._env_?.CLUSTER_TERMINAL_CONNECTION_RETRY_COUNT || 7,
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);
Copy link
Member

Choose a reason for hiding this comment

The 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 })
2 changes: 1 addition & 1 deletion src/components/app/Overview/Overview.tsx
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 && (
Copy link
Member

Choose a reason for hiding this comment

The 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">
2 changes: 1 addition & 1 deletion src/components/app/details/appConfig/AppConfig.tsx
Original file line number Diff line number Diff line change
@@ -175,7 +175,7 @@ export default function AppConfig({ appName, isJobView, filteredEnvIds }: AppCon
setState((prevState) => {
return {
...prevState,
canDeleteApp: response.result.workflows.length === 0,
canDeleteApp: response.result.workflows?.length === 0,//# here is the extra check
workflowsRes: response.result,
}
})
1 change: 1 addition & 0 deletions src/components/app/details/appDetails/AppDetails.tsx
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) {

Copy link
Member

Choose a reason for hiding this comment

The 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(
119 changes: 71 additions & 48 deletions src/components/app/details/main.tsx
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);
Copy link
Member

Choose a reason for hiding this comment

The 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)
5 changes: 4 additions & 1 deletion src/components/common/helpers/Helpers.tsx
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
Copy link
Member

Choose a reason for hiding this comment

The 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) {
Loading