Skip to content

Commit

Permalink
fix: remove inline script from index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
sabhas committed Jul 26, 2022
1 parent efab88b commit 170a9e9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
23 changes: 17 additions & 6 deletions src/context/sasContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@ interface SASContextProps {
startupData: any
}

declare global {
interface Window {
sasjsConfig: SASjsConfig
}
}
const sasElement = document.querySelector('sasjs')

const useComputeApi = sasElement?.getAttribute('useComputeApi')

const sasjsConfig = window.sasjsConfig as SASjsConfig
const sasjsConfig = {
serverUrl: sasElement?.getAttribute('serverUrl') ?? undefined,
appLoc: sasElement?.getAttribute('appLoc') ?? undefined,
serverType: sasElement?.getAttribute('serverType'),
debug: sasElement?.getAttribute('debug') === 'true',
loginMechanism: sasElement?.getAttribute('loginMechanism') ?? undefined,
useComputeApi:
useComputeApi === 'true'
? true
: useComputeApi === 'false'
? false
: useComputeApi,
contextName: sasElement?.getAttribute('contextName') ?? undefined
} as SASjsConfig

const sasService = new SASjs(sasjsConfig)

Expand Down
14 changes: 5 additions & 9 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<sasjs
appLoc="/Public/app/react-seed-app"
serverType="SASJS"
debug="false"
></sasjs>
<div id="root"></div>
<!--
This HTML file is a template.
Expand All @@ -43,14 +48,5 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script>
window.sasjsConfig = {
serverUrl: 'https://sas.analytium.co.uk:5000',
appLoc: '/Public/app/react-seed-app',
serverType: 'SASJS',
debug: false,
loginMechanism: 'Redirected'
}
</script>
</body>
</html>
3 changes: 2 additions & 1 deletion src/layouts/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ const Main = (props) => {
/>
</div>
{!(
window.sasjsConfig.loginMechanism === 'Redirected' ||
document.querySelector('sasjs')?.getAttribute('loginMechanism') ===
'Redirected' ||
sasContext.isUserLoggedIn ||
sasContext.checkingSession
) && <LoginComponent />}
Expand Down

0 comments on commit 170a9e9

Please sign in to comment.