Skip to content

Commit

Permalink
Merge branch 'master' into form-component
Browse files Browse the repository at this point in the history
  • Loading branch information
KhudaDad414 authored Mar 21, 2024
2 parents 0a43430 + 17708de commit 0cf43f0
Show file tree
Hide file tree
Showing 11 changed files with 171 additions and 43 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/bounty-program-commands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# This workflow is centrally managed at https://github.com/asyncapi/.github/
# Don't make changes to this file in this repository, as they will be overwritten with
# changes made to the same file in the abovementioned repository.

# The purpose of this workflow is to allow Bounty Team members
# (https://github.com/orgs/asyncapi/teams/bounty_team) to issue commands to the
# organization's global AsyncAPI bot related to the Bounty Program, while at the
# same time preventing unauthorized users from misusing them.

name: Bounty Program commands

on:
issue_comment:
types:
- created

jobs:
guard-against-unauthorized-use:
if: >
github.actor != ('aeworxet' || 'thulieblack') &&
(
contains(github.event.comment.body, '/bounty' )
)
runs-on: ubuntu-latest

steps:
- name: ❌ @${{github.actor}} made an unauthorized attempt to use a Bounty Program's command
uses: actions/github-script@v6

with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const commentText = `❌ @${{github.actor}} is not authorized to use the Bounty Program's commands.
These commands can only be used by members of the [Bounty Team](https://github.com/orgs/asyncapi/teams/bounty_team).`;
console.log(`❌ @${{github.actor}} made an unauthorized attempt to use a Bounty Program's command.`);
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentText
})
add-label-bounty:
if: >
github.actor == ('aeworxet' || 'thulieblack') &&
(
contains(github.event.comment.body, '/bounty' )
)
runs-on: ubuntu-latest
env:
BOUNTY_PROGRAM_LABELS_JSON: |
[
{"name": "bounty", "color": "0e8a16", "description": "Participation in the Bounty Program"}
]
steps:
- name: Add label `bounty`
uses: actions/github-script@v6

with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const BOUNTY_PROGRAM_LABELS = JSON.parse(process.env.BOUNTY_PROGRAM_LABELS_JSON);
let LIST_OF_LABELS_FOR_REPO = await github.rest.issues.listLabelsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
});
LIST_OF_LABELS_FOR_REPO = LIST_OF_LABELS_FOR_REPO.data.map(key => key.name);
if (!LIST_OF_LABELS_FOR_REPO.includes(BOUNTY_PROGRAM_LABELS[0].name)) {
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: BOUNTY_PROGRAM_LABELS[0].name,
color: BOUNTY_PROGRAM_LABELS[0].color,
description: BOUNTY_PROGRAM_LABELS[0].description
});
}
console.log('Adding label `bounty`...');
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [BOUNTY_PROGRAM_LABELS[0].name]
})
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Disable specific file since it would introduce more complexity to reduce it - mainly code complexity and complex template literals
sonar.exclusions=apps/studio/public/js/monaco/**,apps/studio/src/tailwind.css,apps/studio/src/components/SplitPane/**
# Disable duplicate code in tests since it would introduce more complexity to reduce it.
sonar.cpd.exclusions=apps/studio/public/js/monaco/**,apps/studio/src/components/Template/HTMLWrapper.tsx,apps/studio/src/components/Visualiser/Visualiser.tsx,apps/studio/src/components/Navigationv3.tsx,apps/studio/src/components/Navigation.tsx
sonar.cpd.exclusions=apps/studio/**
2 changes: 1 addition & 1 deletion apps/design-system/src/components/DropdownMenu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const items = [

export const Default = {
args: {
trigger: <button className="bg-white text-black rounded mx-3 my-3">Click me!</button>,
trigger: <button className="text-black bg-white rounded mx-3 my-3 px-3">Click me!</button>,
items,
side: 'bottom',
align: 'start'
Expand Down
2 changes: 1 addition & 1 deletion apps/design-system/src/components/SlideOver.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Example = () => {

return (
<div>
<button onClick={handleOpen} className="bg-white text-black rounded mx-3 my-3">Open SlideOver</button>
<button onClick={handleOpen} className="bg-white text-black rounded my-3 mx-3 px-3">Open SlideOver</button>

<SlideOver isOpen={isOpen} onClose={handleClose}>
<h2>Content of the SlideOver</h2>
Expand Down
5 changes: 5 additions & 0 deletions apps/studio-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
},
"dependencies": {
"@codemirror/state": "^6.4.1",
"@codemirror/commands": "^6.3.3",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lang-yaml": "^6.0.0",
"@codemirror/language": "^6.10.1",
"@codemirror/theme-one-dark": "^6.1.2",
"@types/node": "20.4.6",
"@types/react": "18.2.18",
"@types/react-dom": "18.2.7",
Expand Down
12 changes: 12 additions & 0 deletions apps/studio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @asyncapi/studio

## 0.20.2

### Patch Changes

- 5c7b4c1: scrollTo navigation to right code block in yaml.

## 0.20.1

### Patch Changes

- 6995cdf: bump dependencies

## 0.20.0

### Minor Changes
Expand Down
8 changes: 4 additions & 4 deletions apps/studio/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@asyncapi/studio",
"version": "0.20.0",
"version": "0.20.2",
"description": "One place that allows you to develop an AsyncAPI document, validate it, convert it to the latest version, preview the documentation and visualize the events flow.",
"license": "Apache-2.0",
"bugs": {
Expand All @@ -23,9 +23,9 @@
],
"dependencies": {
"@asyncapi/avro-schema-parser": "^3.0.18",
"@asyncapi/converter": "^1.4.13",
"@asyncapi/openapi-schema-parser": "^3.0.17",
"@asyncapi/parser": "^3.0.9",
"@asyncapi/converter": "^1.4.15",
"@asyncapi/openapi-schema-parser": "^3.0.18",
"@asyncapi/parser": "^3.0.10",
"@asyncapi/protobuf-schema-parser": "^3.2.8",
"@asyncapi/react-component": "^1.2.2",
"@asyncapi/specs": "^6.5.3",
Expand Down
7 changes: 5 additions & 2 deletions apps/studio/src/services/navigation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ export class NavigationService extends AbstractService {
hash: string,
) {
try {
const range = this.svcs.parserSvc.getRangeForJsonPath('asyncapi', jsonPointer);
const doc = this.svcs.editorSvc;
const methodType = doc.value.startsWith('asyncapi') ? 'getRangeForYamlPath' : 'getRangeForJsonPath';
const range = this.svcs.parserSvc[methodType]('asyncapi', jsonPointer);

if (range) {
await this.scrollToEditorLine(range.start.line + 1);
await this.scrollToEditorLine(range.start.line+1);
}

await this.scrollToHash(hash);
Expand Down
29 changes: 26 additions & 3 deletions apps/studio/src/services/parser.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { filesState, documentsState, settingsState } from '../state';
import type { Diagnostic, ParseOptions } from '@asyncapi/parser/cjs';
import type { DocumentDiagnostics } from '../state/documents.state';
import { SchemaParser } from '@asyncapi/parser';
import { getLocationForJsonPath, parseWithPointers } from '@stoplight/yaml';

export class ParserService extends AbstractService {
private parser!: Parser;
Expand Down Expand Up @@ -71,14 +72,36 @@ export class ParserService extends AbstractService {
getRangeForJsonPath(uri: string, jsonPath: string | Array<string | number>) {
try {
const { documents } = documentsState.getState();

const extras = documents[String(uri)]?.extras;

if (extras) {
jsonPath = Array.isArray(jsonPath) ? jsonPath : jsonPath.split('/').map(untilde);
if (jsonPath[0] === '') jsonPath.shift();

return extras.document.getRangeForJsonPath(jsonPath);
}
} catch (err) {
console.error(err);
}
}

getRangeForYamlPath(uri: string, jsonPath: string | Array<string | number>) {
try {
const { documents } = documentsState.getState();

const extras = documents[String(uri)]?.extras;

if (extras) {
jsonPath = Array.isArray(jsonPath) ? jsonPath : jsonPath.split('/').map(untilde);
if (jsonPath[0] === '') jsonPath.shift();
return extras.document.getRangeForJsonPath(jsonPath, true);
const yamlDoc = parseWithPointers(this.svcs.editorSvc.value);

const location = getLocationForJsonPath(yamlDoc, jsonPath, true);
return location?.range || { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } };
}
} catch (err: any) {
return;
} catch (err) {
console.error(err);
}
}

Expand Down
50 changes: 25 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
],
"packageManager": "[email protected]",
"dependencies": {
"@changesets/cli": "^2.26.2",
"@codemirror/commands": "^6.3.3",
"@codemirror/lang-json": "^6.0.1",
"@codemirror/lang-yaml": "^6.0.0",
"@codemirror/language": "^6.10.1",
"@codemirror/theme-one-dark": "^6.1.2"
"@changesets/cli": "^2.26.2"
}
}

0 comments on commit 0cf43f0

Please sign in to comment.