Skip to content

Commit

Permalink
Merge pull request #384 from meaningfy-ws/feature/MWB12-39
Browse files Browse the repository at this point in the history
feature/MWB12-39
  • Loading branch information
kaleanych authored Jan 29, 2025
2 parents 8ef8f28 + aa0d18f commit 747b887
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 9 deletions.
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

0 comments on commit 747b887

Please sign in to comment.