feat: update keycloak theme
This commit is contained in:
+1
-6
@@ -1,22 +1,19 @@
|
||||
import * as React from "../../../../common/keycloak/web_modules/react.js";
|
||||
import * as React from "../../../keycloak.v2/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"
|
||||
@@ -27,7 +24,6 @@ export class AbstractResourcesTable extends React.Component {
|
||||
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);
|
||||
@@ -35,6 +31,5 @@ export class AbstractResourcesTable extends React.Component {
|
||||
return client.clientId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//# sourceMappingURL=AbstractResourceTable.js.map
|
||||
+1
-1
@@ -1 +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"}
|
||||
{"version":3,"file":"AbstractResourceTable.js","names":["React","Msg","AbstractResourcesTable","Component","hasPermissions","row","state","permissions","has","get","length","firstUser","username","numOthers","sharedWithUsersMessage","createElement","Fragment","msgKey","getClientName","client","hasOwnProperty","name","localize","clientId"],"sources":["../../../src/app/content/my-resources-page/AbstractResourceTable.tsx"],"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"],"mappings":"AAAA,OAAO,KAAKA,KAAK;AAEjB,SAASC,GAAG;AAUZ,OAAO,MAAeC,sBAAsB,SAAwCF,KAAK,CAACG,SAAS,CAAyB;EAEhHC,cAAcA,CAACC,GAAW,EAAW;IAC7C,OAAQ,IAAI,CAACC,KAAK,CAACC,WAAW,CAACC,GAAG,CAACH,GAAG,CAAC,IAAM,IAAI,CAACC,KAAK,CAACC,WAAW,CAACE,GAAG,CAACJ,GAAG,CAAC,CAAEK,MAAM,GAAG,CAAE;EAC3F;EAEQC,SAASA,CAACN,GAAW,EAAU;IACrC,IAAI,CAAC,IAAI,CAACD,cAAc,CAACC,GAAG,CAAC,EAAE,OAAO,WAAW,CAAC,CAAC;;IAEnD,OAAO,IAAI,CAACC,KAAK,CAACC,WAAW,CAACE,GAAG,CAACJ,GAAG,CAAC,CAAE,CAAC,CAAC,CAACO,QAAQ;EACrD;EAEUC,SAASA,CAACR,GAAW,EAAU;IACvC,IAAI,CAAC,IAAI,CAACD,cAAc,CAACC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;;IAE1C,OAAO,IAAI,CAACC,KAAK,CAACC,WAAW,CAACE,GAAG,CAACJ,GAAG,CAAC,CAAEK,MAAM,GAAG,CAAC;EACpD;EAEOI,sBAAsBA,CAACT,GAAW,EAAmB;IAC1D,IAAI,CAAC,IAAI,CAACD,cAAc,CAACC,GAAG,CAAC,EAAE,oBAAQL,KAAA,CAAAe,aAAA,CAACf,KAAK,CAACgB,QAAQ,qBAAChB,KAAA,CAAAe,aAAA,CAACd,GAAG;MAACgB,MAAM,EAAC;IAAmB,CAAE,CAAiB,CAAC;IAE1G,oBACEjB,KAAA,CAAAe,aAAA,CAACf,KAAK,CAACgB,QAAQ,qBACbhB,KAAA,CAAAe,aAAA,CAACd,GAAG;MAACgB,MAAM,EAAC;IAAoB,gBAC9BjB,KAAA,CAAAe,aAAA,iBAAS,IAAI,CAACJ,SAAS,CAACN,GAAG,CAAU,CAClC,CAAC,EACL,IAAI,CAACQ,SAAS,CAACR,GAAG,CAAC,GAAG,CAAC,iBAAIL,KAAA,CAAAe,aAAA,CAACd,GAAG;MAACgB,MAAM,EAAC;IAAK,gBAC3CjB,KAAA,CAAAe,aAAA,iBAAS,IAAI,CAACF,SAAS,CAACR,GAAG,CAAU,CAClC,CAAC,EAAC,GACO,CAAC;EAErB;EAEUa,aAAaA,CAACC,MAAc,EAAU;IAC9C,IAAIA,MAAM,CAACC,cAAc,CAAC,MAAM,CAAC,IAAID,MAAM,CAACE,IAAI,KAAK,IAAI,IAAIF,MAAM,CAACE,IAAI,KAAK,EAAE,EAAE;MAC/E,OAAOpB,GAAG,CAACqB,QAAQ,CAACH,MAAM,CAACE,IAAK,CAAC;IACnC,CAAC,MAAM;MACL,OAAOF,MAAM,CAACI,QAAQ;IACxB;EACF;AACF"}
|
||||
+8
-16
@@ -1,5 +1,6 @@
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
/*
|
||||
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
|
||||
*
|
||||
@@ -15,9 +16,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as React from "../../../../common/keycloak/web_modules/react.js";
|
||||
import { 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 * as React from "../../../keycloak.v2/web_modules/react.js";
|
||||
import { Button, Modal, Form, FormGroup, TextInput, InputGroup, ModalVariant } from "../../../keycloak.v2/web_modules/@patternfly/react-core.js";
|
||||
import { OkIcon } from "../../../keycloak.v2/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";
|
||||
@@ -26,9 +28,7 @@ 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({
|
||||
@@ -42,7 +42,6 @@ export class EditTheResource extends React.Component {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_defineProperty(this, "updateChanged", row => {
|
||||
const changed = this.state.changed;
|
||||
changed[row] = !changed[row];
|
||||
@@ -50,23 +49,19 @@ export class EditTheResource extends React.Component {
|
||||
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]);
|
||||
await this.context.doPut(`/resources/${encodeURIComponent(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,
|
||||
@@ -109,12 +104,9 @@ export class EditTheResource extends React.Component {
|
||||
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
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+12
-38
@@ -1,5 +1,6 @@
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
/*
|
||||
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
|
||||
*
|
||||
@@ -15,9 +16,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as React from "../../../../common/keycloak/web_modules/react.js";
|
||||
|
||||
import * as React from "../../../keycloak.v2/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 { Button, Level, LevelItem, PageSection, PageSectionVariants, Stack, StackItem, Tab, Tabs, TextInput } from "../../../keycloak.v2/web_modules/@patternfly/react-core.js";
|
||||
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
|
||||
import { Scope } from "./resource-model.js";
|
||||
import { ResourcesTable } from "./ResourcesTable.js";
|
||||
@@ -29,23 +31,17 @@ 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 || [];
|
||||
@@ -61,7 +57,6 @@ export class MyResourcesPage extends React.Component {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(this, "handleFilterRequest", value => {
|
||||
this.setState({
|
||||
nameFilter: value
|
||||
@@ -70,11 +65,9 @@ export class MyResourcesPage extends React.Component {
|
||||
name: value
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(this, "handleFirstPageClick", () => {
|
||||
this.fetchInitialResources();
|
||||
});
|
||||
|
||||
_defineProperty(this, "handleNextClick", () => {
|
||||
if (this.isSharedWithMeTab()) {
|
||||
this.fetchResources(this.state.sharedWithMe.nextUrl);
|
||||
@@ -82,7 +75,6 @@ export class MyResourcesPage extends React.Component {
|
||||
this.fetchResources(this.state.myResources.nextUrl);
|
||||
}
|
||||
});
|
||||
|
||||
_defineProperty(this, "handlePreviousClick", () => {
|
||||
if (this.isSharedWithMeTab()) {
|
||||
this.fetchResources(this.state.sharedWithMe.prevUrl);
|
||||
@@ -90,8 +82,7 @@ export class MyResourcesPage extends React.Component {
|
||||
this.fetchResources(this.state.myResources.prevUrl);
|
||||
}
|
||||
});
|
||||
|
||||
_defineProperty(this, "handleTabClick", (event, tabIndex) => {
|
||||
_defineProperty(this, "handleTabClick", tabIndex => {
|
||||
if (this.state.activeTabKey === tabIndex) return;
|
||||
this.setState({
|
||||
nameFilter: '',
|
||||
@@ -100,7 +91,6 @@ export class MyResourcesPage extends React.Component {
|
||||
this.fetchInitialResources();
|
||||
});
|
||||
});
|
||||
|
||||
this.context = context;
|
||||
this.state = {
|
||||
activeTabKey: MY_RESOURCES_TAB,
|
||||
@@ -119,11 +109,9 @@ export class MyResourcesPage extends React.Component {
|
||||
};
|
||||
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 !== '';
|
||||
@@ -131,7 +119,6 @@ export class MyResourcesPage extends React.Component {
|
||||
return this.state.myResources.nextUrl !== null && this.state.myResources.nextUrl !== '';
|
||||
}
|
||||
}
|
||||
|
||||
hasPrevious() {
|
||||
if (this.isSharedWithMeTab()) {
|
||||
return this.state.sharedWithMe.prevUrl !== null && this.state.sharedWithMe.prevUrl !== '';
|
||||
@@ -139,7 +126,6 @@ export class MyResourcesPage extends React.Component {
|
||||
return this.state.myResources.prevUrl !== null && this.state.myResources.prevUrl !== '';
|
||||
}
|
||||
}
|
||||
|
||||
fetchInitialResources() {
|
||||
if (this.isSharedWithMeTab()) {
|
||||
this.fetchResources("/resources/shared-with-me");
|
||||
@@ -150,27 +136,26 @@ export class MyResourcesPage extends React.Component {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fetchFilteredResources(params) {
|
||||
if (this.isSharedWithMeTab()) {
|
||||
this.fetchResources("/resources/shared-with-me", params);
|
||||
} else {
|
||||
this.fetchResources("/resources", { ...params,
|
||||
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.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)
|
||||
@@ -182,28 +167,23 @@ export class MyResourcesPage extends React.Component {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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,
|
||||
@@ -211,7 +191,6 @@ export class MyResourcesPage extends React.Component {
|
||||
data: resources
|
||||
};
|
||||
}
|
||||
|
||||
makeTab(eventKey, title, resources, sharedResourcesTab) {
|
||||
return /*#__PURE__*/React.createElement(Tab, {
|
||||
id: title,
|
||||
@@ -240,7 +219,6 @@ export class MyResourcesPage extends React.Component {
|
||||
resources: resources
|
||||
}))));
|
||||
}
|
||||
|
||||
render() {
|
||||
return /*#__PURE__*/React.createElement(ContentPage, {
|
||||
title: "resources",
|
||||
@@ -249,7 +227,7 @@ export class MyResourcesPage extends React.Component {
|
||||
variant: PageSectionVariants.light
|
||||
}, /*#__PURE__*/React.createElement(Tabs, {
|
||||
activeKey: this.state.activeTabKey,
|
||||
onSelect: this.handleTabClick
|
||||
onSelect: (event, index) => this.handleTabClick(index)
|
||||
}, 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, {
|
||||
@@ -266,7 +244,6 @@ export class MyResourcesPage extends React.Component {
|
||||
msgKey: "nextPage"
|
||||
}), ">")))));
|
||||
}
|
||||
|
||||
clearNextPrev() {
|
||||
const newMyResources = this.state.myResources;
|
||||
newMyResources.nextUrl = '';
|
||||
@@ -275,10 +252,7 @@ export class MyResourcesPage extends React.Component {
|
||||
myResources: newMyResources
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_defineProperty(MyResourcesPage, "contextType", AccountServiceContext);
|
||||
|
||||
;
|
||||
//# sourceMappingURL=MyResourcesPage.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+8
-19
@@ -1,5 +1,6 @@
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
/*
|
||||
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
|
||||
*
|
||||
@@ -15,42 +16,36 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as React from "../../../../common/keycloak/web_modules/react.js";
|
||||
import { 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 * as React from "../../../keycloak.v2/web_modules/react.js";
|
||||
import { Button, Modal, Text, Badge, DataListItem, DataList, TextVariants, DataListItemRow, DataListItemCells, DataListCell, Chip, Split, SplitItem, ModalVariant } from "../../../keycloak.v2/web_modules/@patternfly/react-core.js";
|
||||
import { UserCheckIcon } from "../../../keycloak.v2/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 permissionsRequest = await this.context.doGet(`/resources/${encodeURIComponent(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`, [{
|
||||
await this.context.doPut(`/resources/${encodeURIComponent(id)}/permissions`, [{
|
||||
username: username,
|
||||
scopes: userScopes
|
||||
}]);
|
||||
@@ -60,19 +55,16 @@ export class PermissionRequest extends React.Component {
|
||||
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, {
|
||||
@@ -139,13 +131,10 @@ export class PermissionRequest extends React.Component {
|
||||
}, "Deny"))))]
|
||||
})))))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_defineProperty(PermissionRequest, "defaultProps", {
|
||||
permissions: [],
|
||||
row: 0
|
||||
});
|
||||
|
||||
_defineProperty(PermissionRequest, "contextType", AccountServiceContext);
|
||||
//# sourceMappingURL=PermissionRequest.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+15
-24
@@ -1,55 +1,49 @@
|
||||
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";
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
import * as React from "../../../keycloak.v2/web_modules/react.js";
|
||||
import { Select, SelectOption, SelectVariant } from "../../../keycloak.v2/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) => {
|
||||
_defineProperty(this, "onSelect", (event, value) => {
|
||||
const {
|
||||
selected
|
||||
} = this.state;
|
||||
const {
|
||||
onSelect
|
||||
} = this.props;
|
||||
|
||||
if (selected.includes(selection)) {
|
||||
if (!(value instanceof ScopeValue)) {
|
||||
return;
|
||||
}
|
||||
if (selected.includes(value)) {
|
||||
this.setState(prevState => ({
|
||||
selected: prevState.selected.filter(item => item !== selection)
|
||||
selected: prevState.selected.filter(item => item !== value)
|
||||
}), () => onSelect(this.state.selected.map(sv => sv.value)));
|
||||
} else {
|
||||
this.setState(prevState => ({
|
||||
selected: [...prevState.selected, selection]
|
||||
selected: [...prevState.selected, value]
|
||||
}), () => onSelect(this.state.selected.map(sv => sv.value)));
|
||||
}
|
||||
});
|
||||
|
||||
_defineProperty(this, "onToggle", isExpanded => {
|
||||
this.setState({
|
||||
isExpanded
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(this, "clearSelection", () => {
|
||||
this.setState({
|
||||
selected: [],
|
||||
@@ -57,13 +51,10 @@ export class PermissionSelect extends React.Component {
|
||||
});
|
||||
this.props.onSelect([]);
|
||||
});
|
||||
|
||||
let values = [];
|
||||
|
||||
if (this.props.selected) {
|
||||
values = this.props.selected.map(s => new ScopeValue(s));
|
||||
}
|
||||
|
||||
this.state = {
|
||||
isExpanded: false,
|
||||
selected: values,
|
||||
@@ -73,7 +64,6 @@ export class PermissionSelect extends React.Component {
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
isExpanded,
|
||||
@@ -86,6 +76,7 @@ export class PermissionSelect extends React.Component {
|
||||
}, /*#__PURE__*/React.createElement(Msg, {
|
||||
msgKey: "selectPermissions"
|
||||
})), /*#__PURE__*/React.createElement(Select, {
|
||||
maxHeight: 300,
|
||||
direction: this.props.direction || 'down',
|
||||
variant: SelectVariant.typeaheadMulti,
|
||||
typeAheadAriaLabel: Msg.localize("selectPermissions"),
|
||||
@@ -95,9 +86,9 @@ export class PermissionSelect extends React.Component {
|
||||
selections: selected,
|
||||
isOpen: isExpanded,
|
||||
"aria-labelledby": titleId,
|
||||
placeholderText: Msg.localize("selectPermissions")
|
||||
placeholderText: Msg.localize("selectPermissions"),
|
||||
menuAppendTo: "parent"
|
||||
}, this.state.scopes));
|
||||
}
|
||||
|
||||
}
|
||||
//# sourceMappingURL=PermissionSelect.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+9
-19
@@ -1,5 +1,6 @@
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
/*
|
||||
* Copyright 2018 Red Hat, Inc. and/or its affiliates.
|
||||
*
|
||||
@@ -15,9 +16,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as React from "../../../../common/keycloak/web_modules/react.js";
|
||||
import { 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 * as React from "../../../keycloak.v2/web_modules/react.js";
|
||||
import { DataList, DataListItem, DataListItemRow, DataListCell, DataListToggle, DataListContent, DataListItemCells, Level, LevelItem, Button, DataListAction, Dropdown, DropdownPosition, DropdownItem, KebabToggle } from "../../../keycloak.v2/web_modules/@patternfly/react-core.js";
|
||||
import { Remove2Icon, RepositoryIcon, ShareAltIcon, EditAltIcon } from "../../../keycloak.v2/web_modules/@patternfly/react-icons.js";
|
||||
import { AccountServiceContext } from "../../account-service/AccountServiceContext.js";
|
||||
import { PermissionRequest } from "./PermissionRequest.js";
|
||||
import { ShareTheResource } from "./ShareTheResource.js";
|
||||
@@ -30,9 +32,7 @@ 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];
|
||||
@@ -41,23 +41,19 @@ export class ResourcesTable extends AbstractResourcesTable {
|
||||
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: [],
|
||||
@@ -66,9 +62,8 @@ export class ResourcesTable extends AbstractResourcesTable {
|
||||
permissions: new Map()
|
||||
};
|
||||
}
|
||||
|
||||
fetchPermissions(resource, row) {
|
||||
this.context.doGet(`/resources/${resource._id}/permissions`).then(response => {
|
||||
this.context.doGet(`/resources/${encodeURIComponent(resource._id)}/permissions`).then(response => {
|
||||
const newPermissions = new Map(this.state.permissions);
|
||||
newPermissions.set(row, response.data || []);
|
||||
this.setState({
|
||||
@@ -76,17 +71,15 @@ export class ResourcesTable extends AbstractResourcesTable {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
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(() => {
|
||||
return this.context.doPut(`/resources/${encodeURIComponent(resource._id)}/permissions`, permissions).then(() => {
|
||||
ContentAlert.success(Msg.localize('unShareSuccess'));
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.props.resources.data.length === 0) {
|
||||
return /*#__PURE__*/React.createElement(EmptyMessageState, {
|
||||
@@ -94,7 +87,6 @@ export class ResourcesTable extends AbstractResourcesTable {
|
||||
messageKey: "notHaveAnyResource"
|
||||
});
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement(DataList, {
|
||||
"aria-label": Msg.localize('resources'),
|
||||
id: "resourcesList"
|
||||
@@ -306,8 +298,6 @@ export class ResourcesTable extends AbstractResourcesTable {
|
||||
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
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+8
-29
@@ -1,5 +1,6 @@
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
/*
|
||||
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
|
||||
*
|
||||
@@ -15,46 +16,39 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import * as React from "../../../../common/keycloak/web_modules/react.js";
|
||||
import { Button, Chip, ChipGroup, Form, FormGroup, Gallery, GalleryItem, Modal, Stack, StackItem, TextInput, ModalVariant } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
|
||||
|
||||
import * as React from "../../../keycloak.v2/web_modules/react.js";
|
||||
import { Button, Chip, ChipGroup, Form, FormGroup, Gallery, GalleryItem, Modal, Stack, StackItem, TextInput, ModalVariant } from "../../../keycloak.v2/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(() => {
|
||||
this.context.doPut(`/resources/${encodeURIComponent(rscId)}/permissions`, permissions).then(() => {
|
||||
ContentAlert.success('shareSuccess');
|
||||
this.props.onClose();
|
||||
});
|
||||
});
|
||||
|
||||
_defineProperty(this, "handleToggleDialog", () => {
|
||||
if (this.state.isOpen) {
|
||||
this.setState({
|
||||
@@ -68,21 +62,18 @@ export class ShareTheResource extends React.Component {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_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`, {
|
||||
const response = await this.context.doGet(`/resources/${encodeURIComponent(this.props.resource._id)}/user`, {
|
||||
params: {
|
||||
value: this.state.usernameInput
|
||||
}
|
||||
});
|
||||
|
||||
if (response.data && response.data.username) {
|
||||
this.setState({
|
||||
usernameInput: '',
|
||||
@@ -93,21 +84,18 @@ export class ShareTheResource extends React.Component {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_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,
|
||||
@@ -117,7 +105,6 @@ export class ShareTheResource extends React.Component {
|
||||
usernameInput: ''
|
||||
};
|
||||
}
|
||||
|
||||
clearState() {
|
||||
this.setState({
|
||||
permissionsSelected: [],
|
||||
@@ -126,23 +113,18 @@ export class ShareTheResource extends React.Component {
|
||||
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,
|
||||
@@ -211,12 +193,9 @@ export class ShareTheResource extends React.Component {
|
||||
isFilled: true
|
||||
}, this.props.sharedWithUsersMsg))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_defineProperty(ShareTheResource, "defaultProps", {
|
||||
permissions: []
|
||||
});
|
||||
|
||||
_defineProperty(ShareTheResource, "contextType", AccountServiceContext);
|
||||
//# sourceMappingURL=ShareTheResource.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+4
-6
@@ -13,9 +13,10 @@
|
||||
* 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 * as React from "../../../keycloak.v2/web_modules/react.js";
|
||||
import { DataList, DataListItem, DataListItemRow, DataListCell, DataListItemCells, ChipGroup, Chip } from "../../../keycloak.v2/web_modules/@patternfly/react-core.js";
|
||||
import { RepositoryIcon } from "../../../keycloak.v2/web_modules/@patternfly/react-icons.js";
|
||||
import { Msg } from "../../widgets/Msg.js";
|
||||
import { AbstractResourcesTable } from "./AbstractResourceTable.js";
|
||||
import EmptyMessageState from "../../widgets/EmptyMessageState.js";
|
||||
@@ -26,7 +27,6 @@ export class SharedResourcesTable extends AbstractResourcesTable {
|
||||
permissions: new Map()
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.props.resources.data.length === 0) {
|
||||
return /*#__PURE__*/React.createElement(EmptyMessageState, {
|
||||
@@ -34,7 +34,6 @@ export class SharedResourcesTable extends AbstractResourcesTable {
|
||||
messageKey: "noResourcesSharedWithYou"
|
||||
});
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement(DataList, {
|
||||
"aria-label": Msg.localize('resources'),
|
||||
id: "sharedResourcesList"
|
||||
@@ -92,6 +91,5 @@ export class SharedResourcesTable extends AbstractResourcesTable {
|
||||
}, scope.displayName || scope.name))))]
|
||||
})))));
|
||||
}
|
||||
|
||||
}
|
||||
//# sourceMappingURL=SharedResourcesTable.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
-2
@@ -3,7 +3,6 @@ export class Scope {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
toString() {
|
||||
if (this.hasOwnProperty('displayName') && this.displayName) {
|
||||
return this.displayName;
|
||||
@@ -11,6 +10,5 @@ export class Scope {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//# sourceMappingURL=resource-model.js.map
|
||||
+1
-1
@@ -1 +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"}
|
||||
{"version":3,"file":"resource-model.js","names":["Scope","constructor","name","displayName","toString","hasOwnProperty"],"sources":["../../../src/app/content/my-resources-page/resource-model.ts"],"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"],"mappings":"AAeA,OAAO,MAAMA,KAAK,CAAC;EACVC,WAAWA,CAAQC,IAAY,EAASC,WAAoB,EAAE;IAAA,KAA3CD,IAAY,GAAZA,IAAY;IAAA,KAASC,WAAoB,GAApBA,WAAoB;EAAG;EAE/DC,QAAQA,CAAA,EAAW;IACtB,IAAI,IAAI,CAACC,cAAc,CAAC,aAAa,CAAC,IAAK,IAAI,CAACF,WAAY,EAAE;MAC1D,OAAO,IAAI,CAACA,WAAW;IAC3B,CAAC,MAAM;MACH,OAAO,IAAI,CAACD,IAAI;IACpB;EACJ;AACF"}
|
||||
Reference in New Issue
Block a user