AbstractResourceTable.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import * as React from "../../../../common/keycloak/web_modules/react.js";
  2. import { Msg } from "../../widgets/Msg.js";
  3. export class AbstractResourcesTable extends React.Component {
  4. hasPermissions(row) {
  5. return this.state.permissions.has(row) && this.state.permissions.get(row).length > 0;
  6. }
  7. firstUser(row) {
  8. if (!this.hasPermissions(row)) return 'ERROR!!!!'; // should never happen
  9. return this.state.permissions.get(row)[0].username;
  10. }
  11. numOthers(row) {
  12. if (!this.hasPermissions(row)) return -1; // should never happen
  13. return this.state.permissions.get(row).length - 1;
  14. }
  15. sharedWithUsersMessage(row) {
  16. if (!this.hasPermissions(row)) return React.createElement(React.Fragment, null, React.createElement(Msg, {
  17. msgKey: "resourceNotShared"
  18. }));
  19. return React.createElement(React.Fragment, null, React.createElement(Msg, {
  20. msgKey: "resourceSharedWith"
  21. }, React.createElement("strong", null, this.firstUser(row))), this.numOthers(row) > 0 && React.createElement(Msg, {
  22. msgKey: "and"
  23. }, React.createElement("strong", null, this.numOthers(row))), ".");
  24. }
  25. getClientName(client) {
  26. if (client.hasOwnProperty('name') && client.name !== null && client.name !== '') {
  27. return Msg.localize(client.name);
  28. } else {
  29. return client.clientId;
  30. }
  31. }
  32. }
  33. //# sourceMappingURL=AbstractResourceTable.js.map