diff --git a/app/api/migrations/migrations/161-update-translations/index.ts b/app/api/migrations/migrations/161-update-translations/index.ts new file mode 100644 index 0000000000..add40ac863 --- /dev/null +++ b/app/api/migrations/migrations/161-update-translations/index.ts @@ -0,0 +1,57 @@ +/* eslint-disable import/no-default-export */ +import { Db } from 'mongodb'; + +interface Translation { + key: string; +} + +const newKeys: Translation[] = [ + { key: 'Do you want to delete the following items?' }, + { key: 'Already exists' }, +]; + +const deletedKeys: Translation[] = [ + { key: 'Are you sure you want to delete this relationship type?' }, + { key: 'Cannot delete relationship type:' }, + { key: 'Confirm deletion of relationship type:' }, + { key: 'Currently connections only need a title.' }, + { key: 'This relationship type is being used and cannot be deleted.' }, +]; + +export default { + delta: 161, + + reindex: false, + + name: 'update_translations', + + description: 'Updates some translations in settings', + + async up(db: Db) { + const settings = await db.collection('settings').findOne(); + const languages = settings?.languages + .map((l: any) => l.key) + .filter((value: string, index: number, array: any[]) => array.indexOf(value) === index); + + await db.collection('translationsV2').deleteMany({ + key: { $in: deletedKeys.concat(newKeys).map(k => k.key) }, + 'context.id': 'System', + }); + + const insertMany = languages.map(async (l: any) => + db.collection('translationsV2').insertMany( + newKeys.map(k => ({ + key: k.key, + value: k.key, + language: l, + context: { id: 'System', type: 'Uwazi UI', label: 'User Interface' }, + })) + ) + ); + await Promise.all(insertMany); + + process.stdout.write(`${this.name}...\r\n`); + }, +}; + +export { newKeys, deletedKeys }; diff --git a/app/api/migrations/migrations/161-update-translations/specs/161-update_translations.spec.ts b/app/api/migrations/migrations/161-update-translations/specs/161-update_translations.spec.ts new file mode 100644 index 0000000000..ea3322238d --- /dev/null +++ b/app/api/migrations/migrations/161-update-translations/specs/161-update_translations.spec.ts @@ -0,0 +1,59 @@ +import { Db } from 'mongodb'; +import testingDB from 'api/utils/testing_db'; +import migration, { newKeys, deletedKeys } from '../index'; +import { fixtures } from './fixtures'; +import { Fixture } from '../types'; + +let db: Db | null; + +const initTest = async (fixture: Fixture) => { + await testingDB.setupFixturesAndContext(fixture); + db = testingDB.mongodb!; + await migration.up(db); +}; + +describe('migration update translations of settings', () => { + beforeAll(async () => { + jest.spyOn(process.stdout, 'write').mockImplementation((_str: string | Uint8Array) => true); + await initTest(fixtures); + }); + + afterAll(async () => { + await testingDB.disconnect(); + }); + + it('should have a delta number', () => { + expect(migration.delta).toBe(161); + }); + + it('should delete old translations', async () => { + const translations = await testingDB + .mongodb!.collection('translationsV2') + .find({ key: { $in: deletedKeys.map(k => k.key) } }) + .toArray(); + + expect(translations).toEqual([]); + }); + + it('should NOT delete other translations', async () => { + const translations = await testingDB + .mongodb!.collection('translationsV2') + .find({ key: 'Im cool' }) + .toArray(); + + expect(translations.length).toBe(2); + }); + + it('should add new translations per language', async () => { + const translations = await testingDB + .mongodb!.collection('translationsV2') + .find({ key: { $in: newKeys.map(k => k.key) } }) + .toArray(); + + expect(translations.length).toBe(4); + }); + + it('should be idempotent (do not throw an error on multiple runs)', async () => { + await expect(migration.up(testingDB.mongodb!)).resolves.toBe(undefined); + }); +}); diff --git a/app/api/migrations/migrations/161-update-translations/specs/fixtures.ts b/app/api/migrations/migrations/161-update-translations/specs/fixtures.ts new file mode 100644 index 0000000000..6d5986c662 --- /dev/null +++ b/app/api/migrations/migrations/161-update-translations/specs/fixtures.ts @@ -0,0 +1,38 @@ +import db from 'api/utils/testing_db'; +import { Fixture } from '../types'; + +const fixtures: Fixture = { + settings: [{ _id: db.id(), languages: [{ key: 'en' }, { key: 'es' }] }], + translationsV2: [ + { + _id: db.id(), + language: 'en', + context: { id: 'System', label: 'User Interface', type: 'Uwazi UI' }, + key: 'Current value:', + value: 'Current value:', + }, + { + _id: db.id(), + language: 'es', + context: { id: 'System', label: 'User Interface', type: 'Uwazi UI' }, + key: 'Current value:', + value: 'Current value:', + }, + { + _id: db.id(), + language: 'en', + context: { id: 'System', label: 'User Interface', type: 'Uwazi UI' }, + key: 'Im cool', + value: 'Im cool', + }, + { + _id: db.id(), + language: 'es', + context: { id: 'System', label: 'User Interface', type: 'Uwazi UI' }, + key: 'Im cool', + value: 'Im cool', + }, + ], +}; + +export { fixtures }; diff --git a/app/api/migrations/migrations/161-update-translations/types.ts b/app/api/migrations/migrations/161-update-translations/types.ts new file mode 100644 index 0000000000..e2be62654c --- /dev/null +++ b/app/api/migrations/migrations/161-update-translations/types.ts @@ -0,0 +1,6 @@ +interface Fixture { + settings: any; + translationsV2: any; +} + +export type { Fixture }; diff --git a/app/react/App/styles/globals.css b/app/react/App/styles/globals.css index 819f2504e8..7cab9fe447 100644 --- a/app/react/App/styles/globals.css +++ b/app/react/App/styles/globals.css @@ -2350,6 +2350,26 @@ input:checked + .toggle-bg { min-width: 20px; } +.min-w-\[24rem\] { + min-width: 24rem; +} + +.min-w-\[28rem\] { + min-width: 28rem; +} + +.min-w-\[32rem\] { + min-width: 32rem; +} + +.min-w-\[36rem\] { + min-width: 36rem; +} + +.min-w-\[40rem\] { + min-width: 40rem; +} + .min-w-full { min-width: 100%; } diff --git a/app/react/RelationTypes/EditRelationType.js b/app/react/RelationTypes/EditRelationType.js deleted file mode 100644 index 404b0ccc4d..0000000000 --- a/app/react/RelationTypes/EditRelationType.js +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react'; - -import RouteHandler from 'app/App/RouteHandler'; -import { editRelationType } from 'app/RelationTypes/actions/relationTypesActions'; -import relationTypesAPI from 'app/RelationTypes/RelationTypesAPI'; -import { withRouter } from 'app/componentWrappers'; -import TemplateCreator from '../Templates/components/TemplateCreator'; - -class EditRelationTypeComponent extends RouteHandler { - static async requestState(requestParams) { - const [relationType] = await relationTypesAPI.get(requestParams); - relationType.properties = relationType.properties || []; - - return [editRelationType(relationType)]; - } - - render() { - return ( -
- -
- ); - } -} - -export default EditRelationTypeComponent; -const EditRelationType = withRouter(EditRelationTypeComponent); -export { EditRelationType }; diff --git a/app/react/RelationTypes/NewRelationType.js b/app/react/RelationTypes/NewRelationType.js deleted file mode 100644 index 8f3a143f6f..0000000000 --- a/app/react/RelationTypes/NewRelationType.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; - -import RouteHandler from 'app/App/RouteHandler'; -import TemplateCreator from '../Templates/components/TemplateCreator'; - -export default class NewRelationType extends RouteHandler { - render() { - return ( -
- -
- ); - } -} diff --git a/app/react/RelationTypes/components/RelationTypeForm.js b/app/react/RelationTypes/components/RelationTypeForm.js deleted file mode 100644 index fa211924df..0000000000 --- a/app/react/RelationTypes/components/RelationTypeForm.js +++ /dev/null @@ -1,118 +0,0 @@ -import PropTypes from 'prop-types'; -import React, { Component } from 'react'; -import { actions as formActions, Field, Form } from 'react-redux-form'; -import { bindActionCreators } from 'redux'; -import { connect } from 'react-redux'; -import { BackButton } from 'app/Layout'; -import { Icon } from 'UI'; -import { Translate } from 'app/I18N'; -import FormGroup from 'app/DocumentForm/components/FormGroup'; -import { saveRelationType, resetRelationType } from 'app/RelationTypes/actions/relationTypeActions'; - -export class RelationTypeForm extends Component { - componentWillUnmount() { - this.props.resetForm('relationType'); - this.props.setInitial('relationType'); - } - - validation(relationTypes, id) { - return { - name: { - required: val => val && val.trim() !== '', - duplicated: val => { - const name = val || ''; - return !relationTypes.find( - relationType => - relationType._id !== id && - relationType.name.trim().toLowerCase() === name.trim().toLowerCase() - ); - }, - }, - }; - } - - render() { - return ( -
-
-
-
- - - - {(() => { - if ( - this.props.state.dirty && - this.props.state.fields.name && - this.props.state.fields.name.errors.duplicated - ) { - return ( -
- {' '} - Duplicated name -
- ); - } - })()} -
-
-
-
- Currently connections only need a title. -
-
- - -
-
-
-
- ); - } -} - -RelationTypeForm.propTypes = { - relationType: PropTypes.object.isRequired, - relationTypes: PropTypes.object, - saveRelationType: PropTypes.func, - resetRelationType: PropTypes.func, - resetForm: PropTypes.func, - setInitial: PropTypes.func, - state: PropTypes.object, -}; - -export function mapStateToProps(state) { - return { - relationType: state.relationType, - relationTypes: state.relationTypes, - state: state.relationTypeForm, - }; -} - -function mapDispatchToProps(dispatch) { - return bindActionCreators( - { - saveRelationType, - resetRelationType, - resetForm: formActions.reset, - setInitial: formActions.setInitial, - }, - dispatch - ); -} - -export default connect(mapStateToProps, mapDispatchToProps)(RelationTypeForm); diff --git a/app/react/RelationTypes/components/specs/RelationTypeForm.spec.js b/app/react/RelationTypes/components/specs/RelationTypeForm.spec.js deleted file mode 100644 index 75a36666d4..0000000000 --- a/app/react/RelationTypes/components/specs/RelationTypeForm.spec.js +++ /dev/null @@ -1,46 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import Immutable from 'immutable'; - -import { - mapStateToProps, - RelationTypeForm, -} from 'app/RelationTypes/components/RelationTypeForm.js'; - -describe('RelationTypeForm', () => { - let props; - let component; - beforeEach(() => { - props = { - relationType: { name: 'test' }, - relationTypes: Immutable.fromJS([]), - resetForm: jasmine.createSpy('resetForm'), - setInitial: jasmine.createSpy('setInitial'), - handleSubmit: jasmine.createSpy('handleSubmit'), - state: { fields: [] }, - }; - - component = shallow(); - }); - - describe('when unmount', () => { - it('shoould reset the form', () => { - component.unmount(); - expect(props.resetForm).toHaveBeenCalled(); - expect(props.setInitial).toHaveBeenCalled(); - }); - }); - - describe('mapStateToProps', () => { - let state; - beforeEach(() => { - state = { - relationType: Immutable.fromJS({ name: 'relationType name' }), - }; - }); - - it('should map the relationType', () => { - expect(mapStateToProps(state).relationType.toJS()).toEqual({ name: 'relationType name' }); - }); - }); -}); diff --git a/app/react/RelationTypes/specs/EditRelationType.spec.js b/app/react/RelationTypes/specs/EditRelationType.spec.js deleted file mode 100644 index 66a431401e..0000000000 --- a/app/react/RelationTypes/specs/EditRelationType.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import React from 'react'; -import backend from 'fetch-mock'; -import { shallow } from 'enzyme'; - -import { APIURL } from 'app/config.js'; -import EditRelationType from 'app/RelationTypes/EditRelationType'; -import RouteHandler from 'app/App/RouteHandler'; -import TemplateCreator from '../../Templates/components/TemplateCreator'; - -describe('EditRelationType', () => { - const relationType = { name: 'Against' }; - let component; - const props = jasmine.createSpyObj(['editRelationType']); - let context; - - beforeEach(() => { - RouteHandler.renderedFromServer = true; - context = { store: { getState: () => ({}), dispatch: jasmine.createSpy('dispatch') } }; - component = shallow(, { context }); - - backend.restore(); - backend.get(`${APIURL}relationtypes?_id=relationTypeId`, { - body: JSON.stringify({ rows: [relationType] }), - }); - }); - - afterEach(() => backend.restore()); - - it('should render a RelationTypeForm', () => { - expect(component.find(TemplateCreator).length).toBe(1); - }); - - describe('static requestState()', () => { - it('should request the relationTypes using the param relationTypeId', async () => { - const request = { data: { _id: 'relationTypeId' } }; - const actions = await EditRelationType.requestState(request); - expect(actions).toMatchSnapshot(); - }); - }); -}); diff --git a/app/react/RelationTypes/specs/NewRelationType.spec.js b/app/react/RelationTypes/specs/NewRelationType.spec.js deleted file mode 100644 index 18f0b4f7ac..0000000000 --- a/app/react/RelationTypes/specs/NewRelationType.spec.js +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; - -import NewRelationType from 'app/RelationTypes/NewRelationType'; -import TemplateCreator from '../../Templates/components/TemplateCreator'; - -describe('NewRelationType', () => { - let component; - - beforeEach(() => { - const context = { store: { getState: () => ({}) } }; - component = shallow(, { context }); - }); - - it('should render a RelationTypeForm', () => { - expect(component.find(TemplateCreator).length).toBe(1); - }); -}); diff --git a/app/react/RelationTypes/specs/RelationTypesAPI.spec.js b/app/react/RelationTypes/specs/RelationTypesAPI.spec.js deleted file mode 100644 index 135655621c..0000000000 --- a/app/react/RelationTypes/specs/RelationTypesAPI.spec.js +++ /dev/null @@ -1,43 +0,0 @@ -import relationTypesAPI from 'app/RelationTypes/RelationTypesAPI'; -import { APIURL } from 'app/config.js'; -import backend from 'fetch-mock'; -import { RequestParams } from 'app/utils/RequestParams'; - -describe('RelationTypesAPI', () => { - const arrayResponse = [{ name: 'test' }, { name: 'test2' }]; - - beforeEach(() => { - backend.restore(); - backend - .get(`${APIURL}relationtypes?param=value`, { body: JSON.stringify({ rows: arrayResponse }) }) - .delete(`${APIURL}relationtypes?_id=id`, { - body: JSON.stringify({ backednResponse: 'testdelete' }), - }) - .post(`${APIURL}relationtypes`, { body: JSON.stringify({ backednResponse: 'test' }) }); - }); - - afterEach(() => backend.restore()); - - describe('get()', () => { - it('should request relationTypes', async () => { - const response = await relationTypesAPI.get(new RequestParams({ param: 'value' })); - expect(response).toEqual(arrayResponse); - }); - }); - - describe('save()', () => { - it('should post the thesauri data to /relationTypes', async () => { - const data = { name: 'thesauri name', properties: [] }; - const response = await relationTypesAPI.save(new RequestParams(data)); - expect(JSON.parse(backend.lastOptions(`${APIURL}relationtypes`).body)).toEqual(data); - expect(response).toEqual({ backednResponse: 'test' }); - }); - }); - - describe('delete()', () => { - it('should delete the thesauri', async () => { - const response = await relationTypesAPI.delete(new RequestParams({ _id: 'id' })); - expect(response).toEqual({ backednResponse: 'testdelete' }); - }); - }); -}); diff --git a/app/react/RelationTypes/specs/__snapshots__/EditRelationType.spec.js.snap b/app/react/RelationTypes/specs/__snapshots__/EditRelationType.spec.js.snap deleted file mode 100644 index b66ceb29ed..0000000000 --- a/app/react/RelationTypes/specs/__snapshots__/EditRelationType.spec.js.snap +++ /dev/null @@ -1,18 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`EditRelationType static requestState() should request the relationTypes using the param relationTypeId 1`] = ` -Array [ - Object { - "external": true, - "load": true, - "model": "template.data", - "multi": false, - "silent": true, - "type": "rrf/change", - "value": Object { - "name": "Against", - "properties": Array [], - }, - }, -] -`; diff --git a/app/react/Routes.tsx b/app/react/Routes.tsx index b265dfb688..37d0de66b5 100644 --- a/app/react/Routes.tsx +++ b/app/react/Routes.tsx @@ -7,14 +7,11 @@ import Activitylog from 'app/Activitylog/Activitylog'; import Configure2fa from 'app/Auth2fa/Configure2fa'; import { LibraryCards } from 'app/Library/Library'; import { LibraryMap } from 'app/Library/LibraryMap'; -import { EditRelationType } from 'app/RelationTypes/EditRelationType'; -import NewRelationType from 'app/RelationTypes/NewRelationType'; import { PreserveSettings, CustomUploads, EntityTypesList, FiltersForm, - RelationTypesList, Settings, ThesauriList, Dashboard, @@ -42,6 +39,10 @@ import { } from 'V2/Routes/Settings/Translations/EditTranslations'; import { MenuConfig, menuConfigloader } from 'V2/Routes/Settings/MenuConfig/MenuConfig'; +import { + RelationshipTypes, + relationshipTypesLoader, +} from 'V2/Routes/Settings/RelationshipTypes/RelationshipTypes'; import { LanguagesList, languagesListLoader } from 'V2/Routes/Settings/Languages/LanguagesList'; import { Account, accountLoader } from 'V2/Routes/Settings/Account/Account'; import { dashboardLoader, IXDashboard } from 'V2/Routes/Settings/IX/IXDashboard'; @@ -122,10 +123,12 @@ const getRoutesLayout = ( loader={IXSuggestionsLoader(headers)} element={adminsOnlyRoute()} /> - - )} /> - )} /> - )} /> + + )} + loader={relationshipTypesLoader(headers)} + /> )} /> diff --git a/app/react/Settings/components/RelationTypesList.js b/app/react/Settings/components/RelationTypesList.js deleted file mode 100644 index b093f828aa..0000000000 --- a/app/react/Settings/components/RelationTypesList.js +++ /dev/null @@ -1,129 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; -import { withRouter, withContext } from 'app/componentWrappers'; -import { I18NLink, t, Translate } from 'app/I18N'; -import { - deleteRelationType, - checkRelationTypeCanBeDeleted, -} from 'app/RelationTypes/actions/relationTypesActions'; -import relationTypesAPI from 'app/RelationTypes/RelationTypesAPI'; -import RouteHandler from 'app/App/RouteHandler'; -import { Icon } from 'UI'; -import { actions } from 'app/BasicReducer'; -import { notify } from 'app/Notifications/actions/notificationsActions'; -import { SettingsHeader } from './SettingsHeader'; - -class RelationTypesListComponent extends RouteHandler { - static async requestState(requestParams) { - const relationTypes = await relationTypesAPI.get(requestParams.onlyHeaders()); - return [actions.set('relationTypes', relationTypes)]; - } - - deleteRelationType(relationType) { - return this.props - .checkRelationTypeCanBeDeleted(relationType) - .then(() => { - this.props.mainContext.confirm({ - accept: () => { - this.props.deleteRelationType(relationType); - }, - title: ( - <> - Confirm deletion of relationship type: {relationType.name} - - ), - message: 'Are you sure you want to delete this relationship type?', - }); - }) - .catch(() => { - this.props.mainContext.confirm({ - accept: () => {}, - noCancel: true, - title: ( - <> - Cannot delete relationship type: {relationType.name} - - ), - message: 'This relationship type is being used and cannot be deleted.', - }); - }); - } - - render() { - return ( -
-
- - Relationship types - -
    - {this.props.relationTypes.toJS().map((relationType, index) => ( -
  • - - {relationType.name} - -
    - - -   - {t('System', 'Edit')} - - - -   - {t('System', 'Delete')} - -
    -
  • - ))} -
-
- - - {t('System', 'Add relationship')} - -
-
-
- ); - } -} - -RelationTypesListComponent.propTypes = { - relationTypes: PropTypes.object, - deleteRelationType: PropTypes.func, - notify: PropTypes.func, - checkRelationTypeCanBeDeleted: PropTypes.func, - mainContext: PropTypes.shape({ - confirm: PropTypes.func, - }).isRequired, -}; - -RelationTypesListComponent.contextTypes = { - store: PropTypes.object, -}; - -function mapStateToProps(state) { - return { relationTypes: state.relationTypes }; -} - -function mapDispatchToProps(dispatch) { - return bindActionCreators( - { notify, deleteRelationType, checkRelationTypeCanBeDeleted }, - dispatch - ); -} -const RelationTypesList = connect( - mapStateToProps, - mapDispatchToProps -)(withRouter(withContext(RelationTypesListComponent))); - -export { RelationTypesList, mapStateToProps, RelationTypesListComponent }; diff --git a/app/react/Settings/components/SettingsNavigation.tsx b/app/react/Settings/components/SettingsNavigation.tsx index bbc5ee1b84..2f325b078f 100644 --- a/app/react/Settings/components/SettingsNavigation.tsx +++ b/app/react/Settings/components/SettingsNavigation.tsx @@ -87,7 +87,11 @@ const SettingsNavigationComponent = ({ allowcustomJS }: { allowcustomJS: boolean - + Relationship types diff --git a/app/react/Settings/components/specs/RelationTypesList.spec.js b/app/react/Settings/components/specs/RelationTypesList.spec.js deleted file mode 100644 index 5dac4c82df..0000000000 --- a/app/react/Settings/components/specs/RelationTypesList.spec.js +++ /dev/null @@ -1,66 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import Immutable from 'immutable'; -import { RelationTypesListComponent as RelationTypesList } from '../RelationTypesList'; - -describe('RelationTypesList', () => { - let component; - let props; - let context; - - beforeEach(() => { - props = { - relationTypes: Immutable.fromJS([ - { _id: 1, name: 'Against' }, - { _id: 2, name: 'Supports' }, - ]), - notify: jasmine.createSpy('notify'), - deleteRelationType: jasmine - .createSpy('deleteRelationType') - .and.callFake(async () => Promise.resolve()), - checkRelationTypeCanBeDeleted: jasmine - .createSpy('checkRelationTypeCanBeDeleted') - .and.callFake(async () => Promise.resolve()), - mainContext: { confirm: jasmine.createSpy('confirm') }, - }; - - context = { - store: { getState: () => ({}) }, - }; - }); - - const render = () => { - component = shallow(, { context }); - }; - - describe('render', () => { - it('should a list with the document types', () => { - render(); - expect(component.find('ul.relation-types').find('li').length).toBe(2); - }); - }); - - describe('when deleting a relation type', () => { - it('should check if can be deleted', done => { - render(); - component - .instance() - .deleteRelationType({ _id: 1, name: 'Decision' }) - .then(() => { - expect(props.checkRelationTypeCanBeDeleted).toHaveBeenCalled(); - done(); - }); - }); - - it('should confirm the action', done => { - render(); - component - .instance() - .deleteRelationType({ _id: 1, name: 'Decision' }) - .then(() => { - expect(props.mainContext.confirm).toHaveBeenCalled(); - done(); - }); - }); - }); -}); diff --git a/app/react/Settings/index.js b/app/react/Settings/index.js index 8d8462663e..1fde87e932 100644 --- a/app/react/Settings/index.js +++ b/app/react/Settings/index.js @@ -1,7 +1,6 @@ /* eslint-disable import/no-named-as-default */ import EntityTypesList from './components/EntityTypesList'; import FiltersForm from './components/FiltersForm'; -import { RelationTypesList } from './components/RelationTypesList'; import ThesauriList from './components/ThesauriList'; import { Settings } from './Settings'; import SettingsAPI from './SettingsAPI'; @@ -15,7 +14,6 @@ export { SettingsAPI, PreserveSettings, EntityTypesList, - RelationTypesList, ThesauriList, FiltersForm, Dashboard, diff --git a/app/react/Templates/components/MetadataTemplate.tsx b/app/react/Templates/components/MetadataTemplate.tsx index 07e8341cc8..e7af2bfe08 100644 --- a/app/react/Templates/components/MetadataTemplate.tsx +++ b/app/react/Templates/components/MetadataTemplate.tsx @@ -1,3 +1,5 @@ +/* eslint-disable react/no-multi-comp */ +/* eslint-disable comma-spacing */ /* eslint-disable max-lines */ import React, { Component } from 'react'; import { DropTarget } from 'react-dnd-old'; @@ -13,6 +15,9 @@ import ColorPicker from 'app/Forms/components/ColorPicker'; import { I18NLink, t, Translate } from 'app/I18N'; import { notificationActions } from 'app/Notifications'; import { notify } from 'app/Notifications/actions/notificationsActions'; +import { templatesAtom } from 'app/V2/atoms'; +import { useSetRecoilState } from 'recoil'; +import api from 'app/Templates/TemplatesAPI'; import { addProperty, inserted, @@ -47,6 +52,7 @@ interface MetadataTemplateProps { syncedTemplate?: boolean; _id?: string; mainContext: { confirm: Function }; + updateTemplatesAtom: Function; } const getTemplateDefaultColor = (allTemplates: List, template: any) => @@ -65,6 +71,7 @@ class MetadataTemplate extends Component { defaultColor: null, properties: [], mainContext: { confirm: (_props: {}) => {} }, + updateTemplatesAtom: (_templates: any) => {}, }; confirmation = { @@ -111,6 +118,9 @@ class MetadataTemplate extends Component { } try { await this.props.saveTemplate(template); + const templates = await api.get('templates'); + console.log('templates', templates); + this.props.updateTemplatesAtom(templates); } catch (e) { if (e.status === 409) return this.confirmAndSaveTemplate(template, 'templateConflict'); } @@ -292,6 +302,7 @@ MetadataTemplate.propTypes = { defaultColor: PropTypes.string, entityViewPage: PropTypes.string, environment: PropTypes.string.isRequired, + updateTemplatesAtom: PropTypes.func.isRequired, }; /* eslint-enable react/forbid-prop-types, react/require-default-props */ @@ -315,9 +326,16 @@ const target = { }, }; +const withTemplatesAtom = + (Comp: React.ComponentClass) => + (props: T) => { + const updateTemplatesAtom = useSetRecoilState(templatesAtom); + return ; + }; + const dropTarget = DropTarget('METADATA_OPTION', target, (connector: any) => ({ connectDropTarget: connector.dropTarget(), -}))(MetadataTemplate); +}))(withTemplatesAtom(MetadataTemplate)); const mapStateToProps = ( { diff --git a/app/react/V2/Components/UI/ConfirmationModal.tsx b/app/react/V2/Components/UI/ConfirmationModal.tsx index c0d5649022..2386537bf3 100644 --- a/app/react/V2/Components/UI/ConfirmationModal.tsx +++ b/app/react/V2/Components/UI/ConfirmationModal.tsx @@ -35,6 +35,7 @@ const ConfirmationModal = ({ isString(child) ? {child} : child; const wordForConfirmation = t('System', confirmWord, null, false); + return ( diff --git a/app/react/V2/Components/UI/Modal.tsx b/app/react/V2/Components/UI/Modal.tsx index 03975f7686..b2af3d8402 100644 --- a/app/react/V2/Components/UI/Modal.tsx +++ b/app/react/V2/Components/UI/Modal.tsx @@ -11,17 +11,17 @@ interface ModalProps { const Modal = ({ children, size }: ModalProps) => { const sizes = { sm: 'max-w-sm', - md: 'max-w-md', - lg: 'max-w-lg', - xl: 'max-w-xl', - xxl: 'max-w-2xl', - xxxl: 'max-w-3xl', + md: 'max-w-md min-w-[24rem]', + lg: 'max-w-lg min-w-[28rem]', + xl: 'max-w-xl min-w-[32rem]', + xxl: 'max-w-2xl min-w-[36rem]', + xxxl: 'max-w-3xl min-w-[40rem]', }; return (
( ); Modal.Footer = ({ children }: ModalChildrenProps) => ( -
+
{children}
); diff --git a/app/react/V2/Components/UI/Table/Table.tsx b/app/react/V2/Components/UI/Table/Table.tsx index 20b36678a7..8179cbf2b9 100644 --- a/app/react/V2/Components/UI/Table/Table.tsx +++ b/app/react/V2/Components/UI/Table/Table.tsx @@ -56,7 +56,7 @@ const Table = ({ header: CheckBoxHeader, cell: CheckBoxCell, }, - className: 'w-0', + meta: { headerClassName: 'w-0' }, }, ], [], diff --git a/app/react/V2/Routes/Settings/MenuConfig/MenuConfig.tsx b/app/react/V2/Routes/Settings/MenuConfig/MenuConfig.tsx index e6df7f95d9..0ccdae61a7 100644 --- a/app/react/V2/Routes/Settings/MenuConfig/MenuConfig.tsx +++ b/app/react/V2/Routes/Settings/MenuConfig/MenuConfig.tsx @@ -205,7 +205,7 @@ const MenuConfig = () => { } isOpen={isSidepanelOpen} closeSidepanelFunction={() => setIsSidepanelOpen(false)} - size="large" + size="medium" withOverlay > + async () => + relationshipTypesAPI.get(headers); + +const RelationshipTypes = () => { + const relationshipTypes = useLoaderData() as ClientRelationshipType[]; + const revalidator = useRevalidator(); + + const [isSidepanelOpen, setIsSidepanelOpen] = useState(false); + const [showConfirmationModal, setShowConfirmationModal] = useState(false); + const setNotifications = useSetRecoilState(notificationAtom); + const setRelationshipTypes = useSetRecoilState(relationshipTypesAtom); + const templates = useRecoilValue(templatesAtom); + + interface formType extends Omit { + _id?: string; + } + const [formValues, setFormValues] = useState({} as ClientRelationshipType); + + const [selectedItems, setSelectedItems] = useState[]>([]); + const [tableRelationshipTypes, setTableRelationshipTypes] = useState([]); + + useEffect(() => { + setTableRelationshipTypes( + relationshipTypes.map(relationshipType => { + const templatesUsingIt = templates + .map(t => { + const usingIt = t.properties?.some( + property => property.relationType === relationshipType._id + ); + return usingIt ? t : null; + }) + .filter(t => t) as Template[]; + + return { + ...relationshipType, + templates: templatesUsingIt, + disableRowSelection: Boolean(templatesUsingIt.length), + }; + }) + ); + }, [relationshipTypes, templates]); + + const edit = (row: Row) => { + setFormValues(row.original); + setIsSidepanelOpen(true); + }; + + const add = () => { + setFormValues({ name: '' }); + setIsSidepanelOpen(true); + }; + + const submit = async (submitedData: ClientRelationshipType) => { + try { + await relationshipTypesAPI.save(submitedData); + setNotifications({ + type: 'success', + text: Updated, + }); + setIsSidepanelOpen(false); + } catch (error) { + setNotifications({ + type: 'error', + text: An error occurred, + details: error.error, + }); + setIsSidepanelOpen(false); + } + revalidator.revalidate(); + setRelationshipTypes(relationshipTypes); + }; + + const deleteSelected = async () => { + try { + await relationshipTypesAPI.deleteRelationtypes(selectedItems.map(item => item.original._id)); + setNotifications({ + type: 'success', + text: Updated, + }); + setShowConfirmationModal(false); + } catch (error) { + setNotifications({ + type: 'error', + text: An error occurred, + details: error.error, + }); + setShowConfirmationModal(false); + } + revalidator.revalidate(); + setRelationshipTypes(relationshipTypes); + }; + + return ( +
+ + + + + enableSelection + columns={columns({ edit })} + data={tableRelationshipTypes} + title={Relationship types} + onSelection={setSelectedItems} + /> + + + {selectedItems.length > 0 && ( +
+ + Selected {selectedItems.length} of + {relationshipTypes.length} +
+ )} + {selectedItems.length === 0 && ( +
+
+ +
+
+ )} +
+
+ + {`${formValues?.name === '' ? 'Add' : 'Edit'} relationship type`} + + } + isOpen={isSidepanelOpen} + closeSidepanelFunction={() => setIsSidepanelOpen(false)} + size="medium" + withOverlay + > +
setIsSidepanelOpen(false)} + currentTypes={relationshipTypes} + submit={submit} + /> + + {showConfirmationModal && ( + Delete} + warningText={Do you want to delete the following items?} + body={ +
    + {selectedItems.map(item => ( +
  • {item.original.name}
  • + ))} +
+ } + onAcceptClick={deleteSelected} + onCancelClick={() => setShowConfirmationModal(false)} + dangerStyle + /> + )} +
+ ); +}; + +export { RelationshipTypes, relationshipTypesLoader }; diff --git a/app/react/V2/Routes/Settings/RelationshipTypes/components/Form.tsx b/app/react/V2/Routes/Settings/RelationshipTypes/components/Form.tsx new file mode 100644 index 0000000000..ff09140215 --- /dev/null +++ b/app/react/V2/Routes/Settings/RelationshipTypes/components/Form.tsx @@ -0,0 +1,72 @@ +/* eslint-disable react/jsx-props-no-spreading */ +import React from 'react'; + +import { Translate } from 'app/I18N'; +import { InputField } from 'app/V2/Components/Forms'; +import { useForm } from 'react-hook-form'; +import { ClientRelationshipType } from 'app/apiResponseTypes'; +import { Button, Card } from 'app/V2/Components/UI'; + +interface FormProps { + closePanel: () => void; + relationtype?: ClientRelationshipType; + submit: (formValues: ClientRelationshipType) => void; + currentTypes: ClientRelationshipType[]; +} + +const Form = ({ closePanel, submit, relationtype, currentTypes }: FormProps) => { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm({ + values: relationtype, + mode: 'onSubmit', + }); + + return ( +
+ + Relationship Type}> +
+ Name} + {...register('name', { + required: true, + validate: { + alreadyExists: value => !currentTypes.some(type => type.name === value), + }, + })} + hasErrors={!!errors.name} + errorMessage={ + errors.name?.type === 'alreadyExists' ? Already exists : null + } + /> +
+
+ +
+ + +
+
+ ); +}; + +export { Form }; diff --git a/app/react/V2/Routes/Settings/RelationshipTypes/components/TableComponents.tsx b/app/react/V2/Routes/Settings/RelationshipTypes/components/TableComponents.tsx new file mode 100644 index 0000000000..2bcd4c2972 --- /dev/null +++ b/app/react/V2/Routes/Settings/RelationshipTypes/components/TableComponents.tsx @@ -0,0 +1,72 @@ +/* eslint-disable react/no-multi-comp */ +import React from 'react'; +import { Translate } from 'app/I18N'; +import { CellContext, ColumnDef, createColumnHelper } from '@tanstack/react-table'; +import { Button, Pill } from 'app/V2/Components/UI'; +import { ClientRelationshipType, Template } from 'app/apiResponseTypes'; +interface TableRelationshipType extends ClientRelationshipType { + templates: Template[]; + disableRowSelection: boolean; +} + +const EditButton = ({ cell, column }: CellContext) => ( + +); + +const TitleCell = ({ cell, getValue }: CellContext) => ( +
+ + {getValue()} + + ({getValue()}) +
+); + +const templatesCells = ({ + cell, +}: CellContext) => ( +
+ {cell.getValue()?.map(template => ( +
+ + {template.name} + +
+ ))} +
+); + +const TitleHeader = () => Label; +const ActionHeader = () => Action; +const TemplateHeader = () => Templates; + +const columnHelper = createColumnHelper(); +const columns = (actions: { edit: Function }) => [ + columnHelper.accessor('name', { + id: 'name', + header: TitleHeader, + cell: TitleCell, + enableSorting: true, + meta: { headerClassName: 'w-1/2' }, + }) as ColumnDef, + columnHelper.accessor('templates', { + header: TemplateHeader, + cell: templatesCells, + enableSorting: false, + meta: { headerClassName: 'w-1/2' }, + }) as ColumnDef, + columnHelper.accessor('key', { + header: ActionHeader, + cell: EditButton, + enableSorting: false, + meta: { action: actions.edit, headerClassName: 'w-0 text-center' }, + }) as ColumnDef, +]; +export { EditButton, TitleHeader, TitleCell, columns }; +export type { TableRelationshipType }; diff --git a/app/react/V2/api/relationshiptypes/index.ts b/app/react/V2/api/relationshiptypes/index.ts new file mode 100644 index 0000000000..e220f9c87f --- /dev/null +++ b/app/react/V2/api/relationshiptypes/index.ts @@ -0,0 +1,32 @@ +import { IncomingHttpHeaders } from 'http'; +import { ClientRelationshipType } from 'app/apiResponseTypes'; +import api from 'app/utils/api'; +import { RequestParams } from 'app/utils/RequestParams'; + +const get = async (headers?: IncomingHttpHeaders): Promise => { + const requestParams = new RequestParams({}, headers); + return api.get('relationtypes', requestParams).then((response: any) => response.json.rows); +}; + +const save = async (relationshipType: ClientRelationshipType): Promise => { + const requestParams = new RequestParams(relationshipType); + return api.post('relationtypes', requestParams).then((response: any) => response.json); +}; + +const deleteRelationtypes = async (ids: string[]) => { + const allDeleted = ids.map(async id => { + const requestParams = new RequestParams({ _id: id }); + return api.delete('relationtypes', requestParams).then((response: any) => response.json); + }); + + return Promise.all(allDeleted); +}; + +const relationshipTypeBeingUsed = async (relationtypeId: string) => { + const requestParams = new RequestParams({ relationtypeId }); + return api + .get('references/count_by_relationtype', requestParams) + .then((response: any) => response.json > 0); +}; + +export { get, save, deleteRelationtypes, relationshipTypeBeingUsed }; diff --git a/app/react/V2/atoms/relationshipTypes.ts b/app/react/V2/atoms/relationshipTypes.ts new file mode 100644 index 0000000000..013e1ea5ad --- /dev/null +++ b/app/react/V2/atoms/relationshipTypes.ts @@ -0,0 +1,18 @@ +import { atom } from 'recoil'; +import { ClientRelationshipType } from 'app/apiResponseTypes'; +import { store } from 'app/store'; + +const relationshipTypesAtom = atom({ + key: 'relationshipTypes', + default: [] as ClientRelationshipType[], + //sync deprecated redux store + effects: [ + ({ onSet }) => { + onSet(newValue => { + store?.dispatch({ type: 'relationTypes/SET', value: newValue }); + }); + }, + ], +}); + +export { relationshipTypesAtom }; diff --git a/app/react/apiResponseTypes.d.ts b/app/react/apiResponseTypes.d.ts index d576a575a6..4278e3f0e5 100644 --- a/app/react/apiResponseTypes.d.ts +++ b/app/react/apiResponseTypes.d.ts @@ -5,9 +5,9 @@ import { Settings, SettingsFilterSchema, SettingsLinkSchema, - TemplateSchema, } from 'shared/types/settingsType'; import { LanguageSchema } from 'shared/types/commonTypes'; +import { TemplateSchema } from 'shared/types/templateType'; export interface GroupMemberSchema { refId: string; @@ -50,7 +50,7 @@ export interface ClientLanguageSchema extends Omit { _id?: string; } -export interface Template extends Omit { +export interface Template extends TemplateSchema, Omit { _id: string; } @@ -73,3 +73,8 @@ export interface ClientSettings [k: string]: unknown | undefined; }; } + +export interface ClientRelationshipType { + _id: string; + name: string; +} diff --git a/contents/ui-translations/ar.csv b/contents/ui-translations/ar.csv index ec365b4ea7..5b03b46dfb 100644 --- a/contents/ui-translations/ar.csv +++ b/contents/ui-translations/ar.csv @@ -61,6 +61,7 @@ ALL,ALL All,All "All changes will be lost, are you sure you want to proceed?",ستحذف جميع التغييرات، هل أنت متأكد أنك تريد المتابعة؟ Allow captcha bypass,Allow captcha bypass +Already exists,Already exists An error has occured while deleting a language:,An error has occured while deleting a language: An error has occured while installing languages:,An error has occured while installing languages: An error has occurred during data export,An error has occurred during data export @@ -75,7 +76,6 @@ Are you sure you want to delete this connection?,Are you sure you want to delete Are you sure you want to delete this entity?,Are you sure you want to delete this entity? Are you sure you want to delete this file?,Are you sure you want to delete this file? Are you sure you want to delete this item?,Are you sure you want to delete this item? -Are you sure you want to delete this relationship type?,Are you sure you want to delete this relationship type? Are you sure you want to delete this thesaurus?,Are you sure you want to delete this thesaurus? Are you sure?,Are you sure? Attachment deleted,Attachment deleted @@ -103,7 +103,6 @@ Can see,إمكانية الرؤية Can view,إمكانية المعاينة Cancel,الغاء Canceling...,Canceling... -Cannot delete relationship type:,Cannot delete relationship type: Cannot delete template:,Cannot delete template: Cannot delete thesaurus:,Cannot delete thesaurus: Captcha,حروف التحقق @@ -150,7 +149,6 @@ Confirm deletion,تأكيد الحذف Confirm deletion of,Confirm deletion of Confirm deletion of entity,Confirm deletion of entity Confirm deletion of file,Confirm deletion of file -Confirm deletion of relationship type:,Confirm deletion of relationship type: Confirm deletion of template:,Confirm deletion of template: Confirm deletion of thesaurus:,Confirm deletion of thesaurus: Confirm discard changes,Confirm discard changes @@ -200,7 +198,6 @@ Created thesaurus,Created thesaurus Created user group,Created user group Current value,Current value Current Value/Suggestion,Current Value/Suggestion -Currently connections only need a title.,لا تحتاج الاتصالات حالياً إلا لعنوان Custom component error,خطأ في المكون المخصص Custom CSS,CSS تنسيق Custom Favicon,Custom Favicon @@ -247,6 +244,7 @@ Discard changes,تجاهل التغييرات Discard changes?,Discard changes? Dismiss,Dismiss Display entity view from page,عرض معاينة الكيان (الإدخال) من الصفحة +Do you want to delete the following items?,Do you want to delete the following items? Document,مستند Document and entity types,انواع الوثائق والكيانات Document contents,محتويات المستند @@ -816,7 +814,6 @@ This property will appear in the library cards as part of the basic info.,ستظ This property will be inherited from the related entities and shown as metadata of this type of entities.,ستورث هذه الخاصية من الكيانات (الإدخالات) ذات الصلة، وستظهر كبيانات وصفية لهذا النوع من الكيانات (الإدخالات) This property will be shown using all the width available.,ستظهر هذه الخاصية باستخدام كل العرض المتاح This property will be shown without the label.,ستظهر هذه الخاصية دون التسمية -This relationship type is being used and cannot be deleted.,This relationship type is being used and cannot be deleted. this template,this template This template has associated entities,This template has associated entities This template will be used as default for new entities.,سيستخدم القالب قالباً افتراضياً للكيانات (للإدخالات) الجديدة diff --git a/contents/ui-translations/en.csv b/contents/ui-translations/en.csv index 2e7d76a4b6..285c88bb09 100644 --- a/contents/ui-translations/en.csv +++ b/contents/ui-translations/en.csv @@ -61,6 +61,7 @@ ALL,ALL All,All "All changes will be lost, are you sure you want to proceed?","All changes will be lost, are you sure you want to proceed?" Allow captcha bypass,Allow captcha bypass +Already exists,Already exists An error has occured while deleting a language:,An error has occured while deleting a language: An error has occured while installing languages:,An error has occured while installing languages: An error has occurred during data export,An error has occurred during data export @@ -75,7 +76,6 @@ Are you sure you want to delete this connection?,Are you sure you want to delete Are you sure you want to delete this entity?,Are you sure you want to delete this entity? Are you sure you want to delete this file?,Are you sure you want to delete this file? Are you sure you want to delete this item?,Are you sure you want to delete this item? -Are you sure you want to delete this relationship type?,Are you sure you want to delete this relationship type? Are you sure you want to delete this thesaurus?,Are you sure you want to delete this thesaurus? Are you sure?,Are you sure? Attachment deleted,Attachment deleted @@ -103,7 +103,6 @@ Can see,Can see Can view,Can view Cancel,Cancel Canceling...,Canceling... -Cannot delete relationship type:,Cannot delete relationship type: Cannot delete template:,Cannot delete template: Cannot delete thesaurus:,Cannot delete thesaurus: Captcha,Captcha @@ -153,7 +152,6 @@ Confirm deletion,Confirm deletion Confirm deletion of,Confirm deletion of Confirm deletion of entity,Confirm deletion of entity Confirm deletion of file,Confirm deletion of file -Confirm deletion of relationship type:,Confirm deletion of relationship type: Confirm deletion of template:,Confirm deletion of template: Confirm deletion of thesaurus:,Confirm deletion of thesaurus: Confirm discard changes,Confirm discard changes @@ -203,7 +201,6 @@ Created thesaurus,Created thesaurus Created user group,Created user group Current value,Current value Current Value/Suggestion,Current Value/Suggestion -Currently connections only need a title.,Currently connections only need a title. Custom component error,Custom component markup error: unsupported values! Please check your configuration Custom CSS,Custom CSS Custom Favicon,Custom Favicon @@ -250,6 +247,7 @@ Discard changes,Discard changes Discard changes?,Discard changes? Dismiss,Dismiss Display entity view from page,Display entity view from page +Do you want to delete the following items?,Do you want to delete the following items? Document,Document Document and entity types,Document and entity types Document contents,Document contents @@ -819,7 +817,6 @@ This property will appear in the library cards as part of the basic info.,This p This property will be inherited from the related entities and shown as metadata of this type of entities.,This property will be inherited from the related entities and shown as metadata of this type of entities. This property will be shown using all the width available.,This property will be shown using all the width available. This property will be shown without the label.,This property will be shown without the label. -This relationship type is being used and cannot be deleted.,This relationship type is being used and cannot be deleted. this template,this template This template has associated entities,This template has associated entities This template will be used as default for new entities.,This template will be used as default for new entities. diff --git a/contents/ui-translations/es.csv b/contents/ui-translations/es.csv index 40ddb74c41..aa24bfdec0 100644 --- a/contents/ui-translations/es.csv +++ b/contents/ui-translations/es.csv @@ -61,6 +61,7 @@ ALL,TODOS All,TODOS "All changes will be lost, are you sure you want to proceed?","Se perderán todos los cambios, ¿estás seguro de que quieres continuar?" Allow captcha bypass,Permitir la omisión de captcha +Already exists,Already exists An error has occured while deleting a language:,An error has occured while deleting a language: An error has occured while installing languages:,An error has occured while installing languages: An error has occurred during data export,Se ha producido un error durante la exportación de datos. @@ -75,7 +76,6 @@ Are you sure you want to delete this connection?,Estás seguro que quieres elimi Are you sure you want to delete this entity?,Estás seguro que quieres eliminar esta entidad? Are you sure you want to delete this file?,Estás seguro que quieres eliminar este archivo? Are you sure you want to delete this item?,Estás seguro que quieres eliminar este elemento? -Are you sure you want to delete this relationship type?,Estás seguro que quieres eliminar este tipo de relación? Are you sure you want to delete this thesaurus?,Estás seguro que quieres eliminar este tesauro? Are you sure?,Estás seguro? Attachment deleted,Archivo adjunto eliminado @@ -103,7 +103,6 @@ Can see,Puede visualizar Can view,Puede visualizar Cancel,Cancelar Canceling...,Cancelando -Cannot delete relationship type:,No se puede eliminar el tipo de relación: Cannot delete template:,No se puede eliminar la plantilla: Cannot delete thesaurus:,No se puede eliminar el tesauro: Captcha,Captcha @@ -149,7 +148,6 @@ Confirm deletion,Confirmar la eliminación Confirm deletion of,Confirmar la eliminación de Confirm deletion of entity,Confirmar eliminación de entidad Confirm deletion of file,Confirmar eliminación de archivo -Confirm deletion of relationship type:,Confirmar eliminación de tipo de relación: Confirm deletion of template:,Confirmar eliminación de plantilla: Confirm deletion of thesaurus:,Confirmar eliminación de tesauro: Confirm discard changes,Confirmar descartar cambios @@ -199,7 +197,6 @@ Created thesaurus,Tesauro creado Created user group,Grupo de usuarios creado Current value,Valor actual Current Value/Suggestion,Current Value/Suggestion -Currently connections only need a title.,Actualmente las conexiones sólo necesitan un título. Custom component error,Error en el componente de marcado personalizado: valores no soportados! Por favor revisa tu configuración Custom CSS,CSS personalizado Custom Favicon,Custom Favicon @@ -246,6 +243,7 @@ Discard changes,Descartar cambios Discard changes?,Descartar cambios? Dismiss,Descartar Display entity view from page,Mostrar entidad de visualización desde la página +Do you want to delete the following items?,Do you want to delete the following items? Document,Documento Document and entity types,Tipos de documento y entidad Document contents,Contenidos del documento @@ -814,7 +812,6 @@ This property will appear in the library cards as part of the basic info.,Esta p This property will be inherited from the related entities and shown as metadata of this type of entities.,Esta propiedad será heredada desde las entidades relacionadas y se mostrará como metadato de este tipo de entidad. This property will be shown using all the width available.,Esta propiedad se mostrará utilizando todo el espacio disponible. This property will be shown without the label.,Esta propiedad se mostrará sin su etiqueta. -This relationship type is being used and cannot be deleted.,Este tipo de relación esta siendo utilizado y no puede ser eliminado. this template,esta plantilla This template has associated entities,Esta plantilla tiene entidades asociadas This template will be used as default for new entities.,Esta plantilla se utilizará como predeterminada para nuevas entidades diff --git a/contents/ui-translations/fr.csv b/contents/ui-translations/fr.csv index 4d75e266e0..f5b70dd6c9 100644 --- a/contents/ui-translations/fr.csv +++ b/contents/ui-translations/fr.csv @@ -61,6 +61,7 @@ ALL,ALL All,All "All changes will be lost, are you sure you want to proceed?","Tous les changements seront perdus, êtes-vous sûr de vouloir continuer ?" Allow captcha bypass,Allow captcha bypass +Already exists,Already exists An error has occured while deleting a language:,An error has occured while deleting a language: An error has occured while installing languages:,An error has occured while installing languages: An error has occurred during data export,An error has occurred during data export @@ -75,7 +76,6 @@ Are you sure you want to delete this connection?,Are you sure you want to delete Are you sure you want to delete this entity?,Are you sure you want to delete this entity? Are you sure you want to delete this file?,Are you sure you want to delete this file? Are you sure you want to delete this item?,Are you sure you want to delete this item? -Are you sure you want to delete this relationship type?,Are you sure you want to delete this relationship type? Are you sure you want to delete this thesaurus?,Are you sure you want to delete this thesaurus? Are you sure?,Are you sure? Attachment deleted,Attachment deleted @@ -103,7 +103,6 @@ Can see,Peut voir Can view,Peut voir Cancel,Annuler Canceling...,Canceling... -Cannot delete relationship type:,Cannot delete relationship type: Cannot delete template:,Cannot delete template: Cannot delete thesaurus:,Cannot delete thesaurus: Captcha,Captcha @@ -150,7 +149,6 @@ Confirm deletion,Confirmer la suppression Confirm deletion of,Confirm deletion of Confirm deletion of entity,Confirm deletion of entity Confirm deletion of file,Confirm deletion of file -Confirm deletion of relationship type:,Confirm deletion of relationship type: Confirm deletion of template:,Confirm deletion of template: Confirm deletion of thesaurus:,Confirm deletion of thesaurus: Confirm discard changes,Confirm discard changes @@ -200,7 +198,6 @@ Created thesaurus,Created thesaurus Created user group,Created user group Current value,Current value Current Value/Suggestion,Current Value/Suggestion -Currently connections only need a title.,"Actuellement, les connexions ne nécessitent qu'un titre." Custom component error,Erreur de composant personnalisé Custom CSS,CSS personnalisé Custom Favicon,Custom Favicon @@ -247,6 +244,7 @@ Discard changes,Annuler les modifications Discard changes?,Discard changes? Dismiss,Dismiss Display entity view from page,Afficher la vue de l'entité depuis la page +Do you want to delete the following items?,Do you want to delete the following items? Document,Document Document and entity types,Types de documents et d'entités Document contents,Contenu du document @@ -816,7 +814,6 @@ This property will appear in the library cards as part of the basic info.,Cette This property will be inherited from the related entities and shown as metadata of this type of entities.,Cette propriété sera héritée des entités liées et affichée comme métadonnées de ce type d'entités. This property will be shown using all the width available.,Cette propriété sera affichée en utilisant toute la largeur disponible. This property will be shown without the label.,Cette propriété sera affichée sans l'étiquette. -This relationship type is being used and cannot be deleted.,This relationship type is being used and cannot be deleted. this template,this template This template has associated entities,This template has associated entities This template will be used as default for new entities.,Ce modèle sera utilisé par défaut pour les nouvelles entités. diff --git a/contents/ui-translations/ko.csv b/contents/ui-translations/ko.csv index ff91d6138e..cd0ab8efbb 100644 --- a/contents/ui-translations/ko.csv +++ b/contents/ui-translations/ko.csv @@ -61,6 +61,7 @@ ALL,전체 필터 All,전체 필터 "All changes will be lost, are you sure you want to proceed?",모든 변경 사항이 손실됩니다. 계속 진행하시겠습니까? Allow captcha bypass,Allow captcha bypass +Already exists,Already exists An error has occured while deleting a language:,An error has occured while deleting a language: An error has occured while installing languages:,An error has occured while installing languages: An error has occurred during data export,An error has occurred during data export @@ -75,7 +76,6 @@ Are you sure you want to delete this connection?,Are you sure you want to delete Are you sure you want to delete this entity?,Are you sure you want to delete this entity? Are you sure you want to delete this file?,Are you sure you want to delete this file? Are you sure you want to delete this item?,Are you sure you want to delete this item? -Are you sure you want to delete this relationship type?,Are you sure you want to delete this relationship type? Are you sure you want to delete this thesaurus?,Are you sure you want to delete this thesaurus? Are you sure?,Are you sure? Attachment deleted,Attachment deleted @@ -103,7 +103,6 @@ Can see,열람 가능 Can view,열람 가능 Cancel,취소 Canceling...,Canceling... -Cannot delete relationship type:,Cannot delete relationship type: Cannot delete template:,Cannot delete template: Cannot delete thesaurus:,Cannot delete thesaurus: Captcha,보안 문자 @@ -151,7 +150,6 @@ Confirm deletion,삭제 확인 Confirm deletion of,Confirm deletion of Confirm deletion of entity,Confirm deletion of entity Confirm deletion of file,Confirm deletion of file -Confirm deletion of relationship type:,Confirm deletion of relationship type: Confirm deletion of template:,Confirm deletion of template: Confirm deletion of thesaurus:,Confirm deletion of thesaurus: Confirm discard changes,Confirm discard changes @@ -201,7 +199,6 @@ Created thesaurus,Created thesaurus Created user group,Created user group Current value,Current value Current Value/Suggestion,Current Value/Suggestion -Currently connections only need a title.,커넥션에 제목이 필요합니다. Custom component error,사용자 맞춤 구성 오류 Custom CSS,사용자 맞춤 CSS Custom Favicon,Custom Favicon @@ -248,6 +245,7 @@ Discard changes,변경 취소 Discard changes?,Discard changes? Dismiss,Dismiss Display entity view from page,페이지에서 엔티티 뷰 표시 +Do you want to delete the following items?,Do you want to delete the following items? Document,문서 Document and entity types,문서 및 엔티티 유형 Document contents,문서 내용 @@ -817,7 +815,6 @@ This property will appear in the library cards as part of the basic info.,이 This property will be inherited from the related entities and shown as metadata of this type of entities.,관련 엔티티에서 속성을 이어받아 현재 엔티티의 메타데이터에 포함시킵니다. This property will be shown using all the width available.,디스플레이 가능한 너비 내에서 이 속성을 표시합니다. This property will be shown without the label.,이 속성은 라벨 없이 표시됩니다. -This relationship type is being used and cannot be deleted.,This relationship type is being used and cannot be deleted. this template,this template This template has associated entities,This template has associated entities This template will be used as default for new entities.,이 템플릿을 새 엔티티의 기본값으로 사용합니다. diff --git a/contents/ui-translations/my.csv b/contents/ui-translations/my.csv index ca735e5a5a..a9edad5474 100644 --- a/contents/ui-translations/my.csv +++ b/contents/ui-translations/my.csv @@ -61,6 +61,7 @@ ALL,အားလုံး All,အားလုံး "All changes will be lost, are you sure you want to proceed?",အပြောင်းအလဲအားလုံးကို ဆုံးရှုံးပါမည်၊ ရှေ့ဆက်လိုသည်မှာ သေချာပါသလား။ Allow captcha bypass,Allow captcha bypass +Already exists,Already exists An error has occured while deleting a language:,An error has occured while deleting a language: An error has occured while installing languages:,An error has occured while installing languages: An error has occurred during data export,An error has occurred during data export @@ -75,7 +76,6 @@ Are you sure you want to delete this connection?,Are you sure you want to delete Are you sure you want to delete this entity?,Are you sure you want to delete this entity? Are you sure you want to delete this file?,Are you sure you want to delete this file? Are you sure you want to delete this item?,Are you sure you want to delete this item? -Are you sure you want to delete this relationship type?,Are you sure you want to delete this relationship type? Are you sure you want to delete this thesaurus?,Are you sure you want to delete this thesaurus? Are you sure?,Are you sure? Attachment deleted,Attachment deleted @@ -103,7 +103,6 @@ Can see,မြင်နိုင်သည် Can view,ကြည့်နိုင်သည် Cancel,ပယ်ဖျက်ရန် Canceling...,Canceling... -Cannot delete relationship type:,Cannot delete relationship type: Cannot delete template:,Cannot delete template: Cannot delete thesaurus:,Cannot delete thesaurus: Captcha,ကက်ပ်ချာ @@ -151,7 +150,6 @@ Confirm deletion,ဖျက်ရန် အတည်ပြုပါ Confirm deletion of,Confirm deletion of Confirm deletion of entity,Confirm deletion of entity Confirm deletion of file,Confirm deletion of file -Confirm deletion of relationship type:,Confirm deletion of relationship type: Confirm deletion of template:,Confirm deletion of template: Confirm deletion of thesaurus:,Confirm deletion of thesaurus: Confirm discard changes,Confirm discard changes @@ -201,7 +199,6 @@ Created thesaurus,Created thesaurus Created user group,Created user group Current value,Current value Current Value/Suggestion,Current Value/Suggestion -Currently connections only need a title.,လက်ရှိတွင် ချိတ်ဆက်မှုအနည်းငယ်သာ လိုအပ်သည်။ Custom component error,စိတ်ကြိုက် အစိတ်အပိုင်း ချွတ်ယွင်းချက် Custom CSS,စိတ်ကြိုက် CSS Custom Favicon,Custom Favicon @@ -248,6 +245,7 @@ Discard changes,အပြောင်းအလဲများကို ပယ် Discard changes?,Discard changes? Dismiss,Dismiss Display entity view from page,စာမျက်နှာမှ ဖြည့်သွင်းချက် မြင်ကွင်းကို ပြသရန် +Do you want to delete the following items?,Do you want to delete the following items? Document,စာရွက်စာတမ်း Document and entity types,စာရွက်စာတမ်းနှင့် ဖြည့်သွင်းချက် အမျိုးအစားများ Document contents,စာရွက်စာတမ်း မာတိကာ @@ -817,7 +815,6 @@ This property will appear in the library cards as part of the basic info.,ဤထ This property will be inherited from the related entities and shown as metadata of this type of entities.,ဤထူးခြားချက်ကို သက်ဆိုင်ရာ ဖြည့်သွင်းချက်များမှ လက်ခံရယူပြီး ဤဖြည့်သွင်းချက် အမျိုးအစား၏ မီတာဒေတာအဖြစ် ပြသပါမည်။ This property will be shown using all the width available.,ဤထူးခြားချက်ကို ရရှိနိုင်သော အကျယ်အားလုံးသုံးပြီး ပြသပါမည်။ This property will be shown without the label.,ဤထူးခြားချက်ကို တံဆိပ်မှတ်သားမှုမပါဘဲ ပြသပါမည်။ -This relationship type is being used and cannot be deleted.,This relationship type is being used and cannot be deleted. this template,this template This template has associated entities,This template has associated entities This template will be used as default for new entities.,ဤပုံစံပြားကို ဖြည့်သွင်းချက်အသစ်များအတွက် နဂိုမူလအဖြစ် သုံးပါမည်။ diff --git a/contents/ui-translations/ru.csv b/contents/ui-translations/ru.csv index 834db67138..92cc5d175f 100644 --- a/contents/ui-translations/ru.csv +++ b/contents/ui-translations/ru.csv @@ -61,6 +61,7 @@ ALL,ВСЕ All,ВСЕ "All changes will be lost, are you sure you want to proceed?","Все изменения будут потеряны, вы уверены, что хотите продолжить?" Allow captcha bypass,Allow captcha bypass +Already exists,Already exists An error has occured while deleting a language:,An error has occured while deleting a language: An error has occured while installing languages:,An error has occured while installing languages: An error has occurred during data export,An error has occurred during data export @@ -75,7 +76,6 @@ Are you sure you want to delete this connection?,Are you sure you want to delete Are you sure you want to delete this entity?,Are you sure you want to delete this entity? Are you sure you want to delete this file?,Are you sure you want to delete this file? Are you sure you want to delete this item?,Are you sure you want to delete this item? -Are you sure you want to delete this relationship type?,Are you sure you want to delete this relationship type? Are you sure you want to delete this thesaurus?,Are you sure you want to delete this thesaurus? Are you sure?,Are you sure? Attachment deleted,Attachment deleted @@ -103,7 +103,6 @@ Can see,Может видеть Can view,Может просматривать Cancel,Отмена Canceling...,Canceling... -Cannot delete relationship type:,Cannot delete relationship type: Cannot delete template:,Cannot delete template: Cannot delete thesaurus:,Cannot delete thesaurus: Captcha,Captcha @@ -148,7 +147,6 @@ Confirm deletion,Подтвердить удаление Confirm deletion of,Confirm deletion of Confirm deletion of entity,Confirm deletion of entity Confirm deletion of file,Confirm deletion of file -Confirm deletion of relationship type:,Confirm deletion of relationship type: Confirm deletion of template:,Confirm deletion of template: Confirm deletion of thesaurus:,Confirm deletion of thesaurus: Confirm discard changes,Confirm discard changes @@ -198,7 +196,6 @@ Created thesaurus,Created thesaurus Created user group,Created user group Current value,Current value Current Value/Suggestion,Current Value/Suggestion -Currently connections only need a title.,В настоящий момент для подключений только требуется заголовок Custom component error,Ошибка пользовательского компонента Custom CSS,Персональные CSS Custom Favicon,Custom Favicon @@ -245,6 +242,7 @@ Discard changes,Отменить изменения Discard changes?,Discard changes? Dismiss,Dismiss Display entity view from page,Показывать просматриваемый объект со страницы +Do you want to delete the following items?,Do you want to delete the following items? Document,Документ Document and entity types,Типы документов и объектов Document contents,Содержание документа @@ -814,7 +812,6 @@ This property will appear in the library cards as part of the basic info.,Это This property will be inherited from the related entities and shown as metadata of this type of entities.,Это свойство будет приобретено от взаимосвязанных объектов и отображаться как метаданные для этого типа объектов. This property will be shown using all the width available.,Это свойство будет отображаться с использованием всей доступной ширины. This property will be shown without the label.,Это свойство будет отображаться без метки. -This relationship type is being used and cannot be deleted.,This relationship type is being used and cannot be deleted. this template,this template This template has associated entities,This template has associated entities This template will be used as default for new entities.,Этот шаблон будет использоваться по умолчанию для новых объектов. diff --git a/contents/ui-translations/th.csv b/contents/ui-translations/th.csv index 3f5c5150d8..d888a29eee 100644 --- a/contents/ui-translations/th.csv +++ b/contents/ui-translations/th.csv @@ -61,6 +61,7 @@ ALL,ALL All,All "All changes will be lost, are you sure you want to proceed?",การเปลี่ยนแปลงทั้งหมดจะหายไปคุณแน่ใจหรือว่าต้องการดำเนินการต่อ? Allow captcha bypass,Allow captcha bypass +Already exists,Already exists An error has occured while deleting a language:,An error has occured while deleting a language: An error has occured while installing languages:,An error has occured while installing languages: An error has occurred during data export,An error has occurred during data export @@ -75,7 +76,6 @@ Are you sure you want to delete this connection?,Are you sure you want to delete Are you sure you want to delete this entity?,Are you sure you want to delete this entity? Are you sure you want to delete this file?,Are you sure you want to delete this file? Are you sure you want to delete this item?,Are you sure you want to delete this item? -Are you sure you want to delete this relationship type?,Are you sure you want to delete this relationship type? Are you sure you want to delete this thesaurus?,Are you sure you want to delete this thesaurus? Are you sure?,Are you sure? Attachment deleted,Attachment deleted @@ -103,7 +103,6 @@ Can see,มองเห็นได้ Can view,มองเห็นได้ Cancel,ยกเลิก Canceling...,Canceling... -Cannot delete relationship type:,Cannot delete relationship type: Cannot delete template:,Cannot delete template: Cannot delete thesaurus:,Cannot delete thesaurus: Captcha,captcha @@ -151,7 +150,6 @@ Confirm deletion,ยืนยันการลบ Confirm deletion of,Confirm deletion of Confirm deletion of entity,Confirm deletion of entity Confirm deletion of file,Confirm deletion of file -Confirm deletion of relationship type:,Confirm deletion of relationship type: Confirm deletion of template:,Confirm deletion of template: Confirm deletion of thesaurus:,Confirm deletion of thesaurus: Confirm discard changes,Confirm discard changes @@ -201,7 +199,6 @@ Created thesaurus,Created thesaurus Created user group,Created user group Current value,Current value Current Value/Suggestion,Current Value/Suggestion -Currently connections only need a title.,การเชื่อมต่อจำเป็นต้องกำหนดหัวข้อเรื่อง Custom component error,เกิดข้อผิดพลาดในส่วนประกอบที่สร้างเอง Custom CSS,CSS ที่กำหนดเอง Custom Favicon,Custom Favicon @@ -248,6 +245,7 @@ Discard changes,ยกเลิกการเปลี่ยนแปลง Discard changes?,Discard changes? Dismiss,Dismiss Display entity view from page,แสดงมุมมองรายการจากหน้า +Do you want to delete the following items?,Do you want to delete the following items? Document,เอกสาร Document and entity types,ประเภทเอกสารและรายการ Document contents,เนื้อหาของเอกสาร @@ -819,7 +817,6 @@ This property will appear in the library cards as part of the basic info.,คุ This property will be inherited from the related entities and shown as metadata of this type of entities.,คุณสมบัตินี้จะถูกโอนย้ายมาจากรายการที่เกี่ยวข้องและจะถูกแสดงเป็นเมตาดาต้าสำหรับประเภทรายการนี้ This property will be shown using all the width available.,คุณสมบัตินี้จะถูกแสดงโดยใช้พื้นที่ทั้งหมดที่มีอยู่ This property will be shown without the label.,คุณสมบัตินี้จะถูกแสดงโดยไม่มีการจำแนกประเภท -This relationship type is being used and cannot be deleted.,This relationship type is being used and cannot be deleted. this template,this template This template has associated entities,This template has associated entities This template will be used as default for new entities.,แม่แบบนี้จะถูกตั้งเป็นค่าเริ่มต้นสำหรับรายการใหม่ diff --git a/contents/ui-translations/tr.csv b/contents/ui-translations/tr.csv index 8e03f875db..c91d5fd900 100644 --- a/contents/ui-translations/tr.csv +++ b/contents/ui-translations/tr.csv @@ -61,6 +61,7 @@ ALL,ALL All,All "All changes will be lost, are you sure you want to proceed?","Tüm değişiklikler kaybolacak, devam etmek istediğinizden emin misiniz?" Allow captcha bypass,Allow captcha bypass +Already exists,Already exists An error has occured while deleting a language:,An error has occured while deleting a language: An error has occured while installing languages:,An error has occured while installing languages: An error has occurred during data export,An error has occurred during data export @@ -75,7 +76,6 @@ Are you sure you want to delete this connection?,Are you sure you want to delete Are you sure you want to delete this entity?,Are you sure you want to delete this entity? Are you sure you want to delete this file?,Are you sure you want to delete this file? Are you sure you want to delete this item?,Are you sure you want to delete this item? -Are you sure you want to delete this relationship type?,Are you sure you want to delete this relationship type? Are you sure you want to delete this thesaurus?,Are you sure you want to delete this thesaurus? Are you sure?,Are you sure? Attachment deleted,Attachment deleted @@ -103,7 +103,6 @@ Can see,Görebilir Can view,Görüntüleyebilir Cancel,İptal et Canceling...,Canceling... -Cannot delete relationship type:,Cannot delete relationship type: Cannot delete template:,Cannot delete template: Cannot delete thesaurus:,Cannot delete thesaurus: Captcha,Güvenlik kodu @@ -151,7 +150,6 @@ Confirm deletion,Silmeyi onayla Confirm deletion of,Confirm deletion of Confirm deletion of entity,Confirm deletion of entity Confirm deletion of file,Confirm deletion of file -Confirm deletion of relationship type:,Confirm deletion of relationship type: Confirm deletion of template:,Confirm deletion of template: Confirm deletion of thesaurus:,Confirm deletion of thesaurus: Confirm discard changes,Confirm discard changes @@ -201,7 +199,6 @@ Created thesaurus,Created thesaurus Created user group,Created user group Current value,Current value Current Value/Suggestion,Current Value/Suggestion -Currently connections only need a title.,Şu anda bağlantıların yalnızca bir başlığa ihtiyacı var. Custom component error,Özel Yüklemeler Custom CSS,Özel CSS Custom Favicon,Custom Favicon @@ -248,6 +245,7 @@ Discard changes,Değişiklikleri göz ardı et Discard changes?,Discard changes? Dismiss,Dismiss Display entity view from page,Sayfadan varlık görünümünü görüntüle +Do you want to delete the following items?,Do you want to delete the following items? Document,Belge Document and entity types,Belge ve varlık türü Document contents,Belge içeriği @@ -817,7 +815,6 @@ This property will appear in the library cards as part of the basic info.,"Bu ö This property will be inherited from the related entities and shown as metadata of this type of entities.,"Bu özellik, ilgili varlıklardan devralınacak ve bu tür varlıkların meta verileri olarak gösterilecektir." This property will be shown using all the width available.,"Bu özellik, mevcut tüm genişlik kullanılarak gösterilecektir." This property will be shown without the label.,Bu özellik etiketsiz olarak gösterilecektir. -This relationship type is being used and cannot be deleted.,This relationship type is being used and cannot be deleted. this template,this template This template has associated entities,This template has associated entities This template will be used as default for new entities.,"Bu şablon, yeni varlıklar için varsayılan olarak kullanılacaktır." diff --git a/cypress/e2e/settings/relationship-types.cy.ts b/cypress/e2e/settings/relationship-types.cy.ts new file mode 100644 index 0000000000..78ce3e07ed --- /dev/null +++ b/cypress/e2e/settings/relationship-types.cy.ts @@ -0,0 +1,79 @@ +/* eslint-disable max-statements */ +import 'cypress-axe'; +import { clearCookiesAndLogin } from '../helpers/login'; + +describe('Relationship Types configuration', () => { + before(() => { + const env = { DATABASE_NAME: 'uwazi_e2e', INDEX_NAME: 'uwazi_e2e' }; + cy.exec('yarn blank-state --force', { env }); + clearCookiesAndLogin('admin', 'change this password now'); + cy.get('.only-desktop a[aria-label="Settings"]').click(); + cy.injectAxe(); + cy.contains('span', 'Relationship types').click(); + }); + + it('should have no detectable accessibility violations on load', () => { + cy.checkA11y(); + }); + + beforeEach(() => { + cy.intercept('GET', 'api/relationtypes').as('fetchTypes'); + cy.intercept('GET', 'api/templates').as('fetchtemplates'); + }); + + it('tests add types', () => { + cy.getByTestId('relationship-types-add').click(); + cy.checkA11y(); + cy.get('#relationship-type-name').click(); + cy.get('#relationship-type-name').type('Parent'); + + cy.getByTestId('relationship-type-form-submit').click(); + cy.wait('@fetchTypes'); + cy.contains('Dismiss').click(); + + cy.getByTestId('relationship-types-add').click(); + cy.get('#relationship-type-name').click(); + cy.get('#relationship-type-name').type('Son'); + + cy.getByTestId('relationship-type-form-submit').click(); + cy.wait('@fetchTypes'); + cy.contains('Dismiss').click(); + }); + + it('tests Edit', () => { + cy.get('tbody tr:nth-of-type(1)').contains('Edit').click(); + cy.get('#relationship-type-name').click(); + cy.get('#relationship-type-name').type('Edited'); + cy.getByTestId('relationship-type-form-submit').click(); + + cy.wait('@fetchTypes'); + cy.contains('Dismiss').click(); + }); + + it('tests delete', () => { + cy.get('tbody tr:nth-of-type(1) input').click(); + + cy.getByTestId('relationship-types-delete').click(); + cy.checkA11y(); + cy.getByTestId('cancel-button').click(); + + cy.getByTestId('relationship-types-delete').click(); + cy.getByTestId('accept-button').click(); + cy.wait('@fetchTypes'); + cy.contains('Dismiss').click(); + }); + + it('test cant delete when in use', () => { + cy.contains('span', 'Templates').click(); + cy.contains('Edit').click(); + cy.get('aside .list-group-item:nth-of-type(4) button').click(); + cy.get('.metadataTemplate li:nth-of-type(3) .property-edit').click(); + cy.get('select').eq(0).select('Son'); + + cy.contains('Save').click(); + cy.wait('@fetchtemplates'); + cy.contains('span', 'Relationship types').click(); + + cy.get('tbody tr:nth-of-type(1) input').should('be.disabled'); + }); +}); diff --git a/e2e/suite1/metadata.spec.ts b/e2e/suite1/metadata.spec.ts index ed821a0079..4a25ee2d8f 100644 --- a/e2e/suite1/metadata.spec.ts +++ b/e2e/suite1/metadata.spec.ts @@ -149,38 +149,4 @@ describe('Metadata', () => { await expect(page).not.toMatch('My edited template'); }); }); - - describe('Relationship types tests', () => { - it('should create a new connection', async () => { - await expect(page).toClick('a', { text: 'Relationship types' }); - await expect(page).toClick('a', { text: 'Add relationship' }); - await expect(page).toFill('input[placeholder="Template name"]', 'test connection'); - await expect(page).toClick('button', { text: 'Save' }); - await expect(page).toClick('.alert.alert-success'); - await expect(page).toClick('a', { text: 'Relationship types' }); - await expect(page).toMatch('test connection'); - }); - - it('should go back to Connections then edit the created connection', async () => { - await expect(page).toClick('a', { text: 'Relationship types' }); - await expect(page).toClick('a', { text: 'test connection' }); - await expect(page).toFill('input[value="test connection"]', 'test connection edited'); - await expect(page).toClick('button', { text: 'Save' }); - await expect(page).toClick('.alert.alert-success'); - await expect(page).toClick('a', { text: 'Relationship types' }); - await expect(page).toMatch('test connection edited'); - }); - - it('should go back to connections then delete the created connection', async () => { - await expect(page).toClick('a', { text: 'Relationship types' }); - await expect(page).toClick( - // types not up to date pr here https://github.com/DefinitelyTyped/DefinitelyTyped/pull/60579 - // @ts-ignore - { type: 'xpath', value: '//*[text() = "test connection edited"]/parent::li//a' }, - { text: 'Delete' } - ); - await expect(page).toClick('button', { text: 'Accept' }); - await expect(page).not.toMatch('test connection edited'); - }); - }); }); diff --git a/package.json b/package.json index 4d6e249ee1..d3b7dcb2ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uwazi", - "version": "1.157.1", + "version": "1.158.0", "description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.", "keywords": [ "react" @@ -230,7 +230,7 @@ "socket.io-client": "4.7.4", "socket.io-parser": "4.2.4", "stopword": "^3.0.1", - "superagent": "8.0.9", + "superagent": "8.1.2", "svg-captcha": "^1.4.0", "tiny-cookie": "^2.5.1", "typescript": "5.3.3", diff --git a/yarn.lock b/yarn.lock index 444cb749ae..7cba3c2d74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18796,10 +18796,10 @@ sucrase@^3.32.0: pirates "^4.0.1" ts-interface-checker "^0.1.9" -superagent@8.0.9, superagent@^8.0.5: - version "8.0.9" - resolved "https://registry.yarnpkg.com/superagent/-/superagent-8.0.9.tgz#2c6fda6fadb40516515f93e9098c0eb1602e0535" - integrity sha512-4C7Bh5pyHTvU33KpZgwrNKh/VQnvgtCSqPRfJAUdmrtSYePVzVg4E4OzsrbkhJj9O7SO6Bnv75K/F8XVZT8YHA== +superagent@8.1.2, superagent@^8.0.5: + version "8.1.2" + resolved "https://registry.yarnpkg.com/superagent/-/superagent-8.1.2.tgz#03cb7da3ec8b32472c9d20f6c2a57c7f3765f30b" + integrity sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA== dependencies: component-emitter "^1.3.0" cookiejar "^2.1.4"