Skip to content

Commit

Permalink
URL Management control panel: show errors from CSV upload (#6473)
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli authored Nov 5, 2024
1 parent 0a7bd48 commit d6f2b46
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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

0 comments on commit d6f2b46

Please sign in to comment.