Skip to content

Commit

Permalink
Merge pull request #276 from com-pas/sync
Browse files Browse the repository at this point in the history
Sync from OpenSCD
  • Loading branch information
pascalwilbrink committed Oct 23, 2023
2 parents b713839 + d7fe04c commit 58c814b
Show file tree
Hide file tree
Showing 54 changed files with 783 additions and 301 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/stale-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow labels stale issues.
#
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues

on:
workflow_dispatch:
schedule:
- cron: '0 19 * * *'

jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write

steps:
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

days-before-stale: 60
days-before-close: -1
days-before-pr-stale: -1
days-before-pr-close: -1

stale-issue-label: 'stale'
stale-issue-message: |
Hello there,
Thank you for opening this issue! We appreciate your interest in our project.
However, it seems that this issue hasn't had any activity for a while. To ensure that our issue tracker remains organized and efficient, we occasionally review and address stale issues.
If you believe this issue is still relevant and requires attention, please provide any additional context, updates, or details that might help us understand the problem better.
Feel free to continue the conversation here.
If the issue is no longer relevant, you can simply close it. If you're uncertain, you can always reopen it later.
Remember, our project thrives on community contributions, and your input matters. We're here to collaborate and improve.
Thank you for being part of this journey!
28 changes: 28 additions & 0 deletions docs/decisions/0001-record-architecture-decisions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 1. Record architecture decisions

Date: 2023-07

## Status

Accepted

## Context

We need to record the architectural decisions made on this project.

## Decision

We will follow the decisions recorded in the central organizational
repository ([.github](https://github.com/openscd/.github)),
and record new repo-specific decisions in this repository.


We write ADRs in the `docs/decisions` folder instead of a standard `doc/adr`:
- `docs` instead of `doc` because `doc` is used for the generated documentation.
- `decisions` instead of `adrs` because it is more explicit and a followed practice:
[↗ Markdown Any Decision Records - Applying MADR to your project ](https://adr.github.io/madr/#applying-madr-to-your-project)

## Consequences

- It will be harder to track which decisions have to be taken into consideration
- Local decisions will be easier to find
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;
}
}
6 changes: 5 additions & 1 deletion src/editors/IED.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ export default class IedPlugin extends LitElement {
super.updated(_changedProperties);

// When the document is updated, we reset the selected IED.
if (_changedProperties.has('doc') || _changedProperties.has('nsdoc')) {
if (
_changedProperties.has('doc') ||
_changedProperties.has('editCount') ||
_changedProperties.has('nsdoc')
) {
this.selectedIEDs = [];
this.selectedLNClasses = [];

Expand Down
4 changes: 1 addition & 3 deletions src/editors/communication/subnetwork-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ export class SubNetworkEditor extends LitElement {
private subNetworkSpecs(): string {
if (!this.type && !this.bitrate) return '';

return `(${this.type}${
this.type && this.bitrate ? ` — ${this.bitrate}` : ``
})`;
return `(${[this.type, this.bitrate].filter(text => !!text).join(' — ')})`;
}

private header(): string {
Expand Down
4 changes: 2 additions & 2 deletions src/editors/protocol104/wizards/selectDo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
getNameAttribute,
identity,
newSubWizardEvent,
selector,
find,
Wizard,
WizardActor,
WizardInputElement,
Expand Down Expand Up @@ -158,7 +158,7 @@ function checkAndGetLastElementFromPath(
const [tagName, id] = path.pop()!.split(': ');
if (!expectedTag.includes(tagName)) return null;

return doc.querySelector(selector(tagName, id));
return find(doc, tagName, id);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/editors/publisher/data-set-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import './data-set-element-editor.js';
import '../../filtered-list.js';
import { FilteredList } from '../../filtered-list.js';

import { compareNames, identity, selector } from '../../foundation.js';
import { compareNames, identity, find } from '../../foundation.js';
import { styles, updateElementReference } from './foundation.js';

@customElement('data-set-editor')
Expand Down Expand Up @@ -50,7 +50,7 @@ export class DataSetEditor extends LitElement {

private selectDataSet(evt: Event): void {
const id = ((evt.target as FilteredList).selected as ListItem).value;
const dataSet = this.doc.querySelector(selector('DataSet', id));
const dataSet = find(this.doc, 'DataSet', id);

if (dataSet) {
this.selectedDataSet = dataSet;
Expand Down
4 changes: 2 additions & 2 deletions src/editors/publisher/foundation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from 'lit-element';

import { identity, selector } from '../../foundation.js';
import { identity, find } from '../../foundation.js';

export function updateElementReference(
newDoc: XMLDocument,
Expand All @@ -9,7 +9,7 @@ export function updateElementReference(
if (!oldElement || !oldElement.closest('SCL')) return null;

const id = identity(oldElement);
const newElement = newDoc.querySelector(selector(oldElement.tagName, id));
const newElement = find(newDoc, oldElement.tagName, id);

return newElement;
}
Expand Down
4 changes: 2 additions & 2 deletions src/editors/publisher/gse-control-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import '../../filtered-list.js';
import { FilteredList } from '../../filtered-list.js';

import { gooseIcon } from '../../icons/icons.js';
import { compareNames, identity, selector } from '../../foundation.js';
import { compareNames, identity, find } from '../../foundation.js';
import { styles, updateElementReference } from './foundation.js';

@customElement('gse-control-editor')
Expand Down Expand Up @@ -62,7 +62,7 @@ export class GseControlEditor extends LitElement {

private selectGSEControl(evt: Event): void {
const id = ((evt.target as FilteredList).selected as ListItem).value;
const gseControl = this.doc.querySelector(selector('GSEControl', id));
const gseControl = find(this.doc, 'GSEControl', id);
if (!gseControl) return;

this.selectedGseControl = gseControl;
Expand Down
4 changes: 2 additions & 2 deletions src/editors/publisher/report-control-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import './report-control-element-editor.js';
import '../../filtered-list.js';
import { FilteredList } from '../../filtered-list.js';

import { compareNames, identity, selector } from '../../foundation.js';
import { compareNames, identity, find } from '../../foundation.js';
import { reportIcon } from '../../icons/icons.js';
import { styles, updateElementReference } from './foundation.js';

Expand Down Expand Up @@ -66,7 +66,7 @@ export class ReportControlEditor extends LitElement {

private selectReportControl(evt: Event): void {
const id = ((evt.target as FilteredList).selected as ListItem).value;
const reportControl = this.doc.querySelector(selector('ReportControl', id));
const reportControl = find(this.doc, 'ReportControl', id);
if (!reportControl) return;

this.selectedReportControl = reportControl;
Expand Down
8 changes: 3 additions & 5 deletions src/editors/publisher/sampled-value-control-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import '../../filtered-list.js';
import './sampled-value-control-element-editor.js';
import { FilteredList } from '../../filtered-list.js';

import { compareNames, identity, selector } from '../../foundation.js';
import { compareNames, identity, find } from '../../foundation.js';
import { smvIcon } from '../../icons/icons.js';
import { styles, updateElementReference } from './foundation.js';

Expand All @@ -29,7 +29,7 @@ export class SampledValueControlEditor extends LitElement {
/** The document being edited as provided to plugins by [[`OpenSCD`]]. */
@property({ attribute: false })
doc!: XMLDocument;
@property({type: Number})
@property({ type: Number })
editCount = -1;

@state()
Expand Down Expand Up @@ -66,9 +66,7 @@ export class SampledValueControlEditor extends LitElement {

private selectSMVControl(evt: Event): void {
const id = ((evt.target as FilteredList).selected as ListItem).value;
const smvControl = this.doc.querySelector(
selector('SampledValueControl', id)
);
const smvControl = find(this.doc, 'SampledValueControl', id);
if (!smvControl) return;

this.selectedSampledValueControl = smvControl;
Expand Down
2 changes: 2 additions & 0 deletions src/editors/substation/ied-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export class IedEditor extends LitElement {
/** The document being edited as provided to editor by [[`Zeroline`]]. */
@property({ attribute: false })
doc!: XMLDocument;
@property({ type: Number })
editCount = -1;
/** SCL element IED */
@property({ attribute: false })
element!: Element;
Expand Down
6 changes: 3 additions & 3 deletions src/editors/templates/datype-wizards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import {
Create,
createElement,
EditorAction,
find,
getValue,
identity,
newActionEvent,
newSubWizardEvent,
newWizardEvent,
patterns,
Replace,
selector,
Wizard,
WizardActor,
WizardInputElement,
Expand Down Expand Up @@ -89,7 +89,7 @@ export function editDaTypeWizard(
dATypeIdentity: string,
doc: XMLDocument
): Wizard | undefined {
const datype = doc.querySelector(selector('DAType', dATypeIdentity));
const datype = find(doc, 'DAType', dATypeIdentity);
if (!datype) return undefined;

const id = datype.getAttribute('id');
Expand Down Expand Up @@ -138,7 +138,7 @@ export function editDaTypeWizard(
style="margin-top: 0px;"
@selected=${(e: SingleSelectedEvent) => {
const bdaIdentity = (<ListItem>(<List>e.target).selected).value;
const bda = doc.querySelector(selector('BDA', bdaIdentity));
const bda = find(doc, 'BDA', bdaIdentity);
if (bda)
e.target!.dispatchEvent(newSubWizardEvent(editBDAWizard(bda)));
Expand Down
13 changes: 4 additions & 9 deletions src/editors/templates/dotype-wizards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ import {
Create,
createElement,
EditorAction,
find,
getValue,
identity,
isPublic,
newActionEvent,
newSubWizardEvent,
newWizardEvent,
Replace,
selector,
Wizard,
WizardActor,
WizardInputElement,
Expand Down Expand Up @@ -99,12 +99,7 @@ function sDOWizard(options: WizardOptions): Wizard | undefined {
const doc = (<UpdateOptions>options).doc
? (<UpdateOptions>options).doc
: (<CreateOptions>options).parent.ownerDocument;
const sdo =
Array.from(
doc.querySelectorAll(
selector('SDO', (<UpdateOptions>options).identity ?? NaN)
)
).find(isPublic) ?? null;
const sdo = find(doc, 'SDO', (<UpdateOptions>options).identity ?? NaN);

const [title, action, type, menuActions, name, desc] = sdo
? [
Expand Down Expand Up @@ -351,7 +346,7 @@ export function dOTypeWizard(
dOTypeIdentity: string,
doc: XMLDocument
): Wizard | undefined {
const dotype = doc.querySelector(selector('DOType', dOTypeIdentity));
const dotype = find(doc, 'DOType', dOTypeIdentity);
if (!dotype) return undefined;

return [
Expand Down Expand Up @@ -411,7 +406,7 @@ export function dOTypeWizard(
const item = <ListItem>(<List>e.target).selected;
const daIdentity = (<ListItem>(<List>e.target).selected).value;
const da = doc.querySelector(selector('DA', daIdentity));
const da = find(doc, 'DA', daIdentity);
const wizard = item.classList.contains('DA')
? da
Expand Down
15 changes: 7 additions & 8 deletions src/editors/templates/enumtype-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
cloneElement,
createElement,
EditorAction,
find,
getValue,
identity,
isPublic,
Expand All @@ -23,7 +24,6 @@ import {
newWizardEvent,
patterns,
Replace,
selector,
Wizard,
WizardActor,
WizardInputElement,
Expand Down Expand Up @@ -101,12 +101,11 @@ function eNumValWizard(options: WizardOptions): Wizard {
const doc = (<UpdateOptions>options).doc
? (<UpdateOptions>options).doc
: (<CreateOptions>options).parent.ownerDocument;
const enumval =
Array.from(
doc.querySelectorAll(
selector('EnumVal', (<UpdateOptions>options).identity ?? NaN)
)
).find(isPublic) ?? null;
const enumval = find(
doc,
'EnumVal',
(<UpdateOptions>options).identity ?? NaN
);

const [title, action, ord, desc, value, menuActions] = enumval
? [
Expand Down Expand Up @@ -295,7 +294,7 @@ export function eNumTypeEditWizard(
eNumTypeIdentity: string,
doc: XMLDocument
): Wizard | undefined {
const enumtype = doc.querySelector(selector('EnumType', eNumTypeIdentity));
const enumtype = find(doc, 'EnumType', eNumTypeIdentity);
if (!enumtype) return undefined;

return [
Expand Down
Loading

0 comments on commit 58c814b

Please sign in to comment.