From 6b5e83c60792b48ac94f2467a0345122bebfa843 Mon Sep 17 00:00:00 2001 From: Valentijn Scholten Date: Sun, 26 Jan 2025 18:25:09 +0100 Subject: [PATCH] add columns Signed-off-by: Valentijn Scholten --- src/i18n/locales/en.json | 6 +- src/shared/utils.js | 28 +++++++++ .../repositories/Repositories.vue | 59 ++++++++++--------- 3 files changed, 62 insertions(+), 31 deletions(-) diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index e4a00a86d..138c1d58e 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -212,8 +212,10 @@ "reindex_vulnerable_software": "Vulnerable software", "remove_api_key": "Remove API Key", "repositories": "Repositories", - "repository_advisory_alias_sync_enabled": "Enable Security Advisory alias synchronization", - "repository_advisory_mirroring_enabled": "Enable mirroring of Security Advisories (Beta)", + "repository_advisory_alias_sync_enabled": "Alias Sync", + "repository_advisory_mirroring_enabled": "Advisory Sync", + "repository_advisory_alias_sync_toggle": "Enable Security Advisory alias synchronization", + "repository_advisory_mirroring_toggle": "Enable mirroring of Security Advisories (Beta)", "repository_authentication": "Authentication required", "repository_created": "Repository created", "repository_deleted": "Repository deleted", diff --git a/src/shared/utils.js b/src/shared/utils.js index 9bad6c62b..d44da01d0 100644 --- a/src/shared/utils.js +++ b/src/shared/utils.js @@ -128,6 +128,34 @@ export function loadUserPreferencesForBootstrapTable(_this, id, columns) { }); } +/** + * Parses advisoryMirroringEnabled from repository.config. + * Needed in multiple places, so extracted to a common function. + */ +export function parseAdvisoryMirroringEnabled(repo) { + if (repo.config) { + let value = JSON.parse(repo.config); + if (value) { + return value.advisoryMirroringEnabled; + } + return false; + } +} + +/** + * Parses parseAdvisoryAliasSyncEnabled from repository.config. + * Needed in multiple places, so extracted to a common function. + */ +export function parseAdvisoryAliasSyncEnabled(repo) { + if (repo.config) { + let value = JSON.parse(repo.config); + if (value) { + return value.advisoryAliasSyncEnabled; + } + return false; + } +} + export function compareVersions(v1, v2) { if (!v1) { return 1; diff --git a/src/views/administration/repositories/Repositories.vue b/src/views/administration/repositories/Repositories.vue index ef2c4002c..18399b682 100644 --- a/src/views/administration/repositories/Repositories.vue +++ b/src/views/administration/repositories/Repositories.vue @@ -34,6 +34,8 @@ import bootstrapTableMixin from '../../../mixins/bootstrapTableMixin'; import common from '../../../shared/common'; import EventBus from '../../../shared/eventbus'; import RepositoryCreateRepositoryModal from './RepositoryCreateRepositoryModal'; +import { parseAdvisoryMirroringEnabled } from '@/shared/utils'; +import { parseAdvisoryAliasSyncEnabled } from '@/shared/utils'; export default { props: { @@ -123,6 +125,30 @@ export default { return value === true ? '' : ''; }, }, + { + title: this.$t('admin.repository_advisory_mirroring_enabled'), + field: 'advisoryMirroringEnabled', + class: 'tight', + sortable: true, + visible: this.type === 'COMPOSER', + formatter(value, row, index) { + return parseAdvisoryMirroringEnabled(row) === true + ? '' + : ''; + }, + }, + { + title: this.$t('admin.repository_advisory_alias_sync_enabled'), + field: 'advisoryAliasSyncEnabled', + class: 'tight', + sortable: true, + visible: this.type === 'COMPOSER', + formatter(value, row, index) { + return parseAdvisoryAliasSyncEnabled(row) === true + ? '' + : ''; + }, + }, ], data: [], options: { @@ -170,10 +196,10 @@ export default { {{$t('admin.internal')}}
- {{$t('admin.repository_advisory_mirroring_enabled')}} + {{$t('admin.repository_advisory_mirroring_toggle')}}
- {{$t('admin.repository_advisory_alias_sync_enabled')}} + {{$t('admin.repository_advisory_alias_sync_toggle')}}
@@ -222,10 +248,8 @@ export default { username: row.username, password: row.password || 'HiddenDecryptedPropertyPlaceholder', enabled: row.enabled, - advisoryMirroringEnabled: - this.parseAdvisoryMirroringEnabled(row), - advisoryAliasSyncEnabled: - this.parseAdvisoryAliasSyncEnabled(row), + advisoryMirroringEnabled: parseAdvisoryMirroringEnabled(row), + advisoryAliasSyncEnabled: parseAdvisoryAliasSyncEnabled(row), uuid: row.uuid, labelIcon: { dataOn: '\u2713', @@ -233,11 +257,6 @@ export default { }, }; }, - // TODO remove this dead code - // created() { - // this.parseAdvisoryMirroringEnabled(this.repository); - // this.parseAdvisoryAliasSyncEnabled(this.repository); - // }, watch: { internal() { this.updateRepository(); @@ -256,24 +275,6 @@ export default { }, }, methods: { - parseAdvisoryMirroringEnabled: function (repo) { - if (repo.config) { - let value = JSON.parse(repo.config); - if (value) { - return value.advisoryMirroringEnabled; - } - return null; - } - }, - parseAdvisoryAliasSyncEnabled: function (repo) { - if (repo.config) { - let value = JSON.parse(repo.config); - if (value) { - return value.advisoryAliasSyncEnabled; - } - return null; - } - }, deleteRepository: function () { let url = `${this.$api.BASE_URL}/${this.$api.URL_REPOSITORY}/${this.uuid}`; this.axios