From 18fbe82535e599e11b236c94325aa540684b84a9 Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Tue, 17 Jan 2023 19:03:43 -0800 Subject: [PATCH] Fixed minor bugs during code cleaning --- frontend/src/components/basic/Layout.tsx | 5 ++-- frontend/src/components/basic/Listbox.tsx | 24 +++++++++---------- .../basic/dialog/AddApiKeyDialog.tsx | 2 +- .../basic/dialog/AddProjectMemberDialog.tsx | 2 +- .../basic/dialog/AddServiceTokenDialog.tsx | 4 ++-- .../src/components/basic/table/UserTable.tsx | 4 ++-- .../components/integrations/Integration.tsx | 8 +++---- .../src/components/utilities/attemptLogin.ts | 6 ++++- frontend/src/pages/dashboard/[id].tsx | 6 ++--- frontend/src/pages/login.tsx | 2 +- frontend/src/pages/noprojects.tsx | 2 +- frontend/src/pages/settings/org/[id].tsx | 4 ++-- frontend/src/pages/settings/personal/[id].tsx | 2 +- 13 files changed, 38 insertions(+), 33 deletions(-) diff --git a/frontend/src/components/basic/Layout.tsx b/frontend/src/components/basic/Layout.tsx index 19a7fbc936..a3d6092a1a 100644 --- a/frontend/src/components/basic/Layout.tsx +++ b/frontend/src/components/basic/Layout.tsx @@ -190,7 +190,8 @@ const Layout = ({ children }: LayoutProps) => { userWorkspaces.length === 0 && router.asPath !== '/noprojects' && !router.asPath.includes('home') && - !router.asPath.includes('settings') + !router.asPath.includes('settings') || + router.asPath === '/dashboard/undefined' ) { router.push('/noprojects'); } else if (router.asPath !== '/noprojects') { @@ -259,7 +260,7 @@ const Layout = ({ children }: LayoutProps) => { {Object.keys(workspaceMapping).length > 0 ? ( void; data: string[] | null; text?: string; @@ -15,7 +15,7 @@ interface ListBoxProps { /** * This is the component that we use for drop down lists. * @param {object} obj - * @param {string} obj.selected - the item that is currently selected + * @param {string} obj.isSelected - the item that is currently selected * @param {function} obj.onChange - what happends if you select the item inside a list * @param {string[]} obj.data - all the options available * @param {string} obj.text - the text that shows us in front of the select option @@ -23,7 +23,7 @@ interface ListBoxProps { * @returns */ const ListBox = ({ - selected, + isSelected, onChange, data, text, @@ -31,7 +31,7 @@ const ListBox = ({ isFull }: ListBoxProps): JSX.Element => { return ( - +
{text} - + {' '} - {selected} + {isSelected}
{data && ( @@ -62,22 +62,22 @@ const ListBox = ({ {data.map((person, personIdx) => ( - `my-0.5 relative cursor-default select-none py-2 pl-10 pr-4 rounded-md capitalize ${ - isSelected ? 'bg-white/10 text-gray-400 font-bold' : '' + className={({ active, selected }) => + `my-0.5 relative cursor-default select-none py-2 pl-10 pr-4 rounded-md ${ + selected ? 'bg-white/10 text-gray-400 font-bold' : '' } ${ - active && !isSelected + active && !selected ? 'bg-white/5 text-mineshaft-200 cursor-pointer' : 'text-gray-400' } ` } value={person} > - {({ selected: isSelected }) => ( + {({ selected }) => ( <> {person} diff --git a/frontend/src/components/basic/dialog/AddApiKeyDialog.tsx b/frontend/src/components/basic/dialog/AddApiKeyDialog.tsx index 6956b9a7c0..67f0c1f1fa 100644 --- a/frontend/src/components/basic/dialog/AddApiKeyDialog.tsx +++ b/frontend/src/components/basic/dialog/AddApiKeyDialog.tsx @@ -126,7 +126,7 @@ const AddApiKeyDialog = ({
{data?.length > 0 && ( - + )}
diff --git a/frontend/src/components/basic/dialog/AddServiceTokenDialog.tsx b/frontend/src/components/basic/dialog/AddServiceTokenDialog.tsx index 646b5bf4e1..d2126b3e74 100644 --- a/frontend/src/components/basic/dialog/AddServiceTokenDialog.tsx +++ b/frontend/src/components/basic/dialog/AddServiceTokenDialog.tsx @@ -170,7 +170,7 @@ const AddServiceTokenDialog = ({
handleRoleUpdate(index, e)} data={ myRole === 'owner' ? ['owner', 'admin', 'member'] : ['admin', 'member'] @@ -163,7 +163,7 @@ const UserTable = ({ userData, changeData, myUser, filter, resendInvite, isOrg } row.status !== 'invited' && row.status !== 'verified' && ( { throw new Error('Function not implemented.'); diff --git a/frontend/src/components/integrations/Integration.tsx b/frontend/src/components/integrations/Integration.tsx index 62b44d420b..38b005844a 100644 --- a/frontend/src/components/integrations/Integration.tsx +++ b/frontend/src/components/integrations/Integration.tsx @@ -94,7 +94,7 @@ const Integration = ({ integration, environments = [] }: Props) => {
ENVIRONMENT
@@ -110,7 +110,7 @@ const Integration = ({ integration, environments = [] }: Props) => { ? ['Production', 'Deploy previews', 'Branch deploys', 'Local development'] : null } - selected={integrationContext} + isSelected={integrationContext} onChange={setIntegrationContext} />
@@ -134,7 +134,7 @@ const Integration = ({ integration, environments = [] }: Props) => {

ENVIRONMENT

name) : null} - selected={integrationEnvironment.name} + isSelected={integrationEnvironment.name} onChange={(envName) => setIntegrationEnvironment( environments.find(({ name }) => envName === name) || { @@ -159,7 +159,7 @@ const Integration = ({ integration, environments = [] }: Props) => {
APP
app.name) : null} - selected={integrationApp} + isSelected={integrationApp} onChange={(app) => { setIntegrationApp(app); }} diff --git a/frontend/src/components/utilities/attemptLogin.ts b/frontend/src/components/utilities/attemptLogin.ts index 05c3fbb904..acc2b67fea 100644 --- a/frontend/src/components/utilities/attemptLogin.ts +++ b/frontend/src/components/utilities/attemptLogin.ts @@ -204,7 +204,11 @@ const attemptLogin = async ( } if (isLogin) { - router.push(`/dashboard/${localStorage.getItem('projectData.id')}`); + if (localStorage.getItem('projectData.id') !== "undefined") { + router.push(`/dashboard/${localStorage.getItem('projectData.id')}`); + } else { + router.push("/noprojects"); + } } } catch (error) { console.log(error); diff --git a/frontend/src/pages/dashboard/[id].tsx b/frontend/src/pages/dashboard/[id].tsx index 1052a14f54..6b0ce53ae2 100644 --- a/frontend/src/pages/dashboard/[id].tsx +++ b/frontend/src/pages/dashboard/[id].tsx @@ -564,7 +564,7 @@ export default function Dashboard() {
{!snapshotData && data?.length === 0 && ( name)} onChange={(envName) => setSelectedEnv( @@ -644,7 +644,7 @@ export default function Dashboard() { <> {!snapshotData ? ( name)} onChange={(envName) => setSelectedEnv( @@ -657,7 +657,7 @@ export default function Dashboard() { /> ) : ( name)} onChange={(envName) => setSelectedSnapshotEnv( diff --git a/frontend/src/pages/login.tsx b/frontend/src/pages/login.tsx index 0589870395..571a636f77 100644 --- a/frontend/src/pages/login.tsx +++ b/frontend/src/pages/login.tsx @@ -151,7 +151,7 @@ export default function Login() {
- You are not part of any projects in this organization yet. When you do, they will appear + You are not part of any projects in this organization yet. When you are, they will appear here.
diff --git a/frontend/src/pages/settings/org/[id].tsx b/frontend/src/pages/settings/org/[id].tsx index ff2657e6dd..15fcf07cf5 100644 --- a/frontend/src/pages/settings/org/[id].tsx +++ b/frontend/src/pages/settings/org/[id].tsx @@ -72,7 +72,7 @@ export default function SettingsOrg() { key: guidGenerator(), firstName: orgUser.user?.firstName, lastName: orgUser.user?.lastName, - email: orgUser.user?.email === null ? orgUser.inviteEmail : orgUser.user?.email, + email: orgUser.user?.email == null ? orgUser.inviteEmail : orgUser.user?.email, role: orgUser?.role, status: orgUser?.status, userId: orgUser.user?._id, @@ -115,7 +115,7 @@ export default function SettingsOrg() { }; const submitAddUserModal = async (newUserEmail: string) => { - await addUserToOrg(email, localStorage.getItem('orgData.id') as string); + await addUserToOrg(newUserEmail, localStorage.getItem('orgData.id') as string); setEmail(''); setIsAddUserOpen(false); router.reload(); diff --git a/frontend/src/pages/settings/personal/[id].tsx b/frontend/src/pages/settings/personal/[id].tsx index 72f57f1550..7d015ca407 100644 --- a/frontend/src/pages/settings/personal/[id].tsx +++ b/frontend/src/pages/settings/personal/[id].tsx @@ -93,7 +93,7 @@ export default function PersonalSettings() {