Skip to content

Commit

Permalink
databox: fix allowedType [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Jul 6, 2023
1 parent afd4710 commit 067b05a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
11 changes: 5 additions & 6 deletions bin/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ bin/create-config.sh

set -ex

export COMPOSE_PROFILES=setup,db,uploader,auth,databox,expose,notify,dashboard,tools
export AUTH_API_BASE_URL=https://api-auth.${PHRASEA_DOMAIN}
export UPLOADER_CLIENT_BASE_URL=https://uploader.${PHRASEA_DOMAIN}
export DATABOX_CLIENT_BASE_URL=https://databox.${PHRASEA_DOMAIN}
Expand Down Expand Up @@ -58,7 +57,7 @@ exec_container auth-api-php "bin/console alchemy:oauth:create-client ${UPLOADER_
--scope group:list \
--redirect-uri ${UPLOADER_API_BASE_URL}"
## Create minio bucket
docker compose run --rm -T --entrypoint "sh -c" minio-mc "\
COMPOSE_PROFILES="${COMPOSE_PROFILES},setup" docker compose run --rm -T --entrypoint "sh -c" minio-mc "\
while ! nc -z minio 9000; do echo 'Wait minio to startup...' && sleep 0.1; done; \
sleep 5 && \
mc config host add minio http://minio:9000 \$MINIO_ACCESS_KEY \$MINIO_SECRET_KEY && \
Expand All @@ -85,7 +84,7 @@ exec_container auth-api-php "bin/console alchemy:oauth:create-client ${EXPOSE_AD
--scope group:list \
--redirect-uri ${EXPOSE_API_BASE_URL}"
## Create minio bucket
docker compose run --rm -T --entrypoint "sh -c" minio-mc "\
COMPOSE_PROFILES="${COMPOSE_PROFILES},setup" docker compose run --rm -T --entrypoint "sh -c" minio-mc "\
i=0
while ! nc -z minio 9000; do \
echo 'Wait for minio to startup...'; \
Expand Down Expand Up @@ -135,7 +134,7 @@ exec_container auth-api-php "bin/console alchemy:oauth:create-client ${DATABOX_C
--grant-type authorization_code \
--redirect-uri ${DATABOX_CLIENT_BASE_URL}"
## Create minio bucket
docker compose run --rm -T --entrypoint "sh -c" minio-mc "\
COMPOSE_PROFILES="${COMPOSE_PROFILES},setup" docker compose run --rm -T --entrypoint "sh -c" minio-mc "\
while ! nc -z minio 9000; do echo 'Wait minio to startup...' && sleep 0.1; done; \
sleep 5 && \
mc config host add minio http://minio:9000 \$MINIO_ACCESS_KEY \$MINIO_SECRET_KEY && \
Expand All @@ -157,7 +156,7 @@ exec_container auth-api-php "bin/console app:user:create \

## Setup indexer
## Create Databox OAuth client for indexer
docker compose run --rm -T --entrypoint "sh -c" minio-mc "\
COMPOSE_PROFILES="${COMPOSE_PROFILES},setup" docker compose run --rm -T --entrypoint "sh -c" minio-mc "\
while ! nc -z minio 9000; do echo 'Wait minio to startup...' && sleep 0.1; done; \
sleep 5 && \
mc config host add minio http://minio:9000 \$MINIO_ACCESS_KEY \$MINIO_SECRET_KEY && \
Expand All @@ -174,7 +173,7 @@ exec_container rabbitmq "\
rabbitmqadmin declare exchange --vhost=s3events name=s3events type=direct durable='true' -u ${RABBITMQ_USER} -p ${RABBITMQ_PASSWORD} \
&& rabbitmqadmin declare queue --vhost=s3events name=s3events auto_delete=false durable='true' -u ${RABBITMQ_USER} -p ${RABBITMQ_PASSWORD} \
&& rabbitmqadmin declare binding --vhost=s3events source=s3events destination=s3events routing_key='' -u ${RABBITMQ_USER} -p ${RABBITMQ_PASSWORD}"
docker compose run --rm -T --entrypoint "sh -c" minio-mc "\
COMPOSE_PROFILES="${COMPOSE_PROFILES},setup" docker compose run --rm -T --entrypoint "sh -c" minio-mc "\
set -x; \
while ! nc -z minio 9000; do echo 'Wait minio to startup...' && sleep 0.1; done; \
mc config host add minio http://minio:9000 \$MINIO_ACCESS_KEY \$MINIO_SECRET_KEY \
Expand Down
25 changes: 19 additions & 6 deletions databox/client/src/components/Upload/UploadDropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,27 @@ import {Box, Typography} from "@mui/material";
import {grey} from "@mui/material/colors";
import config from "../../config";

export function useAccept() {
export function useAccept(): Accept | undefined {
return React.useMemo<Accept | undefined>(() => {
const list = [
...(config.get('allowedTypes') as string[]),
...(config.get('allowedExtensions') as string[]).map(e => `.${e}`),
];
const a = config.get('allowedTypes') as Accept | undefined;
if (!a) {
return;
}

return list.length > 0 ? {'image/*': list} : undefined;
const n = {...a};
try {
Object.keys(n).forEach(k => {
n[k] = n[k].map(e => `.${e.replace(/^\./, '')}`);
if (n[k].length === 0) {
throw new Error(`Missing extension list for MIME type ${k}`);
}
});
} catch (e: any) {
console.error(e.toString());
return;
}

return n;
}, []);
}

Expand Down

0 comments on commit 067b05a

Please sign in to comment.