diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..461553b --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,102 @@ +name: Build & deploy + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x, 14.x, 16.x] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Run code style check + run: npm run lint + - name: Run code formatter + run: npm run prettier + - name: Build + run: npm run build --if-present + - name: Create deploy folder + run: mkdir deploy + - name: Copy content from build folder to deploy folder + run: cp -r ./build/. ./deploy + - name: Copy content from public folder to deploy folder + run: cp -r ./public/. ./deploy + - name: Add script tag into index.html + run: sed -i '4 i ' './deploy/index.html' + - name: Upload production-ready build files on main branch + if: github.event_name != 'pull_request' + uses: actions/upload-artifact@v2 + with: + name: production-files + path: ./deploy + - name: Upload production-ready build files on pull_request + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v2 + with: + name: pull-request-files + path: ./deploy + + deploy: + name: Deploy + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: https://simtlix.github.io/simfinity-web/${{ env.branch_name }} + steps: + + # save branch name on main branch. + - name: Save branch name on main branch + if: github.event_name != 'pull_request' + run: echo "branch_name=${{ github.head_ref }}" >> $GITHUB_ENV + id: extract_branch + + # save branch name on pull request + - name: Save branch name on pull request + if: github.event_name == 'pull_request' + run: echo "branch_name=${{ github.head_ref }}" >> $GITHUB_ENV + + - name: Download artifact on main branch + if: github.event_name != 'pull_request' + uses: actions/download-artifact@v2 + with: + name: production-files + path: ./deploy + - name: Download artifact on pull_request + if: github.event_name == 'pull_request' + uses: actions/download-artifact@v2 + with: + name: pull-request-files + path: ./deploy + - name: Deploy to gh-pages on main branch + if: github.event_name != 'pull_request' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.ACTIONS_DEPLOY_ACCESS_TOKEN }} + publish_dir: ./deploy + destination_dir: ${{ env.branch_name }} + keep_files: true + - name: Deploy to gh-pages on pull_request + if: github.event_name == 'pull_request' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.ACTIONS_DEPLOY_ACCESS_TOKEN }} + publish_dir: ./deploy + destination_dir: ${{ env.branch_name }} + keep_files: false \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 8668060..5bccc27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5007,6 +5007,11 @@ } } }, + "email-addresses": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/email-addresses/-/email-addresses-3.1.0.tgz", + "integrity": "sha512-k0/r7GrWVL32kZlGwfPNgB2Y/mMXVTq/decgLczm/j34whdaspNrZO8CnXPf1laaHxI6ptUlsnAxN+UAPw+fzg==" + }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -6258,6 +6263,21 @@ "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", "optional": true }, + "filename-reserved-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-2.0.0.tgz", + "integrity": "sha1-q/c9+rc10EVECr/qLZHzieu/oik=" + }, + "filenamify": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/filenamify/-/filenamify-4.3.0.tgz", + "integrity": "sha512-hcFKyUG57yWGAzu1CMt/dPzYZuv+jAJUT85bL8mrXvNe6hWj6yEHEc4EdcgiA6Z3oi1/9wXJdZPXF2dZNgwgOg==", + "requires": { + "filename-reserved-regex": "^2.0.0", + "strip-outer": "^1.0.1", + "trim-repeated": "^1.0.0" + } + }, "filesize": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/filesize/-/filesize-6.0.1.tgz", @@ -6758,6 +6778,95 @@ "assert-plus": "^1.0.0" } }, + "gh-pages": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-3.2.3.tgz", + "integrity": "sha512-jA1PbapQ1jqzacECfjUaO9gV8uBgU6XNMV0oXLtfCX3haGLe5Atq8BxlrADhbD6/UdG9j6tZLWAkAybndOXTJg==", + "requires": { + "async": "^2.6.1", + "commander": "^2.18.0", + "email-addresses": "^3.0.1", + "filenamify": "^4.3.0", + "find-cache-dir": "^3.3.1", + "fs-extra": "^8.1.0", + "globby": "^6.1.0" + }, + "dependencies": { + "find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "requires": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "globby": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "requires": { + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "requires": { + "p-locate": "^4.1.0" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "requires": { + "semver": "^6.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "requires": { + "find-up": "^4.0.0" + } + } + } + }, "glob": { "version": "7.1.7", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", @@ -14677,6 +14786,14 @@ "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==" }, + "strip-outer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", + "integrity": "sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==", + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, "style-loader": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/style-loader/-/style-loader-0.23.1.tgz", @@ -14963,6 +15080,14 @@ "punycode": "^2.1.0" } }, + "trim-repeated": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/trim-repeated/-/trim-repeated-1.0.0.tgz", + "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, "ts-loader": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-6.2.1.tgz", diff --git a/package.json b/package.json index 7d60e40..110281a 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "version": "1.0.0", "author": "Multiscreen Technology Group - SimTLiX SRL", "license": "SEE LICENSE IN LICENSE", + "homepage": "https://simtlix.github.io/simfinity-web/", "repository": { "type": "git", "url": "https://github.com/simtlix/simfinity-web" @@ -13,6 +14,8 @@ "build" ], "scripts": { + "predeploy": "npm run build", + "deploy": "gh-pages -d deploy", "start": "direflow-scripts start", "build": "direflow-scripts build", "build:lib": "direflow-scripts build:lib", @@ -28,6 +31,7 @@ "babel-eslint": "^10.1.0", "direflow-component": "3.5.3", "direflow-scripts": "3.5.3", + "gh-pages": "^3.2.3", "react": "16.13.1", "react-dom": "16.13.1", "react-hook-form": "^7.4.0", diff --git a/src/direflow-components/App.js b/src/direflow-components/App.js index 444de68..adfb948 100644 --- a/src/direflow-components/App.js +++ b/src/direflow-components/App.js @@ -34,10 +34,23 @@ const App = ({ url }) => { } }); }, [url]); + useEffect(() => { + // usar useCallBack + const handleClick = (entity, ind) => { + setCurrentEntity(entity); + setResultTitle( + intl.formatMessage({ + id: `entity.${entity.name}.plural`, + defaultMessage: `Resultados de ${entity.name}`, + }) + ); + setSelectedKey(ind.toString()); + }; if (entities[0]?.name) { handleClick(entities[0], 0); } + // eslint-disable-next-line }, [entities]); const handleClick = (entity, ind) => { setCurrentEntity(entity); diff --git a/src/direflow-components/Form/Collection.js b/src/direflow-components/Form/Collection.js index 0949af5..27c6d2f 100644 --- a/src/direflow-components/Form/Collection.js +++ b/src/direflow-components/Form/Collection.js @@ -203,6 +203,7 @@ const Collection = ({ } ); } + // eslint-disable-next-line }, [parentId]); const handleSearch = (selectedKeys, confirm) => { diff --git a/src/direflow-components/Form/FormStack.js b/src/direflow-components/Form/FormStack.js index e8f75d5..f814755 100644 --- a/src/direflow-components/Form/FormStack.js +++ b/src/direflow-components/Form/FormStack.js @@ -78,6 +78,7 @@ const FormStack = ({ displayEntity = null, onSuccess, mode, id }) => { return newState; }); }, + // eslint-disable-next-line [entitiesStack, openForResultForms] ); @@ -120,6 +121,7 @@ const FormStack = ({ displayEntity = null, onSuccess, mode, id }) => { } }); } + // eslint-disable-next-line }, []); const onSubmit = (data, name) => { @@ -198,6 +200,7 @@ const FormStack = ({ displayEntity = null, onSuccess, mode, id }) => { ); + // eslint-disable-next-line }, [entitiesStack]); return render(); diff --git a/src/direflow-components/Form/SelectEntities.js b/src/direflow-components/Form/SelectEntities.js index b6c17b0..e276e2d 100644 --- a/src/direflow-components/Form/SelectEntities.js +++ b/src/direflow-components/Form/SelectEntities.js @@ -110,6 +110,7 @@ export const SelectEntities = ({ setResponseEntity(data); }); } + // eslint-disable-next-line }, [initialValue, initialValueFromForm]); useEffect(() => { @@ -166,8 +167,8 @@ export const SelectEntities = ({ setResponseEntity(data); }); //} + // eslint-disable-next-line }, [selectValues]); - const renderSelect = useCallback(() => { const options = responseEntity?.map((item) => { return ( @@ -177,6 +178,7 @@ export const SelectEntities = ({ ); }); return options; + // eslint-disable-next-line }, [responseEntity]); // siempre se va a mandar el id como field en este tipo de conexion ? @@ -233,6 +235,7 @@ export const SelectEntities = ({ ); + // eslint-disable-next-line }, [responseEntity, initialValue, initialValueFromForm]); return element(); diff --git a/src/direflow-components/Table/Table.js b/src/direflow-components/Table/Table.js index 427c4dd..44c0c00 100644 --- a/src/direflow-components/Table/Table.js +++ b/src/direflow-components/Table/Table.js @@ -181,6 +181,7 @@ const Table = ({ }; fetch(); } + // eslint-disable-next-line }, [selectValuesFilter, displayEntity, entities, url]); const handleReset = (clearFilters, entity) => { @@ -482,6 +483,7 @@ const Table = ({ }, }; }, + // eslint-disable-next-line [selectValues, selectedOperator] ); @@ -564,6 +566,7 @@ const Table = ({ if (displayEntity) { createColumns(displayEntity, getColumnSearchProps, isDate, setColumns); } + // eslint-disable-next-line }, [getColumnSearchProps]); useEffect(() => { @@ -604,6 +607,7 @@ const Table = ({ } }); } + // eslint-disable-next-line }, [displayEntity, pagination, filters, url, sort, lastDeleted]); const handleTableChange = (pagination, filters, sorter) => { diff --git a/src/direflow-components/Wrapper.js b/src/direflow-components/Wrapper.js index e442b60..f182e46 100644 --- a/src/direflow-components/Wrapper.js +++ b/src/direflow-components/Wrapper.js @@ -28,6 +28,7 @@ const Wrapper = (props) => { useEffect(() => { getData(); + // eslint-disable-next-line }, []); function selectLanguage(e) {