Skip to content

Commit

Permalink
Merge branch 'main' into PPF-460-uitpas-activation
Browse files Browse the repository at this point in the history
  • Loading branch information
vhande committed Jun 28, 2024
2 parents 19416af + 59f7d65 commit 6ab22c3
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 24 deletions.
4 changes: 3 additions & 1 deletion app/Domain/Auth/Controllers/LogoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ private function getLogoutLink(): string
/** @var Auth0 $auth0 */
$auth0 = app(Auth0::class);

$idtoken = $auth0->getIdToken();

if (Auth::check()) {
$auth0->logout();
Auth::guard(config('nova.guard'))->logout();
Expand All @@ -32,7 +34,7 @@ private function getLogoutLink(): string
config(KeycloakConfig::KEYCLOAK_REALM_NAME),
config(KeycloakConfig::KEYCLOAK_CLIENT_ID),
$url,
$auth0->getIdToken()
$idtoken
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Nova/Resources/KeycloakClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function fields(NovaRequest $request): array
Text::make('Open', function (KeycloakClientModel $model) {
$client = $model->toDomain();
$realm = App::get(Realms::class)->getRealmByEnvironment($client->environment);
$url = $realm->baseUrl . 'admin/master/console/#/' . $realm->internalName . '/clients/' . $client->id->toString() . '/settings';
$url = $realm->baseUrl . 'dashboard/' . $realm->internalName . '/clients/' . urlencode($client->clientId) . '/settings';

return sprintf('<a href="%s" class="link-default" target="_blank">Open in Keycloak</a>', $url);
})->asHtml(),
Expand Down
6 changes: 5 additions & 1 deletion resources/ts/Components/Integrations/Detail/Credentials.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const Credentials = ({
subscription,
type,
keyVisibility,
keyVisibilityUpgrade,
legacyAuthConsumers,
authClients,
oldCredentialsExpirationDate,
Expand All @@ -40,7 +41,9 @@ export const Credentials = ({
const hasAnyCredentials = Boolean(
legacyAuthConsumers.length || authClients.length
);
usePolling(!hasAnyCredentials, { only: ["integration"] });
const isV1Upgraded =
keyVisibility === KeyVisibility.v1 && !!keyVisibilityUpgrade;
usePolling(!hasAnyCredentials || isV1Upgraded, { only: ["integration"] });
const credentials = useMemo(
() => ({
legacyTestConsumer: legacyAuthConsumers.find(
Expand Down Expand Up @@ -96,6 +99,7 @@ export const Credentials = ({
type={type}
subscription={subscription}
keyVisibility={keyVisibility}
keyVisibilityUpgrade={keyVisibilityUpgrade}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ import type { Integration } from "../../../types/Integration";
import { KeyVisibility } from "../../../types/KeyVisibility";
import { router } from "@inertiajs/react";
import { Link } from "../../Link";
import { Alert } from "../../Alert";

type Props = Pick<
Integration,
"id" | "status" | "subscription" | "type" | "keyVisibility"
| "id"
| "status"
| "subscription"
| "type"
| "keyVisibility"
| "keyVisibilityUpgrade"
> &
Credentials & { email: string };

Expand All @@ -27,8 +33,10 @@ export const CredentialsAuthClients = ({
subscription,
type,
keyVisibility,
keyVisibilityUpgrade,
}: Props) => {
const { t } = useTranslation();
const isKeyVisibilityV1 = keyVisibility === KeyVisibility.v1;

const auth0TestClientWithLabels = [
{
Expand Down Expand Up @@ -62,27 +70,32 @@ export const CredentialsAuthClients = ({
<Heading className="font-semibold lg:min-w-60" level={4}>
{t("details.credentials.uitid_v2")}
</Heading>
{keyVisibility === KeyVisibility.v1 ? (
<div className="flex flex-col flex-1 gap-4">
<div>
<Trans
i18nKey="details.credentials.uitid_alert"
components={[
<Link
key={t("details.credentials.uitid_alert")}
href={t("details.credentials.uitid_alert_link")}
className="text-publiq-blue-dark hover:underline mb-3"
/>,
]}
/>
{isKeyVisibilityV1 ? (
keyVisibilityUpgrade ? (
<Alert variant="info">{t("integrations.pending_credentials")}</Alert>
) : (
<div className="flex flex-col flex-1 gap-4">
<div>
<Trans
i18nKey="details.credentials.uitid_alert"
components={[
<Link
key={t("details.credentials.uitid_alert")}
href={t("details.credentials.uitid_alert_link")}
className="text-publiq-blue-dark hover:underline mb-3"
/>,
]}
/>
</div>

<ButtonPrimary
className="self-start"
onClick={handleKeyVisibilityUpgrade}
>
{t("details.credentials.action_uitid")}
</ButtonPrimary>
</div>
<ButtonPrimary
className="self-start"
onClick={handleKeyVisibilityUpgrade}
>
{t("details.credentials.action_uitid")}
</ButtonPrimary>
</div>
)
) : (
<div className="flex flex-col flex-1 gap-4">
<div className="flex flex-col gap-3">
Expand Down
6 changes: 6 additions & 0 deletions resources/ts/types/Integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export type Coupon = {
reduction: number;
};

type KeyVisibilityUpgrade = {
id: string;
integrationId: string;
keyVisibility: string;
};
export type Integration = {
id: string;
type: Values<typeof IntegrationType>;
Expand All @@ -32,4 +37,5 @@ export type Integration = {
authClients: AuthClient[];
legacyAuthConsumers: LegacyAuthConsumer[];
keyVisibility: KeyVisibility;
keyVisibilityUpgrade: KeyVisibilityUpgrade | null;
};

0 comments on commit 6ab22c3

Please sign in to comment.