mirror of
https://github.com/wassname/talk.git
synced 2026-08-06 13:41:02 +08:00
[next] Admin Configure (#2076)
* feat: Add RadioButton and CheckBox * feat: configure facebook and google auth * feat: configure sso, localAuth and displayName + some tests * test: add integration tests for configure auth * test: more integration tests * feat: add oidc support * test: add oidc integration test * feat: generate sso key initially * fix: import fetchQuery from correct package * fix: admin url * fix: set timezone to utc when testing * refactor: improve route config * fix: remove obsolete line * fix: clientMutationId increment * fix: oidc only create when enabled * fix: copy * test: update snapshots * feat: fixed graphql logging extension * Update src/locales/en-US/admin.ftl Co-Authored-By: cvle <vinh@wikiwi.io> * Apply suggestions from code review Co-Authored-By: cvle <vinh@wikiwi.io> * test: update snapshots * fix: change Local Auth to Email Authentication * fix: copy updates
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import { graphql } from "react-relay";
|
||||
import { Environment } from "relay-runtime";
|
||||
|
||||
import {
|
||||
commitMutationPromiseNormalized,
|
||||
createMutationContainer,
|
||||
} from "talk-framework/lib/relay";
|
||||
import { Omit } from "talk-framework/types";
|
||||
|
||||
import { CreateOIDCAuthIntegrationMutation as MutationTypes } from "talk-admin/__generated__/CreateOIDCAuthIntegrationMutation.graphql";
|
||||
|
||||
export type CreateOIDCAuthIntegrationInput = Omit<
|
||||
MutationTypes["variables"]["input"],
|
||||
"clientMutationId"
|
||||
>;
|
||||
|
||||
const mutation = graphql`
|
||||
mutation CreateOIDCAuthIntegrationMutation(
|
||||
$input: CreateOIDCAuthIntegrationInput!
|
||||
) {
|
||||
createOIDCAuthIntegration(input: $input) {
|
||||
settings {
|
||||
auth {
|
||||
...OIDCConfigListContainer_authReadOnly
|
||||
}
|
||||
}
|
||||
clientMutationId
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
let clientMutationId = 0;
|
||||
|
||||
function commit(
|
||||
environment: Environment,
|
||||
input: CreateOIDCAuthIntegrationInput
|
||||
) {
|
||||
return commitMutationPromiseNormalized<MutationTypes>(environment, {
|
||||
mutation,
|
||||
variables: {
|
||||
input: {
|
||||
...input,
|
||||
clientMutationId: (clientMutationId++).toString(),
|
||||
},
|
||||
},
|
||||
updater: store => {
|
||||
const record = store
|
||||
.getRootField("createOIDCAuthIntegration")!
|
||||
.getLinkedRecord("settings")!
|
||||
.getLinkedRecord("auth")!
|
||||
.getLinkedRecord("integrations");
|
||||
if (record) {
|
||||
store
|
||||
.getRoot()
|
||||
.getLinkedRecord("settings")!
|
||||
.getLinkedRecord("auth")!
|
||||
.getLinkedRecord("integrations")!
|
||||
.copyFieldsFrom(record);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export const withCreateOIDCAuthIntegrationMutation = createMutationContainer(
|
||||
"createOIDCAuthIntegration",
|
||||
commit
|
||||
);
|
||||
|
||||
export type CreateOIDCAuthIntegrationMutation = (
|
||||
input: CreateOIDCAuthIntegrationInput
|
||||
) => Promise<MutationTypes["response"]["createOIDCAuthIntegration"]>;
|
||||
@@ -0,0 +1,66 @@
|
||||
import { graphql } from "react-relay";
|
||||
import { Environment } from "relay-runtime";
|
||||
|
||||
import {
|
||||
commitMutationPromiseNormalized,
|
||||
createMutationContainer,
|
||||
} from "talk-framework/lib/relay";
|
||||
|
||||
import { RegenerateSSOKeyMutation as MutationTypes } from "talk-admin/__generated__/RegenerateSSOKeyMutation.graphql";
|
||||
|
||||
const mutation = graphql`
|
||||
mutation RegenerateSSOKeyMutation($input: RegenerateSSOKeyInput!) {
|
||||
regenerateSSOKey(input: $input) {
|
||||
settings {
|
||||
auth {
|
||||
integrations {
|
||||
sso {
|
||||
key
|
||||
keyGeneratedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
clientMutationId
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
let clientMutationId = 0;
|
||||
|
||||
function commit(environment: Environment) {
|
||||
return commitMutationPromiseNormalized<MutationTypes>(environment, {
|
||||
mutation,
|
||||
variables: {
|
||||
input: {
|
||||
clientMutationId: (clientMutationId++).toString(),
|
||||
},
|
||||
},
|
||||
updater: store => {
|
||||
const record = store
|
||||
.getRootField("regenerateSSOKey")!
|
||||
.getLinkedRecord("settings")!
|
||||
.getLinkedRecord("auth")!
|
||||
.getLinkedRecord("integrations")!
|
||||
.getLinkedRecord("sso");
|
||||
if (record) {
|
||||
store
|
||||
.getRoot()
|
||||
.getLinkedRecord("settings")!
|
||||
.getLinkedRecord("auth")!
|
||||
.getLinkedRecord("integrations")!
|
||||
.getLinkedRecord("sso")!
|
||||
.copyFieldsFrom(record);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export const withRegenerateSSOKeyMutation = createMutationContainer(
|
||||
"regenerateSSOKey",
|
||||
commit
|
||||
);
|
||||
|
||||
export type RegenerateSSOKeyMutation = () => Promise<
|
||||
MutationTypes["response"]["regenerateSSOKey"]
|
||||
>;
|
||||
@@ -0,0 +1,56 @@
|
||||
import { graphql } from "react-relay";
|
||||
import { Environment } from "relay-runtime";
|
||||
|
||||
import {
|
||||
commitMutationPromiseNormalized,
|
||||
createMutationContainer,
|
||||
} from "talk-framework/lib/relay";
|
||||
import { Omit } from "talk-framework/types";
|
||||
|
||||
import { UpdateOIDCAuthIntegrationMutation as MutationTypes } from "talk-admin/__generated__/UpdateOIDCAuthIntegrationMutation.graphql";
|
||||
|
||||
export type UpdateOIDCAuthIntegrationInput = Omit<
|
||||
MutationTypes["variables"]["input"],
|
||||
"clientMutationId"
|
||||
>;
|
||||
|
||||
const mutation = graphql`
|
||||
mutation UpdateOIDCAuthIntegrationMutation(
|
||||
$input: UpdateOIDCAuthIntegrationInput!
|
||||
) {
|
||||
updateOIDCAuthIntegration(input: $input) {
|
||||
settings {
|
||||
auth {
|
||||
...OIDCConfigListContainer_authReadOnly
|
||||
}
|
||||
}
|
||||
clientMutationId
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
let clientMutationId = 0;
|
||||
|
||||
function commit(
|
||||
environment: Environment,
|
||||
input: UpdateOIDCAuthIntegrationInput
|
||||
) {
|
||||
return commitMutationPromiseNormalized<MutationTypes>(environment, {
|
||||
mutation,
|
||||
variables: {
|
||||
input: {
|
||||
...input,
|
||||
clientMutationId: (clientMutationId++).toString(),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export const withUpdateOIDCAuthIntegrationMutation = createMutationContainer(
|
||||
"updateOIDCAuthIntegration",
|
||||
commit
|
||||
);
|
||||
|
||||
export type UpdateOIDCAuthIntegrationMutation = (
|
||||
input: UpdateOIDCAuthIntegrationInput
|
||||
) => Promise<MutationTypes["response"]["updateOIDCAuthIntegration"]>;
|
||||
@@ -0,0 +1,70 @@
|
||||
import { graphql } from "react-relay";
|
||||
import { Environment } from "relay-runtime";
|
||||
|
||||
import {
|
||||
commitMutationPromiseNormalized,
|
||||
createMutationContainer,
|
||||
} from "talk-framework/lib/relay";
|
||||
import { Omit } from "talk-framework/types";
|
||||
|
||||
import { UpdateSettingsMutation as MutationTypes } from "talk-admin/__generated__/UpdateSettingsMutation.graphql";
|
||||
|
||||
export type UpdateSettingsInput = Omit<
|
||||
MutationTypes["variables"]["input"],
|
||||
"clientMutationId"
|
||||
>;
|
||||
|
||||
const mutation = graphql`
|
||||
mutation UpdateSettingsMutation($input: UpdateSettingsInput!) {
|
||||
updateSettings(input: $input) {
|
||||
settings {
|
||||
auth {
|
||||
...FacebookConfigContainer_auth
|
||||
...FacebookConfigContainer_authReadOnly
|
||||
...GoogleConfigContainer_auth
|
||||
...GoogleConfigContainer_authReadOnly
|
||||
...SSOConfigContainer_auth
|
||||
...SSOConfigContainer_authReadOnly
|
||||
...OIDCConfigListContainer_auth
|
||||
...OIDCConfigListContainer_authReadOnly
|
||||
...DisplayNamesConfigContainer_auth
|
||||
}
|
||||
}
|
||||
clientMutationId
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
let clientMutationId = 0;
|
||||
|
||||
function commit(environment: Environment, input: UpdateSettingsInput) {
|
||||
return commitMutationPromiseNormalized<MutationTypes>(environment, {
|
||||
mutation,
|
||||
variables: {
|
||||
input: {
|
||||
...input,
|
||||
clientMutationId: (clientMutationId++).toString(),
|
||||
},
|
||||
},
|
||||
updater: store => {
|
||||
const record = store
|
||||
.getRootField("updateSettings")!
|
||||
.getLinkedRecord("settings");
|
||||
if (record) {
|
||||
store
|
||||
.getRoot()
|
||||
.getLinkedRecord("settings")!
|
||||
.copyFieldsFrom(record);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export const withUpdateSettingsMutation = createMutationContainer(
|
||||
"updateSettings",
|
||||
commit
|
||||
);
|
||||
|
||||
export type UpdateSettingsMutation = (
|
||||
input: UpdateSettingsInput
|
||||
) => Promise<MutationTypes["response"]["updateSettings"]>;
|
||||
@@ -3,3 +3,20 @@ export {
|
||||
withSetRedirectPathMutation,
|
||||
SetRedirectPathMutation,
|
||||
} from "./SetRedirectPathMutation";
|
||||
export {
|
||||
withUpdateSettingsMutation,
|
||||
UpdateSettingsMutation,
|
||||
UpdateSettingsInput,
|
||||
} from "./UpdateSettingsMutation";
|
||||
export {
|
||||
withRegenerateSSOKeyMutation,
|
||||
RegenerateSSOKeyMutation,
|
||||
} from "./RegenerateSSOKeyMutation";
|
||||
export {
|
||||
withCreateOIDCAuthIntegrationMutation,
|
||||
CreateOIDCAuthIntegrationMutation,
|
||||
} from "./CreateOIDCAuthIntegrationMutation";
|
||||
export {
|
||||
withUpdateOIDCAuthIntegrationMutation,
|
||||
UpdateOIDCAuthIntegrationMutation,
|
||||
} from "./UpdateOIDCAuthIntegrationMutation";
|
||||
|
||||
Reference in New Issue
Block a user