graphql-engine/frontend/libs/nx/storybook-addon-console-env/prod/preset.js
Nicolas Beaussart 1c942fe69e frontend: upgrade to storybook 7
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9006
Co-authored-by: Nicolas Inchauspe <710410+nicoinch@users.noreply.github.com>
Co-authored-by: Brandon Simmons <210815+jberryman@users.noreply.github.com>
Co-authored-by: Daniele Cammareri <5709409+dancamma@users.noreply.github.com>
Co-authored-by: Daniel Harvey <4729125+danieljharvey@users.noreply.github.com>
Co-authored-by: Rishichandra Wawhal <27274869+wawhal@users.noreply.github.com>
Co-authored-by: Samir Talwar <47582+SamirTalwar@users.noreply.github.com>
Co-authored-by: Anon Ray <616387+ecthiender@users.noreply.github.com>
Co-authored-by: Tom Harding <6302310+i-am-tom@users.noreply.github.com>
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
Co-authored-by: John Kiragu <11444316+kigsmtua@users.noreply.github.com>
Co-authored-by: Matthew Goodwin <49927862+m4ttheweric@users.noreply.github.com>
Co-authored-by: Divi <32202683+imperfect-fourth@users.noreply.github.com>
Co-authored-by: paritosh-08 <85472423+paritosh-08@users.noreply.github.com>
Co-authored-by: Aaysha <109507451+aayshasura@users.noreply.github.com>
Co-authored-by: Vijay Prasanna <11921040+vijayprasanna13@users.noreply.github.com>
Co-authored-by: Erik Magnusson <32518962+ejkkan@users.noreply.github.com>
GitOrigin-RevId: fe4953db62326fb3a8de118f8bba2add9bb9c2c2
2023-05-09 17:41:28 +00:00

52 lines
1.4 KiB
JavaScript

function config(entry = []) {
return [...entry, require.resolve('./src/lib/preset/preview')];
}
function managerEntries(entry = []) {
return [...entry, require.resolve('./src/lib/preset/manager')];
}
module.exports = {
config,
managerEntries,
previewBody: body => `
${body}
<script>
// Working as iframe and parent are on the same domain
const params = new URL(window.parent.location)?.searchParams;
let consoleType = 'oss';
let adminSecretSet = false;
const updateGlobals = () => {
if (params?.get('globals')) {
consoleType =
params
.get('globals')
.split(';')
.filter(global => global.includes('consoleType'))[0]
?.split(':')[1] || 'oss';
adminSecretSet =
params
.get('globals')
.split(';')
.filter(global => global.includes('adminSecretSet'))[0]
?.split(':')[1] === '!true';
}
window.__env = {
dataApiUrl: 'http://localhost:8080',
apiHost: 'http://localhost',
apiPort: '8080',
nodeEnv: 'development',
consoleType: consoleType === 'cloud-pro' ? 'cloud' : consoleType,
adminSecretSet,
adminSecret: adminSecretSet ? '*******' : null,
tenantID: consoleType === 'cloud-pro' ? 'tenant-id' : null,
};
};
updateGlobals();
</script>
`,
};