Skip to content

Commit 26a857c

Browse files
Merge pull request #1982 from oliver-sanders/add-jupyterlab-button
jupyter lab dashboard link
2 parents 8c61973 + 827b95a commit 26a857c

File tree

8 files changed

+91
-1
lines changed

8 files changed

+91
-1
lines changed

changes.d/1982.feat.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add link to Jupyter Lab from the Dashboard (if Jupyter Lab is installed).

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"mitt": "3.0.1",
4343
"nprogress": "1.0.0-1",
4444
"preact": "10.24.3",
45+
"simple-icons": "2.17.1",
4546
"subscriptions-transport-ws": "0.11.0",
4647
"svg-pan-zoom": "3.6.2",
4748
"vue": "3.4.11",

src/model/User.model.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
export default class User {
19-
constructor ({ username, owner, permissions, mode, initials, color }) {
19+
constructor ({ username, owner, permissions, mode, initials, color, extensions }) {
2020
/**
2121
* @type {string}
2222
*/
@@ -47,5 +47,9 @@ export default class User {
4747
* @type {string | null}
4848
*/
4949
this.color = color
50+
/**
51+
* Jupyter server extensions.
52+
*/
53+
this.extensions = extensions
5054
}
5155
}

src/utils/icons.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (C) NIWA & British Crown (Met Office) & Contributors.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
/**
19+
* SVG icons for use in the Cylc UI:
20+
* - Centralise icons for use throughout multiple components.
21+
* - Define custom icons.
22+
* - Reformat icons for other source.
23+
*
24+
* Note, the `<v-icon>` component expects icons in the MDI format i.e.:
25+
* - A string representing an SVG path.
26+
* - Consisting of a bezier curve (e.g. `M 0,0 C 1,1 Z`).
27+
* - That fits within a 24px box.
28+
*/
29+
30+
import { Jupyter } from 'simple-icons'
31+
32+
export const jupyterLogo = Jupyter.svg.replace(/.*d="(.*)".*/, '$1')

src/views/Dashboard.vue

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,27 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
9595
You are not running Cylc UI via Cylc Hub.
9696
</v-tooltip>
9797
</div>
98+
<div>
99+
<v-list-item
100+
id="jupyter-lab-button"
101+
:disabled="!user.extensions?.lab"
102+
:href="user.extensions?.lab"
103+
target="_blank"
104+
>
105+
<template v-slot:prepend>
106+
<v-icon size="1.6em">{{ $options.icons.jupyterLogo }}</v-icon>
107+
</template>
108+
<v-list-item-title class="text-h6 font-weight-light">
109+
Jupyter Lab
110+
</v-list-item-title>
111+
<v-list-item-subtitle>
112+
Open Jupyter Lab in a new browser tab.
113+
</v-list-item-subtitle>
114+
</v-list-item>
115+
<v-tooltip :disabled="user.extensions?.lab">
116+
Jupyter Lab is not installed.
117+
</v-tooltip>
118+
</div>
98119
</v-list>
99120
</v-col>
100121
<v-col md="6" lg="6">
@@ -141,6 +162,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
141162
<script>
142163
import { mapState, mapGetters } from 'vuex'
143164
import { mdiBook, mdiBookMultiple, mdiBookOpenVariant, mdiCog, mdiHubspot, mdiTable } from '@mdi/js'
165+
import { jupyterLogo } from '@/utils/icons'
144166
import subscriptionComponentMixin from '@/mixins/subscriptionComponent'
145167
import { createUrl } from '@/utils/urls'
146168
import { WorkflowState, WorkflowStateOrder } from '@/model/WorkflowState.model'
@@ -250,6 +272,7 @@ export default {
250272
quickstart: mdiBook,
251273
workflow: mdiBookOpenVariant,
252274
documentation: mdiBookMultiple,
275+
jupyterLogo,
253276
},
254277
}
255278
</script>

src/views/UserProfile.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
4848
</v-col>
4949
</v-row>
5050

51+
<v-row no-gutters class="align-center wrap">
52+
<v-col cols="3">
53+
<span>Jupyter Server Extensions</span>
54+
</v-col>
55+
<v-col cols="9">
56+
<v-text-field
57+
:model-value="Object.keys(user.extensions).join(', ') || 'None'"
58+
disabled
59+
id="profile-extensions"
60+
aria-disabled="true"
61+
class="text-body-1"
62+
/>
63+
</v-col>
64+
</v-row>
65+
5166
<v-row no-gutters class="align-center wrap">
5267
<v-col cols="3">
5368
<span>{{ $t('UserProfile.permissions') }}</span>

tests/e2e/specs/dashboard.cy.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ describe('Dashboard', () => {
5454
.should('have.class', 'v-list-item--disabled')
5555
})
5656

57+
it('Disables Jupyter Lab button when not installed', () => {
58+
cy
59+
.get('#jupyter-lab-button')
60+
.should('have.class', 'v-list-item--disabled')
61+
})
62+
5763
for (const ref of ['workflow-table-link', 'user-settings-link', 'quickstart-link']) {
5864
it(`Visits ${ref}`, () => {
5965
cy.get(`[data-cy=${ref}`)

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3634,6 +3634,7 @@ __metadata:
36343634
nyc: "npm:17.1.0"
36353635
preact: "npm:10.24.3"
36363636
sass: "npm:1.77.8"
3637+
simple-icons: "npm:2.17.1"
36373638
sinon: "npm:19.0.2"
36383639
standard: "npm:17.1.2"
36393640
subscriptions-transport-ws: "npm:0.11.0"
@@ -9001,6 +9002,13 @@ __metadata:
90019002
languageName: node
90029003
linkType: hard
90039004

9005+
"simple-icons@npm:2.17.1":
9006+
version: 2.17.1
9007+
resolution: "simple-icons@npm:2.17.1"
9008+
checksum: 10c0/134bcac6e5c9f737dafe2d24a323f78259dd5a8bb31ea0034469ccac837242ec75982a1fd63e23e33f516e0fedb65cb254209e414142ac4d6ccb75d5fba041ee
9009+
languageName: node
9010+
linkType: hard
9011+
90049012
"simple-update-notifier@npm:^2.0.0":
90059013
version: 2.0.0
90069014
resolution: "simple-update-notifier@npm:2.0.0"

0 commit comments

Comments
 (0)