Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optional nsd upload button #1474

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading