-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: marcosgvieira <marcos.vieira@camunda.com>
- Loading branch information
1 parent
a55d273
commit 3f884eb
Showing
12 changed files
with
156 additions
and
117 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
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright Camunda Services GmbH | ||
* | ||
* BY INSTALLING, DOWNLOADING, ACCESSING, USING, OR DISTRIBUTING THE SOFTWARE ("USE"), YOU INDICATE YOUR ACCEPTANCE TO AND ARE ENTERING INTO A CONTRACT WITH, THE LICENSOR ON THE TERMS SET OUT IN THIS AGREEMENT. IF YOU DO NOT AGREE TO THESE TERMS, YOU MUST NOT USE THE SOFTWARE. IF YOU ARE RECEIVING THE SOFTWARE ON BEHALF OF A LEGAL ENTITY, YOU REPRESENT AND WARRANT THAT YOU HAVE THE ACTUAL AUTHORITY TO AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT ON BEHALF OF SUCH ENTITY. | ||
* "Licensee" means you, an individual, or the entity on whose behalf you receive the Software. | ||
* | ||
* Permission is hereby granted, free of charge, to the Licensee obtaining a copy of this Software and associated documentation files to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject in each case to the following conditions: | ||
* Condition 1: If the Licensee distributes the Software or any derivative works of the Software, the Licensee must attach this Agreement. | ||
* Condition 2: Without limiting other conditions in this Agreement, the grant of rights is solely for non-production use as defined below. | ||
* "Non-production use" means any use of the Software that is not directly related to creating products, services, or systems that generate revenue or other direct or indirect economic benefits. Examples of permitted non-production use include personal use, educational use, research, and development. Examples of prohibited production use include, without limitation, use for commercial, for-profit, or publicly accessible systems or use for commercial or revenue-generating purposes. | ||
* | ||
* If the Licensee is in breach of the Conditions, this Agreement, including the rights granted under it, will automatically terminate with immediate effect. | ||
* | ||
* SUBJECT AS SET OUT BELOW, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* NOTHING IN THIS AGREEMENT EXCLUDES OR RESTRICTS A PARTY’S LIABILITY FOR (A) DEATH OR PERSONAL INJURY CAUSED BY THAT PARTY’S NEGLIGENCE, (B) FRAUD, OR (C) ANY OTHER LIABILITY TO THE EXTENT THAT IT CANNOT BE LAWFULLY EXCLUDED OR RESTRICTED. | ||
*/ | ||
|
||
import {C3UserConfigurationProvider} from '@camunda/camunda-composite-components'; | ||
import {C3ThemePersister} from 'C3ThemePersister'; | ||
import {api} from 'modules/api'; | ||
import {getStage} from 'modules/utils/getStage'; | ||
import {useEffect, useState} from 'react'; | ||
|
||
const IS_SAAS = typeof window.clientConfig?.organizationId === 'string'; | ||
const STAGE = getStage(window.location.host); | ||
|
||
async function fetchToken() { | ||
try { | ||
const response = await fetch(api.getSaasUserToken()); | ||
|
||
if (!response.ok) { | ||
console.error('Failed to fetch user token', response); | ||
return ''; | ||
} | ||
|
||
const token = await response.json(); | ||
return token; | ||
} catch (error) { | ||
console.error('Failed to fetch user token', error); | ||
return ''; | ||
} | ||
} | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const C3Provider: React.FC<Props> = ({children}) => { | ||
const [token, setToken] = useState<string | null>(null); | ||
useEffect(() => { | ||
async function init() { | ||
if (IS_SAAS) { | ||
setToken(await fetchToken()); | ||
} | ||
} | ||
|
||
init(); | ||
}, []); | ||
|
||
if (token === null) { | ||
return children; | ||
} | ||
|
||
return ( | ||
<C3UserConfigurationProvider | ||
activeOrganizationId={window.clientConfig?.organizationId ?? ''} | ||
userToken={token} | ||
getNewUserToken={fetchToken} | ||
currentClusterUuid={window.clientConfig?.clusterId ?? ''} | ||
currentApp="tasklist" | ||
stage={STAGE === 'unknown' ? 'dev' : STAGE} | ||
handleTheme | ||
> | ||
<C3ThemePersister /> | ||
{children} | ||
</C3UserConfigurationProvider> | ||
); | ||
}; | ||
|
||
export {C3Provider}; |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Camunda Services GmbH | ||
* | ||
* BY INSTALLING, DOWNLOADING, ACCESSING, USING, OR DISTRIBUTING THE SOFTWARE ("USE"), YOU INDICATE YOUR ACCEPTANCE TO AND ARE ENTERING INTO A CONTRACT WITH, THE LICENSOR ON THE TERMS SET OUT IN THIS AGREEMENT. IF YOU DO NOT AGREE TO THESE TERMS, YOU MUST NOT USE THE SOFTWARE. IF YOU ARE RECEIVING THE SOFTWARE ON BEHALF OF A LEGAL ENTITY, YOU REPRESENT AND WARRANT THAT YOU HAVE THE ACTUAL AUTHORITY TO AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT ON BEHALF OF SUCH ENTITY. | ||
* "Licensee" means you, an individual, or the entity on whose behalf you receive the Software. | ||
* | ||
* Permission is hereby granted, free of charge, to the Licensee obtaining a copy of this Software and associated documentation files to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject in each case to the following conditions: | ||
* Condition 1: If the Licensee distributes the Software or any derivative works of the Software, the Licensee must attach this Agreement. | ||
* Condition 2: Without limiting other conditions in this Agreement, the grant of rights is solely for non-production use as defined below. | ||
* "Non-production use" means any use of the Software that is not directly related to creating products, services, or systems that generate revenue or other direct or indirect economic benefits. Examples of permitted non-production use include personal use, educational use, research, and development. Examples of prohibited production use include, without limitation, use for commercial, for-profit, or publicly accessible systems or use for commercial or revenue-generating purposes. | ||
* | ||
* If the Licensee is in breach of the Conditions, this Agreement, including the rights granted under it, will automatically terminate with immediate effect. | ||
* | ||
* SUBJECT AS SET OUT BELOW, THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* NOTHING IN THIS AGREEMENT EXCLUDES OR RESTRICTS A PARTY’S LIABILITY FOR (A) DEATH OR PERSONAL INJURY CAUSED BY THAT PARTY’S NEGLIGENCE, (B) FRAUD, OR (C) ANY OTHER LIABILITY TO THE EXTENT THAT IT CANNOT BE LAWFULLY EXCLUDED OR RESTRICTED. | ||
*/ | ||
|
||
import {useC3Profile} from '@camunda/camunda-composite-components'; | ||
import {themeStore} from 'modules/stores/theme'; | ||
import {useEffect} from 'react'; | ||
|
||
const C3ThemePersister: React.FC = () => { | ||
const {theme} = useC3Profile(); | ||
|
||
useEffect(() => { | ||
themeStore.changeTheme(theme); | ||
}, [theme]); | ||
|
||
return null; | ||
}; | ||
|
||
export {C3ThemePersister}; |
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
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
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
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
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
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
File renamed without changes.
File renamed without changes.
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