Skip to content

Commit

Permalink
Merge pull request #278 from com-pas/Move_UserInfo_To_Compas_Foundation
Browse files Browse the repository at this point in the history
Move user info to compas foundation
  • Loading branch information
pascalwilbrink authored Oct 23, 2023
2 parents bf0f4b6 + 656dafd commit d7fe04c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/Hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { Drawer } from '@material/mwc-drawer';
import { ActionDetail, List } from '@material/mwc-list';
import { ListItem } from '@material/mwc-list/mwc-list-item';

import { Mixin, newPendingStateEvent, UserInfoEvent } from './foundation.js';
import { Mixin, newPendingStateEvent } from './foundation.js';
import { UserInfoEvent } from './compas/foundation.js';
import { LoggingElement } from './Logging.js';
import { PluggingElement, Plugin, pluginIcons } from './Plugging.js';
import { SettingElement } from './Setting.js';
Expand Down
2 changes: 1 addition & 1 deletion src/compas/CompasUserInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { newUserInfoEvent } from '../foundation.js';
import { newUserInfoEvent } from './foundation.js';

import { CompasUserInfoService } from '../compas-services/CompasUserInfoService.js';
import { createLogEvent } from '../compas-services/foundation.js';
Expand Down
22 changes: 22 additions & 0 deletions src/compas/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,25 @@ export function compareVersions(
}
return result;
}

/** Represents user information from a backend. */
export interface UserInfoDetail {
name: string;
}
export type UserInfoEvent = CustomEvent<UserInfoDetail>;
export function newUserInfoEvent(
name: string,
eventInitDict?: CustomEventInit<Partial<UserInfoDetail>>
): UserInfoEvent {
return new CustomEvent<UserInfoDetail>('userinfo', {
bubbles: true,
composed: true,
...eventInitDict,
detail: { name, ...eventInitDict?.detail },
});
}
declare global {
interface ElementEventMap {
['userinfo']: UserInfoEvent;
}
}
18 changes: 0 additions & 18 deletions src/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,23 +479,6 @@ export function newOpenDocEvent(
});
}

/** Represents user information from a backend. */
export interface UserInfoDetail {
name: string;
}
export type UserInfoEvent = CustomEvent<UserInfoDetail>;
export function newUserInfoEvent(
name: string,
eventInitDict?: CustomEventInit<Partial<UserInfoDetail>>
): UserInfoEvent {
return new CustomEvent<UserInfoDetail>('userinfo', {
bubbles: true,
composed: true,
...eventInitDict,
detail: { name, ...eventInitDict?.detail },
});
}

/** @returns a reference to `element` with segments delimited by '/'. */
// TODO(c-dinkel): replace with identity (FIXME)
export function referencePath(element: Element): string {
Expand Down Expand Up @@ -2880,7 +2863,6 @@ declare global {
['pending-state']: PendingStateEvent;
['editor-action']: EditorActionEvent<EditorAction>;
['open-doc']: OpenDocEvent;
['userinfo']: UserInfoEvent;
['wizard']: WizardEvent;
['validate']: ValidateEvent;
['log']: LogEvent;
Expand Down
6 changes: 4 additions & 2 deletions test/integration/compas/foundation.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { expect, fixture, html } from '@open-wc/testing';

import { updateDocumentInOpenSCD } from '../../../src/compas/foundation.js';
import {
updateDocumentInOpenSCD,
newUserInfoEvent,
} from '../../../src/compas/foundation.js';

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

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

0 comments on commit d7fe04c

Please sign in to comment.