SharedResourcesTable.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright 2018 Red Hat, Inc. and/or its affiliates.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import * as React from "../../../../common/keycloak/web_modules/react.js";
  17. import { DataList, DataListItem, DataListItemRow, DataListCell, DataListItemCells, ChipGroup, ChipGroupToolbarItem, Chip } from "../../../../common/keycloak/web_modules/@patternfly/react-core.js";
  18. import { RepositoryIcon } from "../../../../common/keycloak/web_modules/@patternfly/react-icons.js";
  19. import { Msg } from "../../widgets/Msg.js";
  20. import { AbstractResourcesTable } from "./AbstractResourceTable.js";
  21. import EmptyMessageState from "../../widgets/EmptyMessageState.js";
  22. export class SharedResourcesTable extends AbstractResourcesTable {
  23. constructor(props) {
  24. super(props);
  25. this.state = {
  26. permissions: new Map()
  27. };
  28. }
  29. render() {
  30. if (this.props.resources.data.length === 0) {
  31. return React.createElement(EmptyMessageState, {
  32. icon: RepositoryIcon,
  33. messageKey: "noResourcesSharedWithYou"
  34. });
  35. }
  36. return React.createElement(DataList, {
  37. "aria-label": Msg.localize('resources'),
  38. id: "sharedResourcesList"
  39. }, React.createElement(DataListItem, {
  40. key: "resource-header",
  41. "aria-labelledby": "resource-header"
  42. }, React.createElement(DataListItemRow, null, React.createElement(DataListItemCells, {
  43. dataListCells: [React.createElement(DataListCell, {
  44. key: "resource-name-header",
  45. width: 2
  46. }, React.createElement("strong", null, React.createElement(Msg, {
  47. msgKey: "resourceName"
  48. }))), React.createElement(DataListCell, {
  49. key: "application-name-header",
  50. width: 2
  51. }, React.createElement("strong", null, React.createElement(Msg, {
  52. msgKey: "application"
  53. }))), React.createElement(DataListCell, {
  54. key: "permission-header",
  55. width: 2
  56. }), React.createElement(DataListCell, {
  57. key: "requests-header",
  58. width: 2
  59. })]
  60. }))), this.props.resources.data.map((resource, row) => React.createElement(DataListItem, {
  61. key: 'resource-' + row,
  62. "aria-labelledby": resource.name
  63. }, React.createElement(DataListItemRow, null, React.createElement(DataListItemCells, {
  64. dataListCells: [React.createElement(DataListCell, {
  65. key: 'resourceName-' + row,
  66. width: 2
  67. }, React.createElement(Msg, {
  68. msgKey: resource.name
  69. })), React.createElement(DataListCell, {
  70. key: 'resourceClient-' + row,
  71. width: 2
  72. }, React.createElement("a", {
  73. href: resource.client.baseUrl
  74. }, this.getClientName(resource.client))), React.createElement(DataListCell, {
  75. key: 'permissions-' + row,
  76. width: 2
  77. }, resource.scopes.length > 0 && React.createElement(ChipGroup, {
  78. withToolbar: true
  79. }, React.createElement(ChipGroupToolbarItem, {
  80. key: "permissions",
  81. categoryName: Msg.localize('permissions')
  82. }, resource.scopes.map(scope => React.createElement(Chip, {
  83. key: scope.name,
  84. isReadOnly: true
  85. }, scope.displayName || scope.name))))), React.createElement(DataListCell, {
  86. key: 'pending-' + row,
  87. width: 2
  88. }, resource.shareRequests.length > 0 && React.createElement(ChipGroup, {
  89. withToolbar: true
  90. }, React.createElement(ChipGroupToolbarItem, {
  91. key: "permissions",
  92. categoryName: Msg.localize('pending')
  93. }, resource.shareRequests[0].scopes.map(scope => React.createElement(Chip, {
  94. key: scope.name,
  95. isReadOnly: true
  96. }, scope.displayName || scope.name)))))]
  97. })))));
  98. }
  99. }
  100. //# sourceMappingURL=SharedResourcesTable.js.map