From 3e0d4cb70a03ca2cb94eb69c173a1a4528844c42 Mon Sep 17 00:00:00 2001 From: Animesh Das Date: Fri, 17 Feb 2023 00:31:00 +0530 Subject: [PATCH 1/2] fixed infinite loading in dashboard --- frontend/src/pages/dashboard/[id].tsx | 3 +++ .../views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/frontend/src/pages/dashboard/[id].tsx b/frontend/src/pages/dashboard/[id].tsx index d0dda0240..740a763af 100644 --- a/frontend/src/pages/dashboard/[id].tsx +++ b/frontend/src/pages/dashboard/[id].tsx @@ -188,6 +188,9 @@ export default function Dashboard() { useEffect(() => { (async () => { + if(router.isReady && workspaceId === "undefined"){ + router.push('/noprojects'); + } try { const tempNumSnapshots = await getProjectSercetSnapshotsCount({ workspaceId diff --git a/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx b/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx index aadabf088..17acaff33 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx @@ -123,6 +123,9 @@ export const ProjectSettingsPage = () => { await deleteWorkspace.mutateAsync({ workspaceID }); // redirect user to first workspace user is part of const ws = workspaces.find(({ _id }) => _id !== workspaceID); + if(!ws){ + router.push("/noprojects"); + } router.push(`/dashboard/${ws?._id}`); createNotification({ text: 'Successfully deleted workspace', From 54e2b661bc6a92a3e1fe80351d7eb5de561b7092 Mon Sep 17 00:00:00 2001 From: Animesh Das Date: Fri, 17 Feb 2023 14:20:58 +0530 Subject: [PATCH 2/2] ran prettier to fix indentation --- frontend/src/pages/dashboard/[id].tsx | 131 +++++++++++------- .../ProjectSettingsPage.tsx | 10 +- 2 files changed, 83 insertions(+), 58 deletions(-) diff --git a/frontend/src/pages/dashboard/[id].tsx b/frontend/src/pages/dashboard/[id].tsx index 83ee3be2f..70b92cf11 100644 --- a/frontend/src/pages/dashboard/[id].tsx +++ b/frontend/src/pages/dashboard/[id].tsx @@ -138,7 +138,7 @@ export default function Dashboard() { const [dropZoneData, setDropZoneData] = useState(); const [projectTags, setProjectTags] = useState([]); - const { hasUnsavedChanges, setHasUnsavedChanges } = useLeaveConfirm({initialValue: false}); + const { hasUnsavedChanges, setHasUnsavedChanges } = useLeaveConfirm({ initialValue: false }); const { t } = useTranslation(); const { createNotification } = useNotificationContext(); @@ -188,7 +188,7 @@ export default function Dashboard() { useEffect(() => { (async () => { - if(router.isReady && workspaceId === "undefined"){ + if (router.isReady && workspaceId === 'undefined') { router.push('/noprojects'); } try { @@ -288,7 +288,7 @@ export default function Dashboard() { valueOverride: undefined, comment: '', tags: [] - }, + } ]); }; @@ -476,7 +476,8 @@ export default function Dashboard() { initDataPoint.key || newOverrides!.filter((dataPoint) => dataPoint.id === initDataPoint.id)[0] .comment !== initDataPoint.comment || - newOverrides!.filter((dataPoint) => dataPoint.id === initDataPoint.id)[0]?.tags !== initDataPoint?.tags) + newOverrides!.filter((dataPoint) => dataPoint.id === initDataPoint.id)[0]?.tags !== + initDataPoint?.tags) ) .map((secret) => secret.id) .includes(newDataPoint.id) @@ -504,7 +505,11 @@ export default function Dashboard() { }); if (secrets) await addSecrets({ secrets, env: selectedEnv.slug, workspaceId }); } - if (selectedEnv && !selectedEnv.isReadDenied && secretsToBeUpdated.concat(overridesToBeUpdated).length > 0) { + if ( + selectedEnv && + !selectedEnv.isReadDenied && + secretsToBeUpdated.concat(overridesToBeUpdated).length > 0 + ) { const secrets = await encryptSecrets({ secretsToEncrypt: secretsToBeUpdated.concat(overridesToBeUpdated), workspaceId, @@ -563,11 +568,13 @@ export default function Dashboard() { }; const handleOnEnvironmentChange = (envName: string) => { - if(hasUnsavedChanges) { + if (hasUnsavedChanges) { if (!window.confirm(leaveConfirmDefaultMessage)) return; } - const selectedWorkspaceEnv = workspaceEnvs.find(({ name }: { name: string }) => envName === name) || { + const selectedWorkspaceEnv = workspaceEnvs.find( + ({ name }: { name: string }) => envName === name + ) || { name: 'unknown', slug: 'unknown', isWriteDenied: false, @@ -656,16 +663,18 @@ export default function Dashboard() {
- {!selectedEnv?.isReadDenied &&
{(data?.length !== 0 || hasUnsavedChanges) && !snapshotData && (
@@ -799,50 +808,61 @@ export default function Dashboard() { className="mt-1 max-h-[calc(100vh-280px)] overflow-hidden overflow-y-scroll no-scrollbar no-scrollbar::-webkit-scrollbar border border-mineshaft-600 rounded-md" >
-
+
-
0
- Key - {!snapshotData && reorderRows(1)} - > - {sortMethod === 'alphabetical' ? : } - } +
+ 0 +
+ Key + {!snapshotData && ( + reorderRows(1)} + > + {sortMethod === 'alphabetical' ? ( + + ) : ( + + )} + + )}
-
-
Value
+
+
+ Value +
-
Comment
+
+ Comment +
-
Tags
+
+ Tags +
-
-
+
+
null} role="none" onClick={() => {}} className="invisible group-hover:visible" > - +
@@ -850,10 +870,16 @@ export default function Dashboard() {
{!snapshotData && data - ?.filter((row) => - row.key?.toUpperCase().includes(searchKeys.toUpperCase()) - || row.tags?.map(tag => tag.name).join(" ")?.toUpperCase().includes(searchKeys.toUpperCase()) - || row.comment?.toUpperCase().includes(searchKeys.toUpperCase())) + ?.filter( + (row) => + row.key?.toUpperCase().includes(searchKeys.toUpperCase()) || + row.tags + ?.map((tag) => tag.name) + .join(' ') + ?.toUpperCase() + .includes(searchKeys.toUpperCase()) || + row.comment?.toUpperCase().includes(searchKeys.toUpperCase()) + ) .filter((row) => !sharedToHide.includes(row.id)) .filter((row) => row.value !== undefined) .map((keyPair) => ( @@ -919,15 +945,15 @@ export default function Dashboard() { tags={projectTags} /> ))} -
-
-
@@ -974,8 +1000,7 @@ export default function Dashboard() { - row.id === sidebarSecretId && row.value !== undefined + (row: SecretDataProps) => row.id === sidebarSecretId && row.value !== undefined )} modifyKey={listenChangeKey} modifyValue={listenChangeValue} diff --git a/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx b/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx index 17acaff33..d57d76217 100644 --- a/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx +++ b/frontend/src/views/Settings/ProjectSettingsPage/ProjectSettingsPage.tsx @@ -58,7 +58,7 @@ export const ProjectSettingsPage = () => { const renameWorkspace = useRenameWorkspace(); const toggleAutoCapitalization = useToggleAutoCapitalization(); - + const deleteWorkspace = useDeleteWorkspace(); // env crud operation const createWsEnv = useCreateWsEnvironment(); @@ -97,7 +97,7 @@ export const ProjectSettingsPage = () => { } }; - const onAutoCapitalizationToggle = async (state: boolean) => { + const onAutoCapitalizationToggle = async (state: boolean) => { try { await toggleAutoCapitalization.mutateAsync({ workspaceID, @@ -123,8 +123,8 @@ export const ProjectSettingsPage = () => { await deleteWorkspace.mutateAsync({ workspaceID }); // redirect user to first workspace user is part of const ws = workspaces.find(({ _id }) => _id !== workspaceID); - if(!ws){ - router.push("/noprojects"); + if (!ws) { + router.push('/noprojects'); } router.push(`/dashboard/${ws?._id}`); createNotification({ @@ -250,7 +250,7 @@ export const ProjectSettingsPage = () => { const res = await createWsTag.mutateAsync({ workspaceID, tagName: name, - tagSlug: name.replace(" ", "_") + tagSlug: name.replace(' ', '_') }); createNotification({ text: 'Successfully created a tag',