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

feature/MWB12-39 #384

Merged
merged 1 commit into from
Jan 29, 2025
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
4 changes: 4 additions & 0 deletions mapping_workbench/frontend/src/api/mapping-packages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class MappingPackagesApi extends SectionApi {
return [ACTION.VIEW, ACTION.EDIT];
}

get FILE_UPLOAD_FORMATS() {
return {'application/zip': ['.zip']}
}

constructor() {
super("mapping_packages");
this.isProjectResource = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TestDataSuitesApi extends FileCollectionsApi {
}

get FILE_UPLOAD_FORMATS() {
return {'ZIP': 'application/zip'}
return {'application/zip': ['.zip']}
}

get MAPPING_PACKAGE_LINK_FIELD() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ class GenericTripleMapFragmentsApi extends TripleMapFragmentsApi {
return "Triple Map Fragments";
}

get FILE_UPLOAD_FORMATS() {
return {'TTL': {['text/ttl']: ['.ttl']},
'YAML': {['text/yaml']: ['.yaml']}
}
}

get SECTION_ITEM_TITLE() {
return "Triple Map Fragment";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class SpecificTripleMapFragmentsApi extends TripleMapFragmentsApi {
return [ACTION.EDIT, ACTION.DELETE]
}

get

constructor() {
super("specific_triple_map_fragments");
this.hasMappingPackage = true;
Expand Down
3 changes: 1 addition & 2 deletions mapping_workbench/frontend/src/components/file-dropzone.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import Typography from '@mui/material/Typography';
import { FileIcon } from 'src/components/file-icon';
import { bytesToSize } from 'src/utils/bytes-to-size';

export const FileDropzone = (props) => {
const { caption, files = [], onRemove, onRemoveAll, onUpload, disabled, ...other } = props;
export const FileDropzone = ({ caption, files = [], onRemove, onRemoveAll, onUpload, disabled, ...other }) => {
const { getRootProps, getInputProps, isDragActive } = useDropzone(other);

const hasAnyFiles = files.length > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const FileCollectionUploader = (props) => {
</Stack>
<DialogContent id="drop-zone">
<FileDropzone
accept={{'*/*': []}}
accept={{'application/zip': ['.zip']}}
caption="ZIP archive with Test Data Suites"
files={files}
onDrop={handleDrop}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export const FileUploader = (props) => {
);
}

const acceptedFormat = sectionApi.FILE_UPLOAD_FORMATS?.[format] ?? {'*/*': []}

return (
<Dialog
fullWidth
Expand Down Expand Up @@ -178,8 +180,9 @@ export const FileUploader = (props) => {
/>
<Box sx={{mb: 3}}/>
</>}

<FileDropzone
accept={{'*/*': []}}
accept={acceptedFormat}
caption="Max file size is 3 MB"
disabled={uploading}
files={files}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import {toastError, toastLoad, toastSuccess} from "src/components/app-toast";
import Divider from "@mui/material/Divider";


export const PackageImporter = (props) => {
const {onClose, open = false, sectionApi} = props;

export const PackageImporter = ({onClose, open = false, sectionApi}) => {
const defaultPackageTypeValue = DEFAULT_PACKAGE_TYPE;

const [files, setFiles] = useState([]);
Expand Down Expand Up @@ -142,7 +140,7 @@ export const PackageImporter = (props) => {
<Divider sx={{mt: 1}}/>
</FormGroup>
<FileDropzone
accept={{'*/*': []}}
accept={sectionApi.FILE_UPLOAD_FORMATS}
caption="Required name: {PACKAGE_NAME}.zip"
files={files}
onDrop={handleDrop}
Expand Down
Loading