From 190391e493ceca9f03baa4cddc0149fc63376043 Mon Sep 17 00:00:00 2001 From: Vladyslav Matsiiako Date: Mon, 13 Feb 2023 17:27:21 -0800 Subject: [PATCH] Fixed bugs with organizations and sidebars --- .../src/components/basic/table/UserTable.tsx | 19 ++++++------- .../OrganizationContext.tsx | 2 +- .../src/ee/components/ActivitySideBar.tsx | 28 ++++++++----------- frontend/src/layouts/AppLayout/AppLayout.tsx | 4 +-- 4 files changed, 23 insertions(+), 30 deletions(-) diff --git a/frontend/src/components/basic/table/UserTable.tsx b/frontend/src/components/basic/table/UserTable.tsx index c14d77b08..a541c0f01 100644 --- a/frontend/src/components/basic/table/UserTable.tsx +++ b/frontend/src/components/basic/table/UserTable.tsx @@ -38,7 +38,6 @@ const UserTable = ({ userData, changeData, myUser, filter, resendInvite, isOrg } const router = useRouter(); const [myRole, setMyRole] = useState('member'); const [userProjectMemberships, setUserProjectMemberships] = useState([]); - console.log(123, userData) const workspaceId = router.query.id as string; // Delete the row in the table (e.g. a user) @@ -198,15 +197,15 @@ const UserTable = ({ userData, changeData, myUser, filter, resendInvite, isOrg } - - {userProjectMemberships[row.userId] - ? userProjectMemberships[row.userId]?.map((project: any) => ( -
- {project.name} -
- )) - : This user isn't part of any projects yet.} - +
+ {userProjectMemberships[row.userId] + ? userProjectMemberships[row.userId]?.map((project: any) => ( +
+ {project.name} +
+ )) + : This user isn't part of any projects yet.} +
{myUser !== row.email && diff --git a/frontend/src/context/OrganizationContext/OrganizationContext.tsx b/frontend/src/context/OrganizationContext/OrganizationContext.tsx index 31a97d07c..e22e6783b 100644 --- a/frontend/src/context/OrganizationContext/OrganizationContext.tsx +++ b/frontend/src/context/OrganizationContext/OrganizationContext.tsx @@ -27,7 +27,7 @@ export const OrgProvider = ({ children }: Props): JSX.Element => { const value = useMemo( () => ({ orgs: userOrgs, - currentOrg: (userOrgs || []).find(({ _id }) => _id === currentWsOrgID), + currentOrg: (userOrgs || []).find(({ _id }) => _id === currentWsOrgID) || (userOrgs || [])[0], isLoading }), [currentWsOrgID, userOrgs, isLoading] diff --git a/frontend/src/ee/components/ActivitySideBar.tsx b/frontend/src/ee/components/ActivitySideBar.tsx index be2f09e0d..775d08cf7 100644 --- a/frontend/src/ee/components/ActivitySideBar.tsx +++ b/frontend/src/ee/components/ActivitySideBar.tsx @@ -9,7 +9,6 @@ import getActionData from '@app/ee/api/secrets/GetActionData'; import patienceDiff from '@app/ee/utilities/findTextDifferences'; import getLatestFileKey from '@app/pages/api/workspace/getLatestFileKey'; -import DashboardInputField from '../../components/dashboard/DashboardInputField'; import { decryptAssymmetric, decryptSymmetric @@ -130,7 +129,7 @@ const ActivitySideBar = ({ toggleSidebar, currentAction }: SideBarProps) => {
{isLoading ? (
@@ -142,7 +141,7 @@ const ActivitySideBar = ({ toggleSidebar, currentAction }: SideBarProps) => { />
) : ( -
+

{t(`activity:event.${actionMetaData?.name}`)} @@ -157,7 +156,7 @@ const ActivitySideBar = ({ toggleSidebar, currentAction }: SideBarProps) => {

-
+
{(actionMetaData?.name === 'readSecrets' || actionMetaData?.name === 'addSecrets' || actionMetaData?.name === 'deleteSecrets') && @@ -166,14 +165,9 @@ const ActivitySideBar = ({ toggleSidebar, currentAction }: SideBarProps) => {
{item.newSecretVersion.key}
- {}} - type="value" - position={1} - value={item.newSecretVersion.value} - isDuplicate={false} - blurred={false} - /> +
+ {item.newSecretVersion.value ? {item.newSecretVersion.value} : EMPTY } +
))} {actionMetaData?.name === 'updateSecrets' && @@ -182,8 +176,8 @@ const ActivitySideBar = ({ toggleSidebar, currentAction }: SideBarProps) => {
{item.newSecretVersion.key}
-
-
+
+
-{' '} {patienceDiff( item.oldSecretVersion.value.split(''), @@ -194,14 +188,14 @@ const ActivitySideBar = ({ toggleSidebar, currentAction }: SideBarProps) => { character.bIndex !== -1 && ( {character.line} ) )}
-
+
+{' '} {patienceDiff( item.oldSecretVersion.value.split(''), @@ -212,7 +206,7 @@ const ActivitySideBar = ({ toggleSidebar, currentAction }: SideBarProps) => { character.aIndex !== -1 && ( {character.line} diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsx index 1a2dc2cfa..644e5eba4 100644 --- a/frontend/src/layouts/AppLayout/AppLayout.tsx +++ b/frontend/src/layouts/AppLayout/AppLayout.tsx @@ -97,7 +97,7 @@ export const AppLayout = ({ children }: LayoutProps) => { const putUserInWorkSpace = async () => { if (tempLocalStorage('orgData.id') === '') { const userOrgs = await getOrganizations(); - localStorage.setItem('orgData.id', userOrgs[0]._id); + localStorage.setItem('orgData.id', userOrgs[0]?._id); } const orgUserProjects = await getOrganizationUserProjects({ @@ -123,7 +123,7 @@ export const AppLayout = ({ children }: LayoutProps) => { // If a user is not a member of a workspace they are trying to access, just push them to one of theirs if ( - !['callback', 'create', 'authorize'].includes(intendedWorkspaceId) && + !['callback', 'create', 'authorize'].includes(intendedWorkspaceId) && userWorkspaces[0]?._id !== undefined && !userWorkspaces .map((workspace: { _id: string }) => workspace._id) .includes(intendedWorkspaceId)