Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete collection all or single repo #3759

Merged
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
181cf7d
Menu option to delete collection from all/repo
MilanPospisil May 23, 2023
8e555ef
Delete collection operation
MilanPospisil May 23, 2023
bfa02e0
Collection version menu option
MilanPospisil May 23, 2023
645a0f1
Delete collection version
MilanPospisil May 24, 2023
5fff294
Test changes
MilanPospisil May 24, 2023
5ebfa44
Test changes repairs
MilanPospisil May 24, 2023
a31ef09
Test for deletion collection from repo
MilanPospisil May 25, 2023
2caab1e
Tests fix
MilanPospisil May 29, 2023
8626e8f
WIP
MilanPospisil May 29, 2023
7d81b5f
Clear of orphans
MilanPospisil May 30, 2023
e4d999f
Clear collections only
MilanPospisil May 30, 2023
a260d7c
Better cleanup
MilanPospisil May 30, 2023
85032b9
Remove cleanup
MilanPospisil May 31, 2023
530b987
Delete version from repo test
MilanPospisil May 31, 2023
dadb02d
Handle translations
MilanPospisil May 31, 2023
9a73dae
Issue
MilanPospisil May 31, 2023
bf9d68a
PR Checks
MilanPospisil May 31, 2023
411d364
Repair selector for insights
MilanPospisil Jun 1, 2023
50dbc7b
Fix collection test for insights
MilanPospisil Jun 6, 2023
4ad2a4e
Fix collection test for insights2
MilanPospisil Jun 6, 2023
e85c97a
Finally really fix insights tests :)
MilanPospisil Jun 7, 2023
17fa876
Switch contains and not contains
MilanPospisil Jun 7, 2023
f5a9556
Disable new test for insights
MilanPospisil Jun 7, 2023
d5187c6
Do not delete repos
MilanPospisil Jun 7, 2023
d755d80
WIP
MilanPospisil Jun 7, 2023
65ea275
Correct tests
MilanPospisil Jun 8, 2023
d94356e
Collection Tests back to normal + new repo test
MilanPospisil Jun 8, 2023
cc80292
Fix collection test
MilanPospisil Jun 8, 2023
e7eaf16
Clear the mess done by previous commits in deleteAllCollections
MilanPospisil Jun 8, 2023
a7f8dbc
Make deleteNamespacesAndCollections clearer
MilanPospisil Jun 8, 2023
eb31ea1
Move test to approvals
MilanPospisil Jun 8, 2023
1c897b9
Fix copy collection version test
MilanPospisil Jun 9, 2023
ae544f8
Disable removal from repo for insights
MilanPospisil Jun 9, 2023
0d4a242
Better translations in delete modal
MilanPospisil Jun 12, 2023
2abdf20
Change condition to display delete from repo to feature flag instead …
MilanPospisil Jun 12, 2023
72b7279
Add deleteFromRepo string type
MilanPospisil Jun 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Menu option to delete collection from all/repo
MilanPospisil committed Jun 13, 2023
commit 181cf7dc3e9b1bb1189630ace4cf6a4fcaf2e988
27 changes: 25 additions & 2 deletions src/components/delete-modal/delete-collection-modal.tsx
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ interface IProps {
cancelAction: () => void;
deleteAction: () => void;
setConfirmDelete: (val) => void;
deleteFromRepo: any;
}

export const DeleteCollectionModal = (props: IProps) => {
@@ -25,6 +26,7 @@ export const DeleteCollectionModal = (props: IProps) => {
cancelAction,
deleteAction,
setConfirmDelete,
deleteFromRepo,
} = props;

return (
@@ -50,6 +52,13 @@ export const DeleteCollectionModal = (props: IProps) => {
{deleteCollection.collection_version.name} v
{collectionVersion}
</b>{' '}
{deleteFromRepo ? (
<>
from repository <b>{deleteFromRepo} </b>
</>
) : (
<>from the system </>
)}{' '}
and its data will be lost and this will cause the entire
collection to be deleted.
</Trans>
@@ -60,14 +69,28 @@ export const DeleteCollectionModal = (props: IProps) => {
{deleteCollection.collection_version.name} v
{collectionVersion}
</b>{' '}
{deleteFromRepo ? (
<>
from repository <b>{deleteFromRepo} </b>
</>
) : (
<>from the system </>
)}{' '}
and its data will be lost.
</Trans>
)}
</>
) : (
<Trans>
Deleting <b>{deleteCollection.collection_version.name}</b> and its
data will be lost.
Deleting <b>{deleteCollection.collection_version.name}</b>{' '}
{deleteFromRepo ? (
<>
from repository <b>{deleteFromRepo} </b>
</>
) : (
<>from the system </>
)}{' '}
and its data will be lost.
</Trans>
)}
</Text>
17 changes: 15 additions & 2 deletions src/components/headers/collection-header.tsx
Original file line number Diff line number Diff line change
@@ -103,6 +103,7 @@ interface IState {
versionToUploadCertificate: CollectionVersionSearch;
namespace: NamespaceType;
copyCollectionToRepositoryModal: CollectionVersionSearch;
deleteAll: boolean;
}

export class CollectionHeader extends React.Component<IProps, IState> {
@@ -123,6 +124,7 @@ export class CollectionHeader extends React.Component<IProps, IState> {
page_size: Constants.DEFAULT_PAGINATION_OPTIONS[0],
},
deleteCollection: null,
deleteAll: false,
collectionVersion: null,
confirmDelete: false,
alerts: [],
@@ -233,7 +235,14 @@ export class CollectionHeader extends React.Component<IProps, IState> {
DeleteCollectionUtils.deleteMenuOption({
canDeleteCollection: hasPermission('ansible.delete_collection'),
noDependencies,
onClick: () => this.openDeleteModalWithConfirm(),
onClick: () => this.openDeleteModalWithConfirm(null, true),
deleteAll: true,
}),
DeleteCollectionUtils.deleteMenuOption({
canDeleteCollection: hasPermission('ansible.delete_collection'),
noDependencies,
onClick: () => this.openDeleteModalWithConfirm(null, false),
deleteAll: false,
}),
hasPermission('ansible.delete_collection') && (
<DropdownItem
@@ -420,6 +429,9 @@ export class CollectionHeader extends React.Component<IProps, IState> {
});
})
}
deleteFromRepo={
this.state.deleteAll ? null : collection.repository.name
}
/>
{copyCollectionToRepositoryModal && (
<CopyCollectionToRepositoryModal
@@ -1016,11 +1028,12 @@ export class CollectionHeader extends React.Component<IProps, IState> {
this.setState({ showImportModal: isOpen });
}

private openDeleteModalWithConfirm(version = null) {
private openDeleteModalWithConfirm(version = null, deleteAll = true) {
this.setState({
deleteCollection: this.props.collection,
collectionVersion: version,
confirmDelete: false,
deleteAll: deleteAll,
});
}

19 changes: 19 additions & 0 deletions src/containers/namespace-detail/namespace-detail.tsx
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@ interface IState {
showRoleRemoveModal?: string;
showRoleSelectWizard?: { roles?: RoleType[] };
group: GroupType;
deleteAll: boolean;
}

export class NamespaceDetail extends React.Component<RouteProps, IState> {
@@ -137,6 +138,7 @@ export class NamespaceDetail extends React.Component<RouteProps, IState> {
showRoleRemoveModal: null,
showRoleSelectWizard: null,
group: null,
deleteAll: true,
};
}

@@ -348,6 +350,9 @@ export class NamespaceDetail extends React.Component<RouteProps, IState> {
}),
)
}
deleteFromRepo={
this.state.deleteAll ? null : deleteCollection?.repository?.name
}
/>
{isOpenNamespaceModal && (
<DeleteModal
@@ -977,7 +982,21 @@ export class NamespaceDetail extends React.Component<RouteProps, IState> {
addAlert: (alert) => this.addAlert(alert),
setState: (state) => this.setState(state),
collection,
deleteAll: true,
}),
deleteAll: true,
}),
DeleteCollectionUtils.deleteMenuOption({
canDeleteCollection: hasPermission('ansible.delete_collection'),
noDependencies: null,
onClick: () =>
DeleteCollectionUtils.tryOpenDeleteModalWithConfirm({
addAlert: (alert) => this.addAlert(alert),
setState: (state) => this.setState(state),
collection,
deleteAll: false,
}),
deleteAll: false,
}),
<DropdownItem
onClick={() =>
19 changes: 19 additions & 0 deletions src/containers/search/search.tsx
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ interface IState {
deleteCollection: CollectionVersionSearch;
confirmDelete: boolean;
isDeletionPending: boolean;
deleteAll: boolean;
}

class Search extends React.Component<RouteProps, IState> {
@@ -104,6 +105,7 @@ class Search extends React.Component<RouteProps, IState> {
deleteCollection: null,
confirmDelete: false,
isDeletionPending: false,
deleteAll: true,
};
}

@@ -182,6 +184,9 @@ class Search extends React.Component<RouteProps, IState> {
}),
)
}
deleteFromRepo={
this.state.deleteAll ? null : deleteCollection?.repository?.name
}
/>

{showImportModal && (
@@ -376,7 +381,21 @@ class Search extends React.Component<RouteProps, IState> {
addAlert: (alert) => this.addAlert(alert),
setState: (state) => this.setState(state),
collection,
deleteAll: true,
}),
deleteAll: true,
}),
DeleteCollectionUtils.deleteMenuOption({
canDeleteCollection: hasPermission('ansible.delete_collection'),
noDependencies: null,
onClick: () =>
DeleteCollectionUtils.tryOpenDeleteModalWithConfirm({
addAlert: (alert) => this.addAlert(alert),
setState: (state) => this.setState(state),
collection,
deleteAll: false,
}),
deleteAll: false,
}),
hasPermission('galaxy.upload_to_namespace') && (
<DropdownItem
18 changes: 11 additions & 7 deletions src/utilities/delete-collection.tsx
Original file line number Diff line number Diff line change
@@ -27,11 +27,16 @@ export class DeleteCollectionUtils {
canDeleteCollection,
noDependencies,
onClick,
deleteAll,
}) {
if (!canDeleteCollection) {
return null;
}

const caption = deleteAll
? t`Delete entire collection from system`
: t`Delete collection from repository`;

if (noDependencies === false) {
return (
<Tooltip
@@ -45,7 +50,7 @@ export class DeleteCollectionUtils {
</Trans>
}
>
<DropdownItem isDisabled>{t`Delete entire collection`}</DropdownItem>
<DropdownItem isDisabled>{caption}</DropdownItem>
</Tooltip>
);
}
@@ -56,7 +61,7 @@ export class DeleteCollectionUtils {
onClick={onClick}
data-cy='delete-collection-dropdown'
>
{t`Delete entire collection`}
{caption}
</DropdownItem>
);
}
@@ -65,6 +70,7 @@ export class DeleteCollectionUtils {
addAlert,
setState,
collection,
deleteAll,
}) {
DeleteCollectionUtils.getUsedbyDependencies(collection)
.then((noDependencies) =>
@@ -73,6 +79,7 @@ export class DeleteCollectionUtils {
setState,
noDependencies,
collection,
deleteAll,
}),
)
.catch((alert) => addAlert(alert));
@@ -83,11 +90,13 @@ export class DeleteCollectionUtils {
setState,
noDependencies,
collection,
deleteAll,
}) {
if (noDependencies) {
setState({
deleteCollection: collection,
confirmDelete: false,
deleteAll: deleteAll,
});
} else {
addAlert({
@@ -100,11 +109,6 @@ export class DeleteCollectionUtils {
),
variant: 'warning',
});

setState({
deleteCollection: collection,
confirmDelete: false,
});
}
}