Skip to content

Commit

Permalink
fix: core config
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed May 14, 2024
1 parent ef65a20 commit 06a7dbc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build/static/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/static/js/bundle.js.map

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions src/api/tenants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type TenantInfo = {
};
firstFactors: string[];
requiredSecondaryFactors?: string[] | null;
coreConfig: CoreConfigOption[];
coreConfig: CoreConfigFieldInfo[];
userCount: number;
};

Expand All @@ -66,14 +66,12 @@ export type UpdateTenant = {
coreConfig?: Record<string, unknown>;
};

export type CoreConfigOption = {
export type CoreConfigFieldInfo = {
key: string;
valueType: "string" | "number" | "boolean";
valueType: "string" | "boolean" | "number";
value: string | number | boolean | null;
description: string;
isSaaSProtected: boolean;
isDifferentAcrossTenants: boolean;
isModifyableOnlyViaConfigYaml: boolean;
possibleValues?: string[];
isNullable: boolean;
defaultValue: string | number | boolean | null;
Expand Down
34 changes: 12 additions & 22 deletions src/ui/components/tenants/tenantDetail/CoreConfigSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import { ReactComponent as QuestionMarkIcon } from "../../../../assets/question-
import { PUBLIC_TENANT_ID } from "../../../../constants";
import { getConnectionUri } from "../../../../utils";
import TooltipContainer from "../../tooltip/tooltip";
import { useTenantDetailContext } from "./TenantDetailContext";
import { EditCoreConfigPropertyDialog } from "./editCoreConfigPropertyDialog/EditCoreConfigPropertyDialog";
import { EditPluginPropertyDialog } from "./editPluginPropertyDialog/EditPluginPropertyDialog";
import { useTenantDetailContext } from "./TenantDetailContext";
import { PanelHeader, PanelHeaderTitleWithTooltip, PanelRoot } from "./tenantDetailPanel/TenantDetailPanel";
import { UneditablePropertyDialog } from "./uneditablePropertyDialog/UneditablePropertyDialog";

Expand Down Expand Up @@ -67,9 +67,7 @@ export const CoreConfigSection = () => {
key={config.key}
tooltip={config.description}
defaultValue={config.defaultValue}
isSaaSProtected={config.isSaaSProtected}
isDifferentAcrossTenants={config.isDifferentAcrossTenants}
isModifyableOnlyViaConfigYaml={config.isModifyableOnlyViaConfigYaml}
isPluginProperty={config.isPluginProperty}
isPluginPropertyEditable={config.isPluginPropertyEditable}
possibleValues={config.possibleValues}
Expand Down Expand Up @@ -115,9 +113,7 @@ export const CoreConfigSection = () => {
key={config.key}
tooltip={config.description}
defaultValue={config.defaultValue}
isSaaSProtected={config.isSaaSProtected}
isDifferentAcrossTenants={config.isDifferentAcrossTenants}
isModifyableOnlyViaConfigYaml={config.isModifyableOnlyViaConfigYaml}
isPluginProperty={config.isPluginProperty}
isPluginPropertyEditable={config.isPluginPropertyEditable}
possibleValues={config.possibleValues}
Expand Down Expand Up @@ -148,9 +144,7 @@ type CoreConfigTableRowProps = {
tooltip: string;
defaultValue: string | number | boolean | null;
possibleValues?: string[];
isSaaSProtected: boolean;
isDifferentAcrossTenants: boolean;
isModifyableOnlyViaConfigYaml: boolean;
isPluginProperty: boolean;
isPluginPropertyEditable: boolean;
};
Expand All @@ -166,9 +160,7 @@ const CoreConfigTableRow = ({
type,
isNullable,
possibleValues,
isSaaSProtected,
isDifferentAcrossTenants,
isModifyableOnlyViaConfigYaml,
isPluginProperty,
isPluginPropertyEditable,
defaultValue,
Expand All @@ -181,24 +173,22 @@ const CoreConfigTableRow = ({
const isUneditable =
isPublicTenant ||
(isPluginProperty && !isPluginPropertyEditable) ||
isModifyableOnlyViaConfigYaml ||
(isUsingSaaS && isSaaSProtected) ||
(!isPublicTenant && !isDifferentAcrossTenants);

const renderUneditablePropertyReason = () => {
if (isModifyableOnlyViaConfigYaml && isUsingSaaS) {
return "This property cannot be modified since you are using the managed service.";
}
// if (isModifyableOnlyViaConfigYaml && isUsingSaaS) {
// return "This property cannot be modified since you are using the managed service.";
// }

if (isSaaSProtected && isUsingSaaS) {
return "This property cannot be edited or viewed since you are using a managed service and we hide it for security reasons.";
}
// if (isSaaSProtected && isUsingSaaS) {
// return "This property cannot be edited or viewed since you are using a managed service and we hide it for security reasons.";
// }

if ((isPublicTenant && !isUsingNonPublicApp) || isModifyableOnlyViaConfigYaml) {
return isUsingSaaS
? "To modify this property, please visit the dashboard on supertokens.com and click on the edit configuration button."
: "This property is modifiable only via the config.yaml file or via Docker env variables.";
}
// if ((isPublicTenant && !isUsingNonPublicApp) || isModifyableOnlyViaConfigYaml) {
// return isUsingSaaS
// ? "To modify this property, please visit the dashboard on supertokens.com and click on the edit configuration button."
// : "This property is modifiable only via the config.yaml file or via Docker env variables.";
// }

if (isUsingNonPublicApp && isPublicTenant) {
return (
Expand Down

0 comments on commit 06a7dbc

Please sign in to comment.