From 7025df687c4d6fdbc9925954d4f10876fe69f597 Mon Sep 17 00:00:00 2001 From: Lukas Engelter Date: Thu, 14 Mar 2024 09:28:54 +0100 Subject: [PATCH] feat: add `SHOW_TAG_HISTORY` option to hide tag history button (#362) --- README.md | 2 +- bin/90-docker-registry-ui.sh | 1 + src/components/docker-registry-ui.riot | 4 +++- src/components/tag-list/tag-list.riot | 1 + src/components/tag-list/tag-table.riot | 4 ++-- src/index.html | 2 ++ src/scripts/utils.js | 11 +++++++++++ 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c3c98d7..d2f469f 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Some env options are available for use this interface for **only one server** (w - `CATALOG_MAX_BRANCHES`: Set the maximum repository/namespace to expand (e.g. `joxit/docker-registry-ui` `joxit/` is the repository/namespace). Can be 0 to disable branching. (see [#319](https://github.com/Joxit/docker-registry-ui/pull/319)). (default: `1`). Since 2.5.0 - `TAGLIST_PAGE_SIZE`: Set the number of tags to display in one page. (default: `100`). Since 2.5.0 - `REGISTRY_SECURED`: By default, the UI will check on every requests if your registry is secured or not (you will see `401` responses in your console). Set to `true` if your registry uses Basic Authentication and divide by two the number of call to your registry. (default `false`). Since 2.5.0 - +- `SHOW_TAG_HISTORY`: Whether to show the tag history feature or not. Allows to simplify the user interface by hiding it form the tag list if set to `false`. (default: `true`). There are some examples with [docker-compose](https://docs.docker.com/compose/) and docker-registry-ui as proxy [here](https://github.com/Joxit/docker-registry-ui/tree/main/examples/ui-as-proxy/) or docker-registry-ui as standalone [here](https://github.com/Joxit/docker-registry-ui/tree/main/examples/ui-as-standalone/). ### Theme options diff --git a/bin/90-docker-registry-ui.sh b/bin/90-docker-registry-ui.sh index 2083784..4efbdc3 100755 --- a/bin/90-docker-registry-ui.sh +++ b/bin/90-docker-registry-ui.sh @@ -6,6 +6,7 @@ sed -i "s~\${PULL_URL}~${PULL_URL}~" index.html sed -i "s~\${SINGLE_REGISTRY}~${SINGLE_REGISTRY}~" index.html sed -i "s~\${CATALOG_ELEMENTS_LIMIT}~${CATALOG_ELEMENTS_LIMIT}~" index.html sed -i "s~\${SHOW_CONTENT_DIGEST}~${SHOW_CONTENT_DIGEST}~" index.html +sed -i "s~\${SHOW_TAG_HISTORY}~${SHOW_TAG_HISTORY}~" index.html sed -i "s~\${DEFAULT_REGISTRIES}~${DEFAULT_REGISTRIES}~" index.html sed -i "s~\${READ_ONLY_REGISTRIES}~${READ_ONLY_REGISTRIES}~" index.html sed -i "s~\${SHOW_CATALOG_NB_TAGS}~${SHOW_CATALOG_NB_TAGS}~" index.html diff --git a/src/components/docker-registry-ui.riot b/src/components/docker-registry-ui.riot index 1e24f76..b35b5ac 100644 --- a/src/components/docker-registry-ui.riot +++ b/src/components/docker-registry-ui.riot @@ -72,6 +72,7 @@ along with this program. If not, see . pull-url="{ state.pullUrl }" image="{ router.getTagListImage() }" show-content-digest="{ truthy(props.showContentDigest) }" + show-tag-history="{ falsy(props.showTagHistory) }" is-image-remove-activated="{ truthy(props.isImageRemoveActivated) }" on-notify="{ notifySnackbar }" filter-results="{ state.filter }" @@ -146,7 +147,7 @@ along with this program. If not, see . import SearchBar from './search-bar.riot'; import ErrorPage from './error-page.riot'; import VersionNotification from './version-notification.riot'; - import { stripHttps, getRegistryServers, setRegistryServers, truthy, stringToArray } from '../scripts/utils'; + import { stripHttps, getRegistryServers, setRegistryServers, truthy, falsy, stringToArray } from '../scripts/utils'; import router from '../scripts/router'; import { loadTheme } from '../scripts/theme'; @@ -262,6 +263,7 @@ along with this program. If not, see . version, latest, truthy, + falsy, stringToArray, }; diff --git a/src/components/tag-list/tag-list.riot b/src/components/tag-list/tag-list.riot index c039809..f028ddd 100644 --- a/src/components/tag-list/tag-list.riot +++ b/src/components/tag-list/tag-list.riot @@ -50,6 +50,7 @@ along with this program. If not, see . asc="{state.asc}" page="{ state.page }" show-content-digest="{props.showContentDigest}" + show-tag-history="{props.showTagHistory}" is-image-remove-activated="{props.isImageRemoveActivated}" onReverseOrder="{ onReverseOrder }" registry-url="{ props.registryUrl }" diff --git a/src/components/tag-list/tag-table.riot b/src/components/tag-list/tag-table.riot index eab05c6..72fbd3a 100644 --- a/src/components/tag-list/tag-table.riot +++ b/src/components/tag-list/tag-table.riot @@ -52,7 +52,7 @@ along with this program. If not, see . Tag Arch - History + History . - + diff --git a/src/index.html b/src/index.html index 640bd36..6f4a3b6 100644 --- a/src/index.html +++ b/src/index.html @@ -39,6 +39,7 @@ name="${REGISTRY_TITLE}" pull-url="${PULL_URL}" show-content-digest="${SHOW_CONTENT_DIGEST}" + show-tag-history="${SHOW_TAG_HISTORY}" is-image-remove-activated="${DELETE_IMAGES}" catalog-elements-limit="${CATALOG_ELEMENTS_LIMIT}" single-registry="${SINGLE_REGISTRY}" @@ -74,6 +75,7 @@ name="Development Registry" pull-url="" show-content-digest="true" + show-tag-history="true" is-image-remove-activated="true" catalog-elements-limit="1000" single-registry="false" diff --git a/src/scripts/utils.js b/src/scripts/utils.js index 010a461..924c8ae 100644 --- a/src/scripts/utils.js +++ b/src/scripts/utils.js @@ -217,6 +217,17 @@ export function truthy(value) { return value === true || value === 'true'; } +/** + * only is false if explicitly set to boolean false or string 'false'. + * defaults to true in any other case, e.g. if empty. + * + * @param {string|boolean} value the input value to check + * @returns {boolean} false if explicity set, true otherwise + */ +export function falsy(value) { + return value !== false && value !== 'false'; +} + export function stringToArray(value) { return value && typeof value === 'string' ? value.split(',') : []; }