@pb33f/cowboy-components 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/components/attention-box/attention-box.d.ts +5 -0
  2. package/dist/components/attention-box/attention-box.js +28 -5
  3. package/dist/components/footer/footer.css.d.ts +2 -0
  4. package/dist/components/footer/footer.css.js +21 -0
  5. package/dist/components/footer/footer.d.ts +8 -0
  6. package/dist/components/footer/footer.js +36 -0
  7. package/dist/components/header/header.css.js +98 -89
  8. package/dist/components/header/header.d.ts +1 -0
  9. package/dist/components/header/header.js +6 -2
  10. package/dist/components/the-doctor/activity-spinner.d.ts +8 -0
  11. package/dist/components/the-doctor/activity-spinner.js +43 -0
  12. package/dist/components/the-doctor/feedback.css.d.ts +2 -0
  13. package/dist/components/the-doctor/feedback.css.js +30 -0
  14. package/dist/components/the-doctor/feedback.d.ts +14 -0
  15. package/dist/components/the-doctor/feedback.js +83 -0
  16. package/dist/components/the-doctor/status-bar.js +2 -1
  17. package/dist/components/the-doctor/the-doctor.css.js +7 -3
  18. package/dist/components/the-doctor/the-doctor.d.ts +9 -2
  19. package/dist/components/the-doctor/the-doctor.js +68 -9
  20. package/dist/cowboy-components.d.ts +1 -0
  21. package/dist/cowboy-components.js +1 -0
  22. package/dist/cowboy-components.umd.cjs +480 -368
  23. package/dist/css/cowboy-components.css +0 -17
  24. package/dist/model/feedback.d.ts +4 -0
  25. package/dist/model/feedback.js +2 -0
  26. package/dist/services/feedback-service.d.ts +5 -0
  27. package/dist/services/feedback-service.js +30 -0
  28. package/dist/services/linting-service.d.ts +1 -0
  29. package/dist/services/linting-service.js +15 -0
  30. package/dist/style.css +1 -1
  31. package/package.json +1 -1
@@ -21,10 +21,14 @@ import { ProblemList } from "../../components/problem-list/problem-list.js";
21
21
  import { Problem } from "../../model/problem.js";
22
22
  import { ProblemDetailsDrawer, ProblemDrawerEventType } from "../problem-list/details-drawer.js";
23
23
  import RuleDocumentationWorker from "../../workers/rule-documentation.worker.js?worker";
24
- import theDoctorCss from "./the-doctor.css.js";
25
24
  import { ProblemsOverview } from "../problems-overview/problems-overview.js";
26
25
  import { ErrorBanner } from "../error-banner/error-banner.js";
27
26
  import { StatusBar } from "../the-doctor/status-bar.js";
27
+ import { FeedbackComponent } from "./feedback.js";
28
+ import theDoctorCss from "./the-doctor.css.js";
29
+ import linksCss from "../../css/links.css";
30
+ import { FeedbackService } from "@/services/feedback-service";
31
+ import { ActivitySpinner } from "@/components/the-doctor/activity-spinner";
28
32
  export const DoctorDocumentBag = "pb33f-doctor-editor";
29
33
  export const HowToFixBag = "pb33f-doctor-howtofix";
30
34
  export const RuleDocumentationBag = "pb33f-doctor-ruledocs";
@@ -32,8 +36,9 @@ export const DiagnosticBag = "pb33f-doctor-diagnostic";
32
36
  export const OWASPBag = "pb33f-doctor-owasp";
33
37
  export const DefaultDocument = "document";
34
38
  export const DocumentProblems = "problems";
39
+ export const DoctorEndpoint = "doctor-endpoint";
35
40
  let TheDoctor = class TheDoctor extends LitElement {
36
- constructor() {
41
+ constructor(doctorEndpoint = "https://doctor.pb33f.io") {
37
42
  super();
38
43
  this.debounceTime = 300;
39
44
  this.bounceId = 0;
@@ -48,7 +53,16 @@ let TheDoctor = class TheDoctor extends LitElement {
48
53
  this.statusBar = new StatusBar();
49
54
  this.ruleDocsWorker = new RuleDocumentationWorker();
50
55
  this.unavailable = false;
51
- this.doctorEndpoint = "https://doctor.pb33f.io";
56
+ this.feedback = new FeedbackComponent();
57
+ this.activitySpinner = new ActivitySpinner();
58
+ // extract the doctor endpoint from session storage.
59
+ const sessionEndpoint = sessionStorage.getItem(DoctorEndpoint);
60
+ if (sessionEndpoint) {
61
+ this.doctorEndpoint = sessionEndpoint;
62
+ }
63
+ else {
64
+ this.doctorEndpoint = doctorEndpoint;
65
+ }
52
66
  // TODO: make this configurable
53
67
  this.editor.language = "yaml";
54
68
  //@ts-ignore
@@ -112,6 +126,7 @@ let TheDoctor = class TheDoctor extends LitElement {
112
126
  }
113
127
  }
114
128
  lintSpec(value) {
129
+ this.activitySpinner.show();
115
130
  LintingService.lintFile(value, this.OWASPEnabled).then((result) => {
116
131
  if (result && !Array.isArray(result)) {
117
132
  this.editor.setMarkers([result]);
@@ -131,6 +146,7 @@ let TheDoctor = class TheDoctor extends LitElement {
131
146
  LintingService.fetchStatistics().then((result) => {
132
147
  this.problemsOverview.statistics = result;
133
148
  this.diagnosticBag?.set(DiagnosticBag, result);
149
+ this.activitySpinner.hide();
134
150
  if (result?.remainingCredit <= 10) {
135
151
  this.statusBar.callsRemaining = result.remainingCredit;
136
152
  this.statusBar.visible = true;
@@ -195,6 +211,7 @@ let TheDoctor = class TheDoctor extends LitElement {
195
211
  }
196
212
  loadState() {
197
213
  LintingService.doctorEndpoint = this.doctorEndpoint;
214
+ FeedbackService.doctorEndpoint = this.doctorEndpoint;
198
215
  this.docBag = this.bagManager.getBag(DoctorDocumentBag);
199
216
  if (this.docBag) {
200
217
  const doc = this.docBag.get(DefaultDocument);
@@ -232,9 +249,14 @@ let TheDoctor = class TheDoctor extends LitElement {
232
249
  this.fetchDocs();
233
250
  }
234
251
  fetchDocs() {
252
+ this.activitySpinner.show();
235
253
  // the first this we need to do is start a session
236
254
  LintingService.startSession().then((session) => {
237
255
  this.session = session;
256
+ // bootstrap async
257
+ setTimeout(() => {
258
+ this.boostrap();
259
+ });
238
260
  LintingService.fetchAllHowToFix().then((result) => {
239
261
  if (result) {
240
262
  result.forEach((howToFix) => {
@@ -252,6 +274,7 @@ let TheDoctor = class TheDoctor extends LitElement {
252
274
  if (data) {
253
275
  data.forEach((doc) => {
254
276
  this.ruleDocsBag?.set(doc.ruleId, doc);
277
+ this.activitySpinner.hide();
255
278
  });
256
279
  }
257
280
  });
@@ -278,14 +301,37 @@ let TheDoctor = class TheDoctor extends LitElement {
278
301
  this.lintSpec(doc);
279
302
  }
280
303
  }
304
+ boostrap() {
305
+ if (this.editor.getValue() === '') {
306
+ LintingService.bootstrapEditor().then((result) => {
307
+ this.editor.setValue(result, true);
308
+ this.specChanged(new CustomEvent(EditorUpdated, {
309
+ detail: {
310
+ content: result
311
+ }
312
+ }));
313
+ });
314
+ }
315
+ }
281
316
  render() {
282
317
  let overlay = html ``;
283
318
  if (this.unavailable) {
284
319
  overlay = html `
285
320
  <div class="overlay" @click="return false"></div>`;
286
321
  }
322
+ let welcomeBox = html ` <pb33f-attention-box id="welcome" type="success" headerText="Welcome to the clinic, I am the OpenAPI doctor." closeable>
323
+ This is an <strong>early preview</strong> of a new <a href="https://pb33f.io">pb33f</a> product, built on top of our very own open source and free software.
324
+ If you find a bug, please let us know in the <strong>feedback</strong> tab. <br/><br/>
325
+ <a href="#" @click="${this.closeWelcome}">[Close this message]</a>
326
+ </pb33f-attention-box>`;
327
+ const welcomeClosed = localStorage.getItem("pb33f-doctor-welcome");
328
+ if (welcomeClosed) {
329
+ welcomeBox = html ``;
330
+ }
287
331
  return html `
332
+ ${welcomeBox}
288
333
  <div class="doctor">
334
+ ${this.activitySpinner}
289
335
  ${this.errorBanner}
290
336
  ${overlay}
291
337
  <sl-split-panel class="split-panel ${this.unavailable ? 'unavailable' : ''}">
@@ -299,17 +345,23 @@ let TheDoctor = class TheDoctor extends LitElement {
299
345
  <sl-tab slot="nav" panel="overview" class="tab" id="overviewPanel">Overview</sl-tab>
300
346
  <sl-tab slot="nav" panel="problems" class="tab" id="problemsPanel">Problems</sl-tab>
301
347
  <sl-tab slot="nav" panel="ruleset" class="tab" id="rulesetPanel">Rules</sl-tab>
348
+ <sl-tab slot="nav" panel="feedback" class="tab" id="feedbackPanel">Feedback</sl-tab>
302
349
  <sl-tab-panel name="overview" class="tab-panel">${this.problemsOverview}</sl-tab-panel>
303
350
  <sl-tab-panel name="problems" class="tab-panel">${this.problemList}</sl-tab-panel>
304
351
  <sl-tab-panel name="ruleset" class="tab-panel">
305
352
  <div class="ruleset">
306
- <pb33f-attention-box type="info" headerText="Manage RuleSets">
307
- Feature coming soon, you will be able to manage your ruleset(s) here.
308
- </pb33f-attention-box>
309
- <sl-switch size="small" @sl-change="${this.toggleOWASP}" id="owasp">Enable <a href="https://quobix.com/vacuum/rulesets/owasp/">OWASP</a>
310
- Rules</a>?</sl-switch>
353
+ <pb33f-attention-box type="info" headerText="Manage RuleSets">
354
+ Feature coming soon, you will be able to manage your ruleset(s) here.
355
+ </pb33f-attention-box>
356
+ <sl-switch size="small" @sl-change="${this.toggleOWASP}" id="owasp">Enable <a
357
+ href="https://quobix.com/vacuum/rulesets/owasp/">OWASP</a>
358
+ Rules</a>?
359
+ </sl-switch>
311
360
  </div>
312
361
  </sl-tab-panel>
362
+ <sl-tab-panel name="feedback" class="tab-panel">
363
+ ${this.feedback}
364
+ </sl-tab-panel>
313
365
  </sl-tab-group>
314
366
  </div>
315
367
  </sl-split-panel>
@@ -317,8 +369,12 @@ let TheDoctor = class TheDoctor extends LitElement {
317
369
  </div>
318
370
  `;
319
371
  }
372
+ closeWelcome() {
373
+ this.welcomeBox.hide();
374
+ localStorage.setItem("pb33f-doctor-welcome", "closed");
375
+ }
320
376
  };
321
- TheDoctor.styles = [theDoctorCss];
377
+ TheDoctor.styles = [theDoctorCss, linksCss];
322
378
  __decorate([
323
379
  query('#overviewPanel')
324
380
  ], TheDoctor.prototype, "overviewPanel", void 0);
@@ -331,6 +387,9 @@ __decorate([
331
387
  __decorate([
332
388
  query('sl-switch#owasp')
333
389
  ], TheDoctor.prototype, "owaspSwitch", void 0);
390
+ __decorate([
391
+ query('pb33f-attention-box#welcome')
392
+ ], TheDoctor.prototype, "welcomeBox", void 0);
334
393
  __decorate([
335
394
  property({ type: Boolean })
336
395
  ], TheDoctor.prototype, "unavailable", void 0);
@@ -14,6 +14,7 @@ import './components/changelog/release.js';
14
14
  import './components/attention-box/attention-box.js';
15
15
  import './components/render-operation-path/render-operation-path.js';
16
16
  import './components/render-json-path/render-json-path.js';
17
+ import './components/footer/footer.js';
17
18
  import './components/problem-list/problem-list.js';
18
19
  import './components/problem-list/problem-item.js';
19
20
  import './components/the-doctor/the-doctor.js';
@@ -14,6 +14,7 @@ import './components/changelog/release.js';
14
14
  import './components/attention-box/attention-box.js';
15
15
  import './components/render-operation-path/render-operation-path.js';
16
16
  import './components/render-json-path/render-json-path.js';
17
+ import './components/footer/footer.js';
17
18
  // problems
18
19
  import './components/problem-list/problem-list.js';
19
20
  import './components/problem-list/problem-item.js';