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

URL Management control panel: show errors from CSV upload #6473

Merged
merged 2 commits into from
Nov 5, 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
1 change: 1 addition & 0 deletions packages/volto/news/6473.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
URL Management control panel: Show errors from a failed CSV upload. @davisagli
17 changes: 17 additions & 0 deletions packages/volto/src/components/manage/Controlpanels/Aliases.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const Aliases = (props) => {
const [editingData, setEditingData] = useState(null);
const [uploadModalOpen, setUploadModalOpen] = useState(false);
const [uploadError, setUploadError] = useState(null);
const [csvErrors, setCSVErrors] = useState([]);
const isClient = useClient();

const updateResults = useCallback(() => {
Expand Down Expand Up @@ -273,6 +274,7 @@ const Aliases = (props) => {
.then(() => {
updateResults();
setUploadError(null);
setCSVErrors([]);
setUploadModalOpen(false);
toast.success(
<Toast
Expand All @@ -284,6 +286,7 @@ const Aliases = (props) => {
})
.catch((error) => {
setUploadError(error.response?.body?.message);
setCSVErrors(error.response?.body?.csv_errors ?? []);
});
});
};
Expand Down Expand Up @@ -388,6 +391,20 @@ const Aliases = (props) => {
/people/JoeT,/Users/joe-thurston,2018-12-31,false
</code>
</p>
{csvErrors.length ? (
<div
className="ui error message"
style={{ 'overflow-x': 'auto' }}
>
<pre>
Errors:{'\n'}
{csvErrors.map(
(err) =>
`${err.line_number}: ${err.line} - ${err.message}\n`,
)}
</pre>
</div>
) : null}
</>
}
schema={{
Expand Down
Loading