mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* [ML] Disabling delete data view for data frame analytics and transforms wizards * bulk transforms * unused variable Co-authored-by: James Gowdy <jgowdy@elastic.co>
This commit is contained in:
parent
d91e394657
commit
b9888d24d3
5 changed files with 30 additions and 2 deletions
|
@ -28,6 +28,7 @@ export const DeleteActionModal: FC<DeleteAction> = ({
|
|||
toggleDeleteIndex,
|
||||
toggleDeleteIndexPattern,
|
||||
userCanDeleteIndex,
|
||||
userCanDeleteDataView,
|
||||
}) => {
|
||||
if (item === undefined) {
|
||||
return null;
|
||||
|
@ -85,6 +86,7 @@ export const DeleteActionModal: FC<DeleteAction> = ({
|
|||
})}
|
||||
checked={deleteIndexPattern}
|
||||
onChange={toggleDeleteIndexPattern}
|
||||
disabled={userCanDeleteDataView === false}
|
||||
/>
|
||||
)}
|
||||
</EuiFlexItem>
|
||||
|
|
|
@ -42,11 +42,13 @@ export const useDeleteAction = (canDeleteDataFrameAnalytics: boolean) => {
|
|||
const [deleteTargetIndex, setDeleteTargetIndex] = useState<boolean>(true);
|
||||
const [deleteIndexPattern, setDeleteIndexPattern] = useState<boolean>(true);
|
||||
const [userCanDeleteIndex, setUserCanDeleteIndex] = useState<boolean>(false);
|
||||
const [userCanDeleteDataView, setUserCanDeleteDataView] = useState<boolean>(false);
|
||||
const [indexPatternExists, setIndexPatternExists] = useState<boolean>(false);
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
|
||||
const {
|
||||
data: { dataViews },
|
||||
application: { capabilities },
|
||||
} = useMlKibana().services;
|
||||
|
||||
const indexName = item?.config.dest.index ?? '';
|
||||
|
@ -83,6 +85,14 @@ export const useDeleteAction = (canDeleteDataFrameAnalytics: boolean) => {
|
|||
if (userCanDelete) {
|
||||
setUserCanDeleteIndex(true);
|
||||
}
|
||||
|
||||
const canDeleteDataView =
|
||||
capabilities.savedObjectsManagement.delete === true ||
|
||||
capabilities.indexPatterns.save === true;
|
||||
setUserCanDeleteDataView(canDeleteDataView);
|
||||
if (canDeleteDataView === false) {
|
||||
setDeleteIndexPattern(false);
|
||||
}
|
||||
} catch (e) {
|
||||
const error = extractErrorMessage(e);
|
||||
setIsLoading(false);
|
||||
|
@ -180,5 +190,6 @@ export const useDeleteAction = (canDeleteDataFrameAnalytics: boolean) => {
|
|||
toggleDeleteIndex,
|
||||
toggleDeleteIndexPattern,
|
||||
userCanDeleteIndex,
|
||||
userCanDeleteDataView,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -25,6 +25,7 @@ export const useDeleteIndexAndTargetIndex = (items: TransformListRow[]) => {
|
|||
http,
|
||||
savedObjects,
|
||||
ml: { extractErrorMessage },
|
||||
application: { capabilities },
|
||||
} = useAppDependencies();
|
||||
const toastNotifications = useToastNotifications();
|
||||
|
||||
|
@ -32,6 +33,7 @@ export const useDeleteIndexAndTargetIndex = (items: TransformListRow[]) => {
|
|||
const [deleteIndexPattern, setDeleteIndexPattern] = useState<boolean>(true);
|
||||
const [userCanDeleteIndex, setUserCanDeleteIndex] = useState<boolean>(false);
|
||||
const [indexPatternExists, setIndexPatternExists] = useState<boolean>(false);
|
||||
const [userCanDeleteDataView, setUserCanDeleteDataView] = useState<boolean>(false);
|
||||
|
||||
const toggleDeleteIndex = useCallback(
|
||||
() => setDeleteDestIndex(!deleteDestIndex),
|
||||
|
@ -70,6 +72,13 @@ export const useDeleteIndexAndTargetIndex = (items: TransformListRow[]) => {
|
|||
if (userCanDelete) {
|
||||
setUserCanDeleteIndex(true);
|
||||
}
|
||||
const canDeleteDataView =
|
||||
capabilities.savedObjectsManagement.delete === true ||
|
||||
capabilities.indexPatterns.save === true;
|
||||
setUserCanDeleteDataView(canDeleteDataView);
|
||||
if (canDeleteDataView === false) {
|
||||
setDeleteIndexPattern(false);
|
||||
}
|
||||
} catch (e) {
|
||||
toastNotifications.addDanger(
|
||||
i18n.translate(
|
||||
|
@ -80,7 +89,7 @@ export const useDeleteIndexAndTargetIndex = (items: TransformListRow[]) => {
|
|||
)
|
||||
);
|
||||
}
|
||||
}, [http, toastNotifications]);
|
||||
}, [http, toastNotifications, capabilities]);
|
||||
|
||||
useEffect(() => {
|
||||
checkUserIndexPermission();
|
||||
|
@ -99,6 +108,7 @@ export const useDeleteIndexAndTargetIndex = (items: TransformListRow[]) => {
|
|||
|
||||
return {
|
||||
userCanDeleteIndex,
|
||||
userCanDeleteDataView,
|
||||
deleteDestIndex,
|
||||
indexPatternExists,
|
||||
deleteIndexPattern,
|
||||
|
|
|
@ -29,6 +29,7 @@ export const DeleteActionModal: FC<DeleteAction> = ({
|
|||
toggleDeleteIndex,
|
||||
toggleDeleteIndexPattern,
|
||||
userCanDeleteIndex,
|
||||
userCanDeleteDataView,
|
||||
}) => {
|
||||
const isBulkAction = items.length > 1;
|
||||
|
||||
|
@ -74,6 +75,7 @@ export const DeleteActionModal: FC<DeleteAction> = ({
|
|||
)}
|
||||
checked={deleteIndexPattern}
|
||||
onChange={toggleDeleteIndexPattern}
|
||||
disabled={userCanDeleteDataView === false}
|
||||
/>
|
||||
}
|
||||
</EuiFlexItem>
|
||||
|
@ -114,6 +116,7 @@ export const DeleteActionModal: FC<DeleteAction> = ({
|
|||
)}
|
||||
checked={deleteIndexPattern}
|
||||
onChange={toggleDeleteIndexPattern}
|
||||
disabled={userCanDeleteDataView === false}
|
||||
/>
|
||||
</EuiFlexItem>
|
||||
)}
|
||||
|
|
|
@ -38,6 +38,7 @@ export const useDeleteAction = (forceDisable: boolean) => {
|
|||
|
||||
const {
|
||||
userCanDeleteIndex,
|
||||
userCanDeleteDataView,
|
||||
deleteDestIndex,
|
||||
indexPatternExists,
|
||||
deleteIndexPattern,
|
||||
|
@ -50,7 +51,7 @@ export const useDeleteAction = (forceDisable: boolean) => {
|
|||
|
||||
const shouldDeleteDestIndex = userCanDeleteIndex && deleteDestIndex;
|
||||
const shouldDeleteDestIndexPattern =
|
||||
userCanDeleteIndex && indexPatternExists && deleteIndexPattern;
|
||||
userCanDeleteIndex && userCanDeleteDataView && indexPatternExists && deleteIndexPattern;
|
||||
// if we are deleting multiple transforms, then force delete all if at least one item has failed
|
||||
// else, force delete only when the item user picks has failed
|
||||
const forceDelete = isBulkAction
|
||||
|
@ -113,5 +114,6 @@ export const useDeleteAction = (forceDisable: boolean) => {
|
|||
toggleDeleteIndex,
|
||||
toggleDeleteIndexPattern,
|
||||
userCanDeleteIndex,
|
||||
userCanDeleteDataView,
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue