Skip to content

Commit

Permalink
fixed limit check and ran prettier
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Galitzky <amgalitz@amazon.com>
  • Loading branch information
amitgalitz committed Jul 7, 2023
1 parent c8620ad commit 4e703cc
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ function AssociatedDetectors({ embeddable, closeFlyout, setMode }) {
getAugmentVisSavedObjs(embeddable.vis.id, savedObjectLoader, uiSettings)
.then((savedAugmentObjectsArr: any) => {
if (savedAugmentObjectsArr != undefined) {
if (maxAssociatedCount <= savedAugmentObjectsArr.length) {
setAssociationLimitReached(true);
} else {
setAssociationLimitReached(false);
}
const curSelectedDetectors = getAssociatedDetectors(
Object.values(allDetectors),
savedAugmentObjectsArr
Expand All @@ -152,11 +157,6 @@ function AssociatedDetectors({ embeddable, closeFlyout, setMode }) {
maxAssociatedCount = uiSettings.get(
PLUGIN_AUGMENTATION_MAX_OBJECTS_SETTING
);
if (maxAssociatedCount <= curSelectedDetectors.length) {
setAssociationLimitReached(true);
} else {
setAssociationLimitReached(false);
}
setIsLoadingFinalDetectors(false);
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,7 @@ function AddAnomalyDetector({
) : (
<EuiButton
fill={true}
disabled={associationLimitReached}
data-test-subj="adAnywhereCreateDetectorButton"
isLoading={formikProps.isSubmitting}
onClick={() => {
Expand Down
2 changes: 1 addition & 1 deletion public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
setSavedFeatureAnywhereLoader,
setUiActions,
setUISettings,
setQueryService
setQueryService,
} from './services';
import { AnomalyDetectionOpenSearchDashboardsPluginStart } from 'public';
import {
Expand Down
4 changes: 2 additions & 2 deletions public/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export const [getUiActions, setUiActions] =
export const [getUISettings, setUISettings] =
createGetterSetter<IUiSettingsClient>('UISettings');

export const [getQueryService, setQueryService] =
createGetterSetter<DataPublicPluginStart['query']>('Query');
export const [getQueryService, setQueryService] =
createGetterSetter<DataPublicPluginStart['query']>('Query');

// This is primarily used for mocking this module and each of its fns in tests.
export default {
Expand Down

0 comments on commit 4e703cc

Please sign in to comment.