import NameCell from './NameCell';
import PermissionCell from './PermissionCell';
import ActionsCell from './ActionsCell';
-import UsersView from '../views/UsersView';
-import GroupsView from '../views/GroupsView';
import { PermissionTemplateType, CallbackType } from '../propTypes';
export default class ListItem extends React.PureComponent {
refresh: CallbackType
};
- componentWillMount() {
- this.handleShowGroups = this.handleShowGroups.bind(this);
- this.handleShowUsers = this.handleShowUsers.bind(this);
- }
-
- handleShowGroups(permission) {
- new GroupsView({
- permission,
- permissionTemplate: this.props.permissionTemplate,
- refresh: this.props.refresh
- }).render();
- }
-
- handleShowUsers(permission) {
- new UsersView({
- permission,
- permissionTemplate: this.props.permissionTemplate,
- refresh: this.props.refresh
- }).render();
- }
-
render() {
const permissions = this.props.permissionTemplate.permissions.map(p => (
<PermissionCell key={p.key} permission={p} />
+++ /dev/null
-<div class="modal-head">
- <h2>Update "{{permissionName}}" Groups for "{{permissionTemplateName}}"</h2>
-</div>
-<div class="modal-body">
- <div class="js-modal-messages"></div>
- <div id="permission-templates-groups"></div>
-</div>
-<div class="modal-foot">
- <a href="#" class="js-modal-close">Done</a>
-</div>
+++ /dev/null
-<div class="modal-head">
- <h2>Update "{{permission.name}}" Users for "{{permissionTemplateName}}"</h2>
-</div>
-
-<div class="modal-body">
- <div class="js-modal-messages"></div>
-
- <div class="big-spacer-bottom panel panel-vertical">
- <input id="grant-to-project-creators"
- class="little-spacer-right"
- type="checkbox"
- {{#if permission.withProjectCreator}}checked{{/if}}/>
- <label for="grant-to-project-creators">
- {{tp 'permission_templates.grant_permission_to_project_creators' permission.name}}
- </label>
- <i class="icon-help little-spacer-left" title="{{t 'permission_templates.project_creators.explanation'}}" data-toggle="tooltip"/>
- </div>
-
- <div id="permission-templates-users"></div>
-</div>
-
-<div class="modal-foot">
- <a href="#" class="js-modal-close">Done</a>
-</div>
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import escapeHtml from 'escape-html';
-import Modal from '../../../components/common/modals';
-import Template from '../templates/permission-templates-groups.hbs';
-import '../../../components/SelectList';
-
-function getSearchUrl(permission, permissionTemplate) {
- return (
- `${window.baseUrl}/api/permissions/template_groups?` +
- `ps=100&permission=${permission.key}&templateId=${permissionTemplate.id}`
- );
-}
-
-export default Modal.extend({
- template: Template,
-
- onRender() {
- Modal.prototype.onRender.apply(this, arguments);
- new window.SelectList({
- el: this.$('#permission-templates-groups'),
- width: '100%',
- readOnly: false,
- focusSearch: false,
- dangerouslyUnescapedHtmlFormat(item) {
- return escapeHtml(item.name);
- },
- queryParam: 'q',
- searchUrl: getSearchUrl(this.options.permission, this.options.permissionTemplate),
- selectUrl: window.baseUrl + '/api/permissions/add_group_to_template',
- deselectUrl: window.baseUrl + '/api/permissions/remove_group_from_template',
- extra: {
- permission: this.options.permission.key,
- templateId: this.options.permissionTemplate.id
- },
- selectParameter: 'groupName',
- selectParameterValue: 'name',
- parse(r) {
- this.more = false;
- return r.groups;
- }
- });
- },
-
- onDestroy() {
- if (this.options.refresh) {
- this.options.refresh();
- }
- Modal.prototype.onDestroy.apply(this, arguments);
- },
-
- serializeData() {
- return {
- ...Modal.prototype.serializeData.apply(this, arguments),
- permissionName: this.options.permission.name,
- permissionTemplateName: this.options.permissionTemplate.name
- };
- }
-});
+++ /dev/null
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-import escapeHtml from 'escape-html';
-import Modal from '../../../components/common/modals';
-import Template from '../templates/permission-templates-users.hbs';
-import '../../../components/SelectList';
-import {
- addProjectCreatorToTemplate,
- removeProjectCreatorFromTemplate
-} from '../../../api/permissions';
-
-export default Modal.extend({
- template: Template,
-
- events() {
- return {
- ...Modal.prototype.events.apply(this, arguments),
- 'change #grant-to-project-creators': 'onCheckboxChange'
- };
- },
-
- onCheckboxChange() {
- const checked = this.$('#grant-to-project-creators').is(':checked');
- if (checked) {
- addProjectCreatorToTemplate(
- this.options.permissionTemplate.name,
- this.options.permission.key
- );
- } else {
- removeProjectCreatorFromTemplate(
- this.options.permissionTemplate.name,
- this.options.permission.key
- );
- }
- },
-
- onRender() {
- Modal.prototype.onRender.apply(this, arguments);
- this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
- const searchUrl =
- window.baseUrl +
- '/api/permissions/template_users?ps=100&permission=' +
- this.options.permission.key +
- '&templateId=' +
- this.options.permissionTemplate.id;
- new window.SelectList({
- searchUrl,
- el: this.$('#permission-templates-users'),
- width: '100%',
- readOnly: false,
- focusSearch: false,
- dangerouslyUnescapedHtmlFormat(item) {
- return `${escapeHtml(item.name)}<br><span class="note">${escapeHtml(item.login)}</span>`;
- },
- queryParam: 'q',
- selectUrl: window.baseUrl + '/api/permissions/add_user_to_template',
- deselectUrl: window.baseUrl + '/api/permissions/remove_user_from_template',
- extra: {
- permission: this.options.permission.key,
- templateId: this.options.permissionTemplate.id
- },
- selectParameter: 'login',
- selectParameterValue: 'login',
- parse(r) {
- this.more = false;
- return r.users;
- }
- });
- },
-
- onDestroy() {
- if (this.options.refresh) {
- this.options.refresh();
- }
- this.$('[data-toggle="tooltip"]').tooltip('destroy');
- Modal.prototype.onDestroy.apply(this, arguments);
- },
-
- serializeData() {
- return {
- ...Modal.prototype.serializeData.apply(this, arguments),
- permission: this.options.permission,
- permissionTemplateName: this.options.permissionTemplate.name
- };
- }
-});