Skip to content

Commit c7f4b44

Browse files
committed
feat: luigi nodes service implementation
1 parent 3ec1b66 commit c7f4b44

21 files changed

+641
-12
lines changed

angular.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"cli": {
4646
"schematicCollections": [
4747
"@angular-eslint/schematics"
48-
]
48+
],
49+
"analytics": false
4950
}
5051
}

src/lib/injection-tokens.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ export const LUIGI_STATIC_SETTINGS_CONFIG_SERVICE_INJECTION_TOKEN =
22
'OPENMFP_LUIGI_STATIC_SETTINGS_CONFIG_SERVICE';
33
export const LUIGI_COMMUNICATION_CONFIG_SERVICE_INJECTION_TOKEN =
44
'OPENMFP_LUIGI_COMMUNICATION_CONFIG_SERVICE';
5+
export const LOCAL_NODES_SERVICE_INJECTION_TOKEN =
6+
'OPENMFP_LOCAL_NODES_SERVICE_INJECTION_TOKEN';

src/lib/model/luigi.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.

src/lib/models/luigi.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
export interface EntityDefinition {
2+
id: string;
3+
dynamicFetchId?: string;
4+
contextKey?: string;
5+
useBack?: boolean;
6+
label?: string;
7+
pluralLabel?: string;
8+
notFoundConfig?: {
9+
entityListNavigationContext: string;
10+
sapIllusSVG: string;
11+
};
12+
}
13+
14+
export interface LuigiStatusBadge {
15+
label: string;
16+
type: string;
17+
}
18+
19+
export interface PortalLuigiNodeExtensions {
20+
entityType?: string;
21+
requiredPolicies?: string[];
22+
}
23+
24+
export interface LuigiNodeCategory {
25+
label: string;
26+
collapsible?: boolean;
27+
order?: number;
28+
id?: string;
29+
icon?: string;
30+
}
31+
32+
export interface LuigiNodeContext extends Record<string, any> {
33+
serviceProviderConfig?: any;
34+
}
35+
36+
export interface LuigiNode extends PortalLuigiNodeExtensions {
37+
pathSegment?: string;
38+
label?: string;
39+
category?: LuigiNodeCategory | string;
40+
context?: LuigiNodeContext;
41+
statusBadge?: LuigiStatusBadge;
42+
}

src/lib/model/portal-config.ts renamed to src/lib/models/portal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface ServiceProvider {
44
nodes: LuigiNode[];
55
config: Record<string, string>;
66
installationData?: Record<string, string>;
7+
isMandatoryExtension?: boolean;
78
creationTimestamp: string;
89
}
910

File renamed without changes.

src/lib/portal.module.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { HttpClientModule } from '@angular/common/http';
33
import { BrowserModule } from '@angular/platform-browser';
44
import { RouterOutlet } from '@angular/router';
55
import {
6+
LOCAL_NODES_SERVICE_INJECTION_TOKEN,
67
LUIGI_COMMUNICATION_CONFIG_SERVICE_INJECTION_TOKEN,
78
LUIGI_STATIC_SETTINGS_CONFIG_SERVICE_INJECTION_TOKEN,
89
} from './injection-tokens';
@@ -16,6 +17,8 @@ import {
1617
StaticSettingsConfigServiceImpl,
1718
CommunicationConfigService,
1819
CommunicationConfigServiceImpl,
20+
LocalNodesService,
21+
NoopLocalNodesService,
1922
} from './services';
2023

2124
export interface PortalModuleOptions {
@@ -24,6 +27,9 @@ export interface PortalModuleOptions {
2427

2528
/** Service containing and providing the luigi communication configuration **/
2629
communicationConfigService?: Type<CommunicationConfigService>;
30+
31+
/** Service containing and providing the luigi communication configuration **/
32+
localNodesService?: Type<LocalNodesService>;
2733
}
2834

2935
@NgModule({
@@ -42,6 +48,10 @@ export interface PortalModuleOptions {
4248
provide: LUIGI_COMMUNICATION_CONFIG_SERVICE_INJECTION_TOKEN,
4349
useClass: CommunicationConfigServiceImpl,
4450
},
51+
{
52+
provide: LOCAL_NODES_SERVICE_INJECTION_TOKEN,
53+
useClass: NoopLocalNodesService,
54+
},
4555
],
4656
imports: [PortalRoutingModule, BrowserModule, RouterOutlet, HttpClientModule],
4757
exports: [PortalComponent],
@@ -69,6 +79,10 @@ export class PortalModule {
6979
options.communicationConfigService ||
7080
CommunicationConfigServiceImpl,
7181
},
82+
{
83+
provide: LOCAL_NODES_SERVICE_INJECTION_TOKEN,
84+
useClass: options.localNodesService || NoopLocalNodesService,
85+
},
7286
],
7387
imports: [
7488
PortalRoutingModule,

src/lib/services/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from './luigi-core.service';
33
export * from './luigi-config/luigi-config.service';
44
export * from './luigi-config/static-settings-config.service';
55
export * from './luigi-config/communication-config.service';
6+
export * from './luigi-nodes/local-nodes.service';

src/lib/services/luigi-config/luigi-config.service.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CommunicationConfigService } from './communication-config.service';
22
import { LuigiConfigService } from './luigi-config.service';
33
import { EnvConfigService } from '../portal/env-config.service';
44
import { AuthConfigService } from './auth-config.service';
5-
import { ClientEnvironment } from '../../model/env';
5+
import { ClientEnvironment } from '../../models/env';
66
import { RoutingConfigService } from './routing-config.service';
77
import { StaticSettingsConfigService } from './static-settings-config.service';
88

src/lib/services/luigi-config/luigi-config.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
LUIGI_COMMUNICATION_CONFIG_SERVICE_INJECTION_TOKEN,
44
LUIGI_STATIC_SETTINGS_CONFIG_SERVICE_INJECTION_TOKEN,
55
} from '../../injection-tokens';
6-
import { ClientEnvironment } from '../../model/env';
6+
import { ClientEnvironment } from '../../models/env';
77
import { AuthConfigService } from './auth-config.service';
88
import { EnvConfigService } from '../portal/env-config.service';
99
import { CommunicationConfigService } from './communication-config.service';
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { NoopLocalNodesService } from './local-nodes.service';
2+
import { LuigiNode } from '../../models/luigi';
3+
4+
describe('NoopLocalNodesService', () => {
5+
let service: NoopLocalNodesService;
6+
7+
beforeEach(() => {
8+
service = new NoopLocalNodesService();
9+
});
10+
11+
describe('getLocalNodes', () => {
12+
it('should return an empty array', async () => {
13+
const localNodes = await service.getLocalNodes();
14+
expect(localNodes).toEqual([]);
15+
});
16+
});
17+
18+
describe('replaceServerNodesWithLocalOnes', () => {
19+
it('should return the original server nodes', async () => {
20+
const serverNodes: LuigiNode[] = [
21+
{ label: 'Node 1', pathSegment: '/node1' },
22+
{ label: 'Node 2', pathSegment: '/node2' },
23+
];
24+
const currentEntities = ['entity1', 'entity2'];
25+
26+
const replacedNodes = await service.replaceServerNodesWithLocalOnes(
27+
serverNodes,
28+
currentEntities
29+
);
30+
31+
expect(replacedNodes).toEqual(serverNodes);
32+
});
33+
});
34+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { LuigiNode } from '../../models/luigi';
2+
3+
export interface LocalNodesService {
4+
replaceServerNodesWithLocalOnes(
5+
serverLuigiNodes: LuigiNode[],
6+
currentEntities: string[]
7+
): Promise<LuigiNode[]>;
8+
9+
getLocalNodes(): Promise<LuigiNode[]>;
10+
}
11+
12+
export class NoopLocalNodesService implements LocalNodesService {
13+
async getLocalNodes(): Promise<LuigiNode[]> {
14+
return [];
15+
}
16+
17+
async replaceServerNodesWithLocalOnes(
18+
serverLuigiNodes: LuigiNode[],
19+
currentEntities: string[]
20+
): Promise<LuigiNode[]> {
21+
return serverLuigiNodes;
22+
}
23+
}

0 commit comments

Comments
 (0)