-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scaffolding from ansible variants, menu, routes, paths drop the write_only_fields vs hidden_fields distinction, pulp uses hidden_fields RepositoryForm -> ContainerRepositoryForm RepositoryForm, repositoryBasePath - handle file vs ansible different apis unify remoteType and variant to plugin DeleteRemoteModal
- Loading branch information
Showing
43 changed files
with
2,585 additions
and
886 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { msg } from '@lingui/macro'; | ||
import { Paths, formatPath } from 'src/paths'; | ||
import { Action } from './action'; | ||
|
||
export const fileRemoteCreateAction = Action({ | ||
title: msg`Add remote`, | ||
onClick: (item, { navigate }) => | ||
navigate(formatPath(Paths.file.remote.edit, { name: '_' })), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { msg, t } from '@lingui/macro'; | ||
import React from 'react'; | ||
import { FileRemoteAPI } from 'src/api'; | ||
import { DeleteRemoteModal } from 'src/components'; | ||
import { | ||
handleHttpError, | ||
parsePulpIDFromURL, | ||
taskAlert, | ||
waitForTaskUrl, | ||
} from 'src/utilities'; | ||
import { Action } from './action'; | ||
|
||
export const fileRemoteDeleteAction = Action({ | ||
title: msg`Delete`, | ||
modal: ({ addAlert, listQuery, setState, state }) => | ||
state.deleteModalOpen ? ( | ||
<DeleteRemoteModal | ||
closeAction={() => setState({ deleteModalOpen: null })} | ||
deleteAction={() => | ||
deleteRemote(state.deleteModalOpen, { addAlert, setState, listQuery }) | ||
} | ||
name={state.deleteModalOpen.name} | ||
/> | ||
) : null, | ||
onClick: ( | ||
{ name, id, pulp_href }: { name: string; id?: string; pulp_href?: string }, | ||
{ setState }, | ||
) => | ||
setState({ | ||
deleteModalOpen: { pulpId: id || parsePulpIDFromURL(pulp_href), name }, | ||
}), | ||
}); | ||
|
||
function deleteRemote({ name, pulpId }, { addAlert, setState, listQuery }) { | ||
return FileRemoteAPI.delete(pulpId) | ||
.then(({ data }) => { | ||
addAlert(taskAlert(data.task, t`Removal started for remote ${name}`)); | ||
setState({ deleteModalOpen: null }); | ||
return waitForTaskUrl(data.task); | ||
}) | ||
.then(() => listQuery()) | ||
.catch( | ||
handleHttpError(t`Failed to remove remote ${name}`, () => null, addAlert), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { msg } from '@lingui/macro'; | ||
import { Paths, formatPath } from 'src/paths'; | ||
import { Action } from './action'; | ||
|
||
export const fileRemoteEditAction = Action({ | ||
title: msg`Edit`, | ||
onClick: ({ name }, { navigate }) => | ||
navigate(formatPath(Paths.file.remote.edit, { name })), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { msg } from '@lingui/macro'; | ||
import { Paths, formatPath } from 'src/paths'; | ||
import { Action } from './action'; | ||
|
||
export const fileRepositoryCreateAction = Action({ | ||
title: msg`Add repository`, | ||
onClick: (item, { navigate }) => | ||
navigate(formatPath(Paths.file.repository.edit, { name: '_' })), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { msg, t } from '@lingui/macro'; | ||
import React from 'react'; | ||
import { FileDistributionAPI, FileRepositoryAPI } from 'src/api'; | ||
import { DeleteAnsibleRepositoryModal } from 'src/components'; | ||
import { | ||
handleHttpError, | ||
parsePulpIDFromURL, | ||
taskAlert, | ||
waitForTaskUrl, | ||
} from 'src/utilities'; | ||
import { Action } from './action'; | ||
|
||
export const fileRepositoryDeleteAction = Action({ | ||
title: msg`Delete`, | ||
modal: ({ addAlert, listQuery, setState, state }) => | ||
state.deleteModalOpen ? ( | ||
<DeleteAnsibleRepositoryModal | ||
closeAction={() => setState({ deleteModalOpen: null })} | ||
deleteAction={() => | ||
deleteRepository(state.deleteModalOpen, { | ||
addAlert, | ||
listQuery, | ||
setState, | ||
}) | ||
} | ||
name={state.deleteModalOpen.name} | ||
/> | ||
) : null, | ||
onClick: ( | ||
{ name, id, pulp_href }: { name: string; id?: string; pulp_href?: string }, | ||
{ setState }, | ||
) => | ||
setState({ | ||
deleteModalOpen: { | ||
pulpId: id || parsePulpIDFromURL(pulp_href), | ||
name, | ||
pulp_href, | ||
}, | ||
}), | ||
}); | ||
|
||
async function deleteRepository( | ||
{ name, pulp_href, pulpId }, | ||
{ addAlert, setState, listQuery }, | ||
) { | ||
// TODO: handle more pages | ||
const distributionsToDelete = await FileDistributionAPI.list({ | ||
repository: pulp_href, | ||
page: 1, | ||
page_size: 100, | ||
}) | ||
.then(({ data: { results } }) => results || []) | ||
.catch((e) => { | ||
handleHttpError( | ||
t`Failed to list distributions, removing only the repository.`, | ||
() => null, | ||
addAlert, | ||
)(e); | ||
return []; | ||
}); | ||
|
||
const deleteRepo = FileRepositoryAPI.delete(pulpId) | ||
.then(({ data }) => { | ||
addAlert(taskAlert(data.task, t`Removal started for repository ${name}`)); | ||
return waitForTaskUrl(data.task); | ||
}) | ||
.catch( | ||
handleHttpError( | ||
t`Failed to remove repository ${name}`, | ||
() => setState({ deleteModalOpen: null }), | ||
addAlert, | ||
), | ||
); | ||
|
||
const deleteDistribution = ({ name, pulp_href }) => { | ||
const distribution_id = parsePulpIDFromURL(pulp_href); | ||
return FileDistributionAPI.delete(distribution_id) | ||
.then(({ data }) => { | ||
addAlert( | ||
taskAlert(data.task, t`Removal started for distribution ${name}`), | ||
); | ||
return waitForTaskUrl(data.task); | ||
}) | ||
.catch( | ||
handleHttpError( | ||
t`Failed to remove distribution ${name}`, | ||
() => null, | ||
addAlert, | ||
), | ||
); | ||
}; | ||
|
||
return Promise.all([ | ||
deleteRepo, | ||
...distributionsToDelete.map(deleteDistribution), | ||
]).then(() => { | ||
setState({ deleteModalOpen: null }); | ||
listQuery(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { msg } from '@lingui/macro'; | ||
import { Paths, formatPath } from 'src/paths'; | ||
import { Action } from './action'; | ||
|
||
export const fileRepositoryEditAction = Action({ | ||
title: msg`Edit`, | ||
onClick: ({ name }, { navigate }) => | ||
navigate(formatPath(Paths.file.repository.edit, { name })), | ||
}); |
Oops, something went wrong.