graphql-engine/frontend/libs/nx/storybook-addon-console-env/prod/preset.js
Nicolas Inchauspe c8acf12d4f console: apply new sidebar design
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7635
GitOrigin-RevId: 5f4b24d30d39a2cf2c8eb4a0d0ccc60161389303
2023-02-15 12:38:16 +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>
`,
};