Skip to content

Commit

Permalink
Merge branch 'main' into BC-5119-Prevent-creating-new-neXboards
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaellinaresxk authored Nov 16, 2023
2 parents f08f565 + bc0df6f commit 25da5c8
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 7 deletions.
16 changes: 15 additions & 1 deletion ansible/roles/schulcloud-client-core/templates/deployment.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ metadata:
namespace: {{ NAMESPACE }}
labels:
app: client
app.kubernetes.io/part-of: schulcloud-verbund
app.kubernetes.io/version: {{ SCHULCLOUD_CLIENT_IMAGE_TAG }}
app.kubernetes.io/name: client
app.kubernetes.io/component: client
app.kubernetes.io/managed-by: ansible
git.branch: {{ SCHULCLOUD_CLIENT_BRANCH_NAME }}
git.repo: {{ SCHULCLOUD_CLIENT_REPO_NAME }}
spec:
replicas: {{ CLIENT_REPLICAS|default("1", true) }}
strategy:
Expand All @@ -21,9 +28,16 @@ spec:
metadata:
labels:
app: client
app.kubernetes.io/part-of: schulcloud-verbund
app.kubernetes.io/version: {{ SCHULCLOUD_CLIENT_IMAGE_TAG }}
app.kubernetes.io/name: client
app.kubernetes.io/component: client
app.kubernetes.io/managed-by: ansible
git.branch: {{ SCHULCLOUD_CLIENT_BRANCH_NAME }}
git.repo: {{ SCHULCLOUD_CLIENT_REPO_NAME }}
annotations:
spec:
securityContext:
securityContext:
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
Expand Down
10 changes: 10 additions & 0 deletions config/default.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,16 @@
"default": false,
"description": "Makes the new school administration page the default page"
},
"FEATURE_CLIENT_USER_LOGIN_MIGRATION_ENABLED": {
"type": "boolean",
"default": false,
"description": "Changes the login flow to one that supports user login migrations"
},
"FEATURE_H5P_EDITOR_ENABLED": {
"type": "boolean",
"default": false,
"description": "If enabled, adds H5P editor to course topics."
},
"FEATURE_SHOW_NEW_CLASS_VIEW_ENABLED": {
"type": "boolean",
"default": false,
Expand Down
8 changes: 7 additions & 1 deletion locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -3183,7 +3183,8 @@
"geoGebraWorksheet": "GeoGebra Arbeitsblatt",
"material": "Lern-Material",
"neXboard": "neXboard",
"text": "Text"
"text": "Text",
"h5p": "H5P"
},
"input": {
"brainstormAboutXYZ": "Brainstorming zum Thema XYZ",
Expand Down Expand Up @@ -3224,5 +3225,10 @@
"text": {
"nextcloudLink": "Wir arbeiten an einem neuen Dateibereich. Dort können ab jetzt alle <b>neuen Dateien</b> gespeichert und verwaltet werden (Dateibereich öffnen). Alle Team-Mitglieder haben automatisch Zugriff auf die dort gespeicherten Dateien. Alle bereits <b>bestehenden Dateien</b> in der {{title}} sind weiterhin hier verfügbar."
}
},
"h5p": {
"text": {
"createAfterFirstSave": "H5P Inhalte können erst nach dem ersten Speichern erstellt werden."
}
}
}
8 changes: 7 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3183,7 +3183,8 @@
"geoGebraWorksheet": "GeoGebra worksheet",
"material": "Learning material",
"neXboard": "neXboard",
"text": "Text"
"text": "Text",
"h5p": "H5P"
},
"input": {
"brainstormAboutXYZ": "Brainstorming on the topic XYZ",
Expand Down Expand Up @@ -3224,5 +3225,10 @@
"text": {
"nextcloudLink": "We are working on a new file space. From now on, all <b>new files</b> can be saved and managed there (open file area). All team members automatically have access to the files stored there. All already <b>existing files</b> in the {{title}} are still available here."
}
},
"h5p": {
"text": {
"createAfterFirstSave": "H5P contents can only be created after the first save."
}
}
}
8 changes: 7 additions & 1 deletion locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -3183,7 +3183,8 @@
"geoGebraWorksheet": "Hoja de trabajo de GeoGebra",
"material": "Material de aprendizaje",
"neXboard": "neXboard",
"text": "Texto"
"text": "Texto",
"h5p": "H5P"
},
"input": {
"brainstormAboutXYZ": "Lluvia de ideas sobre el tema XYZ",
Expand Down Expand Up @@ -3224,5 +3225,10 @@
"text": {
"nextcloudLink": "Estamos trabajando en un nuevo espacio de archivos. A partir de ahora, todos los <b>archivos nuevos</b> se pueden guardar y administrar allí (área de archivos abiertos). Todos los miembros del equipo tienen acceso automáticamente a los archivos almacenados allí. Todos los <b>archivos existentes</b> en {{title}} todavía están disponibles aquí."
}
},
"h5p": {
"text": {
"createAfterFirstSave": "Los contenidos H5P solo se pueden crear después del primer guardado."
}
}
}
8 changes: 7 additions & 1 deletion locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,8 @@
"text": "Текст",
"material": "Навчальний матеріал",
"etherpad": "Etherpad",
"neXboard": "neXboard"
"neXboard": "neXboard",
"h5p": "H5P"
},
"label": {
"descriptionEtherpad": "Опис Etherpad",
Expand Down Expand Up @@ -3233,5 +3234,10 @@
"text": {
"nextcloudLink": "Ми працюємо над новим файловим простором. Відтепер усі <b>нові файли</b> можна зберігати та керувати ними (відкрита область файлів). Усі члени команди автоматично мають доступ до файлів, які там зберігаються. Усі <b>існуючі файли</b> в {{title}} все ще доступні тут."
}
},
"h5p": {
"text": {
"createAfterFirstSave": "Вміст H5P можна створити лише після першого збереження."
}
}
}
128 changes: 128 additions & 0 deletions static/scripts/topicEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ class TopicBlockList extends React.Component {
*/
render() {
const neXboardEnabled = ($contentBlocksContainer.data('nexboardenabled') === true);
const h5pEditorEnabled = ($contentBlocksContainer.data('h5peditorenabled') === true);
return (
<div>
<SortableList
Expand Down Expand Up @@ -395,6 +396,15 @@ class TopicBlockList extends React.Component {
onClick={this.addBlock.bind(this, TopicInternal)}>
{`+ ${$t('global.headline.task')}`}
</button>
{h5pEditorEnabled ? <button
type="button"
className="btn btn-secondary"
data-testid="topic-addcontent-h5p-btn"
aria-label={$t('global.button.add')}
onClick={this.addBlock.bind(this, TopicH5P)}>
{`+ ${$t('topic.topicEdit.button.h5p')}`}
</button> : ''
}
</div>
</div>
</div>
Expand Down Expand Up @@ -432,6 +442,8 @@ class TopicBlock extends React.Component {
return TopicNexboard;
case 'Etherpad':
return TopicEtherpad;
case 'H5P':
return TopicH5P;
case 'internal':
return TopicInternal;
}
Expand Down Expand Up @@ -1023,6 +1035,122 @@ class TopicNexboard extends TopicBlock {
}
}

/**
* Class representing H5P
* @extends React.Component<{ content: { contentId: string } }>
*/
class TopicH5P extends TopicBlock {
/**
* Initialize the topic.
* @param {Object} props - Properties from React Component.
*/
constructor(props) {
super(props);
}

/**
* This function returns the name of the component that will be used to render the block in view mode.
*/
static get component() {
return 'H5P';
}

openEditor(id) {
const w = 1280;
const h = 1080;

const x = window.top.outerWidth / 2 + window.top.screenX - (w / 2);
const y = window.top.outerHeight / 2 + window.top.screenY - (h / 2);

const { parentType, parentId } = this.props;

const editorPopup = window.open(
`/h5p/editor/${id ?? ''}?parentType=${parentType}&parentId=${parentId}&inline=1`,
'h5p-editor',
`width=${w}, height=${h}, left=${x}, top=${y},
fullscreen=yes, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=yes`,
);

editorPopup.addEventListener('save-content', (event) => {
this.props.onUpdate({ content: event.detail });
});

editorPopup.focus();
}

/**
* Render the block (an textarea)
*/
render() {
const infoBox = <div class="alert info-custom">
<div className="fa fa-info-circle" />
{$t('h5p.text.createAfterFirstSave')}
</div>;

const saved = !!this.props.parentId;

const { contentId, title, contentType } = this.props.content;

const h5pPreview =
<div className="card-columns">
<div className="card">
<div className="card-block">
<h4 className="card-title">
<a href={`/h5p/player/${contentId}?inline=1`} target="_blank">
{title}
</a>
</h4>
<p className="card-text">{contentType}</p>
</div>
<div className="card-footer">
<a className="btn-edit-h5p" onClick={this.openEditor.bind(this, contentId)} onKeyDown={(e) => {
if (e.key === 'Enter'){
this.openEditor.bind(this, contentId);
}
}}>
<i className="fa fa-edit"></i>
</a>
</div>
<input
type="hidden"
value={contentId}
name={`contents[${this.props.position}][content][contentId]`}
/>
<input
type="hidden"
value={title}
name={`contents[${this.props.position}][content][title]`}
/>
<input
type="hidden"
value={contentType}
name={`contents[${this.props.position}][content][contentType]`}
/>
</div>
</div>;

return (
<div>
{saved || infoBox}
{contentId && h5pPreview}
{!contentId &&
<div>
<button
disabled={!saved}
type="button"
className="btn btn-secondary btn-add"
data-testid="topic-h5p-create-btn"
onClick={this.openEditor.bind(this, contentId)}
>
{`+ ${$t('topic.topicEdit.button.h5p')}`}
</button>
</div>
}
</div>
);
}
}

/**
* Render the virtual React DOM into an <div> in the current page.
*/
Expand Down
9 changes: 9 additions & 0 deletions static/styles/courses/course.scss
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,15 @@
}
}

.btn-edit-h5p {
float: right;
cursor: pointer;

i {
color: $primaryColor;
}
}

.courseGroup {
width: 100%;
list-style: none;
Expand Down
26 changes: 26 additions & 0 deletions views/topic/components/content-H5P.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<h2 class="h4">{{title}}</h2>

{{#if content.contentId}}
<div class="card-columns">
<div class="card">
<div class="card-block">
<h4 class="card-title">
<a
href="/h5p/player/{{content.contentId}}?inline=1"
target="_blank"
class="externalLink"
>
{{content.title}}
</a>
{{#ifeq @root.theme.name "brb"}}
<div class="external-source-warning">
<h5>{{$t "topic._topic.text.warningMain"}}</h5>
<h6>{{$t "topic._topic.text.warningFooter"}}</h6>
</div>
{{/ifeq}}
</h4>
<p class="card-text">{{content.contentType}}</p>
</div>
</div>
</div>
{{/if}}
4 changes: 2 additions & 2 deletions views/topic/edit-topic.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<div class="form-group">
<label>{{$t "topic._topic.label.content" }}</label>
<!-- React Magic -->
<div id="content-blocks" data-testid="nexboardButton" data-value="{{lesson.contents}}" data-parent-id="{{lesson._id}}" data-school-id="{{schoolId}}" data-parent-type="lessons" data-etherpadbaseurl="{{etherpadBaseUrl}}"
data-iscoursegroup="{{courseGroupId}}" {{#unlessEnv "FEATURE_NEXBOARD_ENABLED" "true"}} data-neboardenabled="false" {{/unlessEnv}}></div></div>
<div id="content-blocks" data-testid="content-blocks" data-value="{{lesson.contents}}" data-parent-id="{{lesson._id}}" data-school-id="{{schoolId}}" data-parent-type="lessons" data-etherpadbaseurl="{{etherpadBaseUrl}}"
data-iscoursegroup="{{courseGroupId}}" {{#unlessEnv "FEATURE_NEXBOARD_ENABLED" "true"}} data-nexboardenabled="false" {{/unlessEnv}}></div></div>
</div>
{{#ifneq 0 (arrayLength @root.lessonFilesStorageData.files)}}
<label>{{$t "topic._topic.label.embeddedFiles" }}</label>
Expand Down

0 comments on commit 25da5c8

Please sign in to comment.