Skip to content

Delete unneeded actions and selectors in apitokens clusterInitBundles integrations#5202

Merged
pedrottimark merged 1 commit intomasterfrom
redux-uneeded-apitokens-clusterInitBundles-integrations
Mar 13, 2023
Merged

Delete unneeded actions and selectors in apitokens clusterInitBundles integrations#5202
pedrottimark merged 1 commit intomasterfrom
redux-uneeded-apitokens-clusterInitBundles-integrations

Conversation

@pedrottimark
Copy link
Contributor

@pedrottimark pedrottimark commented Mar 10, 2023

Description

Another warm up exercise after returning from week away from code. The following analysis from November 2022.

Found while researching minimum unneeded code in #3759

One more step toward deleting sagas for integrations.

Analysis of reducers/apitokens.js

Find dispatch of actions:

  • fetchAPITokens: useFetchIntegrations dispatches action
  • generateAPIToken: 0 results for request action
  • revokeAPITokens: IntegrationsListPage dispatches action
  • startTokenGenerationWizard: 0 results
  • closeTokenGenerationWizard: 0 results

Find reference to selectors:

  • getAPITokens: useIntegrations and IntegrationTilesPage
  • tokenGenerationWizardOpen: 0 results
  • getCurrentGeneratedToken: 0 results
  • getCurrentGeneratedTokenMetadata: 0 results

Analysis of reducers/clusterInitBundles.js

Find dispatch of actions:

  • fetchClusterInitBundles: useFetchIntegrations and IntegrationsListPage dispatch action
  • generateClusterInitBundle: 0 results for request action
  • revokeClusterInitBundles: 0 results
  • startClusterInitBundleGenerationWizard: 0 results
  • closeClusterInitBundleGenerationWizard: 0 results

Find reference to selectors

  • getClusterInitBundles: useIntegrations and IntegrationTilesPage
  • clusterInitBundleGenerationWizardOpen: 0 results
  • getCurrentGeneratedClusterInitBundle: 0 results
  • getCurrentGeneratedHelmValuesBundle: 0 results
  • getCurrentGeneratedKubectlBundle: 0 results

Analysis of reducers/integrations

Find dispatch of actions:

  • fetchNotifiers: useFetchIntegrations
  • fetchBackups: useFetchIntegrations
  • fetchImageIntegrations: useFetchIntegrations
  • fetchSignatureIntegrations: useFetchIntegrations
  • testIntegration: 0 results
  • deleteIntegrations: IntegrationsListPage
  • triggerBackup: IntegrationsListPage
  • saveIntegration: 0 results
  • setCreateState: 0 results

Find reference to selectors:

  • getBackups: useIntegrations and IntegrationTilesPage
  • getNotifiers: useIntegrations and IntegrationTilesPage plus 5 in Network container
  • getImageIntegrations: useIntegrations and IntegrationTilesPage
  • getCreationState: 0 results
  • getSignatureIntegrations: useIntegrations and IntegrationTilesPage

Interpretation for reducers

Integrations container code:

  1. does dispatch fetch actions.

  2. does dispatch revoke action for API Token

  3. does not dispatch revoke action for Cluster Init Bundle:

    • DeleteClusterInitBundleConfirmationModal component calls the service function.
  4. does not dispatch generate actions:

    • useIntegrationActions hook calls the service functions
  5. does not dispatch testIntegration nor saveIntegration actions

    • useIntegrationActions hook calls the service functions
  6. does not dispatch any Wizard or Create actions

  7. does refer to get selectors

  8. does not refer to any Wizard or Current or CreateState selectors

Interpretation for sagas/apiTokenSagas.js

  1. Delete generateAPIToken and watchGenerateRequest because:

    • no dispatch for action
    • no results for form id: api-token-form-id
  2. Delete types.GENERATE_API_TOKEN.SUCCESS for getAPITokens because:

    • no dispatch for action
  3. Delete watchModalOpen because:

    • no dispatch for action

Interpretation for sagas/clusterInitBundleSagas.js

  1. Delete generateClusterInitBundle and watchGenerateRequest because:

    • no dispatch for action
    • no results for form id: cluster-init-bundle-form-id
  2. Delete types.GENERATE_CLUSTER_INIT_BUNDLE for getClusterInitBundles because:

    • no dispatch for action
  3. Delete requestFetchRoles and watchModalOpen because:

    • no dispatch for action, especially because Cluster Init Bundle does not have role

Interpretation for sagas/integrationSagas.js

Everything is needed.

Analysis of integration tests

  • apiTokens.test.js: generate, refetch, revoke
  • clusterInitBundles.test.js: generate, refetch, revoke
  • externalBackups.test.js: save and refetch and delete and test (with mock response)
  • general.test.js: fetch
  • imageIntegrations.test.js: save (with mock response) and refetch and delete and test
  • notifiers.test.js: save (with mock response for Jira) and refetch and delete and test (with mock response)
  • signatureIntegrations.test.js: save, refetch, delete

Residue

  1. Replace revokeAPIToken action with service function call in parallel with revokeClusterInitBundle within Integrations container code.
  2. Replace apiTokenSagas and clusterInitBundleSagas with dispatch of get actions from Integrations container code. That is, delete sagas, but keep reducers (see step 4).
  3. Explore possible solutions to useFetchIntegrations behavior to request both apitokens and clusterinitbundles when only one or the other changed.
  4. Replace in integrationsSagas everything except get for classic Network Graph
    • dispatch get actions (or thunks) from Integrations container code
    • replace delete and trigger actions with service function calls similar to save and test
  5. Too bad, so sad: to replace get actions and reducer store with service function calls and component state within Integrations probably depends on routing change from unified page of all integration types at /main/integrations with tabs for types and separate pages analogous to Access Control.

Checklist

  • Investigated and inspected CI test results
  • Unit test and regression tests added

Testing Performed

  1. yarn lint in ui

  2. yarn build in ui

  3. wc build/static/js/*.js in ui

    • branch - master: -6381 = 11678027 - 11684348 because webpack does not know that code is obsolete
  4. yarn cypress-open in ui/apps/platform

    • apitokens.test.js
    • clusterInitBundles.test.js
    • externalBackups.test.js
    • general.test.js
    • imageIntegrations.test.js
    • notifiers.test.js
    • signatureIntegrations.test.js

@ghost
Copy link

ghost commented Mar 10, 2023

Images are ready for the commit at 16c4e2c.

To use with deploy scripts, first export MAIN_IMAGE_TAG=3.74.x-348-g16c4e2c46c.

@pedrottimark pedrottimark requested a review from vjwilson March 13, 2023 19:09
@pedrottimark pedrottimark merged commit 77c7689 into master Mar 13, 2023
@pedrottimark pedrottimark deleted the redux-uneeded-apitokens-clusterInitBundles-integrations branch March 13, 2023 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants