Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDMO 2.2.2 #1153

Merged
merged 9 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [RDMO 2.2.2](https://github.com/rdmorganiser/rdmo/compare/2.2.1...2.2.2) (Oct 18, 2024)

* Fix projects interface when using RDMO with a path (#1152)
* Fix missing (unavailable) catalogs projects interface

## [RDMO 2.2.1](https://github.com/rdmorganiser/rdmo/compare/2.2.0...2.2.1) (Sep 13, 2024)

* Fix import error when allauth is not used (#1145)
Expand Down
2 changes: 1 addition & 1 deletion rdmo/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.2.1"
__version__ = "2.2.2"
9 changes: 9 additions & 0 deletions rdmo/core/assets/js/api/BaseApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ function ValidationError(errors) {
this.errors = errors
}

function BadRequestError(errors) {
this.errors = errors
}

class BaseApi {

static get(url) {
Expand All @@ -23,12 +27,17 @@ class BaseApi {
}).then(response => {
if (response.ok) {
return response.json()
} else if (response.status === 400) {
return response.json().then(errors => {
throw new BadRequestError(errors)
})
} else {
throw new ApiError(response.statusText, response.status)
}
})
}


static post(url, data) {
return fetch(baseUrl + url, {
method: 'POST',
Expand Down
17 changes: 12 additions & 5 deletions rdmo/core/assets/js/components/UploadDropZone.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useDropzone } from 'react-dropzone'
const UploadDropZone = ({ acceptedTypes, onImportFile }) => {
const [errorMessage, setErrorMessage] = useState('')

const { getRootProps, getInputProps } = useDropzone({
const { getRootProps, getInputProps, isDragActive } = useDropzone({
accept: acceptedTypes,
onDropAccepted: acceptedFiles => {
if (acceptedFiles.length > 0) {
Expand All @@ -14,7 +14,6 @@ const UploadDropZone = ({ acceptedTypes, onImportFile }) => {
}
},
onDropRejected: rejectedFiles => {
console.log(rejectedFiles)
setErrorMessage(interpolate(gettext('%s has unsupported file type'), [rejectedFiles[0].path]))
}
})
Expand All @@ -23,9 +22,17 @@ const UploadDropZone = ({ acceptedTypes, onImportFile }) => {
<section className="dropzone-container">
<div {...getRootProps({className: 'dropzone'})}>
<input {...getInputProps()} />
<p className="mb-0">
{gettext('Drag and drop a file here or click to select a file')}
</p>
{
isDragActive ? (
<div>
{gettext('Drop the file here ...')}
</div>
) : (
<div>
{gettext('Drag and drop a file here or click to select a file')}
</div>
)
}
{errorMessage && <div className="alert alert-danger mt-2">{errorMessage}</div>}
</div>
</section>
Expand Down
3 changes: 2 additions & 1 deletion rdmo/core/static/core/css/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ metadata {
.page h2:nth-child(2) {
margin-top: 0;
}
.sidebar h2:first-child {
.sidebar h2:first-child,
.sidebar-mt {
margin-top: 70px;
}

Expand Down
Binary file modified rdmo/locale/de/LC_MESSAGES/djangojs.mo
Binary file not shown.
68 changes: 36 additions & 32 deletions rdmo/locale/de/LC_MESSAGES/djangojs.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: RDMO\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-09-13 12:34+0000\n"
"PO-Revision-Date: 2024-07-23 11:18+0200\n"
"POT-Creation-Date: 2024-10-18 15:56+0200\n"
"PO-Revision-Date: 2024-10-18 15:56+0200\n"
"Last-Translator: Jochen Klar <[email protected]>\n"
"Language-Team: RDMO <[email protected]>\n"
"Language: de\n"
Expand All @@ -28,12 +28,16 @@ msgstr "Speichern"
msgid "Search"
msgstr "Suchen"

#: core/assets/js/components/UploadDropZone.js:18
#: core/assets/js/components/UploadDropZone.js:17
#, javascript-format
msgid "%s has unsupported file type"
msgstr "%s hat einen nicht unterstützten Dateityp"

#: core/assets/js/components/UploadDropZone.js:27
#: core/assets/js/components/UploadDropZone.js:28
msgid "Drop the file here ..."
msgstr "Legen Sie die Datei hier ab ..."

#: core/assets/js/components/UploadDropZone.js:32
msgid "Drag and drop a file here or click to select a file"
msgstr "Datei hierher ziehen oder klicken um Datei auszuwählen"

Expand Down Expand Up @@ -136,8 +140,8 @@ msgstr "Neues Attribut erstellen"
#: management/assets/js/components/edit/EditAttribute.js:53
#, javascript-format
msgid ""
"This attribute will be added to the attribute <code class=\"code-"
"domain\">%s</code>."
"This attribute will be added to the attribute <code class=\"code-domain\">"
"%s</code>."
msgstr ""
"Dieses Attribut wird dem Attribut <code class=\"code-domain\">%s</code> "
"hinzugefügt."
Expand All @@ -154,26 +158,26 @@ msgstr ""
#: management/assets/js/components/edit/EditAttribute.js:68
#, javascript-format
msgid ""
"This attribute will be added to the question set <code class=\"code-"
"questions\">%s</code>."
"This attribute will be added to the question set <code class=\"code-questions"
"\">%s</code>."
msgstr ""
"Dieses Attribut wird dem Fragenset <code class=\"code-questions\">%s</code> "
"hinzugefügt."

#: management/assets/js/components/edit/EditAttribute.js:75
#, javascript-format
msgid ""
"This attribute will be added to the question <code class=\"code-"
"questions\">%s</code>."
"This attribute will be added to the question <code class=\"code-questions\">"
"%s</code>."
msgstr ""
"Dieses Attribut wird der Frage <code class=\"code-questions\">%s</code> "
"hinzugefügt."

#: management/assets/js/components/edit/EditAttribute.js:82
#, javascript-format
msgid ""
"This attribute will be added to the condition <code class=\"code-"
"conditions\">%s</code>."
"This attribute will be added to the condition <code class=\"code-conditions"
"\">%s</code>."
msgstr ""
"Dieses Attribut wird der Bedingung <code class=\"code-conditions\">%s</code> "
"hinzugefügt."
Expand Down Expand Up @@ -219,8 +223,8 @@ msgstr "Neue Bedingung erstellen"
#: management/assets/js/components/edit/EditCondition.js:57
#, javascript-format
msgid ""
"This condition will be added to the option set <code class=\"code-"
"options\">%s</code>."
"This condition will be added to the option set <code class=\"code-options\">"
"%s</code>."
msgstr ""
"Diese Bedingung wird dem Optionenset <code class=\"code-options\">%s</code> "
"hinzugefügt."
Expand All @@ -237,17 +241,17 @@ msgstr ""
#: management/assets/js/components/edit/EditCondition.js:71
#, javascript-format
msgid ""
"This condition will be added to the question set <code class=\"code-"
"questions\">%s</code>."
"This condition will be added to the question set <code class=\"code-questions"
"\">%s</code>."
msgstr ""
"Diese Bedingung wird dem Fragenset <code class=\"code-questions\">%s</code> "
"hinzugefügt."

#: management/assets/js/components/edit/EditCondition.js:78
#, javascript-format
msgid ""
"This condition will be added to the question <code class=\"code-"
"questions\">%s</code>."
"This condition will be added to the question <code class=\"code-questions\">"
"%s</code>."
msgstr ""
"Diese Bedingung wird der Frage <code class=\"code-questions\">%s</code> "
"hinzugefügt."
Expand Down Expand Up @@ -307,8 +311,8 @@ msgstr "Neues Optionenset erstellen"
#: management/assets/js/components/edit/EditOptionSet.js:61
#, javascript-format
msgid ""
"This option set will be added to the question <code class=\"code-"
"questions\">%s</code>."
"This option set will be added to the question <code class=\"code-questions\">"
"%s</code>."
msgstr ""
"Dieser Optionenset wird der Frage <code class=\"code-questions\">%s</code> "
"hinzugefügt."
Expand Down Expand Up @@ -415,8 +419,8 @@ msgstr ""
#: management/assets/js/components/edit/EditQuestion.js:74
#, javascript-format
msgid ""
"This question will be added to the question set <code class=\"code-"
"questions\">%s</code>."
"This question will be added to the question set <code class=\"code-questions"
"\">%s</code>."
msgstr ""
"Diese Frage wird dem Fragenset <code class=\"code-questions\">%s</code> "
"hinzugefügt."
Expand All @@ -439,8 +443,8 @@ msgstr "Fragenset erstellen"
#: management/assets/js/components/edit/EditQuestionSet.js:96
#, javascript-format
msgid ""
"This question set will be added to the page <code class=\"code-"
"questions\">%s</code>."
"This question set will be added to the page <code class=\"code-questions\">"
"%s</code>."
msgstr ""
"Dieser Fragenset wird der Seite <code class=\"code-questions\">%s</code> "
"hinzugefügt."
Expand Down Expand Up @@ -1444,42 +1448,42 @@ msgstr "Projekt direkt importieren"
msgid "Import from file"
msgstr "Importieren aus Datei"

#: projects/assets/js/components/main/Projects.js:22
#: projects/assets/js/components/main/Projects.js:25
#: projects/assets/js/utils/translations.js:13
msgid "Pending invitations"
msgstr "Ausstehende Einladungen"

#: projects/assets/js/components/main/Projects.js:28
#: projects/assets/js/components/main/Projects.js:31
#: projects/assets/js/utils/translations.js:7
msgid "Import project"
msgstr "Projekt importieren"

#: projects/assets/js/components/main/Projects.js:33
#: projects/assets/js/components/main/Projects.js:36
#, javascript-format
msgid "%s of %s projects are displayed"
msgstr "%s von %s Projekten werden angezeigt"

#: projects/assets/js/components/main/Projects.js:36
#: projects/assets/js/components/main/Projects.js:39
#, javascript-format
msgid "%s of %s"
msgstr "%s von %s"

#: projects/assets/js/components/main/Projects.js:47
#: projects/assets/js/components/main/Projects.js:50
#: projects/assets/js/utils/translations.js:18
msgid "View all projects"
msgstr "Alle Projekte ansehen"

#: projects/assets/js/components/main/Projects.js:47
#: projects/assets/js/components/main/Projects.js:50
#: projects/assets/js/utils/translations.js:19
msgid "View my projects"
msgstr "Meine Projekte ansehen"

#: projects/assets/js/components/main/Projects.js:48
#: projects/assets/js/components/main/Projects.js:51
#: projects/assets/js/utils/translations.js:11
msgid "My projects"
msgstr "Meine Projekte"

#: projects/assets/js/components/main/Projects.js:48
#: projects/assets/js/components/main/Projects.js:51
#: projects/assets/js/utils/translations.js:3
msgid "All projects"
msgstr "Alle Projekte"
Expand Down
70 changes: 7 additions & 63 deletions rdmo/projects/assets/js/api/ProjectsApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,27 @@ import BaseApi from 'rdmo/core/assets/js/api/BaseApi'
import { encodeParams } from 'rdmo/core/assets/js/utils/api'
import baseUrl from 'rdmo/core/assets/js/utils/baseUrl'

function BadRequestError(errors) {
this.errors = errors
}

class ProjectsApi extends BaseApi {

static fetchProjects(params, fetchParams = {}) {
return fetch('/api/v1/projects/projects/?' + encodeParams(params), fetchParams).then(response => {
if (response.ok) {
return response.json()
} else if (response.status == 400) {
return response.json().then(errors => {
throw new BadRequestError(errors)
})
} else {
throw new Error(response.statusText)
}
})
static fetchProjects(params) {
const url = '/api/v1/projects/projects/?' + encodeParams(params)
return this.get(url)
}

static fetchCatalogs() {
return fetch('/api/v1/projects/catalogs/').then(response => {
if (response.ok) {
return response.json()
} else {
throw new Error(response.statusText)
}
})
return this.get('/api/v1/projects/catalogs/')
}

static fetchAllowedFileTypes() {
return fetch('/api/v1/projects/projects/upload-accept/')
.then(response => {
if (response.ok) {
return response.text()
.then(text => {
try {
// Attempt to parse the text as JSON
const jsonData = JSON.parse(text)
// Check if the parsed data is an array
if (Array.isArray(jsonData)) {
return jsonData
}
} catch (error) {
// If JSON.parse fails, handle text as plain string below
}

// If it's not a JSON array, process it as a string
const cleanedText = text.replace(/^"|"$/g, '')
return cleanedText ? cleanedText.split(',') : []
})
} else {
throw new Error(response.statusText)
}
})
return this.get('/api/v1/projects/projects/upload-accept/')
}

static fetchDirectImportUrls() {
return fetch('/api/v1/projects/projects/imports/')
.then(response => {
if (response.ok) {
return response.json()
} else {
throw new Error(response.statusText)
}
})
return this.get('/api/v1/projects/projects/imports/')
}

static fetchInvites() {
return fetch('/api/v1/projects/invites/user')
.then(response => {
if (response.ok) {
return response.json()
} else {
throw new Error(response.statusText)
}
})
return this.get('/api/v1/projects/invites/user/')
}

static uploadProject(url, file) {
Expand Down
13 changes: 11 additions & 2 deletions rdmo/projects/assets/js/components/helper/PendingInvitations.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react'
import PropTypes from 'prop-types'

import baseUrl from 'rdmo/core/assets/js/utils/baseUrl'

import { ROLE_LABELS } from '../../utils'

const PendingInvitations = ({ invitations }) => {
Expand All @@ -14,8 +17,14 @@ const PendingInvitations = ({ invitations }) => {
{ROLE_LABELS[item.role]}
</div>
<div className="w-50 align-right">
<button className="btn btn-xs btn-success ml-10" onClick={() => { window.location.href = `/projects/join/${item.token}` }}>{gettext('Accept')}</button>
<button className="btn btn-xs btn-danger ml-10" onClick={() => { window.location.href = `/projects/cancel/${item.token}` }}>{gettext('Decline')}</button>
<button className="btn btn-xs btn-success ml-10"
onClick={() => { window.location.href = `${baseUrl}/projects/join/${item.token}/` }}>
{gettext('Accept')}
</button>
<button className="btn btn-xs btn-danger ml-10"
onClick={() => { window.location.href = `${baseUrl}/projects/cancel/${item.token}/` }}>
{gettext('Decline')}
</button>
</div>
</div>
))
Expand Down
Loading