Skip to content

Commit

Permalink
[fix] fixed issues caused by type refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Eriikah committed May 9, 2024
1 parent 6b209b9 commit f19b78e
Show file tree
Hide file tree
Showing 17 changed files with 712 additions and 376 deletions.
34 changes: 24 additions & 10 deletions src/components/SaveButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,30 @@ export default function SaveButton() {
className="saveButton"
onClick={() => {
let stateOk = true;
Object.keys(data.oidcRPMetaDataOptions).forEach((app) => {
if (!ruleOIDC(data.oidcRPMetaDataOptions[app])) {
stateOk = false;
}
});
Object.keys(data.samlSPMetaDataXML).forEach((app) => {
if (!ruleSAML(data.samlSPMetaDataXML[app])) {
stateOk = false;
}
});
if (data.oidcRPMetaDataOptions) {
Object.keys(data.oidcRPMetaDataOptions).forEach((app) => {
if (
!ruleOIDC(
data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[app]
: {}
)
) {
stateOk = false;
}
});
}
if (data.samlSPMetaDataXML) {
Object.keys(data.samlSPMetaDataXML).forEach((app) => {
if (
!ruleSAML(
data.samlSPMetaDataXML ? data.samlSPMetaDataXML[app] : {}
)
) {
stateOk = false;
}
});
}
if (stateOk) {
dispatch(saveConfigCall());
setOpenSavingPopup(true);
Expand Down
2 changes: 2 additions & 0 deletions src/components/applicationsComponents/CasApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export function CasApp({ name }: { name: string }) {
name,
vars,
"exportedVars",
dispatch,
delCASexportedVars,
updateCASexportedVars
)}
Expand Down Expand Up @@ -118,6 +119,7 @@ export function CasApp({ name }: { name: string }) {
name,
casAppMetaDataMacros,
"macros",
dispatch,
delCASAppMetaDataMacros,
updateCASAppMetaDataMacros
)}
Expand Down
74 changes: 50 additions & 24 deletions src/components/applicationsComponents/NativeApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,20 +375,27 @@ function NativPost(
}

export function NativeApp({ name }: { name: string }) {
const locationRules = useAppSelector(
(state) => state.config.data.config.locationRules[name]
);
const locationR = useAppSelector((state) => {
if (state.config.data.config.locationRules) {
return state.config.data.config.locationRules[name];
}
});
const locationRules = locationR ? locationR : {};
const exportedHeaders = useAppSelector((state) => {
return state.config.data.config.exportedHeaders
? state.config.data.config.exportedHeaders[name]
: {};
if (state.config.data.config.exportedHeaders) {
return state.config.data.config.exportedHeaders[name];
}
});
const post = useAppSelector((state) => {
if (state.config.data.config.post) {
return state.config.data.config.post[name];
}
});
const options = useAppSelector((state) => {
if (state.config.data.config.vhostOptions) {
return state.config.data.config.vhostOptions[name];
}
});
const post = useAppSelector((state) =>
state.config.data.config.post ? state.config.data.config.post[name] : {}
);
const options = useAppSelector(
(state) => state.config.data.config.vhostOptions[name]
);
const [optionSelected, setOptionSelected] = useState("basic");
const dispatch = useAppDispatch();
return (
Expand Down Expand Up @@ -474,7 +481,7 @@ export function NativeApp({ name }: { name: string }) {
<FormControl>
<RadioGroup
row
value={options.vhostMaintenance}
value={options ? options.vhostMaintenance : false}
onChange={(e) => {
dispatch(
updateVhostOptions({
Expand Down Expand Up @@ -553,8 +560,9 @@ export function NativeApp({ name }: { name: string }) {
</thead>
{TableVars(
name,
exportedHeaders,
exportedHeaders ? exportedHeaders : {},
"exportedHeaders",
dispatch,
delVhostHeader,
updateVhostHeaders
)}
Expand Down Expand Up @@ -589,7 +597,7 @@ export function NativeApp({ name }: { name: string }) {
</th>
</tr>
</thead>
{NativPost(name, post)}
{NativPost(name, post ? post : {})}
</table>
<Button
className="plus"
Expand All @@ -614,7 +622,11 @@ export function NativeApp({ name }: { name: string }) {
variant="filled"
className="form"
type="number"
value={String(options.vhostPort)}
value={String(
options
? options.vhostPort
: attributes.vhostPort.default
)}
onChange={(el) => {
dispatch(
updateVhostOptions({
Expand All @@ -633,7 +645,11 @@ export function NativeApp({ name }: { name: string }) {
<FormControl>
<RadioGroup
row
value={options.vhostHttps}
value={
options
? options.vhostHttps
: attributes.vhostHttps.default
}
onChange={(e) => {
dispatch(
updateVhostOptions({
Expand Down Expand Up @@ -669,7 +685,7 @@ export function NativeApp({ name }: { name: string }) {
<FormControl>
<RadioGroup
row
value={options.vhostMaintenance}
value={options ? options.vhostMaintenance : false}
onChange={(e) => {
dispatch(
updateVhostOptions({
Expand Down Expand Up @@ -704,7 +720,9 @@ export function NativeApp({ name }: { name: string }) {
className="form"
type="text"
value={String(
options.vhostAliases ? options.vhostAliases : ""
options
? options.vhostAliases
: attributes.vhostAliases.default
)}
onChange={(el) => {
dispatch(
Expand All @@ -728,9 +746,9 @@ export function NativeApp({ name }: { name: string }) {
className="form"
type="text"
value={String(
options.vhostAccessToTrace
options
? options.vhostAccessToTrace
: ""
: attributes.vhostAccessToTrace.default
)}
onChange={(el) => {
dispatch(
Expand All @@ -750,7 +768,11 @@ export function NativeApp({ name }: { name: string }) {
<FormControl sx={{ m: 1, minWidth: 120 }}>
<InputLabel>{t("vhostType")}</InputLabel>
<Select
value={options.vhostType}
value={
options
? options.vhostType
: attributes.vhostType.default
}
label={t("vhostType")}
onChange={(el) =>
dispatch(
Expand Down Expand Up @@ -782,7 +804,7 @@ export function NativeApp({ name }: { name: string }) {
variant="filled"
className="form"
type="number"
value={String(options.vhostAuthnLevel)}
value={String(options ? options.vhostAuthnLevel : 0)}
onChange={(el) => {
dispatch(
updateVhostOptions({
Expand All @@ -804,7 +826,11 @@ export function NativeApp({ name }: { name: string }) {
variant="filled"
className="form"
type="number"
value={String(options.vhostServiceTokenTTL)}
value={String(
options
? options.vhostServiceTokenTTL
: attributes.vhostServiceTokenTTL.default
)}
onChange={(el) => {
dispatch(
updateVhostOptions({
Expand Down
91 changes: 62 additions & 29 deletions src/components/applicationsComponents/OIDCApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,11 @@ export function OIDCApp({ name }: { name: string }) {
<tr>
<th>
{t("oidcRPMetaDataOptionsClientID")}
{data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientID === ""
? "⚠️"
{data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientID === ""
? "⚠️"
: ""
: ""}
</th>
<td>
Expand All @@ -218,8 +220,13 @@ export function OIDCApp({ name }: { name: string }) {
className="form"
type="text"
value={String(
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientID
data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientID
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientID
: ""
: ""
)}
onChange={(e) => {
dispatch(
Expand All @@ -236,12 +243,16 @@ export function OIDCApp({ name }: { name: string }) {
<tr>
<th>
{t("oidcRPMetaDataOptionsPublic")}
{data.oidcRPMetaDataOptions[name]
{data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsPublic ||
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientSecret !== ""
? ""
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsPublic ||
(data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientSecret &&
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientSecret !== "")
? ""
: "⚠️"
: "⚠️"
: "⚠️"}
</th>
Expand All @@ -250,8 +261,10 @@ export function OIDCApp({ name }: { name: string }) {
<RadioGroup
row
value={
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsPublic
data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsPublic
: 0
}
onChange={(e) => {
dispatch(
Expand Down Expand Up @@ -281,12 +294,16 @@ export function OIDCApp({ name }: { name: string }) {
<tr>
<th>
{t("oidcRPMetaDataOptionsClientSecret")}
{data.oidcRPMetaDataOptions[name]
{data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsPublic ||
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientSecret !== ""
? ""
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsPublic ||
(data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientSecret &&
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientSecret !== "")
? ""
: "⚠️"
: "⚠️"
: "⚠️"}
</th>
Expand All @@ -297,10 +314,17 @@ export function OIDCApp({ name }: { name: string }) {
variant="filled"
className="form"
type={attributes.oidcRPMetaDataOptionsClientSecret.type}
value={String(
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientSecret
)}
value={
data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientSecret
? String(
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsClientSecret
)
: ""
: ""
}
onChange={(e) => {
dispatch(
updateOidcMetaDataOptions({
Expand All @@ -323,8 +347,10 @@ export function OIDCApp({ name }: { name: string }) {
type={attributes.oidcRPMetaDataOptionsRedirectUris.type}
name="oidcRPMetaDataOptionsRedirectUris"
value={String(
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsRedirectUris
data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsRedirectUris
: ""
)}
onChange={(e) => {
dispatch(
Expand All @@ -348,8 +374,10 @@ export function OIDCApp({ name }: { name: string }) {
type={attributes.oidcRPMetaDataOptionsAuthMethod.type}
name="oidcRPMetaDataOptionsAuthMethod"
value={String(
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsAuthMethod
data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsAuthMethod
: ""
)}
onChange={(e) => {
dispatch(
Expand All @@ -372,10 +400,12 @@ export function OIDCApp({ name }: { name: string }) {
variant="filled"
type="text"
value={String(
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsDisplay
data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsDisplay
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsDisplay
: ""
: ""
)}
onChange={(e) => {
Expand All @@ -399,8 +429,10 @@ export function OIDCApp({ name }: { name: string }) {
variant="filled"
type={attributes.oidcRPMetaDataOptionsIcon.type}
value={String(
data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsIcon
data.oidcRPMetaDataOptions
? data.oidcRPMetaDataOptions[name]
.oidcRPMetaDataOptionsIcon
: ""
)}
onChange={(e) => {
dispatch(
Expand Down Expand Up @@ -483,6 +515,7 @@ export function OIDCApp({ name }: { name: string }) {
name,
data.oidcRPMetaDataMacros[name],
"oidcRPMetaDataMacros",
dispatch,
delOIDCRPMetaDataMacros,
updateOIDCRPMetaDataMacros
)
Expand Down
Loading

0 comments on commit f19b78e

Please sign in to comment.