Closed praveer38 closed 1 day ago
To disable the "Download as image" feature for charts and dashboards in Superset version 4.0.2, you need to modify the code where the menu items are defined. Specifically, locate the following part of the code and remove or comment out the section related to the "DOWNLOAD_AS_IMAGE" menu key:
<Menu.Item
key={MENU_KEYS.DOWNLOAD_AS_IMAGE}
icon={<Icons.FileImageOutlined css={iconReset} />}
>
{t('Download as image')}
</Menu.Item>
This change will remove the "Download as image" option from the menu, effectively disabling the feature [1].
To continue talking to Dosu, mention @dosu.
@dosu is there a way to disable it from the superset_config.py?
There isn't a specific configuration option in superset_config.py
to disable the "Download as image" feature directly. The feature is controlled through the frontend code, and there is no feature flag or configuration setting in superset_config.py
that can be used to disable it [1].
To continue talking to Dosu, mention @dosu.
@dosu please tell me a way to disable it if I'm running superset as a docker container?
To disable the "Download as image" feature while running Superset as a Docker container, you will need to modify the frontend code within the Docker environment. Here's how you can do it:
Access the Frontend Code:
BUILD_SUPERSET_FRONTEND_IN_DOCKER
to true
to build the Superset frontend in development mode inside the Docker container. This allows you to access and modify the frontend code.Modify the Code:
Rebuild the Frontend:
npm install
npm run dev
Restart the Docker Container:
By following these steps, you can disable the "Download as image" feature in a Dockerized Superset environment [1].
To continue talking to Dosu, mention @dosu.
FROM apache/superset:4.0.2
USER root
RUN apt-get update RUN apt-get install -y build-essential g++ nano RUN mkdir /app/custom_scripts_rc COPY public_user_perms.py /app/custom_scripts_rc/public_user_perms.py RUN pip install mysqlclient Authlib pymssql apache-superset[cors] Flask-OAuthlib psycopg2 pystan==2.19.1.1 prophet
COPY ./docker-init.sh /superset-init.sh COPY docker-bootstrap.sh /app/docker/docker-bootstrap.sh
COPY zdnlk0yk.png /app/superset/static/assets/images/superset.png COPY zdnlk0yk.png /app/superset/static/assets/images/superset-logo-horiz.png
COPY superset_config.py /app/pythonpath/superset_config.py COPY superset_config.py /app/
COPY utils.py /app/superset/connectors/sqla/utils.py COPY models.py /app/superset/connectors/sqla/models.py
ENV SUPERSET_CONFIG_PATH /app/superset_config.py ENV PYTHONPATH="/app/pythonpath" ENV BUILD_SUPERSET_FRONTEND_IN_DOCKER=True
USER superset
CMD ["sh", "-c", "python /app/custom_scripts_rc/public_user_perms.py & /superset-init.sh"] These are the contents of my dockerfile. Please help with the changes. @dosu
To disable the "Download as image" feature in your Dockerized Superset setup, you need to modify the frontend code and rebuild it within the Docker container. Here’s how you can adjust your Dockerfile and process:
Ensure Frontend Code is Accessible:
BUILD_SUPERSET_FRONTEND_IN_DOCKER=True
, which is correct for building the frontend inside the Docker container.Modify the Frontend Code:
docker exec -it <container_id> /bin/bash
cd /app/superset-frontend
Edit the Code:
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/DownloadAsImage.tsx
, and comment out or remove the relevant code that adds this feature to the menu.Rebuild the Frontend:
npm install
npm run dev
Restart the Container:
Your Dockerfile doesn't need changes for this specific task, as it already sets up the environment to build the frontend inside the container. Just ensure you follow the steps above to modify and rebuild the frontend code.
To continue talking to Dosu, mention @dosu.
@dosu but the container only has package.json under superset-frontend
To modify the frontend code in your Dockerized Superset setup, you need to ensure that the full source code is available in the container. If only package.json
is present, it suggests that the source files might not be included in the image or volume.
Here's how you can proceed:
Ensure Source Code Availability:
superset-frontend
directory with all its source files is available in the Docker container. You might need to mount the local superset-frontend
directory into the container using Docker volumes. Update your docker-compose.yml
or Docker run command to include a volume mount for the frontend code.Modify the Frontend Code:
superset-frontend
directory inside the container:
docker exec -it <container_id> /bin/bash
cd /app/superset-frontend
Edit the Code:
src/dashboard/components/menu/DownloadMenuItems/DownloadAsImage.tsx
to comment out or remove the code related to the "Download as image" feature.Rebuild the Frontend:
npm install
npm run dev
Restart the Container:
If the source code is not included in the Docker image, you may need to build the image locally with the source code included or adjust your Docker setup to ensure the source files are available for modification.
To continue talking to Dosu, mention @dosu.
Sorry Dosu always wants people to edit the codebase. There is a permission named "can csv on Superset", try removing that from the role(s) that you want to modify in this way.
Also this should not be a bug report as it is a question. Please post questions on Slack and/or GitHub Discussions. I found the answer searching Slack. I see you have opened a few bug reports today - please be judicious as the Superset project struggles when it comes to triaging bug reports. Valid, complete bug reports are welcome but it is a help if you keep them to a minimum.
I understand. Thanks for the pointer, although we do want to export the data as csv as well as excel but we want to eliminate the option to export it as an image. But I'll post this as a discussion on GitHub. Thanks!
Bug description
How can i disable the download as image feature for charts and dashboards?
Screenshots/recordings
No response
Superset version
4.0.2
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist