mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
e2e api enhancements (part 1) (#1727)
* add typings, deprecate username wrapper * improve imports * unify admin actions for people * remove auth api wrapper * remove unused apis * remove unused apis * use admin api actions everywhere
This commit is contained in:
@@ -23,15 +23,20 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RepoClient, NodeContentTree } from './repo-client/repo-client';
|
||||
import { PersonEntry, NodeEntry } from '@alfresco/js-api';
|
||||
import { PersonModel } from './repo-client/apis/people/people-api-models';
|
||||
|
||||
import { SitesApi } from './repo-client/apis/sites/sites-api';
|
||||
import { UploadApi } from './repo-client/apis/upload/upload-api';
|
||||
import { NodesApi } from './repo-client/apis/nodes/nodes-api';
|
||||
import { FavoritesApi } from './repo-client/apis/favorites/favorites-api';
|
||||
import { SearchApi } from './repo-client/apis/search/search-api';
|
||||
import { RepoClient } from './repo-client/repo-client';
|
||||
import { PersonEntry, NodeEntry, PeopleApi } from '@alfresco/js-api';
|
||||
import {
|
||||
PersonModel,
|
||||
SitesApi,
|
||||
UploadApi,
|
||||
NodesApi,
|
||||
FavoritesApi,
|
||||
SearchApi,
|
||||
NodeContentTree,
|
||||
Person,
|
||||
SharedLinksApi,
|
||||
TrashcanApi
|
||||
} from './repo-client/apis';
|
||||
|
||||
export class AdminActions {
|
||||
private adminApi: RepoClient;
|
||||
@@ -45,6 +50,8 @@ export class AdminActions {
|
||||
nodes: NodesApi = new NodesApi();
|
||||
favorites: FavoritesApi = new FavoritesApi();
|
||||
search: SearchApi = new SearchApi();
|
||||
shared: SharedLinksApi = new SharedLinksApi();
|
||||
trashcan: TrashcanApi = new TrashcanApi();
|
||||
|
||||
async getDataDictionaryId(): Promise<string> {
|
||||
return this.adminApi.nodes.getNodeIdFromParent('Data Dictionary', '-root-');
|
||||
@@ -59,7 +66,25 @@ export class AdminActions {
|
||||
}
|
||||
|
||||
async createUser(user: PersonModel): Promise<PersonEntry> {
|
||||
return this.adminApi.people.createUser(user);
|
||||
const person = new Person(user);
|
||||
const peopleApi = new PeopleApi(this.adminApi.alfrescoApi);
|
||||
|
||||
await this.adminApi.apiAuth();
|
||||
return peopleApi.createPerson(person);
|
||||
}
|
||||
|
||||
async disableUser(username: string): Promise<PersonEntry> {
|
||||
const peopleApi = new PeopleApi(this.adminApi.alfrescoApi);
|
||||
|
||||
await this.adminApi.apiAuth();
|
||||
return peopleApi.updatePerson(username, { enabled: false });
|
||||
}
|
||||
|
||||
async changePassword(username: string, newPassword: string): Promise<PersonEntry> {
|
||||
const peopleApi = new PeopleApi(this.adminApi.alfrescoApi);
|
||||
|
||||
await this.adminApi.apiAuth();
|
||||
return peopleApi.updatePerson(username, { password: newPassword });
|
||||
}
|
||||
|
||||
async createNodeTemplate(name: string, title: string = '', description: string = '', author: string = ''): Promise<NodeEntry> {
|
||||
|
Reference in New Issue
Block a user