Skip to content

Commit 38b1910

Browse files
authored
Merge pull request #1187 from concord-consortium/180951907-display-library-interactive-name-in-authoring
feat: Display Library Interactive name in authoring [PT-#180951907]
2 parents d94a594 + ee684d5 commit 38b1910

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

app/assets/javascripts/lara-typescript.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135926,10 +135926,10 @@ var use_current_user_1 = __webpack_require__(/*! ../common/hooks/use-current-use
135926135926

135927135927
var authored_state_1 = __webpack_require__(/*! ../common/components/authored-state */ "./src/page-item-authoring/common/components/authored-state.tsx");
135928135928

135929-
__webpack_require__(/*! react-tabs/style/react-tabs.css */ "./node_modules/react-tabs/style/react-tabs.css");
135930-
135931135929
var use_authoring_preview_1 = __webpack_require__(/*! ../common/hooks/use-authoring-preview */ "./src/page-item-authoring/common/hooks/use-authoring-preview.ts");
135932135930

135931+
__webpack_require__(/*! react-tabs/style/react-tabs.css */ "./node_modules/react-tabs/style/react-tabs.css");
135932+
135933135933
var ManagedInteractiveAuthoring = function (props) {
135934135934
var libraryInteractive = props.libraryInteractive,
135935135935
managedInteractive = props.managedInteractive,
@@ -135968,7 +135968,14 @@ var ManagedInteractiveAuthoring = function (props) {
135968135968

135969135969
return React.createElement(React.Fragment, null, React.createElement("div", {
135970135970
className: "interactiveItemID"
135971-
}, "InteractiveID: ", managedInteractive.interactive_item_id), React.createElement("fieldset", null, React.createElement("label", {
135971+
}, "InteractiveID: ", managedInteractive.interactive_item_id), React.createElement("div", {
135972+
title: managedInteractive.library_interactive_base_url,
135973+
style: {
135974+
margin: "1rem 0",
135975+
fontWeight: "bold",
135976+
fontSize: "1rem"
135977+
}
135978+
}, managedInteractive.library_interactive_name, " (#", managedInteractive.library_interactive_id, ")"), React.createElement("fieldset", null, React.createElement("label", {
135972135979
htmlFor: "name"
135973135980
}, "Name"), React.createElement("input", {
135974135981
type: "text",

app/models/managed_interactive.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def to_hash
131131
# Deliberately ignoring user (will be set in duplicate)
132132
{
133133
library_interactive_id: library_interactive_id,
134+
library_interactive_name: library_interactive ? library_interactive.name : nil,
135+
library_interactive_base_url: library_interactive ? library_interactive.base_url : nil,
134136
name: name,
135137
url_fragment: url_fragment,
136138
authored_state: authored_state,
@@ -211,7 +213,8 @@ def to_interactive
211213
def duplicate
212214
# Remove linked_interactives from the hash since it can't be mapped to a database column like the other
213215
# properties in the hash can, and so causes an error when we try to create the duplicate interactive.
214-
new_interactive_hash = self.to_hash.except!(:linked_interactives)
216+
# Also remove the library interactive name and base url which are only used by the authoring interface.
217+
new_interactive_hash = self.to_hash.except!(:linked_interactives, :library_interactive_name, :library_interactive_base_url)
215218
# Generate a new object with those values
216219
ManagedInteractive.new(new_interactive_hash)
217220
# N.B. the duplicate hasn't been saved yet
@@ -229,7 +232,8 @@ def report_service_hash
229232
def export
230233
# Remove linked_interactives from the hash so we don't export linked embeddables. The export method
231234
# in LaraSerializationHelper provides special handling for this value. See comment there for more.
232-
hash = to_hash().except!(:linked_interactives)
235+
# Also remove the library interactive name and base url which are only used by the authoring interface.
236+
hash = to_hash().except!(:linked_interactives, :library_interactive_name, :library_interactive_base_url)
233237
hash.delete(:library_interactive_id)
234238
hash[:library_interactive] = library_interactive ? {
235239
data: library_interactive.to_hash()

lara-typescript/src/page-item-authoring/managed-interactives/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { useCurrentUser } from "../common/hooks/use-current-user";
99
import { AuthoredState } from "../common/components/authored-state";
1010
import { AuthoringApiUrls } from "../common/types";
1111
import { ILinkedInteractive } from "../../interactive-api-client";
12+
import { useAuthoringPreview } from "../common/hooks/use-authoring-preview";
1213

1314
import "react-tabs/style/react-tabs.css";
14-
import { useAuthoringPreview } from "../common/hooks/use-authoring-preview";
1515

1616
interface Props {
1717
managedInteractive: IManagedInteractive;
@@ -25,6 +25,8 @@ interface Props {
2525
export interface IManagedInteractive {
2626
id: number;
2727
library_interactive_id: number;
28+
library_interactive_name: string;
29+
library_interactive_base_url: string;
2830
name: string;
2931
url_fragment: string;
3032
authored_state: string;
@@ -90,6 +92,14 @@ export const ManagedInteractiveAuthoring: React.FC<Props> = (props) => {
9092
<div className="interactiveItemID">
9193
InteractiveID: {managedInteractive.interactive_item_id}
9294
</div>
95+
96+
<div
97+
title={managedInteractive.library_interactive_base_url}
98+
style={{margin: "1rem 0", fontWeight: "bold", fontSize: "1rem"}}
99+
>
100+
{managedInteractive.library_interactive_name} (#{managedInteractive.library_interactive_id})
101+
</div>
102+
93103
<fieldset>
94104
<label htmlFor="name">Name</label>
95105
<input

spec/models/managed_interactive_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
it 'has useful values' do
5050
expected = {
5151
library_interactive_id: managed_interactive.library_interactive_id,
52+
library_interactive_name: managed_interactive.library_interactive.name,
53+
library_interactive_base_url: managed_interactive.library_interactive.base_url,
5254
name: managed_interactive.name,
5355
url_fragment: managed_interactive.url_fragment,
5456
authored_state: managed_interactive.authored_state,

0 commit comments

Comments
 (0)