Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fb-optic-107/save-d…
Browse files Browse the repository at this point in the history
…raft-view-all
  • Loading branch information
Travis1282 committed Jan 4, 2024
2 parents b55439c + d1e4416 commit 8c3fcea
Show file tree
Hide file tree
Showing 29 changed files with 238 additions and 77 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/cicd_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,9 @@ jobs:
name: "Lint"
if: github.event_name == 'push' || github.event.pull_request.draft == false
uses: ./.github/workflows/eslint.yml
permissions:
checks: write
contents: read
pull-requests: write
with:
sha: ${{ github.event.pull_request.head.sha || github.event.after }}
7 changes: 7 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ env:
CACHE_NAME_PREFIX: v3
NODE: '18'

permissions:
checks: write
contents: read
pull-requests: write

jobs:
run:
name: Run ESLint
Expand Down Expand Up @@ -58,6 +63,8 @@ jobs:
- name: Run ESLint
uses: tj-actions/eslint-changed-files@v21
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
config_path: ".eslintrc.js"
ignore_path: ".eslintignore"
Expand Down
33 changes: 18 additions & 15 deletions .github/workflows/git-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Dump the client payload context
env:
PAYLOAD_CONTEXT: ${{ toJson(github.event.client_payload) }}
run: echo "$PAYLOAD_CONTEXT"
- uses: hmarr/[email protected]

- name: Add Workflow link to command comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
- name: Checkout on chat command
uses: actions/checkout@v4
Expand All @@ -27,15 +33,20 @@ jobs:
submodules: 'recursive'
fetch-depth: 0

- name: Configure git
shell: bash
run: |
set -xeuo pipefail
git config --global user.name '${{ github.event.client_payload.github.actor }}'
git config --global user.email '${{ github.event.client_payload.github.actor }}@users.noreply.github.com'
- name: Check for merge conflict
id: check-conflict
env:
SLASH_COMMAND_ARG_BRANCH: ${{ github.event.client_payload.slash_command.args.unnamed.arg2 }}
shell: bash
run: |
set -xeuo pipefail
git config --global user.name '${{ github.event.client_payload.github.actor }}'
git config --global user.email '${{ github.event.client_payload.github.actor }}@users.noreply.github.com'
echo "merge_conflict=$(git merge-tree $(git merge-base HEAD origin/$SLASH_COMMAND_ARG_BRANCH) origin/$SLASH_COMMAND_ARG_BRANCH HEAD | grep '<<')" >> $GITHUB_OUTPUT
- name: Add reaction to command comment on merge conflict
Expand All @@ -46,9 +57,7 @@ jobs:
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> **Error**: Merge conflict detected, please resolve it using the git command line.
>
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
> **Error**: Merge conflict detected, please resolve it using the command line.
reactions: "-1"

- name: Merge branch into current branch
Expand Down Expand Up @@ -79,8 +88,6 @@ jobs:
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> Already up-to-date. Nothing to commit.
>
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: "confused"

- name: Add reaction to command comment on success
Expand All @@ -93,8 +100,6 @@ jobs:
body: |
> Successfully pushed new changes:
> ${{ steps.commit_and_push.outputs.last_commit_msg }} (${{ steps.commit_and_push.outputs.last_commit_sha }})
>
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: "+1"

- name: Add reaction to command comment on failure
Expand All @@ -106,8 +111,6 @@ jobs:
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> **Error**: failed to execute "${{ github.event.client_payload.slash_command.args.unnamed.arg1 }}" command
>
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: "-1"

help:
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/jira-command.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "/git command"
name: "/jira command"

on:
repository_dispatch:
Expand All @@ -15,6 +15,15 @@ jobs:
steps:
- uses: hmarr/[email protected]

- name: Add Workflow link to command comment
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GIT_PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
- name: Check user's membership
uses: actions/github-script@v7
id: check-membership
Expand Down Expand Up @@ -62,8 +71,6 @@ jobs:
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> Jira issue [${{ steps.jira-create-issue.outputs.key }}](${{ steps.jira-create-issue.outputs.link }}) is created
>
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: "+1"

- name: Add reaction to command comment on failure
Expand All @@ -76,7 +83,6 @@ jobs:
body: |
> **Error**: failed to execute "${{ github.event.client_payload.slash_command.args.unnamed.arg1 }}" command
> ${{ steps.check-membership.outputs.error }}
> [Workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
reactions: "-1"

help:
Expand Down
30 changes: 26 additions & 4 deletions .github/workflows/slash-command-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ env:
git
jira
issue_commands_list: |
jira
jobs:
slashCommandDispatch:
if: startsWith(github.event.comment.body, '/')
Expand All @@ -22,28 +25,47 @@ jobs:
uses: actions/github-script@v7
env:
COMMANDS_LIST: ${{ env.commands_list }}
ISSUE_COMMANDS_LIST: ${{ env.issue_commands_list }}
with:
github-token: ${{ secrets.GIT_PAT }}
script: |
const body = context.payload.comment.body.toLowerCase().trim()
const commands_list = process.env.COMMANDS_LIST.split("\n")
const issue_commands_list = process.env.ISSUE_COMMANDS_LIST.split("\n")
console.log("Detected PR comment: " + body)
console.log("Commands list: " + commands_list)
console.log("Issue commands list: " + issue_commands_list)
commandArray = body.split(/\s+/)
const contextCommand = commandArray[0].split('/')[1].trim();
console.log("contextCommand: " + contextCommand)
core.setOutput('command_state', 'known')
core.setOutput('is_issue_command', 'false')
if (! commands_list.includes(contextCommand)) {
core.setOutput('command_state', 'unknown')
core.setOutput('command', contextCommand)
}
if (issue_commands_list.includes(contextCommand)) {
core.setOutput('is_issue_command', 'true')
}
- name: Slash Command Dispatch for Issues
id: scd_issues
if: ${{ steps.determine_command.outputs.command_state != 'unknown' && steps.determine_command.outputs.is_issue_command == 'true' }}
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.GIT_PAT }}
reaction-token: ${{ secrets.GIT_PAT }}
issue-type: "issue"
reactions: true
commands: ${{ env.issue_commands_list }}

- name: Slash Command Dispatch
id: scd
if: ${{ steps.determine_command.outputs.command_state != 'unknown' }}
- name: Slash Command Dispatch for PRs
id: scd_prs
if: ${{ steps.determine_command.outputs.command_state != 'unknown' && steps.determine_command.outputs.is_issue_command != 'true' }}
uses: peter-evans/slash-command-dispatch@v3
with:
token: ${{ secrets.GIT_PAT }}
reaction-token: ${{ secrets.GIT_PAT }}
issue-type: "pull-request"
reactions: true
commands: ${{ env.commands_list }}
Expand All @@ -54,6 +76,6 @@ jobs:
with:
comment-id: ${{ github.event.comment.id }}
body: |
> '/${{ steps.determine_command.outputs.command }}' is unknown command.
> '/${{ steps.determine_command.outputs.command }}' is an unknown command.
> See '/help'
reactions: eyes, confused
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"@martel/audio-file-decoder": "2.3.15",
"@thi.ng/rle-pack": "^2.1.6",
"@types/react-beautiful-dnd": "^13.1.3",
"@types/sanitize-html": "^2.9.5",
"babel-plugin-istanbul": "^6.1.1",
"babel-preset-react-app": "^9.1.1",
"d3": "^5.16.0",
Expand All @@ -100,7 +101,8 @@
"react-beautiful-dnd": "^13.1.1",
"react-konva-utils": "^0.2.0",
"react-virtualized-auto-sizer": "^1.0.6",
"react-window": "^1.8.6"
"react-window": "^1.8.6",
"sanitize-html": "^2.11.0"
},
"devDependencies": {
"@babel/core": "7.23.2",
Expand Down
3 changes: 2 additions & 1 deletion src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { FF_DEV_1170, FF_DEV_3873, FF_LSDV_4620_3_ML, isFF } from '../../utils/f
import { Annotation } from './Annotation';
import { Button } from '../../common/Button/Button';
import { reactCleaner } from '../../utils/reactCleaner';
import { sanitizeHtml } from '../../utils/html';

/**
* App
Expand Down Expand Up @@ -241,7 +242,7 @@ class App extends Component {
<>
{store.showingDescription && (
<Segment>
<div dangerouslySetInnerHTML={{ __html: store.description }} />
<div dangerouslySetInnerHTML={{ __html: sanitizeHtml(store.description) }} />
</Segment>
)}
</>
Expand Down
4 changes: 2 additions & 2 deletions src/components/BottomBar/Controls.styl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
&__footer
display flex
flex-direction row
justify-content end
justify-content flex-end

.submit-option
padding 12px 24px
Expand Down Expand Up @@ -129,4 +129,4 @@
border-radius 4px
opacity 0.08
background rgb(9 109 217)
pointer-events none
pointer-events none
2 changes: 1 addition & 1 deletion src/components/Comments/CommentForm.styl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
width 100%
display flex
justify-content center
align-items start
align-items flex-start
flex-shrink 0
flex-grow 0

Expand Down
6 changes: 3 additions & 3 deletions src/components/Comments/CommentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FF_DEV_3873, isFF } from '../../utils/feature-flags';

export type CommentFormProps = {
commentStore: any,
value?: string,
annotationStore: any,
onChange?: (value: string) => void,
inline?: boolean,
rows?: number,
Expand All @@ -19,7 +19,7 @@ export type CommentFormProps = {

export const CommentForm: FC<CommentFormProps> = observer(({
commentStore,
value = '',
annotationStore,
inline = true,
onChange,
rows = 1,
Expand Down Expand Up @@ -52,7 +52,6 @@ export const CommentForm: FC<CommentFormProps> = observer(({
commentStore.setCurrentComment(comment || '');
}, [commentStore]);


useEffect(() => {
if (!isFF(FF_DEV_3873)) {
commentStore.setAddedCommentThisSession(false);
Expand All @@ -72,6 +71,7 @@ export const CommentForm: FC<CommentFormProps> = observer(({
commentStore.setCommentFormSubmit(() => onSubmit());
}, [actionRef, commentStore]);

const value = commentStore.currentComment[annotationStore.selected.id] || '';

return (
<Block ref={formRef} tag="form" name="comment-form" mod={{ inline }} onSubmit={onSubmit}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Comments/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { FF_DEV_3034, isFF } from '../../utils/feature-flags';
import './Comments.styl';


export const Comments: FC<{ commentStore: any, cacheKey?: string }> = observer(({ commentStore, cacheKey }) => {
export const Comments: FC<{ annotationStore: any, commentStore: any, cacheKey?: string }> = observer(({ annotationStore, commentStore, cacheKey }) => {
const mounted = useMounted();

const loadComments = async () => {
Expand Down Expand Up @@ -45,7 +45,7 @@ export const Comments: FC<{ commentStore: any, cacheKey?: string }> = observer((

return (
<Block name="comments">
<CommentForm commentStore={commentStore} inline />
<CommentForm commentStore={commentStore} annotationStore={annotationStore} inline />
<CommentsList commentStore={commentStore} />
</Block>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/ErrorMessage/ErrorMessage.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import styles from './ErrorMessage.module.scss';
import { sanitizeHtml } from '../../utils/html';

export const ErrorMessage = ({ error }) => {
if (typeof error === 'string') {
return <div className={styles.error} dangerouslySetInnerHTML={{ __html: error }} />;
return <div className={styles.error} dangerouslySetInnerHTML={{ __html: sanitizeHtml(error) }} />;
}
const body = error instanceof Error ? error.message : error;

Expand Down
3 changes: 2 additions & 1 deletion src/components/InstructionsModal/InstructionsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Modal } from 'antd';
import { sanitizeHtml } from '../../utils/html';

export const InstructionsModal = ({
title,
Expand Down Expand Up @@ -50,7 +51,7 @@ export const InstructionsModal = ({
{typeof children === 'string' ? (
<p
style={contentStyle}
dangerouslySetInnerHTML={{ __html: children }}
dangerouslySetInnerHTML={{ __html: sanitizeHtml(children) }}
/>
) : (
<p style={contentStyle}>{children}</p>
Expand Down
3 changes: 2 additions & 1 deletion src/components/SidePanels/DetailsPanel/DetailsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const CommentsTab: FC<any> = inject('store')(observer(({ store }) => {
<Block name="comments-panel">
<Elem name="section-tab">
<Elem name="section-content">
<CommentsComponent commentStore={store.commentStore} cacheKey={`task.${store.task.id}`} />
<CommentsComponent annotationStore={store.annotationStore} commentStore={store.commentStore} cacheKey={`task.${store.task.id}`} />
</Elem>
</Elem>
</Block>
Expand Down Expand Up @@ -169,6 +169,7 @@ const GeneralPanel: FC<any> = inject('store')(observer(({ store, currentEntity }
</Elem>
<Elem name="section-content">
<CommentsComponent
annotationStore={store.annotationStore}
commentStore={store.commentStore}
cacheKey={`task.${store.task.id}`}
/>
Expand Down
Loading

0 comments on commit 8c3fcea

Please sign in to comment.