pull/2457/head
Alper Ebicoglu 6 years ago
commit 6e23829361

@ -1,7 +1,15 @@
ui-angular:
- npm/ng-packs/*
- npm/ng-packs/**/*
- npm/ng-packs/**/**/*
- npm/ng-packs/**/**/**/*
- npm/ng-packs/**/**/**/**/*
- npm/ng-packs/**/**/**/**/**/*
- templates/app/angular/*
- templates/app/angular/**/*
- templates/app/angular/**/**/*
- templates/app/angular/**/**/**/*
- templates/module/angular/*
- templates/module/angular/**/*
- templates/module/angular/**/**/*
- templates/module/angular/**/**/**/*

@ -1,7 +1,7 @@
name: Pull request labeler
on:
schedule:
- cron: '0 0 1 1 *'
- cron: '0 12 */1 * *'
jobs:
labeler:
runs-on: ubuntu-latest

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
@ -7,8 +8,17 @@ namespace Volo.Abp.PermissionManagement
{
public interface IPermissionGrantRepository : IBasicRepository<PermissionGrant, Guid>
{
Task<PermissionGrant> FindAsync(string name, string providerName, string providerKey);
Task<PermissionGrant> FindAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default
);
Task<List<PermissionGrant>> GetListAsync(string providerName, string providerKey);
Task<List<PermissionGrant>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default
);
}
}

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Domain.Repositories.EntityFrameworkCore;
@ -8,7 +9,8 @@ using Volo.Abp.EntityFrameworkCore;
namespace Volo.Abp.PermissionManagement.EntityFrameworkCore
{
public class EfCorePermissionGrantRepository : EfCoreRepository<IPermissionManagementDbContext, PermissionGrant, Guid>, IPermissionGrantRepository
public class EfCorePermissionGrantRepository : EfCoreRepository<IPermissionManagementDbContext, PermissionGrant, Guid>,
IPermissionGrantRepository
{
public EfCorePermissionGrantRepository(IDbContextProvider<IPermissionManagementDbContext> dbContextProvider)
: base(dbContextProvider)
@ -16,23 +18,31 @@ namespace Volo.Abp.PermissionManagement.EntityFrameworkCore
}
public async Task<PermissionGrant> FindAsync(string name, string providerName, string providerKey)
public async Task<PermissionGrant> FindAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await DbSet
.FirstOrDefaultAsync(s =>
s.Name == name &&
s.ProviderName == providerName &&
s.ProviderKey == providerKey
s.ProviderKey == providerKey,
GetCancellationToken(cancellationToken)
);
}
public async Task<List<PermissionGrant>> GetListAsync(string providerName, string providerKey)
public async Task<List<PermissionGrant>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await DbSet
.Where(s =>
s.ProviderName == providerName &&
s.ProviderKey == providerKey
).ToListAsync();
).ToListAsync(GetCancellationToken(cancellationToken));
}
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
@ -16,23 +17,31 @@ namespace Volo.Abp.PermissionManagement.MongoDB
}
public async Task<PermissionGrant> FindAsync(string name, string providerName, string providerKey)
public async Task<PermissionGrant> FindAsync(
string name,
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.FirstOrDefaultAsync(s =>
s.Name == name &&
s.ProviderName == providerName &&
s.ProviderKey == providerKey
s.ProviderKey == providerKey,
GetCancellationToken(cancellationToken)
);
}
public async Task<List<PermissionGrant>> GetListAsync(string providerName, string providerKey)
public async Task<List<PermissionGrant>> GetListAsync(
string providerName,
string providerKey,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.Where(s =>
s.ProviderName == providerName &&
s.ProviderKey == providerKey
).ToListAsync();
).ToListAsync(GetCancellationToken(cancellationToken));
}
}
}

@ -229,7 +229,7 @@ export class ConfigState {
const index = flattedRoutes.findIndex(route => route.name === name);
if (index > -1) {
flattedRoutes[index] = newValue as ABP.FullRoute;
flattedRoutes[index] = { ...flattedRoutes[index], ...newValue } as ABP.FullRoute;
}
return patchState({

@ -1,17 +1,12 @@
import {
createServiceFactory,
SpectatorService,
SpyObject,
} from '@ngneat/spectator/jest';
import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest';
import { Store } from '@ngxs/store';
import { ReplaySubject, timer, Subject, of } from 'rxjs';
import { Config } from '../models/config';
import {
ApplicationConfigurationService,
ConfigStateService,
} from '../services';
import { ApplicationConfigurationService, ConfigStateService } from '../services';
import { ConfigState } from '../states';
import { SetLanguage, PatchRouteByName } from '../actions';
import { SetLanguage, PatchRouteByName, AddRoute } from '../actions';
import clone from 'just-clone';
import { ABP } from '../models';
export const CONFIG_STATE_DATA = {
environment: {
@ -55,6 +50,7 @@ export const CONFIG_STATE_DATA = {
name: 'AbpAccount::Login',
order: 1,
url: '/account/login',
parentName: 'AbpAccount::Menu:Account',
},
],
url: '/account',
@ -68,10 +64,27 @@ export const CONFIG_STATE_DATA = {
url: '/',
},
{
name: '::Menu:Identity',
path: 'identity',
children: [],
url: '/identity',
name: 'AbpAccount::Menu:Account',
path: 'account',
invisible: true,
layout: 'application',
children: [
{
path: 'login',
name: 'AbpAccount::Login',
order: 1,
url: '/account/login',
parentName: 'AbpAccount::Menu:Account',
},
],
url: '/account',
},
{
path: 'login',
name: 'AbpAccount::Login',
order: 1,
url: '/account/login',
parentName: 'AbpAccount::Menu:Account',
},
],
localization: {
@ -134,10 +147,7 @@ describe('ConfigState', () => {
store = spectator.get(Store);
service = spectator.service;
appConfigService = spectator.get(ApplicationConfigurationService);
state = new ConfigState(
spectator.get(ApplicationConfigurationService),
store,
);
state = new ConfigState(spectator.get(ApplicationConfigurationService), store);
});
describe('#getAll', () => {
@ -165,16 +175,12 @@ describe('ConfigState', () => {
describe('#getDeep', () => {
it('should return deeper', () => {
expect(
ConfigState.getDeep('environment.localization.defaultResourceName')(
CONFIG_STATE_DATA,
),
ConfigState.getDeep('environment.localization.defaultResourceName')(CONFIG_STATE_DATA),
).toEqual(CONFIG_STATE_DATA.environment.localization.defaultResourceName);
expect(
ConfigState.getDeep([
'environment',
'localization',
'defaultResourceName',
])(CONFIG_STATE_DATA),
ConfigState.getDeep(['environment', 'localization', 'defaultResourceName'])(
CONFIG_STATE_DATA,
),
).toEqual(CONFIG_STATE_DATA.environment.localization.defaultResourceName);
expect(ConfigState.getDeep('test')(null)).toBeFalsy();
@ -183,10 +189,10 @@ describe('ConfigState', () => {
describe('#getRoute', () => {
it('should return route', () => {
expect(
ConfigState.getRoute(null, '::Menu:Home')(CONFIG_STATE_DATA),
).toEqual(CONFIG_STATE_DATA.flattedRoutes[0]);
expect(ConfigState.getRoute('identity')(CONFIG_STATE_DATA)).toEqual(
expect(ConfigState.getRoute(null, '::Menu:Home')(CONFIG_STATE_DATA)).toEqual(
CONFIG_STATE_DATA.flattedRoutes[0],
);
expect(ConfigState.getRoute('account')(CONFIG_STATE_DATA)).toEqual(
CONFIG_STATE_DATA.flattedRoutes[1],
);
});
@ -205,11 +211,7 @@ describe('ConfigState', () => {
describe('#getSetting', () => {
it('should return a setting', () => {
expect(
ConfigState.getSetting('Abp.Localization.DefaultLanguage')(
CONFIG_STATE_DATA,
),
).toEqual(
expect(ConfigState.getSetting('Abp.Localization.DefaultLanguage')(CONFIG_STATE_DATA)).toEqual(
CONFIG_STATE_DATA.setting.values['Abp.Localization.DefaultLanguage'],
);
});
@ -217,9 +219,7 @@ describe('ConfigState', () => {
describe('#getSettings', () => {
it('should return settings', () => {
expect(
ConfigState.getSettings('Localization')(CONFIG_STATE_DATA),
).toEqual({
expect(ConfigState.getSettings('Localization')(CONFIG_STATE_DATA)).toEqual({
'Abp.Localization.DefaultLanguage': 'en',
});
@ -231,45 +231,31 @@ describe('ConfigState', () => {
describe('#getGrantedPolicy', () => {
it('should return a granted policy', () => {
expect(
ConfigState.getGrantedPolicy('Abp.Identity')(CONFIG_STATE_DATA),
).toBe(false);
expect(
ConfigState.getGrantedPolicy('Abp.Identity || Abp.Account')(
CONFIG_STATE_DATA,
),
).toBe(true);
expect(
ConfigState.getGrantedPolicy('Abp.Account && Abp.Identity')(
CONFIG_STATE_DATA,
),
).toBe(false);
expect(
ConfigState.getGrantedPolicy('Abp.Account &&')(CONFIG_STATE_DATA),
).toBe(false);
expect(
ConfigState.getGrantedPolicy('|| Abp.Account')(CONFIG_STATE_DATA),
).toBe(false);
expect(ConfigState.getGrantedPolicy('Abp.Identity')(CONFIG_STATE_DATA)).toBe(false);
expect(ConfigState.getGrantedPolicy('Abp.Identity || Abp.Account')(CONFIG_STATE_DATA)).toBe(
true,
);
expect(ConfigState.getGrantedPolicy('Abp.Account && Abp.Identity')(CONFIG_STATE_DATA)).toBe(
false,
);
expect(ConfigState.getGrantedPolicy('Abp.Account &&')(CONFIG_STATE_DATA)).toBe(false);
expect(ConfigState.getGrantedPolicy('|| Abp.Account')(CONFIG_STATE_DATA)).toBe(false);
expect(ConfigState.getGrantedPolicy('')(CONFIG_STATE_DATA)).toBe(true);
});
});
describe('#getLocalization', () => {
it('should return a localization', () => {
expect(
ConfigState.getLocalization('AbpIdentity::Identity')(CONFIG_STATE_DATA),
).toBe('identity');
expect(ConfigState.getLocalization('AbpIdentity::Identity')(CONFIG_STATE_DATA)).toBe(
'identity',
);
expect(
ConfigState.getLocalization('AbpIdentity::NoIdentity')(
CONFIG_STATE_DATA,
),
).toBe('AbpIdentity::NoIdentity');
expect(ConfigState.getLocalization('AbpIdentity::NoIdentity')(CONFIG_STATE_DATA)).toBe(
'AbpIdentity::NoIdentity',
);
expect(
ConfigState.getLocalization({ key: '', defaultValue: 'default' })(
CONFIG_STATE_DATA,
),
ConfigState.getLocalization({ key: '', defaultValue: 'default' })(CONFIG_STATE_DATA),
).toBe('default');
expect(
@ -290,9 +276,7 @@ describe('ConfigState', () => {
});
expect(false).toBeTruthy(); // fail
} catch (error) {
expect((error as Error).message).toContain(
'Please check your environment',
);
expect((error as Error).message).toContain('Please check your environment');
}
});
});
@ -328,11 +312,11 @@ describe('ConfigState', () => {
});
describe('#PatchRouteByName', () => {
it('should should patch the route', () => {
it('should patch the route', () => {
let patchStateArg;
const patchState = jest.fn(s => (patchStateArg = s));
const getState = jest.fn(() => CONFIG_STATE_DATA);
const getState = jest.fn(() => clone(CONFIG_STATE_DATA));
state.patchRoute(
{ patchState, getState } as any,
@ -347,17 +331,21 @@ describe('ConfigState', () => {
name: 'Home',
path: 'home',
url: '/home',
children: [
{ path: 'dashboard', name: 'Dashboard', url: '/home/dashboard' },
],
children: [{ path: 'dashboard', name: 'Dashboard', url: '/home/dashboard' }],
});
expect(patchStateArg.flattedRoutes[0]).toEqual({
name: 'Home',
path: 'home',
url: '/home',
children: [{ path: 'dashboard', name: 'Dashboard', url: '/home/dashboard' }],
});
});
it('should should patch the route without path', () => {
it('should patch the route without path', () => {
let patchStateArg;
const patchState = jest.fn(s => (patchStateArg = s));
const getState = jest.fn(() => CONFIG_STATE_DATA);
const getState = jest.fn(() => clone(CONFIG_STATE_DATA));
state.patchRoute(
{ patchState, getState } as any,
@ -373,6 +361,69 @@ describe('ConfigState', () => {
url: '/',
children: [{ path: 'dashboard', name: 'Dashboard', url: '/dashboard' }],
});
expect(patchStateArg.flattedRoutes[0]).toEqual({
name: 'Main',
path: '',
url: '/',
children: [{ path: 'dashboard', name: 'Dashboard', url: '/dashboard' }],
});
});
});
describe('#AddRoute', () => {
const newRoute = {
name: 'My new page',
iconClass: 'fa fa-dashboard',
path: 'page',
invisible: false,
order: 2,
requiredPolicy: 'MyProjectName::MyNewPage',
} as Omit<ABP.Route, 'children'>;
test('should add a new route', () => {
let patchStateArg;
const patchState = jest.fn(s => (patchStateArg = s));
const getState = jest.fn(() => clone(CONFIG_STATE_DATA));
state.addRoute({ patchState, getState } as any, new AddRoute(newRoute));
expect(patchStateArg.routes[CONFIG_STATE_DATA.routes.length]).toEqual({
...newRoute,
url: '/page',
});
expect(patchStateArg.flattedRoutes[CONFIG_STATE_DATA.flattedRoutes.length]).toEqual(
patchStateArg.routes[CONFIG_STATE_DATA.routes.length],
);
});
it('should add a new child route', () => {
let patchStateArg;
const patchState = jest.fn(s => (patchStateArg = s));
const getState = jest.fn(() => clone(CONFIG_STATE_DATA));
state.addRoute(
{ patchState, getState } as any,
new AddRoute({ ...newRoute, parentName: 'AbpAccount::Login' }),
);
expect(patchStateArg.routes[1].children[0].children[0]).toEqual({
...newRoute,
parentName: 'AbpAccount::Login',
url: '/account/login/page',
});
expect(patchStateArg.flattedRoutes[CONFIG_STATE_DATA.flattedRoutes.length]).toEqual(
patchStateArg.routes[1].children[0].children[0],
);
expect(
patchStateArg.flattedRoutes[
CONFIG_STATE_DATA.flattedRoutes.findIndex(route => route.name === 'AbpAccount::Login')
],
).toEqual(patchStateArg.routes[1].children[0]);
});
});
});

@ -0,0 +1,17 @@
import '../utils/date-extensions';
describe('DateExtensions', () => {
describe('#toLocalISOString', () => {
test('should able to use as date prototype', () => {
new Date().toLocalISOString();
});
test('should return correct value', () => {
const now = new Date();
const timezoneOffset = now.getTimezoneOffset();
expect(now.toLocalISOString()).toEqual(
new Date(now.getTime() - timezoneOffset * 60000).toISOString(),
);
});
});
});
Loading…
Cancel
Save