From ff49b9e38a29b8e0f9eb95e296fa87880f9b9a84 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 18 Jul 2021 16:48:13 +0200 Subject: [PATCH] settings: added release notes --- package.json | 3 +- .../src/components/tabBody.component.ts | 3 -- tabby-electron/package.json | 1 - tabby-electron/yarn.lock | 12 ----- tabby-plugin-manager/package.json | 1 - tabby-plugin-manager/yarn.lock | 12 ----- tabby-settings/package.json | 2 + .../components/releaseNotesTab.component.pug | 12 +++++ .../components/releaseNotesTab.component.scss | 17 +++++++ .../components/releaseNotesTab.component.ts | 47 +++++++++++++++++++ .../src/components/settingsTab.component.pug | 6 +++ .../src/components/settingsTab.component.ts | 9 ++++ tabby-settings/src/index.ts | 5 ++ tabby-settings/yarn.lock | 23 +++++++++ yarn.lock | 12 +++++ 15 files changed, 135 insertions(+), 30 deletions(-) create mode 100644 tabby-settings/src/components/releaseNotesTab.component.pug create mode 100644 tabby-settings/src/components/releaseNotesTab.component.scss create mode 100644 tabby-settings/src/components/releaseNotesTab.component.ts diff --git a/package.json b/package.json index b41cd999..f3c39f4a 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "@typescript-eslint/eslint-plugin": "^4.28.3", "@typescript-eslint/parser": "^4.28.3", "apply-loader": "2.0.0", + "axios": "^0.21.1", "clone-deep": "^4.0.1", "compare-versions": "^3.6.0", "core-js": "^3.15.2", @@ -55,6 +56,7 @@ "pug-static-loader": "2.0.0", "raw-loader": "4.0.2", "sass-loader": "^12.1.0", + "shell-quote": "^1.7.2", "shelljs": "0.8.4", "slugify": "^1.5.3", "sortablejs": "^1.14.0", @@ -67,7 +69,6 @@ "ts-loader": "^9.2.3", "tslib": "^2.3.0", "typedoc": "^0.21.4", - "shell-quote": "^1.7.2", "typescript": "^4.3.5", "url-loader": "^4.1.1", "val-loader": "4.0.0", diff --git a/tabby-core/src/components/tabBody.component.ts b/tabby-core/src/components/tabBody.component.ts index d5cb36f9..d47271e4 100644 --- a/tabby-core/src/components/tabBody.component.ts +++ b/tabby-core/src/components/tabBody.component.ts @@ -6,9 +6,6 @@ import { BaseTabComponent } from '../components/baseTab.component' @Component({ selector: 'tab-body', template: ` - `, styles: [ diff --git a/tabby-electron/package.json b/tabby-electron/package.json index 49f71656..aaf5df76 100644 --- a/tabby-electron/package.json +++ b/tabby-electron/package.json @@ -20,7 +20,6 @@ "@angular/core": "^9.1.9" }, "devDependencies": { - "axios": "^0.21.1", "winston": "^3.3.3", "electron-promise-ipc": "^2.2.4" } diff --git a/tabby-electron/yarn.lock b/tabby-electron/yarn.lock index 8d272afa..f13b92e7 100644 --- a/tabby-electron/yarn.lock +++ b/tabby-electron/yarn.lock @@ -16,13 +16,6 @@ async@^3.1.0: resolved "https://registry.yarnpkg.com/async/-/async-3.2.0.tgz#b3a2685c5ebb641d3de02d161002c60fc9f85720" integrity sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw== -axios@^0.21.1: - version "0.21.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" - integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== - dependencies: - follow-redirects "^1.10.0" - call-bind@^1.0.0, call-bind@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" @@ -150,11 +143,6 @@ fn.name@1.x.x: resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc" integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== -follow-redirects@^1.10.0: - version "1.14.1" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.1.tgz#d9114ded0a1cfdd334e164e6662ad02bfd91ff43" - integrity sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg== - function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" diff --git a/tabby-plugin-manager/package.json b/tabby-plugin-manager/package.json index 89565cda..ca331ffc 100644 --- a/tabby-plugin-manager/package.json +++ b/tabby-plugin-manager/package.json @@ -18,7 +18,6 @@ "license": "MIT", "devDependencies": { "@types/semver": "^7.1.0", - "axios": "^0.21.1", "semver": "^7.1.1" }, "peerDependencies": { diff --git a/tabby-plugin-manager/yarn.lock b/tabby-plugin-manager/yarn.lock index 4edde763..4ed99d7b 100644 --- a/tabby-plugin-manager/yarn.lock +++ b/tabby-plugin-manager/yarn.lock @@ -7,18 +7,6 @@ resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.7.tgz#b9eb89d7dfa70d5d1ce525bc1411a35347f533a3" integrity sha512-4g1jrL98mdOIwSOUh6LTlB0Cs9I0dQPwINUhBg7C6pN4HLr8GS8xsksJxilW6S6dQHVi2K/o+lQuQcg7LroCnw== -axios@^0.21.1: - version "0.21.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" - integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== - dependencies: - follow-redirects "^1.10.0" - -follow-redirects@^1.10.0: - version "1.13.1" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.1.tgz#5f69b813376cee4fd0474a3aba835df04ab763b7" - integrity sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg== - lru-cache@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" diff --git a/tabby-settings/package.json b/tabby-settings/package.json index 954fd124..062933db 100644 --- a/tabby-settings/package.json +++ b/tabby-settings/package.json @@ -18,6 +18,8 @@ "license": "MIT", "devDependencies": { "@types/deep-equal": "1.0.1", + "marked": "^2.1.3", + "ngx-infinite-scroll": "^10.0.1", "utils-decorators": "^1.8.0" }, "peerDependencies": { diff --git a/tabby-settings/src/components/releaseNotesTab.component.pug b/tabby-settings/src/components/releaseNotesTab.component.pug new file mode 100644 index 00000000..ec59b68a --- /dev/null +++ b/tabby-settings/src/components/releaseNotesTab.component.pug @@ -0,0 +1,12 @@ +.container( + infiniteScroll, + [infiniteScrollDistance]='2', + [infiniteScrollThrottle]='50', + infiniteScrollContainer='release-notes-tab', + [fromRoot]='true', + (scrolled)='onScrolled()' +) + div(*ngFor='let release of releases') + h1 {{release.name}} + .text-muted {{release.version}} / {{release.date|date:'mediumDate'}} + section([fastHtmlBind]='release.content') diff --git a/tabby-settings/src/components/releaseNotesTab.component.scss b/tabby-settings/src/components/releaseNotesTab.component.scss new file mode 100644 index 00000000..4b2888ef --- /dev/null +++ b/tabby-settings/src/components/releaseNotesTab.component.scss @@ -0,0 +1,17 @@ +:host { + overflow-y: scroll; + width: 100%; + padding: 30px; +} + +::ng-deep img { + max-width: 100%; +} + +h1 { + margin: 0; +} + +section { + margin: 20px 0; +} diff --git a/tabby-settings/src/components/releaseNotesTab.component.ts b/tabby-settings/src/components/releaseNotesTab.component.ts new file mode 100644 index 00000000..e6f98ca9 --- /dev/null +++ b/tabby-settings/src/components/releaseNotesTab.component.ts @@ -0,0 +1,47 @@ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +import axios from 'axios' +import marked from 'marked' +import { Component } from '@angular/core' +import { BaseTabComponent } from 'tabby-core' + +export interface Release { + name: string + version: string + content: string + date: Date +} + +/** @hidden */ +@Component({ + selector: 'release-notes-tab', + template: require('./releaseNotesTab.component.pug'), + styles: [require('./releaseNotesTab.component.scss')], +}) +export class ReleaseNotesComponent extends BaseTabComponent { + releases: Release[] = [] + lastPage = 1 + + constructor () { + super() + this.setTitle('Release notes') + this.loadReleases(1) + } + + async loadReleases (page) { + console.log('Loading releases page', page) + const response = await axios.get(`https://api.github.com/repos/eugeny/tabby/releases?page=${page}`, { + headers: { Accept: 'application/vnd.github.v3+json' }, + }) + this.releases = this.releases.concat(response.data.map(r => ({ + name: r.name, + version: r.tag_name, + content: marked(r.body), + date: new Date(r.created_at), + }))) + this.lastPage = page + } + + onScrolled () { + this.loadReleases(this.lastPage + 1) + } +} diff --git a/tabby-settings/src/components/settingsTab.component.pug b/tabby-settings/src/components/settingsTab.component.pug index 2a3d92a3..9e9e1154 100644 --- a/tabby-settings/src/components/settingsTab.component.pug +++ b/tabby-settings/src/components/settingsTab.component.pug @@ -23,6 +23,12 @@ button.btn.btn-warning.btn-block(*ngIf='config.restartRequested', '(click)'='res i.fas.fa-bug span Report a problem + button.btn.btn-secondary.mr-3( + (click)='showReleaseNotes()', + ) + i.fas.fa-book + span What's new + button.btn.btn-secondary( *ngIf='!updateAvailable && hostApp.platform !== Platform.Web', (click)='checkForUpdates()', diff --git a/tabby-settings/src/components/settingsTab.component.ts b/tabby-settings/src/components/settingsTab.component.ts index fc9ed019..4b6c6979 100644 --- a/tabby-settings/src/components/settingsTab.component.ts +++ b/tabby-settings/src/components/settingsTab.component.ts @@ -11,9 +11,11 @@ import { UpdaterService, PlatformService, HostWindowService, + AppService, } from 'tabby-core' import { SettingsTabProvider } from '../api' +import { ReleaseNotesComponent } from './releaseNotesTab.component' /** @hidden */ @Component({ @@ -42,6 +44,7 @@ export class SettingsTabComponent extends BaseTabComponent { public platform: PlatformService, public zone: NgZone, private updater: UpdaterService, + private app: AppService, @Inject(SettingsTabProvider) public settingsProviders: SettingsTabProvider[], ) { super() @@ -115,4 +118,10 @@ export class SettingsTabComponent extends BaseTabComponent { this.updateAvailable = await this.updater.check() this.checkingForUpdate = false } + + showReleaseNotes () { + this.app.openNewTabRaw({ + type: ReleaseNotesComponent, + }) + } } diff --git a/tabby-settings/src/index.ts b/tabby-settings/src/index.ts index 2d47a345..c3b0f8bc 100644 --- a/tabby-settings/src/index.ts +++ b/tabby-settings/src/index.ts @@ -2,6 +2,7 @@ import { NgModule } from '@angular/core' import { BrowserModule } from '@angular/platform-browser' import { FormsModule } from '@angular/forms' import { NgbModule } from '@ng-bootstrap/ng-bootstrap' +import { InfiniteScrollModule } from 'ngx-infinite-scroll' import TabbyCorePlugin, { ToolbarButtonProvider, HotkeyProvider, ConfigProvider } from 'tabby-core' @@ -15,6 +16,7 @@ import { WindowSettingsTabComponent } from './components/windowSettingsTab.compo import { VaultSettingsTabComponent } from './components/vaultSettingsTab.component' import { SetVaultPassphraseModalComponent } from './components/setVaultPassphraseModal.component' import { ProfilesSettingsTabComponent } from './components/profilesSettingsTab.component' +import { ReleaseNotesComponent } from './components/releaseNotesTab.component' import { SettingsTabProvider } from './api' import { ButtonProvider } from './buttonProvider' @@ -29,6 +31,7 @@ import { HotkeySettingsTabProvider, WindowSettingsTabProvider, VaultSettingsTabP FormsModule, NgbModule, TabbyCorePlugin, + InfiniteScrollModule, ], providers: [ { provide: ToolbarButtonProvider, useClass: ButtonProvider, multi: true }, @@ -48,6 +51,7 @@ import { HotkeySettingsTabProvider, WindowSettingsTabProvider, VaultSettingsTabP SetVaultPassphraseModalComponent, VaultSettingsTabComponent, WindowSettingsTabComponent, + ReleaseNotesComponent, ], declarations: [ EditProfileModalComponent, @@ -60,6 +64,7 @@ import { HotkeySettingsTabProvider, WindowSettingsTabProvider, VaultSettingsTabP SetVaultPassphraseModalComponent, VaultSettingsTabComponent, WindowSettingsTabComponent, + ReleaseNotesComponent, ], }) export default class SettingsModule { } // eslint-disable-line @typescript-eslint/no-extraneous-class diff --git a/tabby-settings/yarn.lock b/tabby-settings/yarn.lock index 9f07e3ce..79fe7f5b 100644 --- a/tabby-settings/yarn.lock +++ b/tabby-settings/yarn.lock @@ -2,11 +2,34 @@ # yarn lockfile v1 +"@scarf/scarf@^1.1.0": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@scarf/scarf/-/scarf-1.1.1.tgz#d8b9f20037b3a37dbf8dcdc4b3b72f9285bfce35" + integrity sha512-VGbKDbk1RFIaSmdVb0cNjjWJoRWRI/Weo23AjRCC2nryO0iAS8pzsToJfPVPtVs74WHw4L1UTADNdIYRLkirZQ== + "@types/deep-equal@1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@types/deep-equal/-/deep-equal-1.0.1.tgz#71cfabb247c22bcc16d536111f50c0ed12476b03" integrity sha512-mMUu4nWHLBlHtxXY17Fg6+ucS/MnndyOWyOe7MmwkoMYxvfQU2ajtRaEvqSUv+aVkMqH/C0NCI8UoVfRNQ10yg== +marked@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/marked/-/marked-2.1.3.tgz#bd017cef6431724fd4b27e0657f5ceb14bff3753" + integrity sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA== + +ngx-infinite-scroll@^10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/ngx-infinite-scroll/-/ngx-infinite-scroll-10.0.1.tgz#6f51f2f8775a7c50d1dd8bad125d4e748abbe880" + integrity sha512-7is0eJZ9kJPsaHohRmMhJ/QFHAW9jp9twO5HcHRvFM/Yl/R8QCiokgjwmH0/CR3MuxUanxfHZMfO3PbYTwlBEg== + dependencies: + "@scarf/scarf" "^1.1.0" + opencollective-postinstall "^2.0.2" + +opencollective-postinstall@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259" + integrity sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q== + tinyqueue@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/tinyqueue/-/tinyqueue-2.0.3.tgz#64d8492ebf39e7801d7bd34062e29b45b2035f08" diff --git a/yarn.lock b/yarn.lock index 61f047a3..2c3bc5de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1159,6 +1159,13 @@ aws4@^1.2.1, aws4@^1.8.0: resolved "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz" integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== +axios@^0.21.1: + version "0.21.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" + integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== + dependencies: + follow-redirects "^1.10.0" + babel-runtime@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" @@ -3109,6 +3116,11 @@ flush-write-stream@^1.0.0: inherits "^2.0.1" readable-stream "^2.0.4" +follow-redirects@^1.10.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.1.tgz#d9114ded0a1cfdd334e164e6662ad02bfd91ff43" + integrity sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg== + forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"