This is broken down into 2 parts. How I go about identifying what needs to be hidden, and how to actually hide them. I'll use Gitlab as an example.
At the time, I chose the Enterprise version instead of Community (serves me right) thinking I might want some premium feature way ahead in the future and I don't want potential migration headaches, but because it kept annoying me again and again to start a trial of the Ultimate version, I decided not to.
If you go into your repository settings, you will see a banner like this:
https://preview.redd.it/osbuuw08f62e1.png?width=1473&format=png&auto=webp&s=a4b215f66bcee42404affb4a3a485115c175c394
Looking at the CSS id for this widget in Inspect Element, I see promote_repository_features
. So that must mean every other promotion widget also has similar names. So then I go into /opt/gitlab in the docker container and search for promote_repository_features and I find that I can simply do grep -r "id: 'promote" .
which will basically give me these:
- promote_service_desk
- promote_advanced_search
- promote_burndown_charts
- promote_mr_features
- promote_repository_features
Now all we need is a CSS style to hide these. I put this in a css file called custom.css.
#promote_service_desk, #promote_advanced_search, #promote_burndown_charts, #promote_mr_features, #promote_repository_features { display: none !important; }
In the docker compose config, I add a mount to make my custom css file available in the container like this:
volumes: - './custom.css:/opt/gitlab/embedded/service/gitlab-rails/public/assets/custom.css:ro'
Now we need a way to actually make Gitlab use this file. We can configure it like this as an environment variable GITLAB_OMNIBUS_CONFIG in the docker compose file:
environment: GITLAB_OMNIBUS_CONFIG: | gitlab_rails['custom_html_header_tags'] = '<link rel="stylesheet" href="/assets/custom.css">'
And there we have it. Without changing anything in the Gitlab source or doing some ugly patching, we have our CSS file. Now the nagging banners are all gone!
https://preview.redd.it/6f85g018m62e1.png?width=1657&format=png&auto=webp&s=9a596ceececf4a6b54c64a79c9a4bdf4491e4237
Gitlab also has a GITLAB_POST_RECONFIGURE_SCRIPT
variable that will let you run a script, so perhaps a better way would be to automatically identify new banner ids that they add and hide those as well. I've not gotten around that yet, but will update this post when I come to that.
Update #1: Optional script to generate the custom css.
import subprocess import sys CONTAINER_NAME = "gitlab" command = f""" docker compose exec {CONTAINER_NAME} grep -r "id: 'promote" /opt/gitlab | awk "match(\$0, / id: '([^']+)/, a) {{print a[1]}}" """ css_ids = [] try: css_ids = list(set(subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True, text=True).split())) except subprocess.CalledProcessError as e: print(f"Unable to get promo ids") sys.exit(1) for css_id in css_ids[:-1]: print(f"#{css_id},") print(f"#{css_ids[-1]} {{\n display: none !important;\n}}")
submitted by