Skip to content

Commit

Permalink
Align with naming in app-hmdb: "from XP param" instead of "request is…
Browse files Browse the repository at this point in the history
… from XP attribute"
  • Loading branch information
espen42 committed Oct 14, 2021
1 parent 9cf5003 commit 1c979fe
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/enonic-connection-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const nextDomain = "http://localhost:3000";
/** Where requests from XP CS previews (requesting next renderings) will come from */
const xpPreviewOrigin = apiDomain;

const requestIsFromXpAttribute = '__fromXp__';
const FROM_XP_PARAM = '__fromXp__';


const siteUrl = `${apiDomain}/${siteRoot}`;
Expand All @@ -44,7 +44,7 @@ module.exports = {
siteName,
siteRoot,
contentApiUrl,
requestIsFromXpAttribute,
fromXpParam: FROM_XP_PARAM,

appKey,
appKeyUnderscored: appKey.replace(/\./g, '_'),
Expand Down
4 changes: 2 additions & 2 deletions src/pages/[[...contentPath]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import buildContentFetcher, { ContentFetcher } from "../shared/data/fetchContent";
import { querySelector, variablesGetterSelector } from "../selectors/queries";
import { propsProcessorSelector, commonPropsProcessor } from "../selectors/propsProcessors";
import enonicConnectionConfig, {requestIsFromXpAttribute} from "../enonic-connection-config";
import enonicConnectionConfig, {fromXpParam} from "../enonic-connection-config";

import BasePage from "../components/BasePage";

Expand All @@ -18,7 +18,7 @@ export type Context = {

// The XP preview proxy injects the '__fromXp__' parameter. It's used here
// to make some adaptations in the rendered and returned code, adapting to some postprocessing needed for the CS preview to work.
[requestIsFromXpAttribute:string]: string|boolean
[fromXpParam:string]: string|boolean
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/selectors/propsProcessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/


import {appKey, getPublicAssetUrl, requestIsFromXpAttribute} from '../enonic-connection-config';
import {appKey, getPublicAssetUrl, fromXpParam} from '../enonic-connection-config';

import {processPersonProps} from "./propsProcessors/processPerson";
import {processFolderProps} from "./propsProcessors/processFolder";
Expand All @@ -42,7 +42,7 @@ export const propsProcessorSelector: PropsProcessorSelector = {


export const commonPropsProcessor: PropsProcessorFunc = (content: any, context?: Context) => {
const requestIsFromXp = !!context?.query[requestIsFromXpAttribute];
const requestIsFromXp = !!context?.query[fromXpParam];
const logoUrl = getPublicAssetUrl('images/xp-shield.svg', requestIsFromXp);

return {
Expand Down
4 changes: 2 additions & 2 deletions src/selectors/propsProcessors/processFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { List } from "../queries/getList";
import { getLocalPagePathFromXpPath } from "./paths/paths";
import {PropsProcessorFunc} from "../propsProcessors";
import {Context} from "../../pages/[[...contentPath]]";
import {requestIsFromXpAttribute} from "../../enonic-connection-config";
import {fromXpParam} from "../../enonic-connection-config";


export type DisplayableList = {
Expand All @@ -18,7 +18,7 @@ export type DisplaybleChild = {


export const processFolderProps: PropsProcessorFunc = (list: List, context?: Context): DisplayableList => {
const requestIsFromXp = !!context?.query[requestIsFromXpAttribute];
const requestIsFromXp = !!context?.query[fromXpParam];
return {
displayName: list.displayName,
children: (list.children)
Expand Down
4 changes: 2 additions & 2 deletions src/selectors/propsProcessors/processMovie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {CastItem, Movie} from "../queries/getMovie";
import { getLocalPagePathFromXpPath } from "./paths/paths";
import {PropsProcessorFunc} from "../propsProcessors";
import {Context} from "../../pages/[[...contentPath]]";
import {requestIsFromXpAttribute} from "../../enonic-connection-config";
import {fromXpParam} from "../../enonic-connection-config";



Expand Down Expand Up @@ -61,7 +61,7 @@ const getCast = (cast: CastItem | CastItem[] | undefined, requestIsFromXp: boole


export const processMovieProps: PropsProcessorFunc = (movie:Movie, context?: Context): DisplayableMovie => {
const requestIsFromXp = !!context?.query[requestIsFromXpAttribute];
const requestIsFromXp = !!context?.query[fromXpParam];
const movieData = movie.data || {};

return {
Expand Down
4 changes: 2 additions & 2 deletions src/selectors/propsProcessors/processPerson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DisplayablePhoto, getFirstPhotoData } from "./images/images";
import { getLocalPagePathFromXpPath } from "./paths/paths";
import {Context} from "../../pages/[[...contentPath]]";
import {PropsProcessorFunc} from "../propsProcessors";
import {requestIsFromXpAttribute} from "../../enonic-connection-config";
import {fromXpParam} from "../../enonic-connection-config";



Expand All @@ -16,7 +16,7 @@ export type DisplayablePerson = {


export const processPersonProps: PropsProcessorFunc = (person: Person, context?: Context): DisplayablePerson => {
const requestIsFromXp = !!context?.query[requestIsFromXpAttribute];
const requestIsFromXp = !!context?.query[fromXpParam];
return {
displayName: person.displayName,
bio: person.data?.bio || null,
Expand Down

0 comments on commit 1c979fe

Please sign in to comment.