Skip to content

Commit 1580c0a

Browse files
add columns
Signed-off-by: Valentijn Scholten <valentijnscholten@gmail.com>
1 parent 630f4e1 commit 1580c0a

File tree

3 files changed

+62
-31
lines changed

3 files changed

+62
-31
lines changed

src/i18n/locales/en.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@
212212
"reindex_vulnerable_software": "Vulnerable software",
213213
"remove_api_key": "Remove API Key",
214214
"repositories": "Repositories",
215-
"repository_advisory_alias_sync_enabled": "Enable Security Advisory alias synchronization",
216-
"repository_advisory_mirroring_enabled": "Enable mirroring of Security Advisories (Beta)",
215+
"repository_advisory_alias_sync_enabled": "Alias Sync",
216+
"repository_advisory_mirroring_enabled": "Advisory Sync",
217+
"repository_advisory_alias_sync_toggle": "Enable Security Advisory alias synchronization",
218+
"repository_advisory_mirroring_toggle": "Enable mirroring of Security Advisories (Beta)",
217219
"repository_authentication": "Authentication required",
218220
"repository_created": "Repository created",
219221
"repository_deleted": "Repository deleted",

src/shared/utils.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,34 @@ export function loadUserPreferencesForBootstrapTable(_this, id, columns) {
128128
});
129129
}
130130

131+
/**
132+
* Parses advisoryMirroringEnabled from repository.config.
133+
* Needed in multiple places, so extracted to a common function.
134+
*/
135+
export function parseAdvisoryMirroringEnabled(repo) {
136+
if (repo.config) {
137+
let value = JSON.parse(repo.config);
138+
if (value) {
139+
return value.advisoryMirroringEnabled;
140+
}
141+
return false;
142+
}
143+
}
144+
145+
/**
146+
* Parses parseAdvisoryAliasSyncEnabled from repository.config.
147+
* Needed in multiple places, so extracted to a common function.
148+
*/
149+
export function parseAdvisoryAliasSyncEnabled(repo) {
150+
if (repo.config) {
151+
let value = JSON.parse(repo.config);
152+
if (value) {
153+
return value.advisoryAliasSyncEnabled;
154+
}
155+
return false;
156+
}
157+
}
158+
131159
export function compareVersions(v1, v2) {
132160
if (!v1) {
133161
return 1;

src/views/administration/repositories/Repositories.vue

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import bootstrapTableMixin from '../../../mixins/bootstrapTableMixin';
3434
import common from '../../../shared/common';
3535
import EventBus from '../../../shared/eventbus';
3636
import RepositoryCreateRepositoryModal from './RepositoryCreateRepositoryModal';
37+
import { parseAdvisoryMirroringEnabled } from '@/shared/utils';
38+
import { parseAdvisoryAliasSyncEnabled } from '@/shared/utils';
3739
3840
export default {
3941
props: {
@@ -123,6 +125,30 @@ export default {
123125
return value === true ? '<i class="fa fa-check-square-o" />' : '';
124126
},
125127
},
128+
{
129+
title: this.$t('admin.repository_advisory_mirroring_enabled'),
130+
field: 'advisoryMirroringEnabled',
131+
class: 'tight',
132+
sortable: true,
133+
visible: this.type === 'COMPOSER',
134+
formatter(value, row, index) {
135+
return parseAdvisoryMirroringEnabled(row) === true
136+
? '<i class="fa fa-check-square-o" />'
137+
: '';
138+
},
139+
},
140+
{
141+
title: this.$t('admin.repository_advisory_alias_sync_enabled'),
142+
field: 'advisoryAliasSyncEnabled',
143+
class: 'tight',
144+
sortable: true,
145+
visible: this.type === 'COMPOSER',
146+
formatter(value, row, index) {
147+
return parseAdvisoryAliasSyncEnabled(row) === true
148+
? '<i class="fa fa-check-square-o" />'
149+
: '';
150+
},
151+
},
126152
],
127153
data: [],
128154
options: {
@@ -170,10 +196,10 @@ export default {
170196
<c-switch color="primary" v-model="internal" label v-bind="labelIcon" />{{$t('admin.internal')}}
171197
</div>
172198
<div v-if="this.type === 'COMPOSER'">
173-
<c-switch color="primary" v-model="advisoryMirroringEnabled" label v-bind="labelIcon" />{{$t('admin.repository_advisory_mirroring_enabled')}}
199+
<c-switch color="primary" v-model="advisoryMirroringEnabled" label v-bind="labelIcon" />{{$t('admin.repository_advisory_mirroring_toggle')}}
174200
</div>
175201
<div v-show="advisoryMirroringEnabled" v-if="this.type === 'COMPOSER'">
176-
<c-switch color="primary" v-model="advisoryAliasSyncEnabled" label v-bind="labelIcon" />{{$t('admin.repository_advisory_alias_sync_enabled')}}
202+
<c-switch color="primary" v-model="advisoryAliasSyncEnabled" label v-bind="labelIcon" />{{$t('admin.repository_advisory_alias_sync_toggle')}}
177203
</div>
178204
179205
<div>
@@ -222,22 +248,15 @@ export default {
222248
username: row.username,
223249
password: row.password || 'HiddenDecryptedPropertyPlaceholder',
224250
enabled: row.enabled,
225-
advisoryMirroringEnabled:
226-
this.parseAdvisoryMirroringEnabled(row),
227-
advisoryAliasSyncEnabled:
228-
this.parseAdvisoryAliasSyncEnabled(row),
251+
advisoryMirroringEnabled: parseAdvisoryMirroringEnabled(row),
252+
advisoryAliasSyncEnabled: parseAdvisoryAliasSyncEnabled(row),
229253
uuid: row.uuid,
230254
labelIcon: {
231255
dataOn: '\u2713',
232256
dataOff: '\u2715',
233257
},
234258
};
235259
},
236-
// TODO remove this dead code
237-
// created() {
238-
// this.parseAdvisoryMirroringEnabled(this.repository);
239-
// this.parseAdvisoryAliasSyncEnabled(this.repository);
240-
// },
241260
watch: {
242261
internal() {
243262
this.updateRepository();
@@ -256,24 +275,6 @@ export default {
256275
},
257276
},
258277
methods: {
259-
parseAdvisoryMirroringEnabled: function (repo) {
260-
if (repo.config) {
261-
let value = JSON.parse(repo.config);
262-
if (value) {
263-
return value.advisoryMirroringEnabled;
264-
}
265-
return null;
266-
}
267-
},
268-
parseAdvisoryAliasSyncEnabled: function (repo) {
269-
if (repo.config) {
270-
let value = JSON.parse(repo.config);
271-
if (value) {
272-
return value.advisoryAliasSyncEnabled;
273-
}
274-
return null;
275-
}
276-
},
277278
deleteRepository: function () {
278279
let url = `${this.$api.BASE_URL}/${this.$api.URL_REPOSITORY}/${this.uuid}`;
279280
this.axios

0 commit comments

Comments
 (0)