Skip to content

Commit

Permalink
add columns
Browse files Browse the repository at this point in the history
Signed-off-by: Valentijn Scholten <[email protected]>
  • Loading branch information
valentijnscholten committed Jan 26, 2025
1 parent 796796e commit 6b5e83c
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 31 deletions.
6 changes: 4 additions & 2 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 28 additions & 0 deletions src/shared/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
59 changes: 30 additions & 29 deletions src/views/administration/repositories/Repositories.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -123,6 +125,30 @@ export default {
return value === true ? '<i class="fa fa-check-square-o" />' : '';
},
},
{
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
? '<i class="fa fa-check-square-o" />'
: '';
},
},
{
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
? '<i class="fa fa-check-square-o" />'
: '';
},
},
],
data: [],
options: {
Expand Down Expand Up @@ -170,10 +196,10 @@ export default {
<c-switch color="primary" v-model="internal" label v-bind="labelIcon" />{{$t('admin.internal')}}
</div>
<div v-if="this.type === 'COMPOSER'">
<c-switch color="primary" v-model="advisoryMirroringEnabled" label v-bind="labelIcon" />{{$t('admin.repository_advisory_mirroring_enabled')}}
<c-switch color="primary" v-model="advisoryMirroringEnabled" label v-bind="labelIcon" />{{$t('admin.repository_advisory_mirroring_toggle')}}
</div>
<div v-show="advisoryMirroringEnabled" v-if="this.type === 'COMPOSER'">
<c-switch color="primary" v-model="advisoryAliasSyncEnabled" label v-bind="labelIcon" />{{$t('admin.repository_advisory_alias_sync_enabled')}}
<c-switch color="primary" v-model="advisoryAliasSyncEnabled" label v-bind="labelIcon" />{{$t('admin.repository_advisory_alias_sync_toggle')}}
</div>
<div>
Expand Down Expand Up @@ -222,22 +248,15 @@ 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',
dataOff: '\u2715',
},
};
},
// TODO remove this dead code
// created() {
// this.parseAdvisoryMirroringEnabled(this.repository);
// this.parseAdvisoryAliasSyncEnabled(this.repository);
// },
watch: {
internal() {
this.updateRepository();
Expand All @@ -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
Expand Down

0 comments on commit 6b5e83c

Please sign in to comment.