From c050b987a22ed12375f8b068c221f88568ee67aa Mon Sep 17 00:00:00 2001 From: derrickmehaffy Date: Thu, 6 Oct 2022 14:26:11 -0700 Subject: [PATCH 1/9] Add GH Actions for support team automation Signed-off-by: Derrick Mehaffy --- .github/workflows/issues_dailyCron.yml | 30 ++++ .github/workflows/issues_handleLabel.yml | 207 +++++++++++++++++++++++ 2 files changed, 237 insertions(+) create mode 100644 .github/workflows/issues_dailyCron.yml create mode 100644 .github/workflows/issues_handleLabel.yml diff --git a/.github/workflows/issues_dailyCron.yml b/.github/workflows/issues_dailyCron.yml new file mode 100644 index 0000000000..b241385433 --- /dev/null +++ b/.github/workflows/issues_dailyCron.yml @@ -0,0 +1,30 @@ +name: 'Daily Cron - 00:00' + +on: + schedule: + - cron: '0 0 * * *' + +permissions: + issues: write + statuses: read + +jobs: + cron-tasks: + runs-on: ubuntu-latest + steps: + - name: check for inactive issues that can't be reproduced + uses: actions-cool/issues-helper@v3 + with: + actions: 'close-issues' + token: ${{ secrets.GITHUB_TOKEN }} + labels: 'status: pending reproduction' + inactive-day: 14 + close-reason: 'completed' + body: | + Hello! + + As we have not received any new or updated information to reproduce in 14 days we are marking this issue as closed. Should you have new information please feel free to respond and we can consider reopening it. + + For others finding this closed issue and you have updated information, please open up a new bug report and simply reference this closed bug report so that we can get any new information you may have. If you have questions please refer to the [contributor's guide](https://github.com/strapi/strapi/blob/main/CONTRIBUTING.md#reporting-an-issue) on opening issues. + + Thank you and have a great day! diff --git a/.github/workflows/issues_handleLabel.yml b/.github/workflows/issues_handleLabel.yml new file mode 100644 index 0000000000..84363cbdae --- /dev/null +++ b/.github/workflows/issues_handleLabel.yml @@ -0,0 +1,207 @@ +name: Issue Labeled + +on: + issues: + types: [labeled] + +permissions: + issues: write + pull-requests: write + actions: read + checks: read + contents: read + repository-projects: read + statuses: read + +jobs: + issue-labeled: + runs-on: ubuntu-latest + steps: + # Unable to Reproduce Tasks + - name: 'Comment: unable to reproduce' + if: "${{ github.event.label.name == 'status: can not reproduce' }}" + uses: actions-cool/issues-helper@v3 + with: + actions: 'create-comment' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + > This is a templated message + + Hello @${{ github.event.issue.user.login }}, + + Thank you for reporting this bug, however we are unable to reproduce the issue you described given the information we have on hand. Can you please create a fresh project that you are able to reproduce the issue in, provide clear steps to reproduce this issue, and either upload this fresh project to a new GitHub repo or compress it into a `.zip` and upload it on this issue? + + We would greatly appreciate your assistance with this, by working in a fresh project it will cut out any possible variables that might be unrelated. + Please note that issues labeled with `status: can not reproduce` will be closed in 14 days if there is no activity. + + Thank you! + + # Support team auto assign + - name: 'Assign: add random solution engineer to reproduction issues' + if: "${{ github.event.label.name == 'status: pending reproduction' }}" + uses: actions-cool/issues-helper@v3 + with: + actions: 'add-assignees' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + assignees: 'derrickmehaffy, kasonde, bolg55' + random-to: 1 + + # v3 Legacy Issues + - name: 'Comment: unsupported v3 issues' + if: "${{ github.event.label.name == 'flag: v3-unsupported' }}" + uses: actions-cool/issues-helper@v3 + with: + actions: 'create-comment' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + > This is a templated message + + Hello @${{ github.event.issue.user.login }}, + + Thank you for reporting this potential bug report, please keep in mind that we are no longer accepting bug reports unless they could be deemed high or critical severity or related to security in nature. + The recommended action we suggest for v3 users is to utilize the various migration resources to upgrade your package from Strapi v3 to Strapi v4: + + - [Code Migration Guide](https://docs.strapi.io/developer-docs/latest/update-migration-guides/migration-guides/v4/code-migration.html) and/or [Codemods project](https://github.com/strapi/codemods) + - [Data Migration Guide](https://docs.strapi.io/developer-docs/latest/update-migration-guides/migration-guides/v4/data-migration.html) and/or [Data Migration Scripts](https://github.com/strapi/migration-scripts) + - [Plugin Migration Guide](https://docs.strapi.io/developer-docs/latest/update-migration-guides/migration-guides/v4/plugin-migration.html) + + Please see our [Security file](https://github.com/strapi/strapi/security) for more information about supported versions. + For now this issue is marked as closed as we do not believe this issue is Critical/High Severity nor related to security. + + Thank You + - name: 'Close: unsupported v3 issues' + if: "${{ github.event.label.name == 'flag: v3-unsupported' }}" + uses: actions-cool/issues-helper@v3 + with: + actions: 'close-issue' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + close-reason: 'not_planned' + + # Feature request redirections + - name: 'Comment: redirect feature request to canny' + if: "${{ github.event.label.name == 'issue: feature request' }}" + uses: actions-cool/issues-helper@v3 + with: + actions: 'create-comment' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + > This is a templated message + + Hello @${{ github.event.issue.user.login }}, + + First thank you for reporting this feature need. + To manage feature requests and the Strapi roadmap, we are using Canny. + You will be able to access the Public Roadmap here: https://feedback.strapi.io. + + In your message, please mention the URL of this thread in case some messages are posted there. But the most important is to have your feedback posted on our feedback/roadmap site. + The product team is reading EVERY comment, that really helps us to develop the project in the right direction. We are keeping all feature requests and project insights in one place, our feedback website. + + In order to keep our GitHub issues clean and for valid bug reports this issue will be marked as closed, but please feel free to continue the discussion with other community members here. + + Thank you for your insight and have a good day. + - name: 'Close: redirect feature request to canny' + if: "${{ github.event.label.name == 'issue: feature request' }}" + uses: actions-cool/issues-helper@v3 + with: + actions: 'close-issue' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + close-reason: 'completed' + + # Invalid bug report template actions + - name: 'Comment: invalid bug report template' + if: "${{ github.event.label.name == 'flag: invalid template' }}" + uses: actions-cool/issues-helper@v3 + with: + actions: 'create-comment' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + > This is a templated message + + Hello @${{ github.event.issue.user.login }}, + + We ask that you please follow the [issue template](https://raw.githubusercontent.com/strapi/strapi/master/.github/ISSUE_TEMPLATE/BUG_REPORT.md). + A proper issue submission let's us better understand the origin of your bug and therefore help you. We will reopen your issue when we receive the issue following the template guidelines and properly fill out the template. You can see the template guidelines for bug reports [here](https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md#reporting-an-issue). + + Please update the issue with the template and we can reopen this report. + + Thank you. + - name: 'Close: invalid bug report template' + if: "${{ github.event.label.name == 'flag: invalid template' }}" + uses: actions-cool/issues-helper@v3 + with: + actions: 'close-issue' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + close-reason: 'not_planned' + + # Redirect questions to community sources + - name: 'Comment: redirect question to community' + if: "${{ github.event.label.name == 'flag: question' }}" + uses: actions-cool/issues-helper@v3 + with: + actions: 'create-comment' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + > This is a templated message + + Hello @${{ github.event.issue.user.login }}, + + I see you are wanting to ask a question that is not really a bug report, + + - questions should be directed to [our forum](https://forum.strapi.io) or our [Discord](https://discord.strapi.io) + - feature requests should be directed to our [feedback and feature request database](https://feedback.strapi.io) + + Please see the following contributing guidelines for asking a question [here](https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md#reporting-an-issue). + + Thank you. + - name: 'Close: redirect question to community' + if: "${{ github.event.label.name == 'flag: question' }}" + uses: actions-cool/issues-helper@v3 + with: + actions: 'close-issue' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + close-reason: 'complete' + + # Critical issue alerting + # - name: alert team to critical issue + # if: "${{ github.event.label.name == 'severity: critical' }}" + # uses: rtCamp/action-slack-notify@v2 + # env: + # SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + # SLACK_CHANNEL: crisis + # SLACK_COLOR: bad + # SLACK_TITLE: Issue marked as Critical! + # SLACK_USERNAME: Strapi-Alerts + # SLACK_FOOTER: Triggered by GitHub Actions + + # Auto assign issues to projects based on source + - name: assign issues to Content squad project + uses: actions/add-to-project@v0.3.0 + with: + project-url: https://github.com/orgs/strapi/projects/11 + github-token: ${{ secrets.PROJECT_TRANSFER_TOKEN }} + labeled: 'source: core:admin, source: core:content-manager, source: core:upload, source: plugin:i18n' + label-operator: OR + - name: assign issues to DevExp squad project + uses: actions/add-to-project@v0.3.0 + with: + project-url: https://github.com/orgs/strapi/projects/13 + github-token: ${{ secrets.PROJECT_TRANSFER_TOKEN }} + labeled: 'source: core:content-type-builder, source: core:database, source: core:email, source: core:strapi, source: core:utils, source: plugin:graphql, source: plugin:users-permissions, source: typescript' + label-operator: OR + - name: assign issues to Expansions squad project + uses: actions/add-to-project@v0.3.0 + with: + project-url: https://github.com/orgs/strapi/projects/4 + github-token: ${{ secrets.PROJECT_TRANSFER_TOKEN }} + labeled: 'source: marketplace, source: plugin:sentry, source: plugin:documentation' + label-operator: OR From 19d88652e37be26a2975d14b4b3ba380332a46b1 Mon Sep 17 00:00:00 2001 From: Christian Capeans Date: Wed, 7 Dec 2022 14:21:58 +0100 Subject: [PATCH 2/9] Protect telemetry properties route --- packages/core/admin/admin/src/pages/App/index.js | 12 ++++++++++-- packages/core/admin/server/routes/admin.js | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/core/admin/admin/src/pages/App/index.js b/packages/core/admin/admin/src/pages/App/index.js index c353b68d04..557f77b31f 100644 --- a/packages/core/admin/admin/src/pages/App/index.js +++ b/packages/core/admin/admin/src/pages/App/index.js @@ -71,6 +71,8 @@ function App() { }, []); useEffect(() => { + const currentToken = auth.getToken(); + const getData = async () => { try { const { @@ -81,10 +83,16 @@ function App() { updateProjectSettings({ menuLogo: prefixFileUrlWithBackendUrl(menuLogo) }); - if (uuid) { + if (uuid && currentToken) { const { data: { data: properties }, - } = await axios.get(`${strapi.backendURL}/admin/telemetry-properties`); + } = await axios.get(`${strapi.backendURL}/admin/telemetry-properties`, { + headers: { + Authorization: `Bearer ${currentToken}`, + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + }); setTelemetryProperties(properties); diff --git a/packages/core/admin/server/routes/admin.js b/packages/core/admin/server/routes/admin.js index 4507f4c2ce..538ce59005 100644 --- a/packages/core/admin/server/routes/admin.js +++ b/packages/core/admin/server/routes/admin.js @@ -54,7 +54,7 @@ module.exports = [ path: '/telemetry-properties', handler: 'admin.telemetryProperties', config: { - auth: false, + policies: ['admin::isAuthenticatedAdmin'], }, }, { From 1ae2671f4c09c61dfafc204783679a3d53f47d7c Mon Sep 17 00:00:00 2001 From: gitstart Date: Thu, 8 Dec 2022 16:22:35 +0000 Subject: [PATCH 3/9] fix: select all when page is greater than one --- packages/core/upload/admin/src/pages/App/MediaLibrary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/upload/admin/src/pages/App/MediaLibrary.js b/packages/core/upload/admin/src/pages/App/MediaLibrary.js index 5c4c8f1085..63d995121e 100644 --- a/packages/core/upload/admin/src/pages/App/MediaLibrary.js +++ b/packages/core/upload/admin/src/pages/App/MediaLibrary.js @@ -211,7 +211,7 @@ export const MediaLibrary = () => { } selectAll([ ...assets.map((asset) => ({ ...asset, type: 'asset' })), - ...folders.map((folder) => ({ ...folder, type: 'folder' })), + ...(folders ?? []).map((folder) => ({ ...folder, type: 'folder' })), ]); }} /> From 664b5a8245aaaf82a0f8a3c1e2b105ad2f44b2e0 Mon Sep 17 00:00:00 2001 From: gitstart Date: Fri, 9 Dec 2022 16:26:08 +0000 Subject: [PATCH 4/9] chore: set default value for undefined folders --- packages/core/upload/admin/src/pages/App/MediaLibrary.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/upload/admin/src/pages/App/MediaLibrary.js b/packages/core/upload/admin/src/pages/App/MediaLibrary.js index 63d995121e..d8041b1288 100644 --- a/packages/core/upload/admin/src/pages/App/MediaLibrary.js +++ b/packages/core/upload/admin/src/pages/App/MediaLibrary.js @@ -82,7 +82,7 @@ export const MediaLibrary = () => { }); const { - data: folders, + data: folders = [], isLoading: foldersLoading, errors: foldersError, } = useFolders({ @@ -211,7 +211,7 @@ export const MediaLibrary = () => { } selectAll([ ...assets.map((asset) => ({ ...asset, type: 'asset' })), - ...(folders ?? []).map((folder) => ({ ...folder, type: 'folder' })), + ...folders.map((folder) => ({ ...folder, type: 'folder' })), ]); }} /> From 95601a3fb715c7d2811fffb9ac7caf1446da90d6 Mon Sep 17 00:00:00 2001 From: DMehaffy Date: Mon, 12 Dec 2022 06:43:27 -0800 Subject: [PATCH 5/9] Update .github/workflows/issues_dailyCron.yml Co-authored-by: Alexandre BODIN --- .github/workflows/issues_dailyCron.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issues_dailyCron.yml b/.github/workflows/issues_dailyCron.yml index b241385433..c1ba34a34c 100644 --- a/.github/workflows/issues_dailyCron.yml +++ b/.github/workflows/issues_dailyCron.yml @@ -23,7 +23,7 @@ jobs: body: | Hello! - As we have not received any new or updated information to reproduce in 14 days we are marking this issue as closed. Should you have new information please feel free to respond and we can consider reopening it. + As we have not received any new or updated information to reproduce this issue in the last 14 days we are marking this issue as closed. Should you have new information please feel free to respond and we will consider reopening it. For others finding this closed issue and you have updated information, please open up a new bug report and simply reference this closed bug report so that we can get any new information you may have. If you have questions please refer to the [contributor's guide](https://github.com/strapi/strapi/blob/main/CONTRIBUTING.md#reporting-an-issue) on opening issues. From b69af4277dbceb3ddd09080fe7b91a6767eeeeae Mon Sep 17 00:00:00 2001 From: DMehaffy Date: Mon, 12 Dec 2022 06:43:41 -0800 Subject: [PATCH 6/9] Update .github/workflows/issues_dailyCron.yml Co-authored-by: Alexandre BODIN --- .github/workflows/issues_dailyCron.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issues_dailyCron.yml b/.github/workflows/issues_dailyCron.yml index c1ba34a34c..7d42d50e38 100644 --- a/.github/workflows/issues_dailyCron.yml +++ b/.github/workflows/issues_dailyCron.yml @@ -25,6 +25,6 @@ jobs: As we have not received any new or updated information to reproduce this issue in the last 14 days we are marking this issue as closed. Should you have new information please feel free to respond and we will consider reopening it. - For others finding this closed issue and you have updated information, please open up a new bug report and simply reference this closed bug report so that we can get any new information you may have. If you have questions please refer to the [contributor's guide](https://github.com/strapi/strapi/blob/main/CONTRIBUTING.md#reporting-an-issue) on opening issues. + If anyone else have updated information for this issue, please open up a new bug report and simply reference this closed bug report so that we can get any new information you may have. If you have questions please refer to the [contributor's guide](https://github.com/strapi/strapi/blob/main/CONTRIBUTING.md#reporting-an-issue) on opening issues. Thank you and have a great day! From 96edc9816be75cfda76ed7075a56d37efb1b9a9c Mon Sep 17 00:00:00 2001 From: Christian Capeans Date: Mon, 12 Dec 2022 17:34:34 +0100 Subject: [PATCH 7/9] Add implementation using useFetchClient hook --- packages/core/admin/admin/src/pages/App/index.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/core/admin/admin/src/pages/App/index.js b/packages/core/admin/admin/src/pages/App/index.js index 557f77b31f..b41a98c06f 100644 --- a/packages/core/admin/admin/src/pages/App/index.js +++ b/packages/core/admin/admin/src/pages/App/index.js @@ -25,7 +25,7 @@ import NotFoundPage from '../NotFoundPage'; import UseCasePage from '../UseCasePage'; import { getUID } from './utils'; import routes from './utils/routes'; -import { useConfigurations } from '../../hooks'; +import { useConfigurations, useFetchClient } from '../../hooks'; const AuthenticatedApp = lazy(() => import(/* webpackChunkName: "Admin-authenticatedApp" */ '../../components/AuthenticatedApp') @@ -37,6 +37,7 @@ function App() { const { formatMessage } = useIntl(); const [{ isLoading, hasAdmin, uuid }, setState] = useState({ isLoading: true, hasAdmin: false }); const appInfo = useAppInfos(); + const { get } = useFetchClient(); const authRoutes = useMemo(() => { return makeUniqueRoutes( @@ -71,8 +72,6 @@ function App() { }, []); useEffect(() => { - const currentToken = auth.getToken(); - const getData = async () => { try { const { @@ -83,15 +82,11 @@ function App() { updateProjectSettings({ menuLogo: prefixFileUrlWithBackendUrl(menuLogo) }); - if (uuid && currentToken) { + if (uuid) { const { data: { data: properties }, - } = await axios.get(`${strapi.backendURL}/admin/telemetry-properties`, { - headers: { - Authorization: `Bearer ${currentToken}`, - Accept: 'application/json', - 'Content-Type': 'application/json', - }, + } = await get(`/admin/telemetry-properties`, { + validateStatus: (status) => status < 500, }); setTelemetryProperties(properties); From 32972b043333f092f74b5bf70be7134c56b470d3 Mon Sep 17 00:00:00 2001 From: gitstart Date: Tue, 13 Dec 2022 10:03:59 +0000 Subject: [PATCH 8/9] chore: removes optional chaining --- packages/core/upload/admin/src/pages/App/MediaLibrary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/upload/admin/src/pages/App/MediaLibrary.js b/packages/core/upload/admin/src/pages/App/MediaLibrary.js index d8041b1288..a4ccd227a1 100644 --- a/packages/core/upload/admin/src/pages/App/MediaLibrary.js +++ b/packages/core/upload/admin/src/pages/App/MediaLibrary.js @@ -103,7 +103,7 @@ export const MediaLibrary = () => { push(pathname); } - const folderCount = folders?.length || 0; + const folderCount = folders.length; const assets = assetsData?.results; const assetCount = assets?.length ?? 0; const isLoading = isCurrentFolderLoading || foldersLoading || permissionsLoading || assetsLoading; From 15bf86333b9a14e08a0c47861e2304ea35745e67 Mon Sep 17 00:00:00 2001 From: Christian Capeans Date: Tue, 13 Dec 2022 14:01:48 +0100 Subject: [PATCH 9/9] Add clarification message about validateStatus --- packages/core/admin/admin/src/pages/App/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/core/admin/admin/src/pages/App/index.js b/packages/core/admin/admin/src/pages/App/index.js index b41a98c06f..0aa61f9bc3 100644 --- a/packages/core/admin/admin/src/pages/App/index.js +++ b/packages/core/admin/admin/src/pages/App/index.js @@ -86,6 +86,7 @@ function App() { const { data: { data: properties }, } = await get(`/admin/telemetry-properties`, { + // NOTE: needed because the interceptors of the fetchClient redirect to /login when receive a 401 and it would end up in an infinite loop when the user doesn't have a session. validateStatus: (status) => status < 500, });