Skip to content

Proof of concept for licensing #3008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add LicenseBanner that calls xservice
  • Loading branch information
presleyp committed Jul 15, 2022
commit 9aa9f04c81efb7f76a22630a51cbe3a7834b7491
20 changes: 20 additions & 0 deletions site/src/components/LicenseBanner/LicenseBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useActor } from "@xstate/react"
import { useContext, useEffect } from "react"
import { XServiceContext } from "../../xServices/StateContext"

export const LicenseBanner: React.FC = () => {
const xServices = useContext(XServiceContext)
const [licenseState, licenseSend] = useActor(xServices.licenseXService)
const warnings = licenseState.context.licenseData.warnings

/** Gets license data on app mount because LicenseBanner is mounted in App */
useEffect(() => {
licenseSend("GET_LICENSE_DATA")
}, [licenseSend])

if (warnings) {
return <div>{warnings.map((warning, i) => <p key={`${i}`}>{warning}</p>)}</div>
} else {
return null
}
}