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

CI workflow (front-end) #166

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
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
52 changes: 52 additions & 0 deletions .github/workflows/ci_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on: [pull_request]

jobs:
build:
env:
working-directory: .
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- name: Build
run: |
docker build -t bot-flow .
working-directory: ${{env.working-directory}}
test:
env:
working-directory: ./app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- name: Install dependencies
run: |
yarn install
working-directory: ${{env.working-directory}}
- name: Run tests
run: |
yarn test --ci --coverage --color
working-directory: ${{env.working-directory}}
lint:
env:
working-directory: ./app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12'
- name: Install dependencies
run: |
yarn install
working-directory: ${{env.working-directory}}
- name: Run eslint
run: |
yarn lint
working-directory: ${{env.working-directory}}
27 changes: 27 additions & 0 deletions app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"env": {
"browser": true,
"es6": true,
"jest": true
},
"extends": [
"plugin:react/recommended",
"airbnb"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
}
}
10 changes: 8 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"lint": "eslint ./src/**/*.js"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -42,7 +43,12 @@
"devDependencies": {
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"eslint-plugin-import": "^2.18.2",
"eslint": "6.6.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"react-test-renderer": "^16.9.0"
}
}
14 changes: 8 additions & 6 deletions app/src/components/CustomSnackbar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React from 'react';

import clsx from 'clsx';
import CheckCircleIcon from '@material-ui/icons/CheckCircle';
Expand All @@ -19,7 +19,7 @@ const variantIcon = {
info: InfoIcon,
};

const useStyles1 = makeStyles(theme => ({
const useStyles1 = makeStyles((theme) => ({
success: {
backgroundColor: green[600],
},
Expand Down Expand Up @@ -47,24 +47,26 @@ const useStyles1 = makeStyles(theme => ({

export default function SnackbarContentCustom(props) {
const classes = useStyles1();
const { className, message, onClose, variant, } = props;
const {
className, message, onClose, variant,
} = props;
const Icon = variantIcon[variant];

return (
<SnackbarContent
className={clsx(classes[variant], className)}
aria-describedby="client-snackbar"
message={
message={(
<span id="client-snackbar" className={classes.message}>
<Icon className={clsx(classes.icon, classes.iconVariant)} />
{message}
</span>
}
)}
action={[
<IconButton key="close" aria-label="close" color="inherit" onClick={onClose}>
<CloseIcon className={classes.icon} />
</IconButton>,
]}
/>
);
}
}
68 changes: 34 additions & 34 deletions app/src/components/DeleteSnackbar.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@

import React, { Component } from "react";
import {message} from '../utils/messages';
import React, { Component } from 'react';
import { Button } from '@material-ui/core';
import Snackbar from '@material-ui/core/Snackbar';
import { message } from '../utils/messages';

class DeleteSnackbar extends Component {
handleUndoSnack() {
this.props.handleUndo();
this.props.handleSnackbarClick();
}
handleUndoSnack() {
this.props.handleUndo();
this.props.handleSnackbarClick();
}

render() {
return (
<Snackbar
anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}}
open={this.props.undo}
autoHideDuration={2000}
onClose={() => this.props.handleSnackbarClick(false)}
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span className="success" id="message-id">{message.deleted}</span>}
action={[
<Button
key="undo"
color="secondary"
size="small"
onClick={() => this.handleUndoSnack()}>
Desfazer
</Button>
]}
/>
)
}
render() {
return (
<Snackbar
anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}}
open={this.props.undo}
autoHideDuration={2000}
onClose={() => this.props.handleSnackbarClick(false)}
ContentProps={{
'aria-describedby': 'message-id',
}}
message={<span className="success" id="message-id">{message.deleted}</span>}
action={[
<Button
key="undo"
color="secondary"
size="small"
onClick={() => this.handleUndoSnack()}
>
Desfazer
</Button>,
]}
/>
);
}
}
export default DeleteSnackbar;
export default DeleteSnackbar;
57 changes: 27 additions & 30 deletions app/src/components/DeletionConfirmationDialog.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@

import React from "react";
import { message } from '../utils/messages';
import React from 'react';
import { Button } from '@material-ui/core';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogTitle from '@material-ui/core/DialogTitle';
import { message } from '../utils/messages';

const DeletionConfirmationDialog = ({ dialog_status, handleClose, deleteItem }) => {
return (
<Dialog
open={dialog_status}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">{message.delete_confirmation}</DialogTitle>
<DialogActions>
<Button
color="primary"
onClick={() => handleClose(false)}
>
Cancelar
</Button>
<Button
autoFocus
color="primary"
onClick={() => deleteItem()}
>
Apagar
</Button>
</DialogActions>
</Dialog>
const DeletionConfirmationDialog = ({ dialog_status, handleClose, deleteItem }) => (
<Dialog
open={dialog_status}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">{message.delete_confirmation}</DialogTitle>
<DialogActions>
<Button
color="primary"
onClick={() => handleClose(false)}
>
Cancelar
</Button>
<Button
autoFocus
color="primary"
onClick={() => deleteItem()}
>
Apagar
</Button>
</DialogActions>
</Dialog>

)
}
);

export default DeletionConfirmationDialog;
export default DeletionConfirmationDialog;
Loading