Skip to content

Commit

Permalink
GDB-11001: Filtering Repositories in TTYG Functionality (#1597)
Browse files Browse the repository at this point in the history
* GDB-11001: Filtering Repositories in TTYG Functionality

## What
Added filtering of repositories for:
 - The dropdown in the "Create Agent" dialog;
 - The repository filter in the agent list panel.

## Why
TTYG functionality is designed to work only with GraphDB repositories.

## How
Implemented filtering by repository type when loading repositories for dropdowns.

* Expose the getReadableGraphdbRepositories method in the $repository service.
  • Loading branch information
boyan-tonchev authored Oct 9, 2024
1 parent 0d946c2 commit 5db7b7d
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/js/angular/core/services/repositories.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@ repositories.service('$repositories', ['toastr', '$rootScope', '$timeout', '$loc
});
};

this.getReadableGraphdbRepositories = function () {
return this.getReadableRepositories()
.filter((repo) => repo.type === 'graphdb');
};

this.getWritableRepositories = function () {
const that = this;
return _.filter(this.getRepositories(), function (repo) {
Expand Down
5 changes: 3 additions & 2 deletions src/js/angular/ttyg/controllers/ttyg-view.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,8 @@ function TTYGViewCtrl(
const buildAgentsFilterModel = () => {
const currentRepository = $repositories.getActiveRepository();
// TODO: this should be refreshed automatically when the repositories change
const repositoryObjects = $repositories.getReadableRepositories().map((repo) => (
const repositoryObjects = $repositories.getReadableGraphdbRepositories()
.map((repo) => (
new AgentListFilterModel(repo.id, repo.id, repo.id === currentRepository)
));
$scope.agentListFilterModel = [
Expand Down Expand Up @@ -800,7 +801,7 @@ function TTYGViewCtrl(
};

const buildRepositoryList = () => {
$scope.activeRepositoryList = $repositories.getReadableRepositories()
$scope.activeRepositoryList = $repositories.getReadableGraphdbRepositories()
.map((repo) => (
new SelectMenuOptionsModel({
value: repo.id,
Expand Down
28 changes: 28 additions & 0 deletions test-cypress/fixtures/repositories/get-ttyg-repositories.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,34 @@
"writable": true,
"unsupported": false,
"state": "INACTIVE"
},
{
"id": "Fedx_repository",
"title": "",
"uri": "http://localhost:8080/graphdb/repositories/Fedx_repository",
"externalUrl": "http://boyantonchev:9000/repositories/Fedx_repository",
"local": true,
"type": "fedx",
"sesameType": "graphdb:FedXRepository",
"location": "",
"readable": true,
"writable": true,
"unsupported": false,
"state": "INACTIVE"
},
{
"id": "Ontop_repository",
"title": "",
"uri": "http://localhost:8080/graphdb/repositories/Fedx_repository",
"externalUrl": "http://boyantonchev:9000/repositories/Fedx_repository",
"local": true,
"type": "ontop",
"sesameType": "graphdb:FedXRepository",
"location": "",
"readable": true,
"writable": true,
"unsupported": false,
"state": "INACTIVE"
}
]
}
2 changes: 2 additions & 0 deletions test-cypress/integration/ttyg/agent-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ describe('TTYG agent list', () => {
TTYGViewSteps.getAgents().should('have.length', 2);
// Then Agent list filter should be set to All
TTYGViewSteps.getSelectedAgentFilter().should('contain', 'starwars');
TTYGViewSteps.verifyRepositoryOptionNotExist('Fedx_repository');
TTYGViewSteps.verifyRepositoryOptionNotExist('Ontop_repository');
// When I filter the agents by repository 'biomarkers'
TTYGViewSteps.filterAgentsByRepository('biomarkers');
// Then I should see only 1 agent
Expand Down
3 changes: 3 additions & 0 deletions test-cypress/integration/ttyg/create-agent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ describe('TTYG create new agent', () => {
TTYGViewSteps.createFirstAgent();
// Then I expect the selected repository to be set as the repository ID in the form.
TtygAgentSettingsModalSteps.verifyRepositorySelected('starwars');
// and all options are exclusively for GraphDB repositories.
TtygAgentSettingsModalSteps.verifyRepositoryOptionNotExist('Fedx_repository');
TtygAgentSettingsModalSteps.verifyRepositoryOptionNotExist('Ontop_repository');

// When I open ChatGPT retrieval connector panel
TtygAgentSettingsModalSteps.enableRetrievalMethodPanel();
Expand Down
6 changes: 6 additions & 0 deletions test-cypress/steps/ttyg/ttyg-agent-settings-modal.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export class TtygAgentSettingsModalSteps extends ModalDialogSteps {
this.getRepositorySelect().find('option:selected').should('have.text', repositoryId);
}

static verifyRepositoryOptionNotExist(repositoryId) {
this.getRepositorySelect().each(($select) => {
cy.wrap($select).find('option').should('not.contain.text', repositoryId);
});
}

// Extraction methods

static getExtractionMethodError() {
Expand Down
12 changes: 11 additions & 1 deletion test-cypress/steps/ttyg/ttyg-view-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,19 @@ export class TTYGViewSteps {
return this.getAgentFilter().find('.selected-filter');
}

static getDropdownMenu() {
return this.getAgentFilter().find('.dropdown-menu');
}

static verifyRepositoryOptionNotExist(repositoryId) {
this.getDropdownMenu().each(($select) => {
cy.wrap($select).should('not.contain.text', repositoryId);
});
}

static filterAgentsByRepository(repository) {
this.getAgentFilter().click();
this.getAgentFilter().find('.dropdown-menu').find(`[data-value="${repository}"]`).click();
this.getDropdownMenu().find(`[data-value="${repository}"]`).click();
}

static selectAllAgentsFilter() {
Expand Down

0 comments on commit 5db7b7d

Please sign in to comment.