cy.get('[data-cy=breadcrumb-last]').should('contain', collName);
});
- it.only('shows responsible person for collection if available', () => {
+ it('shows responsible person for collection if available', () => {
cy.createCollection(adminUser.token, {
name: `Test collection ${Math.floor(Math.random() * 999999)}`,
owner_uuid: activeUser.user.uuid,
});
});
- it('can view favourites in workflow', () => {
+ it('can edit project and collections in favorites', () => {
+ cy.createProject({
+ owningUser: adminUser,
+ projectName: 'mySharedWritableProject',
+ canWrite: true,
+ addToFavorites: true
+ });
+
+ cy.createCollection(adminUser.token, {
+ owner_uuid: adminUser.user.uuid,
+ name: `Test target collection ${Math.floor(Math.random() * 999999)}`,
+ }).as('testTargetCollection').then(function (testTargetCollection) {
+ cy.addToFavorites(adminUser.token, adminUser.user.uuid, testTargetCollection.uuid);
+ });
+
+ cy.getAll('@mySharedWritableProject', '@testTargetCollection')
+ .then(function ([mySharedWritableProject, testTargetCollection]) {
+ cy.loginAs(adminUser);
+
+ cy.get('[data-cy=side-panel-tree]').contains('My Favorites').click();
+
+ const newProjectName = `New project name ${mySharedWritableProject.name}`;
+ const newProjectDescription = `New project description ${mySharedWritableProject.name}`;
+ const newCollectionName = `New collection name ${testTargetCollection.name}`;
+ const newCollectionDescription = `New collection description ${testTargetCollection.name}`;
+
+ cy.testEditProjectOrCollection('main', mySharedWritableProject.name, newProjectName, newProjectDescription);
+ cy.testEditProjectOrCollection('main', testTargetCollection.name, newCollectionName, newCollectionDescription, false);
+
+ cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
+
+ cy.get('main').contains(newProjectName).rightclick();
+ cy.contains('Add to public favorites').click();
+ cy.get('main').contains(newCollectionName).rightclick();
+ cy.contains('Add to public favorites').click();
+
+ cy.get('[data-cy=side-panel-tree]').contains('Public Favorites').click();
+
+ cy.testEditProjectOrCollection('main', newProjectName, mySharedWritableProject.name, 'newProjectDescription');
+ cy.testEditProjectOrCollection('main', newCollectionName, testTargetCollection.name, 'newCollectionDescription', false);
+ });
+ });
+
+ it('can view favorites in workflow', () => {
cy.createProject({
owningUser: adminUser,
targetUser: activeUser,
cy.get('[data-cy=context-menu]').should('not.contain', 'Move to trash');
});
});
+
+ it('can edit project in shared with me', () => {
+ cy.createProject({
+ owningUser: adminUser,
+ targetUser: activeUser,
+ projectName: 'mySharedWritableProject',
+ canWrite: true,
+ addToFavorites: true
+ });
+
+ cy.getAll('@mySharedWritableProject')
+ .then(function ([mySharedWritableProject]) {
+ cy.loginAs(activeUser);
+
+ cy.get('[data-cy=side-panel-tree]').contains('Shared with me').click();
+
+ const newProjectName = `New project name ${mySharedWritableProject.name}`;
+ const newProjectDescription = `New project description ${mySharedWritableProject.name}`;
+
+ cy.testEditProjectOrCollection('main', mySharedWritableProject.name, newProjectName, newProjectDescription);
+ });
+ });
});
\ No newline at end of file
})
})
+ it('can edit project in side panel', () => {
+ cy.createProject({
+ owningUser: activeUser,
+ targetUser: activeUser,
+ projectName: 'mySharedWritableProject',
+ canWrite: true,
+ addToFavorites: false
+ });
+
+ cy.getAll('@mySharedWritableProject')
+ .then(function ([mySharedWritableProject]) {
+ cy.loginAs(activeUser);
+
+ cy.get('[data-cy=side-panel-tree]').contains('Projects').click();
+
+ const newProjectName = `New project name ${mySharedWritableProject.name}`;
+ const newProjectDescription = `New project description ${mySharedWritableProject.name}`;
+
+ cy.testEditProjectOrCollection('[data-cy=side-panel-tree]', mySharedWritableProject.name, newProjectName, newProjectDescription);
+ });
+ });
+
})
}
)
+Cypress.Commands.add(
+ "testEditProjectOrCollection", (container, oldName, newName, newDescription, isProject = true) => {
+ cy.get(container).contains(oldName).rightclick();
+ cy.get('[data-cy=context-menu]').contains(isProject ? 'Edit project' : 'Edit collection').click();
+ cy.get('[data-cy=form-dialog]').within(() => {
+ cy.get('input[name=name]').clear().type(newName);
+ cy.get(isProject ? 'div[contenteditable=true]' : 'input[name=description]').clear().type(newDescription);
+ cy.get('[data-cy=form-submit-btn]').click();
+ });
+
+ cy.get(container).contains(newName).rightclick();
+ cy.get('[data-cy=context-menu]').contains(isProject ? 'Edit project' : 'Edit collection').click();
+ cy.get('[data-cy=form-dialog]').within(() => {
+ cy.get('input[name=name]').should('have.value', newName);
+
+ if (isProject) {
+ cy.get('span[data-text=true]').contains(newDescription);
+ } else {
+ cy.get('input[name=description]').should('have.value', newDescription);
+ }
+
+ cy.get('[data-cy=form-cancel-btn]').click();
+ });
+ }
+)
+
Cypress.Commands.add(
"doSearch", (searchTerm) => {
cy.get('[data-cy=searchbar-input-field]').type(`{selectall}${searchTerm}{enter}`);
name: '',
uuid: '',
ownerUuid: '',
+ description: '',
kind: ResourceKind.COLLECTION,
menuKind: isCollectionFileSelected
? isWritable
uuid: res.uuid,
kind: res.kind,
menuKind,
+ description: res.description,
ownerUuid: res.ownerUuid,
isTrashed: ('isTrashed' in res) ? res.isTrashed : false,
}));
import { DataTableDefaultView } from '~/components/data-table-default-view/data-table-default-view';
import { createTree } from '~/models/tree';
import { getSimpleObjectTypeFilters } from '~/store/resource-type-filters/resource-type-filters';
-import { ResourcesState } from '~/store/resources/resources';
+import { getResource, ResourcesState } from '~/store/resources/resources';
+import { GroupContentsResource } from '~/services/groups-service/groups-service';
+import { GroupClass, GroupResource } from '~/models/group';
+import { getProperty } from '~/store/properties/properties';
+import { PROJECT_PANEL_CURRENT_UUID } from '~/store/project-panel/project-panel-action';
type CssRules = "toolbar" | "button";
];
interface FavoritePanelDataProps {
+ currentItemId: any;
favorites: FavoritesState;
resources: ResourcesState;
userUuid: string;
favorites: state.favorites,
resources: state.resources,
userUuid: state.auth.user!.uuid,
+ currentItemId: getProperty(PROJECT_PANEL_CURRENT_UUID)(state.properties),
});
type FavoritePanelProps = FavoritePanelDataProps & FavoritePanelActionProps & DispatchProp
class extends React.Component<FavoritePanelProps> {
handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
- const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid));
- if (menuKind) {
+ const { resources } = this.props;
+ const resource = getResource<GroupContentsResource>(resourceUuid)(resources);
+
+ let readonly = false;
+ const project = getResource<GroupResource>(this.props.currentItemId)(resources);
+
+ if (project && project.groupClass === GroupClass.FILTER) {
+ readonly = true;
+ }
+
+ const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid, readonly));
+
+ if (menuKind&& resource) {
this.props.dispatch<any>(openContextMenu(event, {
- name: '',
- uuid: resourceUuid,
- ownerUuid: '',
- kind: ResourceKind.NONE,
- menuKind
+ name: resource.name,
+ uuid: resource.uuid,
+ ownerUuid: resource.ownerUuid,
+ isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false,
+ kind: resource.kind,
+ menuKind,
+ description: resource.description,
}));
}
this.props.dispatch<any>(loadDetailsPanel(resourceUuid));
ownerUuid: resource.ownerUuid,
isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false,
kind: resource.kind,
- menuKind
+ menuKind,
+ description: resource.description,
}));
}
this.props.dispatch<any>(loadDetailsPanel(resourceUuid));
import { getSimpleObjectTypeFilters } from '~/store/resource-type-filters/resource-type-filters';
import { PUBLIC_FAVORITE_PANEL_ID } from '~/store/public-favorites-panel/public-favorites-action';
import { PublicFavoritesState } from '~/store/public-favorites/public-favorites-reducer';
+import { getResource, ResourcesState } from '~/store/resources/resources';
+import { GroupContentsResource } from '~/services/groups-service/groups-service';
type CssRules = "toolbar" | "button";
interface PublicFavoritePanelDataProps {
publicFavorites: PublicFavoritesState;
+ resources: ResourcesState;
}
interface PublicFavoritePanelActionProps {
onItemClick: (item: string) => void;
- onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string) => void;
+ onContextMenu: (resources: ResourcesState) => (event: React.MouseEvent<HTMLElement>, item: string) => void;
onDialogOpen: (ownerUuid: string) => void;
onItemDoubleClick: (item: string) => void;
}
-const mapStateToProps = ({ publicFavorites }: RootState): PublicFavoritePanelDataProps => ({
- publicFavorites
+const mapStateToProps = ({ publicFavorites, resources }: RootState): PublicFavoritePanelDataProps => ({
+ publicFavorites,
+ resources,
});
const mapDispatchToProps = (dispatch: Dispatch): PublicFavoritePanelActionProps => ({
- onContextMenu: (event, resourceUuid) => {
+ onContextMenu: (resources: ResourcesState) => (event, resourceUuid) => {
+ const resource = getResource<GroupContentsResource>(resourceUuid)(resources);
const kind = dispatch<any>(resourceUuidToContextMenuKind(resourceUuid));
- if (kind) {
+ if (kind && resource) {
dispatch<any>(openContextMenu(event, {
- name: '',
+ name: resource.name,
+ description: resource.description,
uuid: resourceUuid,
ownerUuid: '',
kind: ResourceKind.NONE,
id={PUBLIC_FAVORITE_PANEL_ID}
onRowClick={this.props.onItemClick}
onRowDoubleClick={this.props.onItemDoubleClick}
- onContextMenu={this.props.onContextMenu}
+ onContextMenu={this.props.onContextMenu(this.props.resources)}
contextMenuColumn={true}
dataTableDefaultView={
<DataTableDefaultView
const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(resourceUuid));
if (menuKind && resource) {
this.props.dispatch<any>(openContextMenu(event, {
- name: '',
+ name: resource.name,
uuid: resource.uuid,
+ description: resource.description,
ownerUuid: resource.ownerUuid,
isTrashed: ('isTrashed' in resource) ? resource.isTrashed: false,
kind: resource.kind,