@mongoosejs/studio 0.0.49 → 0.0.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const api = require('../api');
4
+ const mothership = require('../mothership');
4
5
  const template = require('./navbar.html');
5
6
 
6
7
  const appendCSS = require('../appendCSS');
@@ -9,17 +10,53 @@ appendCSS(require('./navbar.css'));
9
10
 
10
11
  module.exports = app => app.component('navbar', {
11
12
  template: template,
12
- data: () => ({ nodeEnv: null }),
13
+ props: ['user'],
14
+ data: () => ({ nodeEnv: null, showFlyout: false }),
13
15
  computed: {
14
16
  routeName() {
15
17
  return this.$route.name;
16
18
  },
17
19
  warnEnv() {
18
20
  return this.nodeEnv === 'prod' || this.nodeEnv === 'production';
21
+ },
22
+ hasAPIKey() {
23
+ return mothership.hasAPIKey;
19
24
  }
20
25
  },
21
26
  async mounted() {
22
27
  const { nodeEnv } = await api.status();
23
28
  this.nodeEnv = nodeEnv;
29
+ },
30
+ methods: {
31
+ async loginWithGithub() {
32
+ const { url } = await mothership.githubLogin();
33
+ window.location.href = url;
34
+ },
35
+ hideFlyout() {
36
+ this.showFlyout = false;
37
+ },
38
+ logout() {
39
+ window.localStorage.setItem('_mongooseStudioAccessToken', '');
40
+ window.location.reload();
41
+ },
42
+ },
43
+ directives: {
44
+ clickOutside: {
45
+ beforeMount(el, binding, vnode) {
46
+ el.clickOutsideEvent = (event) => {
47
+ let isOutside = true;
48
+ if (event.target === el || el.contains(event.target)) {
49
+ isOutside = false;
50
+ }
51
+ if (isOutside) {
52
+ binding.value.call();
53
+ }
54
+ };
55
+ document.body.addEventListener('click', el.clickOutsideEvent);
56
+ },
57
+ unmounted(el) {
58
+ document.body.removeEventListener('click', el.clickOutsideEvent);
59
+ }
60
+ }
24
61
  }
25
62
  });
@@ -0,0 +1,35 @@
1
+ <div class="w-full h-full flex items-center justify-center">
2
+ <div class="text-center">
3
+ <div class="rounded-full bg-gray-100 p-6 inline-block">
4
+ <img src="images/logo.svg" class="w-48 h-48">
5
+ </div>
6
+ <div class="text-lg mt-2 font-bold">
7
+ Mongoose Studio
8
+ </div>
9
+ <div class="mt-2 text-gray-700">
10
+ {{workspaceName}}
11
+ </div>
12
+ <div class="mt-4">
13
+ <async-button
14
+ type="button"
15
+ @click="loginWithGithub"
16
+ class="rounded bg-ultramarine-600 px-2 py-2 text-sm font-semibold text-white shadow-sm hover:bg-ultramarine-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ultramarine-600">
17
+ Login With GitHub
18
+ </async-button>
19
+ </div>
20
+ <div class="mt-4" v-if="error">
21
+ <div class="rounded-md bg-red-50 p-4">
22
+ <div class="flex">
23
+ <div class="shrink-0">
24
+ <svg class="size-5 text-red-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
25
+ <path fill-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16ZM8.28 7.22a.75.75 0 0 0-1.06 1.06L8.94 10l-1.72 1.72a.75.75 0 1 0 1.06 1.06L10 11.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L11.06 10l1.72-1.72a.75.75 0 0 0-1.06-1.06L10 8.94 8.28 7.22Z" clip-rule="evenodd" />
26
+ </svg>
27
+ </div>
28
+ <div class="ml-3">
29
+ <h3 class="text-sm font-medium text-red-800">{{error}}</h3>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ </div>
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ const mothership = require('../mothership');
4
+ const template = require('./splash.html');
5
+
6
+ module.exports = app => app.component('splash', {
7
+ template,
8
+ inject: ['state'],
9
+ data: () => ({ error: null }),
10
+ computed: {
11
+ workspaceName() {
12
+ return config__workspace.name;
13
+ }
14
+ },
15
+ async mounted() {
16
+ const href = window.location.href;
17
+ if (href.match(/\?code=([a-zA-Z0-9]+)$/)) {
18
+ const code = href.match(/\?code=([a-zA-Z0-9]+)$/)[1];
19
+ const { accessToken, user, roles } = await mothership.github(code);
20
+ if (roles == null) {
21
+ this.error = 'You are not authorized to access this workspace';
22
+ return;
23
+ }
24
+ this.state.user = user;
25
+ window.localStorage.setItem('_mongooseStudioAccessToken', accessToken._id);
26
+ }
27
+ },
28
+ methods: {
29
+ async loginWithGithub() {
30
+ const { url } = await mothership.githubLogin();
31
+ window.location.href = url;
32
+ }
33
+ }
34
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongoosejs/studio",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "dependencies": {
5
5
  "archetype": "0.13.1",
6
6
  "csv-stringify": "6.3.0",
@@ -36,20 +36,46 @@ module.exports = {
36
36
  '900': '#0a5757',
37
37
  '950': '#003235',
38
38
  },
39
- 'navy-blue': {
40
- '50': '#f1f4ff',
41
- '100': '#e5e8ff',
42
- '200': '#ced5ff',
43
- '300': '#a7b1ff',
44
- '400': '#767fff',
45
- '500': '#3f42ff',
46
- '600': '#2118ff',
47
- '700': '#1007fa',
48
- '800': '#0d05d2',
49
- '900': '#0c06ac',
50
- '950': '#000088',
39
+ 'ultramarine': {
40
+ '50': '#f1f5ff',
41
+ '100': '#e5eaff',
42
+ '200': '#cedaff',
43
+ '300': '#a7b9ff',
44
+ '400': '#768cff',
45
+ '500': '#3f53ff',
46
+ '600': '#1823ff',
47
+ '700': '#0713fa',
48
+ '800': '#0510d2',
49
+ '900': '#060eac',
50
+ '950': '#000c87',
51
51
  },
52
- }
52
+ 'forest-green': {
53
+ '50': '#ecfff1',
54
+ '100': '#d3ffe0',
55
+ '200': '#aaffc3',
56
+ '300': '#69ff95',
57
+ '400': '#21ff5f',
58
+ '500': '#00f23a',
59
+ '600': '#00ca2c',
60
+ '700': '#009e25',
61
+ '800': '#008726',
62
+ '900': '#02651f',
63
+ '950': '#00390e',
64
+ },
65
+ 'valencia': {
66
+ '50': '#fdf3f3',
67
+ '100': '#fbe5e5',
68
+ '200': '#f9cfcf',
69
+ '300': '#f3aeae',
70
+ '400': '#eb7e7e',
71
+ '500': '#dc4949',
72
+ '600': '#ca3838',
73
+ '700': '#aa2b2b',
74
+ '800': '#8d2727',
75
+ '900': '#752727',
76
+ '950': '#3f1010',
77
+ }
78
+ }
53
79
  }
54
80
  }
55
- };
81
+ };