forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a way to extend the UI with an Java API (keycloak#23772)
* POC to see how we could extend the UI This is very crude and there are still open issues that need to be worked out Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * added saving option Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * added list and recreate client form Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * add tab ui Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * integrate tabs Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * remove examples Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * fixed error messages Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> * added Feature for ui customization Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> --------- Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> Signed-off-by: ShefeeqPM <86718986+ShefeeqPM@users.noreply.github.com>
- Loading branch information
Showing
32 changed files
with
729 additions
and
155 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
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
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,67 @@ | ||
import { ButtonVariant, DropdownItem } from "@patternfly/react-core"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useNavigate, useParams } from "react-router-dom"; | ||
import { adminClient } from "../admin-client"; | ||
import { useAlerts } from "../components/alert/Alerts"; | ||
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog"; | ||
import { ViewHeader } from "../components/view-header/ViewHeader"; | ||
import { useServerInfo } from "../context/server-info/ServerInfoProvider"; | ||
import { PageHandler } from "./PageHandler"; | ||
import { PAGE_PROVIDER } from "./PageList"; | ||
import { PageParams, toPage } from "./routes"; | ||
import { useRealm } from "../context/realm-context/RealmContext"; | ||
|
||
export default function Page() { | ||
const { t } = useTranslation(); | ||
const { componentTypes } = useServerInfo(); | ||
const { realm } = useRealm(); | ||
const pages = componentTypes?.[PAGE_PROVIDER]; | ||
const navigate = useNavigate(); | ||
const { id, providerId } = useParams<PageParams>(); | ||
const { addAlert, addError } = useAlerts(); | ||
|
||
const page = pages?.find((p) => p.id === providerId); | ||
if (!page) { | ||
throw new Error(t("notFound")); | ||
} | ||
|
||
const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({ | ||
titleKey: "itemDeleteConfirmTitle", | ||
messageKey: "itemDeleteConfirm", | ||
continueButtonLabel: "delete", | ||
continueButtonVariant: ButtonVariant.danger, | ||
onConfirm: async () => { | ||
try { | ||
await adminClient.components.del({ | ||
id: id!, | ||
}); | ||
addAlert(t("itemDeletedSuccess")); | ||
navigate(toPage({ realm, providerId: providerId! })); | ||
} catch (error) { | ||
addError("itemSaveError", error); | ||
} | ||
}, | ||
}); | ||
return ( | ||
<> | ||
<DeleteConfirm /> | ||
<ViewHeader | ||
titleKey={id || t("createItem")} | ||
dropdownItems={ | ||
id | ||
? [ | ||
<DropdownItem | ||
data-testid="delete-item" | ||
key="delete" | ||
onClick={() => toggleDeleteDialog()} | ||
> | ||
{t("delete")} | ||
</DropdownItem>, | ||
] | ||
: undefined | ||
} | ||
/> | ||
<PageHandler providerType={PAGE_PROVIDER} id={id} page={page} /> | ||
</> | ||
); | ||
} |
Oops, something went wrong.