feat: update keycloak theme

This commit is contained in:
Jonas Juselius
2024-02-22 09:47:34 +01:00
parent d6fde78f8d
commit f9e012da95
9813 changed files with 611335 additions and 162181 deletions
@@ -1,5 +1,6 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
@@ -15,8 +16,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as React from "../../../../common/keycloak/web_modules/react.js";
import { ActionGroup, Button, Form, FormGroup, TextInput, Grid, GridItem, ExpandableSection, ValidatedOptions, PageSection, PageSectionVariants, Text, TextVariants, TextContent } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import * as React from "../../../keycloak.v2/web_modules/react.js";
import { ActionGroup, Button, Form, FormGroup, TextInput, InputGroup, Grid, GridItem, ExpandableSection, ValidatedOptions, PageSection, PageSectionVariants, Text, TextVariants, TextContent } from "../../../keycloak.v2/web_modules/@patternfly/react-core.js";
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import { Msg } from "../../widgets/Msg.js";
import { ContentPage } from "../ContentPage.js";
@@ -24,22 +25,19 @@ import { ContentAlert } from "../ContentAlert.js";
import { LocaleSelector } from "../../widgets/LocaleSelectors.js";
import { KeycloakContext } from "../../keycloak-service/KeycloakContext.js";
import { AIACommand } from "../../util/AIACommand.js";
import { ExternalLinkSquareAltIcon } from "../../../keycloak.v2/web_modules/@patternfly/react-icons.js";
/**
* @author Stan Silvert ssilvert@redhat.com (C) 2018 Red Hat Inc.
*/
export class AccountPage extends React.Component {
constructor(props, context) {
super(props);
_defineProperty(this, "context", void 0);
_defineProperty(this, "isRegistrationEmailAsUsername", features.isRegistrationEmailAsUsername);
_defineProperty(this, "isEditUserNameAllowed", features.isEditUserNameAllowed);
_defineProperty(this, "isDeleteAccountAllowed", features.deleteAccountAllowed);
_defineProperty(this, "isUpdateEmailFeatureEnabled", features.updateEmailFeatureEnabled);
_defineProperty(this, "isUpdateEmailActionEnabled", features.updateEmailActionEnabled);
_defineProperty(this, "DEFAULT_STATE", {
errors: {
username: '',
@@ -55,37 +53,34 @@ export class AccountPage extends React.Component {
attributes: {}
}
});
_defineProperty(this, "state", this.DEFAULT_STATE);
_defineProperty(this, "handleCancel", () => {
this.fetchPersonalInfo();
});
_defineProperty(this, "handleChange", (value, event) => {
const target = event.currentTarget;
const name = target.name;
this.setState({
errors: { ...this.state.errors,
errors: {
...this.state.errors,
[name]: target.validationMessage
},
formFields: { ...this.state.formFields,
formFields: {
...this.state.formFields,
[name]: value
}
});
});
_defineProperty(this, "handleSubmit", event => {
event.preventDefault();
const form = event.target;
const isValid = form.checkValidity();
if (isValid) {
const reqData = { ...this.state.formFields
const reqData = {
...this.state.formFields
};
this.context.doPost("/", reqData).then(() => {
ContentAlert.success('accountUpdatedMessage');
if (locale !== this.state.formFields.attributes.locale[0]) {
window.location.reload();
}
@@ -97,17 +92,19 @@ export class AccountPage extends React.Component {
return acc;
}, {});
this.setState({
errors: { ...validationMessages
errors: {
...validationMessages
},
formFields: this.state.formFields
});
}
});
_defineProperty(this, "handleDelete", keycloak => {
new AIACommand(keycloak, "delete_account").execute();
});
_defineProperty(this, "handleEmailUpdate", keycloak => {
new AIACommand(keycloak, "UPDATE_EMAIL").execute();
});
_defineProperty(this, "UsernameInput", () => /*#__PURE__*/React.createElement(TextInput, {
isRequired: true,
type: "text",
@@ -118,7 +115,6 @@ export class AccountPage extends React.Component {
onChange: this.handleChange,
validated: this.state.errors.username !== '' ? ValidatedOptions.error : ValidatedOptions.default
}));
_defineProperty(this, "RestrictedUsernameInput", () => /*#__PURE__*/React.createElement(TextInput, {
isReadOnly: true,
type: "text",
@@ -126,16 +122,13 @@ export class AccountPage extends React.Component {
name: "username",
value: this.state.formFields.username
}));
this.context = context;
this.fetchPersonalInfo();
}
fetchPersonalInfo() {
this.context.doGet("/").then(response => {
this.setState(this.DEFAULT_STATE);
const formFields = response.data;
if (!formFields.attributes) {
formFields.attributes = {
locale: [locale]
@@ -143,14 +136,13 @@ export class AccountPage extends React.Component {
} else if (!formFields.attributes.locale) {
formFields.attributes.locale = [locale];
}
this.setState({ ...{
this.setState({
...{
formFields: formFields
}
});
});
}
render() {
const fields = this.state.formFields;
return /*#__PURE__*/React.createElement(ContentPage, {
@@ -166,13 +158,13 @@ export class AccountPage extends React.Component {
}, Msg.localize('allFieldsRequired'))), /*#__PURE__*/React.createElement(Form, {
onSubmit: event => this.handleSubmit(event),
className: "personal-info-form"
}, !this.isRegistrationEmailAsUsername && /*#__PURE__*/React.createElement(FormGroup, {
}, !this.isRegistrationEmailAsUsername && fields.username != undefined && /*#__PURE__*/React.createElement(FormGroup, {
label: Msg.localize("username"),
fieldId: "user-name",
helperTextInvalid: this.state.errors.username,
validated: this.state.errors.username !== "" ? ValidatedOptions.error : ValidatedOptions.default
}, this.isEditUserNameAllowed && /*#__PURE__*/React.createElement(this.UsernameInput, null), !this.isEditUserNameAllowed && /*#__PURE__*/React.createElement(this.RestrictedUsernameInput, null)), /*#__PURE__*/React.createElement(FormGroup, {
label: Msg.localize("email"),
}, this.isEditUserNameAllowed && /*#__PURE__*/React.createElement(this.UsernameInput, null), !this.isEditUserNameAllowed && /*#__PURE__*/React.createElement(this.RestrictedUsernameInput, null)), !this.isUpdateEmailFeatureEnabled && /*#__PURE__*/React.createElement(FormGroup, {
label: Msg.localize('email'),
fieldId: "email-address",
helperTextInvalid: this.state.errors.email,
validated: this.state.errors.email !== "" ? ValidatedOptions.error : ValidatedOptions.default
@@ -185,7 +177,24 @@ export class AccountPage extends React.Component {
value: fields.email,
onChange: this.handleChange,
validated: this.state.errors.email !== "" ? ValidatedOptions.error : ValidatedOptions.default
})), /*#__PURE__*/React.createElement(FormGroup, {
})), this.isUpdateEmailFeatureEnabled && /*#__PURE__*/React.createElement(FormGroup, {
label: Msg.localize('email'),
fieldId: "email-address"
}, /*#__PURE__*/React.createElement(InputGroup, null, /*#__PURE__*/React.createElement(TextInput, {
isDisabled: true,
type: "email",
id: "email-address",
name: "email",
value: fields.email
}), this.isUpdateEmailActionEnabled && (!this.isRegistrationEmailAsUsername || this.isEditUserNameAllowed) && /*#__PURE__*/React.createElement(KeycloakContext.Consumer, null, keycloak => /*#__PURE__*/React.createElement(Button, {
id: "update-email-btn",
variant: "link",
onClick: () => this.handleEmailUpdate(keycloak),
icon: /*#__PURE__*/React.createElement(ExternalLinkSquareAltIcon, null),
iconPosition: "right"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "updateEmail"
}))))), /*#__PURE__*/React.createElement(FormGroup, {
label: Msg.localize("firstName"),
fieldId: "first-name",
helperTextInvalid: this.state.errors.firstName,
@@ -222,8 +231,10 @@ export class AccountPage extends React.Component {
value: fields.attributes.locale || "",
onChange: value => this.setState({
errors: this.state.errors,
formFields: { ...this.state.formFields,
attributes: { ...this.state.formFields.attributes,
formFields: {
...this.state.formFields,
attributes: {
...this.state.formFields.attributes,
locale: [value]
}
}
@@ -247,7 +258,7 @@ export class AccountPage extends React.Component {
marginTop: "30px"
}
}, /*#__PURE__*/React.createElement(ExpandableSection, {
toggleText: "Delete Account"
toggleText: Msg.localize("deleteAccount")
}, /*#__PURE__*/React.createElement(Grid, {
hasGutter: true
}, /*#__PURE__*/React.createElement(GridItem, {
@@ -267,10 +278,7 @@ export class AccountPage extends React.Component {
span: 2
}))))));
}
}
_defineProperty(AccountPage, "contextType", AccountServiceContext);
;
//# sourceMappingURL=AccountPage.js.map