[ML] Changes for optional spaces plugin (#151170)

Changes to ensure ML behaves correctly when the spaces plugin is
disabled.
Related to https://github.com/elastic/kibana/issues/149687
Closes https://github.com/elastic/kibana/issues/149953

ML was in pretty good shape for this change as we already assumed spaces
could be optional.
The only change needed is to ensure the saved object sync button is
enabled on the management page even when spaces is missing.
Previously we incorrectly hid this button.
This commit is contained in:
James Gowdy 2023-02-16 14:18:14 +00:00 committed by GitHub
parent 41afa5c9c4
commit 31c73b9719
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 18 deletions

View file

@ -19,7 +19,7 @@ import { useMlApiContext } from '../../contexts/kibana';
import { useToastNotificationService } from '../../services/toast_notification_service';
interface Props {
spacesApi: SpacesPluginStart;
spacesApi: SpacesPluginStart; // this component is only ever used when spaces is enabled
spaceIds: string[];
id: string;
mlSavedObjectType: MlSavedObjectType;

View file

@ -40,7 +40,7 @@ interface StartPlugins {
usageCollection?: UsageCollectionSetup;
fieldFormats: FieldFormatsRegistry;
dashboard: DashboardSetup;
spacesApi: SpacesPluginStart;
spacesApi?: SpacesPluginStart;
charts: ChartsPluginStart;
cases?: CasesUiStart;
unifiedSearch: UnifiedSearchPublicPluginStart;

View file

@ -62,7 +62,6 @@ export const JobsListPage: FC<{
() => mlApiServicesProvider(new HttpService(coreStart.http)),
[coreStart.http]
);
const spacesEnabled = spacesApi !== undefined;
const [initialized, setInitialized] = useState(false);
const [accessDenied, setAccessDenied] = useState(false);
const [isPlatinumOrTrialLicense, setIsPlatinumOrTrialLicense] = useState(true);
@ -153,20 +152,18 @@ export const JobsListPage: FC<{
>
<EuiFlexGroup>
<EuiFlexItem grow={false}>
{spacesEnabled && (
<>
<EuiButtonEmpty
onClick={() => setShowSyncFlyout(true)}
data-test-subj="mlStackMgmtSyncButton"
>
{i18n.translate('xpack.ml.management.jobsList.syncFlyoutButton', {
defaultMessage: 'Synchronize saved objects',
})}
</EuiButtonEmpty>
{showSyncFlyout && <JobSpacesSyncFlyout onClose={onCloseSyncFlyout} />}
<EuiSpacer size="s" />
</>
)}
<>
<EuiButtonEmpty
onClick={() => setShowSyncFlyout(true)}
data-test-subj="mlStackMgmtSyncButton"
>
{i18n.translate('xpack.ml.management.jobsList.syncFlyoutButton', {
defaultMessage: 'Synchronize saved objects',
})}
</EuiButtonEmpty>
{showSyncFlyout && <JobSpacesSyncFlyout onClose={onCloseSyncFlyout} />}
<EuiSpacer size="s" />
</>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<ExportJobsFlyout

View file

@ -32,7 +32,7 @@ import { getFilters } from './filters';
import { useTableState } from './use_table_state';
interface Props {
spacesApi: SpacesPluginStart | undefined;
spacesApi?: SpacesPluginStart;
setCurrentTab: (tabId: MlSavedObjectType) => void;
}