@nymphjs/tilmeld-setup 1.0.0-beta.2 → 1.0.0-beta.20

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,95 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-beta.20](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.19...v1.0.0-beta.20) (2023-04-30)
7
+
8
+ ### Features
9
+
10
+ - let the user revoke all current auth tokens ([63af3b9](https://github.com/sciactive/nymphjs/commit/63af3b9a31c6c221ab40c2c8a69231675f4634a2))
11
+
12
+ # [1.0.0-beta.19](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.18...v1.0.0-beta.19) (2023-04-29)
13
+
14
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
15
+
16
+ # [1.0.0-beta.18](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.17...v1.0.0-beta.18) (2023-04-27)
17
+
18
+ ### Bug Fixes
19
+
20
+ - small type issues ([b91579c](https://github.com/sciactive/nymphjs/commit/b91579c9c1e96500d903332648f5a93c9a7e7d9b))
21
+
22
+ ### Features
23
+
24
+ - add enforceTilmeld function ([130faf1](https://github.com/sciactive/nymphjs/commit/130faf151dcdfbfacd6814833868907dca037d24))
25
+ - add the ability to switch to a user without their password ([ca4466a](https://github.com/sciactive/nymphjs/commit/ca4466af1704d68905ac087350a8cf151c1072d9))
26
+
27
+ # [1.0.0-beta.17](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.16...v1.0.0-beta.17) (2023-04-24)
28
+
29
+ ### Features
30
+
31
+ - add spa router to user admin app ([25bb344](https://github.com/sciactive/nymphjs/commit/25bb344f4d358eeb2254df98782f1cba229b5f50))
32
+
33
+ # [1.0.0-beta.16](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.15...v1.0.0-beta.16) (2023-03-31)
34
+
35
+ ### Features
36
+
37
+ - add ability to tell tilmeld to log in a specific user during authentication ([922e145](https://github.com/sciactive/nymphjs/commit/922e1452adae44bed2aa9655be16e19796acb39b))
38
+
39
+ # [1.0.0-beta.15](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.14...v1.0.0-beta.15) (2023-03-23)
40
+
41
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
42
+
43
+ # [1.0.0-beta.14](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.13...v1.0.0-beta.14) (2023-03-17)
44
+
45
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
46
+
47
+ # [1.0.0-beta.13](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2023-03-16)
48
+
49
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
50
+
51
+ # [1.0.0-beta.12](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2023-03-04)
52
+
53
+ ### Bug Fixes
54
+
55
+ - make sure all default exports are also named exports ([06da9a6](https://github.com/sciactive/nymphjs/commit/06da9a61d444860f70b7f5b95b824547d9880500))
56
+
57
+ # [1.0.0-beta.11](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2023-02-27)
58
+
59
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
60
+
61
+ # [1.0.0-beta.10](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2023-01-19)
62
+
63
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
64
+
65
+ # [1.0.0-beta.9](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2023-01-09)
66
+
67
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
68
+
69
+ # [1.0.0-beta.8](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2023-01-09)
70
+
71
+ ### Features
72
+
73
+ - make entities in nymph client instance specific too ([1029f06](https://github.com/sciactive/nymphjs/commit/1029f061a1ad193e4a8a2dab0186b9a4b517f646))
74
+
75
+ # [1.0.0-beta.7](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2023-01-05)
76
+
77
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
78
+
79
+ # [1.0.0-beta.6](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2023-01-05)
80
+
81
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
82
+
83
+ # [1.0.0-beta.5](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.4...v1.0.0-beta.5) (2022-11-24)
84
+
85
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
86
+
87
+ # [1.0.0-beta.4](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.3...v1.0.0-beta.4) (2022-11-23)
88
+
89
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
90
+
91
+ # [1.0.0-beta.3](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.2...v1.0.0-beta.3) (2022-11-21)
92
+
93
+ **Note:** Version bump only for package @nymphjs/tilmeld-setup
94
+
6
95
  # [1.0.0-beta.2](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2022-11-21)
7
96
 
8
97
  **Note:** Version bump only for package @nymphjs/tilmeld-setup
package/README.md CHANGED
@@ -53,7 +53,8 @@ const app = express();
53
53
 
54
54
  // Use the REST server.
55
55
  app.use('/rest', createServer(nymph));
56
- // Use the Tilmeld Setup App, passing in the Nymph Client Config.
56
+
57
+ // Create Tilmeld setup app.
57
58
  app.use(
58
59
  '/user',
59
60
  setup(
@@ -33,16 +33,6 @@
33
33
  <path fill="currentColor" d={mdiMastodon} />
34
34
  </Icon>
35
35
  </IconButton>
36
- <IconButton
37
- href="https://twitter.com/SciActive"
38
- target="_blank"
39
- rel="noreferrer"
40
- title="SciActive on Twitter"
41
- >
42
- <Icon component={Svg} viewBox="0 0 24 24">
43
- <path fill="currentColor" d={mdiTwitter} />
44
- </Icon>
45
- </IconButton>
46
36
  <div>
47
37
  <IconButton
48
38
  title="Account"
@@ -74,7 +64,7 @@
74
64
  : 'hide-initial-small'}"
75
65
  >
76
66
  <Content>
77
- <List>
67
+ <List tag="div">
78
68
  {#if tilmeldAdmin}
79
69
  {#each sections as section (section.name)}
80
70
  {#if 'separator' in section}
@@ -82,13 +72,12 @@
82
72
  {:else}
83
73
  <Item
84
74
  bind:this={section.component}
85
- nonInteractive={!('route' in section)}
86
- on:click={() => {
87
- if ('route' in section) {
88
- active = section.route ?? Intro;
89
- }
90
- }}
91
- activated={active === section.route}
75
+ tag="a"
76
+ nonInteractive={!('href' in section)}
77
+ href={'href' in section ? `#${section.href}` : undefined}
78
+ activated={section.absolute
79
+ ? $location === section.href
80
+ : $location.startsWith(section.href ?? '!')}
92
81
  style={section.indent
93
82
  ? 'margin-left: ' + section.indent * 25 + 'px;'
94
83
  : ''}
@@ -98,11 +87,11 @@
98
87
  {/if}
99
88
  {/each}
100
89
  {:else if user == null}
101
- <Item on:click={() => (drawerOpen = false)} activated>
90
+ <Item tag="span" on:click={() => (drawerOpen = false)} activated>
102
91
  <Text class="mdc-theme--on-secondary">Login</Text>
103
92
  </Item>
104
93
  {:else}
105
- <Item on:click={() => (drawerOpen = false)} activated>
94
+ <Item tag="span" on:click={() => (drawerOpen = false)} activated>
106
95
  <Text class="mdc-theme--on-secondary">Forbidden</Text>
107
96
  </Item>
108
97
  {/if}
@@ -117,13 +106,17 @@
117
106
  <main class="tilmeld-main-content" bind:this={mainContent}>
118
107
  {#if tilmeldAdmin}
119
108
  {#if clientConfig}
120
- <svelte:component this={active} />
109
+ <Router {routes} />
121
110
  {:else}
122
111
  Loading...
123
112
  {/if}
124
113
  {:else if user == null}
125
114
  <section style="display: flex; justify-content: center;">
126
- <Login {User} {clientConfig} />
115
+ <Login
116
+ {User}
117
+ {clientConfig}
118
+ showExistingUserToggle={allowRegistration}
119
+ />
127
120
  </section>
128
121
  {:else}
129
122
  <section>You don't have permission to access this app.</section>
@@ -135,10 +128,14 @@
135
128
 
136
129
  <script lang="ts">
137
130
  import { onMount, SvelteComponent } from 'svelte';
138
- import type { ClientConfig, CurrentUserData } from '@nymphjs/tilmeld-client';
139
- import { User } from '@nymphjs/tilmeld-client';
131
+ import Router, { location } from 'svelte-spa-router';
132
+ import type {
133
+ User as UserClass,
134
+ ClientConfig,
135
+ CurrentUserData,
136
+ } from '@nymphjs/tilmeld-client';
140
137
  import { Login, Account } from '@nymphjs/tilmeld-components';
141
- import { mdiGithub, mdiMastodon, mdiTwitter } from '@mdi/js';
138
+ import { mdiGithub, mdiMastodon } from '@mdi/js';
142
139
  import TopAppBar, { Row, Section, Title } from '@smui/top-app-bar';
143
140
  import Drawer, { Content, Scrim, AppContent } from '@smui/drawer';
144
141
  import IconButton from '@smui/icon-button';
@@ -146,28 +143,33 @@
146
143
  import Menu from '@smui/menu';
147
144
  import { Icon, Svg } from '@smui/common';
148
145
 
149
- import Intro from './Intro.svelte';
150
- import Users from './Users.svelte';
151
- import Groups from './Groups.svelte';
152
- import type { SvelteComponentDev } from 'svelte/internal';
146
+ import { User } from './nymph';
147
+ import Intro from './routes/Intro.svelte';
148
+ import Users from './routes/Users.svelte';
149
+ import UserEdit from './routes/UserEdit.svelte';
150
+ import Groups from './routes/Groups.svelte';
151
+ import GroupEdit from './routes/GroupEdit.svelte';
152
+ import NotFound from './routes/NotFound.svelte';
153
153
 
154
154
  const DEFAULT_AVATAR = 'https://secure.gravatar.com/avatar/?d=mm&s=40';
155
+ const allowRegistration = (window as any).allowRegistration;
155
156
 
156
157
  let mainContent: HTMLElement;
157
158
  let miniWindow = false;
158
159
  let drawerOpen = false;
159
160
  let accountMenu: any;
160
- let active: typeof SvelteComponentDev = Intro;
161
161
  let clientConfig: ClientConfig;
162
- let user: (User & CurrentUserData) | undefined = undefined;
162
+ let user: (UserClass & CurrentUserData) | undefined = undefined;
163
163
  let userAvatar: string = DEFAULT_AVATAR;
164
164
  let tilmeldAdmin: boolean | undefined = undefined;
165
165
  let accountOpen = false;
166
166
 
167
- $: if (active && mainContent) {
168
- drawerOpen = false;
169
- mainContent.scrollTop = 0;
170
- }
167
+ location.subscribe(() => {
168
+ if (mainContent) {
169
+ drawerOpen = false;
170
+ mainContent.scrollTop = 0;
171
+ }
172
+ });
171
173
 
172
174
  $: if (user) {
173
175
  user.$gatekeeper('tilmeld/admin').then((value) => (tilmeldAdmin = value));
@@ -177,18 +179,29 @@
177
179
  userAvatar = DEFAULT_AVATAR;
178
180
  }
179
181
 
182
+ const routes = {
183
+ '/': Intro,
184
+ '/users/edit/:guid': UserEdit,
185
+ '/users/:query?': Users,
186
+ '/groups/edit/:guid': GroupEdit,
187
+ '/groups/:query?': Groups,
188
+ '*': NotFound,
189
+ };
190
+
180
191
  const sections: (
181
192
  | {
182
193
  name: string;
183
194
  indent: number;
184
- route?: typeof SvelteComponentDev;
195
+ href?: string;
196
+ absolute?: boolean;
185
197
  component?: SvelteComponent;
186
198
  }
187
199
  | { name: string; separator: true }
188
200
  )[] = [
189
201
  {
190
202
  name: 'Introduction',
191
- route: Intro,
203
+ href: '/',
204
+ absolute: true,
192
205
  indent: 0,
193
206
  },
194
207
  {
@@ -197,17 +210,17 @@
197
210
  },
198
211
  {
199
212
  name: 'Users',
200
- route: Users,
213
+ href: '/users/',
201
214
  indent: 0,
202
215
  },
203
216
  {
204
217
  name: 'Groups',
205
- route: Groups,
218
+ href: '/groups/',
206
219
  indent: 0,
207
220
  },
208
221
  ];
209
222
 
210
- const onLogin = (currentUser: User & CurrentUserData) => {
223
+ const onLogin = (currentUser: UserClass & CurrentUserData) => {
211
224
  user = currentUser;
212
225
  };
213
226
  const onLogout = () => {
@@ -1,17 +1,21 @@
1
1
  import type { NymphOptions } from '@nymphjs/client';
2
2
  import { Entity, Nymph } from '@nymphjs/client';
3
- import { User, Group } from '@nymphjs/tilmeld-client';
3
+ import {
4
+ User as UserClass,
5
+ Group as GroupClass,
6
+ } from '@nymphjs/tilmeld-client';
4
7
 
5
8
  const nymph = new Nymph(
6
9
  (window as unknown as { nymphOptions: NymphOptions }).nymphOptions
7
10
  );
8
- nymph.addEntityClass(User);
9
- nymph.addEntityClass(Group);
10
-
11
- export default nymph;
11
+ const User = nymph.addEntityClass(UserClass);
12
+ const Group = nymph.addEntityClass(GroupClass);
13
+ User.init(nymph);
12
14
 
13
15
  // Helps with admin and debugging.
14
16
  (window as any).Entity = Entity;
15
17
  (window as any).User = User;
16
18
  (window as any).Group = Group;
17
19
  (window as any).nymph = nymph;
20
+
21
+ export { nymph, User, Group };