-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace daytona-web import source (#8)
Signed-off-by: Zoran Zorica <[email protected]>
- Loading branch information
Showing
4 changed files
with
68 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 31 additions & 31 deletions
62
plugins/daytona/src/components/WorkspaceListComponent/WorkspaceListCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { useApi, SessionState } from "@backstage/core-plugin-api"; | ||
import { AuthCardComponent } from "../AuthCardComponent/AuthCardComponent"; | ||
import { daytonaAuthApiRef } from "@daytonaio/daytona-web"; | ||
import { daytonaAuthApiRef } from "../../definitions"; | ||
import { WorkspaceListComponent } from "./WorkspaceListComponent"; | ||
|
||
export const WorkspaceListCard = () => { | ||
const daytonaAuthApi = useApi(daytonaAuthApiRef); | ||
const [isLoggedIn, setIsLoggedIn] = useState(() => { | ||
// Initialize state based on session storage | ||
return window.sessionStorage.getItem('isDaytonaSignedIn') === 'true'; | ||
const daytonaAuthApi = useApi(daytonaAuthApiRef); | ||
const [isLoggedIn, setIsLoggedIn] = useState(() => { | ||
// Initialize state based on session storage | ||
return window.sessionStorage.getItem('isDaytonaSignedIn') === 'true'; | ||
}); | ||
// window.sessionStorage.setItem('isDaytonaSignedIn', 'false'); | ||
// const isDaytonaSignedIn = window.sessionStorage.getItem('isDaytonaSignedIn') == 'true'; | ||
|
||
useEffect(() => { | ||
const authSubscription = daytonaAuthApi.sessionState$().subscribe(state => { | ||
console.log('isDaytonaSignedIn inside useEffect', state); | ||
if (state === SessionState.SignedIn) { | ||
setIsLoggedIn(true); | ||
window.sessionStorage.setItem('isDaytonaSignedIn', 'true'); | ||
console.log('isDaytonaSignedIn inside if-block', window.sessionStorage.getItem('isDaytonaSignedIn') == 'true'); | ||
} else { | ||
setIsLoggedIn(false); | ||
window.sessionStorage.setItem('isDaytonaSignedIn', 'false'); | ||
} | ||
}); | ||
// window.sessionStorage.setItem('isDaytonaSignedIn', 'false'); | ||
// const isDaytonaSignedIn = window.sessionStorage.getItem('isDaytonaSignedIn') == 'true'; | ||
return () => { | ||
authSubscription.unsubscribe(); | ||
}; | ||
}, [daytonaAuthApi]); | ||
|
||
useEffect(() => { | ||
const authSubscription = daytonaAuthApi.sessionState$().subscribe(state => { | ||
console.log('isDaytonaSignedIn inside useEffect', state); | ||
if (state === SessionState.SignedIn) { | ||
setIsLoggedIn(true); | ||
window.sessionStorage.setItem('isDaytonaSignedIn', 'true'); | ||
console.log('isDaytonaSignedIn inside if-block', window.sessionStorage.getItem('isDaytonaSignedIn') == 'true'); | ||
} else { | ||
setIsLoggedIn(false); | ||
window.sessionStorage.setItem('isDaytonaSignedIn', 'false'); | ||
} | ||
}); | ||
return () => { | ||
authSubscription.unsubscribe(); | ||
}; | ||
}, [daytonaAuthApi]); | ||
// const isDaytonaSignedIn = window.sessionStorage.getItem('isDaytonaSignedIn') == 'true'; | ||
console.log('isDaytonaSignedIn after useEffect', window.sessionStorage.getItem('isDaytonaSignedIn') == 'true'); | ||
|
||
// const isDaytonaSignedIn = window.sessionStorage.getItem('isDaytonaSignedIn') == 'true'; | ||
console.log('isDaytonaSignedIn after useEffect', window.sessionStorage.getItem('isDaytonaSignedIn') == 'true'); | ||
|
||
return ( | ||
<> | ||
return ( | ||
<> | ||
{isLoggedIn ? <WorkspaceListComponent /> : <AuthCardComponent />} | ||
</> | ||
); | ||
} | ||
</> | ||
); | ||
} |
48 changes: 24 additions & 24 deletions
48
plugins/daytona/src/components/WorkspaceOverviewContent/WorkspaceOverviewCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { useApi, SessionState } from "@backstage/core-plugin-api"; | ||
import { AuthCardComponent } from "../AuthCardComponent"; | ||
import { daytonaAuthApiRef } from "@daytonaio/daytona-web"; | ||
import { daytonaAuthApiRef } from "../../definitions"; | ||
import { WorkspaceOverviewContent } from "./WorkspaceOverviewContent"; | ||
|
||
export const WorkspaceOverviewCard = () => { | ||
const daytonaAuthApi = useApi(daytonaAuthApiRef); | ||
const [isLoggedIn, setIsLoggedIn] = useState(() => { | ||
// Initialize state based on session storage | ||
return window.sessionStorage.getItem('isDaytonaSignedIn') === 'true'; | ||
const daytonaAuthApi = useApi(daytonaAuthApiRef); | ||
const [isLoggedIn, setIsLoggedIn] = useState(() => { | ||
// Initialize state based on session storage | ||
return window.sessionStorage.getItem('isDaytonaSignedIn') === 'true'; | ||
}); | ||
|
||
useEffect(() => { | ||
const authSubscription = daytonaAuthApi.sessionState$().subscribe(state => { | ||
if (state === SessionState.SignedIn) { | ||
setIsLoggedIn(true); | ||
window.sessionStorage.setItem('isDaytonaSignedIn', 'true'); | ||
} else { | ||
setIsLoggedIn(false); | ||
} | ||
}); | ||
return () => { | ||
authSubscription.unsubscribe(); | ||
}; | ||
}, [daytonaAuthApi]); | ||
|
||
useEffect(() => { | ||
const authSubscription = daytonaAuthApi.sessionState$().subscribe(state => { | ||
if (state === SessionState.SignedIn) { | ||
setIsLoggedIn(true); | ||
window.sessionStorage.setItem('isDaytonaSignedIn', 'true'); | ||
} else { | ||
setIsLoggedIn(false); | ||
} | ||
}); | ||
return () => { | ||
authSubscription.unsubscribe(); | ||
}; | ||
}, [daytonaAuthApi]); | ||
|
||
return ( | ||
<> | ||
return ( | ||
<> | ||
{isLoggedIn ? <WorkspaceOverviewContent /> : <AuthCardComponent />} | ||
</> | ||
); | ||
} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters