+export const openDetailsPanel = (uuid: string) => detailsPanelActions.OPEN_DETAILS_PANEL(uuid);
+
+export const openProjectPropertiesDialog = () =>
+ (dispatch: Dispatch) => {
+ dispatch<any>(dialogActions.OPEN_DIALOG({ id: PROJECT_PROPERTIES_DIALOG_NAME, data: { } }));
+ };
+
+export const deleteProjectProperty = (key: string, value: string) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const { detailsPanel, resources } = getState();
+ const project = getResource(detailsPanel.resourceUuid)(resources) as ProjectResource;
+ try {
+ if (project) {
+ project.properties = deleteProperty(project.properties, key, value);
+ const updatedProject = await services.projectService.update(project.uuid, { properties: project.properties });
+ dispatch(resourcesActions.SET_RESOURCES([updatedProject]));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully deleted.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
+ }
+ } catch (e) {
+ dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_PROPERTIES_FORM_NAME }));
+ throw new Error('Could not remove property from the project.');
+ }
+ };
+
+export const createProjectProperty = (data: TagProperty) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const { detailsPanel, resources } = getState();
+ const project = getResource(detailsPanel.resourceUuid)(resources) as ProjectResource;
+ dispatch(startSubmit(PROJECT_PROPERTIES_FORM_NAME));
+ try {
+ if (project) {
+ const key = data.keyID || data.key;
+ const value = data.valueID || data.value;
+ project.properties = addProperty(project.properties, key, value);
+ const updatedProject = await services.projectService.update(
+ project.uuid, {
+ properties: {...project.properties}
+ }
+ );
+ dispatch(resourcesActions.SET_RESOURCES([updatedProject]));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully added.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
+ dispatch(stopSubmit(PROJECT_PROPERTIES_FORM_NAME));
+ }
+ return;
+ } catch (e) {
+ dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_PROPERTIES_FORM_NAME }));
+ throw new Error('Could not add property to the project.');
+ }
+ };