+
{hasPermission(CREATE_FEATURE) ? (
-
+
diff --git a/frontend/src/data/applications-api.js b/frontend/src/data/applications-api.js
index 919e3df790..5a4e3e1554 100644
--- a/frontend/src/data/applications-api.js
+++ b/frontend/src/data/applications-api.js
@@ -34,9 +34,18 @@ function storeApplicationMetaData(appName, key, value) {
}).then(throwIfNotSuccess);
}
+function deleteApplication(appName) {
+ return fetch(`${URI}/${appName}`, {
+ method: 'DELETE',
+ headers,
+ credentials: 'include',
+ }).then(throwIfNotSuccess);
+}
+
export default {
fetchApplication,
fetchAll,
fetchApplicationsWithStrategyName,
storeApplicationMetaData,
+ deleteApplication,
};
diff --git a/frontend/src/page/applications/view.js b/frontend/src/page/applications/view.js
index 13e72c32a6..95d163ca64 100644
--- a/frontend/src/page/applications/view.js
+++ b/frontend/src/page/applications/view.js
@@ -2,10 +2,11 @@ import React from 'react';
import PropTypes from 'prop-types';
import ApplicationEditComponent from '../../component/application/application-edit-container';
-const render = ({ match: { params } }) =>
;
+const render = ({ match: { params }, history }) =>
;
render.propTypes = {
match: PropTypes.object.isRequired,
+ history: PropTypes.object.isRequired,
};
export default render;
diff --git a/frontend/src/store/application/actions.js b/frontend/src/store/application/actions.js
index 71e2900f8d..7a29837583 100644
--- a/frontend/src/store/application/actions.js
+++ b/frontend/src/store/application/actions.js
@@ -7,6 +7,8 @@ export const ERROR_UPDATING_APPLICATION_DATA = 'ERROR_UPDATING_APPLICATION_DATA'
export const RECEIVE_APPLICATION = 'RECEIVE_APPLICATION';
export const UPDATE_APPLICATION_FIELD = 'UPDATE_APPLICATION_FIELD';
+export const DELETE_APPLICATION = 'DELETE_APPLICATION';
+export const ERROR_DELETE_APPLICATION = 'ERROR_DELETE_APPLICATION';
const recieveAllApplications = json => ({
type: RECEIVE_ALL_APPLICATIONS,
@@ -41,3 +43,11 @@ export function fetchApplication(appName) {
.then(json => dispatch(recieveApplication(json)))
.catch(dispatchAndThrow(dispatch, ERROR_RECEIVE_ALL_APPLICATIONS));
}
+
+export function deleteApplication(appName) {
+ return dispatch =>
+ api
+ .deleteApplication(appName)
+ .then(() => dispatch({ type: DELETE_APPLICATION, appName }))
+ .catch(dispatchAndThrow(dispatch, ERROR_DELETE_APPLICATION));
+}
diff --git a/frontend/src/store/application/index.js b/frontend/src/store/application/index.js
index 8e3dc36689..06da890586 100644
--- a/frontend/src/store/application/index.js
+++ b/frontend/src/store/application/index.js
@@ -1,5 +1,5 @@
import { fromJS, List, Map } from 'immutable';
-import { RECEIVE_ALL_APPLICATIONS, RECEIVE_APPLICATION, UPDATE_APPLICATION_FIELD } from './actions';
+import { RECEIVE_ALL_APPLICATIONS, RECEIVE_APPLICATION, UPDATE_APPLICATION_FIELD, DELETE_APPLICATION } from './actions';
import { USER_LOGOUT, USER_LOGIN } from '../user/actions';
function getInitState() {
@@ -14,6 +14,11 @@ const store = (state = getInitState(), action) => {
return state.set('list', new List(action.value.applications));
case UPDATE_APPLICATION_FIELD:
return state.setIn(['apps', action.appName, action.key], action.value);
+ case DELETE_APPLICATION: {
+ const index = state.get('list').findIndex(item => item.appName === action.appName);
+ const result = state.removeIn(['list', index]);
+ return result.removeIn(['apps', action.appName]);
+ }
case USER_LOGOUT:
case USER_LOGIN:
return getInitState();