From ad908024d4c7c4d07d7643eace268e33690cc705 Mon Sep 17 00:00:00 2001 From: Filippo Ledda Date: Tue, 5 Mar 2024 19:02:52 +0100 Subject: [PATCH] Fix resources issue --- .../components/workspace/drawer/WorkspaceInteractions.tsx | 2 ++ .../workspace/drawer/WorkspaceResourceBrowser.tsx | 6 ++++-- applications/osb-portal/src/pages/WorkspacePage.tsx | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/applications/osb-portal/src/components/workspace/drawer/WorkspaceInteractions.tsx b/applications/osb-portal/src/components/workspace/drawer/WorkspaceInteractions.tsx index 97a5058c..20b041d6 100644 --- a/applications/osb-portal/src/components/workspace/drawer/WorkspaceInteractions.tsx +++ b/applications/osb-portal/src/components/workspace/drawer/WorkspaceInteractions.tsx @@ -113,6 +113,7 @@ interface WorkspaceProps { refreshWorkspacePage?: () => void; currentResource: WorkspaceResource; hideTabs: Boolean; + staticPage: Boolean; } const SidebarBox = styled(Box)(({ theme }) => ({ @@ -292,6 +293,7 @@ export default (props: WorkspaceProps | any) => { currentResource={props.currentResource} refreshWorkspace={handleWorkspaceRefresh} user={props.user} + staticPage={props.staticPage} /> diff --git a/applications/osb-portal/src/components/workspace/drawer/WorkspaceResourceBrowser.tsx b/applications/osb-portal/src/components/workspace/drawer/WorkspaceResourceBrowser.tsx index 4788ffa2..bf804a31 100644 --- a/applications/osb-portal/src/components/workspace/drawer/WorkspaceResourceBrowser.tsx +++ b/applications/osb-portal/src/components/workspace/drawer/WorkspaceResourceBrowser.tsx @@ -134,7 +134,7 @@ const OSBResourceItem = (props: { const handleOpenResource = (e: any | Event) => { e.preventDefault(); - const isApplicationChanged = currentResource.type.application.code !== resource.type.application.code; + const isApplicationChanged = currentResource && currentResource.type.application.code !== resource.type.application.code; if(isApplicationChanged && window.confirm("Unsaved changes will be lost: are you sure you want to change application?")){ navigate( {pathname: `/workspaces/open/${workspaceId}/${resource.type.application.code}`, @@ -197,6 +197,7 @@ interface WorkspaceProps { refreshWorkspace: () => void; currentResource: WorkspaceResource; user: UserInfo; + staticPage: Boolean; } const WorkspaceResourceBrowser = (props: WorkspaceProps) => { @@ -277,7 +278,8 @@ const WorkspaceResourceBrowser = (props: WorkspaceProps) => { currentResourceId={currentResourceId} Icon={Icon} workspaceId={workspace.id} - currentResource={currentResource} + currentResource={props.staticPage ? null: currentResource} + /> ))} diff --git a/applications/osb-portal/src/pages/WorkspacePage.tsx b/applications/osb-portal/src/pages/WorkspacePage.tsx index 0f72536c..a5aa9d61 100644 --- a/applications/osb-portal/src/pages/WorkspacePage.tsx +++ b/applications/osb-portal/src/pages/WorkspacePage.tsx @@ -240,6 +240,7 @@ export const WorkspacePage = (props: any) => { user={user} open={true} hideTabs={true} + staticPage={true} refreshWorkspace={props.refreshWorkspace} currentResource={ workspace.lastOpen || workspace.resources[0]