Skip to content

Commit

Permalink
feat: optional nsd upload button (#1474)
Browse files Browse the repository at this point in the history
* feat: optional nsd upload button

Signed-off-by: Steffen van den Driest <[email protected]>

* chore: removed translate

Signed-off-by: Steffen van den Driest <[email protected]>

---------

Signed-off-by: Steffen van den Driest <[email protected]>
  • Loading branch information
Stef3st authored Mar 18, 2024
1 parent 03dabf9 commit a6c5d3e
Show file tree
Hide file tree
Showing 4 changed files with 368 additions and 7 deletions.
13 changes: 9 additions & 4 deletions packages/open-scd/src/addons/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export class OscdSettings extends LitElement {
})
host!: HTMLElement;

@property({ type: Boolean })
nsdUploadButton = true;

/**
* Get the versions of the current OpenSCD NSD files.
* @returns Current version, revision and release for all current OpenSCD NSD files.
Expand Down Expand Up @@ -424,10 +427,12 @@ export class OscdSettings extends LitElement {
</mwc-formfield>
</form>
<wizard-divider></wizard-divider>
<section>
<h3>${get('settings.loadNsdTranslations')}</h3>
${this.renderFileSelect()}
</section>
${this.nsdUploadButton
? html`<section id="shownsdbutton">
<h3>${get('settings.loadNsdTranslations')}</h3>
${this.renderFileSelect()}
</section>`
: html``}
<mwc-list id="nsdocList">
${this.renderNsdocItem('IEC 61850-7-2')}
${this.renderNsdocItem('IEC 61850-7-3')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ snapshots["Oscd-Settings upload .nsdoc file using event and looks like latest sn
</form>
<wizard-divider>
</wizard-divider>
<section>
<section id="shownsdbutton">
<h3>
Uploaded NSDoc files
</h3>
Expand Down
18 changes: 18 additions & 0 deletions packages/open-scd/test/unit/Setting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ describe('OSCD-Settings', () => {
expect(element).to.have.deep.property('settings', defaults);
});

it('enables/shows the upload .nsdoc file button by default', async () => {
element.settingsUI.show();
await element.settingsUI.updateComplete;
expect(element.settingsUI.querySelector('section[id="shownsdbutton"]')).to
.not.be.null;
await expect(element).shadowDom.to.equalSnapshot();
});

it('disables/hides the upload .nsdoc file button', async () => {
element.settingsUI.show();
await element.settingsUI.updateComplete;
element.nsdUploadButton = false;
await element.requestUpdate();
expect(element.settingsUI.querySelector('section[id="shownsdbutton"]')).to
.be.null;
await expect(element).shadowDom.to.equalSnapshot();
});

it('saves chosen .nsdoc file and looks like latest snapshot', async () => {
element.settingsUI.show();
await element.settingsUI.updateComplete;
Expand Down
Loading

0 comments on commit a6c5d3e

Please sign in to comment.