mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 01:18:42 +00:00
Create/Edit pack UX: Pack save redirects to manage packs page, fix flash message (#2767)
This commit is contained in:
parent
d0777ccfd3
commit
ed2a9abd9c
3 changed files with 18 additions and 21 deletions
1
changes/issue-2749-save-pack-redirect
Normal file
1
changes/issue-2749-save-pack-redirect
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Saving a pack redirects to the Manage Packs Page, fix flash render after creating pack
|
||||
|
|
@ -36,6 +36,7 @@ import PackQueryEditorModal from "./components/PackQueryEditorModal";
|
|||
import RemovePackQueryModal from "./components/RemovePackQueryModal";
|
||||
|
||||
interface IEditPacksPageProps {
|
||||
router: any;
|
||||
params: Params;
|
||||
}
|
||||
|
||||
|
|
@ -71,6 +72,7 @@ interface IFormData {
|
|||
const baseClass = "edit-pack-page";
|
||||
|
||||
const EditPacksPage = ({
|
||||
router,
|
||||
params: { id: paramsPackId },
|
||||
}: IEditPacksPageProps): JSX.Element => {
|
||||
const { isPremiumTier } = useContext(AppContext);
|
||||
|
|
@ -102,13 +104,13 @@ const EditPacksPage = ({
|
|||
}
|
||||
);
|
||||
|
||||
const { data: storedPack, refetch: refetchStoredPack } = useQuery<
|
||||
IStoredPackResponse,
|
||||
Error,
|
||||
IPack
|
||||
>(["stored pack"], () => packsAPI.load(packId), {
|
||||
select: (data: IStoredPackResponse) => data.pack,
|
||||
});
|
||||
const { data: storedPack } = useQuery<IStoredPackResponse, Error, IPack>(
|
||||
["stored pack"],
|
||||
() => packsAPI.load(packId),
|
||||
{
|
||||
select: (data: IStoredPackResponse) => data.pack,
|
||||
}
|
||||
);
|
||||
|
||||
const {
|
||||
data: storedPackQueries,
|
||||
|
|
@ -226,8 +228,7 @@ const EditPacksPage = ({
|
|||
packsAPI
|
||||
.update(packId, updatedPack)
|
||||
.then(() => {
|
||||
refetchStoredPack();
|
||||
window.scrollTo(0, 0);
|
||||
router.push(PATHS.MANAGE_PACKS);
|
||||
dispatch(renderFlash("success", `Successfully updated this pack.`));
|
||||
})
|
||||
.catch((response) => {
|
||||
|
|
|
|||
|
|
@ -41,25 +41,20 @@ export class PackComposerPage extends Component {
|
|||
return false;
|
||||
};
|
||||
|
||||
visitPackPage = (packID) => {
|
||||
const { dispatch } = this.props;
|
||||
|
||||
dispatch(push(PATHS.PACK(packID)));
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
handleSubmit = (formData) => {
|
||||
const { create } = packActions;
|
||||
const { dispatch } = this.props;
|
||||
const { visitPackPage } = this;
|
||||
|
||||
return dispatch(create(formData))
|
||||
.then((pack) => {
|
||||
const { id: packID } = pack;
|
||||
|
||||
dispatch(renderFlash("success", `Pack successfully created.`));
|
||||
visitPackPage(packID);
|
||||
dispatch(push(PATHS.PACK(packID)));
|
||||
dispatch(
|
||||
renderFlash(
|
||||
"success",
|
||||
"Pack successfully created. Add queries to your pack."
|
||||
)
|
||||
);
|
||||
})
|
||||
.catch((response) => {
|
||||
if (response.base.slice(0, 27) === "Error 1062: Duplicate entry") {
|
||||
|
|
|
|||
Loading…
Reference in a new issue