├── .eslintrc ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── draft-release-notes-config.yml └── workflows │ ├── cypress-workflow.yml │ ├── draft-release-notes-workflow.yml │ ├── release-workflow.yml │ └── unit-tests-workflow.yml ├── .gitignore ├── .kibana-plugin-helpers.json ├── .lintstagedrc ├── .prettierignore ├── .prettierrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── babel.config.js ├── cypress.json ├── cypress ├── .eslintrc.json ├── fixtures │ ├── sample_policy.json │ └── sample_rollup.json ├── integration │ ├── indices_spec.js │ ├── managed_indices_spec.js │ ├── policies_spec.js │ └── rollups_spec.js ├── plugins │ └── index.js └── support │ ├── commands.js │ ├── constants.js │ ├── index.d.ts │ └── index.js ├── kibana.json ├── models └── interfaces.ts ├── package.json ├── public ├── app.scss ├── components │ ├── ConfirmationModal │ │ ├── ConfirmationModal.test.tsx │ │ ├── ConfirmationModal.tsx │ │ ├── __snapshots__ │ │ │ └── ConfirmationModal.test.tsx.snap │ │ └── index.ts │ ├── ContentPanel │ │ ├── ContentPanel.test.tsx │ │ ├── ContentPanel.tsx │ │ ├── ContentPanelActions.test.tsx │ │ ├── ContentPanelActions.tsx │ │ ├── __snapshots__ │ │ │ ├── ContentPanel.test.tsx.snap │ │ │ └── ContentPanelActions.test.tsx.snap │ │ └── index.ts │ ├── DarkMode │ │ ├── DarkMode.tsx │ │ └── index.ts │ ├── Modal │ │ ├── Modal.test.tsx │ │ ├── Modal.tsx │ │ ├── ModalRoot.tsx │ │ └── index.ts │ ├── PolicyModal │ │ ├── PolicyModal.test.tsx │ │ ├── PolicyModal.tsx │ │ ├── __snapshots__ │ │ │ └── PolicyModal.test.tsx.snap │ │ └── index.ts │ └── core_services.ts ├── index.ts ├── index_management_app.tsx ├── models │ └── interfaces.ts ├── pages │ ├── ChangePolicy │ │ ├── components │ │ │ ├── ChangeManagedIndices │ │ │ │ ├── ChangeManagedIndices.test.tsx │ │ │ │ ├── ChangeManagedIndices.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── ChangeManagedIndices.test.tsx.snap │ │ │ │ └── index.ts │ │ │ └── NewPolicy │ │ │ │ ├── NewPolicy.test.tsx │ │ │ │ ├── NewPolicy.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── NewPolicy.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── containers │ │ │ └── ChangePolicy │ │ │ │ ├── ChangePolicy.test.tsx │ │ │ │ ├── ChangePolicy.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── ChangePolicy.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── index.ts │ │ └── models │ │ │ └── interfaces.ts │ ├── Commons │ │ └── BaseAggregationAndMetricSettings.tsx │ ├── CreatePolicy │ │ ├── components │ │ │ ├── ConfigurePolicy │ │ │ │ ├── ConfigurePolicy.test.tsx │ │ │ │ ├── ConfigurePolicy.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── ConfigurePolicy.test.tsx.snap │ │ │ │ └── index.ts │ │ │ └── DefinePolicy │ │ │ │ ├── DefinePolicy.test.tsx │ │ │ │ ├── DefinePolicy.tsx │ │ │ │ ├── __mocks__ │ │ │ │ └── DefinePolicyMock.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── DefinePolicy.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── containers │ │ │ └── CreatePolicy │ │ │ │ ├── CreatePolicy.test.tsx │ │ │ │ ├── CreatePolicy.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── CreatePolicy.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── index.ts │ │ └── utils │ │ │ └── constants.ts │ ├── CreateRollup │ │ ├── components │ │ │ ├── AdvancedAggregation │ │ │ │ ├── AdvancedAggregation.tsx │ │ │ │ └── index.ts │ │ │ ├── ConfigureRollup │ │ │ │ ├── ConfigureRollup.tsx │ │ │ │ └── index.ts │ │ │ ├── CreateRollupSteps │ │ │ │ ├── CreateRollupSteps.tsx │ │ │ │ └── index.ts │ │ │ ├── HistogramAndMetrics │ │ │ │ ├── HistogramAndMetrics.tsx │ │ │ │ └── index.ts │ │ │ ├── JobNameAndIndices │ │ │ │ ├── JobNameAndIndices.tsx │ │ │ │ └── index.ts │ │ │ ├── MetricsCalculation │ │ │ │ ├── MetricsCalculation.tsx │ │ │ │ └── index.ts │ │ │ ├── RollupIndices │ │ │ │ ├── RollupIndices.tsx │ │ │ │ └── index.ts │ │ │ ├── Schedule │ │ │ │ ├── Schedule.tsx │ │ │ │ └── index.ts │ │ │ ├── ScheduleRolesAndNotifications │ │ │ │ ├── ScheduleRolesAndNotifications.tsx │ │ │ │ └── index.ts │ │ │ └── TimeAggregations │ │ │ │ ├── TimeAggregation.tsx │ │ │ │ └── index.ts │ │ ├── containers │ │ │ ├── CreateRollup │ │ │ │ ├── CreateRollup.tsx │ │ │ │ └── index.ts │ │ │ ├── CreateRollupForm │ │ │ │ ├── CreateRollupForm.test.tsx │ │ │ │ ├── CreateRollupForm.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── CreateRollupForm.test.tsx.snap │ │ │ │ └── index.ts │ │ │ ├── CreateRollupStep2 │ │ │ │ ├── CreateRollupStep2.tsx │ │ │ │ └── index.ts │ │ │ ├── CreateRollupStep3 │ │ │ │ ├── CreateRollupStep3.tsx │ │ │ │ └── index.ts │ │ │ └── CreateRollupStep4 │ │ │ │ ├── CreateRollupStep4.tsx │ │ │ │ └── index.ts │ │ ├── index.ts │ │ └── utils │ │ │ ├── constants.ts │ │ │ └── helpers.ts │ ├── EditRollup │ │ ├── containers │ │ │ ├── EditRollup.test.tsx │ │ │ ├── EditRollup.tsx │ │ │ ├── __snapshots__ │ │ │ │ └── EditRollup.test.tsx.snap │ │ │ └── index.ts │ │ └── index.ts │ ├── Indices │ │ ├── components │ │ │ ├── ApplyPolicyModal │ │ │ │ ├── ApplyPolicyModal.test.tsx │ │ │ │ ├── ApplyPolicyModal.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── ApplyPolicyModal.test.tsx.snap │ │ │ │ └── index.ts │ │ │ ├── IndexControls │ │ │ │ ├── IndexControls.test.tsx │ │ │ │ ├── IndexControls.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── IndexControls.test.tsx.snap │ │ │ │ └── index.ts │ │ │ └── IndexEmptyPrompt │ │ │ │ ├── IndexEmptyPrompt.test.tsx │ │ │ │ ├── IndexEmptyPrompt.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── IndexEmptyPrompt.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── containers │ │ │ └── Indices │ │ │ │ ├── Indices.test.tsx │ │ │ │ ├── Indices.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── Indices.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── models │ │ │ └── interfaces.ts │ │ └── utils │ │ │ ├── constants.tsx │ │ │ └── helpers.ts │ ├── Main │ │ ├── Main.tsx │ │ └── index.ts │ ├── ManagedIndices │ │ ├── components │ │ │ ├── InfoModal │ │ │ │ ├── InfoModal.test.tsx │ │ │ │ ├── InfoModal.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── InfoModal.test.tsx.snap │ │ │ │ └── index.ts │ │ │ ├── ManagedIndexControls │ │ │ │ ├── ManagedIndexControls.test.tsx │ │ │ │ ├── ManagedIndexControls.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── ManagedIndexControls.test.tsx.snap │ │ │ │ └── index.ts │ │ │ ├── ManagedIndexEmptyPrompt │ │ │ │ ├── ManagedIndexEmptyPrompt.test.tsx │ │ │ │ ├── ManagedIndexEmptyPrompt.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── ManagedIndexEmptyPrompt.test.tsx.snap │ │ │ │ └── index.ts │ │ │ ├── RetryModal │ │ │ │ ├── RetryModal.test.tsx │ │ │ │ ├── RetryModal.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── RetryModal.test.tsx.snap │ │ │ │ └── index.ts │ │ │ └── RolloverAliasModal │ │ │ │ ├── RolloverAliasModal.test.tsx │ │ │ │ ├── RolloverAliasModal.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── RolloverAliasModal.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── containers │ │ │ └── ManagedIndices │ │ │ │ ├── ManagedIndices.test.tsx │ │ │ │ ├── ManagedIndices.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── ManagedIndices.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── models │ │ │ └── interfaces.ts │ │ └── utils │ │ │ ├── constants.ts │ │ │ └── helpers.ts │ ├── Policies │ │ ├── components │ │ │ ├── PolicyControls │ │ │ │ ├── PolicyControls.test.tsx │ │ │ │ ├── PolicyControls.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ │ └── PolicyControls.test.tsx.snap │ │ │ │ └── index.ts │ │ │ └── PolicyEmptyPrompt │ │ │ │ ├── PolicyEmptyPrompt.test.tsx │ │ │ │ ├── PolicyEmptyPrompt.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── PolicyEmptyPrompt.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── containers │ │ │ └── Policies │ │ │ │ ├── Policies.test.tsx │ │ │ │ ├── Policies.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── Policies.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── models │ │ │ └── interfaces.ts │ │ └── utils │ │ │ ├── constants.ts │ │ │ └── helpers.ts │ ├── RollupDetails │ │ ├── components │ │ │ ├── AggregationAndMetricsSettings │ │ │ │ ├── AggregationAndMetricsSettings.tsx │ │ │ │ └── index.ts │ │ │ ├── GeneralInformation │ │ │ │ ├── GeneralInformation.tsx │ │ │ │ └── index.ts │ │ │ └── RollupStatus │ │ │ │ ├── RollupStatus.tsx │ │ │ │ └── index.ts │ │ ├── containers │ │ │ └── RollupDetails │ │ │ │ ├── RollupDetails.test.tsx │ │ │ │ ├── RollupDetails.tsx │ │ │ │ ├── __snapshots__ │ │ │ │ └── RollupDetails.test.tsx.snap │ │ │ │ └── index.ts │ │ ├── index.ts │ │ └── utils │ │ │ └── helpers.tsx │ └── Rollups │ │ ├── components │ │ ├── DeleteModal │ │ │ ├── DeleteModal.tsx │ │ │ └── index.ts │ │ └── RollupEmptyPrompt │ │ │ ├── RollupEmptyPrompt.tsx │ │ │ └── index.ts │ │ ├── containers │ │ └── Rollups │ │ │ ├── Rollups.test.tsx │ │ │ ├── Rollups.tsx │ │ │ ├── __snapshots__ │ │ │ └── Rollups.test.tsx.snap │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── models │ │ └── interfaces.ts │ │ └── utils │ │ ├── constants.tsx │ │ └── helpers.ts ├── plugin.ts ├── services │ ├── IndexService.test.ts │ ├── IndexService.ts │ ├── ManagedIndexService.test.ts │ ├── ManagedIndexService.ts │ ├── PolicyService.test.ts │ ├── PolicyService.ts │ ├── RollupService.test.ts │ ├── RollupService.ts │ ├── Services.ts │ └── index.ts ├── temporary │ ├── AsyncInterval.ts │ └── EuiRefreshPicker.tsx └── utils │ ├── constants.ts │ └── helpers.ts ├── release-notes ├── create-release-notes.py ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.10.0.0.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.10.1.0.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.11.0.0.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.12.0.0.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.13.0.0.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.13.0.1.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.3.0.0.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.4.0.0.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.6.0.0.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.7.0.0.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.8.0.0.md ├── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.9.0.0.md └── opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.9.0.1.md ├── server ├── clusters │ ├── index.ts │ └── ism │ │ ├── createISMCluster.ts │ │ └── ismPlugin.ts ├── index.ts ├── models │ ├── interfaces.ts │ └── types.ts ├── plugin.ts ├── routes │ ├── index.ts │ ├── indices.ts │ ├── managedIndices.ts │ ├── policies.ts │ └── rollups.ts ├── services │ ├── IndexService.ts │ ├── ManagedIndexService.ts │ ├── PolicyService.ts │ ├── RollupService.ts │ └── index.ts └── utils │ ├── constants.ts │ └── helpers.ts ├── test ├── constants.ts ├── jest.config.js ├── mocks │ ├── browserServicesMock.ts │ ├── coreServicesMock.ts │ ├── historyMock.ts │ ├── httpClientMock.ts │ ├── index.ts │ └── styleMock.ts ├── polyfills.ts ├── polyfills │ └── mutationObserver.js ├── setup.jest.ts └── setupTests.ts ├── tsconfig.json ├── utils └── constants.ts └── yarn.lock /.eslintrc: -------------------------------------------------------------------------------- 1 | --- 2 | extends: "@elastic/kibana" 3 | 4 | settings: 5 | import/resolver: 6 | '@elastic/eslint-import-resolver-kibana': 7 | rootPackageName: 'opendistro_index_management_kibana' 8 | pluginPaths: 9 | - . 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **Other plugins installed** 13 | Please mention if you are using this plugin along side any other plugin. Security for example. 14 | 15 | **To Reproduce** 16 | Steps to reproduce the behavior: 17 | 1. Go to '...' 18 | 2. Click on '....' 19 | 3. Scroll down to '....' 20 | 4. See error 21 | 22 | **Expected behavior** 23 | A clear and concise description of what you expected to happen. 24 | 25 | **Screenshots** 26 | If applicable, add screenshots to help explain your problem. 27 | 28 | **Desktop (please complete the following information):** 29 | - OS: [e.g. iOS] 30 | - Browser [e.g. chrome, safari] 31 | - Version [e.g. 22] 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 11 | 12 | **Describe the solution you'd like** 13 | A clear and concise description of what you want to happen. 14 | 15 | **Describe alternatives you've considered** 16 | A clear and concise description of any alternative solutions or features you've considered. 17 | 18 | **Additional context** 19 | Add any other context or screenshots about the feature request here. 20 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | *Issue #, if available:* 2 | 3 | *Description of changes:* 4 | 5 | 6 | By making a contribution to this project, I certify that: 7 | 8 | (a) The contribution was created in whole or in part by me and I 9 | have the right to submit it under the open source license 10 | indicated in the file; or 11 | 12 | (b) The contribution is based upon previous work that, to the best 13 | of my knowledge, is covered under an appropriate open source 14 | license and I have the right under that license to submit that 15 | work with modifications, whether created in whole or in part 16 | by me, under the same open source license (unless I am 17 | permitted to submit under a different license), as indicated 18 | in the file; or 19 | 20 | (c) The contribution was provided directly to me by some other 21 | person who certified (a), (b) or (c) and I have not modified 22 | it. 23 | 24 | (d) I understand and agree that this project and the contribution 25 | are public and that a record of the contribution (including all 26 | personal information I submit with it, including my sign-off) is 27 | maintained indefinitely and may be redistributed consistent with 28 | this project or the open source license(s) involved. 29 | 30 | -------------------------------------------------------------------------------- /.github/draft-release-notes-config.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/marketplace/actions/release-drafter 2 | # As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you’re ready 3 | 4 | template: | 5 | Compatible with Kibana (**set version here**). 6 | $CHANGES 7 | 8 | # Setting the formatting and sorting for the release notes body 9 | name-template: Version (set version here) 10 | change-template: '* $TITLE ([#$NUMBER]($URL))' 11 | sort-by: merged_at 12 | sort-direction: ascending 13 | replacers: 14 | - search: '##' 15 | replace: '###' 16 | 17 | # Organizing the tagged PRs into unified ODFE categories 18 | categories: 19 | - title: 'Breaking changes' 20 | labels: 21 | - 'breaking change' 22 | - title: 'Features' 23 | labels: 24 | - 'feature' 25 | - title: 'Enhancements' 26 | labels: 27 | - 'enhancement' 28 | - 'action' 29 | - 'API' 30 | - title: 'Bug Fixes' 31 | labels: 32 | - 'bug' 33 | - title: 'Infrastructure' 34 | labels: 35 | - 'infra' 36 | - 'testing' 37 | - 'CI/CD' 38 | - 'dependencies' 39 | - title: 'Documentation' 40 | labels: 41 | - 'documentation' 42 | - title: 'Maintenance' 43 | labels: 44 | - 'version support' 45 | - title: 'Refactoring' 46 | labels: 47 | - 'refactor' 48 | -------------------------------------------------------------------------------- /.github/workflows/draft-release-notes-workflow.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | update_release_draft: 10 | name: Update draft release notes 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Update draft release notes 14 | uses: release-drafter/release-drafter@v5 15 | with: 16 | config-name: draft-release-notes-config.yml 17 | name: Version (set here) 18 | tag: (None) 19 | env: 20 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 21 | -------------------------------------------------------------------------------- /.github/workflows/unit-tests-workflow.yml: -------------------------------------------------------------------------------- 1 | name: Unit tests workflow 2 | on: 3 | push: 4 | branches: 5 | - main 6 | 7 | jobs: 8 | tests: 9 | name: Run unit tests 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout Index Management Kibana plugin 13 | uses: actions/checkout@v2 14 | with: 15 | path: index-management-kibana-plugin 16 | - name: Get Kibana version 17 | id: kibana_version 18 | run: | 19 | echo "::set-output name=kibana_version::$(node -p "(require('./index-management-kibana-plugin/kibana.json').kibanaVersion).match(/[.0-9]+/)[0]")" 20 | - name: Checkout Kibana 21 | uses: actions/checkout@v2 22 | with: 23 | repository: opendistro-for-elasticsearch/kibana-oss 24 | ref: ${{ steps.kibana_version.outputs.kibana_version }} 25 | token: ${{ secrets.GITHUB_KIBANA_OSS }} 26 | path: kibana 27 | - name: Get node and yarn versions 28 | id: versions 29 | run: | 30 | echo "::set-output name=node_version::$(node -p "(require('./kibana/package.json').engines.node).match(/[.0-9]+/)[0]")" 31 | echo "::set-output name=yarn_version::$(node -p "(require('./kibana/package.json').engines.yarn).match(/[.0-9]+/)[0]")" 32 | - name: Setup node 33 | uses: actions/setup-node@v1 34 | with: 35 | node-version: ${{ steps.versions.outputs.node_version }} 36 | registry-url: 'https://registry.npmjs.org' 37 | - name: Install correct yarn version for Kibana 38 | run: | 39 | npm uninstall -g yarn 40 | echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}" 41 | npm i -g yarn@${{ steps.versions.outputs.yarn_version }} 42 | - name: Bootstrap plugin/kibana 43 | run: | 44 | mkdir -p kibana/plugins 45 | mv index-management-kibana-plugin kibana/plugins 46 | cd kibana/plugins/index-management-kibana-plugin 47 | yarn kbn bootstrap 48 | - name: Run tests 49 | run: | 50 | cd kibana/plugins/index-management-kibana-plugin 51 | yarn run test:jest 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | npm-debug.log* 2 | node_modules 3 | /build/ 4 | /public/app.css 5 | .idea/ 6 | yarn-error.log 7 | /coverage/ 8 | .DS_Store 9 | /cypress/screenshots/ 10 | /cypress/videos/ 11 | target 12 | -------------------------------------------------------------------------------- /.kibana-plugin-helpers.json: -------------------------------------------------------------------------------- 1 | { 2 | "serverSourcePatterns": [ 3 | "package.json", 4 | "tsconfig.json", 5 | "yarn.lock", 6 | ".yarnrc", 7 | "{lib,public,server,webpackShims,translations,utils,models,test}/**/*", 8 | "!__tests__" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "*.{ts,tsx,js,jsx,json,css,md}": ["prettier --write", "git add"] 3 | } 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | build 3 | coverage 4 | node_modules 5 | npm-debug.log 6 | yarn.lock 7 | *.md 8 | *.lock 9 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "printWidth": 140 4 | } 5 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | index-management-kibana-plugin 2 | Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | // babelrc doesn't respect NODE_PATH anymore but using require does. 17 | // Alternative to install them locally in node_modules 18 | module.exports = { 19 | presets: [require("@babel/preset-env"), require("@babel/preset-react"), require("@babel/preset-typescript")], 20 | plugins: [ 21 | [require("@babel/plugin-transform-runtime"), { regenerator: true }], 22 | require("@babel/plugin-proposal-class-properties"), 23 | require("@babel/plugin-proposal-object-rest-spread"), 24 | ], 25 | }; 26 | -------------------------------------------------------------------------------- /cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "viewportHeight": 900, 3 | "viewportWidth": 1440, 4 | "defaultCommandTimeout": 10000, 5 | "env": { 6 | "elasticsearch": "localhost:9200", 7 | "kibana": "localhost:5601", 8 | "security_enabled": false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /cypress/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["plugin:cypress/recommended"], 3 | "rules": { 4 | "quotes": ["error", "double", { "allowTemplateLiterals": true }] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /cypress/fixtures/sample_policy.json: -------------------------------------------------------------------------------- 1 | { 2 | "policy": { 3 | "description": "A simple description", 4 | "default_state": "hot", 5 | "states": [ 6 | { 7 | "name": "hot", 8 | "actions": [ 9 | { 10 | "replica_count": { 11 | "number_of_replicas": 5 12 | } 13 | } 14 | ], 15 | "transitions": [ 16 | { 17 | "state_name": "cold", 18 | "conditions": { 19 | "min_index_age": "30d" 20 | } 21 | } 22 | ] 23 | }, 24 | { 25 | "name": "cold", 26 | "actions": [ 27 | { 28 | "replica_count": { 29 | "number_of_replicas": 2 30 | } 31 | } 32 | ], 33 | "transitions": [] 34 | } 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /cypress/fixtures/sample_rollup.json: -------------------------------------------------------------------------------- 1 | { 2 | "rollup": { 3 | "enabled": true, 4 | "schedule": { 5 | "interval": { 6 | "period": 1, 7 | "unit": "Minutes", 8 | "start_time": 1602100553 9 | } 10 | }, 11 | "last_updated_time": 1602100553, 12 | "description": "An example rollup job that rolls up the sample ecommerce data", 13 | "source_index": "kibana_sample_data_ecommerce", 14 | "target_index": "test_rollup_target", 15 | "page_size": 1000, 16 | "delay": 0, 17 | "continuous": false, 18 | "dimensions": [ 19 | { 20 | "date_histogram": { 21 | "source_field": "order_date", 22 | "fixed_interval": "90m", 23 | "timezone": "America/Los_Angeles" 24 | } 25 | }, 26 | { 27 | "terms": { 28 | "source_field": "customer_gender" 29 | } 30 | }, 31 | { 32 | "terms": { 33 | "source_field": "geoip.city_name" 34 | } 35 | }, 36 | { 37 | "terms": { 38 | "source_field": "geoip.region_name" 39 | } 40 | }, 41 | { 42 | "terms": { 43 | "source_field": "day_of_week" 44 | } 45 | } 46 | ], 47 | "metrics": [ 48 | { 49 | "source_field": "taxless_total_price", 50 | "metrics": [{ "avg": {} }, { "sum": {} }, { "max": {} }, { "min": {} }, { "value_count": {} }] 51 | }, 52 | { 53 | "source_field": "total_quantity", 54 | "metrics": [{ "avg": {} }, { "max": {} }] 55 | } 56 | ] 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /cypress/plugins/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | /// 17 | // *********************************************************** 18 | // This example plugins/index.js can be used to load plugins 19 | // 20 | // You can change the location of this file or turn off loading 21 | // the plugins file with the 'pluginsFile' configuration option. 22 | // 23 | // You can read more here: 24 | // https://on.cypress.io/plugins-guide 25 | // *********************************************************** 26 | 27 | // This function is called when a project is opened or re-opened (e.g. due to 28 | // the project's config changing) 29 | 30 | // TODO: yarn kbn bootstrap fails when trying to add below package as a dependency.. 31 | // const wp = require("@cypress/webpack-preprocessor"); 32 | // 33 | /** 34 | * @type {Cypress.PluginConfig} 35 | */ 36 | module.exports = on => { 37 | // const options = { 38 | // webpackOptions: { 39 | // resolve: { 40 | // extensions: [".ts", ".tsx", ".js", ".jsx", ".json"], 41 | // }, 42 | // module: { 43 | // rules: [ 44 | // { 45 | // test: /\.tsx?$/, 46 | // loader: "ts-loader", 47 | // options: { transpileOnly: true }, 48 | // }, 49 | // ], 50 | // }, 51 | // }, 52 | // }; 53 | // 54 | // on("file:preprocessor", wp(options)); 55 | }; 56 | -------------------------------------------------------------------------------- /cypress/support/constants.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | export const API_ROUTE_PREFIX = "/_opendistro/_ism"; 17 | export const API_ROUTE_PREFIX_ROLLUP = "/_opendistro/_rollup"; 18 | 19 | export const INDEX = { 20 | OPENDISTRO_ISM_CONFIG: ".opendistro-ism-config", 21 | }; 22 | 23 | export const API = { 24 | POLICY_BASE: `${API_ROUTE_PREFIX}/policies`, 25 | EXPLAIN_BASE: `${API_ROUTE_PREFIX}/explain`, 26 | RETRY_BASE: `${API_ROUTE_PREFIX}/retry`, 27 | ADD_POLICY_BASE: `${API_ROUTE_PREFIX}/add`, 28 | REMOVE_POLICY_BASE: `${API_ROUTE_PREFIX}/remove`, 29 | CHANGE_POLICY_BASE: `${API_ROUTE_PREFIX}/change_policy`, 30 | ROLLUP_JOBS_BASE: `${API_ROUTE_PREFIX_ROLLUP}/jobs`, 31 | }; 32 | 33 | export const PLUGIN_NAME = "opendistro_index_management_kibana"; 34 | 35 | export const ADMIN_AUTH = { 36 | username: "admin", 37 | password: "admin", 38 | }; 39 | -------------------------------------------------------------------------------- /cypress/support/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | /// 17 | 18 | declare namespace Cypress { 19 | interface Chainable { 20 | /** 21 | * Deletes all indices in cluster 22 | * @example 23 | * cy.wipeCluster() 24 | */ 25 | deleteAllIndices(): Chainable; 26 | /** 27 | * Creates a policy 28 | * @example 29 | * cy.createPolicy("some_policy", { "policy": { ... } }) 30 | */ 31 | createPolicy(policyId: string, policyJSON: object): Chainable; 32 | /** 33 | * Gets settings for index 34 | * @example 35 | * cy.getIndexSettings("some_index") 36 | */ 37 | getIndexSettings(index: string): Chainable; 38 | /** 39 | * Updated the managed index config's start time to 40 | * make it run in 3 seconds after calling this 41 | * @example 42 | * cy.updateManagedIndexConfigStartTime("some_index") 43 | */ 44 | updateManagedIndexConfigStartTime(index: string): Chainable; 45 | /** 46 | * Creates index with policy 47 | * @example 48 | * cy.createIndex("some_index", "some_policy") 49 | */ 50 | createIndex(index: string, policyID?: string, settings?: object): Chainable; 51 | /** 52 | * Creates a rollup 53 | * @example 54 | * cy.createRollup("some_rollup", { "rollup": { ... } }) 55 | */ 56 | createRollup(policyId: string, policyJSON: object): Chainable; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /cypress/support/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | // *********************************************************** 17 | // This example support/index.js is processed and 18 | // loaded automatically before your test files. 19 | // 20 | // This is a great place to put global configuration and 21 | // behavior that modifies Cypress. 22 | // 23 | // You can change the location of this file or turn off 24 | // automatically serving support files with the 25 | // 'supportFile' configuration option. 26 | // 27 | // You can read more here: 28 | // https://on.cypress.io/configuration 29 | // *********************************************************** 30 | 31 | // Import commands.js using ES2015 syntax: 32 | import "./commands"; 33 | 34 | // Alternatively you can use CommonJS syntax: 35 | // require('./commands') 36 | 37 | // Switch the base URL of Elasticsearch when security enabled in the cluster 38 | if (Cypress.env("security_enabled")) { 39 | Cypress.env("elasticsearch", "https://localhost:9200"); 40 | } 41 | -------------------------------------------------------------------------------- /kibana.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "opendistroIndexManagementKibana", 3 | "version": "1.13.0.1", 4 | "kibanaVersion": "7.10.2", 5 | "configPath": ["opendistro_index_management"], 6 | "requiredPlugins": ["navigation"], 7 | "server": true, 8 | "ui": true 9 | } 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "opendistro_index_management_kibana", 3 | "version": "1.13.0.1", 4 | "description": "Kibana plugin for Index Management", 5 | "main": "index.js", 6 | "license": "Apache-2.0", 7 | "homepage": "https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin", 8 | "config": { 9 | "id": "opendistroIndexManagementKibana" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin" 14 | }, 15 | "scripts": { 16 | "cypress:open": "cypress open", 17 | "kbn": "node ../../scripts/kbn", 18 | "es": "node ../../scripts/es", 19 | "lint": "eslint .", 20 | "plugin-helpers": "node ../../scripts/plugin_helpers", 21 | "test:jest": "NODE_PATH=../../node_modules ../../node_modules/.bin/jest --config ./test/jest.config.js", 22 | "build": "yarn plugin-helpers build", 23 | "postbuild": "echo Renaming build artifact to [$npm_package_config_id-$npm_package_version.zip] && mv build/$npm_package_config_id*.zip build/$npm_package_config_id-$npm_package_version.zip" 24 | }, 25 | "husky": { 26 | "hooks": { 27 | "pre-commit": "lint-staged" 28 | } 29 | }, 30 | "resolutions": { 31 | "**/@types/node": "10.12.27", 32 | "@types/react": "^16.9.8", 33 | "**/@types/angular": "1.6.50", 34 | "**/@types/jest": "^24.0.9", 35 | "**/@types/react-dom": "^16.9.8", 36 | "**/@types/react-router-dom": "^4.3.1", 37 | "eslint-utils": "^1.4.2" 38 | }, 39 | "devDependencies": { 40 | "@elastic/elastic-eslint-config-kibana": "link:../../packages/elastic-eslint-config-kibana", 41 | "@elastic/eslint-import-resolver-kibana": "link:../../packages/kbn-eslint-import-resolver-kibana", 42 | "@types/react-dom": "^16.9.8", 43 | "@types/react-router-dom": "^5.1.5", 44 | "cypress": "^6.0.0", 45 | "eslint-plugin-no-unsanitized": "^3.0.2", 46 | "eslint-plugin-prefer-object-spread": "^1.2.1", 47 | "husky": "^3.0.0", 48 | "lint-staged": "^9.2.0", 49 | "ts-loader": "^6.2.1" 50 | }, 51 | "engines": { 52 | "node": "10.23.1", 53 | "yarn": "^1.21.1" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /public/app.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | -------------------------------------------------------------------------------- /public/components/ConfirmationModal/ConfirmationModal.test.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import "@testing-library/jest-dom/extend-expect"; 18 | import { render, fireEvent } from "@testing-library/react"; 19 | import ConfirmationModal from "./ConfirmationModal"; 20 | 21 | describe(" spec", () => { 22 | it("renders the component", () => { 23 | render( 24 | {}} 29 | onAction={() => {}} 30 | /> 31 | ); 32 | // EuiOverlayMask appends an element to the body so we should have two, an empty div from react-test-library 33 | // and our EuiOverlayMask element 34 | expect(document.body.children).toHaveLength(2); 35 | expect(document.body.children[1]).toMatchSnapshot(); 36 | }); 37 | 38 | it("calls onAction when action button clicked", () => { 39 | const onAction = jest.fn(); 40 | const { getByTestId } = render( 41 | {}} 46 | onAction={onAction} 47 | /> 48 | ); 49 | 50 | fireEvent.click(getByTestId("confirmationModalActionButton")); 51 | expect(onAction).toHaveBeenCalled(); 52 | }); 53 | 54 | it("calls close when close button clicked", () => { 55 | const onClose = jest.fn(); 56 | const { getByTestId } = render( 57 | {}} 63 | /> 64 | ); 65 | 66 | fireEvent.click(getByTestId("confirmationModalCloseButton")); 67 | expect(onClose).toHaveBeenCalled(); 68 | }); 69 | }); 70 | -------------------------------------------------------------------------------- /public/components/ConfirmationModal/ConfirmationModal.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { 18 | EuiButton, 19 | EuiModal, 20 | EuiModalBody, 21 | EuiModalFooter, 22 | EuiModalHeader, 23 | EuiModalHeaderTitle, 24 | EuiOverlayMask, 25 | EuiButtonEmpty, 26 | // @ts-ignore 27 | } from "@elastic/eui"; 28 | 29 | interface ConfirmationModalProps { 30 | title: string; 31 | bodyMessage: string; 32 | actionMessage: string; 33 | onClose: () => void; 34 | onAction: () => void; 35 | } 36 | 37 | const ConfirmationModal: React.SFC = ({ title, bodyMessage, actionMessage, onClose, onAction }) => { 38 | return ( 39 | 40 | {/* 41 | // @ts-ignore */} 42 | 43 | 44 | {title} 45 | 46 | 47 | {bodyMessage} 48 | 49 | 50 | 51 | Cancel 52 | 53 | { 55 | onAction(); 56 | onClose(); 57 | }} 58 | fill 59 | data-test-subj="confirmationModalActionButton" 60 | > 61 | {actionMessage} 62 | 63 | 64 | 65 | 66 | ); 67 | }; 68 | 69 | export default ConfirmationModal; 70 | -------------------------------------------------------------------------------- /public/components/ConfirmationModal/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ConfirmationModal from "./ConfirmationModal"; 17 | 18 | export default ConfirmationModal; 19 | -------------------------------------------------------------------------------- /public/components/ContentPanel/ContentPanel.test.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { render } from "@testing-library/react"; 18 | import ContentPanel from "./ContentPanel"; 19 | 20 | describe(" spec", () => { 21 | it("renders the component", () => { 22 | const { container } = render( 23 | one,
two
]}> 24 |
Testing ContentPanel
25 |
26 | ); 27 | expect(container.firstChild).toMatchSnapshot(); 28 | }); 29 | 30 | it("renders actions", () => { 31 | const { getByText } = render( 32 | one,
two
]}> 33 |
Testing ContentPanel
34 |
35 | ); 36 | getByText("one"); 37 | getByText("two"); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /public/components/ContentPanel/ContentPanel.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiPanel, EuiTitle } from "@elastic/eui"; 18 | 19 | interface ContentPanelProps { 20 | title?: string; 21 | titleSize?: "xxxs" | "xxs" | "xs" | "s" | "m" | "l"; 22 | bodyStyles?: object; 23 | panelStyles?: object; 24 | horizontalRuleClassName?: string; 25 | actions?: React.ReactNode | React.ReactNode[]; 26 | children: React.ReactNode | React.ReactNode[]; 27 | } 28 | 29 | const ContentPanel: React.SFC = ({ 30 | title = "", 31 | titleSize = "l", 32 | bodyStyles = {}, 33 | panelStyles = {}, 34 | horizontalRuleClassName = "", 35 | actions, 36 | children, 37 | }) => ( 38 | 39 | 40 | 41 | 42 |

{title}

43 |
44 |
45 | {actions ? ( 46 | 47 | 48 | {Array.isArray(actions) ? ( 49 | (actions as React.ReactNode[]).map( 50 | (action: React.ReactNode, idx: number): React.ReactNode => {action} 51 | ) 52 | ) : ( 53 | {actions} 54 | )} 55 | 56 | 57 | ) : null} 58 |
59 | 60 | 61 | 62 |
{children}
63 |
64 | ); 65 | 66 | export default ContentPanel; 67 | -------------------------------------------------------------------------------- /public/components/ContentPanel/ContentPanelActions.test.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { render, fireEvent } from "@testing-library/react"; 18 | import ContentPanelActions from "./ContentPanelActions"; 19 | 20 | describe(" spec", () => { 21 | it("renders the component", () => { 22 | const actions = [{ text: "ContentPanelActions" }]; 23 | const { container } = render(); 24 | expect(container.firstChild).toMatchSnapshot(); 25 | }); 26 | 27 | it("renders a button to click", () => { 28 | const spy = jest.fn(); 29 | const actions = [{ text: "ContentPanelActions", buttonProps: { onClick: spy } }]; 30 | const { getByTestId } = render(); 31 | fireEvent.click(getByTestId("ContentPanelActionsButton")); 32 | expect(spy).toHaveBeenCalledTimes(1); 33 | }); 34 | 35 | it("passes rest of props to button", () => { 36 | const spy = jest.fn(); 37 | const actions = [{ text: "ContentPanelActions", buttonProps: { onClick: spy, disabled: true } }]; 38 | const { getByTestId } = render(); 39 | fireEvent.click(getByTestId("ContentPanelActionsButton")); 40 | expect(spy).toHaveBeenCalledTimes(0); 41 | expect(getByTestId("ContentPanelActionsButton")).toBeDisabled(); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /public/components/ContentPanel/ContentPanelActions.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { EuiButton, EuiFlexGroup, EuiFlexItem } from "@elastic/eui"; 18 | import { ModalConsumer } from "../Modal"; 19 | 20 | interface ContentPanelActionsProps { 21 | actions: { 22 | text: string; 23 | buttonProps?: object; 24 | flexItemProps?: object; 25 | modal?: { 26 | onClickModal: (onShow: (component: any, props: object) => void) => () => void; 27 | }; 28 | }[]; 29 | } 30 | 31 | const ContentPanelActions: React.SFC = ({ actions }) => ( 32 | 33 | {actions.map(({ text, buttonProps = {}, flexItemProps = {}, modal = null }, index) => { 34 | let button = ( 35 | 36 | {text} 37 | 38 | ); 39 | 40 | if (modal) { 41 | button = ( 42 | 43 | {({ onShow }) => ( 44 | 45 | {text} 46 | 47 | )} 48 | 49 | ); 50 | } 51 | 52 | return ( 53 | 54 | {button} 55 | 56 | ); 57 | })} 58 | 59 | ); 60 | 61 | export default ContentPanelActions; 62 | -------------------------------------------------------------------------------- /public/components/ContentPanel/__snapshots__/ContentPanel.test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[` spec renders the component 1`] = ` 4 |
8 |
12 |
15 |

18 | Testing 19 |

20 |
21 |
24 |
27 |
30 |
31 | one 32 |
33 |
34 |
37 |
38 | two 39 |
40 |
41 |
42 |
43 |
44 |
47 |
50 |
51 | Testing ContentPanel 52 |
53 |
54 |
55 | `; 56 | -------------------------------------------------------------------------------- /public/components/ContentPanel/__snapshots__/ContentPanelActions.test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[` spec renders the component 1`] = ` 4 |
7 |
10 | 25 |
26 |
27 | `; 28 | -------------------------------------------------------------------------------- /public/components/ContentPanel/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ContentPanel from "./ContentPanel"; 17 | import ContentPanelActions from "./ContentPanelActions"; 18 | 19 | export { ContentPanel, ContentPanelActions }; 20 | -------------------------------------------------------------------------------- /public/components/DarkMode/DarkMode.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { createContext } from "react"; 17 | 18 | const DarkModeContext = createContext({ isDarkMode: false }); 19 | 20 | const DarkModeConsumer = DarkModeContext.Consumer; 21 | 22 | export { DarkModeConsumer, DarkModeContext }; 23 | -------------------------------------------------------------------------------- /public/components/DarkMode/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | export { DarkModeConsumer, DarkModeContext } from "./DarkMode"; 17 | -------------------------------------------------------------------------------- /public/components/Modal/Modal.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React, { Component, createContext } from "react"; 17 | 18 | const ModalContext = createContext({ 19 | component: null, 20 | props: {}, 21 | onShow: (component: any, props: object) => {}, 22 | onClose: () => {}, 23 | }); 24 | 25 | const ModalConsumer = ModalContext.Consumer; 26 | 27 | class ModalProvider extends Component { 28 | state = { component: null, props: {} }; 29 | 30 | onShow = (component: any, props: object): void => { 31 | this.setState({ 32 | component, 33 | props, 34 | }); 35 | }; 36 | 37 | onClose = (): void => { 38 | this.setState({ 39 | component: null, 40 | props: {}, 41 | }); 42 | }; 43 | 44 | render() { 45 | return ( 46 | 47 | {this.props.children} 48 | 49 | ); 50 | } 51 | } 52 | 53 | export { ModalConsumer, ModalProvider }; 54 | -------------------------------------------------------------------------------- /public/components/Modal/ModalRoot.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React, { ComponentType } from "react"; 17 | import { BrowserServices } from "../../models/interfaces"; 18 | import { ModalConsumer } from "./Modal"; 19 | 20 | interface ModalRootProps { 21 | services: BrowserServices; 22 | } 23 | 24 | // All modals will have access to the BrowserServices if they need it 25 | const ModalRoot: React.SFC = ({ services }) => ( 26 | 27 | {({ 28 | component: Komponent, 29 | props, 30 | onClose, 31 | }: { 32 | component: ComponentType<{ onClose: () => void; services: BrowserServices }> | null; 33 | props: object; 34 | onClose: () => void; 35 | }) => (Komponent ? : null)} 36 | 37 | ); 38 | 39 | export default ModalRoot; 40 | -------------------------------------------------------------------------------- /public/components/Modal/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { ModalConsumer, ModalProvider } from "./Modal"; 17 | import ModalRoot from "./ModalRoot"; 18 | 19 | export { ModalConsumer, ModalProvider, ModalRoot }; 20 | -------------------------------------------------------------------------------- /public/components/PolicyModal/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import PolicyModal from "./PolicyModal"; 17 | 18 | export default PolicyModal; 19 | -------------------------------------------------------------------------------- /public/components/core_services.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { createContext } from "react"; 17 | import { CoreStart } from "kibana/public"; 18 | 19 | const CoreServicesContext = createContext(null); 20 | 21 | const CoreServicesConsumer = CoreServicesContext.Consumer; 22 | 23 | export { CoreServicesContext, CoreServicesConsumer }; 24 | -------------------------------------------------------------------------------- /public/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { PluginInitializerContext } from "kibana/public"; 17 | import { IndexManagementPlugin } from "./plugin"; 18 | 19 | export interface IndexManagementPluginSetup {} 20 | export interface IndexManagementPluginStart {} 21 | 22 | export function plugin(initializerContext: PluginInitializerContext) { 23 | return new IndexManagementPlugin(initializerContext); 24 | } 25 | -------------------------------------------------------------------------------- /public/index_management_app.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { CoreStart, AppMountParameters } from "kibana/public"; 17 | import React from "react"; 18 | import ReactDOM from "react-dom"; 19 | import { render, unmountComponentAtNode } from "react-dom"; 20 | import { HashRouter as Router, Route } from "react-router-dom"; 21 | import { IndexService, ManagedIndexService, PolicyService, RollupService, ServicesContext } from "./services"; 22 | import { DarkModeContext } from "./components/DarkMode"; 23 | import Main from "./pages/Main"; 24 | import { CoreServicesContext } from "./components/core_services"; 25 | 26 | export function renderApp(coreStart: CoreStart, params: AppMountParameters) { 27 | const http = coreStart.http; 28 | 29 | const indexService = new IndexService(http); 30 | const managedIndexService = new ManagedIndexService(http); 31 | const policyService = new PolicyService(http); 32 | const rollupService = new RollupService(http); 33 | const services = { indexService, managedIndexService, policyService, rollupService }; 34 | 35 | const isDarkMode = coreStart.uiSettings.get("theme:darkMode") || false; 36 | 37 | ReactDOM.render( 38 | 39 | ( 41 | 42 | 43 | 44 |
45 | 46 | 47 | 48 | )} 49 | /> 50 | , 51 | params.element 52 | ); 53 | return () => ReactDOM.unmountComponentAtNode(params.element); 54 | } 55 | -------------------------------------------------------------------------------- /public/models/interfaces.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { IndexService, ManagedIndexService, PolicyService, RollupService } from "../services"; 17 | 18 | export interface BrowserServices { 19 | indexService: IndexService; 20 | managedIndexService: ManagedIndexService; 21 | policyService: PolicyService; 22 | rollupService: RollupService; 23 | } 24 | -------------------------------------------------------------------------------- /public/pages/ChangePolicy/components/ChangeManagedIndices/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ChangeManagedIndices from "./ChangeManagedIndices"; 17 | 18 | export default ChangeManagedIndices; 19 | -------------------------------------------------------------------------------- /public/pages/ChangePolicy/components/NewPolicy/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import NewPolicy from "./NewPolicy"; 17 | 18 | export default NewPolicy; 19 | -------------------------------------------------------------------------------- /public/pages/ChangePolicy/containers/ChangePolicy/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ChangePolicy from "./ChangePolicy"; 17 | 18 | export default ChangePolicy; 19 | -------------------------------------------------------------------------------- /public/pages/ChangePolicy/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ChangePolicy from "./containers/ChangePolicy"; 17 | 18 | export default ChangePolicy; 19 | -------------------------------------------------------------------------------- /public/pages/ChangePolicy/models/interfaces.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { Policy } from "../../../../models/interfaces"; 17 | 18 | export interface PolicyOption { 19 | label: string; 20 | value: Policy; 21 | } 22 | -------------------------------------------------------------------------------- /public/pages/CreatePolicy/components/ConfigurePolicy/ConfigurePolicy.test.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { render } from "@testing-library/react"; 18 | import ConfigurePolicy from "./ConfigurePolicy"; 19 | 20 | describe(" spec", () => { 21 | it("renders the component", () => { 22 | const { container } = render( {}} />); 23 | expect(container.firstChild).toMatchSnapshot(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /public/pages/CreatePolicy/components/ConfigurePolicy/ConfigurePolicy.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React, { ChangeEvent } from "react"; 17 | import { EuiSpacer, EuiFormRow, EuiFieldText, EuiText } from "@elastic/eui"; 18 | import { ContentPanel } from "../../../../components/ContentPanel"; 19 | 20 | interface ConfigurePolicyProps { 21 | policyId: string; 22 | policyIdError: string; 23 | isEdit: boolean; 24 | onChange: (value: ChangeEvent) => void; 25 | } 26 | 27 | const ConfigurePolicy = ({ isEdit, policyId, policyIdError, onChange }: ConfigurePolicyProps) => ( 28 | 29 |
30 | 31 |

Policies let you automatically perform administrative operations on indices.

32 |
33 | 34 | 40 | 41 | 42 |
43 |
44 | ); 45 | 46 | // @ts-ignore 47 | export default ConfigurePolicy; 48 | -------------------------------------------------------------------------------- /public/pages/CreatePolicy/components/ConfigurePolicy/__snapshots__/ConfigurePolicy.test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[` spec renders the component 1`] = ` 4 |
8 |
12 |
15 |

18 | Name policy 19 |

20 |
21 |
22 |
25 |
28 |
31 |
34 |

35 | Policies let you automatically perform administrative operations on indices. 36 |

37 |
38 |
41 |
45 |
48 | 55 |
56 |
59 |
62 |
65 | 73 |
74 |
75 |
79 | Specify a unique ID that is easy to recognize and remember. 80 |
81 |
82 |
83 |
84 |
85 |
86 | `; 87 | -------------------------------------------------------------------------------- /public/pages/CreatePolicy/components/ConfigurePolicy/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ConfigurePolicy from "./ConfigurePolicy"; 17 | 18 | export default ConfigurePolicy; 19 | -------------------------------------------------------------------------------- /public/pages/CreatePolicy/components/DefinePolicy/DefinePolicy.test.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { render } from "@testing-library/react"; 18 | import DefinePolicy from "./DefinePolicy"; 19 | import { DEFAULT_POLICY } from "../../utils/constants"; 20 | 21 | describe(" spec", () => { 22 | it("renders the component", () => { 23 | const { container } = render( 24 | {}} onAutoIndent={() => {}} /> 25 | ); 26 | expect(container.firstChild).toMatchSnapshot(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /public/pages/CreatePolicy/components/DefinePolicy/__mocks__/DefinePolicyMock.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React, { ChangeEvent } from "react"; 17 | import { 18 | EuiSpacer, 19 | EuiButton, 20 | EuiTextArea, 21 | EuiText, 22 | // @ts-ignore 23 | EuiCopy, 24 | } from "@elastic/eui"; 25 | import { ContentPanel } from "../../../../../components/ContentPanel"; 26 | 27 | interface DefinePolicyProps { 28 | jsonString: string; 29 | hasJSONError: boolean; 30 | onChange: (value: string) => void; 31 | onAutoIndent: () => void; 32 | } 33 | 34 | /* 35 | * Attempting to test EuiCodeEditor which uses react-ace was a lot more effort than seemed worthwhile 36 | * at the moment, so in the meantime we will mock DefinePolicy as a EuiTextArea so that we can still test 37 | * the functionality of CreatePolicy (minus the JSON code editor). 38 | * */ 39 | const DefinePolicy = ({ jsonString, onChange, onAutoIndent, hasJSONError }: DefinePolicyProps) => ( 40 | 46 | {(copy: () => void) => ( 47 | 48 | Copy 49 | 50 | )} 51 | , 52 | 53 | Auto Indent 54 | , 55 | ]} 56 | > 57 |
58 | 59 |

Create a policy with a JSON configuration file. This can be added directly in the code editor below.

60 |
61 |
62 | 63 | ) => onChange(e.target.value)} aria-label="Code Editor" /> 64 |
65 | ); 66 | 67 | export default DefinePolicy; 68 | -------------------------------------------------------------------------------- /public/pages/CreatePolicy/components/DefinePolicy/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import DefinePolicy from "./DefinePolicy"; 17 | 18 | export default DefinePolicy; 19 | -------------------------------------------------------------------------------- /public/pages/CreatePolicy/containers/CreatePolicy/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import CreatePolicy from "./CreatePolicy"; 17 | 18 | export default CreatePolicy; 19 | -------------------------------------------------------------------------------- /public/pages/CreatePolicy/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import CreatePolicy from "./containers/CreatePolicy"; 17 | 18 | export default CreatePolicy; 19 | -------------------------------------------------------------------------------- /public/pages/CreatePolicy/utils/constants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | export const DEFAULT_POLICY = JSON.stringify( 17 | { 18 | policy: { 19 | description: "A simple default policy that changes the replica count between hot and cold states.", 20 | default_state: "hot", 21 | states: [ 22 | { 23 | name: "hot", 24 | actions: [{ replica_count: { number_of_replicas: 5 } }], 25 | transitions: [{ state_name: "cold", conditions: { min_index_age: "30d" } }], 26 | }, 27 | { 28 | name: "cold", 29 | actions: [{ replica_count: { number_of_replicas: 2 } }], 30 | transitions: [], 31 | }, 32 | ], 33 | }, 34 | }, 35 | null, 36 | 4 37 | ); 38 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/AdvancedAggregation/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import AdvancedAggregation from "./AdvancedAggregation"; 17 | 18 | export default AdvancedAggregation; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/ConfigureRollup/ConfigureRollup.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React, { ChangeEvent } from "react"; 17 | import { EuiSpacer, EuiFormRow, EuiFieldText, EuiTextArea, EuiText, EuiFlexGroup, EuiFlexItem } from "@elastic/eui"; 18 | import { ContentPanel } from "../../../../components/ContentPanel"; 19 | 20 | interface ConfigureRollupProps { 21 | isEdit: boolean; 22 | rollupId: string; 23 | rollupIdError: string; 24 | onChangeName: (value: ChangeEvent) => void; 25 | onChangeDescription: (value: ChangeEvent) => void; 26 | description: string; 27 | } 28 | 29 | const ConfigureRollup = ({ isEdit, rollupId, rollupIdError, onChangeName, onChangeDescription, description }: ConfigureRollupProps) => ( 30 | 31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |

Description

41 |
42 |
43 | 44 | 45 | - optional 46 | 47 | 48 |
49 | 50 | 51 | 52 | 53 |
54 |
55 | ); 56 | export default ConfigureRollup; 57 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/ConfigureRollup/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ConfigureRollup from "./ConfigureRollup"; 17 | 18 | export default ConfigureRollup; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/CreateRollupSteps/CreateRollupSteps.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | import React from "react"; 16 | import { EuiSteps } from "@elastic/eui"; 17 | 18 | interface CreateRollupStepsProps { 19 | step: number; 20 | } 21 | 22 | const setOfSteps = (step: number) => { 23 | return [ 24 | { 25 | title: "Set up indices", 26 | children: null, 27 | }, 28 | { 29 | title: "Define aggregations and metrics", 30 | children: null, 31 | status: step < 2 ? "disabled" : null, 32 | }, 33 | { 34 | title: "Specify schedule", 35 | children: null, 36 | status: step < 3 ? "disabled" : null, 37 | }, 38 | { 39 | title: "Review and create", 40 | children: null, 41 | status: step < 4 ? "disabled" : null, 42 | }, 43 | ]; 44 | }; 45 | const CreateRollupSteps = ({ step }: CreateRollupStepsProps) => ( 46 |
47 | 48 |
49 | ); 50 | 51 | export default CreateRollupSteps; 52 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/CreateRollupSteps/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import CreateRollupSteps from "./CreateRollupSteps"; 17 | 18 | export default CreateRollupSteps; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/HistogramAndMetrics/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import HistogramAndMetrics from "./HistogramAndMetrics"; 17 | 18 | export default HistogramAndMetrics; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/JobNameAndIndices/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import JobNameAndIndices from "./JobNameAndIndices"; 17 | 18 | export default JobNameAndIndices; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/MetricsCalculation/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import MetricsCalculation from "./MetricsCalculation"; 17 | 18 | export default MetricsCalculation; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/RollupIndices/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import RollupIndices from "./RollupIndices"; 17 | 18 | export default RollupIndices; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/Schedule/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import Schedule from "./Schedule"; 17 | 18 | export default Schedule; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/ScheduleRolesAndNotifications/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ScheduleRolesAndNotifications from "./ScheduleRolesAndNotifications"; 17 | 18 | export default ScheduleRolesAndNotifications; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/components/TimeAggregations/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import TimeAggregation from "./TimeAggregation"; 17 | 18 | export default TimeAggregation; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/containers/CreateRollup/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import CreateRollup from "./CreateRollup"; 17 | 18 | export default CreateRollup; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/containers/CreateRollupForm/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import CreateRollupForm from "./CreateRollupForm"; 17 | 18 | export default CreateRollupForm; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/containers/CreateRollupStep2/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import CreateRollupStep2 from "./CreateRollupStep2"; 17 | 18 | export default CreateRollupStep2; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/containers/CreateRollupStep3/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import CreateRollupStep3 from "./CreateRollupStep3"; 17 | 18 | export default CreateRollupStep3; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/containers/CreateRollupStep4/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import CreateRollupStep4 from "./CreateRollupStep4"; 17 | 18 | export default CreateRollupStep4; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import CreateRollup from "./containers/CreateRollup"; 17 | 18 | export default CreateRollup; 19 | -------------------------------------------------------------------------------- /public/pages/CreateRollup/utils/constants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | export const EMPTY_ROLLUP = JSON.stringify({ 17 | rollup: { 18 | continuous: false, 19 | description: "", 20 | dimensions: [ 21 | { 22 | date_histogram: { 23 | source_field: "", 24 | fixed_interval: "1h", 25 | timezone: "UTC", 26 | }, 27 | }, 28 | ], 29 | enabled: true, 30 | metrics: [], 31 | page_size: 1000, 32 | roles: [], 33 | schedule: { 34 | interval: { 35 | start_time: 234802, 36 | period: 1, 37 | unit: "MINUTES", 38 | }, 39 | }, 40 | source_index: "", 41 | target_index: "", 42 | }, 43 | }); 44 | 45 | export const FixedTimeunitOptions = [ 46 | { value: "ms", text: "Millisecond(s)" }, 47 | { value: "s", text: "Second(s)" }, 48 | { value: "m", text: "Minute(s)" }, 49 | { value: "h", text: "Hour(s)" }, 50 | { value: "d", text: "Day(s)" }, 51 | ]; 52 | 53 | export const DelayTimeunitOptions = [ 54 | { value: "SECONDS", text: "Second(s)" }, 55 | { value: "MINUTES", text: "Minute(s)" }, 56 | { value: "HOURS", text: "Hour(s)" }, 57 | { value: "DAYS", text: "Day(s)" }, 58 | ]; 59 | 60 | export const CalendarTimeunitOptions = [ 61 | { value: "m", text: "Minute" }, 62 | { value: "h", text: "Hour" }, 63 | { value: "d", text: "Day" }, 64 | { value: "w", text: "Week" }, 65 | { value: "M", text: "Month" }, 66 | { value: "q", text: "Quarter" }, 67 | { value: "y", text: "Year" }, 68 | ]; 69 | 70 | export const ScheduleIntervalTimeunitOptions = [ 71 | { value: "MINUTES", text: "Minute(s)" }, 72 | { value: "HOURS", text: "Hour(s)" }, 73 | { value: "DAYS", text: "Day(s)" }, 74 | ]; 75 | 76 | export const AddFieldsColumns = [ 77 | { 78 | field: "label", 79 | name: "Field name", 80 | sortable: true, 81 | }, 82 | { 83 | field: "type", 84 | name: "Field type", 85 | sortable: true, 86 | render: (type: string | undefined) => (type == null || type == undefined ? "-" : type), 87 | }, 88 | ]; 89 | -------------------------------------------------------------------------------- /public/pages/EditRollup/containers/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import EditRollup from "./EditRollup"; 17 | 18 | export default EditRollup; 19 | -------------------------------------------------------------------------------- /public/pages/EditRollup/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import EditRollup from "./containers/EditRollup"; 17 | 18 | export default EditRollup; 19 | -------------------------------------------------------------------------------- /public/pages/Indices/components/ApplyPolicyModal/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ApplyPolicyModal from "./ApplyPolicyModal"; 17 | 18 | export default ApplyPolicyModal; 19 | -------------------------------------------------------------------------------- /public/pages/Indices/components/IndexControls/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import IndexControls from "./IndexControls"; 17 | 18 | export default IndexControls; 19 | -------------------------------------------------------------------------------- /public/pages/Indices/components/IndexEmptyPrompt/IndexEmptyPrompt.test.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import "@testing-library/jest-dom/extend-expect"; 18 | import { render, fireEvent } from "@testing-library/react"; 19 | import IndexEmptyPrompt, { TEXT } from "./IndexEmptyPrompt"; 20 | 21 | describe(" spec", () => { 22 | it("renders the component", async () => { 23 | const { container } = render( {}} />); 24 | 25 | expect(container.firstChild).toMatchSnapshot(); 26 | }); 27 | 28 | it("renders no indices by default", async () => { 29 | const { getByText, queryByTestId } = render( {}} />); 30 | 31 | getByText(TEXT.NO_INDICES); 32 | expect(queryByTestId("indexEmptyPromptResetFilters")).toBeNull(); 33 | }); 34 | 35 | it("shows LOADING", async () => { 36 | const { getByText, queryByTestId } = render( {}} />); 37 | 38 | getByText(TEXT.LOADING); 39 | expect(queryByTestId("indexEmptyPromptResetFilters")).toBeNull(); 40 | }); 41 | 42 | it("shows reset filters", async () => { 43 | const resetFilters = jest.fn(); 44 | const { getByText, getByTestId } = render(); 45 | 46 | getByText(TEXT.RESET_FILTERS); 47 | fireEvent.click(getByTestId("indexEmptyPromptResetFilters")); 48 | expect(resetFilters).toHaveBeenCalledTimes(1); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /public/pages/Indices/components/IndexEmptyPrompt/IndexEmptyPrompt.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { EuiButton, EuiEmptyPrompt, EuiText } from "@elastic/eui"; 18 | 19 | export const TEXT = { 20 | RESET_FILTERS: "There are no indices matching your applied filters. Reset your filters to view your indices.", 21 | NO_INDICES: "There are no existing indices. Create an index to view it here.", 22 | LOADING: "Loading indices...", 23 | }; 24 | 25 | const getMessagePrompt = ({ filterIsApplied, loading }: IndexEmptyPromptProps): string => { 26 | if (loading) return TEXT.LOADING; 27 | if (filterIsApplied) return TEXT.RESET_FILTERS; 28 | return TEXT.NO_INDICES; 29 | }; 30 | 31 | const getActions: React.SFC = ({ filterIsApplied, loading, resetFilters }) => { 32 | if (loading) { 33 | return null; 34 | } 35 | 36 | if (filterIsApplied) { 37 | return ( 38 | 39 | Reset Filters 40 | 41 | ); 42 | } 43 | 44 | return null; 45 | }; 46 | 47 | interface IndexEmptyPromptProps { 48 | filterIsApplied: boolean; 49 | loading: boolean; 50 | resetFilters: () => void; 51 | } 52 | 53 | const IndexEmptyPrompt: React.SFC = props => ( 54 | 58 |

{getMessagePrompt(props)}

59 | 60 | } 61 | actions={getActions(props)} 62 | /> 63 | ); 64 | 65 | export default IndexEmptyPrompt; 66 | -------------------------------------------------------------------------------- /public/pages/Indices/components/IndexEmptyPrompt/__snapshots__/IndexEmptyPrompt.test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[` spec renders the component 1`] = ` 4 |
8 | 11 |
14 |
17 |

18 | There are no existing indices. Create an index to view it here. 19 |

20 |
21 |
22 |
23 |
24 | `; 25 | -------------------------------------------------------------------------------- /public/pages/Indices/components/IndexEmptyPrompt/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import IndexEmptyPrompt from "./IndexEmptyPrompt"; 17 | 18 | export default IndexEmptyPrompt; 19 | -------------------------------------------------------------------------------- /public/pages/Indices/containers/Indices/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import Indices from "./Indices"; 17 | 18 | export default Indices; 19 | -------------------------------------------------------------------------------- /public/pages/Indices/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import Indices from "./containers/Indices"; 17 | 18 | export default Indices; 19 | -------------------------------------------------------------------------------- /public/pages/Indices/models/interfaces.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { Direction } from "@elastic/eui"; 17 | import { Policy } from "../../../../models/interfaces"; 18 | import { ManagedCatIndex } from "../../../../server/models/interfaces"; 19 | 20 | export interface PolicyOption { 21 | label: string; 22 | policy?: Policy; 23 | } 24 | 25 | export interface IndicesQueryParams { 26 | from: number; 27 | size: number; 28 | search: string; 29 | sortField: keyof ManagedCatIndex; 30 | sortDirection: Direction; 31 | } 32 | -------------------------------------------------------------------------------- /public/pages/Indices/utils/helpers.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import queryString from "query-string"; 17 | import { DEFAULT_QUERY_PARAMS } from "./constants"; 18 | import { IndicesQueryParams } from "../models/interfaces"; 19 | 20 | export function getURLQueryParams(location: { search: string }): IndicesQueryParams { 21 | const { from, size, search, sortField, sortDirection } = queryString.parse(location.search); 22 | return { 23 | // @ts-ignore 24 | from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10), 25 | // @ts-ignore 26 | size: isNaN(parseInt(size, 10)) ? DEFAULT_QUERY_PARAMS.size : parseInt(size, 10), 27 | search: typeof search !== "string" ? DEFAULT_QUERY_PARAMS.search : search, 28 | sortField: typeof sortField !== "string" ? "index" : sortField, 29 | sortDirection: typeof sortDirection !== "string" ? DEFAULT_QUERY_PARAMS.sortDirection : sortDirection, 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /public/pages/Main/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import Main from "./Main"; 17 | 18 | export default Main; 19 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/InfoModal/InfoModal.test.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import "@testing-library/jest-dom/extend-expect"; 18 | import { render, fireEvent } from "@testing-library/react"; 19 | import InfoModal from "./InfoModal"; 20 | 21 | describe(" spec", () => { 22 | it("renders the component", () => { 23 | render( {}} />); 24 | // EuiOverlayMask appends an element to the body so we should have two, an empty div from react-test-library 25 | // and our EuiOverlayMask element 26 | expect(document.body.children).toHaveLength(2); 27 | expect(document.body.children[1]).toMatchSnapshot(); 28 | }); 29 | 30 | it("calls close when close button clicked", () => { 31 | const onClose = jest.fn(); 32 | const { getByTestId } = render(); 33 | 34 | fireEvent.click(getByTestId("infoModalCloseButton")); 35 | expect(onClose).toHaveBeenCalled(); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/InfoModal/InfoModal.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { 18 | EuiButton, 19 | EuiModal, 20 | EuiModalBody, 21 | EuiModalFooter, 22 | EuiModalHeader, 23 | EuiModalHeaderTitle, 24 | EuiOverlayMask, 25 | EuiCodeBlock, 26 | } from "@elastic/eui"; 27 | 28 | interface InfoModalProps { 29 | info: object; 30 | onClose: () => void; 31 | } 32 | 33 | const InfoModal = ({ info, onClose }: InfoModalProps) => ( 34 | 35 | {/* 36 | // @ts-ignore */} 37 | 38 | 39 | Managed Index Info 40 | 41 | 42 | 43 | 44 | {JSON.stringify(info, null, 4)} 45 | 46 | 47 | 48 | 49 | 50 | Close 51 | 52 | 53 | 54 | 55 | ); 56 | 57 | export default InfoModal; 58 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/InfoModal/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import InfoModal from "./InfoModal"; 17 | 18 | export default InfoModal; 19 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/ManagedIndexControls/ManagedIndexControls.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React, { ChangeEvent, Component } from "react"; 17 | import { EuiFieldSearch, EuiFlexGroup, EuiFlexItem, EuiPagination } from "@elastic/eui"; 18 | import EuiRefreshPicker from "../../../../temporary/EuiRefreshPicker"; 19 | 20 | interface ManagedIndexControlsProps { 21 | activePage: number; 22 | pageCount: number; 23 | search: string; 24 | onSearchChange: (e: ChangeEvent) => void; 25 | onPageClick: (page: number) => void; 26 | onRefresh: () => void; 27 | } 28 | 29 | export default class ManagedIndexControls extends Component { 30 | state = { 31 | refreshInterval: 0, 32 | isPaused: true, 33 | }; 34 | 35 | onRefreshChange = ({ refreshInterval, isPaused }: { refreshInterval: number; isPaused: boolean }) => { 36 | this.setState({ isPaused, refreshInterval }); 37 | }; 38 | 39 | render() { 40 | const { activePage, pageCount, search, onSearchChange, onPageClick, onRefresh } = this.props; 41 | const { refreshInterval, isPaused } = this.state; 42 | 43 | return ( 44 | 45 | 46 | 47 | 48 | 49 | 55 | 56 | {pageCount > 1 && ( 57 | 58 | 64 | 65 | )} 66 | 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/ManagedIndexControls/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ManagedIndexControls from "./ManagedIndexControls"; 17 | 18 | export default ManagedIndexControls; 19 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/ManagedIndexEmptyPrompt.test.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import "@testing-library/jest-dom/extend-expect"; 18 | import { render, fireEvent } from "@testing-library/react"; 19 | import ManagedIndexEmptyPrompt, { TEXT } from "./ManagedIndexEmptyPrompt"; 20 | 21 | describe(" spec", () => { 22 | it("renders the component", async () => { 23 | const { container } = render( {}} />); 24 | 25 | expect(container.firstChild).toMatchSnapshot(); 26 | }); 27 | 28 | it("renders no managed indices by default", async () => { 29 | const { getByText, queryByTestId } = render( 30 | {}} /> 31 | ); 32 | 33 | getByText(TEXT.NO_MANAGED_INDICES); 34 | expect(queryByTestId("managedIndexEmptyPromptResetFilters")).toBeNull(); 35 | }); 36 | 37 | it("shows LOADING", async () => { 38 | const { getByText, queryByTestId } = render( {}} />); 39 | 40 | getByText(TEXT.LOADING); 41 | expect(queryByTestId("managedIndexEmptyPromptResetFilters")).toBeNull(); 42 | }); 43 | 44 | it("shows reset filters", async () => { 45 | const resetFilters = jest.fn(); 46 | const { getByText, getByTestId } = render( 47 | 48 | ); 49 | 50 | getByText(TEXT.RESET_FILTERS); 51 | fireEvent.click(getByTestId("managedIndexEmptyPromptResetFilters")); 52 | expect(resetFilters).toHaveBeenCalledTimes(1); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/ManagedIndexEmptyPrompt.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { EuiButton, EuiEmptyPrompt, EuiText } from "@elastic/eui"; 18 | import { PLUGIN_NAME, ROUTES } from "../../../../utils/constants"; 19 | 20 | export const TEXT = { 21 | RESET_FILTERS: "There are no managed indices matching your applied filters. Reset your filters to view your managed indices.", 22 | NO_MANAGED_INDICES: "There are no existing managed indices. Create a policy to add to an index.", 23 | LOADING: "Loading managed indices...", 24 | }; 25 | 26 | const getMessagePrompt = ({ filterIsApplied, loading }: ManagedIndexEmptyPromptProps): string => { 27 | if (loading) return TEXT.LOADING; 28 | if (filterIsApplied) return TEXT.RESET_FILTERS; 29 | return TEXT.NO_MANAGED_INDICES; 30 | }; 31 | 32 | const getActions: React.SFC = ({ filterIsApplied, loading, resetFilters }) => { 33 | if (loading) return null; 34 | 35 | if (filterIsApplied) { 36 | return ( 37 | 38 | Reset Filters 39 | 40 | ); 41 | } 42 | 43 | return ( 44 | 45 | Create policy 46 | 47 | ); 48 | }; 49 | 50 | interface ManagedIndexEmptyPromptProps { 51 | filterIsApplied: boolean; 52 | loading: boolean; 53 | resetFilters: () => void; 54 | } 55 | 56 | const ManagedIndexEmptyPrompt: React.SFC = props => ( 57 | 61 |

{getMessagePrompt(props)}

62 | 63 | } 64 | actions={getActions(props)} 65 | /> 66 | ); 67 | 68 | export default ManagedIndexEmptyPrompt; 69 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/__snapshots__/ManagedIndexEmptyPrompt.test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[` spec renders the component 1`] = ` 4 |
8 | 11 |
14 |
17 |

18 | There are no existing managed indices. Create a policy to add to an index. 19 |

20 |
21 |
22 |
23 |
26 | 45 | `; 46 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/ManagedIndexEmptyPrompt/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ManagedIndexEmptyPrompt from "./ManagedIndexEmptyPrompt"; 17 | 18 | export default ManagedIndexEmptyPrompt; 19 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/RetryModal/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import RetryModal from "./RetryModal"; 17 | 18 | export default RetryModal; 19 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/components/RolloverAliasModal/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import RolloverAliasModal from "./RolloverAliasModal"; 17 | 18 | export default RolloverAliasModal; 19 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/containers/ManagedIndices/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ManagedIndices from "./ManagedIndices"; 17 | 18 | export default ManagedIndices; 19 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import ManagedIndices from "./containers/ManagedIndices"; 17 | 18 | export default ManagedIndices; 19 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/models/interfaces.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { Direction } from "@elastic/eui"; 17 | import { ManagedIndexItem } from "../../../../models/interfaces"; 18 | 19 | export interface ManagedIndicesQueryParams { 20 | from: number; 21 | size: number; 22 | search: string; 23 | sortField: keyof ManagedIndexItem; 24 | sortDirection: Direction; 25 | } 26 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/utils/constants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { ManagedIndicesQueryParams } from "../models/interfaces"; 17 | 18 | export const DEFAULT_PAGE_SIZE_OPTIONS = [5, 10, 20, 50]; 19 | export const DEFAULT_QUERY_PARAMS: ManagedIndicesQueryParams = { 20 | from: 0, 21 | size: 20, 22 | search: "", 23 | sortField: "index", 24 | sortDirection: "desc", 25 | }; 26 | -------------------------------------------------------------------------------- /public/pages/ManagedIndices/utils/helpers.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import queryString from "query-string"; 17 | import { DEFAULT_QUERY_PARAMS } from "./constants"; 18 | import { ManagedIndicesQueryParams } from "../models/interfaces"; 19 | 20 | export function getURLQueryParams(location: { search: string }): ManagedIndicesQueryParams { 21 | const { from, size, search, sortField, sortDirection } = queryString.parse(location.search); 22 | 23 | return { 24 | // @ts-ignore 25 | from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10), 26 | // @ts-ignore 27 | size: isNaN(parseInt(size, 10)) ? DEFAULT_QUERY_PARAMS.size : parseInt(size, 10), 28 | search: typeof search !== "string" ? DEFAULT_QUERY_PARAMS.search : search, 29 | sortField: typeof sortField !== "string" ? DEFAULT_QUERY_PARAMS.sortField : sortField, 30 | sortDirection: typeof sortDirection !== "string" ? DEFAULT_QUERY_PARAMS.sortDirection : sortDirection, 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /public/pages/Policies/components/PolicyControls/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import PolicyControls from "./PolicyControls"; 17 | 18 | export default PolicyControls; 19 | -------------------------------------------------------------------------------- /public/pages/Policies/components/PolicyEmptyPrompt/PolicyEmptyPrompt.test.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import "@testing-library/jest-dom/extend-expect"; 18 | import { render, fireEvent } from "@testing-library/react"; 19 | import PolicyEmptyPrompt, { TEXT } from "./PolicyEmptyPrompt"; 20 | 21 | describe(" spec", () => { 22 | it("renders the component", async () => { 23 | const { container } = render( {}} />); 24 | 25 | expect(container.firstChild).toMatchSnapshot(); 26 | }); 27 | 28 | it("renders no indices by default", async () => { 29 | const { getByText, queryByTestId } = render( {}} />); 30 | 31 | getByText(TEXT.NO_POLICIES); 32 | expect(queryByTestId("policyEmptyPromptRestFilters")).toBeNull(); 33 | }); 34 | 35 | it("shows LOADING", async () => { 36 | const { getByText, queryByTestId } = render( {}} />); 37 | 38 | getByText(TEXT.LOADING); 39 | expect(queryByTestId("policyEmptyPromptRestFilters")).toBeNull(); 40 | }); 41 | 42 | it("shows reset filters", async () => { 43 | const resetFilters = jest.fn(); 44 | const { getByText, getByTestId } = render(); 45 | 46 | getByText(TEXT.RESET_FILTERS); 47 | fireEvent.click(getByTestId("policyEmptyPromptRestFilters")); 48 | expect(resetFilters).toHaveBeenCalledTimes(1); 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /public/pages/Policies/components/PolicyEmptyPrompt/PolicyEmptyPrompt.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { EuiButton, EuiEmptyPrompt, EuiText } from "@elastic/eui"; 18 | import { PLUGIN_NAME, ROUTES } from "../../../../utils/constants"; 19 | 20 | export const TEXT = { 21 | RESET_FILTERS: "There are no policies matching your applied filters. Reset your filters to view your policies.", 22 | NO_POLICIES: "There are no existing policies. Create a policy to apply to your indices.", 23 | LOADING: "Loading policies...", 24 | }; 25 | 26 | const getMessagePrompt = ({ filterIsApplied, loading }: PolicyEmptyPromptProps) => { 27 | if (loading) return TEXT.LOADING; 28 | if (filterIsApplied) return TEXT.RESET_FILTERS; 29 | return TEXT.NO_POLICIES; 30 | }; 31 | 32 | const getActions: React.SFC = ({ filterIsApplied, loading, resetFilters }) => { 33 | if (loading) { 34 | return null; 35 | } 36 | if (filterIsApplied) { 37 | return ( 38 | 39 | Reset Filters 40 | 41 | ); 42 | } 43 | 44 | return ( 45 | 46 | Create policy 47 | 48 | ); 49 | }; 50 | 51 | interface PolicyEmptyPromptProps { 52 | filterIsApplied: boolean; 53 | loading: boolean; 54 | resetFilters: () => void; 55 | } 56 | 57 | const PolicyEmptyPrompt: React.SFC = props => ( 58 | 62 |

{getMessagePrompt(props)}

63 | 64 | } 65 | actions={getActions(props)} 66 | /> 67 | ); 68 | 69 | export default PolicyEmptyPrompt; 70 | -------------------------------------------------------------------------------- /public/pages/Policies/components/PolicyEmptyPrompt/__snapshots__/PolicyEmptyPrompt.test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[` spec renders the component 1`] = ` 4 |
8 | 11 |
14 |
17 |

18 | There are no existing policies. Create a policy to apply to your indices. 19 |

20 |
21 |
22 |
23 |
26 | 45 | `; 46 | -------------------------------------------------------------------------------- /public/pages/Policies/components/PolicyEmptyPrompt/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import PolicyEmptyPrompt from "./PolicyEmptyPrompt"; 17 | 18 | export default PolicyEmptyPrompt; 19 | -------------------------------------------------------------------------------- /public/pages/Policies/containers/Policies/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import Policies from "./Policies"; 17 | 18 | export default Policies; 19 | -------------------------------------------------------------------------------- /public/pages/Policies/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import Policies from "./containers/Policies"; 17 | 18 | export default Policies; 19 | -------------------------------------------------------------------------------- /public/pages/Policies/models/interfaces.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { Direction } from "@elastic/eui"; 17 | 18 | export interface PolicyItem { 19 | id: string; 20 | seqNo: number; 21 | primaryTerm: number; 22 | policy: object; // only dumped to view as JSON as of now, don't need to type 23 | } 24 | 25 | export interface PoliciesQueryParams { 26 | from: number; 27 | size: number; 28 | search: string; 29 | sortField: keyof PolicyItem; 30 | sortDirection: Direction; 31 | } 32 | -------------------------------------------------------------------------------- /public/pages/Policies/utils/constants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { PoliciesQueryParams } from "../models/interfaces"; 17 | import { SortDirection } from "../../../utils/constants"; 18 | 19 | export const DEFAULT_PAGE_SIZE_OPTIONS = [5, 10, 20, 50]; 20 | export const DEFAULT_QUERY_PARAMS: PoliciesQueryParams = { 21 | from: 0, 22 | size: 20, 23 | search: "", 24 | sortField: "id", 25 | sortDirection: SortDirection.DESC, 26 | }; 27 | -------------------------------------------------------------------------------- /public/pages/Policies/utils/helpers.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import queryString from "query-string"; 17 | // @ts-ignore 18 | import moment from "moment"; 19 | import { DEFAULT_QUERY_PARAMS } from "./constants"; 20 | import { PoliciesQueryParams } from "../models/interfaces"; 21 | 22 | export function getURLQueryParams(location: { search: string }): PoliciesQueryParams { 23 | const { from, size, search, sortField, sortDirection } = queryString.parse(location.search); 24 | 25 | return { 26 | // @ts-ignore 27 | from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10), 28 | // @ts-ignore 29 | size: isNaN(parseInt(size, 10)) ? DEFAULT_QUERY_PARAMS.size : parseInt(size, 10), 30 | search: typeof search !== "string" ? DEFAULT_QUERY_PARAMS.search : search, 31 | sortField: typeof sortField !== "string" ? DEFAULT_QUERY_PARAMS.sortField : sortField, 32 | sortDirection: typeof sortDirection !== "string" ? DEFAULT_QUERY_PARAMS.sortDirection : sortDirection, 33 | }; 34 | } 35 | 36 | export const renderTime = (time: number): string => { 37 | const momentTime = moment(time).local(); 38 | if (time && momentTime.isValid()) return momentTime.format("MM/DD/YY h:mm a"); 39 | return "-"; 40 | }; 41 | -------------------------------------------------------------------------------- /public/pages/RollupDetails/components/AggregationAndMetricsSettings/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import AggregationAndMetricsSettings from "./containers/AggregationAndMetricsSettings"; 17 | 18 | export default AggregationAndMetricsSettings; 19 | -------------------------------------------------------------------------------- /public/pages/RollupDetails/components/GeneralInformation/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import GeneralInformation from "./GeneralInformation"; 17 | 18 | export default GeneralInformation; 19 | -------------------------------------------------------------------------------- /public/pages/RollupDetails/components/RollupStatus/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import RollupStatus from "./RollupStatus"; 17 | 18 | export default RollupStatus; 19 | -------------------------------------------------------------------------------- /public/pages/RollupDetails/containers/RollupDetails/__snapshots__/RollupDetails.test.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[` spec renders the component 1`] = ` 4 |
5 | Testing rollup landing page 6 |
7 | `; 8 | -------------------------------------------------------------------------------- /public/pages/RollupDetails/containers/RollupDetails/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import RollupDetails from "./RollupDetails"; 17 | 18 | export default RollupDetails; 19 | -------------------------------------------------------------------------------- /public/pages/RollupDetails/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import RollupDetails from "./containers/RollupDetails"; 17 | 18 | export default RollupDetails; 19 | -------------------------------------------------------------------------------- /public/pages/Rollups/components/DeleteModal/DeleteModal.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React, { ChangeEvent, Component, Fragment } from "react"; 17 | import { EuiConfirmModal, EuiForm, EuiFormRow, EuiFieldText, EuiOverlayMask, EuiSpacer } from "@elastic/eui"; 18 | 19 | interface DeleteModalProps { 20 | rollupId: string; 21 | closeDeleteModal: (event?: any) => void; 22 | onClickDelete: (event?: any) => void; 23 | } 24 | 25 | interface DeleteModalState { 26 | confirmDeleteText: string; 27 | } 28 | 29 | export default class DeleteModal extends Component { 30 | state = { confirmDeleteText: "" }; 31 | 32 | onChange = (e: ChangeEvent): void => { 33 | this.setState({ confirmDeleteText: e.target.value }); 34 | }; 35 | 36 | render() { 37 | const { rollupId, closeDeleteModal, onClickDelete } = this.props; 38 | const { confirmDeleteText } = this.state; 39 | 40 | return ( 41 | 42 | 52 | 53 | 54 | By deleting "{rollupId}", all future scheduled rollup execution will be canceled. However, your target index 55 | will remain as it is. 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /public/pages/Rollups/components/DeleteModal/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import DeleteModal from "./DeleteModal"; 17 | 18 | export default DeleteModal; 19 | -------------------------------------------------------------------------------- /public/pages/Rollups/components/RollupEmptyPrompt/RollupEmptyPrompt.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import { EuiButton, EuiEmptyPrompt, EuiText } from "@elastic/eui"; 18 | import { PLUGIN_NAME, ROUTES } from "../../../../utils/constants"; 19 | 20 | export const TEXT = { 21 | RESET_FILTERS: "There are no rollup jobs matching your applied filters. Reset your filters to view your rollup jobs.", 22 | NO_ROLLUPS: 23 | "Rollup jobs help you conserve storage space for historical time series data while preserving the specific information you need.", 24 | LOADING: "Loading rollup jobs...", 25 | }; 26 | 27 | const getMessagePrompt = ({ filterIsApplied, loading }: RollupEmptyPromptProps) => { 28 | if (loading) return TEXT.LOADING; 29 | if (filterIsApplied) return TEXT.RESET_FILTERS; 30 | return TEXT.NO_ROLLUPS; 31 | }; 32 | 33 | const getActions: React.SFC = ({ filterIsApplied, loading, resetFilters }) => { 34 | if (loading) { 35 | return null; 36 | } 37 | if (filterIsApplied) { 38 | return ( 39 | 40 | Reset Filters 41 | 42 | ); 43 | } 44 | 45 | return ( 46 | 47 | Create rollup 48 | 49 | ); 50 | }; 51 | 52 | interface RollupEmptyPromptProps { 53 | filterIsApplied: boolean; 54 | loading: boolean; 55 | resetFilters: () => void; 56 | } 57 | 58 | const RollupEmptyPrompt: React.SFC = (props) => ( 59 | 63 |

{getMessagePrompt(props)}

64 | 65 | } 66 | actions={getActions(props)} 67 | /> 68 | ); 69 | 70 | export default RollupEmptyPrompt; 71 | -------------------------------------------------------------------------------- /public/pages/Rollups/components/RollupEmptyPrompt/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import RollupEmptyPrompt from "./RollupEmptyPrompt"; 17 | 18 | export default RollupEmptyPrompt; 19 | -------------------------------------------------------------------------------- /public/pages/Rollups/containers/Rollups/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import Rollups from "./Rollups"; 17 | 18 | export default Rollups; 19 | -------------------------------------------------------------------------------- /public/pages/Rollups/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import Rollups from "./containers/Rollups"; 17 | 18 | export default Rollups; 19 | -------------------------------------------------------------------------------- /public/pages/Rollups/models/interfaces.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { Direction } from "@elastic/eui"; 17 | import { DocumentRollup } from "../../../../models/interfaces"; 18 | 19 | export interface RollupQueryParams { 20 | from: number; 21 | size: number; 22 | search: string; 23 | sortField: keyof DocumentRollup; 24 | sortDirection: Direction; 25 | } 26 | -------------------------------------------------------------------------------- /public/pages/Rollups/utils/constants.tsx: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { SortDirection } from "../../../utils/constants"; 17 | 18 | export const DEFAULT_PAGE_SIZE_OPTIONS = [5, 10, 20, 50]; 19 | 20 | export const DEFAULT_QUERY_PARAMS = { 21 | from: 0, 22 | size: 20, 23 | search: "", 24 | sortField: "_id", 25 | sortDirection: SortDirection.DESC, 26 | }; 27 | -------------------------------------------------------------------------------- /public/pages/Rollups/utils/helpers.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import queryString from "query-string"; 17 | // @ts-ignore 18 | import moment from "moment"; 19 | import { DEFAULT_QUERY_PARAMS } from "./constants"; 20 | import { RollupQueryParams } from "../models/interfaces"; 21 | 22 | export function getURLQueryParams(location: { search: string }): RollupQueryParams { 23 | const { from, size, search, sortField, sortDirection } = queryString.parse(location.search); 24 | 25 | return { 26 | // @ts-ignores 27 | from: isNaN(parseInt(from, 10)) ? DEFAULT_QUERY_PARAMS.from : parseInt(from, 10), 28 | // @ts-ignore 29 | size: isNaN(parseInt(size, 10)) ? DEFAULT_QUERY_PARAMS.size : parseInt(size, 10), 30 | search: typeof search !== "string" ? DEFAULT_QUERY_PARAMS.search : search, 31 | sortField: typeof sortField !== "string" ? DEFAULT_QUERY_PARAMS.sortField : sortField, 32 | sortDirection: typeof sortDirection !== "string" ? DEFAULT_QUERY_PARAMS.sortDirection : sortDirection, 33 | }; 34 | } 35 | 36 | export const renderTime = (time: number): string => { 37 | const momentTime = moment(time).local(); 38 | if (time && momentTime.isValid()) return momentTime.format("MM/DD/YY h:mm a"); 39 | return "-"; 40 | }; 41 | 42 | export const renderEnabled = (isEnabled: boolean): string => { 43 | return isEnabled ? "Enabled" : "Disabled"; 44 | }; 45 | 46 | export const renderContinuous = (continuous: boolean): string => { 47 | return continuous ? "Yes" : "No"; 48 | }; 49 | -------------------------------------------------------------------------------- /public/plugin.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { AppMountParameters, CoreSetup, CoreStart, Plugin, PluginInitializerContext } from "../../../src/core/public"; 17 | import { IndexManagementPluginSetup } from "."; 18 | import { IndexManagementPluginStart } from "."; 19 | 20 | export class IndexManagementPlugin implements Plugin { 21 | constructor(private readonly initializerContext: PluginInitializerContext) { 22 | // can retrieve config from initializerContext 23 | } 24 | 25 | public setup(core: CoreSetup): IndexManagementPluginSetup { 26 | core.application.register({ 27 | id: "opendistro_index_management_kibana", 28 | title: "Index Management", 29 | order: 7000, 30 | category: { 31 | id: "odfe", 32 | label: "Open Distro for Elasticsearch", 33 | order: 2000, 34 | }, 35 | mount: async (params: AppMountParameters) => { 36 | const { renderApp } = await import("./index_management_app"); 37 | const [coreStart, depsStart] = await core.getStartServices(); 38 | return renderApp(coreStart, params); 39 | }, 40 | }); 41 | return {}; 42 | } 43 | 44 | public start(core: CoreStart): IndexManagementPluginStart { 45 | return {}; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /public/services/IndexService.test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { httpClientMock } from "../../test/mocks"; 17 | import IndexService from "./IndexService"; 18 | import { NODE_API } from "../../utils/constants"; 19 | 20 | const indexService = new IndexService(httpClientMock); 21 | 22 | describe("IndexService spec", () => { 23 | it("calls get indices nodejs route when calling getIndices", async () => { 24 | httpClientMock.get = jest.fn().mockResolvedValue({ data: {} }); 25 | const queryObject = {}; 26 | await indexService.getIndices(queryObject); 27 | 28 | expect(httpClientMock.get).toHaveBeenCalledTimes(1); 29 | expect(httpClientMock.get).toHaveBeenCalledWith(`..${NODE_API._INDICES}`, { query: queryObject }); 30 | }); 31 | 32 | it("calls apply policy nodejs route when calling applyPolicy", async () => { 33 | httpClientMock.post = jest.fn().mockResolvedValue({ data: {} }); 34 | const indices = ["one", "two"]; 35 | const policyId = "test"; 36 | await indexService.applyPolicy(indices, policyId); 37 | 38 | expect(httpClientMock.post).toHaveBeenCalledTimes(1); 39 | expect(httpClientMock.post).toHaveBeenCalledWith(`..${NODE_API.APPLY_POLICY}`, { body: JSON.stringify({ indices, policyId }) }); 40 | }); 41 | 42 | it("calls search nodejs route when calling searchPolicies", async () => { 43 | httpClientMock.post = jest.fn().mockResolvedValue({ data: {} }); 44 | const searchValue = "test"; 45 | await indexService.searchPolicies(searchValue); 46 | 47 | expect(httpClientMock.get).toHaveBeenCalledTimes(1); 48 | }); 49 | }); 50 | -------------------------------------------------------------------------------- /public/services/PolicyService.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { HttpSetup } from "kibana/public"; 17 | import { GetPoliciesResponse, PutPolicyResponse } from "../../server/models/interfaces"; 18 | import { ServerResponse } from "../../server/models/types"; 19 | import { NODE_API } from "../../utils/constants"; 20 | import { DocumentPolicy, Policy } from "../../models/interfaces"; 21 | 22 | export default class PolicyService { 23 | httpClient: HttpSetup; 24 | 25 | constructor(httpClient: HttpSetup) { 26 | this.httpClient = httpClient; 27 | } 28 | 29 | getPolicies = async (queryObject: object): Promise> => { 30 | let url = `..${NODE_API.POLICIES}`; 31 | const response = (await this.httpClient.get(url, { query: queryObject })) as ServerResponse; 32 | return response; 33 | }; 34 | 35 | putPolicy = async ( 36 | policy: Policy, 37 | policyId: string, 38 | seqNo?: number, 39 | primaryTerm?: number 40 | ): Promise> => { 41 | let url = `..${NODE_API.POLICIES}/${policyId}`; 42 | const response = (await this.httpClient.put(url, { query: { seqNo, primaryTerm }, body: JSON.stringify(policy) })) as ServerResponse< 43 | PutPolicyResponse 44 | >; 45 | return response; 46 | }; 47 | 48 | getPolicy = async (policyId: string): Promise> => { 49 | const url = `..${NODE_API.POLICIES}/${policyId}`; 50 | const response = (await this.httpClient.get(url)) as ServerResponse; 51 | return response; 52 | }; 53 | 54 | deletePolicy = async (policyId: string): Promise> => { 55 | const url = `..${NODE_API.POLICIES}/${policyId}`; 56 | const response = (await this.httpClient.delete(url)) as ServerResponse; 57 | return response; 58 | }; 59 | } 60 | -------------------------------------------------------------------------------- /public/services/Services.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { createContext } from "react"; 17 | import { BrowserServices } from "../models/interfaces"; 18 | 19 | const ServicesContext = createContext(null); 20 | 21 | const ServicesConsumer = ServicesContext.Consumer; 22 | 23 | export { ServicesContext, ServicesConsumer }; 24 | -------------------------------------------------------------------------------- /public/services/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { ServicesConsumer, ServicesContext } from "./Services"; 17 | import IndexService from "./IndexService"; 18 | import ManagedIndexService from "./ManagedIndexService"; 19 | import PolicyService from "./PolicyService"; 20 | import RollupService from "./RollupService"; 21 | 22 | export { ServicesConsumer, ServicesContext, IndexService, ManagedIndexService, PolicyService, RollupService }; 23 | -------------------------------------------------------------------------------- /public/temporary/AsyncInterval.ts: -------------------------------------------------------------------------------- 1 | // Code from https://github.com/elastic/eui 2 | // Used under the Apache-2.0 license. 3 | 4 | // This is from EUI library, but cannot be used until we are at 7.2+ 5 | // This is a temporary import for 7.0 and 7.1 6 | export default class AsyncInterval { 7 | timeoutId: number | undefined; 8 | isStopped: boolean = false; 9 | __pendingFn: Function | undefined; 10 | 11 | constructor(fn: Function, refreshInterval: number) { 12 | this.setAsyncInterval(fn, refreshInterval); 13 | } 14 | 15 | setAsyncInterval = (fn: Function, ms: number) => { 16 | if (!this.isStopped) { 17 | this.timeoutId = window.setTimeout(async () => { 18 | if (document.visibilityState === "visible") { 19 | this.__pendingFn = await fn(); 20 | } 21 | this.setAsyncInterval(fn, ms); 22 | }, ms); 23 | } 24 | }; 25 | 26 | stop = () => { 27 | this.isStopped = true; 28 | window.clearTimeout(this.timeoutId); 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /public/temporary/EuiRefreshPicker.tsx: -------------------------------------------------------------------------------- 1 | // Code from https://github.com/elastic/eui 2 | // Used under the Apache-2.0 license. 3 | 4 | import React, { Component } from "react"; 5 | import { EuiSuperDatePicker } from "@elastic/eui"; 6 | import AsyncInterval from "./AsyncInterval"; 7 | 8 | interface EuiRefreshPickerProps { 9 | isPaused: boolean; 10 | refreshInterval: number; 11 | onRefresh: Function; 12 | onRefreshChange: Function; 13 | } 14 | 15 | // Some of this code is from EUI library, but cannot be used until we are at 7.2+ 16 | // This is a temporary import for 7.0 and 7.1 17 | export default class EuiRefreshPicker extends Component { 18 | asyncInterval: AsyncInterval | undefined; 19 | 20 | componentDidMount = () => { 21 | if (!this.props.isPaused) { 22 | this.startInterval(this.props.refreshInterval); 23 | } 24 | }; 25 | 26 | componentWillUnmount = () => { 27 | this.stopInterval(); 28 | }; 29 | 30 | onRefreshChange = ({ refreshInterval, isPaused }: { refreshInterval: number; isPaused: boolean }) => { 31 | this.stopInterval(); 32 | if (!isPaused) { 33 | this.startInterval(refreshInterval); 34 | } 35 | if (this.props.onRefreshChange) { 36 | this.props.onRefreshChange({ refreshInterval, isPaused }); 37 | } 38 | }; 39 | 40 | stopInterval = () => { 41 | if (this.asyncInterval) { 42 | this.asyncInterval.stop(); 43 | } 44 | }; 45 | 46 | startInterval = (refreshInterval: number) => { 47 | const { onRefresh } = this.props; 48 | if (onRefresh) { 49 | const handler = () => { 50 | onRefresh({ refreshInterval }); 51 | }; 52 | this.asyncInterval = new AsyncInterval(handler, refreshInterval); 53 | } 54 | }; 55 | 56 | // Current version of EuiSuperDatePicker requires onTimeChange even if we don't use it 57 | onTimeChange = () => {}; 58 | 59 | render() { 60 | return ( 61 | 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /public/utils/constants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | export const PLUGIN_NAME = "opendistro_index_management_kibana"; 17 | 18 | export const DEFAULT_EMPTY_DATA = "-"; 19 | 20 | export const DOCUMENTATION_URL = "https://opendistro.github.io/for-elasticsearch-docs/docs/ism/"; 21 | 22 | export const ROUTES = Object.freeze({ 23 | CHANGE_POLICY: "/change-policy", 24 | CREATE_POLICY: "/create-policy", 25 | EDIT_POLICY: "/edit-policy", 26 | MANAGED_INDICES: "/managed-indices", 27 | INDEX_POLICIES: "/index-policies", 28 | INDICES: "/indices", 29 | ROLLUPS: "/rollups", 30 | CREATE_ROLLUP: "/create-rollup", 31 | EDIT_ROLLUP: "/edit-rollup", 32 | ROLLUP_DETAILS: "/rollup-details", 33 | }); 34 | 35 | export const BREADCRUMBS = Object.freeze({ 36 | INDEX_MANAGEMENT: { text: "Index Management", href: "#/" }, 37 | INDICES: { text: "Indices", href: `#${ROUTES.INDICES}` }, 38 | INDEX_POLICIES: { text: "Index policies", href: `#${ROUTES.INDEX_POLICIES}` }, 39 | MANAGED_INDICES: { text: "Managed indices", href: `#${ROUTES.MANAGED_INDICES}` }, 40 | EDIT_POLICY: { text: "Edit policy" }, 41 | CREATE_POLICY: { text: "Create policy" }, 42 | CHANGE_POLICY: { text: "Change policy" }, 43 | ROLLUPS: { text: "Rollup jobs", href: `#${ROUTES.ROLLUPS}` }, 44 | CREATE_ROLLUP: { text: "Create rollup job" }, 45 | EDIT_ROLLUP: { text: "Edit rollup job" }, 46 | ROLLUP_DETAILS: { text: "Rollup details" }, 47 | }); 48 | 49 | // TODO: Kibana EUI has a SortDirection already 50 | export enum SortDirection { 51 | ASC = "asc", 52 | DESC = "desc", 53 | } 54 | -------------------------------------------------------------------------------- /public/utils/helpers.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | export function getErrorMessage(err: any, defaultMessage: string) { 17 | if (err && err.message) return err.message; 18 | return defaultMessage; 19 | } 20 | -------------------------------------------------------------------------------- /release-notes/create-release-notes.py: -------------------------------------------------------------------------------- 1 | # raw note for file_path means to copy down draft release content generated by Github workflow 2 | # this script helps add the URLs to all PR and have the right release note filename 3 | # run by `python create-release-notes.py`, then input date, file_path ... as requested 4 | 5 | import os 6 | import sys 7 | import fileinput 8 | import re 9 | 10 | link_prefix = "https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/" 11 | searchExp = re.compile("([\(\[]).*?([\)\]])") 12 | 13 | current_date = raw_input("what day is today (e.g. 2020-06-29): ") 14 | file_path = raw_input("Path to raw note file (e.g., note.md): ") 15 | plugin_name = "index-management-kibana-plugin" 16 | plugin_version = raw_input('Plugin version (x.x.x.x): ') 17 | 18 | app_num = int( 19 | raw_input('Elasticsearch plugin (enter 1) or Kibana plugin (enter 2)? ')) 20 | app = 'Elasticsearch' 21 | if app_num is 2: 22 | app = 'Kibana' 23 | 24 | app_version = raw_input(app + ' compatibility version (x.x.x): ') 25 | 26 | for line in fileinput.input(file_path, inplace=True): 27 | # Add title and ES/Kibana compatibility 28 | if fileinput.isfirstline(): 29 | line = "## Version " + plugin_version + " " + current_date + "\n\n" \ 30 | "Compatible with " + app + " " + app_version + "\n" 31 | 32 | # Add link to PRs 33 | if '*' in line: 34 | start = line.find('#') + 1 35 | end = line.find(')', start) 36 | pr_num = line[start:end] 37 | line = re.sub(searchExp, "([#" + pr_num + 38 | "](" + link_prefix + pr_num + "))", line) 39 | sys.stdout.write(line) 40 | 41 | # Rename file to be consistent with ODFE standards 42 | new_file_path = "opendistro-for-elasticsearch-" + plugin_name + ".release-notes-" + \ 43 | plugin_version + ".md" 44 | os.rename(file_path, new_file_path) 45 | 46 | print('\n\nDone!\n') 47 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.10.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.10.0.0 (2020-8-18) 2 | 3 | Compatible with Kibana 7.9. 4 | 5 | ### Bug Fixes 6 | * Fixes missing actions on table, unused query parameter ?, and some ae… ([#103](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/103)) 7 | * add brace dep for binary kibana not starting problem ([#96](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/96)) 8 | 9 | ### Infrastructure 10 | * Adds cypress e2e tests and github action cypress workflow ([#80](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/80)) 11 | 12 | ### Maintenance 13 | * Adds support for Kibana 7.9 ([#118](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/118)) 14 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.10.1.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.10.1.0 (2020-9-8) 2 | 3 | Compatible with Kibana 7.9.1. 4 | 5 | ### Maintenance 6 | * Adds support for Kibana 7.9.1 ([#120](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/120)) 7 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.11.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.11.0.0 (2020-10-19) 2 | 3 | Compatible with Kibana 7.9.1. 4 | 5 | ### Maintenance 6 | * changes for kibana side menu ([#131](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/131)) 7 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.12.0.0.md: -------------------------------------------------------------------------------- 1 | 2 | ## Version 1.12.0.0, 2020-12-02 3 | 4 | Compatible with Kibana 7.10.0 5 | 6 | ### Features 7 | 8 | * Rollup Kibana ([#128](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/128)) 9 | 10 | ### Enhancements 11 | 12 | * change position of index-management in kibana side bar ([#140](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/140)) 13 | * Kibana migration ([#142](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/142)) 14 | 15 | ### Bug Fixes 16 | 17 | * Bug fix for duplicate dimension/metrics items and deletion error ([#145](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/145)) 18 | 19 | ### Infrastructure 20 | 21 | * Updates to github action workflows and some bug fix after upgrading to Kibana 7.10 ([#139](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/139)) 22 | 23 | ### Maintainence 24 | 25 | * Combine getRollup with getExplain API in backend and other code fix ([#141](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/141)) 26 | * Add support for Kibana 7.10.0 ([#144](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/144)) 27 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.13.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.13.0.0 2021-02-04 2 | 3 | Compatible with Kibana 7.10.2 4 | ### Bug Fixes 5 | 6 | * Bug fix: getRollups API, rollup jobs landing page ([#154](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/154)) 7 | 8 | ### Infrastructure 9 | 10 | * Add E2E cypress tests for rollup ([#152](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/152)) 11 | * Change release workflow to use new staging bucket for artifacts ([#151](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/151)) 12 | 13 | ### Documentation 14 | 15 | * Compatible with Kibana 7.10.2, ODFE 1.13.0 ([#155](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/155)) 16 | 17 | ### Refactoring 18 | 19 | * Modify getRollups API to use getRollup instead of search API ([#150](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/150)) 20 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.13.0.1.md: -------------------------------------------------------------------------------- 1 | ## Version 1.13.0.1 2021-02-11 2 | 3 | Compatible with Kibana 7.10.2 4 | 5 | ### Enhancements 6 | 7 | * Get All and Explain All ([#149](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/149)) 8 | 9 | ### Bug Fixes 10 | 11 | * Bug fix: getRollups API, rollup jobs landing page ([#154](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/154)) 12 | 13 | ### Infrastructure 14 | 15 | * Add E2E cypress tests for rollup ([#152](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/152)) 16 | * Change release workflow to use new staging bucket for artifacts ([#151](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/151)) 17 | 18 | ### Documentation 19 | 20 | * Compatible with Kibana 7.10.2, ODFE 1.13.0 ([#155](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/155)) 21 | 22 | ### Refactoring 23 | 24 | * Modify getRollups API to use getRollup instead of search API ([#150](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/150)) 25 | 26 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.3.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.3.0 2 | 3 | ### Features 4 | 5 | This is the first official release of Open Distro Index Management Kibana plugin. 6 | 7 | To use this plugin you will need the [Open Distro Index Management plugin](https://github.com/opendistro-for-elasticsearch/index-management). 8 | This plugin allows you to manage your policies and managed indices directly through Kibana. 9 | 10 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.4.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.4.0 2 | 3 | ### Features 4 | 5 | * Adds support for Kibana 7.4.2 - [PR #73](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/73) 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.6.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.6.0 2 | 3 | ### Features 4 | 5 | * Adds support for Kibana 7.6.1 - [PR #83](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/83) 6 | 7 | ### Bug Fixes 8 | 9 | * Fixes table defaults using incorrect sortField - [PR #83](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/83) 10 | * Adds title html attribute to certain columns in tables so they can be viewed - [PR #83](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/83) 11 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.7.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.7.0 2 | 3 | Adds support for ODFE 1.7.0 4 | 5 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.8.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.8.0 2 | 3 | * Adds support for Kibana 7.7.0 - [PR #90](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/90) 4 | 5 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.9.0.0.md: -------------------------------------------------------------------------------- 1 | ## Version 1.9.0 2 | 3 | * Adds support for Kibana 7.8.0 - [PR #94](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/94) 4 | 5 | -------------------------------------------------------------------------------- /release-notes/opendistro-for-elasticsearch-index-management-kibana-plugin.release-notes-1.9.0.1.md: -------------------------------------------------------------------------------- 1 | ## Version 1.9.0 2 | 3 | Bug Fixes 4 | * add brace dep for binary kibana not starting problem - [PR #97](https://github.com/opendistro-for-elasticsearch/index-management-kibana-plugin/pull/97) 5 | 6 | 7 | -------------------------------------------------------------------------------- /server/clusters/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import createISMCluster from "./ism/createISMCluster"; 17 | 18 | export { createISMCluster }; 19 | -------------------------------------------------------------------------------- /server/clusters/ism/createISMCluster.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { Legacy } from "kibana"; 17 | import ismPlugin from "./ismPlugin"; 18 | import { CLUSTER, DEFAULT_HEADERS } from "../../utils/constants"; 19 | 20 | type Server = Legacy.Server; 21 | 22 | export default function createISMCluster(server: Server) { 23 | const { customHeaders, ...rest } = server.config().get("elasticsearch"); 24 | server.plugins.elasticsearch.createCluster(CLUSTER.ISM, { 25 | plugins: [ismPlugin], 26 | customHeaders: { ...customHeaders, ...DEFAULT_HEADERS }, 27 | ...rest, 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /server/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { schema, TypeOf } from "@kbn/config-schema"; 17 | import { PluginConfigDescriptor, PluginInitializerContext } from "../../../src/core/server"; 18 | import { IndexPatternManagementPlugin } from "./plugin"; 19 | 20 | export const configSchema = schema.object({ 21 | enabled: schema.boolean({ defaultValue: true }), 22 | }); 23 | 24 | export type IndexManagementPluginConfigType = TypeOf; 25 | 26 | export const config: PluginConfigDescriptor = { 27 | exposeToBrowser: { 28 | enabled: true, 29 | }, 30 | schema: configSchema, 31 | }; 32 | 33 | export interface IndexManagementPluginSetup {} 34 | export interface IndexManagementPluginStart {} 35 | 36 | export function plugin(initializerContext: PluginInitializerContext) { 37 | return new IndexPatternManagementPlugin(); 38 | } 39 | -------------------------------------------------------------------------------- /server/models/types.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | export type MatchAllQuery = { match_all: {} }; 17 | 18 | export type ManagedIndicesSort = { 19 | [sortField: string]: string; 20 | index: "managed_index.index"; 21 | policyId: "managed_index.policy_id"; 22 | }; 23 | 24 | export type PoliciesSort = { 25 | [sortField: string]: string; 26 | id: "policy.policy_id.keyword"; 27 | "policy.policy.description": "policy.description.keyword"; 28 | "policy.policy.last_updated_time": "policy.last_updated_time"; 29 | }; 30 | 31 | export type RollupsSort = { 32 | [sortField: string]: string; 33 | id: "rollup.rollup_id.keyword"; 34 | "rollup.rollup.description": "rollup.description.keyword"; 35 | "rollup.rollup.last_updated_time": "rollup.last_updated_time"; 36 | }; 37 | 38 | export type ServerResponse = { ok: false; error: string } | { ok: true; response: T }; 39 | -------------------------------------------------------------------------------- /server/plugin.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { IndexManagementPluginSetup, IndexManagementPluginStart } from "."; 17 | import { Plugin, CoreSetup, CoreStart, IClusterClient } from "../../../src/core/server"; 18 | import ismPlugin from "./clusters/ism/ismPlugin"; 19 | import { PolicyService, ManagedIndexService, IndexService, RollupService } from "./services"; 20 | import { indices, policies, managedIndices, rollups } from "../server/routes"; 21 | 22 | export class IndexPatternManagementPlugin implements Plugin { 23 | public async setup(core: CoreSetup) { 24 | // create Elasticsearch client that aware of ISM API endpoints 25 | const esDriver: IClusterClient = core.elasticsearch.legacy.createClient("index_management", { 26 | plugins: [ismPlugin], 27 | }); 28 | 29 | // Initialize services 30 | const indexService = new IndexService(esDriver); 31 | const policyService = new PolicyService(esDriver); 32 | const managedIndexService = new ManagedIndexService(esDriver); 33 | const rollupService = new RollupService(esDriver); 34 | const services = { indexService, policyService, managedIndexService, rollupService }; 35 | 36 | // create router 37 | const router = core.http.createRouter(); 38 | // Add server routes 39 | indices(services, router); 40 | policies(services, router); 41 | managedIndices(services, router); 42 | rollups(services, router); 43 | 44 | return {}; 45 | } 46 | 47 | public async start(core: CoreStart) { 48 | return {}; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /server/routes/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import indices from "./indices"; 17 | import policies from "./policies"; 18 | import managedIndices from "./managedIndices"; 19 | import rollups from "./rollups"; 20 | 21 | export { indices, policies, managedIndices, rollups }; 22 | -------------------------------------------------------------------------------- /server/routes/indices.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { schema } from "@kbn/config-schema"; 17 | import { NodeServices } from "../models/interfaces"; 18 | import { NODE_API } from "../../utils/constants"; 19 | import { IRouter } from "../../../../src/core/server"; 20 | 21 | export default function (services: NodeServices, router: IRouter) { 22 | const { indexService } = services; 23 | 24 | router.post( 25 | { 26 | path: NODE_API._SEARCH, 27 | validate: { 28 | body: schema.any(), 29 | }, 30 | }, 31 | indexService.search 32 | ); 33 | 34 | router.get( 35 | { 36 | path: NODE_API._INDICES, 37 | validate: { 38 | query: schema.object({ 39 | from: schema.number(), 40 | size: schema.number(), 41 | search: schema.string(), 42 | sortField: schema.string(), 43 | sortDirection: schema.string(), 44 | }), 45 | }, 46 | }, 47 | indexService.getIndices 48 | ); 49 | 50 | router.post( 51 | { 52 | path: NODE_API.APPLY_POLICY, 53 | validate: { 54 | body: schema.any(), 55 | }, 56 | }, 57 | indexService.applyPolicy 58 | ); 59 | 60 | router.post( 61 | { 62 | path: NODE_API.EDIT_ROLLOVER_ALIAS, 63 | validate: { 64 | body: schema.any(), 65 | }, 66 | }, 67 | indexService.editRolloverAlias 68 | ); 69 | } 70 | -------------------------------------------------------------------------------- /server/routes/managedIndices.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { IRouter } from "kibana/server"; 17 | import { schema } from "@kbn/config-schema"; 18 | import { NodeServices } from "../models/interfaces"; 19 | import { NODE_API } from "../../utils/constants"; 20 | 21 | export default function (services: NodeServices, router: IRouter) { 22 | const { managedIndexService } = services; 23 | 24 | router.get( 25 | { 26 | path: NODE_API.MANAGED_INDICES, 27 | validate: { 28 | query: schema.object({ 29 | from: schema.number(), 30 | size: schema.number(), 31 | search: schema.string(), 32 | sortField: schema.string(), 33 | sortDirection: schema.string(), 34 | }), 35 | }, 36 | }, 37 | managedIndexService.getManagedIndices 38 | ); 39 | 40 | router.get( 41 | { 42 | path: `${NODE_API.MANAGED_INDICES}/{id}`, 43 | validate: { 44 | params: schema.object({ 45 | id: schema.string(), 46 | }), 47 | }, 48 | }, 49 | managedIndexService.getManagedIndex 50 | ); 51 | 52 | router.post( 53 | { 54 | path: NODE_API.RETRY, 55 | validate: { 56 | body: schema.any(), 57 | }, 58 | }, 59 | managedIndexService.retryManagedIndexPolicy 60 | ); 61 | 62 | router.post( 63 | { 64 | path: NODE_API.CHANGE_POLICY, 65 | validate: { 66 | body: schema.any(), 67 | }, 68 | }, 69 | managedIndexService.changePolicy 70 | ); 71 | 72 | router.post( 73 | { 74 | path: NODE_API.REMOVE_POLICY, 75 | validate: { 76 | body: schema.any(), 77 | }, 78 | }, 79 | managedIndexService.removePolicy 80 | ); 81 | } 82 | -------------------------------------------------------------------------------- /server/routes/policies.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { IRouter } from "kibana/server"; 17 | import { schema } from "@kbn/config-schema"; 18 | import { NodeServices } from "../models/interfaces"; 19 | import { NODE_API } from "../../utils/constants"; 20 | 21 | export default function (services: NodeServices, router: IRouter) { 22 | const { policyService } = services; 23 | 24 | router.get( 25 | { 26 | path: NODE_API.POLICIES, 27 | validate: { 28 | query: schema.object({ 29 | from: schema.number(), 30 | size: schema.number(), 31 | search: schema.string(), 32 | sortField: schema.string(), 33 | sortDirection: schema.string(), 34 | }), 35 | }, 36 | }, 37 | policyService.getPolicies 38 | ); 39 | 40 | router.put( 41 | { 42 | path: `${NODE_API.POLICIES}/{id}`, 43 | validate: { 44 | params: schema.object({ 45 | id: schema.string(), 46 | }), 47 | query: schema.object({ 48 | seqNo: schema.maybe(schema.number()), 49 | primaryTerm: schema.maybe(schema.number()), 50 | }), 51 | body: schema.any(), 52 | }, 53 | }, 54 | policyService.putPolicy 55 | ); 56 | 57 | router.get( 58 | { 59 | path: `${NODE_API.POLICIES}/{id}`, 60 | validate: { 61 | params: schema.object({ 62 | id: schema.string(), 63 | }), 64 | }, 65 | }, 66 | policyService.getPolicy 67 | ); 68 | 69 | router.delete( 70 | { 71 | path: `${NODE_API.POLICIES}/{id}`, 72 | validate: { 73 | params: schema.object({ 74 | id: schema.string(), 75 | }), 76 | }, 77 | }, 78 | policyService.deletePolicy 79 | ); 80 | } 81 | -------------------------------------------------------------------------------- /server/services/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import IndexService from "./IndexService"; 17 | import PolicyService from "./PolicyService"; 18 | import ManagedIndexService from "./ManagedIndexService"; 19 | import RollupService from "./RollupService"; 20 | 21 | export { IndexService, PolicyService, ManagedIndexService, RollupService }; 22 | -------------------------------------------------------------------------------- /server/utils/constants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { DefaultHeaders, IndexManagementApi } from "../models/interfaces"; 17 | 18 | export const API_ROUTE_PREFIX = "/_opendistro/_ism"; 19 | export const API_ROUTE_PREFIX_ROLLUP = "/_opendistro/_rollup"; 20 | 21 | export const API: IndexManagementApi = { 22 | POLICY_BASE: `${API_ROUTE_PREFIX}/policies`, 23 | EXPLAIN_BASE: `${API_ROUTE_PREFIX}/explain`, 24 | RETRY_BASE: `${API_ROUTE_PREFIX}/retry`, 25 | ADD_POLICY_BASE: `${API_ROUTE_PREFIX}/add`, 26 | REMOVE_POLICY_BASE: `${API_ROUTE_PREFIX}/remove`, 27 | CHANGE_POLICY_BASE: `${API_ROUTE_PREFIX}/change_policy`, 28 | ROLLUP_JOBS_BASE: `${API_ROUTE_PREFIX_ROLLUP}/jobs`, 29 | }; 30 | 31 | export const DEFAULT_HEADERS: DefaultHeaders = { 32 | "Content-Type": "application/json", 33 | Accept: "application/json", 34 | }; 35 | 36 | export enum CLUSTER { 37 | ADMIN = "admin", 38 | ISM = "opendistro_ism", 39 | DATA = "data", 40 | } 41 | 42 | export enum INDEX { 43 | OPENDISTRO_ISM_CONFIG = ".opendistro-ism-config", 44 | } 45 | 46 | export enum Setting { 47 | RolloverAlias = "opendistro.index_state_management.rollover_alias", 48 | } 49 | -------------------------------------------------------------------------------- /test/jest.config.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | module.exports = { 17 | rootDir: "../", 18 | setupFiles: ["/test/polyfills.ts", "/test/setupTests.ts"], 19 | setupFilesAfterEnv: ["/test/setup.jest.ts"], 20 | roots: [""], 21 | coverageDirectory: "./coverage", 22 | moduleNameMapper: { 23 | "\\.(css|less|scss)$": "/test/mocks/styleMock.ts", 24 | "^ui/(.*)": "/../../src/legacy/ui/public/$1/", 25 | }, 26 | coverageReporters: ["lcov", "text", "cobertura"], 27 | testMatch: ["**/*.test.js", "**/*.test.jsx", "**/*.test.ts", "**/*.test.tsx"], 28 | collectCoverageFrom: [ 29 | "**/*.ts", 30 | "**/*.tsx", 31 | "**/*.js", 32 | "**/*.jsx", 33 | "!**/models/**", 34 | "!**/node_modules/**", 35 | "!**/index.ts", 36 | "!/index.js", 37 | "!/public/app.js", 38 | "!/public/temporary/**", 39 | "!/babel.config.js", 40 | "!/test/**", 41 | "!/server/**", 42 | "!/coverage/**", 43 | "!/scripts/**", 44 | "!/build/**", 45 | "!/cypress/**", 46 | "!**/vendor/**", 47 | ], 48 | clearMocks: true, 49 | testPathIgnorePatterns: ["/build/", "/node_modules/"], 50 | }; 51 | -------------------------------------------------------------------------------- /test/mocks/browserServicesMock.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { IndexService, ManagedIndexService, PolicyService, RollupService } from "../../public/services"; 17 | import httpClientMock from "./httpClientMock"; 18 | 19 | const indexService = new IndexService(httpClientMock); 20 | const managedIndexService = new ManagedIndexService(httpClientMock); 21 | const policyService = new PolicyService(httpClientMock); 22 | const rollupService = new RollupService(httpClientMock); 23 | 24 | export default { indexService, managedIndexService, policyService, rollupService }; 25 | -------------------------------------------------------------------------------- /test/mocks/coreServicesMock.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { CoreStart } from "kibana/public"; 17 | 18 | const coreServicesMock = { 19 | uiSettings: { 20 | get: jest.fn(), 21 | }, 22 | chrome: { 23 | setBreadcrumbs: jest.fn(), 24 | }, 25 | notifications: { 26 | toasts: { 27 | addDanger: jest.fn().mockName("addDanger"), 28 | addSuccess: jest.fn().mockName("addSuccess"), 29 | }, 30 | }, 31 | }; 32 | 33 | export default coreServicesMock as CoreStart; 34 | -------------------------------------------------------------------------------- /test/mocks/historyMock.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | const historyMock = { 17 | action: "REPLACE", // PUSH, REPLACE, POP 18 | block: jest.fn(), // prevents navigation 19 | createHref: jest.fn(), 20 | go: jest.fn(), // moves the pointer in the history stack by n entries 21 | goBack: jest.fn(), // equivalent to go(-1) 22 | goForward: jest.fn(), // equivalent to go(1) 23 | length: 0, // number of entries in the history stack 24 | listen: jest.fn(), 25 | location: { 26 | hash: "", // URL hash fragment 27 | pathname: "", // path of URL 28 | search: "", // URL query string 29 | state: undefined, // location-specific state that was provided to e.g. push(path, state) when this location was pushed onto the stack 30 | }, 31 | push: jest.fn(), // pushes new entry onto history stack 32 | replace: jest.fn(), // replaces current entry on history stack 33 | }; 34 | 35 | export default historyMock; 36 | -------------------------------------------------------------------------------- /test/mocks/httpClientMock.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import { HttpSetup } from "kibana/public"; 17 | 18 | const httpClientMock = jest.fn() as any; 19 | 20 | httpClientMock.delete = jest.fn(); 21 | httpClientMock.get = jest.fn(); 22 | httpClientMock.head = jest.fn(); 23 | httpClientMock.post = jest.fn(); 24 | httpClientMock.put = jest.fn(); 25 | 26 | export default httpClientMock as HttpSetup; 27 | -------------------------------------------------------------------------------- /test/mocks/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import browserServicesMock from "./browserServicesMock"; 17 | import historyMock from "./historyMock"; 18 | import httpClientMock from "./httpClientMock"; 19 | import styleMock from "./styleMock"; 20 | import coreServicesMock from "./coreServicesMock"; 21 | 22 | export { browserServicesMock, historyMock, httpClientMock, styleMock, coreServicesMock }; 23 | -------------------------------------------------------------------------------- /test/mocks/styleMock.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | export default {}; 17 | -------------------------------------------------------------------------------- /test/polyfills.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | // @ts-ignore 17 | import { MutationObserver } from "./polyfills/mutationObserver"; 18 | 19 | Object.defineProperty(window, "MutationObserver", { value: MutationObserver }); 20 | -------------------------------------------------------------------------------- /test/setup.jest.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | import React from "react"; 17 | import "@testing-library/jest-dom/extend-expect"; 18 | import { configure } from "@testing-library/react"; 19 | 20 | configure({ testIdAttribute: "data-test-subj" }); 21 | 22 | jest.mock("@elastic/eui/lib/components/form/form_row/make_id", () => () => "some_make_id"); 23 | 24 | jest.mock("@elastic/eui/lib/services/accessibility/html_id_generator", () => ({ 25 | htmlIdGenerator: () => { 26 | return () => "some_html_id"; 27 | }, 28 | })); 29 | 30 | // @ts-ignore 31 | window.Worker = function () { 32 | this.postMessage = () => {}; 33 | // @ts-ignore 34 | this.terminate = () => {}; 35 | }; 36 | 37 | // @ts-ignore 38 | window.URL = { 39 | createObjectURL: () => { 40 | return ""; 41 | }, 42 | }; 43 | 44 | // https://github.com/elastic/eui/issues/2530 45 | jest.mock("@elastic/eui/lib/components/icon", () => ({ 46 | EuiIcon: () => "EuiIconMock", 47 | __esModule: true, 48 | IconPropType: require("@elastic/eui/lib/components/icon/icon").IconPropType, 49 | ICON_TYPES: require("@elastic/eui/lib/components/icon/icon").TYPES, 50 | ICON_SIZES: require("@elastic/eui/lib/components/icon/icon").SIZES, 51 | ICON_COLORS: require("@elastic/eui/lib/components/icon/icon").COLORS, 52 | })); 53 | -------------------------------------------------------------------------------- /test/setupTests.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | require("babel-polyfill"); 17 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // extend Kibana's tsconfig, or use your own settings 3 | "extends": "../../tsconfig.json", 4 | 5 | // tell the TypeScript compiler where to find your source files 6 | "include": ["server/**/*", "public/**/*", "utils/**/*", "models/**/*", "test/**/*"], 7 | "exclude": ["node_modules", "*/node_modules/"], 8 | "compilerOptions": { 9 | "skipLibCheck": true, 10 | "esModuleInterop": true, 11 | "outDir": "./target" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /utils/constants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"). 5 | * You may not use this file except in compliance with the License. 6 | * A copy of the License is located at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * or in the "license" file accompanying this file. This file is distributed 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 | * express or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | */ 15 | 16 | export const BASE_API_PATH = "/api/ism"; 17 | export const NODE_API = Object.freeze({ 18 | _SEARCH: `${BASE_API_PATH}/_search`, 19 | _INDICES: `${BASE_API_PATH}/_indices`, 20 | _MAPPINGS: `${BASE_API_PATH}/_mappings`, 21 | APPLY_POLICY: `${BASE_API_PATH}/applyPolicy`, 22 | EDIT_ROLLOVER_ALIAS: `${BASE_API_PATH}/editRolloverAlias`, 23 | POLICIES: `${BASE_API_PATH}/policies`, 24 | ROLLUPS: `${BASE_API_PATH}/rollups`, 25 | MANAGED_INDICES: `${BASE_API_PATH}/managedIndices`, 26 | RETRY: `${BASE_API_PATH}/retry`, 27 | CHANGE_POLICY: `${BASE_API_PATH}/changePolicy`, 28 | REMOVE_POLICY: `${BASE_API_PATH}/removePolicy`, 29 | }); 30 | 31 | export const REQUEST = Object.freeze({ 32 | PUT: "PUT", 33 | DELETE: "DELETE", 34 | GET: "GET", 35 | POST: "POST", 36 | HEAD: "HEAD", 37 | }); 38 | --------------------------------------------------------------------------------