feat: initial commit

This commit is contained in:
Jonas Juselius
2022-07-04 10:47:36 +02:00
commit d6fde78f8d
1058 changed files with 462301 additions and 0 deletions
@@ -0,0 +1,113 @@
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; }
/*
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { Alert, AlertActionCloseButton, AlertGroup, AlertVariant } from "../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { Msg } from "../widgets/Msg.js";
export class ContentAlert extends React.Component {
constructor(props) {
super(props);
_defineProperty(this, "hideAlert", key => {
this.setState({
alerts: [...this.state.alerts.filter(el => el.key !== key)]
});
});
_defineProperty(this, "getUniqueId", () => new Date().getTime());
_defineProperty(this, "postAlert", (variant, message, params) => {
const alerts = this.state.alerts;
const key = this.getUniqueId();
alerts.push({
key,
message: Msg.localize(message, params),
variant
});
this.setState({
alerts
});
if (variant !== AlertVariant.danger) {
setTimeout(() => this.hideAlert(key), 8000);
}
});
this.state = {
alerts: []
};
ContentAlert.instance = this;
}
/**
* @param message A literal text message or localization key.
*/
static success(message, params) {
ContentAlert.instance.postAlert(AlertVariant.success, message, params);
}
/**
* @param message A literal text message or localization key.
*/
static danger(message, params) {
ContentAlert.instance.postAlert(AlertVariant.danger, message, params);
}
/**
* @param message A literal text message or localization key.
*/
static warning(message, params) {
ContentAlert.instance.postAlert(AlertVariant.warning, message, params);
}
/**
* @param message A literal text message or localization key.
*/
static info(message, params) {
ContentAlert.instance.postAlert(AlertVariant.info, message, params);
}
render() {
return /*#__PURE__*/React.createElement(AlertGroup, {
isToast: true,
"aria-live": "assertive"
}, this.state.alerts.map(({
key,
variant,
message
}) => /*#__PURE__*/React.createElement(Alert, {
"aria-details": message,
isLiveRegion: true,
variant: variant,
title: message,
actionClose: /*#__PURE__*/React.createElement(AlertActionCloseButton, {
title: message,
variantLabel: `${variant} alert`,
onClose: () => this.hideAlert(key)
}),
key: key
})));
}
}
_defineProperty(ContentAlert, "instance", void 0);
//# sourceMappingURL=ContentAlert.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,63 @@
/*
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { Button, Text, Title, Tooltip, PageSection, TextContent, PageSectionVariants, SplitItem, Split } from "../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { SyncAltIcon } from "../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { Msg } from "../widgets/Msg.js";
import { ContentAlert } from "./ContentAlert.js";
/**
* @author Stan Silvert ssilvert@redhat.com (C) 2019 Red Hat Inc.
*/
export class ContentPage extends React.Component {
constructor(props) {
super(props);
}
render() {
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ContentAlert, null), /*#__PURE__*/React.createElement(PageSection, {
variant: PageSectionVariants.light,
className: "pf-u-pb-xs"
}, /*#__PURE__*/React.createElement(Split, null, /*#__PURE__*/React.createElement(SplitItem, {
isFilled: true
}, /*#__PURE__*/React.createElement(TextContent, null, /*#__PURE__*/React.createElement(Title, {
headingLevel: "h1",
size: "2xl",
className: "pf-u-mb-xl"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: this.props.title
})), this.props.introMessage && /*#__PURE__*/React.createElement(Text, {
component: "p"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: this.props.introMessage
})))), this.props.onRefresh && /*#__PURE__*/React.createElement(SplitItem, null, /*#__PURE__*/React.createElement(Tooltip, {
content: /*#__PURE__*/React.createElement(Msg, {
msgKey: "refreshPage"
})
}, /*#__PURE__*/React.createElement(Button, {
"aria-label": Msg.localize('refreshPage'),
id: "refresh-page",
variant: "link",
onClick: this.props.onRefresh,
icon: /*#__PURE__*/React.createElement(SyncAltIcon, null)
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "refresh"
})))))), this.props.children);
}
}
;
//# sourceMappingURL=ContentPage.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../src/app/content/ContentPage.tsx"],"names":["React","Button","Text","Title","Tooltip","PageSection","TextContent","PageSectionVariants","SplitItem","Split","SyncAltIcon","Msg","ContentAlert","ContentPage","Component","constructor","props","render","light","title","introMessage","onRefresh","localize","children"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,KAAKA,KAAZ;AACA,SAAQC,MAAR,EAAgCC,IAAhC,EAAsCC,KAAtC,EAA6CC,OAA7C,EAAwFC,WAAxF,EAAqGC,WAArG,EAAkHC,mBAAlH,EAAuIC,SAAvI,EAAkJC,KAAlJ;AACA,SAAkBC,WAAlB;AAEA,SAAQC,GAAR;AACA,SAAQC,YAAR;;AASA;AACA;AACA;AACA,OAAO,MAAMC,WAAN,SAA0Bb,KAAK,CAACc,SAAhC,CAA4D;AAExDC,EAAAA,WAAW,CAACC,KAAD,EAA0B;AACxC,UAAMA,KAAN;AACH;;AAEMC,EAAAA,MAAM,GAAoB;AAC7B,wBACI,oBAAC,KAAD,CAAO,QAAP,qBACA,oBAAC,YAAD,OADA,eAGA,oBAAC,WAAD;AAAa,MAAA,OAAO,EAAEV,mBAAmB,CAACW,KAA1C;AAAiD,MAAA,SAAS,EAAC;AAA3D,oBACE,oBAAC,KAAD,qBACE,oBAAC,SAAD;AAAW,MAAA,QAAQ;AAAnB,oBACE,oBAAC,WAAD,qBACE,oBAAC,KAAD;AAAO,MAAA,YAAY,EAAC,IAApB;AAAyB,MAAA,IAAI,EAAC,KAA9B;AAAoC,MAAA,SAAS,EAAC;AAA9C,oBACE,oBAAC,GAAD;AAAK,MAAA,MAAM,EAAE,KAAKF,KAAL,CAAWG;AAAxB,MADF,CADF,EAIG,KAAKH,KAAL,CAAWI,YAAX,iBACC,oBAAC,IAAD;AAAM,MAAA,SAAS,EAAC;AAAhB,oBACE,oBAAC,GAAD;AAAK,MAAA,MAAM,EAAE,KAAKJ,KAAL,CAAWI;AAAxB,MADF,CALJ,CADF,CADF,EAaG,KAAKJ,KAAL,CAAWK,SAAX,iBACC,oBAAC,SAAD,qBACE,oBAAC,OAAD;AAAS,MAAA,OAAO,eAAE,oBAAC,GAAD;AAAK,QAAA,MAAM,EAAC;AAAZ;AAAlB,oBACE,oBAAC,MAAD;AACE,oBAAYV,GAAG,CAACW,QAAJ,CAAa,aAAb,CADd;AAEE,MAAA,EAAE,EAAC,cAFL;AAGE,MAAA,OAAO,EAAC,MAHV;AAIE,MAAA,OAAO,EAAE,KAAKN,KAAL,CAAWK,SAJtB;AAKE,MAAA,IAAI,eAAE,oBAAC,WAAD;AALR,oBAOE,oBAAC,GAAD;AAAK,MAAA,MAAM,EAAC;AAAZ,MAPF,CADF,CADF,CAdJ,CADF,CAHA,EAkCC,KAAKL,KAAL,CAAWO,QAlCZ,CADJ;AAsCH;;AA7C8D;AA8ClE","sourcesContent":["/*\n * Copyright 2019 Red Hat, Inc. and/or its affiliates.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from 'react';\nimport {Button, Grid, GridItem, Text, Title, Tooltip, Card, CardBody, Stack, StackItem, PageSection, TextContent, PageSectionVariants, SplitItem, Split} from '@patternfly/react-core';\nimport {RedoIcon, SyncAltIcon} from '@patternfly/react-icons';\n\nimport {Msg} from '../widgets/Msg';\nimport {ContentAlert} from './ContentAlert';\n\ninterface ContentPageProps {\n title: string; // Literal title or key into message bundle\n introMessage?: string; // Literal message or key into message bundle\n onRefresh?: () => void;\n children: React.ReactNode;\n}\n\n/**\n * @author Stan Silvert ssilvert@redhat.com (C) 2019 Red Hat Inc.\n */\nexport class ContentPage extends React.Component<ContentPageProps> {\n\n public constructor(props: ContentPageProps) {\n super(props);\n }\n\n public render(): React.ReactNode {\n return (\n <React.Fragment>\n <ContentAlert />\n\n <PageSection variant={PageSectionVariants.light} className=\"pf-u-pb-xs\">\n <Split>\n <SplitItem isFilled>\n <TextContent>\n <Title headingLevel=\"h1\" size=\"2xl\" className=\"pf-u-mb-xl\">\n <Msg msgKey={this.props.title} />\n </Title>\n {this.props.introMessage && (\n <Text component=\"p\">\n <Msg msgKey={this.props.introMessage} />\n </Text>\n )}\n </TextContent>\n </SplitItem>\n {this.props.onRefresh && (\n <SplitItem>\n <Tooltip content={<Msg msgKey=\"refreshPage\" />}>\n <Button\n aria-label={Msg.localize('refreshPage')}\n id=\"refresh-page\"\n variant=\"link\"\n onClick={this.props.onRefresh}\n icon={<SyncAltIcon />}\n >\n <Msg msgKey=\"refresh\" />\n </Button>\n </Tooltip>\n </SplitItem>\n )}\n </Split>\n </PageSection>\n {this.props.children}\n </React.Fragment>\n );\n }\n};\n"],"file":"ContentPage.js"}
@@ -0,0 +1,276 @@
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; }
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import { Msg } from "../../widgets/Msg.js";
import { ContentPage } from "../ContentPage.js";
import { ContentAlert } from "../ContentAlert.js";
import { LocaleSelector } from "../../widgets/LocaleSelectors.js";
import { KeycloakContext } from "../../keycloak-service/KeycloakContext.js";
import { AIACommand } from "../../util/AIACommand.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, "DEFAULT_STATE", {
errors: {
username: '',
firstName: '',
lastName: '',
email: ''
},
formFields: {
username: '',
firstName: '',
lastName: '',
email: '',
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,
[name]: target.validationMessage
},
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
};
this.context.doPost("/", reqData).then(() => {
ContentAlert.success('accountUpdatedMessage');
if (locale !== this.state.formFields.attributes.locale[0]) {
window.location.reload();
}
});
} else {
const formData = new FormData(form);
const validationMessages = Array.from(formData.keys()).reduce((acc, key) => {
acc[key] = form.elements[key].validationMessage;
return acc;
}, {});
this.setState({
errors: { ...validationMessages
},
formFields: this.state.formFields
});
}
});
_defineProperty(this, "handleDelete", keycloak => {
new AIACommand(keycloak, "delete_account").execute();
});
_defineProperty(this, "UsernameInput", () => /*#__PURE__*/React.createElement(TextInput, {
isRequired: true,
type: "text",
id: "user-name",
name: "username",
maxLength: 254,
value: this.state.formFields.username,
onChange: this.handleChange,
validated: this.state.errors.username !== '' ? ValidatedOptions.error : ValidatedOptions.default
}));
_defineProperty(this, "RestrictedUsernameInput", () => /*#__PURE__*/React.createElement(TextInput, {
isReadOnly: true,
type: "text",
id: "user-name",
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]
};
} else if (!formFields.attributes.locale) {
formFields.attributes.locale = [locale];
}
this.setState({ ...{
formFields: formFields
}
});
});
}
render() {
const fields = this.state.formFields;
return /*#__PURE__*/React.createElement(ContentPage, {
title: "personalInfoHtmlTitle",
introMessage: "personalSubMessage"
}, /*#__PURE__*/React.createElement(PageSection, {
isFilled: true,
variant: PageSectionVariants.light
}, /*#__PURE__*/React.createElement(TextContent, {
className: "pf-u-mb-lg"
}, /*#__PURE__*/React.createElement(Text, {
component: TextVariants.small
}, Msg.localize('allFieldsRequired'))), /*#__PURE__*/React.createElement(Form, {
onSubmit: event => this.handleSubmit(event),
className: "personal-info-form"
}, !this.isRegistrationEmailAsUsername && /*#__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"),
fieldId: "email-address",
helperTextInvalid: this.state.errors.email,
validated: this.state.errors.email !== "" ? ValidatedOptions.error : ValidatedOptions.default
}, /*#__PURE__*/React.createElement(TextInput, {
isRequired: true,
type: "email",
id: "email-address",
name: "email",
maxLength: 254,
value: fields.email,
onChange: this.handleChange,
validated: this.state.errors.email !== "" ? ValidatedOptions.error : ValidatedOptions.default
})), /*#__PURE__*/React.createElement(FormGroup, {
label: Msg.localize("firstName"),
fieldId: "first-name",
helperTextInvalid: this.state.errors.firstName,
validated: this.state.errors.firstName !== "" ? ValidatedOptions.error : ValidatedOptions.default
}, /*#__PURE__*/React.createElement(TextInput, {
isRequired: true,
type: "text",
id: "first-name",
name: "firstName",
maxLength: 254,
value: fields.firstName,
onChange: this.handleChange,
validated: this.state.errors.firstName !== "" ? ValidatedOptions.error : ValidatedOptions.default
})), /*#__PURE__*/React.createElement(FormGroup, {
label: Msg.localize("lastName"),
fieldId: "last-name",
helperTextInvalid: this.state.errors.lastName,
validated: this.state.errors.lastName !== "" ? ValidatedOptions.error : ValidatedOptions.default
}, /*#__PURE__*/React.createElement(TextInput, {
isRequired: true,
type: "text",
id: "last-name",
name: "lastName",
maxLength: 254,
value: fields.lastName,
onChange: this.handleChange,
validated: this.state.errors.lastName !== "" ? ValidatedOptions.error : ValidatedOptions.default
})), features.isInternationalizationEnabled && /*#__PURE__*/React.createElement(FormGroup, {
label: Msg.localize("selectLocale"),
isRequired: true,
fieldId: "locale"
}, /*#__PURE__*/React.createElement(LocaleSelector, {
id: "locale-selector",
value: fields.attributes.locale || "",
onChange: value => this.setState({
errors: this.state.errors,
formFields: { ...this.state.formFields,
attributes: { ...this.state.formFields.attributes,
locale: [value]
}
}
})
})), /*#__PURE__*/React.createElement(ActionGroup, null, /*#__PURE__*/React.createElement(Button, {
type: "submit",
id: "save-btn",
variant: "primary",
isDisabled: Object.values(this.state.errors).filter(e => e !== "").length !== 0
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "doSave"
})), /*#__PURE__*/React.createElement(Button, {
id: "cancel-btn",
variant: "link",
onClick: this.handleCancel
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "doCancel"
})))), this.isDeleteAccountAllowed && /*#__PURE__*/React.createElement("div", {
id: "delete-account",
style: {
marginTop: "30px"
}
}, /*#__PURE__*/React.createElement(ExpandableSection, {
toggleText: "Delete Account"
}, /*#__PURE__*/React.createElement(Grid, {
hasGutter: true
}, /*#__PURE__*/React.createElement(GridItem, {
span: 6
}, /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "deleteAccountWarning"
}))), /*#__PURE__*/React.createElement(GridItem, {
span: 4
}, /*#__PURE__*/React.createElement(KeycloakContext.Consumer, null, keycloak => /*#__PURE__*/React.createElement(Button, {
id: "delete-account-btn",
variant: "danger",
onClick: () => this.handleDelete(keycloak),
className: "delete-button"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "doDelete"
})))), /*#__PURE__*/React.createElement(GridItem, {
span: 2
}))))));
}
}
_defineProperty(AccountPage, "contextType", AccountServiceContext);
;
//# sourceMappingURL=AccountPage.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,70 @@
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; }
/*
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { withRouter } from "../../../../common/keycloak/web_modules/react-router-dom.js";
import { AIACommand } from "../../util/AIACommand.js";
import { Msg } from "../../widgets/Msg.js";
import { Title, Button, EmptyState, EmptyStateVariant, EmptyStateIcon, EmptyStateBody, TitleSizes } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { PassportIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { KeycloakContext } from "../../keycloak-service/KeycloakContext.js"; // Note: This class demonstrates two features of the ContentPages framework:
// 1) The PageDef is available as a React property.
// 2) You can add additional custom properties to the PageDef. In this case,
// we add a value called kcAction in content.js and access it by extending the
// PageDef interface.
/**
* @author Stan Silvert
*/
class ApplicationInitiatedActionPage extends React.Component {
constructor(props) {
super(props);
_defineProperty(this, "handleClick", keycloak => {
new AIACommand(keycloak, this.props.pageDef.kcAction).execute();
});
}
render() {
return /*#__PURE__*/React.createElement(EmptyState, {
variant: EmptyStateVariant.full
}, /*#__PURE__*/React.createElement(EmptyStateIcon, {
icon: PassportIcon
}), /*#__PURE__*/React.createElement(Title, {
headingLevel: "h5",
size: TitleSizes.lg
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: this.props.pageDef.label,
params: this.props.pageDef.labelParams
})), /*#__PURE__*/React.createElement(EmptyStateBody, null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "actionRequiresIDP"
})), /*#__PURE__*/React.createElement(KeycloakContext.Consumer, null, keycloak => /*#__PURE__*/React.createElement(Button, {
variant: "primary",
onClick: () => this.handleClick(keycloak),
target: "_blank"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "continue"
}))));
}
}
; // Note that the class name is not exported above. To get access to the router,
// we use withRouter() and export a different name.
export const AppInitiatedActionPage = withRouter(ApplicationInitiatedActionPage);
//# sourceMappingURL=AppInitiatedActionPage.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,184 @@
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; }
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { DataList, DataListItem, DataListItemRow, DataListCell, DataListToggle, DataListContent, DataListItemCells, DescriptionList, DescriptionListTerm, DescriptionListGroup, DescriptionListDescription, Grid, GridItem, Button, PageSection, PageSectionVariants, Stack } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { InfoAltIcon, CheckIcon, ExternalLinkAltIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { ContentPage } from "../ContentPage.js";
import { ContinueCancelModal } from "../../widgets/ContinueCancelModal.js";
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import { Msg } from "../../widgets/Msg.js";
export class ApplicationsPage extends React.Component {
constructor(props, context) {
super(props);
_defineProperty(this, "context", void 0);
_defineProperty(this, "removeConsent", clientId => {
this.context.doDelete("/applications/" + clientId + "/consent").then(() => {
this.fetchApplications();
});
});
_defineProperty(this, "onToggle", row => {
const newIsRowOpen = this.state.isRowOpen;
newIsRowOpen[row] = !newIsRowOpen[row];
this.setState({
isRowOpen: newIsRowOpen
});
});
this.context = context;
this.state = {
isRowOpen: [],
applications: []
};
this.fetchApplications();
}
fetchApplications() {
this.context.doGet("/applications").then(response => {
const applications = response.data || [];
this.setState({
isRowOpen: new Array(applications.length).fill(false),
applications: applications
});
});
}
elementId(item, application) {
return `application-${item}-${application.clientId}`;
}
render() {
return /*#__PURE__*/React.createElement(ContentPage, {
title: Msg.localize('applicationsPageTitle'),
introMessage: "Manage your application permissions."
}, /*#__PURE__*/React.createElement(PageSection, {
isFilled: true,
variant: PageSectionVariants.light
}, /*#__PURE__*/React.createElement(Stack, {
hasGutter: true
}, /*#__PURE__*/React.createElement(DataList, {
id: "applications-list",
"aria-label": Msg.localize('applicationsPageTitle')
}, /*#__PURE__*/React.createElement(DataListItem, {
id: "applications-list-header",
"aria-labelledby": "Columns names"
}, /*#__PURE__*/React.createElement(DataListItemRow, null, "// invisible toggle allows headings to line up properly", /*#__PURE__*/React.createElement("span", {
style: {
visibility: 'hidden',
height: 55
}
}, /*#__PURE__*/React.createElement(DataListToggle, {
isExpanded: false,
id: "applications-list-header-invisible-toggle",
"aria-controls": "hidden"
})), /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
key: "applications-list-client-id-header",
width: 2,
className: "pf-u-pt-md"
}, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "applicationName"
}))), /*#__PURE__*/React.createElement(DataListCell, {
key: "applications-list-app-type-header",
width: 2,
className: "pf-u-pt-md"
}, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "applicationType"
}))), /*#__PURE__*/React.createElement(DataListCell, {
key: "applications-list-status",
width: 2,
className: "pf-u-pt-md"
}, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "status"
})))]
}))), this.state.applications.map((application, appIndex) => {
return /*#__PURE__*/React.createElement(DataListItem, {
id: this.elementId("client-id", application),
key: 'application-' + appIndex,
"aria-labelledby": "applications-list",
isExpanded: this.state.isRowOpen[appIndex]
}, /*#__PURE__*/React.createElement(DataListItemRow, {
className: "pf-u-align-items-center"
}, /*#__PURE__*/React.createElement(DataListToggle, {
onClick: () => this.onToggle(appIndex),
isExpanded: this.state.isRowOpen[appIndex],
id: this.elementId('toggle', application),
"aria-controls": this.elementId("expandable", application)
}), /*#__PURE__*/React.createElement(DataListItemCells, {
className: "pf-u-align-items-center",
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
id: this.elementId('name', application),
width: 2,
key: 'app-' + appIndex
}, /*#__PURE__*/React.createElement(Button, {
className: "pf-u-pl-0 title-case",
component: "a",
variant: "link",
onClick: () => window.open(application.effectiveUrl)
}, application.clientName || application.clientId, " ", /*#__PURE__*/React.createElement(ExternalLinkAltIcon, null))), /*#__PURE__*/React.createElement(DataListCell, {
id: this.elementId('internal', application),
width: 2,
key: 'internal-' + appIndex
}, application.userConsentRequired ? Msg.localize('thirdPartyApp') : Msg.localize('internalApp'), application.offlineAccess ? ', ' + Msg.localize('offlineAccess') : ''), /*#__PURE__*/React.createElement(DataListCell, {
id: this.elementId('status', application),
width: 2,
key: 'status-' + appIndex
}, application.inUse ? Msg.localize('inUse') : Msg.localize('notInUse'))]
})), /*#__PURE__*/React.createElement(DataListContent, {
className: "pf-u-pl-35xl",
hasNoPadding: false,
"aria-label": Msg.localize('applicationDetails'),
id: this.elementId("expandable", application),
isHidden: !this.state.isRowOpen[appIndex]
}, /*#__PURE__*/React.createElement(DescriptionList, null, /*#__PURE__*/React.createElement(DescriptionListGroup, null, /*#__PURE__*/React.createElement(DescriptionListTerm, null, Msg.localize('client')), /*#__PURE__*/React.createElement(DescriptionListDescription, null, application.clientId)), application.description && /*#__PURE__*/React.createElement(DescriptionListGroup, null, /*#__PURE__*/React.createElement(DescriptionListTerm, null, Msg.localize('description')), /*#__PURE__*/React.createElement(DescriptionListDescription, null, application.description)), application.effectiveUrl && /*#__PURE__*/React.createElement(DescriptionListGroup, null, /*#__PURE__*/React.createElement(DescriptionListTerm, null, "URL"), /*#__PURE__*/React.createElement(DescriptionListDescription, null, application.effectiveUrl.split('"'))), application.consent && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DescriptionListGroup, null, /*#__PURE__*/React.createElement(DescriptionListTerm, null, "Has access to"), application.consent.grantedScopes.map((scope, scopeIndex) => {
return /*#__PURE__*/React.createElement(React.Fragment, {
key: 'scope-' + scopeIndex
}, /*#__PURE__*/React.createElement(DescriptionListDescription, null, /*#__PURE__*/React.createElement(CheckIcon, null), " ", scope.name));
})), /*#__PURE__*/React.createElement(DescriptionListGroup, null, /*#__PURE__*/React.createElement(DescriptionListTerm, null, Msg.localize('accessGrantedOn') + ': '), /*#__PURE__*/React.createElement(DescriptionListDescription, null, new Intl.DateTimeFormat(locale, {
year: 'numeric',
month: 'long',
day: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric'
}).format(application.consent.createDate))))), (application.consent || application.offlineAccess) && /*#__PURE__*/React.createElement(Grid, {
hasGutter: true
}, /*#__PURE__*/React.createElement("hr", null), /*#__PURE__*/React.createElement(GridItem, null, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ContinueCancelModal, {
buttonTitle: Msg.localize('removeButton') // required
,
buttonVariant: "secondary" // defaults to 'primary'
,
modalTitle: Msg.localize('removeModalTitle') // required
,
modalMessage: Msg.localize('removeModalMessage', [application.clientId]),
modalContinueButtonLabel: Msg.localize('confirmButton') // defaults to 'Continue'
,
onContinue: () => this.removeConsent(application.clientId) // required
}))), /*#__PURE__*/React.createElement(GridItem, null, /*#__PURE__*/React.createElement(InfoAltIcon, null), " ", Msg.localize('infoMessage')))));
})))));
}
}
_defineProperty(ApplicationsPage, "contextType", AccountServiceContext);
;
//# sourceMappingURL=ApplicationsPage.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,28 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as React from "../../../../common/keycloak/web_modules/react.js";
export class AuthenticatorPage extends React.Component {
constructor(props) {
super(props);
}
render() {
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("h2", null, "Hello Authenticator Page"));
}
}
;
//# sourceMappingURL=AuthenticatorPage.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/app/content/authenticator-page/AuthenticatorPage.tsx"],"names":["React","AuthenticatorPage","Component","constructor","props","render"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,KAAKA,KAAZ;AAKA,OAAO,MAAMC,iBAAN,SAAgCD,KAAK,CAACE,SAAtC,CAAwE;AAEpEC,EAAAA,WAAW,CAACC,KAAD,EAAgC;AAC9C,UAAMA,KAAN;AACH;;AAEMC,EAAAA,MAAM,GAAoB;AAC7B,wBACI,8CACE,2DADF,CADJ;AAKH;;AAZ0E;AAa9E","sourcesContent":["/* \n * Copyright 2018 Red Hat, Inc. and/or its affiliates.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from 'react';\n \nexport interface AuthenticatorPageProps {\n}\n \nexport class AuthenticatorPage extends React.Component<AuthenticatorPageProps> {\n \n public constructor(props: AuthenticatorPageProps) {\n super(props);\n }\n\n public render(): React.ReactNode {\n return (\n <div>\n <h2>Hello Authenticator Page</h2>\n </div>\n );\n }\n};"],"file":"AuthenticatorPage.js"}
@@ -0,0 +1,238 @@
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; }
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import TimeUtil from "../../util/TimeUtil.js";
import { Button, DataList, DataListItem, DataListItemRow, DataListContent, DescriptionList, DescriptionListTerm, DescriptionListDescription, DescriptionListGroup, Grid, GridItem, Label, PageSection, PageSectionVariants, Title, Tooltip, SplitItem, Split } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { DesktopIcon, MobileAltIcon, SyncAltIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { Msg } from "../../widgets/Msg.js";
import { ContinueCancelModal } from "../../widgets/ContinueCancelModal.js";
import { KeycloakContext } from "../../keycloak-service/KeycloakContext.js";
import { ContentPage } from "../ContentPage.js";
import { ContentAlert } from "../ContentAlert.js";
/**
* @author Stan Silvert ssilvert@redhat.com (C) 2019 Red Hat Inc.
*/
export class DeviceActivityPage extends React.Component {
constructor(props, context) {
super(props);
_defineProperty(this, "context", void 0);
_defineProperty(this, "signOutAll", keycloakService => {
this.context.doDelete("/sessions").then(() => {
keycloakService.logout();
});
});
_defineProperty(this, "signOutSession", (device, session) => {
this.context.doDelete("/sessions/" + session.id).then(() => {
this.fetchDevices();
ContentAlert.success('signedOutSession', [session.browser, device.os]);
});
});
this.context = context;
this.state = {
devices: []
};
this.fetchDevices();
}
fetchDevices() {
this.context.doGet("/sessions/devices").then(response => {
console.log({
response
});
let devices = this.moveCurrentToTop(response.data);
this.setState({
devices: devices
});
});
} // current device and session should display at the top of their respective lists
moveCurrentToTop(devices) {
let currentDevice = devices[0];
devices.forEach((device, index) => {
if (device.current) {
currentDevice = device;
devices.splice(index, 1);
devices.unshift(device);
}
});
currentDevice.sessions.forEach((session, index) => {
if (session.current) {
const currentSession = currentDevice.sessions.splice(index, 1);
currentDevice.sessions.unshift(currentSession[0]);
}
});
return devices;
}
time(time) {
return TimeUtil.format(time * 1000);
}
elementId(item, session, element = 'session') {
return `${element}-${session.id.substring(0, 7)}-${item}`;
}
findDeviceTypeIcon(session, device) {
const deviceType = device.mobile;
if (deviceType === true) return /*#__PURE__*/React.createElement(MobileAltIcon, {
id: this.elementId('icon-mobile', session, 'device')
});
return /*#__PURE__*/React.createElement(DesktopIcon, {
id: this.elementId('icon-desktop', session, 'device')
});
}
findOS(device) {
if (device.os.toLowerCase().includes('unknown')) return Msg.localize('unknownOperatingSystem');
return device.os;
}
findOSVersion(device) {
if (device.osVersion.toLowerCase().includes('unknown')) return '';
return device.osVersion;
}
makeClientsString(clients) {
let clientsString = "";
clients.forEach((client, index) => {
let clientName;
if (client.hasOwnProperty('clientName') && client.clientName !== undefined && client.clientName !== '') {
clientName = Msg.localize(client.clientName);
} else {
clientName = client.clientId;
}
clientsString += clientName;
if (clients.length > index + 1) clientsString += ', ';
});
return clientsString;
}
isShowSignOutAll(devices) {
if (devices.length === 0) return false;
if (devices.length > 1) return true;
if (devices[0].sessions.length > 1) return true;
return false;
}
render() {
return /*#__PURE__*/React.createElement(ContentPage, {
title: "device-activity",
introMessage: "signedInDevicesExplanation"
}, /*#__PURE__*/React.createElement(PageSection, {
isFilled: true,
variant: PageSectionVariants.light
}, /*#__PURE__*/React.createElement(Split, {
hasGutter: true,
className: "pf-u-mb-lg"
}, /*#__PURE__*/React.createElement(SplitItem, {
isFilled: true
}, /*#__PURE__*/React.createElement("div", {
id: "signedInDevicesTitle",
className: "pf-c-content"
}, /*#__PURE__*/React.createElement(Title, {
headingLevel: "h2",
size: "xl"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "signedInDevices"
})))), /*#__PURE__*/React.createElement(SplitItem, null, /*#__PURE__*/React.createElement(Tooltip, {
content: /*#__PURE__*/React.createElement(Msg, {
msgKey: "refreshPage"
})
}, /*#__PURE__*/React.createElement(Button, {
"aria-describedby": "refresh page",
id: "refresh-page",
variant: "link",
onClick: this.fetchDevices.bind(this),
icon: /*#__PURE__*/React.createElement(SyncAltIcon, null)
}, "Refresh"))), /*#__PURE__*/React.createElement(SplitItem, null, /*#__PURE__*/React.createElement(KeycloakContext.Consumer, null, keycloak => this.isShowSignOutAll(this.state.devices) && /*#__PURE__*/React.createElement(ContinueCancelModal, {
buttonTitle: "signOutAllDevices",
buttonId: "sign-out-all",
modalTitle: "signOutAllDevices",
modalMessage: "signOutAllDevicesWarning",
onContinue: () => this.signOutAll(keycloak)
})))), /*#__PURE__*/React.createElement(DataList, {
className: "signed-in-device-list",
"aria-label": Msg.localize('signedInDevices')
}, /*#__PURE__*/React.createElement(DataListItem, {
"aria-labelledby": "sessions",
id: "device-activity-sessions"
}, this.state.devices.map((device, deviceIndex) => {
return /*#__PURE__*/React.createElement(React.Fragment, null, device.sessions.map((session, sessionIndex) => {
return /*#__PURE__*/React.createElement(React.Fragment, {
key: 'device-' + deviceIndex + '-session-' + sessionIndex
}, /*#__PURE__*/React.createElement(DataListItemRow, null, /*#__PURE__*/React.createElement(DataListContent, {
"aria-label": "device-sessions-content",
isHidden: false,
className: "pf-u-flex-grow-1"
}, /*#__PURE__*/React.createElement(Grid, {
className: "signed-in-device-grid",
hasGutter: true
}, /*#__PURE__*/React.createElement(GridItem, {
className: "device-icon",
span: 1,
rowSpan: 2
}, /*#__PURE__*/React.createElement("span", null, this.findDeviceTypeIcon(session, device))), /*#__PURE__*/React.createElement(GridItem, {
sm: 8,
md: 9,
span: 10
}, /*#__PURE__*/React.createElement("span", {
id: this.elementId('browser', session),
className: "pf-u-mr-md"
}, this.findOS(device), " ", this.findOSVersion(device), " / ", session.browser), session.current && /*#__PURE__*/React.createElement(Label, {
color: "green"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "currentSession"
}))), /*#__PURE__*/React.createElement(GridItem, {
className: "pf-u-text-align-right",
sm: 3,
md: 2,
span: 1
}, !session.current && /*#__PURE__*/React.createElement(ContinueCancelModal, {
buttonTitle: "doSignOut",
buttonId: this.elementId('sign-out', session),
modalTitle: "doSignOut",
buttonVariant: "secondary",
modalMessage: "signOutWarning",
onContinue: () => this.signOutSession(device, session)
})), /*#__PURE__*/React.createElement(GridItem, {
span: 11
}, /*#__PURE__*/React.createElement(DescriptionList, {
columnModifier: {
sm: '2Col',
lg: '3Col'
}
}, /*#__PURE__*/React.createElement(DescriptionListGroup, null, /*#__PURE__*/React.createElement(DescriptionListTerm, null, Msg.localize('ipAddress')), /*#__PURE__*/React.createElement(DescriptionListDescription, null, session.ipAddress)), /*#__PURE__*/React.createElement(DescriptionListGroup, null, /*#__PURE__*/React.createElement(DescriptionListTerm, null, Msg.localize('lastAccessedOn')), /*#__PURE__*/React.createElement(DescriptionListDescription, null, this.time(session.lastAccess))), /*#__PURE__*/React.createElement(DescriptionListGroup, null, /*#__PURE__*/React.createElement(DescriptionListTerm, null, Msg.localize('clients')), /*#__PURE__*/React.createElement(DescriptionListDescription, null, this.makeClientsString(session.clients))), /*#__PURE__*/React.createElement(DescriptionListGroup, null, /*#__PURE__*/React.createElement(DescriptionListTerm, null, Msg.localize('started')), /*#__PURE__*/React.createElement(DescriptionListDescription, null, this.time(session.started))), /*#__PURE__*/React.createElement(DescriptionListGroup, null, /*#__PURE__*/React.createElement(DescriptionListTerm, null, Msg.localize('expires')), /*#__PURE__*/React.createElement(DescriptionListDescription, null, this.time(session.expires)))))))));
}));
})))));
}
}
_defineProperty(DeviceActivityPage, "contextType", AccountServiceContext);
;
//# sourceMappingURL=DeviceActivityPage.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,36 @@
/*
* Copyright 2020 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { WarningTriangleIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { Msg } from "../../widgets/Msg.js";
import EmptyMessageState from "../../widgets/EmptyMessageState.js";
export class ForbiddenPage extends React.Component {
constructor() {
super({});
}
render() {
return /*#__PURE__*/React.createElement(EmptyMessageState, {
icon: WarningTriangleIcon,
messageKey: "forbidden"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "needAccessRights"
}));
}
}
;
//# sourceMappingURL=ForbiddenPage.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/app/content/forbidden-page/ForbiddenPage.tsx"],"names":["React","WarningTriangleIcon","Msg","EmptyMessageState","ForbiddenPage","Component","constructor","render"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,KAAKA,KAAZ;AAEA,SAASC,mBAAT;AACA,SAAQC,GAAR;AACA,OAAOC,iBAAP;AAGA,OAAO,MAAMC,aAAN,SAA4BJ,KAAK,CAACK,SAAlC,CAA4C;AAExCC,EAAAA,WAAW,GAAG;AACjB,UAAM,EAAN;AACH;;AAEMC,EAAAA,MAAM,GAAoB;AAC7B,wBACI,oBAAC,iBAAD;AAAmB,MAAA,IAAI,EAAEN,mBAAzB;AAA8C,MAAA,UAAU,EAAC;AAAzD,oBACI,oBAAC,GAAD;AAAK,MAAA,MAAM,EAAC;AAAZ,MADJ,CADJ;AAKH;;AAZ8C;AAalD","sourcesContent":["/*\n * Copyright 2020 Red Hat, Inc. and/or its affiliates.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport * as React from 'react';\n\nimport { WarningTriangleIcon } from '@patternfly/react-icons';\nimport {Msg} from '../../widgets/Msg';\nimport EmptyMessageState from '../../widgets/EmptyMessageState';\n\n\nexport class ForbiddenPage extends React.Component {\n\n public constructor() {\n super({});\n }\n\n public render(): React.ReactNode {\n return (\n <EmptyMessageState icon={WarningTriangleIcon} messageKey=\"forbidden\">\n <Msg msgKey=\"needAccessRights\"/>\n </EmptyMessageState>\n );\n }\n};\n"],"file":"ForbiddenPage.js"}
@@ -0,0 +1,261 @@
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; }
/*
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { withRouter } from "../../../../common/keycloak/web_modules/react-router-dom.js";
import { Button, DataList, DataListAction, DataListItemCells, DataListCell, DataListItemRow, Label, PageSection, PageSectionVariants, Split, SplitItem, Stack, StackItem, Title, DataListItem } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { BitbucketIcon, CubeIcon, GitlabIcon, LinkIcon, PaypalIcon, UnlinkIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import { Msg } from "../../widgets/Msg.js";
import { ContentPage } from "../ContentPage.js";
import { createRedirect } from "../../util/RedirectUri.js";
/**
* @author Stan Silvert
*/
class LinkedAccountsPage extends React.Component {
constructor(props, context) {
super(props);
_defineProperty(this, "context", void 0);
this.context = context;
this.state = {
linkedAccounts: [],
unLinkedAccounts: []
};
this.getLinkedAccounts();
}
getLinkedAccounts() {
this.context.doGet("/linked-accounts").then(response => {
console.log({
response
});
const linkedAccounts = response.data.filter(account => account.connected);
const unLinkedAccounts = response.data.filter(account => !account.connected);
this.setState({
linkedAccounts: linkedAccounts,
unLinkedAccounts: unLinkedAccounts
});
});
}
unLinkAccount(account) {
const url = '/linked-accounts/' + account.providerName;
this.context.doDelete(url).then(response => {
console.log({
response
});
this.getLinkedAccounts();
});
}
linkAccount(account) {
const url = '/linked-accounts/' + account.providerName;
const redirectUri = createRedirect(this.props.location.pathname);
this.context.doGet(url, {
params: {
providerId: account.providerName,
redirectUri
}
}).then(response => {
console.log({
response
});
window.location.href = response.data.accountLinkUri;
});
}
render() {
return /*#__PURE__*/React.createElement(ContentPage, {
title: Msg.localize('linkedAccountsTitle'),
introMessage: Msg.localize('linkedAccountsIntroMessage')
}, /*#__PURE__*/React.createElement(PageSection, {
isFilled: true,
variant: PageSectionVariants.light
}, /*#__PURE__*/React.createElement(Stack, {
hasGutter: true
}, /*#__PURE__*/React.createElement(StackItem, null, /*#__PURE__*/React.createElement(Title, {
headingLevel: "h2",
className: "pf-u-mb-lg",
size: "xl"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "linkedLoginProviders"
})), /*#__PURE__*/React.createElement(DataList, {
id: "linked-idps",
"aria-label": Msg.localize('linkedLoginProviders')
}, this.makeRows(this.state.linkedAccounts, true))), /*#__PURE__*/React.createElement(StackItem, null, /*#__PURE__*/React.createElement(Title, {
headingLevel: "h2",
className: "pf-u-mt-xl pf-u-mb-lg",
size: "xl"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "unlinkedLoginProviders"
})), /*#__PURE__*/React.createElement(DataList, {
id: "unlinked-idps",
"aria-label": Msg.localize('unlinkedLoginProviders')
}, this.makeRows(this.state.unLinkedAccounts, false))))));
}
emptyRow(isLinked) {
let isEmptyMessage = '';
if (isLinked) {
isEmptyMessage = Msg.localize('linkedEmpty');
} else {
isEmptyMessage = Msg.localize('unlinkedEmpty');
}
return /*#__PURE__*/React.createElement(DataListItem, {
key: "emptyItem",
"aria-labelledby": Msg.localize('isEmptyMessage')
}, /*#__PURE__*/React.createElement(DataListItemRow, {
key: "emptyRow"
}, /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
key: "empty"
}, isEmptyMessage)]
})));
}
makeRows(accounts, isLinked) {
if (accounts.length === 0) {
return this.emptyRow(isLinked);
}
return /*#__PURE__*/React.createElement(React.Fragment, null, " ", accounts.map(account => /*#__PURE__*/React.createElement(DataListItem, {
id: `${account.providerAlias}-idp`,
key: account.providerName,
"aria-labelledby": Msg.localize('linkedAccountsTitle')
}, /*#__PURE__*/React.createElement(DataListItemRow, {
key: account.providerName
}, /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
key: "idp"
}, /*#__PURE__*/React.createElement(Split, null, /*#__PURE__*/React.createElement(SplitItem, {
className: "pf-u-mr-sm"
}, this.findIcon(account)), /*#__PURE__*/React.createElement(SplitItem, {
className: "pf-u-my-xs",
isFilled: true
}, /*#__PURE__*/React.createElement("span", {
id: `${account.providerAlias}-idp-name`
}, account.displayName)))), /*#__PURE__*/React.createElement(DataListCell, {
key: "label"
}, /*#__PURE__*/React.createElement(Split, null, /*#__PURE__*/React.createElement(SplitItem, {
className: "pf-u-my-xs",
isFilled: true
}, /*#__PURE__*/React.createElement("span", {
id: `${account.providerAlias}-idp-label`
}, this.label(account))))), /*#__PURE__*/React.createElement(DataListCell, {
key: "username",
width: 5
}, /*#__PURE__*/React.createElement(Split, null, /*#__PURE__*/React.createElement(SplitItem, {
className: "pf-u-my-xs",
isFilled: true
}, /*#__PURE__*/React.createElement("span", {
id: `${account.providerAlias}-idp-username`
}, account.linkedUsername))))]
}), /*#__PURE__*/React.createElement(DataListAction, {
"aria-labelledby": Msg.localize('link'),
"aria-label": Msg.localize('unLink'),
id: "setPasswordAction"
}, isLinked && /*#__PURE__*/React.createElement(Button, {
id: `${account.providerAlias}-idp-unlink`,
variant: "link",
onClick: () => this.unLinkAccount(account)
}, /*#__PURE__*/React.createElement(UnlinkIcon, {
size: "sm"
}), " ", /*#__PURE__*/React.createElement(Msg, {
msgKey: "unLink"
})), !isLinked && /*#__PURE__*/React.createElement(Button, {
id: `${account.providerAlias}-idp-link`,
variant: "link",
onClick: () => this.linkAccount(account)
}, /*#__PURE__*/React.createElement(LinkIcon, {
size: "sm"
}), " ", /*#__PURE__*/React.createElement(Msg, {
msgKey: "link"
})))))), " ");
}
label(account) {
if (account.social) {
return /*#__PURE__*/React.createElement(Label, {
color: "blue"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "socialLogin"
}));
}
return /*#__PURE__*/React.createElement(Label, {
color: "green"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "systemDefined"
}));
}
findIcon(account) {
const socialIconId = `${account.providerAlias}-idp-icon-social`;
console.log(account);
switch (true) {
case account.providerName.toLowerCase().includes('bitbucket'):
return /*#__PURE__*/React.createElement(BitbucketIcon, {
id: socialIconId,
size: "lg"
});
case account.providerName.toLowerCase().includes('openshift'):
return /*#__PURE__*/React.createElement("div", {
className: "idp-icon-social",
id: "openshift-idp-icon-social"
});
case account.providerName.toLowerCase().includes('gitlab'):
return /*#__PURE__*/React.createElement(GitlabIcon, {
id: socialIconId,
size: "lg"
});
case account.providerName.toLowerCase().includes('paypal'):
return /*#__PURE__*/React.createElement(PaypalIcon, {
id: socialIconId,
size: "lg"
});
case account.providerName !== '' && account.social:
return /*#__PURE__*/React.createElement("div", {
className: "idp-icon-social",
id: socialIconId
});
default:
return /*#__PURE__*/React.createElement(CubeIcon, {
id: `${account.providerAlias}-idp-icon-default`,
size: "lg"
});
}
}
}
_defineProperty(LinkedAccountsPage, "contextType", AccountServiceContext);
;
const LinkedAccountsPagewithRouter = withRouter(LinkedAccountsPage);
export { LinkedAccountsPagewithRouter as LinkedAccountsPage };
//# sourceMappingURL=LinkedAccountsPage.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,40 @@
import * as React from "../../../../common/keycloak/web_modules/react.js";
import { Msg } from "../../widgets/Msg.js";
export class AbstractResourcesTable extends React.Component {
hasPermissions(row) {
return this.state.permissions.has(row) && this.state.permissions.get(row).length > 0;
}
firstUser(row) {
if (!this.hasPermissions(row)) return 'ERROR!!!!'; // should never happen
return this.state.permissions.get(row)[0].username;
}
numOthers(row) {
if (!this.hasPermissions(row)) return -1; // should never happen
return this.state.permissions.get(row).length - 1;
}
sharedWithUsersMessage(row) {
if (!this.hasPermissions(row)) return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "resourceNotShared"
}));
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "resourceSharedWith"
}, /*#__PURE__*/React.createElement("strong", null, this.firstUser(row))), this.numOthers(row) > 0 && /*#__PURE__*/React.createElement(Msg, {
msgKey: "and"
}, /*#__PURE__*/React.createElement("strong", null, this.numOthers(row))), ".");
}
getClientName(client) {
if (client.hasOwnProperty('name') && client.name !== null && client.name !== '') {
return Msg.localize(client.name);
} else {
return client.clientId;
}
}
}
//# sourceMappingURL=AbstractResourceTable.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/app/content/my-resources-page/AbstractResourceTable.tsx"],"names":["React","Msg","AbstractResourcesTable","Component","hasPermissions","row","state","permissions","has","get","length","firstUser","username","numOthers","sharedWithUsersMessage","getClientName","client","hasOwnProperty","name","localize","clientId"],"mappings":"AAAA,OAAO,KAAKA,KAAZ;AAEA,SAASC,GAAT;AAUA,OAAO,MAAeC,sBAAf,SAA6EF,KAAK,CAACG,SAAnF,CAAqH;AAEhHC,EAAAA,cAAc,CAACC,GAAD,EAAuB;AAC7C,WAAQ,KAAKC,KAAL,CAAWC,WAAX,CAAuBC,GAAvB,CAA2BH,GAA3B,CAAD,IAAsC,KAAKC,KAAL,CAAWC,WAAX,CAAuBE,GAAvB,CAA2BJ,GAA3B,EAAiCK,MAAjC,GAA0C,CAAvF;AACD;;AAEOC,EAAAA,SAAS,CAACN,GAAD,EAAsB;AACrC,QAAI,CAAC,KAAKD,cAAL,CAAoBC,GAApB,CAAL,EAA+B,OAAO,WAAP,CADM,CACc;;AAEnD,WAAO,KAAKC,KAAL,CAAWC,WAAX,CAAuBE,GAAvB,CAA2BJ,GAA3B,EAAiC,CAAjC,EAAoCO,QAA3C;AACD;;AAESC,EAAAA,SAAS,CAACR,GAAD,EAAsB;AACvC,QAAI,CAAC,KAAKD,cAAL,CAAoBC,GAApB,CAAL,EAA+B,OAAO,CAAC,CAAR,CADQ,CACG;;AAE1C,WAAO,KAAKC,KAAL,CAAWC,WAAX,CAAuBE,GAAvB,CAA2BJ,GAA3B,EAAiCK,MAAjC,GAA0C,CAAjD;AACD;;AAEMI,EAAAA,sBAAsB,CAACT,GAAD,EAA+B;AAC1D,QAAI,CAAC,KAAKD,cAAL,CAAoBC,GAApB,CAAL,EAA+B,oBAAQ,oBAAC,KAAD,CAAO,QAAP,qBAAgB,oBAAC,GAAD;AAAK,MAAA,MAAM,EAAC;AAAZ,MAAhB,CAAR;AAE/B,wBACE,oBAAC,KAAD,CAAO,QAAP,qBACE,oBAAC,GAAD;AAAK,MAAA,MAAM,EAAC;AAAZ,oBACE,oCAAS,KAAKM,SAAL,CAAeN,GAAf,CAAT,CADF,CADF,EAIG,KAAKQ,SAAL,CAAeR,GAAf,IAAsB,CAAtB,iBAA2B,oBAAC,GAAD;AAAK,MAAA,MAAM,EAAC;AAAZ,oBAC1B,oCAAS,KAAKQ,SAAL,CAAeR,GAAf,CAAT,CAD0B,CAJ9B,MADF;AAUD;;AAESU,EAAAA,aAAa,CAACC,MAAD,EAAyB;AAC9C,QAAIA,MAAM,CAACC,cAAP,CAAsB,MAAtB,KAAiCD,MAAM,CAACE,IAAP,KAAgB,IAAjD,IAAyDF,MAAM,CAACE,IAAP,KAAgB,EAA7E,EAAiF;AAC/E,aAAOjB,GAAG,CAACkB,QAAJ,CAAaH,MAAM,CAACE,IAApB,CAAP;AACD,KAFD,MAEO;AACL,aAAOF,MAAM,CAACI,QAAd;AACD;AACF;;AAvCyH","sourcesContent":["import * as React from 'react';\nimport { Permission, PaginatedResources, Client } from './resource-model';\nimport { Msg } from '../../widgets/Msg';\n\nexport interface ResourcesTableProps {\n resources: PaginatedResources;\n}\n\nexport interface ResourcesTableState {\n permissions: Map<number, Permission[]>;\n}\n\nexport abstract class AbstractResourcesTable<S extends ResourcesTableState> extends React.Component<ResourcesTableProps, S> {\n\n protected hasPermissions(row: number): boolean {\n return (this.state.permissions.has(row)) && (this.state.permissions.get(row)!.length > 0);\n }\n\n private firstUser(row: number): string {\n if (!this.hasPermissions(row)) return 'ERROR!!!!'; // should never happen\n\n return this.state.permissions.get(row)![0].username;\n }\n\n protected numOthers(row: number): number {\n if (!this.hasPermissions(row)) return -1; // should never happen\n\n return this.state.permissions.get(row)!.length - 1;\n }\n\n public sharedWithUsersMessage(row: number): React.ReactNode {\n if (!this.hasPermissions(row)) return (<React.Fragment><Msg msgKey='resourceNotShared' /></React.Fragment>);\n\n return (\n <React.Fragment>\n <Msg msgKey='resourceSharedWith'>\n <strong>{this.firstUser(row)}</strong>\n </Msg>\n {this.numOthers(row) > 0 && <Msg msgKey='and'>\n <strong>{this.numOthers(row)}</strong>\n </Msg>}.\n </React.Fragment>\n );\n }\n\n protected getClientName(client: Client): string {\n if (client.hasOwnProperty('name') && client.name !== null && client.name !== '') {\n return Msg.localize(client.name!);\n } else {\n return client.clientId;\n }\n }\n}\n"],"file":"AbstractResourceTable.js"}
@@ -0,0 +1,120 @@
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; }
/*
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { Button, Modal, Form, FormGroup, TextInput, InputGroup, ModalVariant } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { OkIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { Scope } from "./resource-model.js";
import { Msg } from "../../widgets/Msg.js";
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import { ContentAlert } from "../ContentAlert.js";
import { PermissionSelect } from "./PermissionSelect.js";
export class EditTheResource extends React.Component {
constructor(props, context) {
super(props);
_defineProperty(this, "context", void 0);
_defineProperty(this, "handleToggleDialog", () => {
if (this.state.isOpen) {
this.setState({
isOpen: false
});
this.props.onClose();
} else {
this.clearState();
this.setState({
isOpen: true
});
}
});
_defineProperty(this, "updateChanged", row => {
const changed = this.state.changed;
changed[row] = !changed[row];
this.setState({
changed
});
});
this.context = context;
this.state = {
changed: [],
isOpen: false
};
}
clearState() {
this.setState({});
}
async savePermission(permission) {
await this.context.doPut(`/resources/${this.props.resource._id}/permissions`, [permission]);
ContentAlert.success(Msg.localize('updateSuccess'));
}
render() {
return /*#__PURE__*/React.createElement(React.Fragment, null, this.props.children(this.handleToggleDialog), /*#__PURE__*/React.createElement(Modal, {
title: 'Edit the resource - ' + this.props.resource.name,
variant: ModalVariant.large,
isOpen: this.state.isOpen,
onClose: this.handleToggleDialog,
actions: [/*#__PURE__*/React.createElement(Button, {
key: "done",
variant: "link",
id: "done",
onClick: this.handleToggleDialog
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "done"
}))]
}, /*#__PURE__*/React.createElement(Form, {
isHorizontal: true
}, this.props.permissions.map((p, row) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, {
fieldId: `username-${row}`,
label: Msg.localize('User')
}, /*#__PURE__*/React.createElement(TextInput, {
id: `username-${row}`,
type: "text",
value: p.username,
isDisabled: true
})), /*#__PURE__*/React.createElement(FormGroup, {
fieldId: `permissions-${row}`,
label: Msg.localize('permissions'),
isRequired: true
}, /*#__PURE__*/React.createElement(InputGroup, null, /*#__PURE__*/React.createElement(PermissionSelect, {
scopes: this.props.resource.scopes,
selected: p.scopes.map(s => new Scope(s)),
direction: row === this.props.permissions.length - 1 ? "up" : "down",
onSelect: selection => {
p.scopes = selection.map(s => s.name);
this.updateChanged(row);
}
}), /*#__PURE__*/React.createElement(Button, {
id: `save-${row}`,
isDisabled: !this.state.changed[row],
onClick: () => this.savePermission(p)
}, /*#__PURE__*/React.createElement(OkIcon, null)))), /*#__PURE__*/React.createElement("hr", null))))));
}
}
_defineProperty(EditTheResource, "defaultProps", {
permissions: []
});
_defineProperty(EditTheResource, "contextType", AccountServiceContext);
//# sourceMappingURL=EditTheResource.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,284 @@
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; }
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 parse from "../../util/ParseLink.js";
import { Button, Level, LevelItem, PageSection, PageSectionVariants, Stack, StackItem, Tab, Tabs, TextInput } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import { Scope } from "./resource-model.js";
import { ResourcesTable } from "./ResourcesTable.js";
import { ContentPage } from "../ContentPage.js";
import { Msg } from "../../widgets/Msg.js";
import { SharedResourcesTable } from "./SharedResourcesTable.js";
const MY_RESOURCES_TAB = 0;
const SHARED_WITH_ME_TAB = 1;
export class MyResourcesPage extends React.Component {
constructor(props, context) {
super(props);
_defineProperty(this, "context", void 0);
_defineProperty(this, "first", 0);
_defineProperty(this, "max", 5);
_defineProperty(this, "makeScopeObj", scope => {
return new Scope(scope.name, scope.displayName);
});
_defineProperty(this, "fetchPermissionRequests", () => {
this.state.myResources.data.forEach(resource => {
this.fetchShareRequests(resource);
});
});
_defineProperty(this, "fetchPending", async () => {
const response = await this.context.doGet(`/resources/pending-requests`);
const resources = response.data || [];
resources.forEach(pendingRequest => {
this.state.sharedWithMe.data.forEach(resource => {
if (resource._id === pendingRequest._id) {
resource.shareRequests = [{
username: 'me',
scopes: pendingRequest.scopes
}];
this.forceUpdate();
}
});
});
});
_defineProperty(this, "handleFilterRequest", value => {
this.setState({
nameFilter: value
});
this.fetchFilteredResources({
name: value
});
});
_defineProperty(this, "handleFirstPageClick", () => {
this.fetchInitialResources();
});
_defineProperty(this, "handleNextClick", () => {
if (this.isSharedWithMeTab()) {
this.fetchResources(this.state.sharedWithMe.nextUrl);
} else {
this.fetchResources(this.state.myResources.nextUrl);
}
});
_defineProperty(this, "handlePreviousClick", () => {
if (this.isSharedWithMeTab()) {
this.fetchResources(this.state.sharedWithMe.prevUrl);
} else {
this.fetchResources(this.state.myResources.prevUrl);
}
});
_defineProperty(this, "handleTabClick", (event, tabIndex) => {
if (this.state.activeTabKey === tabIndex) return;
this.setState({
nameFilter: '',
activeTabKey: tabIndex
}, () => {
this.fetchInitialResources();
});
});
this.context = context;
this.state = {
activeTabKey: MY_RESOURCES_TAB,
nameFilter: '',
isModalOpen: false,
myResources: {
nextUrl: '',
prevUrl: '',
data: []
},
sharedWithMe: {
nextUrl: '',
prevUrl: '',
data: []
}
};
this.fetchInitialResources();
}
isSharedWithMeTab() {
return this.state.activeTabKey === SHARED_WITH_ME_TAB;
}
hasNext() {
if (this.isSharedWithMeTab()) {
return this.state.sharedWithMe.nextUrl !== null && this.state.sharedWithMe.nextUrl !== '';
} else {
return this.state.myResources.nextUrl !== null && this.state.myResources.nextUrl !== '';
}
}
hasPrevious() {
if (this.isSharedWithMeTab()) {
return this.state.sharedWithMe.prevUrl !== null && this.state.sharedWithMe.prevUrl !== '';
} else {
return this.state.myResources.prevUrl !== null && this.state.myResources.prevUrl !== '';
}
}
fetchInitialResources() {
if (this.isSharedWithMeTab()) {
this.fetchResources("/resources/shared-with-me");
} else {
this.fetchResources("/resources", {
first: this.first,
max: this.max
});
}
}
fetchFilteredResources(params) {
if (this.isSharedWithMeTab()) {
this.fetchResources("/resources/shared-with-me", params);
} else {
this.fetchResources("/resources", { ...params,
first: this.first,
max: this.max
});
}
}
fetchResources(url, extraParams) {
this.context.doGet(url, {
params: extraParams
}).then(response => {
const resources = response.data || [];
resources.forEach(resource => resource.shareRequests = []); // serialize the Scope objects from JSON so that toString() will work.
resources.forEach(resource => resource.scopes = resource.scopes.map(this.makeScopeObj));
if (this.isSharedWithMeTab()) {
this.setState({
sharedWithMe: this.parseResourceResponse(response)
}, this.fetchPending);
} else {
this.setState({
myResources: this.parseResourceResponse(response)
}, this.fetchPermissionRequests);
}
});
}
fetchShareRequests(resource) {
this.context.doGet('/resources/' + resource._id + '/permissions/requests').then(response => {
resource.shareRequests = response.data || [];
if (resource.shareRequests.length > 0) {
this.forceUpdate();
}
});
}
parseResourceResponse(response) {
const links = response.headers.get('link') || undefined;
const parsed = parse(links);
let next = '';
let prev = '';
if (parsed !== null) {
if (parsed.next) next = parsed.next;
if (parsed.prev) prev = parsed.prev;
}
const resources = response.data || [];
return {
nextUrl: next,
prevUrl: prev,
data: resources
};
}
makeTab(eventKey, title, resources, sharedResourcesTab) {
return /*#__PURE__*/React.createElement(Tab, {
id: title,
eventKey: eventKey,
title: Msg.localize(title)
}, /*#__PURE__*/React.createElement(Stack, {
hasGutter: true
}, /*#__PURE__*/React.createElement(StackItem, {
isFilled: true
}, /*#__PURE__*/React.createElement("span", null)), /*#__PURE__*/React.createElement(StackItem, {
isFilled: true
}, /*#__PURE__*/React.createElement(Level, {
hasGutter: true
}, /*#__PURE__*/React.createElement(LevelItem, null, /*#__PURE__*/React.createElement(TextInput, {
value: this.state.nameFilter,
onChange: this.handleFilterRequest,
id: 'filter-' + title,
type: "text",
placeholder: Msg.localize('filterByName'),
iconVariant: "search"
})))), /*#__PURE__*/React.createElement(StackItem, {
isFilled: true
}, !sharedResourcesTab && /*#__PURE__*/React.createElement(ResourcesTable, {
resources: resources
}), sharedResourcesTab && /*#__PURE__*/React.createElement(SharedResourcesTable, {
resources: resources
}))));
}
render() {
return /*#__PURE__*/React.createElement(ContentPage, {
title: "resources",
onRefresh: this.fetchInitialResources.bind(this)
}, /*#__PURE__*/React.createElement(PageSection, {
variant: PageSectionVariants.light
}, /*#__PURE__*/React.createElement(Tabs, {
activeKey: this.state.activeTabKey,
onSelect: this.handleTabClick
}, this.makeTab(0, 'myResources', this.state.myResources, false), this.makeTab(1, 'sharedwithMe', this.state.sharedWithMe, true)), /*#__PURE__*/React.createElement(Level, {
hasGutter: true
}, /*#__PURE__*/React.createElement(LevelItem, null, this.hasPrevious() && /*#__PURE__*/React.createElement(Button, {
onClick: this.handlePreviousClick
}, "<", /*#__PURE__*/React.createElement(Msg, {
msgKey: "previousPage"
}))), /*#__PURE__*/React.createElement(LevelItem, null, this.hasPrevious() && /*#__PURE__*/React.createElement(Button, {
onClick: this.handleFirstPageClick
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "firstPage"
}))), /*#__PURE__*/React.createElement(LevelItem, null, this.hasNext() && /*#__PURE__*/React.createElement(Button, {
onClick: this.handleNextClick
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "nextPage"
}), ">")))));
}
clearNextPrev() {
const newMyResources = this.state.myResources;
newMyResources.nextUrl = '';
newMyResources.prevUrl = '';
this.setState({
myResources: newMyResources
});
}
}
_defineProperty(MyResourcesPage, "contextType", AccountServiceContext);
;
//# sourceMappingURL=MyResourcesPage.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,151 @@
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; }
/*
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { Button, Modal, Text, Badge, DataListItem, DataList, TextVariants, DataListItemRow, DataListItemCells, DataListCell, Chip, Split, SplitItem, ModalVariant } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { UserCheckIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import { Msg } from "../../widgets/Msg.js";
import { ContentAlert } from "../ContentAlert.js";
export class PermissionRequest extends React.Component {
constructor(props, context) {
super(props);
_defineProperty(this, "context", void 0);
_defineProperty(this, "handleApprove", async (shareRequest, index) => {
this.handle(shareRequest.username, shareRequest.scopes, true);
this.props.resource.shareRequests.splice(index, 1);
});
_defineProperty(this, "handleDeny", async (shareRequest, index) => {
this.handle(shareRequest.username, shareRequest.scopes);
this.props.resource.shareRequests.splice(index, 1);
});
_defineProperty(this, "handle", async (username, scopes, approve = false) => {
const id = this.props.resource._id;
this.handleToggleDialog();
const permissionsRequest = await this.context.doGet(`/resources/${id}/permissions`);
const permissions = permissionsRequest.data || [];
const foundPermission = permissions.find(p => p.username === username);
const userScopes = foundPermission ? foundPermission.scopes : [];
if (approve) {
userScopes.push(...scopes);
}
try {
await this.context.doPut(`/resources/${id}/permissions`, [{
username: username,
scopes: userScopes
}]);
ContentAlert.success(Msg.localize('shareSuccess'));
this.props.onClose();
} catch (e) {
console.error('Could not update permissions', e.error);
}
});
_defineProperty(this, "handleToggleDialog", () => {
this.setState({
isOpen: !this.state.isOpen
});
});
this.context = context;
this.state = {
isOpen: false
};
}
render() {
const id = `shareRequest-${this.props.resource.name.replace(/\s/, '-')}`;
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
id: id,
variant: "link",
onClick: this.handleToggleDialog
}, /*#__PURE__*/React.createElement(UserCheckIcon, {
size: "lg"
}), /*#__PURE__*/React.createElement(Badge, null, this.props.resource.shareRequests.length)), /*#__PURE__*/React.createElement(Modal, {
id: `modal-${id}`,
title: Msg.localize('permissionRequests') + ' - ' + this.props.resource.name,
variant: ModalVariant.large,
isOpen: this.state.isOpen,
onClose: this.handleToggleDialog,
actions: [/*#__PURE__*/React.createElement(Button, {
id: `close-${id}`,
key: "close",
variant: "link",
onClick: this.handleToggleDialog
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "close"
}))]
}, /*#__PURE__*/React.createElement(DataList, {
"aria-label": Msg.localize('permissionRequests')
}, /*#__PURE__*/React.createElement(DataListItemRow, null, /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
key: "permissions-name-header",
width: 5
}, /*#__PURE__*/React.createElement("strong", null, "Requestor")), /*#__PURE__*/React.createElement(DataListCell, {
key: "permissions-requested-header",
width: 5
}, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "permissionRequests"
}))), /*#__PURE__*/React.createElement(DataListCell, {
key: "permission-request-header",
width: 5
})]
})), this.props.resource.shareRequests.map((shareRequest, i) => /*#__PURE__*/React.createElement(DataListItem, {
key: i,
"aria-labelledby": "requestor"
}, /*#__PURE__*/React.createElement(DataListItemRow, null, /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
id: `requestor${i}`,
key: `requestor${i}`
}, /*#__PURE__*/React.createElement("span", null, shareRequest.firstName, " ", shareRequest.lastName, " ", shareRequest.lastName ? '' : shareRequest.username), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Text, {
component: TextVariants.small
}, shareRequest.email)), /*#__PURE__*/React.createElement(DataListCell, {
id: `permissions${i}`,
key: `permissions${i}`
}, shareRequest.scopes.map((scope, j) => /*#__PURE__*/React.createElement(Chip, {
key: j,
isReadOnly: true
}, scope))), /*#__PURE__*/React.createElement(DataListCell, {
key: `actions${i}`
}, /*#__PURE__*/React.createElement(Split, {
hasGutter: true
}, /*#__PURE__*/React.createElement(SplitItem, null, /*#__PURE__*/React.createElement(Button, {
id: `accept-${i}-${id}`,
onClick: () => this.handleApprove(shareRequest, i)
}, "Accept")), /*#__PURE__*/React.createElement(SplitItem, null, /*#__PURE__*/React.createElement(Button, {
id: `deny-${i}-${id}`,
variant: "danger",
onClick: () => this.handleDeny(shareRequest, i)
}, "Deny"))))]
})))))));
}
}
_defineProperty(PermissionRequest, "defaultProps", {
permissions: [],
row: 0
});
_defineProperty(PermissionRequest, "contextType", AccountServiceContext);
//# sourceMappingURL=PermissionRequest.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,103 @@
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; }
import * as React from "../../../../common/keycloak/web_modules/react.js";
import { Select, SelectOption, SelectVariant } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { Msg } from "../../widgets/Msg.js";
class ScopeValue {
constructor(value) {
_defineProperty(this, "value", void 0);
this.value = value;
}
toString() {
return this.value.displayName ? this.value.displayName : this.value.name;
}
compareTo(selectOption) {
return selectOption.name === this.value.name;
}
}
export class PermissionSelect extends React.Component {
constructor(props) {
super(props);
_defineProperty(this, "onSelect", (_event, selection) => {
const {
selected
} = this.state;
const {
onSelect
} = this.props;
if (selected.includes(selection)) {
this.setState(prevState => ({
selected: prevState.selected.filter(item => item !== selection)
}), () => onSelect(this.state.selected.map(sv => sv.value)));
} else {
this.setState(prevState => ({
selected: [...prevState.selected, selection]
}), () => onSelect(this.state.selected.map(sv => sv.value)));
}
});
_defineProperty(this, "onToggle", isExpanded => {
this.setState({
isExpanded
});
});
_defineProperty(this, "clearSelection", () => {
this.setState({
selected: [],
isExpanded: false
});
this.props.onSelect([]);
});
let values = [];
if (this.props.selected) {
values = this.props.selected.map(s => new ScopeValue(s));
}
this.state = {
isExpanded: false,
selected: values,
scopes: this.props.scopes.map((option, index) => /*#__PURE__*/React.createElement(SelectOption, {
key: index,
value: values.find(s => s.compareTo(option)) || new ScopeValue(option)
}))
};
}
render() {
const {
isExpanded,
selected
} = this.state;
const titleId = 'permission-id';
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
id: titleId,
hidden: true
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "selectPermissions"
})), /*#__PURE__*/React.createElement(Select, {
direction: this.props.direction || 'down',
variant: SelectVariant.typeaheadMulti,
typeAheadAriaLabel: Msg.localize("selectPermissions"),
onToggle: this.onToggle,
onSelect: this.onSelect,
onClear: this.clearSelection,
selections: selected,
isOpen: isExpanded,
"aria-labelledby": titleId,
placeholderText: Msg.localize("selectPermissions")
}, this.state.scopes));
}
}
//# sourceMappingURL=PermissionSelect.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,313 @@
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; }
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { DataList, DataListItem, DataListItemRow, DataListCell, DataListToggle, DataListContent, DataListItemCells, Level, LevelItem, Button, DataListAction, Dropdown, DropdownPosition, DropdownItem, KebabToggle } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { Remove2Icon, RepositoryIcon, ShareAltIcon, EditAltIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import { PermissionRequest } from "./PermissionRequest.js";
import { ShareTheResource } from "./ShareTheResource.js";
import { Msg } from "../../widgets/Msg.js";
import { AbstractResourcesTable } from "./AbstractResourceTable.js";
import { EditTheResource } from "./EditTheResource.js";
import { ContentAlert } from "../ContentAlert.js";
import EmptyMessageState from "../../widgets/EmptyMessageState.js";
import { ContinueCancelModal } from "../../widgets/ContinueCancelModal.js";
export class ResourcesTable extends AbstractResourcesTable {
constructor(props, context) {
super(props);
_defineProperty(this, "context", void 0);
_defineProperty(this, "onToggle", row => {
const newIsRowOpen = this.state.isRowOpen;
newIsRowOpen[row] = !newIsRowOpen[row];
if (newIsRowOpen[row]) this.fetchPermissions(this.props.resources.data[row], row);
this.setState({
isRowOpen: newIsRowOpen
});
});
_defineProperty(this, "onContextToggle", (row, isOpen) => {
if (this.state.isModalActive) return;
const data = this.props.resources.data;
const contextOpen = this.state.contextOpen;
contextOpen[row] = isOpen;
if (isOpen) {
const index = row > data.length ? row - data.length - 1 : row;
this.fetchPermissions(data[index], index);
}
this.setState({
contextOpen
});
});
this.context = context;
this.state = {
isRowOpen: [],
contextOpen: [],
isModalActive: false,
permissions: new Map()
};
}
fetchPermissions(resource, row) {
this.context.doGet(`/resources/${resource._id}/permissions`).then(response => {
const newPermissions = new Map(this.state.permissions);
newPermissions.set(row, response.data || []);
this.setState({
permissions: newPermissions
});
});
}
removeShare(resource, row) {
const permissions = this.state.permissions.get(row).map(a => ({
username: a.username,
scopes: []
}));
return this.context.doPut(`/resources/${resource._id}/permissions`, permissions).then(() => {
ContentAlert.success(Msg.localize('unShareSuccess'));
});
}
render() {
if (this.props.resources.data.length === 0) {
return /*#__PURE__*/React.createElement(EmptyMessageState, {
icon: RepositoryIcon,
messageKey: "notHaveAnyResource"
});
}
return /*#__PURE__*/React.createElement(DataList, {
"aria-label": Msg.localize('resources'),
id: "resourcesList"
}, /*#__PURE__*/React.createElement(DataListItem, {
key: "resource-header",
"aria-labelledby": "resource-header"
}, /*#__PURE__*/React.createElement(DataListItemRow, null, "// invisible toggle allows headings to line up properly", /*#__PURE__*/React.createElement("span", {
style: {
visibility: 'hidden'
}
}, /*#__PURE__*/React.createElement(DataListToggle, {
isExpanded: false,
id: "resource-header-invisible-toggle",
"aria-controls": "ex-expand1"
})), /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
key: "resource-name-header",
width: 5
}, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "resourceName"
}))), /*#__PURE__*/React.createElement(DataListCell, {
key: "application-name-header",
width: 5
}, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "application"
}))), /*#__PURE__*/React.createElement(DataListCell, {
key: "permission-request-header",
width: 5
}, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "permissionRequests"
})))]
}))), this.props.resources.data.map((resource, row) => /*#__PURE__*/React.createElement(DataListItem, {
key: 'resource-' + row,
"aria-labelledby": resource.name,
isExpanded: this.state.isRowOpen[row]
}, /*#__PURE__*/React.createElement(DataListItemRow, null, /*#__PURE__*/React.createElement(DataListToggle, {
onClick: () => this.onToggle(row),
isExpanded: this.state.isRowOpen[row],
id: 'resourceToggle-' + row,
"aria-controls": "ex-expand1"
}), /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
id: 'resourceName-' + row,
key: 'resourceName-' + row,
width: 5
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: resource.name
})), /*#__PURE__*/React.createElement(DataListCell, {
id: 'resourceClient-' + row,
key: 'resourceClient-' + row,
width: 5
}, /*#__PURE__*/React.createElement("a", {
href: resource.client.baseUrl
}, this.getClientName(resource.client))), /*#__PURE__*/React.createElement(DataListCell, {
id: 'resourceRequests-' + row,
key: 'permissionRequests-' + row,
width: 5
}, resource.shareRequests.length > 0 && /*#__PURE__*/React.createElement(PermissionRequest, {
resource: resource,
onClose: () => this.fetchPermissions(resource, row)
}))]
}), /*#__PURE__*/React.createElement(DataListAction, {
visibility: {
lg: 'hidden'
},
"aria-labelledby": "check-action-item3 check-action-action3",
id: "check-action-action3",
"aria-label": "Actions"
}, /*#__PURE__*/React.createElement(Dropdown, {
isPlain: true,
position: DropdownPosition.right,
onSelect: () => this.setState({
isModalActive: true
}),
toggle: /*#__PURE__*/React.createElement(KebabToggle, {
onToggle: isOpen => this.onContextToggle(row + this.props.resources.data.length + 1, isOpen)
}),
isOpen: this.state.contextOpen[row + this.props.resources.data.length + 1],
dropdownItems: [/*#__PURE__*/React.createElement(ShareTheResource, {
resource: resource,
permissions: this.state.permissions.get(row),
sharedWithUsersMsg: this.sharedWithUsersMessage(row),
onClose: () => {
this.setState({
isModalActive: false
}, () => {
this.onContextToggle(row + this.props.resources.data.length + 1, false);
this.fetchPermissions(resource, row + this.props.resources.data.length + 1);
});
}
}, toggle => /*#__PURE__*/React.createElement(DropdownItem, {
id: 'mob-share-' + row,
key: "mob-share",
onClick: toggle
}, /*#__PURE__*/React.createElement(ShareAltIcon, null), " ", /*#__PURE__*/React.createElement(Msg, {
msgKey: "share"
}))), /*#__PURE__*/React.createElement(EditTheResource, {
resource: resource,
permissions: this.state.permissions.get(row),
onClose: () => {
this.setState({
isModalActive: false
}, () => {
this.onContextToggle(row + this.props.resources.data.length + 1, false);
this.fetchPermissions(resource, row + this.props.resources.data.length + 1);
});
}
}, toggle => /*#__PURE__*/React.createElement(DropdownItem, {
id: 'mob-edit-' + row,
key: "mob-edit",
isDisabled: this.numOthers(row) < 0,
onClick: toggle
}, /*#__PURE__*/React.createElement(EditAltIcon, null), " ", /*#__PURE__*/React.createElement(Msg, {
msgKey: "edit"
}))), /*#__PURE__*/React.createElement(ContinueCancelModal, {
render: toggle => /*#__PURE__*/React.createElement(DropdownItem, {
id: 'mob-remove-' + row,
key: "mob-remove",
isDisabled: this.numOthers(row) < 0,
onClick: toggle
}, /*#__PURE__*/React.createElement(Remove2Icon, null), " ", /*#__PURE__*/React.createElement(Msg, {
msgKey: "unShare"
})),
modalTitle: "unShare",
modalMessage: "unShareAllConfirm",
onClose: () => this.setState({
isModalActive: false
}, () => {
this.onContextToggle(row + this.props.resources.data.length + 1, false);
}),
onContinue: () => this.removeShare(resource, row).then(() => this.fetchPermissions(resource, row + this.props.resources.data.length + 1))
})]
})), /*#__PURE__*/React.createElement(DataListAction, {
id: `actions-${row}`,
visibility: {
default: 'hidden',
lg: 'visible'
},
"aria-labelledby": "Row actions",
"aria-label": "Actions"
}, /*#__PURE__*/React.createElement(ShareTheResource, {
resource: resource,
permissions: this.state.permissions.get(row),
sharedWithUsersMsg: this.sharedWithUsersMessage(row),
onClose: () => this.fetchPermissions(resource, row)
}, toggle => /*#__PURE__*/React.createElement(Button, {
id: `share-${row}`,
variant: "link",
onClick: toggle
}, /*#__PURE__*/React.createElement(ShareAltIcon, null), " ", /*#__PURE__*/React.createElement(Msg, {
msgKey: "share"
}))), /*#__PURE__*/React.createElement(Dropdown, {
id: `action-menu-${row}`,
isPlain: true,
position: DropdownPosition.right,
toggle: /*#__PURE__*/React.createElement(KebabToggle, {
onToggle: isOpen => this.onContextToggle(row, isOpen)
}),
onSelect: () => this.setState({
isModalActive: true
}),
isOpen: this.state.contextOpen[row],
dropdownItems: [/*#__PURE__*/React.createElement(EditTheResource, {
resource: resource,
permissions: this.state.permissions.get(row),
onClose: () => {
this.setState({
isModalActive: false
}, () => {
this.onContextToggle(row, false);
this.fetchPermissions(resource, row);
});
}
}, toggle => /*#__PURE__*/React.createElement(DropdownItem, {
id: 'edit-' + row,
key: "edit",
component: "button",
isDisabled: this.numOthers(row) < 0,
onClick: toggle
}, /*#__PURE__*/React.createElement(EditAltIcon, null), " ", /*#__PURE__*/React.createElement(Msg, {
msgKey: "edit"
}))), /*#__PURE__*/React.createElement(ContinueCancelModal, {
render: toggle => /*#__PURE__*/React.createElement(DropdownItem, {
id: 'remove-' + row,
key: "remove",
component: "button",
isDisabled: this.numOthers(row) < 0,
onClick: toggle
}, /*#__PURE__*/React.createElement(Remove2Icon, null), " ", /*#__PURE__*/React.createElement(Msg, {
msgKey: "unShare"
})),
modalTitle: "unShare",
modalMessage: "unShareAllConfirm",
onClose: () => this.setState({
isModalActive: false
}, () => {
this.onContextToggle(row, false);
}),
onContinue: () => this.removeShare(resource, row).then(() => this.fetchPermissions(resource, row))
})]
}))), /*#__PURE__*/React.createElement(DataListContent, {
hasNoPadding: false,
"aria-label": "Session Details",
id: 'ex-expand' + row,
isHidden: !this.state.isRowOpen[row]
}, /*#__PURE__*/React.createElement(Level, {
hasGutter: true
}, /*#__PURE__*/React.createElement(LevelItem, null, /*#__PURE__*/React.createElement("span", null)), /*#__PURE__*/React.createElement(LevelItem, {
id: 'shared-with-user-message-' + row
}, this.sharedWithUsersMessage(row)), /*#__PURE__*/React.createElement(LevelItem, null, /*#__PURE__*/React.createElement("span", null)))))));
}
}
_defineProperty(ResourcesTable, "contextType", AccountServiceContext);
//# sourceMappingURL=ResourcesTable.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,222 @@
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; }
/*
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { Button, Chip, ChipGroup, Form, FormGroup, Gallery, GalleryItem, Modal, Stack, StackItem, TextInput, ModalVariant } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import { Msg } from "../../widgets/Msg.js";
import { ContentAlert } from "../ContentAlert.js";
import { PermissionSelect } from "./PermissionSelect.js";
/**
* @author Stan Silvert ssilvert@redhat.com (C) 2019 Red Hat Inc.
*/
export class ShareTheResource extends React.Component {
constructor(props, context) {
super(props);
_defineProperty(this, "context", void 0);
_defineProperty(this, "handleAddPermission", () => {
const rscId = this.props.resource._id;
const newPermissions = [];
for (const permission of this.state.permissionsSelected) {
newPermissions.push(permission.name);
}
const permissions = [];
for (const username of this.state.usernames) {
permissions.push({
username: username,
scopes: newPermissions
});
}
this.handleToggleDialog();
this.context.doPut(`/resources/${rscId}/permissions`, permissions).then(() => {
ContentAlert.success('shareSuccess');
this.props.onClose();
});
});
_defineProperty(this, "handleToggleDialog", () => {
if (this.state.isOpen) {
this.setState({
isOpen: false
});
this.props.onClose();
} else {
this.clearState();
this.setState({
isOpen: true
});
}
});
_defineProperty(this, "handleUsernameChange", username => {
this.setState({
usernameInput: username
});
});
_defineProperty(this, "handleAddUsername", async () => {
if (this.state.usernameInput !== '' && !this.state.usernames.includes(this.state.usernameInput)) {
const response = await this.context.doGet(`/resources/${this.props.resource._id}/user`, {
params: {
value: this.state.usernameInput
}
});
if (response.data && response.data.username) {
this.setState({
usernameInput: '',
usernames: [...this.state.usernames, this.state.usernameInput]
});
} else {
ContentAlert.info('userNotFound', [this.state.usernameInput]);
}
}
});
_defineProperty(this, "handleEnterKeyInAddField", event => {
if (event.key === "Enter") {
event.preventDefault();
this.handleAddUsername();
}
});
_defineProperty(this, "handleDeleteUsername", username => {
const newUsernames = this.state.usernames.filter(user => user !== username);
this.setState({
usernames: newUsernames
});
});
this.context = context;
this.state = {
isOpen: false,
permissionsSelected: [],
permissionsUnSelected: this.props.resource.scopes,
usernames: [],
usernameInput: ''
};
}
clearState() {
this.setState({
permissionsSelected: [],
permissionsUnSelected: this.props.resource.scopes,
usernames: [],
usernameInput: ''
});
}
isAddDisabled() {
return this.state.usernameInput === '' || this.isAlreadyShared();
}
isAlreadyShared() {
for (let permission of this.props.permissions) {
if (permission.username === this.state.usernameInput) return true;
}
return false;
}
isFormInvalid() {
return this.state.usernames.length === 0 || this.state.permissionsSelected.length === 0;
}
render() {
return /*#__PURE__*/React.createElement(React.Fragment, null, this.props.children(this.handleToggleDialog), /*#__PURE__*/React.createElement(Modal, {
title: 'Share the resource - ' + this.props.resource.name,
variant: ModalVariant.large,
isOpen: this.state.isOpen,
onClose: this.handleToggleDialog,
actions: [/*#__PURE__*/React.createElement(Button, {
key: "cancel",
variant: "link",
onClick: this.handleToggleDialog
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "cancel"
})), /*#__PURE__*/React.createElement(Button, {
key: "confirm",
variant: "primary",
id: "done",
onClick: this.handleAddPermission,
isDisabled: this.isFormInvalid()
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "done"
}))]
}, /*#__PURE__*/React.createElement(Stack, {
hasGutter: true
}, /*#__PURE__*/React.createElement(StackItem, {
isFilled: true
}, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(FormGroup, {
label: "Add users to share your resource with",
type: "string",
helperTextInvalid: Msg.localize('resourceAlreadyShared'),
fieldId: "username",
isRequired: true
}, /*#__PURE__*/React.createElement(Gallery, {
hasGutter: true
}, /*#__PURE__*/React.createElement(GalleryItem, null, /*#__PURE__*/React.createElement(TextInput, {
value: this.state.usernameInput,
id: "username",
"aria-describedby": "username-helper",
placeholder: "Username or email",
onChange: this.handleUsernameChange,
onKeyPress: this.handleEnterKeyInAddField
})), /*#__PURE__*/React.createElement(GalleryItem, null, /*#__PURE__*/React.createElement(Button, {
key: "add-user",
variant: "primary",
id: "add",
onClick: this.handleAddUsername,
isDisabled: this.isAddDisabled()
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "add"
})))), /*#__PURE__*/React.createElement(ChipGroup, {
categoryName: Msg.localize('shareWith')
}, this.state.usernames.map(currentChip => /*#__PURE__*/React.createElement(Chip, {
key: currentChip,
onClick: () => this.handleDeleteUsername(currentChip)
}, currentChip)))), /*#__PURE__*/React.createElement(FormGroup, {
label: "",
fieldId: "permissions-selected"
}, /*#__PURE__*/React.createElement(PermissionSelect, {
scopes: this.state.permissionsUnSelected,
onSelect: selection => this.setState({
permissionsSelected: selection
}),
direction: "up"
})))), /*#__PURE__*/React.createElement(StackItem, {
isFilled: true
}, /*#__PURE__*/React.createElement("br", null)), /*#__PURE__*/React.createElement(StackItem, {
isFilled: true
}, this.props.sharedWithUsersMsg))));
}
}
_defineProperty(ShareTheResource, "defaultProps", {
permissions: []
});
_defineProperty(ShareTheResource, "contextType", AccountServiceContext);
//# sourceMappingURL=ShareTheResource.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,97 @@
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { DataList, DataListItem, DataListItemRow, DataListCell, DataListItemCells, ChipGroup, Chip } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { RepositoryIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { Msg } from "../../widgets/Msg.js";
import { AbstractResourcesTable } from "./AbstractResourceTable.js";
import EmptyMessageState from "../../widgets/EmptyMessageState.js";
export class SharedResourcesTable extends AbstractResourcesTable {
constructor(props) {
super(props);
this.state = {
permissions: new Map()
};
}
render() {
if (this.props.resources.data.length === 0) {
return /*#__PURE__*/React.createElement(EmptyMessageState, {
icon: RepositoryIcon,
messageKey: "noResourcesSharedWithYou"
});
}
return /*#__PURE__*/React.createElement(DataList, {
"aria-label": Msg.localize('resources'),
id: "sharedResourcesList"
}, /*#__PURE__*/React.createElement(DataListItem, {
key: "resource-header",
"aria-labelledby": "resource-header"
}, /*#__PURE__*/React.createElement(DataListItemRow, null, /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
key: "resource-name-header",
width: 2
}, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "resourceName"
}))), /*#__PURE__*/React.createElement(DataListCell, {
key: "application-name-header",
width: 2
}, /*#__PURE__*/React.createElement("strong", null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "application"
}))), /*#__PURE__*/React.createElement(DataListCell, {
key: "permission-header",
width: 2
}), /*#__PURE__*/React.createElement(DataListCell, {
key: "requests-header",
width: 2
})]
}))), this.props.resources.data.map((resource, row) => /*#__PURE__*/React.createElement(DataListItem, {
key: 'resource-' + row,
"aria-labelledby": resource.name
}, /*#__PURE__*/React.createElement(DataListItemRow, null, /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
key: 'resourceName-' + row,
width: 2
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: resource.name
})), /*#__PURE__*/React.createElement(DataListCell, {
key: 'resourceClient-' + row,
width: 2
}, /*#__PURE__*/React.createElement("a", {
href: resource.client.baseUrl
}, this.getClientName(resource.client))), /*#__PURE__*/React.createElement(DataListCell, {
key: 'permissions-' + row,
width: 2
}, resource.scopes.length > 0 && /*#__PURE__*/React.createElement(ChipGroup, {
categoryName: Msg.localize('permissions')
}, resource.scopes.map(scope => /*#__PURE__*/React.createElement(Chip, {
key: scope.name,
isReadOnly: true
}, scope.displayName || scope.name)))), /*#__PURE__*/React.createElement(DataListCell, {
key: 'pending-' + row,
width: 2
}, resource.shareRequests.length > 0 && /*#__PURE__*/React.createElement(ChipGroup, {
categoryName: Msg.localize('pending')
}, resource.shareRequests[0].scopes.map(scope => /*#__PURE__*/React.createElement(Chip, {
key: scope.name,
isReadOnly: true
}, scope.displayName || scope.name))))]
})))));
}
}
//# sourceMappingURL=SharedResourcesTable.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,16 @@
export class Scope {
constructor(name, displayName) {
this.name = name;
this.displayName = displayName;
}
toString() {
if (this.hasOwnProperty('displayName') && this.displayName) {
return this.displayName;
} else {
return this.name;
}
}
}
//# sourceMappingURL=resource-model.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/app/content/my-resources-page/resource-model.ts"],"names":["Scope","constructor","name","displayName","toString","hasOwnProperty"],"mappings":"AAeA,OAAO,MAAMA,KAAN,CAAY;AACVC,EAAAA,WAAW,CAAQC,IAAR,EAA6BC,WAA7B,EAAmD;AAAA,SAA3CD,IAA2C,GAA3CA,IAA2C;AAAA,SAAtBC,WAAsB,GAAtBA,WAAsB;AAAE;;AAEhEC,EAAAA,QAAQ,GAAW;AACtB,QAAI,KAAKC,cAAL,CAAoB,aAApB,KAAuC,KAAKF,WAAhD,EAA8D;AAC1D,aAAO,KAAKA,WAAZ;AACH,KAFD,MAEO;AACH,aAAO,KAAKD,IAAZ;AACH;AACJ;;AATgB","sourcesContent":["export interface Resource {\n _id: string;\n name: string;\n client: Client;\n scopes: Scope[];\n uris: string[];\n shareRequests: Permission[];\n}\n\nexport interface Client {\n baseUrl: string;\n clientId: string;\n name?: string;\n}\n\nexport class Scope {\n public constructor(public name: string, public displayName?: string) {}\n\n public toString(): string {\n if (this.hasOwnProperty('displayName') && (this.displayName)) {\n return this.displayName;\n } else {\n return this.name;\n }\n }\n}\n\nexport interface PaginatedResources {\n nextUrl: string;\n prevUrl: string;\n data: Resource[];\n}\n\nexport interface Permission {\n email?: string;\n firstName?: string;\n lastName?: string;\n scopes: Scope[] | string[]; // this should be Scope[] - fix API\n username: string;\n}\n\nexport interface Permissions {\n permissions: Permission[];\n row?: number;\n}\n"],"file":"resource-model.js"}
@@ -0,0 +1,31 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import * as React from "../../../../common/keycloak/web_modules/react.js";
import { WarningTriangleIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
import { withRouter } from "../../../../common/keycloak/web_modules/react-router-dom.js";
import { Msg } from "../../widgets/Msg.js";
import EmptyMessageState from "../../widgets/EmptyMessageState.js";
class PgNotFound extends React.Component {
constructor(props) {
super(props);
}
render() {
return /*#__PURE__*/React.createElement(EmptyMessageState, {
icon: WarningTriangleIcon,
messageKey: "pageNotFound"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "invalidRoute",
params: [this.props.location.pathname]
}));
}
}
;
export const PageNotFound = withRouter(PgNotFound);
//# sourceMappingURL=PageNotFound.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/app/content/page-not-found/PageNotFound.tsx"],"names":["React","WarningTriangleIcon","withRouter","Msg","EmptyMessageState","PgNotFound","Component","constructor","props","render","location","pathname","PageNotFound"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAO,KAAKA,KAAZ;AAEA,SAASC,mBAAT;AACA,SAAQC,UAAR;AACA,SAAQC,GAAR;AACA,OAAOC,iBAAP;;AAIA,MAAMC,UAAN,SAAyBL,KAAK,CAACM,SAA/B,CAA4D;AAEjDC,EAAAA,WAAW,CAACC,KAAD,EAA2B;AACzC,UAAMA,KAAN;AACH;;AAEMC,EAAAA,MAAM,GAAoB;AAC7B,wBACI,oBAAC,iBAAD;AAAmB,MAAA,IAAI,EAAER,mBAAzB;AAA8C,MAAA,UAAU,EAAC;AAAzD,oBACI,oBAAC,GAAD;AAAK,MAAA,MAAM,EAAC,cAAZ;AAA2B,MAAA,MAAM,EAAE,CAAC,KAAKO,KAAL,CAAWE,QAAX,CAAoBC,QAArB;AAAnC,MADJ,CADJ;AAKH;;AAZuD;;AAa3D;AAED,OAAO,MAAMC,YAAY,GAAGV,UAAU,CAACG,UAAD,CAA/B","sourcesContent":["/*\n * To change this license header, choose License Headers in Project Properties.\n * To change this template file, choose Tools | Templates\n * and open the template in the editor.\n */\n\nimport * as React from 'react';\n\nimport { WarningTriangleIcon } from '@patternfly/react-icons';\nimport {withRouter, RouteComponentProps} from 'react-router-dom';\nimport {Msg} from '../../widgets/Msg';\nimport EmptyMessageState from '../../widgets/EmptyMessageState';\n\nexport interface PageNotFoundProps extends RouteComponentProps {}\n\nclass PgNotFound extends React.Component<PageNotFoundProps> {\n\n public constructor(props: PageNotFoundProps) {\n super(props);\n }\n\n public render(): React.ReactNode {\n return (\n <EmptyMessageState icon={WarningTriangleIcon} messageKey=\"pageNotFound\">\n <Msg msgKey=\"invalidRoute\" params={[this.props.location.pathname]} />\n </EmptyMessageState>\n );\n }\n};\n\nexport const PageNotFound = withRouter(PgNotFound);"],"file":"PageNotFound.js"}
@@ -0,0 +1,350 @@
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; }
/*
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 { withRouter } from "../../../../common/keycloak/web_modules/react-router-dom.js";
import { Alert, Button, DataList, DataListAction, DataListItemCells, DataListCell, DataListItem, DataListItemRow, EmptyState, EmptyStateVariant, EmptyStateBody, Split, SplitItem, Title, Dropdown, DropdownPosition, KebabToggle, PageSection, PageSectionVariants } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
import { AIACommand } from "../../util/AIACommand.js";
import TimeUtil from "../../util/TimeUtil.js";
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
import { ContinueCancelModal } from "../../widgets/ContinueCancelModal.js";
import { Msg } from "../../widgets/Msg.js";
import { ContentPage } from "../ContentPage.js";
import { ContentAlert } from "../ContentAlert.js";
import { KeycloakContext } from "../../keycloak-service/KeycloakContext.js";
/**
* @author Stan Silvert ssilvert@redhat.com (C) 2018 Red Hat Inc.
*/
class SigningInPage extends React.Component {
constructor(props, context) {
super(props);
_defineProperty(this, "context", void 0);
_defineProperty(this, "handleRemove", (credentialId, userLabel) => {
this.context.doDelete("/credentials/" + credentialId).then(() => {
this.getCredentialContainers();
ContentAlert.success("successRemovedMessage", [userLabel]);
});
});
this.context = context;
this.state = {
credentialContainers: new Map()
};
this.getCredentialContainers();
}
getCredentialContainers() {
this.context.doGet("/credentials").then(response => {
const allContainers = new Map();
const containers = response.data || [];
containers.forEach(container => {
let categoryMap = allContainers.get(container.category);
if (!categoryMap) {
categoryMap = new Map();
allContainers.set(container.category, categoryMap);
}
categoryMap.set(container.type, container);
});
this.setState({
credentialContainers: allContainers
});
});
}
static credElementId(credType, credId, item) {
return `${credType}-${item}-${credId.substring(0, 8)}`;
}
render() {
return /*#__PURE__*/React.createElement(ContentPage, {
title: "signingIn",
introMessage: "signingInSubMessage"
}, this.renderCategories());
}
renderCategories() {
return Array.from(this.state.credentialContainers.keys()).map(category => /*#__PURE__*/React.createElement(PageSection, {
key: category,
variant: PageSectionVariants.light
}, /*#__PURE__*/React.createElement(Title, {
id: `${category}-categ-title`,
headingLevel: "h2",
size: "xl"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: category
})), this.renderTypes(category)));
}
renderTypes(category) {
let credTypeMap = this.state.credentialContainers.get(category);
return /*#__PURE__*/React.createElement(KeycloakContext.Consumer, null, keycloak => /*#__PURE__*/React.createElement(React.Fragment, null, Array.from(credTypeMap.keys()).map((credType, index, typeArray) => [this.renderCredTypeTitle(credTypeMap.get(credType), keycloak, category), this.renderUserCredentials(credTypeMap, credType, keycloak)])));
}
renderEmptyRow(type, isLast) {
if (isLast) return; // don't put empty row at the end
return /*#__PURE__*/React.createElement(DataListItem, {
"aria-labelledby": "empty-list-item-" + type
}, /*#__PURE__*/React.createElement(DataListItemRow, {
key: "empty-row-" + type
}, /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, null)]
})));
}
renderUserCredentials(credTypeMap, credType, keycloak) {
const credContainer = credTypeMap.get(credType);
const userCredentialMetadatas = credContainer.userCredentialMetadatas;
const removeable = credContainer.removeable;
const type = credContainer.type;
const displayName = credContainer.displayName;
if (!userCredentialMetadatas || userCredentialMetadatas.length === 0) {
const localizedDisplayName = Msg.localize(displayName);
return /*#__PURE__*/React.createElement(DataList, {
"aria-label": Msg.localize('notSetUp', [localizedDisplayName]),
className: "pf-u-mb-xl"
}, /*#__PURE__*/React.createElement(DataListItem, {
key: "no-credentials-list-item",
"aria-labelledby": Msg.localize('notSetUp', [localizedDisplayName])
}, /*#__PURE__*/React.createElement(DataListItemRow, {
key: "no-credentials-list-item-row",
className: "pf-u-align-items-center"
}, /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: [/*#__PURE__*/React.createElement(DataListCell, {
key: 'no-credentials-cell-0'
}), /*#__PURE__*/React.createElement(EmptyState, {
id: `${type}-not-set-up`,
key: 'no-credentials-cell-1',
variant: EmptyStateVariant.xs
}, /*#__PURE__*/React.createElement(EmptyStateBody, null, /*#__PURE__*/React.createElement(Msg, {
msgKey: "notSetUp",
params: [localizedDisplayName]
}))), /*#__PURE__*/React.createElement(DataListCell, {
key: 'no-credentials-cell-2'
})]
}))));
}
userCredentialMetadatas.forEach(credentialMetadata => {
let credential = credentialMetadata.credential;
if (!credential.userLabel) credential.userLabel = Msg.localize(credential.type);
if (credential.hasOwnProperty('createdDate') && credential.createdDate && credential.createdDate > 0) {
credential.strCreatedDate = TimeUtil.format(credential.createdDate);
}
});
let updateAIA;
if (credContainer.updateAction) {
updateAIA = new AIACommand(keycloak, credContainer.updateAction);
}
let maxWidth = {
maxWidth: 689
};
return /*#__PURE__*/React.createElement(React.Fragment, {
key: "userCredentialMetadatas"
}, " ", userCredentialMetadatas.map(credentialMetadata => /*#__PURE__*/React.createElement(React.Fragment, null, credentialMetadata.infoMessage && !credentialMetadata.warningMessageTitle && !credentialMetadata.warningMessageDescription && /*#__PURE__*/React.createElement(Alert, {
variant: "default",
className: "pf-u-mb-md",
isInline: true,
isPlain: true,
title: Msg.localize(JSON.parse(credentialMetadata.infoMessage).key, JSON.parse(credentialMetadata.infoMessage).parameters)
}), credentialMetadata.warningMessageTitle && credentialMetadata.warningMessageDescription && /*#__PURE__*/React.createElement(Alert, {
variant: "warning",
className: "pf-u-mb-md",
isInline: true,
title: Msg.localize(JSON.parse(credentialMetadata.warningMessageTitle).key, JSON.parse(credentialMetadata.warningMessageTitle).parameters),
style: maxWidth
}, /*#__PURE__*/React.createElement("p", null, Msg.localize(JSON.parse(credentialMetadata.warningMessageDescription).key, JSON.parse(credentialMetadata.warningMessageDescription).parameters))), /*#__PURE__*/React.createElement(DataList, {
"aria-label": "user credential",
className: "pf-u-mb-xl"
}, /*#__PURE__*/React.createElement(DataListItem, {
id: `${SigningInPage.credElementId(type, credentialMetadata.credential.id, 'row')}`,
key: 'credential-list-item-' + credentialMetadata.credential.id,
"aria-labelledby": 'credential-list-item-' + credentialMetadata.credential.userLabel
}, /*#__PURE__*/React.createElement(DataListItemRow, {
key: 'userCredentialRow-' + credentialMetadata.credential.id,
className: "pf-u-align-items-center"
}, /*#__PURE__*/React.createElement(DataListItemCells, {
dataListCells: this.credentialRowCells(credentialMetadata, type)
}), /*#__PURE__*/React.createElement(CredentialAction, {
credential: credentialMetadata.credential,
removeable: removeable,
updateAction: updateAIA,
credRemover: this.handleRemove
})))))), " ");
}
credentialRowCells(credMetadata, type) {
const credRowCells = [];
const credential = credMetadata.credential;
let maxWidth = {
"--pf-u-max-width--MaxWidth": "300px"
};
credRowCells.push( /*#__PURE__*/React.createElement(DataListCell, {
id: `${SigningInPage.credElementId(type, credential.id, 'label')}`,
key: 'userLabel-' + credential.id,
className: "pf-u-max-width",
style: maxWidth
}, credential.userLabel));
if (credential.strCreatedDate) {
credRowCells.push( /*#__PURE__*/React.createElement(DataListCell, {
id: `${SigningInPage.credElementId(type, credential.id, "created-at")}`,
key: "created-" + credential.id
}, /*#__PURE__*/React.createElement("strong", {
className: "pf-u-mr-md"
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "credentialCreatedAt"
}), " "), credential.strCreatedDate));
credRowCells.push( /*#__PURE__*/React.createElement(DataListCell, {
key: "spacer-" + credential.id
}));
}
return credRowCells;
}
renderCredTypeTitle(credContainer, keycloak, category) {
if (!credContainer.hasOwnProperty("helptext") && !credContainer.hasOwnProperty("createAction")) return;
let setupAction;
if (credContainer.createAction) {
setupAction = new AIACommand(keycloak, credContainer.createAction);
}
const credContainerDisplayName = Msg.localize(credContainer.displayName);
return /*#__PURE__*/React.createElement(React.Fragment, {
key: "credTypeTitle-" + credContainer.type
}, /*#__PURE__*/React.createElement(Split, {
className: "pf-u-mt-lg pf-u-mb-lg"
}, /*#__PURE__*/React.createElement(SplitItem, null, /*#__PURE__*/React.createElement(Title, {
headingLevel: "h3",
size: "md",
className: "pf-u-mb-md"
}, /*#__PURE__*/React.createElement("span", {
className: "cred-title pf-u-display-block",
id: `${credContainer.type}-cred-title`
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: credContainer.displayName
}))), /*#__PURE__*/React.createElement("span", {
id: `${credContainer.type}-cred-help`
}, credContainer.helptext && /*#__PURE__*/React.createElement(Msg, {
msgKey: credContainer.helptext
}))), /*#__PURE__*/React.createElement(SplitItem, {
isFilled: true
}, credContainer.createAction && /*#__PURE__*/React.createElement("div", {
id: "mob-setUpAction-" + credContainer.type,
className: "pf-u-display-none-on-lg pf-u-float-right"
}, /*#__PURE__*/React.createElement(Dropdown, {
isPlain: true,
position: DropdownPosition.right,
toggle: /*#__PURE__*/React.createElement(KebabToggle, {
onToggle: isOpen => {
credContainer.open = isOpen;
this.setState({
credentialContainers: new Map(this.state.credentialContainers)
});
}
}),
isOpen: credContainer.open,
dropdownItems: [/*#__PURE__*/React.createElement("button", {
id: `mob-${credContainer.type}-set-up`,
className: "pf-c-button pf-m-link",
type: "button",
onClick: () => setupAction.execute()
}, /*#__PURE__*/React.createElement("span", {
className: "pf-c-button__icon"
}, /*#__PURE__*/React.createElement("i", {
className: "fas fa-plus-circle",
"aria-hidden": "true"
})), /*#__PURE__*/React.createElement(Msg, {
msgKey: "setUpNew",
params: [credContainerDisplayName]
}))]
})), credContainer.createAction && /*#__PURE__*/React.createElement("div", {
id: "setUpAction-" + credContainer.type,
className: "pf-u-display-none pf-u-display-inline-flex-on-lg pf-u-float-right"
}, /*#__PURE__*/React.createElement("button", {
id: `${credContainer.type}-set-up`,
className: "pf-c-button pf-m-link",
type: "button",
onClick: () => setupAction.execute()
}, /*#__PURE__*/React.createElement("span", {
className: "pf-c-button__icon"
}, /*#__PURE__*/React.createElement("i", {
className: "fas fa-plus-circle",
"aria-hidden": "true"
})), /*#__PURE__*/React.createElement(Msg, {
msgKey: "setUpNew",
params: [credContainerDisplayName]
}))))));
}
}
_defineProperty(SigningInPage, "contextType", AccountServiceContext);
;
class CredentialAction extends React.Component {
render() {
if (this.props.updateAction) {
return /*#__PURE__*/React.createElement(DataListAction, {
"aria-labelledby": Msg.localize('updateCredAriaLabel'),
"aria-label": Msg.localize('updateCredAriaLabel'),
id: "updateAction-" + this.props.credential.id
}, /*#__PURE__*/React.createElement(Button, {
variant: "secondary",
id: `${SigningInPage.credElementId(this.props.credential.type, this.props.credential.id, "update")}`,
onClick: () => this.props.updateAction.execute()
}, /*#__PURE__*/React.createElement(Msg, {
msgKey: "update"
})));
}
if (this.props.removeable) {
const userLabel = this.props.credential.userLabel;
return /*#__PURE__*/React.createElement(DataListAction, {
"aria-label": Msg.localize('removeCredAriaLabel'),
"aria-labelledby": Msg.localize('removeCredAriaLabel'),
id: 'removeAction-' + this.props.credential.id
}, /*#__PURE__*/React.createElement(ContinueCancelModal, {
buttonTitle: "remove",
buttonVariant: "danger",
buttonId: `${SigningInPage.credElementId(this.props.credential.type, this.props.credential.id, 'remove')}`,
modalTitle: Msg.localize('removeCred', [userLabel]),
modalMessage: Msg.localize('stopUsingCred', [userLabel]),
onContinue: () => this.props.credRemover(this.props.credential.id, userLabel)
}));
}
return /*#__PURE__*/React.createElement(React.Fragment, null);
}
}
const SigningInPageWithRouter = withRouter(SigningInPage);
export { SigningInPageWithRouter as SigningInPage };
//# sourceMappingURL=SigningInPage.js.map
File diff suppressed because one or more lines are too long