Geo Primary Verification List: Hookup single 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 single item actions that will be supported in the API Geo Primary Verification API: POST api/v4/admin... (#537712 - closed).
Relevant links
- UI issue: Geo Primary Verification List: Hookup `geo_shar... (#538023 - closed)
- API Support Issue: Geo Primary Verification API: POST api/v4/admin... (#537712 - closed)
Implementation plan
- Define the
ACTION_TYPESin theconstants.jsfile
export const ACTION_TYPES = {
CHECKSUM: 'checksum'
}
- Add
commitSingleModelActionmethod to theee/api/data_management_api.js
const DATA_MANAGEMENT_SINGLE_ACTION_PATH = '/api/:version/data_management/:model/:id/:action';
export const commitSingleModelAction = (model, id, action) => {
const url = buildApiUrl(DATA_MANAGEMENT_SINGLE_ACTION_PATH)
.replace(':model', model)
.replace(':id', id)
.replace(':action', action)
return axios.post(url);
};
- Define the actions in the
actionsArrayindata_management_list_item.vueand pass it in the template
<script>
export default {
computed: {
actionsArray() {
return [
{
id: 'geo-checksum-item',
value: ACTION_TYPES.CHECKSUM,
text: this.$options.i18n.checksum,
},
];
},
},
}
</script>
<template>
<geo-list-item
:actions-array="actionsArray"
>
</geo-list-item>
</template>
- Define an event handler for
actionClickedin thedata_management_list_item.vue
<script>
export default {
methods: {
onActionClicked(action) {
this.$emit('actionClicked', { id: this.item.id, action: action.value })
}
}
}
</script>
<template>
<geo-list-item
@actionClicked="onActionClicked"
>
</geo-list-item>
</template>
- Pass along the
actionClickedevent indata_management_view.vue
<script>
export default {
methods: {
onActionClicked(data) {
this.$emit('actionClicked', data)
}
}
}
</script>
<template>
<data-management-list-item
@actionClicked="onActionClicked"
/>
</template>
- Handle
actionClickedin theapp.vueand fire thecommitSingleModelActionAPI method
<script>
export default {
methods: {
async onSingleAction({ id, action }) {
try {
this.isLoading = true
await commitSingleModelAction(this.activeModel, id, action)
} catch (error) {
createAlert({
message: sprintf(this.$options.i18n.singleModelActionError, { id }),
captureError: true,
error,
});
} finally {
this.isLoading = false
}
},
}
}
</script>
<template>
<data-management-view @actionClicked="onSingleAction" />
</template>
Edited by 🤖 GitLab Bot 🤖