Geo Primary Verification List: Hookup bulk actions to UI
Why are we doing this work
This work will be behind feature flag geo_primary_verification_view
This work is focused on taking the UI added as as part of Geo Primary Verification List: Hookup `geo_shar... (#538023 - closed) and hooking up the bulk actions that will be supported in the API Geo Primary Verification API: POST `api/v4/admi... (#537709 - closed).
These actions will function very similar to how we utilize them in the Geo Replicables views: https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/assets/javascripts/geo_replicable/components/geo_replicable_bulk_actions.vue
Relevant links
- UI issue: Geo Primary Verification List: Hookup `geo_shar... (#538023 - closed)
- API Support Issue: Geo Primary Verification API: POST `api/v4/admi... (#537709 - closed)
- Geo Replicables bulk actions: https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/assets/javascripts/geo_replicable/components/geo_replicable_bulk_actions.vue
Implementation plan
- Define
BULK_ACTIONSin theconstants.jsfile
export const BULK_ACTIONS = [
{
id: 'geo-bulk-action-checksum',
action: ACTION_TYPES.CHECKSUM,
text: s__('Geo|Checksum all'),
modal: {
title: s__('Geo|checksum all %{type}'),
description: s__(
'Geo|This will checksum all %{type}. It may take some time to complete. Are you sure you want to continue?',
),
},
},
]
- Define
commitBulkModelActioninee/api/data_management_api.js
const DATA_MANAGEMENT_BULK_ACTION_PATH = '/api/:version/data_management/:model/:action';
export const commitBulkModelAction = (model, action, options = {}) => {
const url = buildApiUrl(DATA_MANAGEMENT_BULK_ACTION_PATH)
.replace(':model', model)
.replace(':action', action)
return axios.post(url, {
params: {
...options
}
});
};
- Expose
modelTitleto theee/admin/data_management/index.jsbased on its implementation in Geo Primary Verification: View helpers (#537695 - closed) and provide it to the app asitemTitle
export const initDataManagement = () => {
// most of file omitted
const { modelTitle } = el.dataset;
return new Vue({
// omitted
provide: {
itemTitle: modelTitle,
},
});
};
- Expose
BULK_ACTIONStoapp.vueand pass it as a prop togeo-list-top-baralong with properly setting the propshow-actions
<template>
<geo-list-top-bar
:show-actions="sBoolean(modelItems.length)"
:bulk-actions="$options.BULK_ACTIONS"
/>
</template>
- Add event handling for
bulkActionevent that calls the API methodcommitBulkModelActioninapp.vue
<script>
export default {
methods: {
async onBulkAction(action) {
try {
this.isLoading = true
await commitBulkModelAction(this.activeModel, action)
} catch (error) {
createAlert({
message: this.$options.i18n.bulkActionError,
captureError: true,
error,
});
} finally {
this.isLoading = false
}
},
},
}
</script>
<template>
<geo-list-top-bar
@bulkAction="onBulkAction"
/>
</template>
Edited by 🤖 GitLab Bot 🤖