Skip to content

Commit

Permalink
Fix display of slots
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Dec 30, 2022
1 parent 7bdbd31 commit a7f5a0d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
16 changes: 13 additions & 3 deletions searchlib/components/RenderSlot/RenderSlot.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import React from 'react';
/**
* This is a big "switch"
*/
// import React from 'react';

import { SEARCH_STATES } from '@eeacms/search/constants';
import { SEARCH_STATE_IDS } from '@eeacms/search/constants';

export default function RenderSlot(props) {
const { slotName, searchState } = props;
return props[slotName] ? props[slotName] : null;
const anyStateId = `${slotName}-${SEARCH_STATE_IDS.any}`;
const byStateId = `${slotName}-${SEARCH_STATE_IDS[searchState]}`;

const anyState = props[anyStateId];
const byState = props[byStateId];

const res = props[slotName] || byState || anyState || null;
return res;
}
4 changes: 3 additions & 1 deletion src/SearchBlock/BlockContainer/BlockContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export default function BlockContainer(props) {
);

return mode === 'view' ? (
<RenderBlocks content={content} metadata={metadata} location={location} />
data ? (
<RenderBlocks content={content} metadata={metadata} location={location} />
) : null
) : data ? (
<BlockEdit
id={block}
Expand Down
5 changes: 4 additions & 1 deletion src/SearchBlock/templates/FullView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { SEARCH_STATES, SLOTS, SearchApp } from '@eeacms/search';
import { SlotEditor, BlockContainer } from './../BlockContainer';

const slotCombinations = SLOTS.reduce(
(acc, slot) => [...acc, ...SEARCH_STATES.map((state) => `${slot}-${state}`)],
(acc, slot) => [
...acc,
...SEARCH_STATES.map((state) => `${slot}-${state[0]}`),
],
[],
);

Expand Down

0 comments on commit a7f5a0d

Please sign in to comment.