From 6a3eeb9ec44d9bce02468f78670f6c0a2fd1b6ee Mon Sep 17 00:00:00 2001 From: kohinoor98 Date: Mon, 13 Nov 2023 17:07:26 -0600 Subject: [PATCH 1/8] typescript config and clean up Signed-off-by: kohinoor98 --- .eslintrc.js | 41 ++- .lintstagedrc | 8 +- cypress/support/index.d.ts | 17 +- models/interfaces.ts | 38 ++- package.json | 3 +- .../JobHandler/callbacks/force_merge.test.tsx | 19 +- public/JobHandler/callbacks/force_merge.tsx | 19 +- public/JobHandler/callbacks/open.test.tsx | 19 +- public/JobHandler/callbacks/open.tsx | 15 +- public/JobHandler/callbacks/reindex.test.tsx | 19 +- public/JobHandler/callbacks/reindex.tsx | 19 +- public/JobHandler/callbacks/shrink.test.tsx | 19 +- public/JobHandler/callbacks/shrink.tsx | 15 + public/JobHandler/callbacks/split.test.tsx | 19 +- public/JobHandler/callbacks/split.tsx | 15 + public/JobHandler/components/DetailLink.tsx | 15 + .../components/ErrorToastContentForJob.tsx | 15 + .../FormatResourceWithClusterInfo.tsx | 15 + .../JobHandler/components/components.test.tsx | 17 +- public/JobHandler/index.ts | 15 + public/JobHandler/interface.ts | 19 +- public/JobHandler/utils.ts | 15 + .../AdvancedSettings.test.tsx | 17 +- public/components/AdvancedSettings/index.tsx | 20 +- .../AliasSelect/AliasSelect.test.tsx | 17 +- public/components/AliasSelect/index.tsx | 23 +- .../components/BottomBar/BottomBar.test.tsx | 15 + public/components/BottomBar/BottomBar.tsx | 19 +- public/components/BottomBar/index.ts | 15 + .../ChannelNotification.test.tsx | 17 +- .../ChannelNotification.tsx | 15 + .../components/ChannelNotification/index.ts | 15 + .../ComboBoxWithoutWarning/index.tsx | 15 + .../ComponentTemplateBadge.tsx | 15 + .../ComponentTemplateBadge/index.ts | 15 + .../ConfirmationModal.test.tsx | 15 + .../ConfirmationModal/ConfirmationModal.tsx | 17 +- public/components/ConfirmationModal/index.ts | 15 + .../ContentPanel/ContentPanel.test.tsx | 15 + .../components/ContentPanel/ContentPanel.tsx | 17 +- .../ContentPanel/ContentPanelActions.test.tsx | 15 + .../ContentPanel/ContentPanelActions.tsx | 21 +- public/components/ContentPanel/index.ts | 15 + .../CreatePolicyModal.test.tsx | 15 + .../CreatePolicyModal/CreatePolicyModal.tsx | 17 +- public/components/CreatePolicyModal/index.ts | 15 + .../CustomFormRow/CustomFormRow.test.tsx | 15 + public/components/CustomFormRow/index.tsx | 15 + public/components/CustomLabel/CustomLabel.tsx | 15 + public/components/CustomLabel/index.ts | 15 + public/components/DarkMode/DarkMode.tsx | 15 + public/components/DarkMode/index.ts | 15 + .../DeleteModal/DeleteModal.test.tsx | 15 + public/components/DeleteModal/DeleteModal.tsx | 15 + public/components/DeleteModal/index.ts | 15 + .../DescriptionListHoz.test.tsx | 15 + .../DescriptionListHoz/DescriptionListHoz.tsx | 15 + public/components/DescriptionListHoz/index.ts | 15 + .../EuiToolTipWrapper.test.tsx | 15 + public/components/EuiToolTipWrapper/index.tsx | 19 +- .../FilterGroup/FilterGroup.test.tsx | 17 +- public/components/FilterGroup/index.tsx | 22 +- .../FormGenerator/FormGenerator.test.tsx | 15 + .../built_in_components/index.tsx | 27 +- public/components/FormGenerator/index.tsx | 61 ++-- .../IndexDetail/IndexDetail.test.tsx | 17 +- public/components/IndexDetail/IndexDetail.tsx | 286 ++++++++++-------- public/components/IndexDetail/index.ts | 15 + .../IndexMapping/IndexMapping.test.tsx | 17 +- .../components/IndexMapping/IndexMapping.tsx | 33 +- public/components/IndexMapping/helper.ts | 15 + public/components/IndexMapping/index.ts | 15 + public/components/IndexMapping/interfaces.ts | 23 +- .../JSONDiffEditor/JSONDiffEditor.test.tsx | 15 + .../JSONDiffEditor/JSONDiffEditor.tsx | 30 +- .../JSONDiffEditor/JSONTextArea.tsx | 19 +- public/components/JSONDiffEditor/index.tsx | 15 + public/components/JSONDiffEditor/interface.ts | 15 + .../components/JSONEditor/JSONEditor.test.tsx | 17 +- public/components/JSONEditor/JSONEditor.tsx | 17 +- public/components/JSONEditor/index.ts | 15 + .../components/JSONModal/JSONModal.test.tsx | 15 + public/components/JSONModal/JSONModal.tsx | 17 +- public/components/JSONModal/index.ts | 15 + .../LegacyNotification.test.tsx | 15 + .../LegacyNotification/LegacyNotification.tsx | 15 + public/components/LegacyNotification/index.ts | 15 + .../MappingLabel/MappingLabel.test.tsx | 15 + .../components/MappingLabel/MappingLabel.tsx | 37 ++- public/components/MappingLabel/index.ts | 15 + public/components/Modal/Modal.test.tsx | 19 +- public/components/Modal/Modal.tsx | 15 + public/components/Modal/ModalRoot.tsx | 17 +- public/components/Modal/index.ts | 15 + .../MonacoJSONEditor.test.tsx | 15 + .../MonacoJSONEditor/MonacoJSONEditor.tsx | 29 +- public/components/MonacoJSONEditor/hooks.tsx | 22 ++ public/components/MonacoJSONEditor/index.tsx | 15 + .../components/MonacoJSONEditor/interface.ts | 28 +- .../PolicyModal/PolicyModal.test.tsx | 16 + public/components/PolicyModal/PolicyModal.tsx | 17 +- public/components/PolicyModal/index.ts | 15 + .../RemoteSelect/RemoteSelect.test.tsx | 17 +- public/components/RemoteSelect/index.tsx | 58 ++-- .../SimplePopover/SimplePopover.test.tsx | 17 +- .../SimplePopover/SimplePopover.tsx | 56 +++- public/components/SimplePopover/index.ts | 15 + .../SwitchableEditor.test.tsx | 17 +- .../SwitchableEditor/SwitchableEditor.tsx | 17 +- public/components/SwitchableEditor/index.tsx | 15 + public/components/Toast/Toast.test.tsx | 15 + public/components/Toast/index.tsx | 15 + .../ToolTipWithoutWarning/index.tsx | 15 + .../UnsavedChangesBottomBar.test.tsx | 15 + .../UnsavedChangesBottomBar.tsx | 23 +- .../UnsavedChangesBottomBar/index.ts | 15 + public/components/core_services.ts | 15 + .../ChannelSelect/ChannelSelect.test.tsx | 17 +- .../ChannelSelect/ChannelSelect.tsx | 21 +- public/containers/ChannelSelect/hooks.tsx | 82 +++-- public/containers/ChannelSelect/index.ts | 15 + .../ClearCacheModal/ClearCacheModal.test.tsx | 23 +- .../ClearCacheModal/ClearCacheModal.tsx | 69 +++-- public/containers/ClearCacheModal/index.ts | 15 + .../ErrorNotification.test.tsx | 15 + .../ErrorNotification/ErrorNotification.tsx | 19 +- public/containers/ErrorNotification/index.ts | 15 + .../FlushIndexModal/FlushIndexModal.test.tsx | 37 ++- .../FlushIndexModal/FlushIndexModal.tsx | 167 +++++----- .../FlushIndexModalTestHelper.tsx | 15 + public/containers/FlushIndexModal/index.ts | 15 + .../IndexDetail/IndexDetail.test.tsx | 15 + public/containers/IndexDetail/index.tsx | 61 ++-- .../containers/IndexForm/IndexForm.test.tsx | 15 + public/containers/IndexForm/index.tsx | 17 ++ .../NotificationCallout.test.tsx | 17 +- .../NotificationCallout.tsx | 20 ++ .../NotificationConfig.test.tsx | 23 +- .../NotificationConfig/NotificationConfig.tsx | 63 ++-- .../containers/NotificationConfig/hooks.tsx | 30 +- public/containers/NotificationConfig/index.ts | 15 + public/containers/RefreshAction/index.tsx | 140 +++++---- public/context/JobSchedulerContext.tsx | 15 + public/index.ts | 16 + public/index_management_app.tsx | 15 + public/lib/JobScheduler/JobScheduler.test.ts | 15 + public/lib/JobScheduler/JobScheduler.ts | 15 + public/lib/JobScheduler/index.ts | 15 + public/lib/JobScheduler/interface.ts | 19 +- public/lib/JobScheduler/store-localstorage.ts | 15 + public/lib/field/index.tsx | 18 +- public/lib/field/interfaces.ts | 39 ++- public/lib/field/messages.ts | 15 + public/lib/field/rules/index.ts | 15 + public/lib/field/util.ts | 15 + public/lib/monaco/index.ts | 20 ++ public/lib/monaco/json.ts | 20 ++ public/models/interfaces.ts | 15 + .../IndexControls/IndexControls.test.tsx | 15 + .../IndexControls/IndexControls.tsx | 15 + .../Aliases/components/IndexControls/index.ts | 15 + .../AliasActions/AliasActions.test.tsx | 15 + .../Aliases/containers/AliasActions/index.tsx | 16 + .../containers/Aliases/Aliases.test.tsx | 17 +- .../Aliases/containers/Aliases/Aliases.tsx | 19 +- .../pages/Aliases/containers/Aliases/index.ts | 15 + .../CreateAlias/CreateAlias.test.tsx | 15 + .../Aliases/containers/CreateAlias/index.tsx | 31 +- .../DeleteAliasModal.test.tsx | 15 + .../DeleteAliasModal/DeleteAliasModal.tsx | 15 + .../containers/DeleteAliasModal/index.ts | 15 + public/pages/Aliases/index.ts | 15 + public/pages/Aliases/interface.ts | 15 + public/pages/Aliases/utils/constants.tsx | 15 + .../ChangeManagedIndices.test.tsx | 15 + .../ChangeManagedIndices.tsx | 25 +- .../components/ChangeManagedIndices/index.ts | 15 + .../components/NewPolicy/NewPolicy.test.tsx | 15 + .../components/NewPolicy/NewPolicy.tsx | 17 +- .../components/NewPolicy/index.ts | 15 + .../ChangePolicy/ChangePolicy.test.tsx | 15 + .../containers/ChangePolicy/ChangePolicy.tsx | 23 +- .../containers/ChangePolicy/index.ts | 15 + public/pages/ChangePolicy/index.ts | 15 + .../pages/ChangePolicy/models/interfaces.ts | 15 + .../BaseAggregationAndMetricSettings.tsx | 46 ++- .../IndexControls/IndexControls.test.tsx | 15 + .../IndexControls/IndexControls.tsx | 15 + .../components/IndexControls/index.ts | 15 + .../AssociatedTemplatesModal.test.tsx | 17 +- .../AssociatedTemplatesModal.tsx | 21 +- .../AssociatedTemplatesModal/index.ts | 15 + .../ComposableTemplates.test.tsx | 17 +- .../ComposableTemplates.tsx | 19 +- .../containers/ComposableTemplates/index.ts | 20 ++ .../ComposableTemplatesActions.test.tsx | 17 +- .../ComposableTemplatesActions/index.tsx | 15 + .../DeleteComposableTemplatesModal.test.tsx | 15 + .../DeleteComposableTemplatesModal.tsx | 31 +- .../DeleteComposableTemplatesModal/index.ts | 15 + public/pages/ComposableTemplates/index.ts | 15 + public/pages/ComposableTemplates/interface.ts | 20 ++ .../ComposableTemplates/utils/constants.tsx | 15 + .../pages/ComposableTemplates/utils/hooks.tsx | 95 +++--- .../ComposableTemplates/utils/services.ts | 24 +- .../IndexSettings/IndexSettings.tsx | 24 +- .../components/IndexSettings/index.ts | 20 ++ .../components/TemplateType/TemplateType.tsx | 22 +- .../components/TemplateType/index.ts | 20 ++ .../CreateComposableTemplate.test.tsx | 15 + .../CreateComposableTemplate.tsx | 23 +- .../CreateComposableTemplate/index.ts | 15 + .../DefineTemplate/DefineTemplate.tsx | 21 ++ .../containers/DefineTemplate/index.ts | 20 ++ .../containers/IndexAlias/IndexAlias.tsx | 20 ++ .../containers/IndexAlias/index.ts | 20 ++ .../TemplateDetail/TemplateDetail.test.tsx | 19 +- .../TemplateDetail/TemplateDetail.tsx | 19 +- .../containers/TemplateDetail/index.ts | 15 + .../TemplateMappings/TemplateMappings.tsx | 22 +- .../containers/TemplateMappings/index.ts | 20 ++ .../pages/CreateComposableTemplate/hooks.tsx | 22 +- .../pages/CreateComposableTemplate/index.ts | 15 + .../CreateComposableTemplate/interface.ts | 20 ++ .../IndexSettings/IndexSettings.tsx | 15 + .../components/IndexSettings/index.ts | 15 + .../BackingIndices/BackingIndices.tsx | 57 ++-- .../containers/BackingIndices/index.ts | 15 + .../CreateDataStream.test.tsx | 15 + .../CreateDataStream/CreateDataStream.tsx | 21 +- .../containers/CreateDataStream/index.ts | 15 + .../DataStreamDetail.test.tsx | 19 +- .../DataStreamDetail/DataStreamDetail.tsx | 82 +++-- .../containers/DataStreamDetail/hooks.tsx | 23 +- .../containers/DataStreamDetail/index.ts | 15 + .../DefineDataStream/DefineDataStream.tsx | 17 +- .../containers/DefineDataStream/index.ts | 15 + .../containers/IndexAlias/IndexAlias.tsx | 15 + .../containers/IndexAlias/index.ts | 15 + .../TemplateMappings/TemplateMappings.tsx | 15 + .../containers/TemplateMappings/index.ts | 15 + public/pages/CreateDataStream/hooks.tsx | 15 + public/pages/CreateDataStream/index.ts | 15 + public/pages/CreateDataStream/interface.ts | 19 +- .../CreateIndex/CreateIndex.test.tsx | 15 + .../containers/CreateIndex/CreateIndex.tsx | 19 +- .../containers/CreateIndex/index.ts | 15 + .../containers/IndexForm/IndexForm.test.tsx | 15 + .../containers/IndexForm/index.tsx | 33 +- public/pages/CreateIndex/index.ts | 15 + .../DefineTemplate/DefineTemplate.test.tsx | 20 +- .../DefineTemplate/DefineTemplate.tsx | 17 +- .../DefineTemplate/OverviewTemplate.tsx | 15 + .../components/DefineTemplate/index.ts | 15 + .../IndexSettings/IndexSettings.tsx | 19 +- .../components/IndexSettings/index.ts | 15 + .../components/TemplateType/TemplateType.tsx | 17 +- .../components/TemplateType/index.ts | 15 + public/pages/CreateIndexTemplate/constant.ts | 20 ++ .../ComposableTemplate/ComposableTemplate.tsx | 27 +- .../containers/ComposableTemplate/index.ts | 15 + .../CreateIndexTemplate.test.tsx | 15 + .../CreateIndexTemplate.tsx | 21 +- .../containers/CreateIndexTemplate/index.ts | 15 + .../containers/IndexAlias/IndexAlias.tsx | 15 + .../containers/IndexAlias/index.ts | 15 + .../PreviewTemplate/PreviewTemplate.tsx | 19 +- .../containers/PreviewTemplate/index.ts | 15 + .../TemplateDetail/TemplateDetail.test.tsx | 15 + .../TemplateDetail/TemplateDetail.tsx | 43 ++- .../containers/TemplateDetail/index.ts | 15 + .../TemplateMappings/TemplateMappings.tsx | 15 + .../containers/TemplateMappings/index.ts | 15 + public/pages/CreateIndexTemplate/hooks.tsx | 23 +- public/pages/CreateIndexTemplate/index.ts | 15 + public/pages/CreateIndexTemplate/interface.ts | 15 + .../ConfigurePolicy/ConfigurePolicy.test.tsx | 15 + .../ConfigurePolicy/ConfigurePolicy.tsx | 15 + .../components/ConfigurePolicy/index.ts | 15 + .../DefinePolicy/DefinePolicy.test.tsx | 15 + .../components/DefinePolicy/DefinePolicy.tsx | 19 +- .../__mocks__/DefinePolicyMock.tsx | 15 + .../components/DefinePolicy/index.ts | 15 + .../CreatePolicy/CreatePolicy.test.tsx | 17 ++ .../containers/CreatePolicy/CreatePolicy.tsx | 21 +- .../containers/CreatePolicy/index.ts | 15 + public/pages/CreatePolicy/index.ts | 15 + public/pages/CreatePolicy/utils/constants.ts | 15 + .../pages/CreatePolicy/utils/helpers.test.tsx | 15 + public/pages/CreatePolicy/utils/helpers.tsx | 15 + .../AdvancedAggregation.tsx | 51 ++-- .../components/AdvancedAggregation/index.ts | 15 + .../ConfigureRollup/ConfigureRollup.tsx | 15 + .../components/ConfigureRollup/index.ts | 15 + .../CreateRollupSteps/CreateRollupSteps.tsx | 15 + .../components/CreateRollupSteps/index.ts | 15 + .../HistogramAndMetrics.tsx | 29 +- .../components/HistogramAndMetrics/index.ts | 15 + .../JobNameAndIndices/JobNameAndIndices.tsx | 22 +- .../components/JobNameAndIndices/index.ts | 15 + .../MetricsCalculation/MetricsCalculation.tsx | 49 +-- .../components/MetricsCalculation/index.ts | 15 + .../RollupIndices/RollupIndices.tsx | 41 ++- .../components/RollupIndices/index.ts | 15 + .../components/Schedule/Schedule.tsx | 24 +- .../CreateRollup/components/Schedule/index.ts | 15 + .../ScheduleRolesAndNotifications.tsx | 20 +- .../ScheduleRolesAndNotifications/index.ts | 15 + .../TimeAggregations/TimeAggregation.tsx | 34 ++- .../components/TimeAggregations/index.ts | 15 + .../containers/CreateRollup/CreateRollup.tsx | 24 +- .../containers/CreateRollup/index.ts | 15 + .../CreateRollupForm.test.tsx | 75 +++-- .../CreateRollupForm/CreateRollupForm.tsx | 149 +++++---- .../containers/CreateRollupForm/index.ts | 15 + .../CreateRollupStep2/CreateRollupStep2.tsx | 21 +- .../containers/CreateRollupStep2/index.ts | 15 + .../CreateRollupStep3/CreateRollupStep3.tsx | 17 +- .../containers/CreateRollupStep3/index.ts | 15 + .../CreateRollupStep4/CreateRollupStep4.tsx | 25 +- .../containers/CreateRollupStep4/index.ts | 15 + public/pages/CreateRollup/index.ts | 15 + public/pages/CreateRollup/utils/constants.ts | 17 +- public/pages/CreateRollup/utils/helpers.ts | 79 +++-- .../components/CronSchedule/CronSchedule.tsx | 51 +++- .../components/CronSchedule/constants.ts | 15 + .../components/CronSchedule/helper.ts | 41 ++- .../components/CronSchedule/index.ts | 15 + .../components/Notification/Notification.tsx | 15 + .../components/Notification/index.ts | 15 + .../SnapshotAdvancedSettings.tsx | 19 +- .../SnapshotAdvancedSettings/index.ts | 15 + .../SnapshotIndicesRepoInput.tsx | 23 +- .../SnapshotIndicesRepoInput/index.ts | 15 + .../pages/CreateSnapshotPolicy/constants.ts | 15 + .../CreateSnapshotPolicy.tsx | 37 ++- .../containers/CreateSnapshotPolicy/index.ts | 15 + .../CreateSnapshotPolicy/containers/helper.ts | 27 +- public/pages/CreateSnapshotPolicy/index.ts | 15 + .../ConfigureTransform/ConfigureTransform.tsx | 15 + .../components/ConfigureTransform/index.ts | 15 + .../CreateTransformSteps.tsx | 15 + .../components/CreateTransformSteps/index.ts | 15 + .../DefineTransforms/DefineTransforms.tsx | 90 ++++-- .../components/DefineTransforms/index.ts | 15 + .../IndexFilterPopover/IndexFilterPopover.tsx | 21 +- .../components/IndexFilterPopover/index.ts | 15 + .../JobNameAndIndices/JobNameAndIndices.tsx | 24 +- .../components/JobNameAndIndices/index.ts | 15 + .../PreviewEmptyPrompt/PreviewEmptyPrompt.tsx | 15 + .../components/PreviewEmptyPrompt/index.ts | 15 + .../EditTransformPanel/EditTransformPanel.tsx | 15 + .../Panels/EditTransformPanel/index.ts | 15 + .../PreviewOptions/PreviewOptions.tsx | 15 + .../components/PreviewOptions/index.ts | 15 + .../PreviewTransform/PreviewTransform.tsx | 31 +- .../components/PreviewTransform/index.ts | 15 + .../ReviewDefinition/ReviewDefinition.tsx | 25 +- .../components/ReviewDefinition/index.ts | 15 + .../ReviewSchedule/ReviewSchedule.tsx | 16 + .../components/ReviewSchedule/index.ts | 15 + .../components/Schedule/Schedule.tsx | 16 + .../components/Schedule/index.ts | 15 + .../TransformIndices/TransformIndices.tsx | 41 ++- .../components/TransformIndices/index.ts | 15 + .../DateHistogramPanel.test.tsx | 15 + .../DateHistogramPanel/DateHistogramPanel.tsx | 20 +- .../Panels/DateHistogramPanel/index.ts | 15 + .../Panels/HistogramPanel/HistogramPanel.tsx | 17 +- .../Panels/HistogramPanel/index.ts | 15 + .../PercentilePanel/PercentilePanel.tsx | 21 +- .../Panels/PercentilePanel/index.ts | 15 + .../ScriptedMetricsPanel.tsx | 15 + .../Panels/ScriptedMetricsPanel/index.ts | 15 + .../TransformOptions/TransformOptions.tsx | 20 +- .../components/TransformOptions/index.ts | 15 + .../CreateTransformForm.test.tsx | 21 +- .../CreateTransformForm.tsx | 117 ++++--- .../containers/CreateTransformForm/index.ts | 15 + .../DefineTransformsStep.tsx | 15 + .../containers/DefineTransformsStep/index.ts | 15 + .../ReviewAndCreateStep.tsx | 21 +- .../containers/ReviewAndCreateStep/index.ts | 15 + .../SetUpIndicesStep/SetUpIndicesStep.tsx | 24 +- .../containers/SetUpIndicesStep/index.ts | 15 + .../SpecifyScheduleStep.tsx | 17 +- .../containers/SpecifyScheduleStep/index.ts | 15 + public/pages/CreateTransform/index.ts | 15 + .../pages/CreateTransform/utils/constants.ts | 17 +- public/pages/CreateTransform/utils/helpers.ts | 61 ++-- .../IndexControls/IndexControls.test.tsx | 15 + .../IndexControls/IndexControls.tsx | 15 + .../components/IndexControls/index.ts | 15 + .../DataStreams/DataStreams.test.tsx | 17 +- .../containers/DataStreams/DataStreams.tsx | 17 +- .../containers/DataStreams/index.ts | 15 + .../DataStreamsActions.test.tsx | 17 +- .../containers/DataStreamsActions/index.tsx | 16 + .../DeleteDataStreamsModal.test.tsx | 15 + .../DeleteDataStreamsModal.tsx | 15 + .../DeleteDataStreamsModal/index.ts | 15 + public/pages/DataStreams/index.ts | 15 + public/pages/DataStreams/interface.ts | 15 + public/pages/DataStreams/utils/constants.tsx | 15 + .../EditRollup/containers/EditRollup.test.tsx | 21 +- .../EditRollup/containers/EditRollup.tsx | 53 ++-- public/pages/EditRollup/containers/index.ts | 15 + public/pages/EditRollup/index.ts | 15 + .../ForceMergeAdvancedOptions.test.tsx | 15 + .../ForceMergeAdvancedOptions.tsx | 17 +- .../ForceMergeAdvancedOptions/index.ts | 15 + .../IndexSelect/IndexSelect.test.tsx | 17 +- .../components/IndexSelect/IndexSelect.tsx | 43 ++- .../components/IndexSelect/index.ts | 15 + .../components/SwitchNumber/index.tsx | 21 +- .../container/ForceMerge/ForceMerge.test.tsx | 16 + .../container/ForceMerge/ForceMerge.tsx | 74 +++-- .../ForceMerge/container/ForceMerge/index.ts | 15 + public/pages/ForceMerge/index.ts | 15 + public/pages/ForceMerge/models/interfaces.ts | 15 + public/pages/ForceMerge/utils/constants.ts | 15 + public/pages/ForceMerge/utils/helper.test.ts | 15 + public/pages/ForceMerge/utils/helper.ts | 47 ++- .../IndexDetail/IndexDetail.test.tsx | 17 +- .../containers/IndexDetail/IndexDetail.tsx | 45 ++- .../containers/IndexDetail/constants.tsx | 21 +- .../containers/IndexDetail/index.ts | 15 + .../containers/IndexDetail/interface.ts | 15 + public/pages/IndexDetail/index.ts | 15 + .../ApplyPolicyModal.test.tsx | 15 + .../ApplyPolicyModal/ApplyPolicyModal.tsx | 15 + .../components/ApplyPolicyModal/index.ts | 15 + .../CloseIndexModal/CloseIndexModal.test.tsx | 15 + .../CloseIndexModal/CloseIndexModal.tsx | 15 + .../components/CloseIndexModal/index.ts | 15 + .../DeleteIndexModal.test.tsx | 15 + .../DeleteIndexModal/DeleteIndexModal.tsx | 15 + .../components/DeleteIndexModal/index.ts | 15 + .../IndexControls/IndexControls.test.tsx | 15 + .../IndexControls/IndexControls.tsx | 15 + .../Indices/components/IndexControls/index.ts | 15 + .../IndexEmptyPrompt.test.tsx | 15 + .../IndexEmptyPrompt/IndexEmptyPrompt.tsx | 19 +- .../components/IndexEmptyPrompt/index.ts | 15 + .../OpenIndexModal/OpenIndexModal.test.tsx | 15 + .../OpenIndexModal/OpenIndexModal.tsx | 15 + .../components/OpenIndexModal/index.ts | 15 + .../IndexDetail/IndexDetail.test.tsx | 15 + .../Indices/containers/IndexDetail/index.tsx | 17 +- .../containers/Indices/Indices.test.tsx | 15 + .../Indices/containers/Indices/Indices.tsx | 15 + .../pages/Indices/containers/Indices/index.ts | 15 + .../IndicesActions/IndicesActions.test.tsx | 65 ++-- .../containers/IndicesActions/index.tsx | 85 ++++-- public/pages/Indices/index.ts | 15 + public/pages/Indices/models/interfaces.ts | 15 + public/pages/Indices/utils/constants.tsx | 23 +- public/pages/Indices/utils/helpers.ts | 23 +- public/pages/Main/Main.tsx | 26 +- public/pages/Main/index.ts | 15 + .../components/InfoModal/InfoModal.test.tsx | 15 + .../components/InfoModal/InfoModal.tsx | 15 + .../components/InfoModal/index.ts | 15 + .../ManagedIndexControls.test.tsx | 15 + .../ManagedIndexControls.tsx | 15 + .../components/ManagedIndexControls/index.ts | 15 + .../ManagedIndexEmptyPrompt.test.tsx | 15 + .../ManagedIndexEmptyPrompt.tsx | 19 +- .../ManagedIndexEmptyPrompt/index.ts | 15 + .../components/RetryModal/RetryModal.test.tsx | 17 ++ .../components/RetryModal/RetryModal.tsx | 20 +- .../components/RetryModal/index.ts | 15 + .../RolloverAliasModal.test.tsx | 15 + .../RolloverAliasModal/RolloverAliasModal.tsx | 15 + .../components/RolloverAliasModal/index.ts | 15 + .../ManagedIndices/ManagedIndices.test.tsx | 17 +- .../ManagedIndices/ManagedIndices.tsx | 27 +- .../containers/ManagedIndices/index.ts | 15 + public/pages/ManagedIndices/index.ts | 15 + .../pages/ManagedIndices/models/interfaces.ts | 15 + .../pages/ManagedIndices/utils/constants.ts | 15 + public/pages/ManagedIndices/utils/helpers.ts | 15 + public/pages/Notifications/constant.ts | 20 ++ .../Notifications/Notifications.test.tsx | 15 + .../Notifications/Notifications.tsx | 52 +++- .../containers/Notifications/index.ts | 15 + public/pages/Notifications/hooks.tsx | 23 +- public/pages/Notifications/index.ts | 15 + public/pages/Notifications/interface.ts | 23 +- .../PolicyControls/PolicyControls.test.tsx | 15 + .../PolicyControls/PolicyControls.tsx | 15 + .../components/PolicyControls/index.ts | 15 + .../PolicyEmptyPrompt.test.tsx | 15 + .../PolicyEmptyPrompt/PolicyEmptyPrompt.tsx | 19 +- .../components/PolicyEmptyPrompt/index.ts | 15 + .../containers/Policies/Policies.test.tsx | 19 +- .../Policies/containers/Policies/Policies.tsx | 19 +- .../Policies/containers/Policies/index.ts | 15 + public/pages/Policies/index.ts | 15 + public/pages/Policies/models/interfaces.ts | 15 + public/pages/Policies/utils/constants.ts | 15 + public/pages/Policies/utils/helpers.ts | 15 + .../DeleteModal/DeleteModal.test.tsx | 17 +- .../components/DeleteModal/DeleteModal.tsx | 19 +- .../components/DeleteModal/index.ts | 15 + .../PolicySettings/PolicySettings.test.tsx | 15 + .../PolicySettings/PolicySettings.tsx | 17 ++ .../components/PolicySettings/index.ts | 15 + .../PolicyDetails/PolicyDetails.tsx | 19 +- .../containers/PolicyDetails/index.ts | 15 + public/pages/PolicyDetails/index.ts | 15 + .../CreateIndexFlyout.test.tsx | 15 + .../CreateIndexFlyout/CreateIndexFlyout.tsx | 17 +- .../components/CreateIndexFlyout/index.ts | 15 + .../IndexSelect/IndexSelect.test.tsx | 17 +- .../components/IndexSelect/IndexSelect.tsx | 41 ++- .../Reindex/components/IndexSelect/index.ts | 15 + .../ReindexAdvancedOptions.test.tsx | 15 + .../ReindexAdvancedOptions.tsx | 25 +- .../ReindexAdvancedOptions/index.ts | 15 + .../container/Reindex/Reindex.test.tsx | 17 +- .../Reindex/container/Reindex/Reindex.tsx | 70 +++-- .../pages/Reindex/container/Reindex/index.ts | 15 + public/pages/Reindex/index.ts | 15 + public/pages/Reindex/models/interfaces.ts | 15 + public/pages/Reindex/utils/constants.ts | 15 + public/pages/Reindex/utils/helper.test.ts | 39 ++- public/pages/Reindex/utils/helper.ts | 45 ++- .../CreateRepositoryFlyout.tsx | 26 +- .../CreateRepositoryFlyout/constants.ts | 15 + .../CreateRepositoryFlyout/index.ts | 15 + .../components/DeleteModal/DeleteModal.tsx | 19 +- .../components/DeleteModal/index.ts | 15 + .../containers/Repositories/Repositories.tsx | 27 +- .../containers/Repositories/index.ts | 15 + public/pages/Repositories/index.ts | 15 + .../containers/Rollover/Rollover.test.tsx | 17 +- .../Rollover/containers/Rollover/Rollover.tsx | 207 +++++++------ .../Rollover/containers/Rollover/index.ts | 15 + public/pages/Rollover/hooks.tsx | 17 +- public/pages/Rollover/index.ts | 15 + public/pages/Rollover/interface.ts | 15 + .../AggregationAndMetricsSettings.tsx | 55 ++-- .../AggregationAndMetricsSettings/index.ts | 15 + .../GeneralInformation/GeneralInformation.tsx | 16 + .../components/GeneralInformation/index.ts | 15 + .../components/RollupStatus/RollupStatus.tsx | 23 +- .../components/RollupStatus/index.ts | 15 + .../RollupDetails/RollupDetails.test.tsx | 21 +- .../RollupDetails/RollupDetails.tsx | 25 +- .../containers/RollupDetails/index.ts | 15 + public/pages/RollupDetails/index.ts | 15 + public/pages/RollupDetails/utils/helpers.tsx | 19 +- .../components/DeleteModal/DeleteModal.tsx | 21 +- .../Rollups/components/DeleteModal/index.ts | 15 + .../RollupEmptyPrompt/RollupEmptyPrompt.tsx | 19 +- .../components/RollupEmptyPrompt/index.ts | 15 + .../containers/Rollups/Rollups.test.tsx | 17 +- .../Rollups/containers/Rollups/Rollups.tsx | 39 ++- .../pages/Rollups/containers/Rollups/index.ts | 15 + public/pages/Rollups/index.ts | 15 + public/pages/Rollups/models/interfaces.ts | 15 + public/pages/Rollups/utils/constants.tsx | 15 + public/pages/Rollups/utils/helpers.ts | 15 + .../ShrinkIndex/ShrinkIndex.test.tsx | 15 + .../container/ShrinkIndex/ShrinkIndex.tsx | 31 +- .../container/ShrinkIndex/index.ts | 15 + public/pages/ShrinkIndex/index.ts | 15 + public/pages/ShrinkIndex/utils/constants.ts | 15 + public/pages/SnapshotPolicies/constants.tsx | 15 + .../SnapshotPolicies/SnapshotPolicies.tsx | 38 ++- .../containers/SnapshotPolicies/index.ts | 15 + public/pages/SnapshotPolicies/helpers.ts | 17 +- public/pages/SnapshotPolicies/index.ts | 15 + .../components/InfoModal/InfoModal.tsx | 15 + .../components/InfoModal/index.ts | 15 + .../SnapshotPolicyDetails.tsx | 27 +- .../containers/SnapshotPolicyDetails/index.ts | 15 + public/pages/SnapshotPolicyDetails/index.ts | 15 + .../AddPrefixInput/AddPrefixInput.test.tsx | 18 +- .../AddPrefixInput/AddPrefixInput.tsx | 15 + .../components/AddPrefixInput/index.ts | 15 + .../CreateSnapshotFlyout.tsx | 35 ++- .../CreateSnapshotFlyout/constants.ts | 15 + .../components/CreateSnapshotFlyout/index.ts | 15 + .../components/ErrorModal/ErrorModal.tsx | 33 +- .../Snapshots/components/ErrorModal/index.ts | 17 +- .../components/IndexList/IndexList.tsx | 19 +- .../Snapshots/components/IndexList/index.ts | 15 + .../IndexSettingsInput/IndexSettingsInput.tsx | 24 +- .../components/IndexSettingsInput/index.ts | 15 + .../RenameInput/RenameInput.test.tsx | 16 +- .../components/RenameInput/RenameInput.tsx | 28 +- .../Snapshots/components/RenameInput/index.ts | 15 + .../RestoreActivitiesPanel.tsx | 205 +++++++------ .../RestoreActivitiesPanel/index.ts | 15 + .../RestoreSnapshotFlyout.tsx | 178 ++++++----- .../components/RestoreSnapshotFlyout/index.ts | 15 + .../SnapshotFlyout/SnapshotFlyout.tsx | 17 +- .../components/SnapshotFlyout/index.ts | 15 + .../SnapshotIndicesInput.test.tsx | 29 +- .../SnapshotIndicesInput.tsx | 23 +- .../components/SnapshotIndicesInput/index.ts | 15 + .../SnapshotRenameOptions.test.tsx | 43 ++- .../SnapshotRenameOptions.tsx | 25 +- .../components/SnapshotRenameOptions/index.ts | 15 + .../SnapshotRestoreAdvancedOptions.tsx | 46 +-- .../SnapshotRestoreAdvancedOptions/index.ts | 15 + .../SnapshotRestoreOption.test.tsx | 44 ++- .../SnapshotRestoreOption.tsx | 17 +- .../components/SnapshotRestoreOption/index.ts | 15 + public/pages/Snapshots/constants.ts | 18 +- .../containers/Snapshots/Snapshots.tsx | 93 +++--- .../Snapshots/containers/Snapshots/index.ts | 15 + public/pages/Snapshots/helper.tsx | 59 ++-- public/pages/Snapshots/index.ts | 15 + .../SplitIndexForm/SplitIndexForm.tsx | 17 +- .../components/SplitIndexForm/index.ts | 15 + .../container/SplitIndex/SplitIndex.test.tsx | 21 +- .../container/SplitIndex/SplitIndex.tsx | 23 +- .../SplitIndex/container/SplitIndex/index.ts | 15 + public/pages/SplitIndex/index.ts | 15 + .../components/DeleteTemplate/index.tsx | 15 + .../IndexControls/IndexControls.test.tsx | 15 + .../IndexControls/IndexControls.tsx | 15 + .../components/IndexControls/index.ts | 15 + .../AssociatedComponentsModal.test.tsx | 17 +- .../AssociatedComponentsModal.tsx | 19 +- .../AssociatedComponentsModal/index.ts | 15 + .../DeleteTemplateModal.test.tsx | 15 + .../DeleteTemplateModal.tsx | 17 +- .../containers/DeleteTemplatesModal/index.ts | 15 + .../Templates/IndexPatternDisplay.tsx | 20 ++ .../containers/Templates/Templates.test.tsx | 17 +- .../containers/Templates/Templates.tsx | 25 +- .../Templates/containers/Templates/index.ts | 15 + .../TemplatesActions.test.tsx | 17 +- .../containers/TemplatesActions/index.tsx | 16 + public/pages/Templates/index.ts | 15 + public/pages/Templates/interface.ts | 15 + public/pages/Templates/utils/constants.tsx | 15 + .../ConfigureTransform/Configure.tsx | 15 + .../components/ConfigureTransform/index.ts | 15 + .../components/DeleteModal/DeleteModal.tsx | 17 +- .../components/DeleteModal/index.ts | 15 + .../components/ErrorModal/ErrorModal.tsx | 15 + .../Transforms/components/ErrorModal/index.ts | 15 + .../GeneralInformation/GeneralInformation.tsx | 16 + .../components/GeneralInformation/index.ts | 15 + .../Transforms/components/Indices/Indices.tsx | 16 + .../Transforms/components/Indices/index.ts | 15 + .../components/Schedule/Schedule.tsx | 18 +- .../Transforms/components/Schedule/index.ts | 15 + .../TransformEmptyPrompt.tsx | 19 +- .../components/TransformEmptyPrompt/index.ts | 15 + .../TransformStatus/TransformStatus.tsx | 16 + .../components/TransformStatus/index.ts | 15 + .../Transforms/EditTransform.test.tsx | 17 +- .../containers/Transforms/EditTransform.tsx | 47 ++- .../Transforms/TransformDetails.test.tsx | 21 +- .../Transforms/TransformDetails.tsx | 37 ++- .../Transforms/TransformSettings.tsx | 21 +- .../containers/Transforms/Transforms.test.tsx | 17 +- .../containers/Transforms/Transforms.tsx | 25 +- .../Transforms/containers/Transforms/index.ts | 15 + public/pages/Transforms/index.ts | 15 + public/pages/Transforms/models/interfaces.ts | 15 + public/pages/Transforms/utils/constants.tsx | 15 + public/pages/Transforms/utils/helpers.ts | 17 +- .../pages/Transforms/utils/metadataHelper.tsx | 25 +- .../components/Badge/Badge.test.tsx | 15 + .../components/Badge/Badge.tsx | 15 + .../components/Badge/index.ts | 15 + .../ChannelNotification.test.tsx | 17 +- .../ChannelNotification.tsx | 15 + .../components/ChannelNotification/index.ts | 15 + .../DraggableItem/DraggableItem.test.tsx | 17 +- .../DraggableItem/DraggableItem.tsx | 15 + .../components/DraggableItem/index.ts | 15 + .../EuiFormCustomLabel.test.tsx | 15 + .../EuiFormCustomLabel/EuiFormCustomLabel.tsx | 15 + .../components/EuiFormCustomLabel/index.ts | 15 + .../FlyoutFooter/FlyoutFooter.test.tsx | 17 +- .../components/FlyoutFooter/FlyoutFooter.tsx | 15 + .../components/FlyoutFooter/index.ts | 15 + .../ISMTemplate/ISMTemplate.test.tsx | 17 +- .../components/ISMTemplate/ISMTemplate.tsx | 17 +- .../components/ISMTemplate/index.ts | 15 + .../ISMTemplates/ISMTemplates.test.tsx | 15 + .../components/ISMTemplates/ISMTemplates.tsx | 19 +- .../components/ISMTemplates/index.ts | 15 + .../LegacyNotification.test.tsx | 15 + .../LegacyNotification/LegacyNotification.tsx | 15 + .../components/LegacyNotification/index.ts | 15 + .../components/PolicyInfo/PolicyInfo.test.tsx | 17 +- .../components/PolicyInfo/PolicyInfo.tsx | 15 + .../components/PolicyInfo/index.ts | 15 + .../components/States/State.test.tsx | 17 +- .../components/States/State.tsx | 17 +- .../components/States/States.test.tsx | 17 +- .../components/States/States.tsx | 20 +- .../components/States/index.ts | 15 + .../TimeoutRetrySettings.test.tsx | 15 + .../TimeoutRetrySettings.tsx | 15 + .../components/TimeoutRetrySettings/index.ts | 15 + .../components/Transition/Transition.test.tsx | 15 + .../components/Transition/Transition.tsx | 16 + .../Transition/TransitionContent.test.tsx | 15 + .../Transition/TransitionContent.tsx | 15 + .../components/Transition/index.ts | 15 + .../AliasUIAction/AliasUIAction.test.tsx | 15 + .../UIActions/AliasUIAction/AliasUIAction.tsx | 23 +- .../AliasUIAction/AliasUIActionComponent.tsx | 21 +- .../UIActions/AllocationUIAction.tsx | 15 + .../components/UIActions/CloseUIAction.tsx | 15 + .../components/UIActions/DeleteUIAction.tsx | 15 + .../UIActions/ForceMergeUIAction.tsx | 15 + .../UIActions/IndexPriorityUIAction.tsx | 16 + .../UIActions/NotificationUIAction.tsx | 15 + .../components/UIActions/OpenUIAction.tsx | 15 + .../components/UIActions/ReadOnlyUIAction.tsx | 15 + .../UIActions/ReadWriteUIAction.tsx | 15 + .../UIActions/ReplicaCountUIAction.tsx | 15 + .../components/UIActions/RolloverUIAction.tsx | 19 ++ .../components/UIActions/RollupUIAction.tsx | 15 + .../components/UIActions/ShrinkUIAction.tsx | 17 +- .../components/UIActions/SnapshotUIAction.tsx | 15 + .../components/UIActions/index.ts | 15 + .../CreateAction/CreateAction.test.tsx | 15 + .../containers/CreateAction/CreateAction.tsx | 19 +- .../containers/CreateAction/index.ts | 15 + .../containers/CreateState/Actions.test.tsx | 20 +- .../containers/CreateState/Actions.tsx | 17 +- .../CreateState/CreateState.test.tsx | 15 + .../containers/CreateState/CreateState.tsx | 23 +- .../CreateState/Transitions.test.tsx | 15 + .../containers/CreateState/Transitions.tsx | 15 + .../containers/CreateState/index.ts | 15 + .../CreateTransition.test.tsx | 15 + .../CreateTransition/CreateTransition.tsx | 17 +- .../containers/CreateTransition/index.ts | 15 + .../ErrorNotification.test.tsx | 15 + .../ErrorNotification/ErrorNotification.tsx | 15 + .../containers/ErrorNotification/index.ts | 15 + .../VisualCreatePolicy/VisualCreatePolicy.tsx | 25 +- .../containers/VisualCreatePolicy/index.ts | 15 + public/pages/VisualCreatePolicy/index.ts | 15 + .../VisualCreatePolicy/utils/constants.ts | 15 + .../VisualCreatePolicy/utils/helpers.test.ts | 15 + .../pages/VisualCreatePolicy/utils/helpers.ts | 28 +- public/plugin.ts | 15 + public/services/CommonService.test.ts | 15 + public/services/CommonService.ts | 17 +- public/services/IndexService.test.ts | 15 + public/services/IndexService.ts | 17 +- public/services/ManagedIndexService.test.ts | 15 + public/services/ManagedIndexService.ts | 17 +- public/services/NotificationService.test.ts | 15 + public/services/NotificationService.ts | 19 +- public/services/PolicyService.test.ts | 15 + public/services/PolicyService.ts | 19 +- public/services/RollupService.test.ts | 15 + public/services/RollupService.ts | 23 +- public/services/Services.ts | 15 + public/services/SnapshotManagementService.ts | 31 +- public/services/TransformService.test.ts | 19 +- public/services/TransformService.ts | 21 +- public/services/index.ts | 15 + public/temporary/AsyncInterval.ts | 19 +- public/temporary/EuiRefreshPicker.tsx | 15 + .../JSON_schemas/index_mappings/index.ts | 22 +- .../index_mappings/index_mappings.test.ts | 15 + .../index_mappings/property_item.ts | 20 ++ public/utils/constants.ts | 23 +- public/utils/helpers.test.ts | 15 + public/utils/helpers.ts | 27 +- server/clusters/index.ts | 15 + server/clusters/ism/createISMCluster.ts | 15 + server/clusters/ism/ismPlugin.ts | 15 + server/index.ts | 17 ++ server/models/interfaces.ts | 29 +- server/models/types.ts | 37 ++- server/plugin.ts | 15 + server/routes/aliases.ts | 15 + server/routes/common.ts | 15 + server/routes/dataStreams.ts | 15 + server/routes/index.ts | 15 + server/routes/indices.ts | 15 + server/routes/managedIndices.ts | 15 + server/routes/notifications.ts | 17 +- server/routes/policies.ts | 15 + server/routes/rollups.ts | 15 + server/routes/snapshotManagement.ts | 17 +- server/routes/transforms.ts | 19 +- server/services/AliasServices.ts | 17 +- server/services/CommonService.test.ts | 20 ++ server/services/CommonService.ts | 19 +- server/services/DataStreamService.ts | 19 +- server/services/IndexService.ts | 15 + server/services/ManagedIndexService.ts | 34 ++- server/services/NotificationService.ts | 15 + server/services/PolicyService.ts | 17 +- server/services/RollupService.ts | 25 +- server/services/SnapshotManagementService.ts | 35 ++- server/services/TransformService.ts | 33 +- server/services/index.ts | 15 + server/utils/constants.ts | 15 + server/utils/helpers.ts | 15 + test/constants.ts | 79 +++-- test/mocks/browserServicesMock.ts | 15 + test/mocks/coreServicesMock.ts | 15 + test/mocks/historyMock.ts | 15 + test/mocks/httpClientMock.ts | 15 + test/mocks/index.ts | 15 + test/mocks/styleMock.ts | 15 + test/polyfills.ts | 15 + test/setup.jest.ts | 20 ++ test/setupTests.ts | 15 + tsconfig.json | 3 +- utils/constants.ts | 15 + utils/helper.ts | 20 ++ 821 files changed, 14952 insertions(+), 2249 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 562ff10ff..cb52838e4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,12 +1,17 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - const LICENSE_HEADER = ` /* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. */ `; @@ -15,6 +20,28 @@ module.exports = { extends: ["@elastic/eslint-config-kibana", "plugin:@elastic/eui/recommended"], rules: { // "@osd/eslint/require-license-header": "off" + "import/no-default-export": "off", + "@typescript-eslint/naming-convention": [ + "error", + { + selector: "default", + format: ["camelCase", "UPPER_CASE", "PascalCase", "snake_case"], + leadingUnderscore: "allow", + trailingUnderscore: "allow", + }, + ], + "@osd/eslint/no-restricted-paths": [ + "error", + { + basePath: __dirname, + zones: [ + { + target: ["(public|server)/**/*"], + from: ["../../packages/**/*", "packages/**/*"], + }, + ], + }, + ], }, overrides: [ { diff --git a/.lintstagedrc b/.lintstagedrc index e7e7db117..e155bc449 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -1,3 +1,9 @@ { - "*.{ts,tsx,js,jsx,json,css,md}": ["prettier --write", "git add"] + "*.{ts,tsx}": [ + "npx eslint --fix", + "prettier --write" + ], + "*.{js,jsx,json,css,md}": [ + "prettier --write" + ] } diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts index 091fe9f91..6f42566f4 100644 --- a/cypress/support/index.d.ts +++ b/cypress/support/index.d.ts @@ -1,9 +1,24 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ -/// +// / declare namespace Cypress { interface Chainable { diff --git a/models/interfaces.ts b/models/interfaces.ts index 062dd49e8..d6425702d 100644 --- a/models/interfaces.ts +++ b/models/interfaces.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -41,13 +56,13 @@ export type DiffableMappingsPropertiesObject = Record< } >; -export type MappingsProperties = { +export type MappingsProperties = Array<{ fieldName: string; type: string; path?: string; analyzer?: string; properties?: MappingsProperties; -}[]; +}>; export interface IndexItem { index: string; @@ -525,14 +540,14 @@ export interface Transform { enabled_at: number | null; updated_at: number; metadata_id: string | null; - aggregations: Map; + aggregations: Map; page_size: number; schedule: IntervalSchedule | CronSchedule; schema_version: number; source_index: string; target_index: string; - roles: String[]; - data_selection_query: Map; + roles: string[]; + data_selection_query: Map; } export interface TransformMetadata { @@ -571,7 +586,7 @@ export interface CronSchedule { }; } -//Frontend dimension data model +// Frontend dimension data model export interface DimensionItem { sequence: number; field: FieldItem; @@ -579,7 +594,7 @@ export interface DimensionItem { interval?: number; } -//Frontend metric data model +// Frontend metric data model export interface MetricItem { source_field: FieldItem; all: boolean; @@ -620,18 +635,23 @@ interface HistogramItem { }; } -//Backend dimension data model +// Backend dimension data model export type RollupDimensionItem = DateHistogramItem | TermsItem | HistogramItem; -//Backend metric data model +// Backend metric data model export interface RollupMetricItem { source_field: string; metrics: [ { + // eslint-disable-next-line @typescript-eslint/ban-types min?: Object; + // eslint-disable-next-line @typescript-eslint/ban-types max?: Object; + // eslint-disable-next-line @typescript-eslint/ban-types sum?: Object; + // eslint-disable-next-line @typescript-eslint/ban-types avg?: Object; + // eslint-disable-next-line @typescript-eslint/ban-types value_count?: Object; } ]; diff --git a/package.json b/package.json index 7c079c666..b2018485c 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "osd": "node ../../scripts/osd", "opensearch": "node ../../scripts/opensearch", "lint": "node ../../scripts/eslint . && node ../../scripts/stylelint", + "eslint:fix": "npx eslint '**/*.{ts,tsx}' --fix", "plugin-helpers": "node ../../scripts/plugin_helpers", "test:jest": "../../node_modules/.bin/jest --config ./test/jest.config.js", "build": "yarn plugin-helpers build", @@ -73,4 +74,4 @@ "engines": { "yarn": "^1.21.1" } -} \ No newline at end of file +} diff --git a/public/JobHandler/callbacks/force_merge.test.tsx b/public/JobHandler/callbacks/force_merge.test.tsx index 049a971e9..2b5e0774a 100644 --- a/public/JobHandler/callbacks/force_merge.test.tsx +++ b/public/JobHandler/callbacks/force_merge.test.tsx @@ -1,12 +1,27 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ +import { CoreSetup } from "opensearch-dashboards/public"; import { callbackForForceMerge, callbackForForceMergeTimeout } from "./force_merge"; import { coreServicesMock, httpClientMock } from "../../../test/mocks"; import { ListenType } from "../../lib/JobScheduler"; -import { CoreSetup } from "opensearch-dashboards/public"; const getMockFn = (response = {}, ok = true) => { return jest.fn().mockResolvedValue({ @@ -33,7 +48,7 @@ const core = ({ describe("callbackForForceMerge spec", () => { it("callback when error", async () => { httpClientMock.fetch = getMockFn({}, false); - let result = await callbackForForceMerge(forceMergeMetaData, { + const result = await callbackForForceMerge(forceMergeMetaData, { core, }); expect(result).toBe(false); diff --git a/public/JobHandler/callbacks/force_merge.tsx b/public/JobHandler/callbacks/force_merge.tsx index b1685ec5e..7555f9f54 100644 --- a/public/JobHandler/callbacks/force_merge.tsx +++ b/public/JobHandler/callbacks/force_merge.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -15,11 +30,11 @@ type ForceMergeTaskResult = TaskResult<{ successful: number; total: number; failed: number; - failures?: { + failures?: Array<{ index: string; status: string; shard: number; - }[]; + }>; }; }>; diff --git a/public/JobHandler/callbacks/open.test.tsx b/public/JobHandler/callbacks/open.test.tsx index e6e265d8f..241219e48 100644 --- a/public/JobHandler/callbacks/open.test.tsx +++ b/public/JobHandler/callbacks/open.test.tsx @@ -1,11 +1,26 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ +import { CoreSetup } from "opensearch-dashboards/public"; import { callbackForOpen, callbackForOpenTimeout } from "./open"; import { coreServicesMock, httpClientMock } from "../../../test/mocks"; import { ListenType } from "../../lib/JobScheduler"; -import { CoreSetup } from "opensearch-dashboards/public"; const getMockFn = (response = {}, ok = true) => { return jest.fn().mockResolvedValue({ @@ -32,7 +47,7 @@ const core = ({ describe("callbackForOpen spec", () => { it("callback when error", async () => { httpClientMock.fetch = getMockFn({}, false); - let result = await callbackForOpen(openMetaData, { + const result = await callbackForOpen(openMetaData, { core, }); expect(result).toBe(false); diff --git a/public/JobHandler/callbacks/open.tsx b/public/JobHandler/callbacks/open.tsx index 28056345c..935e4dca4 100644 --- a/public/JobHandler/callbacks/open.tsx +++ b/public/JobHandler/callbacks/open.tsx @@ -1,7 +1,18 @@ /* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. */ + import React from "react"; import { CallbackType, TaskResult } from "../interface"; import { OpenJobMetaData } from "../../models/interfaces"; diff --git a/public/JobHandler/callbacks/reindex.test.tsx b/public/JobHandler/callbacks/reindex.test.tsx index aae3276f1..33ba7b641 100644 --- a/public/JobHandler/callbacks/reindex.test.tsx +++ b/public/JobHandler/callbacks/reindex.test.tsx @@ -1,11 +1,26 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ +import { CoreSetup } from "opensearch-dashboards/public"; import { callbackForReindex, callbackForReindexTimeout } from "./reindex"; import { coreServicesMock, httpClientMock } from "../../../test/mocks"; import { ListenType } from "../../lib/JobScheduler"; -import { CoreSetup } from "opensearch-dashboards/public"; const getMockFn = (response = {}, ok = true) => { return jest.fn().mockResolvedValue({ @@ -35,7 +50,7 @@ const core = ({ describe("callbackForOpen spec", () => { it("callback when error", async () => { httpClientMock.fetch = getMockFn({}, false); - let result = await callbackForReindex(reindexMetaData, { + const result = await callbackForReindex(reindexMetaData, { core, }); expect(result).toBe(false); diff --git a/public/JobHandler/callbacks/reindex.tsx b/public/JobHandler/callbacks/reindex.tsx index 16cf3f9a9..7a9ef45aa 100644 --- a/public/JobHandler/callbacks/reindex.tsx +++ b/public/JobHandler/callbacks/reindex.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -13,12 +28,12 @@ import { ErrorToastContentForJob } from "../components/ErrorToastContentForJob"; type ReindexTaskResult = TaskResult<{ canceled?: string; - failures: { + failures: Array<{ cause?: { reason: string; }; id?: string; - }[]; + }>; }>; export const callbackForReindex: CallbackType = async (job: ReindexJobMetaData, { core }) => { diff --git a/public/JobHandler/callbacks/shrink.test.tsx b/public/JobHandler/callbacks/shrink.test.tsx index 293461a3f..16702214d 100644 --- a/public/JobHandler/callbacks/shrink.test.tsx +++ b/public/JobHandler/callbacks/shrink.test.tsx @@ -1,11 +1,26 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ +import { CoreSetup } from "opensearch-dashboards/public"; import { callbackForShrink, callbackForShrinkTimeout } from "./shrink"; import { coreServicesMock, httpClientMock } from "../../../test/mocks"; import { ListenType } from "../../lib/JobScheduler"; -import { CoreSetup } from "opensearch-dashboards/public"; const getMockFn = (response = {}, ok = true) => { return jest.fn().mockResolvedValue({ @@ -33,7 +48,7 @@ const core = ({ describe("callbackForOpen spec", () => { it("callback when error", async () => { httpClientMock.fetch = getMockFn({}, false); - let result = await callbackForShrink(shrinkMetaData, { + const result = await callbackForShrink(shrinkMetaData, { core, }); expect(result).toBe(false); diff --git a/public/JobHandler/callbacks/shrink.tsx b/public/JobHandler/callbacks/shrink.tsx index 34e90b699..91518aedb 100644 --- a/public/JobHandler/callbacks/shrink.tsx +++ b/public/JobHandler/callbacks/shrink.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/JobHandler/callbacks/split.test.tsx b/public/JobHandler/callbacks/split.test.tsx index 04f920c2c..4eb738785 100644 --- a/public/JobHandler/callbacks/split.test.tsx +++ b/public/JobHandler/callbacks/split.test.tsx @@ -1,11 +1,26 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ +import { CoreSetup } from "opensearch-dashboards/public"; import { callbackForSplit, callbackForSplitTimeout } from "./split"; import { coreServicesMock, httpClientMock } from "../../../test/mocks"; import { ListenType } from "../../lib/JobScheduler"; -import { CoreSetup } from "opensearch-dashboards/public"; const getMockFn = (response = {}, ok = true) => { return jest.fn().mockResolvedValue({ @@ -33,7 +48,7 @@ const core = ({ describe("callbackForOpen spec", () => { it("callback when error", async () => { httpClientMock.fetch = getMockFn({}, false); - let result = await callbackForSplit(splitMetaData, { + const result = await callbackForSplit(splitMetaData, { core, }); expect(result).toBe(false); diff --git a/public/JobHandler/callbacks/split.tsx b/public/JobHandler/callbacks/split.tsx index 260a578e0..68ed93da5 100644 --- a/public/JobHandler/callbacks/split.tsx +++ b/public/JobHandler/callbacks/split.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/JobHandler/components/DetailLink.tsx b/public/JobHandler/components/DetailLink.tsx index 276c9d756..727306c4d 100644 --- a/public/JobHandler/components/DetailLink.tsx +++ b/public/JobHandler/components/DetailLink.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/JobHandler/components/ErrorToastContentForJob.tsx b/public/JobHandler/components/ErrorToastContentForJob.tsx index 586fde083..097238645 100644 --- a/public/JobHandler/components/ErrorToastContentForJob.tsx +++ b/public/JobHandler/components/ErrorToastContentForJob.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/JobHandler/components/FormatResourceWithClusterInfo.tsx b/public/JobHandler/components/FormatResourceWithClusterInfo.tsx index e73dc7dbe..5f7351d2a 100644 --- a/public/JobHandler/components/FormatResourceWithClusterInfo.tsx +++ b/public/JobHandler/components/FormatResourceWithClusterInfo.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/JobHandler/components/components.test.tsx b/public/JobHandler/components/components.test.tsx index 1556f418a..054e6123a 100644 --- a/public/JobHandler/components/components.test.tsx +++ b/public/JobHandler/components/components.test.tsx @@ -1,12 +1,27 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import React from "react"; import { render } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; import { DetailLink } from "./DetailLink"; import { ErrorToastContentForJob } from "./ErrorToastContentForJob"; -import userEvent from "@testing-library/user-event"; import { FormatResourceWithClusterInfo, FormatResourcesWithClusterInfo } from "./FormatResourceWithClusterInfo"; describe(" spec", () => { diff --git a/public/JobHandler/index.ts b/public/JobHandler/index.ts index 1798e4625..f13f2480f 100644 --- a/public/JobHandler/index.ts +++ b/public/JobHandler/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/JobHandler/interface.ts b/public/JobHandler/interface.ts index 08d42638a..24fc198f0 100644 --- a/public/JobHandler/interface.ts +++ b/public/JobHandler/interface.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -12,7 +27,7 @@ export type CallbackType = ( } ) => Promise; -export type TaskResult = { +export interface TaskResult { found: boolean; _source: { completed: boolean; @@ -22,7 +37,7 @@ export type TaskResult = { reason: string; }; }; -}; +} export type RecoveryTaskResult = TaskResult<{ acknowledged: boolean; diff --git a/public/JobHandler/utils.ts b/public/JobHandler/utils.ts index a8fdcb99d..c024b310b 100644 --- a/public/JobHandler/utils.ts +++ b/public/JobHandler/utils.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/AdvancedSettings/AdvancedSettings.test.tsx b/public/components/AdvancedSettings/AdvancedSettings.test.tsx index 037111627..cb1c8c4ac 100644 --- a/public/components/AdvancedSettings/AdvancedSettings.test.tsx +++ b/public/components/AdvancedSettings/AdvancedSettings.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -5,8 +20,8 @@ import React from "react"; import { fireEvent, render } from "@testing-library/react"; -import AdvancedSettings from "./index"; import userEvent from "@testing-library/user-event"; +import AdvancedSettings from "./index"; describe(" spec", () => { it("render the component", () => { diff --git a/public/components/AdvancedSettings/index.tsx b/public/components/AdvancedSettings/index.tsx index d78419640..2eab5dc44 100644 --- a/public/components/AdvancedSettings/index.tsx +++ b/public/components/AdvancedSettings/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -40,8 +55,11 @@ function AdvancedSettings(props: IAdvancedSettingsProps, ref: React.Ref, "value" | "onChange"> { value?: Record; onChange?: (value: AliasSelectProps["value"]) => void; - refreshOptions: (aliasName: string) => Promise>; + refreshOptions: (aliasName: string) => Promise>>; onOptionsChange?: RemoteSelectProps["onOptionsChange"]; } const AliasSelect = forwardRef((props: AliasSelectProps, ref: React.Ref) => { const { value, onChange, refreshOptions: refreshOptionsFromProps, onOptionsChange } = props; - const optionsRef = useRef<{ label: string; [key: string]: any }[]>([]); + const optionsRef = useRef>([]); const refreshOptions: RemoteSelectProps["refreshOptions"] = ({ searchValue }) => { return refreshOptionsFromProps(searchValue || "").then((res) => { if (res?.ok) { @@ -51,12 +66,13 @@ const AliasSelect = forwardRef((props: AliasSelectProps, ref: React.Ref { - onChange && + if (onChange) { onChange( val .map((label) => optionsRef.current.find((item) => item.label === label) || { label }) .reduce((total, { label, ...others }) => ({ ...total, [label]: others || {} }), {}) ); + } }} /> ); @@ -64,5 +80,4 @@ const AliasSelect = forwardRef((props: AliasSelectProps, ref: React.Ref spec", () => { it("renders the component", () => { diff --git a/public/components/ChannelNotification/ChannelNotification.tsx b/public/components/ChannelNotification/ChannelNotification.tsx index af195be02..3bf9fcf97 100644 --- a/public/components/ChannelNotification/ChannelNotification.tsx +++ b/public/components/ChannelNotification/ChannelNotification.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/ChannelNotification/index.ts b/public/components/ChannelNotification/index.ts index 153112fbc..6d0a4be20 100644 --- a/public/components/ChannelNotification/index.ts +++ b/public/components/ChannelNotification/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/ComboBoxWithoutWarning/index.tsx b/public/components/ComboBoxWithoutWarning/index.tsx index 19c297006..12b0e0dc4 100644 --- a/public/components/ComboBoxWithoutWarning/index.tsx +++ b/public/components/ComboBoxWithoutWarning/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/ComponentTemplateBadge/ComponentTemplateBadge.tsx b/public/components/ComponentTemplateBadge/ComponentTemplateBadge.tsx index e512842e2..e508628ea 100644 --- a/public/components/ComponentTemplateBadge/ComponentTemplateBadge.tsx +++ b/public/components/ComponentTemplateBadge/ComponentTemplateBadge.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/ComponentTemplateBadge/index.ts b/public/components/ComponentTemplateBadge/index.ts index 5906902a5..df2d13798 100644 --- a/public/components/ComponentTemplateBadge/index.ts +++ b/public/components/ComponentTemplateBadge/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/ConfirmationModal/ConfirmationModal.test.tsx b/public/components/ConfirmationModal/ConfirmationModal.test.tsx index db33807c0..4e15228fa 100644 --- a/public/components/ConfirmationModal/ConfirmationModal.test.tsx +++ b/public/components/ConfirmationModal/ConfirmationModal.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/ConfirmationModal/ConfirmationModal.tsx b/public/components/ConfirmationModal/ConfirmationModal.tsx index 93d9cf746..8ed7a2ffd 100644 --- a/public/components/ConfirmationModal/ConfirmationModal.tsx +++ b/public/components/ConfirmationModal/ConfirmationModal.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -26,7 +41,7 @@ interface ConfirmationModalProps { onAction: () => void; } -const ConfirmationModal: React.SFC = ({ +const ConfirmationModal: React.FC = ({ title, bodyMessage, actionMessage, diff --git a/public/components/ConfirmationModal/index.ts b/public/components/ConfirmationModal/index.ts index fda88df80..5cd074351 100644 --- a/public/components/ConfirmationModal/index.ts +++ b/public/components/ConfirmationModal/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/ContentPanel/ContentPanel.test.tsx b/public/components/ContentPanel/ContentPanel.test.tsx index 577dc5f27..f975b4599 100644 --- a/public/components/ContentPanel/ContentPanel.test.tsx +++ b/public/components/ContentPanel/ContentPanel.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/ContentPanel/ContentPanel.tsx b/public/components/ContentPanel/ContentPanel.tsx index d3689f90c..85e233e51 100644 --- a/public/components/ContentPanel/ContentPanel.tsx +++ b/public/components/ContentPanel/ContentPanel.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -43,7 +58,7 @@ const renderSubTitleText = (subTitleText: string | JSX.Element): JSX.Element | n return subTitleText; }; -const ContentPanel: React.SFC = ({ +const ContentPanel: React.FC = ({ title = "", titleSize = "l", subTitleText = "", diff --git a/public/components/ContentPanel/ContentPanelActions.test.tsx b/public/components/ContentPanel/ContentPanelActions.test.tsx index 6fd341545..cb5c0e7d8 100644 --- a/public/components/ContentPanel/ContentPanelActions.test.tsx +++ b/public/components/ContentPanel/ContentPanelActions.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/ContentPanel/ContentPanelActions.tsx b/public/components/ContentPanel/ContentPanelActions.tsx index fc8136093..bfd131e28 100644 --- a/public/components/ContentPanel/ContentPanelActions.tsx +++ b/public/components/ContentPanel/ContentPanelActions.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -8,7 +23,7 @@ import { EuiButton, EuiFlexGroup, EuiFlexItem } from "@elastic/eui"; import { ModalConsumer } from "../Modal"; interface ContentPanelActionsProps { - actions: { + actions: Array<{ text: string; buttonProps?: object; flexItemProps?: object; @@ -16,10 +31,10 @@ interface ContentPanelActionsProps { modal?: { onClickModal: (onShow: (component: any, props: object) => void) => () => void; }; - }[]; + }>; } -const ContentPanelActions: React.SFC = ({ actions }) => ( +const ContentPanelActions: React.FC = ({ actions }) => ( {actions.map(({ text, buttonProps = {}, flexItemProps = {}, modal = null, children }, index) => { let button = children ? ( diff --git a/public/components/ContentPanel/index.ts b/public/components/ContentPanel/index.ts index de17791e4..f47257c1e 100644 --- a/public/components/ContentPanel/index.ts +++ b/public/components/ContentPanel/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/CreatePolicyModal/CreatePolicyModal.test.tsx b/public/components/CreatePolicyModal/CreatePolicyModal.test.tsx index e1700bbd1..7e50ea854 100644 --- a/public/components/CreatePolicyModal/CreatePolicyModal.test.tsx +++ b/public/components/CreatePolicyModal/CreatePolicyModal.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/CreatePolicyModal/CreatePolicyModal.tsx b/public/components/CreatePolicyModal/CreatePolicyModal.tsx index 9838b179d..c39ce105e 100644 --- a/public/components/CreatePolicyModal/CreatePolicyModal.tsx +++ b/public/components/CreatePolicyModal/CreatePolicyModal.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -27,7 +42,7 @@ interface CreatePolicyModalProps { onClickContinue: (visual: boolean) => void; } -const CreatePolicyModal: React.SFC = ({ isEdit = false, onClose, onClickContinue }) => { +const CreatePolicyModal: React.FC = ({ isEdit = false, onClose, onClickContinue }) => { const [visual, setVisual] = useState(true); return ( diff --git a/public/components/CreatePolicyModal/index.ts b/public/components/CreatePolicyModal/index.ts index 058ab3e28..e39806e57 100644 --- a/public/components/CreatePolicyModal/index.ts +++ b/public/components/CreatePolicyModal/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/CustomFormRow/CustomFormRow.test.tsx b/public/components/CustomFormRow/CustomFormRow.test.tsx index d0e6c72f8..23a3e4023 100644 --- a/public/components/CustomFormRow/CustomFormRow.test.tsx +++ b/public/components/CustomFormRow/CustomFormRow.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/CustomFormRow/index.tsx b/public/components/CustomFormRow/index.tsx index 400f1b4f1..8e00649d8 100644 --- a/public/components/CustomFormRow/index.tsx +++ b/public/components/CustomFormRow/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/CustomLabel/CustomLabel.tsx b/public/components/CustomLabel/CustomLabel.tsx index 61f52bd24..a990e3612 100644 --- a/public/components/CustomLabel/CustomLabel.tsx +++ b/public/components/CustomLabel/CustomLabel.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/CustomLabel/index.ts b/public/components/CustomLabel/index.ts index 5188f6e70..1c9e68d89 100644 --- a/public/components/CustomLabel/index.ts +++ b/public/components/CustomLabel/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/DarkMode/DarkMode.tsx b/public/components/DarkMode/DarkMode.tsx index 45eb59734..07ab73bf9 100644 --- a/public/components/DarkMode/DarkMode.tsx +++ b/public/components/DarkMode/DarkMode.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/DarkMode/index.ts b/public/components/DarkMode/index.ts index b68055225..9e212937c 100644 --- a/public/components/DarkMode/index.ts +++ b/public/components/DarkMode/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/DeleteModal/DeleteModal.test.tsx b/public/components/DeleteModal/DeleteModal.test.tsx index 87236b36e..f1228ef4b 100644 --- a/public/components/DeleteModal/DeleteModal.test.tsx +++ b/public/components/DeleteModal/DeleteModal.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/DeleteModal/DeleteModal.tsx b/public/components/DeleteModal/DeleteModal.tsx index aa51df14d..e5a05b986 100644 --- a/public/components/DeleteModal/DeleteModal.tsx +++ b/public/components/DeleteModal/DeleteModal.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/DeleteModal/index.ts b/public/components/DeleteModal/index.ts index bb5f76385..4e6674fe0 100644 --- a/public/components/DeleteModal/index.ts +++ b/public/components/DeleteModal/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/DescriptionListHoz/DescriptionListHoz.test.tsx b/public/components/DescriptionListHoz/DescriptionListHoz.test.tsx index 59f418bc1..431b805bd 100644 --- a/public/components/DescriptionListHoz/DescriptionListHoz.test.tsx +++ b/public/components/DescriptionListHoz/DescriptionListHoz.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/DescriptionListHoz/DescriptionListHoz.tsx b/public/components/DescriptionListHoz/DescriptionListHoz.tsx index 87b47d419..6f34c8488 100644 --- a/public/components/DescriptionListHoz/DescriptionListHoz.tsx +++ b/public/components/DescriptionListHoz/DescriptionListHoz.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/DescriptionListHoz/index.ts b/public/components/DescriptionListHoz/index.ts index 6816f55f5..ea354b2fa 100644 --- a/public/components/DescriptionListHoz/index.ts +++ b/public/components/DescriptionListHoz/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/EuiToolTipWrapper/EuiToolTipWrapper.test.tsx b/public/components/EuiToolTipWrapper/EuiToolTipWrapper.test.tsx index 2abc9fcb7..bb2278ae7 100644 --- a/public/components/EuiToolTipWrapper/EuiToolTipWrapper.test.tsx +++ b/public/components/EuiToolTipWrapper/EuiToolTipWrapper.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/EuiToolTipWrapper/index.tsx b/public/components/EuiToolTipWrapper/index.tsx index fd651068c..8108ea789 100644 --- a/public/components/EuiToolTipWrapper/index.tsx +++ b/public/components/EuiToolTipWrapper/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -12,10 +27,10 @@ interface IEuiToolTipWrapperOptions { export interface IEuiToolTipWrapperProps { disabledReason?: | string - | { + | Array<{ visible: boolean; message: string; - }[]; + }>; } export default function EuiToolTipWrapper( diff --git a/public/components/FilterGroup/FilterGroup.test.tsx b/public/components/FilterGroup/FilterGroup.test.tsx index 7e0c63059..325564853 100644 --- a/public/components/FilterGroup/FilterGroup.test.tsx +++ b/public/components/FilterGroup/FilterGroup.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -5,8 +20,8 @@ import React, { useState } from "react"; import { act, render, waitFor } from "@testing-library/react"; -import FilterGroup, { IFilterGroupProps } from "./index"; import userEvent from "@testing-library/user-event"; +import FilterGroup, { IFilterGroupProps } from "./index"; const WrappedComponent = (props: IFilterGroupProps) => { const [value, onChange] = useState(); diff --git a/public/components/FilterGroup/index.tsx b/public/components/FilterGroup/index.tsx index 858d83775..0ac76f8b3 100644 --- a/public/components/FilterGroup/index.tsx +++ b/public/components/FilterGroup/index.tsx @@ -1,8 +1,28 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import { EuiFilterButton, EuiFilterButtonProps, EuiFilterGroup, EuiFilterSelectItem, EuiPopover } from "@elastic/eui"; import React, { useState } from "react"; export interface IFilterGroupProps { - options: { label: string }[]; + options: Array<{ label: string }>; value?: string[]; filterButtonProps?: EuiFilterButtonProps; onChange?: (val: IFilterGroupProps["value"]) => void; diff --git a/public/components/FormGenerator/FormGenerator.test.tsx b/public/components/FormGenerator/FormGenerator.test.tsx index adc218843..10375e745 100644 --- a/public/components/FormGenerator/FormGenerator.test.tsx +++ b/public/components/FormGenerator/FormGenerator.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/FormGenerator/built_in_components/index.tsx b/public/components/FormGenerator/built_in_components/index.tsx index c1e3eb3a9..25148b6b7 100644 --- a/public/components/FormGenerator/built_in_components/index.tsx +++ b/public/components/FormGenerator/built_in_components/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -74,13 +89,13 @@ const componentMap: Record { - const allOptions = (options as { label: string; options?: { label: string }[] }[]).reduce((total, current) => { + const allOptions = (options as Array<{ label: string; options?: Array<{ label: string }> }>).reduce((total, current) => { if (current.options) { return [...total, ...current.options]; } else { return [...total, current]; } - }, [] as { label: string }[]); + }, [] as Array<{ label: string }>); const findItem = allOptions.find((item: { label: string }) => item.label === searchValue); if (findItem) { onChange(searchValue); @@ -111,8 +126,8 @@ const componentMap: Record[]; - onChange: (val: string[], values: EuiComboBoxOptionOption[], ...args: any) => void; + options: Array>; + onChange: (val: string[], values: Array>, ...args: any) => void; }, ref: React.Ref ) => { @@ -125,7 +140,7 @@ const componentMap: Record[]); + }, [] as Array>); const findItem = allOptions.find((item: { label: string }) => item.label === searchValue); if (findItem) { onChange( @@ -147,7 +162,7 @@ const componentMap: Record others.options.find((option) => option.value === item) || { label: item, value: item }) - .filter((item) => item !== undefined) as EuiComboBoxOptionOption[] + .filter((item) => item !== undefined) as Array> } /> ); diff --git a/public/components/FormGenerator/index.tsx b/public/components/FormGenerator/index.tsx index 2c6e449cf..f205c8c61 100644 --- a/public/components/FormGenerator/index.tsx +++ b/public/components/FormGenerator/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -44,7 +59,7 @@ export interface IFormGeneratorProps { onChange?: (totalValue: IFormGeneratorProps["value"], key?: FieldName, value?: any) => void; } -export interface IFormGeneratorRef extends FieldInstance {} +export type IFormGeneratorRef = FieldInstance; export { AllBuiltInComponents }; @@ -57,10 +72,10 @@ function FormGenerator(props: IFormGeneratorProps, re const field = useField({ ...fieldProps, onChange(name: FieldName, value: any) { - propsRef.current.onChange && propsRef.current.onChange({ ...field.getValues() }, name, value); + if (propsRef.current.onChange) propsRef.current.onChange({ ...field.getValues() }, name, value); }, }); - const errorMessage: Record = field.getErrors(); + const errorMessage: Record = field.getErrors(); useImperativeHandle(ref, () => ({ ...field, validatePromise: async () => { @@ -77,15 +92,19 @@ function FormGenerator(props: IFormGeneratorProps, re return result; }, })); - useEffect(() => { - if (!isEqual(field.getValues(), props.value)) { - if (propsRef.current.resetValuesWhenPropsValueChange) { - field.resetValues(props.value as T); - } else { - field.setValues(props.value as T); + useEffect( + () => { + if (!isEqual(field.getValues(), props.value)) { + if (propsRef.current.resetValuesWhenPropsValueChange) { + field.resetValues(props.value as T); + } else { + field.setValues(props.value as T); + } } - } - }, [props.value]); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [props.value] + ); const formattedFormFields = useMemo(() => { return formFields.map((item) => { const { rules } = item.options || {}; @@ -117,14 +136,18 @@ function FormGenerator(props: IFormGeneratorProps, re }); }, [formFields, field]); - const finalValue = useMemo(() => { - const value = field.getValues(); - if (!blockedNameList) { - return field.getValues(); - } + const finalValue = useMemo( + () => { + const value = field.getValues(); + if (!blockedNameList) { + return field.getValues(); + } - return omit(value, blockedNameList); - }, [field.getValues(), blockedNameList]); + return omit(value, blockedNameList); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [field.getValues(), blockedNameList] + ); return ( @@ -175,7 +198,7 @@ function FormGenerator(props: IFormGeneratorProps, re if (!isEqual(val, finalValue)) { field.validatePromise(); } - propsRef.current.onChange && propsRef.current.onChange(field.getValues(), undefined, editorValue); + if (propsRef.current.onChange) propsRef.current.onChange(field.getValues(), undefined, editorValue); }} /> diff --git a/public/components/IndexDetail/IndexDetail.test.tsx b/public/components/IndexDetail/IndexDetail.test.tsx index 70b6b1d29..6a58b6897 100644 --- a/public/components/IndexDetail/IndexDetail.test.tsx +++ b/public/components/IndexDetail/IndexDetail.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -6,8 +21,8 @@ import React, { useRef, forwardRef, useState } from "react"; import { render, waitFor } from "@testing-library/react"; import { renderHook } from "@testing-library/react-hooks"; -import IndexDetail, { IIndexDetailRef, IndexDetailProps } from "./IndexDetail"; import userEvent from "@testing-library/user-event"; +import IndexDetail, { IIndexDetailRef, IndexDetailProps } from "./IndexDetail"; const IndexDetailOnChangeWrapper = forwardRef((props: Omit, ref: any) => { const [value, setValue] = useState(props.value as any); diff --git a/public/components/IndexDetail/IndexDetail.tsx b/public/components/IndexDetail/IndexDetail.tsx index 01bc32138..d0ed555e1 100644 --- a/public/components/IndexDetail/IndexDetail.tsx +++ b/public/components/IndexDetail/IndexDetail.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -123,13 +138,14 @@ const IndexDetail = ( const hasEdit = useRef(false); const onValueChange = useCallback( (name: string | string[], val) => { - let finalValue = valueRef.current || {}; + const finalValue = valueRef.current || {}; set(finalValue, name, val); onChange({ ...finalValue }); if (name !== "index") { hasEdit.current = true; } }, + // eslint-disable-next-line react-hooks/exhaustive-deps [onChange, value] ); const destroyRef = useRef(false); @@ -139,68 +155,72 @@ const IndexDetail = ( const aliasesRef = useRef(null); const settingsRef = useRef(null); const mappingsRef = useRef(null); - const onIndexInputBlur = useCallback(async () => { - await new Promise((resolve) => setTimeout(resolve, 200)); - if (destroyRef.current) { - return; - } - if (finalValue.index && onSimulateIndexTemplate) { - setTemplateSimulateLoading(true); - const result = await onSimulateIndexTemplate(finalValue.index); + const onIndexInputBlur = useCallback( + async () => { + await new Promise((resolve) => setTimeout(resolve, 200)); if (destroyRef.current) { return; } - setTemplateSimulateLoading(false); - if (result && result.ok) { - let onChangePromise: Promise; - if (hasEdit.current) { - onChangePromise = new Promise((resolve) => { - Modal.show({ - title: "Merge your changes with templates?", - content: - "The index name matches one or more index templates. Index aliases, settings, and mappings are inherited from matching templates. Do you want to merge your changes with templates?", - locale: { - confirm: "Merge with templates", - cancel: "Overwrite by templates", - }, - footer: ["cancel", "confirm"], - type: "confirm", - "data-test-subj": "simulate-confirm", - onCancel: () => resolve(result.response), - onOk: () => { - const formatValue: IndexItemRemote = { - index: "", - ...finalValue, - mappings: { - properties: transformArrayToObject(finalValue.mappings?.properties || []), - }, - }; - const mergedValue: IndexItemRemote = { - index: finalValue.index || "", - }; - merge(mergedValue, result.response, formatValue); - resolve(mergedValue); + if (finalValue.index && onSimulateIndexTemplate) { + setTemplateSimulateLoading(true); + const result = await onSimulateIndexTemplate(finalValue.index); + if (destroyRef.current) { + return; + } + setTemplateSimulateLoading(false); + if (result && result.ok) { + let onChangePromise: Promise; + if (hasEdit.current) { + onChangePromise = new Promise((resolve) => { + Modal.show({ + title: "Merge your changes with templates?", + content: + "The index name matches one or more index templates. Index aliases, settings, and mappings are inherited from matching templates. Do you want to merge your changes with templates?", + locale: { + confirm: "Merge with templates", + cancel: "Overwrite by templates", + }, + footer: ["cancel", "confirm"], + type: "confirm", + "data-test-subj": "simulate-confirm", + onCancel: () => resolve(result.response), + onOk: () => { + const formatValue: IndexItemRemote = { + index: "", + ...finalValue, + mappings: { + properties: transformArrayToObject(finalValue.mappings?.properties || []), + }, + }; + const mergedValue: IndexItemRemote = { + index: finalValue.index || "", + }; + merge(mergedValue, result.response, formatValue); + resolve(mergedValue); + }, + }); + }); + } else { + onChangePromise = Promise.resolve(result.response); + } + onChangePromise.then((data) => { + onChange({ + ...data, + mappings: { + properties: transformObjectToArray(data?.mappings?.properties || {}), }, }); + hasEdit.current = false; + setIsMatchingTemplate(true); }); } else { - onChangePromise = Promise.resolve(result.response); + setIsMatchingTemplate(false); } - onChangePromise.then((data) => { - onChange({ - ...data, - mappings: { - properties: transformObjectToArray(data?.mappings?.properties || {}), - }, - }); - hasEdit.current = false; - setIsMatchingTemplate(true); - }); - } else { - setIsMatchingTemplate(false); } - } - }, [finalValue.index, onSimulateIndexTemplate]); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [finalValue.index, onSimulateIndexTemplate] + ); const onImportSettings = async ({ index }: { index: string }) => { if (onGetIndexDetail) { const indexDetail: IndexItemRemote = await new Promise((resolve) => { @@ -237,102 +257,106 @@ const IndexDetail = ( useImperativeHandle(ref, () => ({ validate: async () => { const result = await Promise.all([ - aliasesRef.current?.validatePromise().then((result) => result.errors), + aliasesRef.current?.validatePromise().then((aliasResult) => aliasResult.errors), mappingsRef.current?.validate(), - settingsRef.current?.validatePromise().then((result) => result.errors), + settingsRef.current?.validatePromise().then((settingsResult) => settingsResult.errors), ]); return result.every((item) => !item); }, - hasUnsavedChanges: (mode: IndicesUpdateMode) => diffJson(oldValue?.[mode], finalValue[mode]), + hasUnsavedChanges: (indMode: IndicesUpdateMode) => diffJson(oldValue?.[indMode], finalValue[indMode]), getMappingsJSONEditorValue: () => mappingsRef.current?.getJSONEditorValue() || "", simulateFromTemplate: onIndexInputBlur, importSettings: onImportSettings, })); - const formFields: IField[] = useMemo(() => { - return [ - { - rowProps: { - label: "Number of primary shards", - helpText: ( - <> -
Specify the number of primary shards for the index. Default is 1.
-
The number of primary shards cannot be changed after the index is created.
- - ), - direction: isEdit ? "hoz" : "ver", - }, - name: "index.number_of_shards", - type: readonly || (isEdit && !INDEX_DYNAMIC_SETTINGS.includes("index.number_of_shards")) ? "Text" : "Number", - options: { - rules: [ - { - min: 1, - message: "Number of primary shards cannot be smaller than 1.", - }, - { - validator(rule, value, values) { - if (Number(value) !== parseInt(value)) { - return Promise.reject("Number of primary shards must be an integer."); - } + const formFields: IField[] = useMemo( + () => { + return [ + { + rowProps: { + label: "Number of primary shards", + helpText: ( + <> +
Specify the number of primary shards for the index. Default is 1.
+
The number of primary shards cannot be changed after the index is created.
+ + ), + direction: isEdit ? "hoz" : "ver", + }, + name: "index.number_of_shards", + type: readonly || (isEdit && !INDEX_DYNAMIC_SETTINGS.includes("index.number_of_shards")) ? "Text" : "Number", + options: { + rules: [ + { + min: 1, + message: "Number of primary shards cannot be smaller than 1.", + }, + { + validator(rule, v, values) { + if (Number(v) !== parseInt(v, 10)) { + return Promise.reject("Number of primary shards must be an integer."); + } - return Promise.resolve(); + return Promise.resolve(); + }, }, + ], + props: { + placeholder: "Specify primary shard count.", + removeWhenEmpty: true, }, - ], - props: { - placeholder: "Specify primary shard count.", - removeWhenEmpty: true, }, }, - }, - { - rowProps: { - label: "Number of replicas", - helpText: REPLICA_NUMBER_MESSAGE, - direction: isEdit ? "hoz" : "ver", - }, - name: "index.number_of_replicas", - type: readonly || (isEdit && !INDEX_DYNAMIC_SETTINGS.includes("index.number_of_replicas")) ? "Text" : "Number", - options: { - rules: [ - { - min: 0, - message: "Number of replicas cannot be smaller than 0.", - }, - { - validator(rule, value, values) { - if (Number(value) !== parseInt(value)) { - return Promise.reject("Number of replicas must be an integer."); - } + { + rowProps: { + label: "Number of replicas", + helpText: REPLICA_NUMBER_MESSAGE, + direction: isEdit ? "hoz" : "ver", + }, + name: "index.number_of_replicas", + type: readonly || (isEdit && !INDEX_DYNAMIC_SETTINGS.includes("index.number_of_replicas")) ? "Text" : "Number", + options: { + rules: [ + { + min: 0, + message: "Number of replicas cannot be smaller than 0.", + }, + { + validator(rule, v, values) { + if (Number(v) !== parseInt(v, 10)) { + return Promise.reject("Number of replicas must be an integer."); + } - return Promise.resolve(); + return Promise.resolve(); + }, }, + ], + props: { + placeholder: "Specify number of replicas.", + removeWhenEmpty: true, }, - ], - props: { - placeholder: "Specify number of replicas.", - removeWhenEmpty: true, }, }, - }, - { - rowProps: { - label: "Refresh interval", - helpText: - "Specify how often the index should refresh, which publishes the most recent changes and make them available for search. Default is 1 second.", - direction: isEdit ? "hoz" : "ver", - }, - name: "index.refresh_interval", - type: readonly ? "Text" : "Input", - options: { - props: { - placeholder: "Can be set to -1 to disable refreshing.", - removeWhenEmpty: true, + { + rowProps: { + label: "Refresh interval", + helpText: + "Specify how often the index should refresh, which publishes the most recent changes and make them available for search. Default is 1 second.", + direction: isEdit ? "hoz" : "ver", + }, + name: "index.refresh_interval", + type: readonly ? "Text" : "Input", + options: { + props: { + placeholder: "Can be set to -1 to disable refreshing.", + removeWhenEmpty: true, + }, }, }, - }, - ] as IField[]; - }, [isEdit, finalValue.index, templateSimulateLoading]); + ] as IField[]; + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [isEdit, finalValue.index, templateSimulateLoading] + ); useEffect(() => { return () => { destroyRef.current = true; @@ -395,7 +419,7 @@ const IndexDetail = ( }, options: { props: { - refreshOptions: refreshOptions, + refreshOptions, }, rules: [...ALIAS_SELECT_RULE], }, diff --git a/public/components/IndexDetail/index.ts b/public/components/IndexDetail/index.ts index f46f9f20e..69dd32300 100644 --- a/public/components/IndexDetail/index.ts +++ b/public/components/IndexDetail/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/IndexMapping/IndexMapping.test.tsx b/public/components/IndexMapping/IndexMapping.test.tsx index fc94f7a2a..3a964ae42 100644 --- a/public/components/IndexMapping/IndexMapping.test.tsx +++ b/public/components/IndexMapping/IndexMapping.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -6,9 +21,9 @@ import React, { forwardRef, Ref, useRef, useState } from "react"; import { render, fireEvent, waitFor, act } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; +import { renderHook } from "@testing-library/react-hooks"; import IndexMapping, { IIndexMappingsRef, IndexMappingProps, transformObjectToArray } from "./IndexMapping"; import { MappingsProperties } from "../../../models/interfaces"; -import { renderHook } from "@testing-library/react-hooks"; const IndexMappingOnChangeWrapper = forwardRef((props: Partial, ref: Ref) => { const [value, setValue] = useState(props.value as any); diff --git a/public/components/IndexMapping/IndexMapping.tsx b/public/components/IndexMapping/IndexMapping.tsx index edc775177..3de148f4f 100644 --- a/public/components/IndexMapping/IndexMapping.tsx +++ b/public/components/IndexMapping/IndexMapping.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -23,7 +38,9 @@ const IndexMapping = ( { value: propsValue, onChange: propsOnChange, isEdit, oldValue, readonly, docVersion }: IndexMappingProps, ref: Ref ) => { + // eslint-disable-next-line react-hooks/exhaustive-deps const value = propsValue?.properties || []; + // eslint-disable-next-line react-hooks/exhaustive-deps const onChange = (val: MappingsProperties) => { propsOnChange({ ...propsValue, @@ -79,7 +96,7 @@ const IndexMapping = ( let isFirstEditableField = false; return (formValue || []).map((item, index) => { const { fieldName, ...fieldSettings } = item; - const id = [pos, index].filter((item) => item !== "").join(".properties."); + const id = [pos, index].filter((itm) => itm !== "").join(".properties."); const readonlyFlag = readonly || (isEdit && !!get(oldValue?.properties, id)); let shouldShowLabel = false; if (!readonlyFlag && !isFirstEditableField) { @@ -90,9 +107,9 @@ const IndexMapping = ( label: ( { - if (ref) { - allFieldsRef.current[id] = ref; + ref={(r) => { + if (r) { + allFieldsRef.current[id] = r; } else { delete allFieldsRef.current[id]; } @@ -100,12 +117,12 @@ const IndexMapping = ( readonly={readonlyFlag} value={item} id={`mapping-visual-editor-${id}`} - onFieldNameCheck={(fieldName) => { + onFieldNameCheck={(innerFieldName) => { const hasDuplicateName = (formValue || []) .filter((sibItem, sibIndex) => sibIndex < index) - .some((sibItem) => sibItem.fieldName === fieldName); + .some((sibItem) => sibItem.fieldName === innerFieldName); if (hasDuplicateName) { - return `Duplicate field name [${fieldName}], please change your field name`; + return `Duplicate field name [${innerFieldName}], please change your field name`; } return ""; @@ -133,6 +150,7 @@ const IndexMapping = ( iconWhenExpanded: , }; if (fieldSettings.properties) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions (payload.icon = ), (payload.iconWhenExpanded = ), (payload.children = transformValueToTreeItems(fieldSettings.properties, id)); @@ -141,6 +159,7 @@ const IndexMapping = ( return payload; }); }; + // eslint-disable-next-line react-hooks/exhaustive-deps const transformedTreeItems = useMemo(() => transformValueToTreeItems(value), [value]); const newValue = useMemo(() => { const oldValueKeys = (oldValue?.properties || []).map((item) => item.fieldName); diff --git a/public/components/IndexMapping/helper.ts b/public/components/IndexMapping/helper.ts index e999d29ff..9134c5e2a 100644 --- a/public/components/IndexMapping/helper.ts +++ b/public/components/IndexMapping/helper.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/IndexMapping/index.ts b/public/components/IndexMapping/index.ts index c5249554c..c9a3b4a07 100644 --- a/public/components/IndexMapping/index.ts +++ b/public/components/IndexMapping/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/IndexMapping/interfaces.ts b/public/components/IndexMapping/interfaces.ts index 02fb4f019..b62f6d733 100644 --- a/public/components/IndexMapping/interfaces.ts +++ b/public/components/IndexMapping/interfaces.ts @@ -1,18 +1,33 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import { MappingsProperties, MappingsPropertiesObject } from "../../../models/interfaces"; -export type IndexMappingsAll = { +export interface IndexMappingsAll { properties?: MappingsProperties; [key: string]: any; -}; +} -export type IndexMappingsObjectAll = { +export interface IndexMappingsObjectAll { properties?: MappingsPropertiesObject; [key: string]: any; -}; +} export interface IndexMappingProps { value?: IndexMappingsAll; diff --git a/public/components/JSONDiffEditor/JSONDiffEditor.test.tsx b/public/components/JSONDiffEditor/JSONDiffEditor.test.tsx index fb6b4fc22..6a37b7e84 100644 --- a/public/components/JSONDiffEditor/JSONDiffEditor.test.tsx +++ b/public/components/JSONDiffEditor/JSONDiffEditor.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/JSONDiffEditor/JSONDiffEditor.tsx b/public/components/JSONDiffEditor/JSONDiffEditor.tsx index f89ee3cd9..95510aaea 100644 --- a/public/components/JSONDiffEditor/JSONDiffEditor.tsx +++ b/public/components/JSONDiffEditor/JSONDiffEditor.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -24,12 +39,12 @@ const JSONDiffEditor = forwardRef(({ value, onChange, ...others }: JSONDiffEdito return; } try { - const value = editorRef.current?.getModifiedEditor().getValue(); - if (!value) { + const v = editorRef.current?.getModifiedEditor().getValue(); + if (!v) { throw new Error("Value cannot be empty"); } - JSON.parse(value); - onChange && onChange(value); + JSON.parse(v); + if (onChange) onChange(v); } catch (e) { setConfirmModalVisible(true); } @@ -50,6 +65,7 @@ const JSONDiffEditor = forwardRef(({ value, onChange, ...others }: JSONDiffEdito } } }, + // eslint-disable-next-line react-hooks/exhaustive-deps [setEditorValue, isReady, inputRef.current] ); const valueRef = useRef(editorValue); @@ -64,7 +80,9 @@ const JSONDiffEditor = forwardRef(({ value, onChange, ...others }: JSONDiffEdito editorRef.current?.getDomNode().addEventListener("click", onClickContainer.current); editorRef.current?.getModifiedEditor().getDomNode()?.setAttribute("data-test-subj", "codeEditorContainer"); return () => { + // eslint-disable-next-line react-hooks/exhaustive-deps document.body.removeEventListener("click", onClickOutsideHandler.current); + // eslint-disable-next-line react-hooks/exhaustive-deps editorRef.current?.getDomNode().removeEventListener("click", onClickContainer.current); }; }, [isReady]); @@ -92,8 +110,8 @@ const JSONDiffEditor = forwardRef(({ value, onChange, ...others }: JSONDiffEdito onChange={(e) => { try { JSON.parse(e.target.value); - onChange && onChange(e.target.value); - } catch (e) { + if (onChange) onChange(e.target.value); + } catch (err) { // do nothing } }} diff --git a/public/components/JSONDiffEditor/JSONTextArea.tsx b/public/components/JSONDiffEditor/JSONTextArea.tsx index 9158885f5..0db3a0f1a 100644 --- a/public/components/JSONDiffEditor/JSONTextArea.tsx +++ b/public/components/JSONDiffEditor/JSONTextArea.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -52,8 +67,8 @@ const JSONDiffEditor = forwardRef(({ value, onChange, ...others }: JSONDiffEdito onBlur={(e) => { try { JSON.parse(e.target.value); - onChange && onChange(e.target.value); - } catch (e) { + if (onChange) onChange(e.target.value); + } catch (err) { // do nothing setConfirmModalVisible(true); } diff --git a/public/components/JSONDiffEditor/index.tsx b/public/components/JSONDiffEditor/index.tsx index bc41570ca..18963be1d 100644 --- a/public/components/JSONDiffEditor/index.tsx +++ b/public/components/JSONDiffEditor/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/JSONDiffEditor/interface.ts b/public/components/JSONDiffEditor/interface.ts index 7ce15504e..859e072c6 100644 --- a/public/components/JSONDiffEditor/interface.ts +++ b/public/components/JSONDiffEditor/interface.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/JSONEditor/JSONEditor.test.tsx b/public/components/JSONEditor/JSONEditor.test.tsx index 7d015727a..23fb576c7 100644 --- a/public/components/JSONEditor/JSONEditor.test.tsx +++ b/public/components/JSONEditor/JSONEditor.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -6,8 +21,8 @@ import React, { useRef } from "react"; import "@testing-library/jest-dom/extend-expect"; import { fireEvent, render, waitFor } from "@testing-library/react"; -import JSONEditor, { IJSONEditorRef } from "./JSONEditor"; import { renderHook } from "@testing-library/react-hooks"; +import JSONEditor, { IJSONEditorRef } from "./JSONEditor"; async function inputTextArea(props: { textareaInput: HTMLTextAreaElement; nowValue: string; newValue: string }) { const { textareaInput, nowValue, newValue } = props; diff --git a/public/components/JSONEditor/JSONEditor.tsx b/public/components/JSONEditor/JSONEditor.tsx index 2599c3918..aac2ee9a1 100644 --- a/public/components/JSONEditor/JSONEditor.tsx +++ b/public/components/JSONEditor/JSONEditor.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -67,7 +82,7 @@ const JSONEditor = forwardRef(({ value, onChange, disabled, ...others }: JSONEdi } try { JSON.parse(tempEditorValue); - onChange && onChange(tempEditorValue); + if (onChange) onChange(tempEditorValue); setConfirmModalVisible(false); } catch (e) { setConfirmModalVisible(true); diff --git a/public/components/JSONEditor/index.ts b/public/components/JSONEditor/index.ts index 2d617d358..d2123e154 100644 --- a/public/components/JSONEditor/index.ts +++ b/public/components/JSONEditor/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/JSONModal/JSONModal.test.tsx b/public/components/JSONModal/JSONModal.test.tsx index c19935c0d..495ed95b8 100644 --- a/public/components/JSONModal/JSONModal.test.tsx +++ b/public/components/JSONModal/JSONModal.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/JSONModal/JSONModal.tsx b/public/components/JSONModal/JSONModal.tsx index 5013e89e1..89a219d0c 100644 --- a/public/components/JSONModal/JSONModal.tsx +++ b/public/components/JSONModal/JSONModal.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -21,7 +36,7 @@ interface JSONModalProps { onClose: () => void; } -const JSONModal: React.SFC = ({ title, json, onClose }) => { +const JSONModal: React.FC = ({ title, json, onClose }) => { return ( diff --git a/public/components/JSONModal/index.ts b/public/components/JSONModal/index.ts index 17333a9c3..842400e1c 100644 --- a/public/components/JSONModal/index.ts +++ b/public/components/JSONModal/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/LegacyNotification/LegacyNotification.test.tsx b/public/components/LegacyNotification/LegacyNotification.test.tsx index d46bd0e03..ad8f53dc5 100644 --- a/public/components/LegacyNotification/LegacyNotification.test.tsx +++ b/public/components/LegacyNotification/LegacyNotification.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/LegacyNotification/LegacyNotification.tsx b/public/components/LegacyNotification/LegacyNotification.tsx index 9b9009a03..cae0e8b97 100644 --- a/public/components/LegacyNotification/LegacyNotification.tsx +++ b/public/components/LegacyNotification/LegacyNotification.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/LegacyNotification/index.ts b/public/components/LegacyNotification/index.ts index 0cb8c76bf..e6e5faed4 100644 --- a/public/components/LegacyNotification/index.ts +++ b/public/components/LegacyNotification/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/MappingLabel/MappingLabel.test.tsx b/public/components/MappingLabel/MappingLabel.test.tsx index 93ef6e14e..b9dab1b8a 100644 --- a/public/components/MappingLabel/MappingLabel.test.tsx +++ b/public/components/MappingLabel/MappingLabel.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/MappingLabel/MappingLabel.tsx b/public/components/MappingLabel/MappingLabel.tsx index 63e718b68..a0f7ab8ce 100644 --- a/public/components/MappingLabel/MappingLabel.tsx +++ b/public/components/MappingLabel/MappingLabel.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -15,12 +30,12 @@ import { EuiFormRowProps, } from "@elastic/eui"; import { set, pick, isEqual } from "lodash"; +import { useEffect } from "react"; import { MappingsProperties } from "../../../models/interfaces"; import { AllBuiltInComponents } from "../FormGenerator"; import useField, { transformNameToString } from "../../lib/field"; import { INDEX_MAPPING_TYPES, INDEX_MAPPING_TYPES_WITH_CHILDREN } from "../../utils/constants"; import SimplePopover from "../SimplePopover"; -import { useEffect } from "react"; interface IMappingLabel { value: MappingsProperties[number]; @@ -72,6 +87,7 @@ export const MappingLabel = forwardRef((props: IMappingLabel, forwardedRef: Reac } return propsRef.current.onChange(newValue, k, v); }, + // eslint-disable-next-line react-hooks/exhaustive-deps [propsRef.current.value, propsRef.current.onChange] ); const field = useField({ @@ -82,11 +98,15 @@ export const MappingLabel = forwardRef((props: IMappingLabel, forwardedRef: Reac onChange: onFieldChange, unmountComponent: true, }); - useEffect(() => { - if (!isEqual(propsRef.current.value, field.getValues())) { - field.resetValues(propsRef.current.value); - } - }, [propsRef.current.value]); + useEffect( + () => { + if (!isEqual(propsRef.current.value, field.getValues())) { + field.resetValues(propsRef.current.value); + } + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [propsRef.current.value] + ); const value = field.getValues(); const type = value.type; useImperativeHandle(forwardedRef, () => ({ @@ -143,8 +163,8 @@ export const MappingLabel = forwardRef((props: IMappingLabel, forwardedRef: Reac message: "Field name is required, please input", }, { - validator: (rule, value) => { - const checkResult = onFieldNameCheck(value); + validator: (rule, v) => { + const checkResult = onFieldNameCheck(v); if (checkResult) { return Promise.reject(checkResult); } @@ -182,6 +202,7 @@ export const MappingLabel = forwardRef((props: IMappingLabel, forwardedRef: Reac {moreFields.map((item) => { + // eslint-disable-next-line no-shadow const { label, type, ...others } = item; const RenderComponent = AllBuiltInComponents[type]; return ( diff --git a/public/components/MappingLabel/index.ts b/public/components/MappingLabel/index.ts index 8b6fb9cb2..6b89dfa34 100644 --- a/public/components/MappingLabel/index.ts +++ b/public/components/MappingLabel/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/Modal/Modal.test.tsx b/public/components/Modal/Modal.test.tsx index 4367cff61..3023e32a2 100644 --- a/public/components/Modal/Modal.test.tsx +++ b/public/components/Modal/Modal.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -16,7 +31,7 @@ describe(" spec", () => { const { container } = render( - {services => services && } + {(services) => services && } ); @@ -34,7 +49,7 @@ describe(" spec", () => {
- {services => services && } + {(services) => services && } {({ onShow }) => ( onShow(Modal, { text: "interesting text" })}> diff --git a/public/components/Modal/Modal.tsx b/public/components/Modal/Modal.tsx index 462a0dded..8214feade 100644 --- a/public/components/Modal/Modal.tsx +++ b/public/components/Modal/Modal.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/Modal/ModalRoot.tsx b/public/components/Modal/ModalRoot.tsx index fc6b1e9a0..40d3a4248 100644 --- a/public/components/Modal/ModalRoot.tsx +++ b/public/components/Modal/ModalRoot.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -12,7 +27,7 @@ interface ModalRootProps { } // All modals will have access to the BrowserServices if they need it -const ModalRoot: React.SFC = ({ services }) => ( +const ModalRoot: React.FC = ({ services }) => ( {({ component: Komponent, diff --git a/public/components/Modal/index.ts b/public/components/Modal/index.ts index e53b691dd..c86de8d70 100644 --- a/public/components/Modal/index.ts +++ b/public/components/Modal/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/MonacoJSONEditor/MonacoJSONEditor.test.tsx b/public/components/MonacoJSONEditor/MonacoJSONEditor.test.tsx index aa74e8a47..847a0e5f8 100644 --- a/public/components/MonacoJSONEditor/MonacoJSONEditor.test.tsx +++ b/public/components/MonacoJSONEditor/MonacoJSONEditor.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/MonacoJSONEditor/MonacoJSONEditor.tsx b/public/components/MonacoJSONEditor/MonacoJSONEditor.tsx index 43901c52c..d86f2ae0f 100644 --- a/public/components/MonacoJSONEditor/MonacoJSONEditor.tsx +++ b/public/components/MonacoJSONEditor/MonacoJSONEditor.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -28,13 +43,13 @@ const MonacoJSONEditor = forwardRef( return; } try { - const value = editorRef.current?.getValue(); - if (!value) { + const v = editorRef.current?.getValue(); + if (!v) { throw new Error("Value can not be empty"); } - JSON.parse(value); + JSON.parse(v); setConfirmModalVisible(false); - onChange && onChange(value); + if (onChange) onChange(v); } catch (e) { setConfirmModalVisible(true); } @@ -49,6 +64,7 @@ const MonacoJSONEditor = forwardRef( } } }, + // eslint-disable-next-line react-hooks/exhaustive-deps [setEditorValue, isReady, inputRef.current] ); const valueRef = useRef(editorValue); @@ -73,6 +89,7 @@ const MonacoJSONEditor = forwardRef( useEffect(() => { return () => { + // eslint-disable-next-line react-hooks/exhaustive-deps onClickOutsideHandler.current(); }; }, []); @@ -100,8 +117,8 @@ const MonacoJSONEditor = forwardRef( onChange={(e) => { try { JSON.parse(e.target.value); - onChange && onChange(e.target.value); - } catch (e) { + if (onChange) onChange(e.target.value); + } catch (err) { // do nothing } }} diff --git a/public/components/MonacoJSONEditor/hooks.tsx b/public/components/MonacoJSONEditor/hooks.tsx index c202624c4..05889f10d 100644 --- a/public/components/MonacoJSONEditor/hooks.tsx +++ b/public/components/MonacoJSONEditor/hooks.tsx @@ -1,3 +1,23 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import { monaco } from "@osd/monaco"; import { euiThemeVars } from "@osd/ui-shared-deps/theme"; import { useEffect, useRef } from "react"; @@ -25,6 +45,7 @@ export function useDiagnosticsOptions(props: { monaco?: typeof monaco; diagnosti }); } return () => { + // eslint-disable-next-line react-hooks/exhaustive-deps props.monaco?.languages.json.jsonDefaults.setDiagnosticsOptions(oldOptionsSettingsRef.current || {}); }; }, [props.monaco, props.diagnosticsOptions]); @@ -54,5 +75,6 @@ export function useModel(props: { editor?: monaco.editor.IStandaloneCodeEditor; return () => { props.editor?.getModel()?.dispose(); }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); } diff --git a/public/components/MonacoJSONEditor/index.tsx b/public/components/MonacoJSONEditor/index.tsx index 4a2a288d5..9618047d8 100644 --- a/public/components/MonacoJSONEditor/index.tsx +++ b/public/components/MonacoJSONEditor/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/MonacoJSONEditor/interface.ts b/public/components/MonacoJSONEditor/interface.ts index 9920759ec..2f7d2e394 100644 --- a/public/components/MonacoJSONEditor/interface.ts +++ b/public/components/MonacoJSONEditor/interface.ts @@ -1,11 +1,33 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import { monaco } from "@osd/monaco"; import { JSONSchema4 } from "@types/json-schema"; import { JSONEditorProps } from "../JSONEditor"; export type DiagnosticsOptions = Omit & { - schemas?: (Omit["schemas"][number], "schema"> & { - schema?: JSONSchema4; - })[]; + schemas?: Array< + Omit["schemas"][number], "schema"> & { + schema?: JSONSchema4; + } + >; }; export interface MonacoJSONEditorProps extends JSONEditorProps { diff --git a/public/components/PolicyModal/PolicyModal.test.tsx b/public/components/PolicyModal/PolicyModal.test.tsx index 527aec6b9..7d0c1addd 100644 --- a/public/components/PolicyModal/PolicyModal.test.tsx +++ b/public/components/PolicyModal/PolicyModal.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -31,6 +46,7 @@ describe(" spec", () => { policy={{ policy: { name: "policy" } }} // replace with random policy w/ seed onClose={() => {}} onEdit={() => { + // eslint-disable-next-line no-empty { } }} diff --git a/public/components/PolicyModal/PolicyModal.tsx b/public/components/PolicyModal/PolicyModal.tsx index 5d1798c72..21d498097 100644 --- a/public/components/PolicyModal/PolicyModal.tsx +++ b/public/components/PolicyModal/PolicyModal.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -28,7 +43,7 @@ interface PolicyModalProps { onEdit: (visual: boolean) => void; } -const PolicyModal: React.SFC = ({ policyId, policy, errorMessage, onClose, onEdit }) => { +const PolicyModal: React.FC = ({ policyId, policy, errorMessage, onClose, onEdit }) => { const policyString = JSON.stringify(policy, null, 4); return ( diff --git a/public/components/PolicyModal/index.ts b/public/components/PolicyModal/index.ts index b263ece48..30afc2b11 100644 --- a/public/components/PolicyModal/index.ts +++ b/public/components/PolicyModal/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/RemoteSelect/RemoteSelect.test.tsx b/public/components/RemoteSelect/RemoteSelect.test.tsx index e30ae7e30..adbe81032 100644 --- a/public/components/RemoteSelect/RemoteSelect.test.tsx +++ b/public/components/RemoteSelect/RemoteSelect.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -5,8 +20,8 @@ import React, { useState } from "react"; import { render, waitFor } from "@testing-library/react"; -import RemoteSelect, { RemoteSelectProps } from "./index"; import userEvent from "@testing-library/user-event"; +import RemoteSelect, { RemoteSelectProps } from "./index"; const onChangeMock = jest.fn(); diff --git a/public/components/RemoteSelect/index.tsx b/public/components/RemoteSelect/index.tsx index 55c18369b..0f6ae078d 100644 --- a/public/components/RemoteSelect/index.tsx +++ b/public/components/RemoteSelect/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -12,13 +27,13 @@ import { ServerResponse } from "../../../server/models/types"; export interface RemoteSelectProps extends Omit, "value" | "onChange"> { value?: string[]; onChange?: (value: Required["value"]) => void; - onOptionsChange?: (options: { label: string; [key: string]: any }[]) => void; - refreshOptions: (params: { searchValue?: string }) => Promise>; + onOptionsChange?: (options: Array<{ label: string; [key: string]: any }>) => void; + refreshOptions: (params: { searchValue?: string }) => Promise>>; } const RemoteSelect = forwardRef((props: RemoteSelectProps, ref: React.Ref) => { const { value = [], onChange, refreshOptions: refreshOptionsFromProps, onOptionsChange, ...others } = props; - const [allOptions, setAllOptions] = useState([] as { label: string }[]); + const [allOptions, setAllOptions] = useState([] as Array<{ label: string }>); const [isLoading, setIsLoading] = useState(false); const destroyRef = useRef(false); const refreshOptionsWithoutDebounce = useCallback( @@ -28,7 +43,7 @@ const RemoteSelect = forwardRef((props: RemoteSelectProps, ref: React.Ref) => { + .then((res: ServerResponse>) => { if (destroyRef.current) { return; } @@ -47,17 +62,26 @@ const RemoteSelect = forwardRef((props: RemoteSelectProps, ref: React.Ref { - refreshOptionsWithoutDebounce({ searchValue: "" }); - return () => { - destroyRef.current = true; - }; - }, []); - useEffect(() => { - onOptionsChange && onOptionsChange(allOptions); - }, [allOptions]); - const onCreateOption = (searchValue: string, flattenedOptions: { label: string }[] = []) => { + useEffect( + () => { + refreshOptionsWithoutDebounce({ searchValue: "" }); + return () => { + destroyRef.current = true; + }; + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [] + ); + useEffect( + () => { + if (onOptionsChange) onOptionsChange(allOptions); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [allOptions] + ); + const onCreateOption = (searchValue: string, flattenedOptions: Array<{ label: string }> = []) => { const normalizedSearchValue = searchValue.trim().toLowerCase(); if (!normalizedSearchValue) { @@ -71,7 +95,7 @@ const RemoteSelect = forwardRef((props: RemoteSelectProps, ref: React.Ref option.label.trim().toLowerCase() === normalizedSearchValue) === -1) { setAllOptions([...allOptions, newOption]); - onChange && onChange([...value, newOption.label]); + if (onChange) onChange([...value, newOption.label]); } }; return ( @@ -80,8 +104,8 @@ const RemoteSelect = forwardRef((props: RemoteSelectProps, ref: React.Ref void} selectedOptions={value?.map((item) => ({ label: item }))} - onChange={(value) => { - onChange && onChange(value.map((item) => item.label)); + onChange={(v) => { + if (onChange) onChange(v.map((item) => item.label)); }} options={allOptions} isLoading={isLoading} diff --git a/public/components/SimplePopover/SimplePopover.test.tsx b/public/components/SimplePopover/SimplePopover.test.tsx index eab359d28..9a52f1feb 100644 --- a/public/components/SimplePopover/SimplePopover.test.tsx +++ b/public/components/SimplePopover/SimplePopover.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -5,8 +20,8 @@ import React from "react"; import { render, waitFor } from "@testing-library/react"; -import SimplePopover, { loopToGetPath } from "./SimplePopover"; import userEvent from "@testing-library/user-event"; +import SimplePopover, { loopToGetPath } from "./SimplePopover"; describe(" spec", () => { it("renders the component", () => { diff --git a/public/components/SimplePopover/SimplePopover.tsx b/public/components/SimplePopover/SimplePopover.tsx index 8c0b741a6..b4352e25f 100644 --- a/public/components/SimplePopover/SimplePopover.tsx +++ b/public/components/SimplePopover/SimplePopover.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -44,15 +59,20 @@ const SimplePopover: React.FC = (props) => { }; } - const outsideClick = useCallback(() => { - setTimeout(() => { - if (destroyRef.current) { - return; - } - setPopVisible(false); - }, 0); - }, [popVisible, setPopVisible]); + const outsideClick = useCallback( + () => { + setTimeout(() => { + if (destroyRef.current) { + return; + } + setPopVisible(false); + }, 0); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [popVisible, setPopVisible] + ); + // eslint-disable-next-line react-hooks/exhaustive-deps const outsideHover = useCallback( throttle((e: MouseEvent) => { if (popVisible && popoverRef.current && panelRef.current) { @@ -65,14 +85,18 @@ const SimplePopover: React.FC = (props) => { [popVisible, setPopVisible] ); - useEffect(() => { - if (popVisible && triggerType === "click") { - window.addEventListener("click", outsideClick); - } - return () => { - window.removeEventListener("click", outsideClick); - }; - }, [outsideClick, triggerType]); + useEffect( + () => { + if (popVisible && triggerType === "click") { + window.addEventListener("click", outsideClick); + } + return () => { + window.removeEventListener("click", outsideClick); + }; + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [outsideClick, triggerType] + ); useEffect(() => { if (popVisible && triggerType === "hover") { diff --git a/public/components/SimplePopover/index.ts b/public/components/SimplePopover/index.ts index 68d299e46..a6dbc2be9 100644 --- a/public/components/SimplePopover/index.ts +++ b/public/components/SimplePopover/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/SwitchableEditor/SwitchableEditor.test.tsx b/public/components/SwitchableEditor/SwitchableEditor.test.tsx index 1bcc0c283..6d13cf00e 100644 --- a/public/components/SwitchableEditor/SwitchableEditor.test.tsx +++ b/public/components/SwitchableEditor/SwitchableEditor.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -6,8 +21,8 @@ import React from "react"; import "@testing-library/jest-dom/extend-expect"; import { render, waitFor } from "@testing-library/react"; -import SwitchableEditor from "./index"; import userEvent from "@testing-library/user-event"; +import SwitchableEditor from "./index"; describe(" spec", () => { it("renders the component", async () => { diff --git a/public/components/SwitchableEditor/SwitchableEditor.tsx b/public/components/SwitchableEditor/SwitchableEditor.tsx index 153dc2c95..504c9bd68 100644 --- a/public/components/SwitchableEditor/SwitchableEditor.tsx +++ b/public/components/SwitchableEditor/SwitchableEditor.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -14,7 +29,7 @@ export interface SwitchableEditorProps extends JSONDiffEditorProps, Pick) => { diff --git a/public/components/SwitchableEditor/index.tsx b/public/components/SwitchableEditor/index.tsx index 8b0e14658..e0f7b2db1 100644 --- a/public/components/SwitchableEditor/index.tsx +++ b/public/components/SwitchableEditor/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/Toast/Toast.test.tsx b/public/components/Toast/Toast.test.tsx index 543fe391f..65ad99d7c 100644 --- a/public/components/Toast/Toast.test.tsx +++ b/public/components/Toast/Toast.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/Toast/index.tsx b/public/components/Toast/index.tsx index a37d9ca66..64d76c412 100644 --- a/public/components/Toast/index.tsx +++ b/public/components/Toast/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/ToolTipWithoutWarning/index.tsx b/public/components/ToolTipWithoutWarning/index.tsx index 641c6367a..372c280ff 100644 --- a/public/components/ToolTipWithoutWarning/index.tsx +++ b/public/components/ToolTipWithoutWarning/index.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/UnsavedChangesBottomBar/UnsavedChangesBottomBar.test.tsx b/public/components/UnsavedChangesBottomBar/UnsavedChangesBottomBar.test.tsx index cd47064be..2066c6646 100644 --- a/public/components/UnsavedChangesBottomBar/UnsavedChangesBottomBar.test.tsx +++ b/public/components/UnsavedChangesBottomBar/UnsavedChangesBottomBar.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/UnsavedChangesBottomBar/UnsavedChangesBottomBar.tsx b/public/components/UnsavedChangesBottomBar/UnsavedChangesBottomBar.tsx index d08805159..04c95b34c 100644 --- a/public/components/UnsavedChangesBottomBar/UnsavedChangesBottomBar.tsx +++ b/public/components/UnsavedChangesBottomBar/UnsavedChangesBottomBar.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -8,7 +23,7 @@ import classNames from "classnames"; import BottomBar from "../BottomBar"; import "./index.scss"; -export type CustomFormRowProps = { +export interface CustomFormRowProps { unsavedCount: number; formErrorsCount?: number; onClickCancel?: () => void; @@ -22,7 +37,7 @@ export type CustomFormRowProps = { }) => React.ReactChild; confirmButtonProps?: EuiButtonProps; cancelButtonprops?: EuiButtonEmptyProps; -}; +} export default function UnsavedChangesBottomBar(props: CustomFormRowProps) { const { unsavedCount, onClickCancel, onClickSubmit, submitButtonDataTestSubj, formErrorsCount } = props; @@ -32,9 +47,11 @@ export default function UnsavedChangesBottomBar(props: CustomFormRowProps) { setLoading(true); try { await onClickSubmit(); + // eslint-disable-next-line no-empty } catch (e) { } finally { if (destroyRef.current) { + // eslint-disable-next-line no-unsafe-finally return; } setLoading(false); @@ -53,6 +70,7 @@ export default function UnsavedChangesBottomBar(props: CustomFormRowProps) { ), + // eslint-disable-next-line react-hooks/exhaustive-deps [onClickCancel] ); @@ -73,6 +91,7 @@ export default function UnsavedChangesBottomBar(props: CustomFormRowProps) { /> ), + // eslint-disable-next-line react-hooks/exhaustive-deps [onClick, submitButtonDataTestSubj, loading] ); diff --git a/public/components/UnsavedChangesBottomBar/index.ts b/public/components/UnsavedChangesBottomBar/index.ts index 6473decf8..c83d6345a 100644 --- a/public/components/UnsavedChangesBottomBar/index.ts +++ b/public/components/UnsavedChangesBottomBar/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/components/core_services.ts b/public/components/core_services.ts index c09f1975c..a318906be 100644 --- a/public/components/core_services.ts +++ b/public/components/core_services.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/containers/ChannelSelect/ChannelSelect.test.tsx b/public/containers/ChannelSelect/ChannelSelect.test.tsx index abec5d7b3..da4f1cb8e 100644 --- a/public/containers/ChannelSelect/ChannelSelect.test.tsx +++ b/public/containers/ChannelSelect/ChannelSelect.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -6,11 +21,11 @@ import React from "react"; import "@testing-library/jest-dom/extend-expect"; import { render, waitFor } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; import ChannelSelect, { ChannelSelectProps } from "./ChannelSelect"; import { browserServicesMock, coreServicesMock } from "../../../test/mocks"; import { ServicesContext } from "../../services"; import { CoreServicesContext } from "../../components/core_services"; -import userEvent from "@testing-library/user-event"; function renderWithServiceAndCore(props: ChannelSelectProps) { return { diff --git a/public/containers/ChannelSelect/ChannelSelect.tsx b/public/containers/ChannelSelect/ChannelSelect.tsx index 785d7d1c0..04afc5cf2 100644 --- a/public/containers/ChannelSelect/ChannelSelect.tsx +++ b/public/containers/ChannelSelect/ChannelSelect.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -10,8 +25,8 @@ import { AllBuiltInComponents } from "../../components/FormGenerator"; import "./index.scss"; export interface ChannelSelectProps { - value?: { id: string }[]; - onChange: (val: { id: string }[]) => void; + value?: Array<{ id: string }>; + onChange: (val: Array<{ id: string }>) => void; "data-test-subj"?: string; } @@ -26,7 +41,7 @@ const ChannelSelect = (props: ChannelSelectProps) => { placeholder="Select channel" isLoading={loading} options={channels.map((channel) => ({ value: channel.config_id, label: channel.name, className: "valid-option" }))} - onChange={(val, options: EuiComboBoxOptionOption[]) => { + onChange={(val, options: Array>) => { onChange( options.map((item) => ({ id: item.value || "", diff --git a/public/containers/ChannelSelect/hooks.tsx b/public/containers/ChannelSelect/hooks.tsx index 2332e0c5a..7e2bcea50 100644 --- a/public/containers/ChannelSelect/hooks.tsx +++ b/public/containers/ChannelSelect/hooks.tsx @@ -1,3 +1,23 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + import { useContext, useState, useEffect, useRef, useCallback } from "react"; import { ServicesContext } from "../../services"; import { BrowserServices } from "../../models/interfaces"; @@ -5,7 +25,7 @@ import { FeatureChannelList, GetChannelsResponse } from "../../../server/models/ import { ServerResponse } from "../../../server/models/types"; let listenCount = 0; -let promise: Promise> | undefined = undefined; +let promise: Promise> | undefined; const LISTEN_KEY = "GET_CHANNELS_LISTEN"; const getChannels = async (props: { services: BrowserServices; force?: boolean }): Promise> => { @@ -27,36 +47,44 @@ export const useChannels = () => { const [channels, setChannels] = useState([]); const [loading, setLoading] = useState(true); const destroyRef = useRef(false); - const refresh = useCallback((force?: boolean) => { - setLoading(true); - getChannels({ - services, - force, - }) - .then((res) => { - if (destroyRef.current) { - return; - } - if (res && res.ok) { - setChannels(res.response.channel_list); - } + const refresh = useCallback( + (force?: boolean) => { + setLoading(true); + getChannels({ + services, + force, }) - .finally(() => { - if (destroyRef.current) { - return; - } - setLoading(false); - }); - }, []); + .then((res) => { + if (destroyRef.current) { + return; + } + if (res && res.ok) { + setChannels(res.response.channel_list); + } + }) + .finally(() => { + if (destroyRef.current) { + return; + } + setLoading(false); + }); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [] + ); const listenHandler = useCallback(() => { refresh(); }, [refresh]); - useEffect(() => { - refresh(); - return () => { - destroyRef.current = true; - }; - }, []); + useEffect( + () => { + refresh(); + return () => { + destroyRef.current = true; + }; + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [] + ); useEffect(() => { window.addEventListener(LISTEN_KEY, listenHandler); diff --git a/public/containers/ChannelSelect/index.ts b/public/containers/ChannelSelect/index.ts index 6a3bd07af..ff9594f57 100644 --- a/public/containers/ChannelSelect/index.ts +++ b/public/containers/ChannelSelect/index.ts @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 diff --git a/public/containers/ClearCacheModal/ClearCacheModal.test.tsx b/public/containers/ClearCacheModal/ClearCacheModal.test.tsx index 23e4973b2..8a9852623 100644 --- a/public/containers/ClearCacheModal/ClearCacheModal.test.tsx +++ b/public/containers/ClearCacheModal/ClearCacheModal.test.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -5,16 +20,16 @@ import React from "react"; import "@testing-library/jest-dom/extend-expect"; +import { CoreStart } from "opensearch-dashboards/public"; +import { render, fireEvent, waitFor } from "@testing-library/react"; +import { act } from "react-dom/test-utils"; import { browserServicesMock, coreServicesMock } from "../../../test/mocks"; import { CoreServicesContext } from "../../components/core_services"; import { ServicesContext } from "../../services"; import { BrowserServices } from "../../models/interfaces"; import { ModalProvider } from "../../components/Modal"; -import { CoreStart } from "opensearch-dashboards/public"; -import { render, fireEvent, waitFor } from "@testing-library/react"; import ClearCacheModal, { ClearCacheModalProps } from "./ClearCacheModal"; import { INDEX_OP_TARGET_TYPE } from "../../utils/constants"; -import { act } from "react-dom/test-utils"; function renderWithRouter( coreServicesContext: CoreStart | null, @@ -51,7 +66,7 @@ describe(" spec", () => { selectedItems: [], visible: true, type: INDEX_OP_TARGET_TYPE.INDEX, - onClose: onClose, + onClose, }); await waitFor(() => { expect(getByText("Cache will be cleared for all open indexes.")).toBeInTheDocument(); diff --git a/public/containers/ClearCacheModal/ClearCacheModal.tsx b/public/containers/ClearCacheModal/ClearCacheModal.tsx index 0855da739..eafa5155a 100644 --- a/public/containers/ClearCacheModal/ClearCacheModal.tsx +++ b/public/containers/ClearCacheModal/ClearCacheModal.tsx @@ -1,3 +1,18 @@ +/* + * Copyright OpenSearch Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + /* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 @@ -5,12 +20,6 @@ import React, { useCallback, useContext, useEffect, useState } from "react"; import { CoreStart } from "opensearch-dashboards/public"; -import { CatIndex, DataStream } from "../../../server/models/interfaces"; -import { IAlias } from "../../pages/Aliases/interface"; -import { ServicesContext } from "../../services"; -import { CoreServicesContext } from "../../components/core_services"; -import { INDEX_OP_BLOCKS_TYPE, INDEX_OP_TARGET_TYPE } from "../../utils/constants"; -import { getErrorMessage, filterBlockedItems } from "../../utils/helpers"; import { EuiButton, EuiButtonEmpty, @@ -22,6 +31,12 @@ import { EuiModalHeaderTitle, EuiSpacer, } from "@elastic/eui"; +import { CatIndex, DataStream } from "../../../server/models/interfaces"; +import { IAlias } from "../../pages/Aliases/interface"; +import { ServicesContext } from "../../services"; +import { CoreServicesContext } from "../../components/core_services"; +import { INDEX_OP_BLOCKS_TYPE, INDEX_OP_TARGET_TYPE } from "../../utils/constants"; +import { getErrorMessage, filterBlockedItems } from "../../utils/helpers"; export interface ClearCacheModalProps { selectedItems: CatIndex[] | DataStream[] | IAlias[]; @@ -121,11 +136,11 @@ export default function ClearCacheModal(props: ClearCacheModalProps) { let toast = ""; if (unBlockedItems.length > 1) { toast = `Cache for ${unBlockedItems.length} ${type} [${unBlockedItems.join(", ")}] have been successfully cleared.`; - } else if (unBlockedItems.length == 1) { + } else if (unBlockedItems.length === 1) { toast = `Cache for ${unBlockedItems[0]} has been successfully cleared.`; } - if (!selectedItems || selectedItems.length == 0) { + if (!selectedItems || selectedItems.length === 0) { toast = "Cache for all open indexes have been successfully cleared."; } coreServices.notifications.toasts.addSuccess(toast); @@ -150,22 +165,26 @@ export default function ClearCacheModal(props: ClearCacheModalProps) { } }, [services, coreServices, onClose, unBlockedItems, selectedItems, type]); - useEffect(() => { - if (visible && selectedItems.length > 0 && selectedItems.length == blockedItems.length) { - if (selectedItems.length == 1) { - coreServices.notifications.toasts.addDanger({ - title: "Unable to clear cache", - text: `Cache cannot be cleared for ${blockedItems[0]} because it is closed or blocked.`, - }); - } else { - coreServices.notifications.toasts.addDanger({ - title: "Unable to clear cache", - text: `Cache cannot be cleared for the selected ${type} because they are closed or blocked.`, - }); + useEffect( + () => { + if (visible && selectedItems.length > 0 && selectedItems.length === blockedItems.length) { + if (selectedItems.length === 1) { + coreServices.notifications.toasts.addDanger({ + title: "Unable to clear cache", + text: `Cache cannot be cleared for ${blockedItems[0]} because it is closed or blocked.`, + }); + } else { + coreServices.notifications.toasts.addDanger({ + title: "Unable to clear cache", + text: `Cache cannot be cleared for the selected ${type} because they are closed or blocked.`, + }); + } + onClose(); } - onClose(); - } - }, [visible, unBlockedItems, blockedItems, coreServices, onClose, type]); + }, + // eslint-disable-next-line react-hooks/exhaustive-deps + [visible, unBlockedItems, blockedItems, coreServices, onClose, type] + ); if (!visible || loading) { return null; @@ -186,7 +205,7 @@ export default function ClearCacheModal(props: ClearCacheModalProps) { )}
-