Skip to content

Commit d7fe04c

Browse files
Merge pull request #278 from com-pas/Move_UserInfo_To_Compas_Foundation
Move user info to compas foundation
2 parents bf0f4b6 + 656dafd commit d7fe04c

File tree

5 files changed

+29
-22
lines changed

5 files changed

+29
-22
lines changed

src/Hosting.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import { Drawer } from '@material/mwc-drawer';
1515
import { ActionDetail, List } from '@material/mwc-list';
1616
import { ListItem } from '@material/mwc-list/mwc-list-item';
1717

18-
import { Mixin, newPendingStateEvent, UserInfoEvent } from './foundation.js';
18+
import { Mixin, newPendingStateEvent } from './foundation.js';
19+
import { UserInfoEvent } from './compas/foundation.js';
1920
import { LoggingElement } from './Logging.js';
2021
import { PluggingElement, Plugin, pluginIcons } from './Plugging.js';
2122
import { SettingElement } from './Setting.js';

src/compas/CompasUserInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { newUserInfoEvent } from '../foundation.js';
1+
import { newUserInfoEvent } from './foundation.js';
22

33
import { CompasUserInfoService } from '../compas-services/CompasUserInfoService.js';
44
import { createLogEvent } from '../compas-services/foundation.js';

src/compas/foundation.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,25 @@ export function compareVersions(
106106
}
107107
return result;
108108
}
109+
110+
/** Represents user information from a backend. */
111+
export interface UserInfoDetail {
112+
name: string;
113+
}
114+
export type UserInfoEvent = CustomEvent<UserInfoDetail>;
115+
export function newUserInfoEvent(
116+
name: string,
117+
eventInitDict?: CustomEventInit<Partial<UserInfoDetail>>
118+
): UserInfoEvent {
119+
return new CustomEvent<UserInfoDetail>('userinfo', {
120+
bubbles: true,
121+
composed: true,
122+
...eventInitDict,
123+
detail: { name, ...eventInitDict?.detail },
124+
});
125+
}
126+
declare global {
127+
interface ElementEventMap {
128+
['userinfo']: UserInfoEvent;
129+
}
130+
}

src/foundation.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -479,23 +479,6 @@ export function newOpenDocEvent(
479479
});
480480
}
481481

482-
/** Represents user information from a backend. */
483-
export interface UserInfoDetail {
484-
name: string;
485-
}
486-
export type UserInfoEvent = CustomEvent<UserInfoDetail>;
487-
export function newUserInfoEvent(
488-
name: string,
489-
eventInitDict?: CustomEventInit<Partial<UserInfoDetail>>
490-
): UserInfoEvent {
491-
return new CustomEvent<UserInfoDetail>('userinfo', {
492-
bubbles: true,
493-
composed: true,
494-
...eventInitDict,
495-
detail: { name, ...eventInitDict?.detail },
496-
});
497-
}
498-
499482
/** @returns a reference to `element` with segments delimited by '/'. */
500483
// TODO(c-dinkel): replace with identity (FIXME)
501484
export function referencePath(element: Element): string {
@@ -2880,7 +2863,6 @@ declare global {
28802863
['pending-state']: PendingStateEvent;
28812864
['editor-action']: EditorActionEvent<EditorAction>;
28822865
['open-doc']: OpenDocEvent;
2883-
['userinfo']: UserInfoEvent;
28842866
['wizard']: WizardEvent;
28852867
['validate']: ValidateEvent;
28862868
['log']: LogEvent;

test/integration/compas/foundation.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { expect, fixture, html } from '@open-wc/testing';
22

3-
import { updateDocumentInOpenSCD } from '../../../src/compas/foundation.js';
3+
import {
4+
updateDocumentInOpenSCD,
5+
newUserInfoEvent,
6+
} from '../../../src/compas/foundation.js';
47

58
import { OpenSCD } from '../../../src/open-scd.js';
69
import '../../../src/open-scd.js';
7-
import { newUserInfoEvent } from '../../../src/foundation.js';
810

911
describe('compas-foundation', () => {
1012
let element: OpenSCD;

0 commit comments

Comments
 (0)