Skip to content

Commit

Permalink
extracted predefined values andsorted
Browse files Browse the repository at this point in the history
  • Loading branch information
Nina Ciocanu committed May 7, 2024
1 parent a2f1a7c commit 21be45a
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 39 deletions.
22 changes: 22 additions & 0 deletions src/view/actions/constants/mediaContentTypes.js
@@ -0,0 +1,22 @@
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
export default {
vod: "Video-on-demand",
live: "Live streaming",
linear: "Linear playback of the media asset",
ugc: "User-generated content",
dvod: "Downloaded video-on-demand",
radio: "Radio show",
podcast: "Podcast",
audiobook: "Audiobook",
song: "Song"
};
1 change: 0 additions & 1 deletion src/view/actions/constants/mediaEventTypes.js
Expand Up @@ -28,5 +28,4 @@ export default {
"media.sessionComplete": "Media sessionComplete",
"media.sessionEnd": "Media sessionEnd",
"media.statesUpdate": "Media statesUpdate"
// "media.downloaded": "Media downloaded content" - this doesn't make sense in web
};
17 changes: 17 additions & 0 deletions src/view/actions/constants/mediaShowTypes.js
@@ -0,0 +1,17 @@
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
export default {
0: "Full episode",
1: "Preview/trailer",
2: "Clip",
3: "Other"
};
18 changes: 18 additions & 0 deletions src/view/actions/constants/mediaStates.js
@@ -0,0 +1,18 @@
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
export default {
closedCaptioning: "Closed captioning",
fullScreen: "Full screen",
inFocus: "In focus",
mute: "Mute",
pictureInPicture: "Picture in picture"
};
59 changes: 21 additions & 38 deletions src/view/actions/sendStreamingMediaEvent.jsx
Expand Up @@ -24,6 +24,18 @@ import checkbox from "../forms/checkbox";
import objectArray from "../forms/objectArray";
import section from "../forms/section";
import dataElement from "../forms/dataElement";
import mediaStates from "./constants/mediaStates";
import mediaContentTypes from "./constants/mediaContentTypes";
import mediaShowTypes from "./constants/mediaShowTypes";

const getSortedInputItems = mapItems => {
return Object.keys(mapItems)
.reduce((items, key) => {
items.push({ value: key, label: mapItems[key] });
return items;
}, [])
.sort((a, b) => a.label.localeCompare(b.label));
};

const wrapGetInitialValues =
getInitialValues =>
Expand Down Expand Up @@ -356,7 +368,7 @@ const stateUpdateDetailsSection = section({ label: "State Update Details" }, [
label: "States started",
learnMoreUrl:
"https://experienceleague.adobe.com/en/docs/experience-platform/xdm/data-types/list-of-states-start-collection",
singularLabel: "State",
singularLabel: "State that started",
description: "Create an array of states that started.",
dataElementDescription:
"Provide a data element that returns an array of states that started.",
Expand All @@ -366,13 +378,7 @@ const stateUpdateDetailsSection = section({ label: "State Update Details" }, [
comboBox({
name: "name",
description: "Select or enter the state that started.",
items: [
{ value: "fullScreen", label: "Full screen" },
{ value: "closedCaptioning", label: "Closed captioning" },
{ value: "mute", label: "Mute" },
{ value: "pictureInPicture", label: "Picture in picture" },
{ value: "inFocus", label: "In focus" }
],
items: getSortedInputItems(mediaStates),
allowsCustomValue: true
})
]
Expand All @@ -383,7 +389,7 @@ const stateUpdateDetailsSection = section({ label: "State Update Details" }, [
label: "States ended",
learnMoreUrl:
"https://experienceleague.adobe.com/en/docs/experience-platform/xdm/data-types/list-of-states-end-collection",
singularLabel: "State",
singularLabel: "State that ended",
description: "Create an array of states that ended.",
dataElementDescription:
"Provide a data element that returns an array of states that ended.",
Expand All @@ -393,13 +399,7 @@ const stateUpdateDetailsSection = section({ label: "State Update Details" }, [
comboBox({
name: "name",
description: "Select or enter the state that ended.",
items: [
{ value: "fullScreen", label: "Full screen" },
{ value: "closedCaptioning", label: "Closed captioning" },
{ value: "mute", label: "Mute" },
{ value: "pictureInPicture", label: "Picture in picture" },
{ value: "inFocus", label: "In focus" }
],
items: getSortedInputItems(mediaStates),
allowsCustomValue: true
})
]
Expand Down Expand Up @@ -431,17 +431,7 @@ const sessionDetailsSection = dataElementSection(
"Enter the content type of the media session. Select a predefined value or enter a custom value.",
dataElementDescription:
"Provide a data element that returns to a content type.",
items: [
{ value: "vod", label: "Video-on-demand" },
{ value: "live", label: "Live streaming" },
{ value: "linear", label: "Linear playback of the media asset" },
{ value: "ugc", label: "User-generated content" },
{ value: "dvod", label: "Downloaded video-on-demand" },
{ value: "radio", label: "Radio show" },
{ value: "podcast", label: "Podcast" },
{ value: "audiobook", label: "Audiobook" },
{ value: "song", label: "Song" }
],
items: getSortedInputItems(mediaContentTypes),
allowsCustomValue: true
}),
textField({
Expand Down Expand Up @@ -565,12 +555,7 @@ const sessionDetailsSection = dataElementSection(
"Type of content, expressed as an integer between 0 and 3. Select a predefined value or enter a custom value.",
dataElementDescription:
"Provide a data element that returns a show type.",
items: [
{ value: "0", label: "Full episode" },
{ value: "1", label: "Preview/trailer" },
{ value: "2", label: "Clip" },
{ value: "3", label: "Other" }
],
items: getSortedInputItems(mediaShowTypes),
allowsCustomValue: true
}),
textField({
Expand Down Expand Up @@ -740,10 +725,7 @@ const sendEventForm = form(
label: "Media event type",
description: "Select your media event type.",
isRequired: true,
items: Object.keys(mediaEventTypes).reduce((items, key) => {
items.push({ value: key, label: mediaEventTypes[key] });
return items;
}, [])
items: getSortedInputItems(mediaEventTypes)
}),
textField({
name: "playerId",
Expand All @@ -768,7 +750,8 @@ const sendEventForm = form(
name: "playhead",
label: "Playhead",
isRequired: true,
description: "Provide a data element that returns the playback playhead in seconds.",
description:
"Provide a data element that returns the playback playhead in seconds.",
tokenize: false
})
]
Expand Down

0 comments on commit 21be45a

Please sign in to comment.