| 
 | 1 | +/*!  | 
 | 2 | +   Copyright 2018 Propel http://propel.site/.  All rights reserved.  | 
 | 3 | +   Licensed under the Apache License, Version 2.0 (the "License");  | 
 | 4 | +   you may not use this file except in compliance with the License.  | 
 | 5 | +   You may obtain a copy of the License at  | 
 | 6 | +
  | 
 | 7 | +   http://www.apache.org/licenses/LICENSE-2.0  | 
 | 8 | +
  | 
 | 9 | +   Unless required by applicable law or agreed to in writing, software  | 
 | 10 | +   distributed under the License is distributed on an "AS IS" BASIS,  | 
 | 11 | +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  | 
 | 12 | +   See the License for the specific language governing permissions and  | 
 | 13 | +   limitations under the License.  | 
 | 14 | + */  | 
 | 15 | + | 
 | 16 | +import { Component, h } from "preact";  | 
 | 17 | +import * as types from "../types";  | 
 | 18 | +import { NotebookList } from "./list";  | 
 | 19 | +import { newNotebookButton } from "./new_notebook_button";  | 
 | 20 | +import { profileLink } from "./user_title";  | 
 | 21 | + | 
 | 22 | +export interface RecentProps {  | 
 | 23 | +  mostRecent: types.NbInfo[];  | 
 | 24 | +  userInfo?: types.UserInfo;  | 
 | 25 | +  // TODO  | 
 | 26 | +  // onNewNotebookClicked?: () => void;  | 
 | 27 | +  onClick?: (nbId: string) => void;  | 
 | 28 | +}  | 
 | 29 | + | 
 | 30 | +export interface RecentState {}  | 
 | 31 | + | 
 | 32 | +export class Recent extends Component<RecentProps, RecentState> {  | 
 | 33 | +  onClick(nbId: string) {  | 
 | 34 | +    if (this.props.onClick) this.props.onClick(nbId);  | 
 | 35 | +  }  | 
 | 36 | + | 
 | 37 | +  render() {  | 
 | 38 | +    let profileLinkEl = null;  | 
 | 39 | +    if (this.props.userInfo) {  | 
 | 40 | +      // TODO This is ugly - we're reusing most-recent-header just to get a line  | 
 | 41 | +      // break between the link to "Your Notebooks" and "Most Recent".  | 
 | 42 | +      profileLinkEl = (  | 
 | 43 | +        <div class="most-recent-header">  | 
 | 44 | +          <h2>{profileLink(this.props.userInfo, "Your Notebooks")}</h2>  | 
 | 45 | +        </div>  | 
 | 46 | +      );  | 
 | 47 | +    }  | 
 | 48 | + | 
 | 49 | +    return (  | 
 | 50 | +      <div class="nb-listing">  | 
 | 51 | +        {profileLinkEl}  | 
 | 52 | +        <div class="nb-listing-header">  | 
 | 53 | +          <div class="nb-listing-header-title">  | 
 | 54 | +            <h2>Recently Updated</h2>  | 
 | 55 | +          </div>  | 
 | 56 | +          <div class="nb-listing-header-cta">{newNotebookButton()}</div>  | 
 | 57 | +        </div>  | 
 | 58 | +        <NotebookList  | 
 | 59 | +          showTitle={ true }  | 
 | 60 | +          notebooks={ this.props.mostRecent }  | 
 | 61 | +          onClick={ this.onClick.bind(this) }  | 
 | 62 | +        />  | 
 | 63 | +      </div>  | 
 | 64 | +    );  | 
 | 65 | + }  | 
 | 66 | +}  | 
0 commit comments