UNIQUE_VIOLATION = 'UniqueViolation',
OWNERSHIP_CYCLE = 'OwnershipCycle',
MODIFYING_CONTAINER_REQUEST_FINAL_STATE = 'ModifyingContainerRequestFinalState',
+ NAME_HAS_ALREADY_BEEN_TAKEN = 'NameHasAlreadyBeenTaken',
UNKNOWN = 'Unknown',
NONE = 'None'
}
return CommonResourceServiceError.OWNERSHIP_CYCLE;
case /Mounts cannot be modified in state 'Final'/.test(error):
return CommonResourceServiceError.MODIFYING_CONTAINER_REQUEST_FINAL_STATE;
+ case /Name has already been taken/.test(error):
+ return CommonResourceServiceError.NAME_HAS_ALREADY_BEEN_TAKEN;
default:
return CommonResourceServiceError.UNKNOWN;
}
import { unionize, ofType, UnionOf } from "~/common/unionize";
import { dialogActions } from '~/store/dialog/dialog-actions';
import { RepositoryResource } from "~/models/repositories";
+import { startSubmit, reset, stopSubmit } from "redux-form";
+import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
+import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
+import { projectPanelActions } from '~/store/project-panel/project-panel-action';
export const repositoriesActions = unionize({
SET_REPOSITORIES: ofType<any>(),
export const REPOSITORIES_SAMPLE_GIT_DIALOG = 'repositoriesSampleGitDialog';
export const REPOSITORY_ATTRIBUTES_DIALOG = 'repositoryAttributesDialog';
export const REPOSITORY_CREATE_FORM_NAME = 'repositoryCreateFormName';
+export const REPOSITORY_REMOVE_DIALOG = 'repositoryRemoveDialog';
export const openRepositoriesSampleGitDialog = () =>
(dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
export const openRepositoryCreateDialog = () =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- dispatch(dialogActions.OPEN_DIALOG({ id: REPOSITORY_CREATE_FORM_NAME, data: {} }));
+ const userUuid = await services.authService.getUuid();
+ const user = await services.userService.get(userUuid!);
+ dispatch(reset(REPOSITORY_CREATE_FORM_NAME));
+ dispatch(dialogActions.OPEN_DIALOG({ id: REPOSITORY_CREATE_FORM_NAME, data: { user } }));
};
export const createRepository = (repository: RepositoryResource) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
const userUuid = await services.authService.getUuid();
const user = await services.userService.get(userUuid!);
- await services.repositoriesService.create({ name: `${user.username}/${repository.name}` });
+ 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 }));
};
const repositoriesBindedActions = bindDataExplorerActions(REPOSITORIES_PANEL);
import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
import { AdvancedIcon, RemoveIcon, ShareIcon, AttributesIcon } from "~/components/icon/icon";
-import { openFileRemoveDialog, openRenameFileDialog } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
+import { openRenameFileDialog } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
import { openAdvancedTabDialog } from "~/store/advanced-tab/advanced-tab";
-import { openRepositoryAttributes } from "~/store/repositories/repositories-actions";
+import { openRepositoryAttributes, openRemoveRepositoryDialog } from "~/store/repositories/repositories-actions";
export const repositoryActionSet: ContextMenuActionSet = [[{
name: "Attributes",
name: "Remove",
icon: RemoveIcon,
execute: (dispatch, resource) => {
- dispatch<any>(openFileRemoveDialog(resource.uuid));
+ dispatch<any>(openRemoveRepositoryDialog(resource.uuid));
}
}]];
export const DialogRepositoryCreate = (props: DialogRepositoryProps) =>
<FormDialog
dialogTitle='Add new repository'
- formFields={RepositoryAddField}
+ formFields={RepositoryNameField}
submitLabel='CREATE REPOSITORY'
{...props}
/>;
-const RepositoryAddField = () =>
- <RepositoryNameField />;
import { Field } from "redux-form";
import { TextField } from "~/components/text-field/text-field";
import { REPOSITORY_NAME_VALIDATION } from "~/validators/validators";
+import { Grid } from "@material-ui/core";
-export const RepositoryNameField = () =>
- <span>
- pawelkowalczyk/
- <Field
- name='name'
- component={TextField}
- validate={REPOSITORY_NAME_VALIDATION}
- label="Name"
- autoFocus={true} />.git<br/>
+export const RepositoryNameField = (props: any) =>
+ <Grid container style={{ marginTop: '0', paddingTop: '24px' }}>
+ <Grid item xs={3}>
+ {props.data.user.username}/
+ </Grid>
+ <Grid item xs={7} style={{ bottom: '24px', position: 'relative' }}>
+ <Field
+ name='name'
+ component={TextField}
+ validate={REPOSITORY_NAME_VALIDATION}
+ label="Name"
+ autoFocus={true} />
+ </Grid>
+ <Grid item xs={2}>
+ .git
+ </Grid>
+ <Grid item xs={12}>
It may take a minute or two before you can clone your new repository.
- </span>;
\ No newline at end of file
+ </Grid>
+ </Grid>;
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+import { Dispatch, compose } from 'redux';
+import { connect } from "react-redux";
+import { ConfirmationDialog } from "~/components/confirmation-dialog/confirmation-dialog";
+import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog";
+import { removeRepository, REPOSITORY_REMOVE_DIALOG } from '~/store/repositories/repositories-actions';
+
+ const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<any>) => ({
+ onConfirm: () => {
+ props.closeDialog();
+ dispatch<any>(removeRepository(props.data.uuid));
+ }
+});
+
+ export const RemoveRepositoryDialog = compose(
+ withDialog(REPOSITORY_REMOVE_DIALOG),
+ connect(null, mapDispatchToProps)
+)(ConfirmationDialog);
\ No newline at end of file
import { RepositoriesSampleGitDialog } from '~/views-components/repositories-sample-git-dialog/repositories-sample-git-dialog';
import { RepositoryAttributesDialog } from '~/views-components/repository-attributes-dialog/repository-attributes-dialog';
import { CreateRepositoryDialog } from '~/views-components/dialog-forms/create-repository-dialog';
+import { RemoveRepositoryDialog } from '~/views-components/repository-remove-dialog/repository-remove-dialog';
type CssRules = 'root' | 'container' | 'splitter' | 'asidePanel' | 'contentWrapper' | 'content';
<ProcessInputDialog />
<ProjectPropertiesDialog />
<RemoveProcessDialog />
+ <RemoveRepositoryDialog />
<RenameFileDialog />
<RepositoryAttributesDialog />
<RepositoriesSampleGitDialog />