Skip to content

mini app explicitly defaults to full screen #46

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

Merged
merged 2 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion .idea/react-components-viewer.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-component-viewer",
"version": "0.23.0",
"version": "0.24.0",
"description": "React Component to help with development of other React components",
"repository": {
"type": "git",
Expand Down
15 changes: 15 additions & 0 deletions src/components/viewer/ComponentViewerStateCreator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ describe('ComponentViewerStateCreator', () => {
'&_rcv_dropdown_brand=brand_one&_rcv_dropdown_services=fake_services');
});

it('should preserve false state of the full screen toggle', () => {
const stateCreator = new ComponentViewerStateCreator(registries);
const url = stateCreator.buildUrlSearchParams({
registryName: '',
demoName: '',
entryTitle: '',
isFullScreen: false,
isHelpOn: false,
filterText: '',
selectedToolbarItems: {}
});

expect(url).toEqual('_rcv_fs=false');
});

it('should extract toolbar items from url', () => {
const stateCreator = new ComponentViewerStateCreator(registries);
const state = stateCreator.stateFromUrl(
Expand Down
20 changes: 11 additions & 9 deletions src/components/viewer/ComponentViewerStateCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class ComponentViewerStateCreator {

const selectedToolbarItems = extractSelectedToolbarItems();

const fullScreenValue = searchParams.get(queryParamNames.isFullScreen) || 'false';
const fullScreenValue = searchParams.get(queryParamNames.isFullScreen);
const isFullScreen = fullScreenValue === 'true';

const helpOnValue = searchParams.get(queryParamNames.isHelpOn) || 'false';
Expand All @@ -44,7 +44,7 @@ export class ComponentViewerStateCreator {
registryName: miniAppByUrl.registry.name,
demoName: miniAppByUrl.demoEntry.name,
entryTitle: miniAppByUrl.demoEntry.firstEntryTitle,
isFullScreen,
isFullScreen: fullScreenValue === null ? true : isFullScreen,
isHelpOn: isHelpOn,
filterText: '',
selectedToolbarItems
Expand Down Expand Up @@ -87,15 +87,17 @@ export class ComponentViewerStateCreator {
buildUrlSearchParams(state: ComponentViewerState): string {
const searchParams = new URLSearchParams();

Object.keys(state).forEach(k => {
const v = state[k];
Object.keys(state).forEach(key => {
const value = state[key];

if (k === 'selectedToolbarItems') {
const toolbarItems: {[labelKey: string]: string} = v;
Object.keys(v).forEach(dropDownLabelKey => searchParams.set(
if (key === 'selectedToolbarItems') {
const toolbarItems: {[labelKey: string]: string} = value;
Object.keys(value).forEach(dropDownLabelKey => searchParams.set(
queryParamNames.selectedToolbarItemPrefix + dropDownLabelKey, toolbarItems[dropDownLabelKey]));
} else if (v) {
searchParams.set(queryParamNames[k], v.toString());
} else {
if (value || key === 'isFullScreen') {
searchParams.set(queryParamNames[key], value.toString());
}
}
});

Expand Down