Skip to content
Snippets Groups Projects

Allow urlText to be saved on metric images

Merged Sean Arnold requested to merge 346171-frontend-for-metric-image-url-text into master
All threads resolved!
Files
14
import createFlash from '~/flash';
import createFlash from '~/flash';
import { s__ } from '~/locale';
import { s__ } from '~/locale';
import { deleteMetricImage, getMetricImages, uploadMetricImage } from '../service';
import {
 
deleteMetricImage,
 
getMetricImages,
 
uploadMetricImage,
 
updateMetricImage,
 
} from '../service';
import * as types from './mutation_types';
import * as types from './mutation_types';
export const fetchMetricImages = async ({ state, commit }) => {
export const fetchMetricImages = async ({ state, commit }) => {
@@ -23,7 +28,13 @@ export const uploadImage = async ({ state, commit }, { files, url, urlText }) =>
@@ -23,7 +28,13 @@ export const uploadImage = async ({ state, commit }, { files, url, urlText }) =>
const { issueIid, projectId } = state;
const { issueIid, projectId } = state;
try {
try {
const response = await uploadMetricImage({ file: files.item(0), id: projectId, issueIid, url, urlText });
const response = await uploadMetricImage({
 
file: files.item(0),
 
id: projectId,
 
issueIid,
 
url,
 
urlText,
 
});
commit(types.RECEIVE_METRIC_UPLOAD_SUCCESS, response);
commit(types.RECEIVE_METRIC_UPLOAD_SUCCESS, response);
} catch (error) {
} catch (error) {
commit(types.RECEIVE_METRIC_UPLOAD_ERROR);
commit(types.RECEIVE_METRIC_UPLOAD_ERROR);
@@ -31,6 +42,26 @@ export const uploadImage = async ({ state, commit }, { files, url, urlText }) =>
@@ -31,6 +42,26 @@ export const uploadImage = async ({ state, commit }, { files, url, urlText }) =>
}
}
};
};
 
export const updateImage = async ({ state, commit }, { imageId, url, urlText }) => {
 
commit(types.REQUEST_METRIC_UPLOAD);
 
 
const { issueIid, projectId } = state;
 
 
try {
 
const response = await updateMetricImage({
 
issueIid,
 
id: projectId,
 
imageId,
 
url,
 
urlText,
 
});
 
commit(types.RECEIVE_METRIC_UPDATE_SUCCESS, response);
 
} catch (error) {
 
commit(types.RECEIVE_METRIC_UPLOAD_ERROR);
 
createFlash({ message: s__('Incidents|There was an issue updating your image.') });
 
}
 
};
 
export const deleteImage = async ({ state, commit }, imageId) => {
export const deleteImage = async ({ state, commit }, imageId) => {
const { issueIid, projectId } = state;
const { issueIid, projectId } = state;
Loading