chore: update identity provider id

This commit is contained in:
Steven
2024-08-12 23:41:56 +08:00
parent 80304070e7
commit ea7ea0ac24
15 changed files with 277 additions and 270 deletions

View File

@ -28,6 +28,7 @@
"react-router-dom": "^6.24.1",
"react-use": "^17.5.1",
"tailwindcss": "^3.4.3",
"uuid": "^10.0.0",
"zustand": "^4.5.4"
},
"devDependencies": {
@ -36,6 +37,7 @@
"@types/lodash-es": "^4.17.12",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.0",
"@vitejs/plugin-react-swc": "^3.6.0",

View File

@ -68,6 +68,9 @@ importers:
tailwindcss:
specifier: ^3.4.3
version: 3.4.4
uuid:
specifier: ^10.0.0
version: 10.0.0
zustand:
specifier: ^4.5.4
version: 4.5.4(@types/react@18.3.3)(immer@10.1.1)(react@18.3.1)
@ -87,6 +90,9 @@ importers:
'@types/react-dom':
specifier: ^18.2.25
version: 18.3.0
'@types/uuid':
specifier: ^10.0.0
version: 10.0.0
'@typescript-eslint/eslint-plugin':
specifier: ^7.16.1
version: 7.16.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0)(typescript@5.5.4)
@ -893,6 +899,9 @@ packages:
'@types/react@18.3.3':
resolution: {integrity: sha512-hti/R0pS0q1/xx+TsI73XIqk26eBsISZ2R0wUijXIngRK9R/e7Xw/cXVxQK7R5JjW+SV4zGcn5hXjudkN/pLIw==}
'@types/uuid@10.0.0':
resolution: {integrity: sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==}
'@typescript-eslint/eslint-plugin@7.16.1':
resolution: {integrity: sha512-SxdPak/5bO0EnGktV05+Hq8oatjAYVY3Zh2bye9pGZy6+jwyR3LG3YKkV4YatlsgqXP28BTeVm9pqwJM96vf2A==}
engines: {node: ^18.18.0 || >=20.0.0}
@ -2381,6 +2390,10 @@ packages:
util-deprecate@1.0.2:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
uuid@10.0.0:
resolution: {integrity: sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==}
hasBin: true
vite@5.3.4:
resolution: {integrity: sha512-Cw+7zL3ZG9/NZBB8C+8QbQZmR54GwqIz+WMI4b3JgdYJvX+ny9AjJXqkGQlDXSXRP9rP0B4tbciRMOVEKulVOA==}
engines: {node: ^18.0.0 || >=20.0.0}
@ -3184,6 +3197,8 @@ snapshots:
'@types/prop-types': 15.7.12
csstype: 3.1.2
'@types/uuid@10.0.0': {}
'@typescript-eslint/eslint-plugin@7.16.1(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0)(typescript@5.5.4)':
dependencies:
'@eslint-community/regexpp': 4.10.1
@ -4916,6 +4931,8 @@ snapshots:
util-deprecate@1.0.2: {}
uuid@10.0.0: {}
vite@5.3.4(@types/node@20.14.2):
dependencies:
esbuild: 0.21.5

View File

@ -3,6 +3,7 @@ import { isUndefined } from "lodash-es";
import { useState } from "react";
import { toast } from "react-hot-toast";
import { useTranslation } from "react-i18next";
import { v4 as uuidv4 } from "uuid";
import { workspaceServiceClient } from "@/grpcweb";
import { absolutifyLink } from "@/helpers/utils";
import useLoading from "@/hooks/useLoading";
@ -26,6 +27,7 @@ const CreateIdentityProviderDrawer: React.FC<Props> = (props: Props) => {
const [state, setState] = useState<State>({
identityProviderCreate: IdentityProvider.fromPartial(
identityProvider || {
id: uuidv4(),
type: IdentityProvider_Type.OAUTH2,
config: {
oauth2: IdentityProviderConfig_OAuth2Config.fromPartial({
@ -46,14 +48,6 @@ const CreateIdentityProviderDrawer: React.FC<Props> = (props: Props) => {
});
};
const handleNameInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setPartialState({
identityProviderCreate: Object.assign(state.identityProviderCreate, {
name: e.target.value,
}),
});
};
const handleTitleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setPartialState({
identityProviderCreate: Object.assign(state.identityProviderCreate, {
@ -102,7 +96,7 @@ const CreateIdentityProviderDrawer: React.FC<Props> = (props: Props) => {
};
const onSave = async () => {
if (!state.identityProviderCreate.name || !state.identityProviderCreate.title) {
if (!state.identityProviderCreate.id || !state.identityProviderCreate.title) {
toast.error("Please fill in required fields.");
return;
}
@ -112,7 +106,7 @@ const CreateIdentityProviderDrawer: React.FC<Props> = (props: Props) => {
await workspaceServiceClient.updateWorkspaceSetting({
setting: {
identityProviders: workspaceStore.setting.identityProviders.map((idp) =>
idp.name === state.identityProviderCreate.name ? state.identityProviderCreate : idp,
idp.id === state.identityProviderCreate.id ? state.identityProviderCreate : idp,
),
},
updateMask: ["identity_providers"],
@ -143,18 +137,6 @@ const CreateIdentityProviderDrawer: React.FC<Props> = (props: Props) => {
<ModalClose />
<DialogContent className="w-full max-w-full">
<div className="overflow-y-auto w-full mt-2 px-4 pb-4 sm:w-[24rem]">
<div className="w-full flex flex-col justify-start items-start mb-3">
<span className="mb-2">
Name <span className="text-red-600">*</span>
</span>
<Input
className="w-full"
type="text"
placeholder="The unique name of your identity provider"
value={state.identityProviderCreate.name}
onChange={handleNameInputChange}
/>
</div>
<div className="w-full flex flex-col justify-start items-start mb-3">
<span className="mb-2">
Title <span className="text-red-600">*</span>
@ -169,8 +151,13 @@ const CreateIdentityProviderDrawer: React.FC<Props> = (props: Props) => {
/>
</div>
</div>
<Divider className="!mb-3" />
{isCreating && (
<p className="border rounded-md p-2 text-sm w-full mb-2 break-all">Redirect URL: {absolutifyLink("/auth/callback")}</p>
<p className="shadow-sm rounded-md py-1 px-2 bg-zinc-100 dark:bg-zinc-900 text-sm w-full mb-2 break-all">
<span className="opacity-60">Redirect URL</span>
<br />
<code>{absolutifyLink("/auth/callback")}</code>
</p>
)}
<div className="w-full flex flex-col justify-start items-start mb-3">
<span className="mb-2">

View File

@ -38,7 +38,7 @@ const SSOSection = () => {
try {
await workspaceServiceClient.updateWorkspaceSetting({
setting: {
identityProviders: identityProviderList.filter((idp) => idp.name !== identityProvider.name),
identityProviders: identityProviderList.filter((idp) => idp.id !== identityProvider.id),
},
updateMask: ["identity_providers"],
});
@ -92,10 +92,8 @@ const SSOSection = () => {
</thead>
<tbody className="divide-y divide-gray-200 dark:divide-zinc-800">
{identityProviderList.map((identityProvider) => (
<tr key={identityProvider.name}>
<td className="whitespace-nowrap py-2 pl-4 pr-3 text-sm text-gray-900 dark:text-gray-500">
{identityProvider.name}
</td>
<tr key={identityProvider.id}>
<td className="whitespace-nowrap py-2 pl-4 pr-3 text-sm text-gray-900 dark:text-gray-500">{identityProvider.id}</td>
<td className="whitespace-nowrap px-3 py-2 text-sm text-gray-500">{identityProvider.title}</td>
<td className="relative whitespace-nowrap py-2 pl-3 pr-4 text-right text-sm">
<IconButton