@@ -6,7 +6,7 @@ import {useAppStore} from "../stores/AppStore.js";
66import { ApplicationConnectionHeader } from "../components/ApplicationConnectionHeader.jsx" ;
77import { Overview } from "../connection/Overview.jsx" ;
88import { Testing } from "../connection/Testing.jsx" ;
9- import { arp , getApplicationById , getIdentityProviders , privacy } from "../api/index.js" ;
9+ import { getApplicationById , getIdentityProviders } from "../api/index.js" ;
1010import { Loader } from "@surfnet/sds" ;
1111import { APPLICATION_STATUSES , CONNECTION_STATUSES , ENVIRONMENTS , PROTOCOLS } from "../utils/Manage.js" ;
1212import { AppInformation } from "../connection/AppInformation.jsx" ;
@@ -30,22 +30,22 @@ const protocolOptions = Object.values(PROTOCOLS).map(protocol => ({
3030
3131export const Connection = ( ) => {
3232 const { applicationId, tab = "overview" } = useParams ( ) ;
33- const { user, currentOrganization , arp, privacy} = useAppStore ( state => state ) ;
33+ const { user, arp, privacy} = useAppStore ( state => state ) ;
3434
3535 const [ application , setApplication ] = useState ( { } ) ;
36- const [ arpInfo , setArpInfo ] = useState ( { profiles : [ ] , attributes : [ ] } ) ;
3736 const [ profileOptions , setProfileOptions ] = useState ( [ ] ) ;
3837 const [ currentTab , setCurrentTab ] = useState ( tab ) ;
3938 const [ connection , setConnection ] = useState ( null ) ;
4039 const [ identityProviders , setIdentityProviders ] = useState ( [ ] ) ;
4140 const [ prodIdentityProviders , setProdIdentityProviders ] = useState ( [ ] ) ;
4241 const [ loading , setLoading ] = useState ( true ) ;
4342 const [ refreshApp , setRefreshApp ] = useState ( 0 ) ;
43+ const [ dirty , setDirty ] = useState ( false ) ;
4444
4545 const navigate = useNavigate ( ) ;
4646
4747 useEffect ( ( ) => {
48- getApplicationById ( applicationId )
48+ getApplicationById ( applicationId )
4949 . then ( res => {
5050 //For convenience editing
5151 const options = arp . profiles . map ( profile => ( {
@@ -64,8 +64,8 @@ export const Connection = () => {
6464 breadcrumbPaths : [
6565 { path : "/home" , value : I18n . t ( "breadCrumb.access" ) , menuItemName : "yourApps" } ,
6666 {
67- path : `/organization/${ currentOrganization . id } ` ,
68- value : currentOrganization . name ,
67+ path : `/organization/${ application . organization . id } ` ,
68+ value : application . organization . name ,
6969 menuItemName : "yourApps"
7070 } ,
7171 { path : `/application/${ applicationId } ` , value : I18n . t ( "breadCrumb.applications" ) } ,
@@ -114,6 +114,7 @@ export const Connection = () => {
114114 . then ( res => {
115115 setApplication ( convertServerApplicationToClient ( res , protocolOptions , profileOptions , arp ) ) ;
116116 setConnection ( null ) ;
117+ setDirty ( false ) ;
117118 setLoading ( false ) ;
118119 setRefreshApp ( new Date ( ) . getTime ( ) ) ;
119120 } )
@@ -146,6 +147,9 @@ export const Connection = () => {
146147 }
147148
148149 const changeTab = newTab => {
150+ if ( dirty ) {
151+ refresh ( )
152+ }
149153 if ( currentTab === "testing" || currentTab === "prod" ) {
150154 //force the overview
151155 setConnection ( null ) ;
@@ -179,6 +183,7 @@ export const Connection = () => {
179183 profileOptions = { profileOptions }
180184 identityProviders = { identityProviders }
181185 isProduction = { false }
186+ setDirty = { setDirty }
182187 />
183188 }
184189 case "prod" : {
@@ -193,6 +198,7 @@ export const Connection = () => {
193198 profileOptions = { profileOptions }
194199 identityProviders = { prodIdentityProviders }
195200 isProduction = { true }
201+ setDirty = { setDirty }
196202 />
197203 }
198204 case "application" : {
@@ -226,6 +232,7 @@ export const Connection = () => {
226232 throw new Error ( `Unknown tab; ${ currentTab } ` )
227233 }
228234 }
235+
229236 if ( loading ) {
230237 return < Loader />
231238 }
0 commit comments