+ dispatch(startSubmit(REPOSITORY_CREATE_FORM_NAME));
+ try {
+ const newRepository = await services.repositoriesService.create({ name: `${user.username}/${repository.name}` });
+ dispatch(dialogActions.CLOSE_DIALOG({ id: REPOSITORY_CREATE_FORM_NAME }));
+ dispatch(reset(REPOSITORY_CREATE_FORM_NAME));
+ dispatch<any>(loadRepositoriesData());
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Repository has been successfully created.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
+ return newRepository;
+ } catch (e) {
+ const error = getCommonResourceServiceError(e);
+ if (error === CommonResourceServiceError.NAME_HAS_ALREADY_BEEN_TAKEN) {
+ dispatch(stopSubmit(REPOSITORY_CREATE_FORM_NAME, { name: 'Repository with the same name already exists.' }));
+ }
+ return undefined;
+ }
+ };
+
+export const openRemoveRepositoryDialog = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(dialogActions.OPEN_DIALOG({
+ id: REPOSITORY_REMOVE_DIALOG,
+ data: {
+ title: 'Remove repository',
+ text: 'Are you sure you want to remove this repository?',
+ confirmButtonLabel: 'Remove',
+ uuid
+ }
+ }));
+ };
+
+export const removeRepository = (uuid: string) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
+ await services.repositoriesService.delete(uuid);
+ dispatch<any>(loadRepositoriesData());
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removed.', hideDuration: 2000 }));