Skip to content

Commit

Permalink
[ML] Changes for optional spaces plugin (#151170)
Browse files Browse the repository at this point in the history
Changes to ensure ML behaves correctly when the spaces plugin is
disabled.
Related to #149687
Closes #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.
  • Loading branch information
jgowdyelastic authored Feb 16, 2023
1 parent 41afa5c commit 31c73b9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface StartPlugins {
usageCollection?: UsageCollectionSetup;
fieldFormats: FieldFormatsRegistry;
dashboard: DashboardSetup;
spacesApi: SpacesPluginStart;
spacesApi?: SpacesPluginStart;
charts: ChartsPluginStart;
cases?: CasesUiStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 31c73b9

Please sign in to comment.