CurrentTabViews.tsx 4.27 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*******************************************************************************
 * Copyright 2003-2018 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 * contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 *
 * This file is part of CubicWeb.
 *
 * CubicWeb 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 2.1 of the License, or (at your option)
 * any later version.
 *
 * CubicWeb 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 CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/

import React = require("react");
import { application, definition } from "@logilab/libview";
import { ResourceData } from "../data";

export interface CurrentTabViewsProps {
26
  displayBack: boolean;
27
28
29
30
31
32
33
34
35
36
37
38
39
  data: ResourceData;
  registry: definition.ViewRegistry;
  onClickBack: () => void;
}

export class CurrentTabViews extends React.Component<CurrentTabViewsProps, {}> {
  constructor(props: CurrentTabViewsProps) {
    super(props);
  }

  render() {
    return (
      <div className="container-fluid">
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
        {this.props.displayBack ? (
          <div className="row">
            <div className="col-2">
              <a
                className="btn btn-outline-light"
                onClick={this.props.onClickBack}
                title="Back"
              >
                <span style={{ fontSize: "20pt", cursor: "pointer" }}>
                  <img width="24px" src="../icons/back.svg" />
                </span>
              </a>
            </div>
            <div className="col-2" />
            <div className="col-2" />
            <div className="col-6" />
56
          </div>
57
        ) : (
58
59
            <div />
          )}
60
61
62
63
64
65
        <div className="row">
          <div className="col-12">
            <span style={{ fontSize: "17pt" }}>Evaluated views</span>
          </div>
        </div>
        <hr />
66
67
68
        {this.props.data.rendering === null ? (
          <span />
        ) : (
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
            this.props.data.rendering.evaluations.map(
              (evaluation: application.RenderingEvaluation, index: number) => {
                let view = this.props.registry.descriptors[evaluation.viewId];
                if (view === undefined) return null;
                return (
                  <div key={"evaluation-" + index} className="row">
                    <div className="col-12">
                      <span
                        title="Priority for this view"
                        className="badge badge-primary"
                        style={{ marginRight: "5pt" }}
                      >
                        {evaluation.priority}
                      </span>
                      <span>{view.name}</span>
                    </div>
85
                  </div>
86
87
88
89
                );
              }
            )
          )}
90
        <hr />
91
92
        {Object.keys(this.props.registry.descriptors)
          .map((viewId: string, index: number) => {
93
            if (
94
              this.props.data.rendering === null ||
95
96
              this.props.data.rendering.evaluations.find(
                (value: application.RenderingEvaluation) =>
97
                  value.viewId === viewId
98
              )
99
            ) {
100
              return null;
101
            }
102
            let view = this.props.registry.descriptors[viewId];
103
            if (view === undefined) return null;
104
105
106
107
108
109
110
111
112
113
114
115
            return (
              <div key={"view-" + index} className="row">
                <div className="col-12">
                  <span
                    title="Priority for this view"
                    className="badge badge-secondary"
                    style={{ marginRight: "5pt" }}
                  >
                    {"disabled"}
                  </span>
                  <span>{view.name}</span>
                </div>
116
              </div>
117
118
            );
          })
119
          .filter((value: any) => value !== null)}
120
121
122
123
      </div>
    );
  }
}