@things-factory/auth-ui 8.0.37 → 9.0.0-9.0.0-beta.59.0

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.
Files changed (142) hide show
  1. package/dist-client/components/abstract-auth-page.d.ts +1 -1
  2. package/dist-client/components/abstract-auth-page.js +2 -0
  3. package/dist-client/components/abstract-auth-page.js.map +1 -1
  4. package/dist-client/components/abstract-password-reset.d.ts +2 -2
  5. package/dist-client/components/abstract-password-reset.js +5 -5
  6. package/dist-client/components/abstract-password-reset.js.map +1 -1
  7. package/dist-client/components/change-password.js +1 -1
  8. package/dist-client/components/change-password.js.map +1 -1
  9. package/dist-client/components/invite-user.d.ts +1 -1
  10. package/dist-client/components/invite-user.js +1 -2
  11. package/dist-client/components/invite-user.js.map +1 -1
  12. package/dist-client/components/partner-role-editor.js +1 -1
  13. package/dist-client/components/partner-role-editor.js.map +1 -1
  14. package/dist-client/components/profile-component.d.ts +3 -3
  15. package/dist-client/components/profile-component.js +3 -3
  16. package/dist-client/components/profile-component.js.map +1 -1
  17. package/dist-client/components/role-privilege-editor.js +2 -1
  18. package/dist-client/components/role-privilege-editor.js.map +1 -1
  19. package/dist-client/components/user-role-editor.d.ts +2 -2
  20. package/dist-client/components/user-role-editor.js +2 -2
  21. package/dist-client/components/user-role-editor.js.map +1 -1
  22. package/dist-client/constants/index.d.ts +1 -1
  23. package/dist-client/constants/index.js +1 -1
  24. package/dist-client/constants/index.js.map +1 -1
  25. package/dist-client/entries/auth/activate.d.ts +1 -1
  26. package/dist-client/entries/auth/activate.js +1 -1
  27. package/dist-client/entries/auth/activate.js.map +1 -1
  28. package/dist-client/entries/auth/checkin.js +2 -2
  29. package/dist-client/entries/auth/checkin.js.map +1 -1
  30. package/dist-client/entries/auth/forgot-password.d.ts +2 -2
  31. package/dist-client/entries/auth/forgot-password.js +11 -3
  32. package/dist-client/entries/auth/forgot-password.js.map +1 -1
  33. package/dist-client/entries/auth/reset-password.d.ts +1 -1
  34. package/dist-client/entries/auth/reset-password.js +1 -1
  35. package/dist-client/entries/auth/reset-password.js.map +1 -1
  36. package/dist-client/entries/auth/result.d.ts +1 -1
  37. package/dist-client/entries/auth/result.js +1 -1
  38. package/dist-client/entries/auth/result.js.map +1 -1
  39. package/dist-client/entries/auth/signin.d.ts +1 -1
  40. package/dist-client/entries/auth/signin.js +1 -1
  41. package/dist-client/entries/auth/signin.js.map +1 -1
  42. package/dist-client/entries/auth/signup.d.ts +3 -1
  43. package/dist-client/entries/auth/signup.js +32 -2
  44. package/dist-client/entries/auth/signup.js.map +1 -1
  45. package/dist-client/entries/auth/unlock-user.d.ts +1 -1
  46. package/dist-client/entries/auth/unlock-user.js +1 -1
  47. package/dist-client/entries/auth/unlock-user.js.map +1 -1
  48. package/dist-client/entries/oauth2/oauth2-decision-page.d.ts +1 -1
  49. package/dist-client/entries/oauth2/oauth2-decision-page.js +1 -1
  50. package/dist-client/entries/oauth2/oauth2-decision-page.js.map +1 -1
  51. package/dist-client/entries/public/home.js +2 -2
  52. package/dist-client/entries/public/home.js.map +1 -1
  53. package/dist-client/pages/application/application.js +1 -1
  54. package/dist-client/pages/application/application.js.map +1 -1
  55. package/dist-client/pages/domain/domain-management.d.ts +1 -1
  56. package/dist-client/pages/domain/domain-management.js +1 -1
  57. package/dist-client/pages/domain/domain-management.js.map +1 -1
  58. package/dist-client/pages/domain-link/domain-link-management.d.ts +53 -0
  59. package/dist-client/pages/domain-link/domain-link-management.js +353 -0
  60. package/dist-client/pages/domain-link/domain-link-management.js.map +1 -0
  61. package/dist-client/pages/partner/partner-management.d.ts +3 -3
  62. package/dist-client/pages/partner/partner-management.js +3 -3
  63. package/dist-client/pages/partner/partner-management.js.map +1 -1
  64. package/dist-client/pages/profile.d.ts +1 -1
  65. package/dist-client/pages/profile.js +1 -1
  66. package/dist-client/pages/profile.js.map +1 -1
  67. package/dist-client/pages/role/role-management.d.ts +3 -3
  68. package/dist-client/pages/role/role-management.js +3 -3
  69. package/dist-client/pages/role/role-management.js.map +1 -1
  70. package/dist-client/pages/user/user-management.d.ts +4 -4
  71. package/dist-client/pages/user/user-management.js +4 -4
  72. package/dist-client/pages/user/user-management.js.map +1 -1
  73. package/dist-client/route.js +3 -0
  74. package/dist-client/route.js.map +1 -1
  75. package/dist-client/tsconfig.tsbuildinfo +1 -1
  76. package/dist-server/tsconfig.tsbuildinfo +1 -1
  77. package/helps/auth/domain-link.md +178 -0
  78. package/package.json +12 -12
  79. package/things-factory.config.js +2 -1
  80. package/translations/en.json +7 -0
  81. package/translations/ja.json +7 -0
  82. package/translations/ko.json +7 -0
  83. package/translations/ms.json +7 -0
  84. package/translations/zh.json +7 -0
  85. package/client/auth-style-sign.ts +0 -194
  86. package/client/bootstrap.ts +0 -55
  87. package/client/components/abstract-auth-page.ts +0 -301
  88. package/client/components/abstract-password-reset.ts +0 -163
  89. package/client/components/abstract-sign.ts +0 -127
  90. package/client/components/change-password.ts +0 -153
  91. package/client/components/contact-us.ts +0 -116
  92. package/client/components/create-domain-popup.ts +0 -141
  93. package/client/components/create-role.ts +0 -123
  94. package/client/components/create-user.ts +0 -117
  95. package/client/components/credential-manager.ts +0 -64
  96. package/client/components/delete-user-popup.ts +0 -117
  97. package/client/components/domain-switch.ts +0 -127
  98. package/client/components/invite-customer.ts +0 -104
  99. package/client/components/invite-user.ts +0 -104
  100. package/client/components/my-login-history.ts +0 -101
  101. package/client/components/ownership-transfer-popup.ts +0 -110
  102. package/client/components/partner-info-card.ts +0 -89
  103. package/client/components/partner-role-editor.ts +0 -153
  104. package/client/components/profile-component.ts +0 -392
  105. package/client/components/role-edit-form.ts +0 -92
  106. package/client/components/role-privilege-editor.ts +0 -267
  107. package/client/components/role-selector.ts +0 -102
  108. package/client/components/user-role-editor.ts +0 -499
  109. package/client/constants/application.ts +0 -9
  110. package/client/constants/index.ts +0 -1
  111. package/client/entries/auth/activate.ts +0 -272
  112. package/client/entries/auth/checkin.ts +0 -183
  113. package/client/entries/auth/forgot-password.ts +0 -104
  114. package/client/entries/auth/reset-password.ts +0 -22
  115. package/client/entries/auth/result.ts +0 -193
  116. package/client/entries/auth/signin.ts +0 -18
  117. package/client/entries/auth/signup.ts +0 -115
  118. package/client/entries/auth/unlock-user.ts +0 -22
  119. package/client/entries/oauth2/oauth2-decision-error-page.ts +0 -50
  120. package/client/entries/oauth2/oauth2-decision-page.ts +0 -196
  121. package/client/entries/public/home.ts +0 -246
  122. package/client/index.ts +0 -124
  123. package/client/pages/app-binding/app-binding.ts +0 -423
  124. package/client/pages/app-binding/app-bindings.ts +0 -171
  125. package/client/pages/appliance/appliance.ts +0 -452
  126. package/client/pages/appliance/home.ts +0 -177
  127. package/client/pages/appliance/register.ts +0 -183
  128. package/client/pages/application/application.ts +0 -428
  129. package/client/pages/application/applications.ts +0 -182
  130. package/client/pages/application/register.ts +0 -211
  131. package/client/pages/attribute/attribute-set-item-list.ts +0 -237
  132. package/client/pages/attribute/attribute-set-management.ts +0 -282
  133. package/client/pages/auth-provider/auth-provider-management.ts +0 -381
  134. package/client/pages/domain/domain-management.ts +0 -431
  135. package/client/pages/partner/partner-management.ts +0 -112
  136. package/client/pages/profile.ts +0 -32
  137. package/client/pages/role/role-management.ts +0 -134
  138. package/client/pages/user/user-management.ts +0 -223
  139. package/client/route.ts +0 -67
  140. package/client/themes/auth-theme.css +0 -65
  141. package/client/utils/password-rule.ts +0 -37
  142. package/server/index.ts +0 -0
@@ -1,117 +0,0 @@
1
- import '@material/web/button/outlined-button.js'
2
- import '@material/web/textfield/filled-text-field.js'
3
-
4
- import { css, html, LitElement } from 'lit'
5
- import { customElement, query } from 'lit/decorators.js'
6
-
7
- import { i18next } from '@operato/i18n'
8
-
9
- function capitalize(str) {
10
- return str ? str.charAt(0).toUpperCase() + str.slice(1) : ''
11
- }
12
-
13
- @customElement('create-user')
14
- class CreateUser extends LitElement {
15
- static styles = css`
16
- :host {
17
- --md-text-field-fill-color: var(--md-sys-color-on-primary);
18
- background-color: var(--md-sys-color-surface);
19
- margin: var(--spacing-large) 0;
20
- padding: var(--spacing-large);
21
- border-radius: var(--border-radius);
22
- box-shadow: var(--box-shadow);
23
-
24
- display: grid;
25
- grid-template-columns: 1fr 2fr 2fr auto;
26
- gap: 5px 15px;
27
- clear: both;
28
- max-width: var(--input-container-max-width);
29
-
30
- align-items: center;
31
- }
32
-
33
- md-outlined-button {
34
- margin: var(--input-margin);
35
- }
36
-
37
- @media screen and (max-width: 480px) {
38
- :host {
39
- grid-template-columns: 1fr 1fr;
40
- }
41
-
42
- md-outlined-button {
43
- grid-column: span 2;
44
-
45
- margin: var(--input-margin);
46
- }
47
- }
48
- `
49
-
50
- @query('[name=name]') nameInput!: HTMLInputElement
51
- @query('[name=username]') usernameInput!: HTMLInputElement
52
- @query('[name=email]') emailInput!: HTMLInputElement
53
-
54
- render() {
55
- return html`
56
- <md-filled-text-field
57
- type="text"
58
- name="username"
59
- label=${capitalize(i18next.t('label.user-id'))}
60
- pattern="^(?:[A-Za-z0-9]*|[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,})$"
61
- ><md-icon slot="leading-icon">badge</md-icon></md-filled-text-field
62
- >
63
-
64
- <md-filled-text-field
65
- type="text"
66
- name="name"
67
- label=${capitalize(i18next.t('label.x name', { x: i18next.t('label.user') }))}
68
- ><md-icon slot="leading-icon">id_card</md-icon></md-filled-text-field
69
- >
70
-
71
- <md-filled-text-field type="email" name="email" label=${capitalize(i18next.t('field.email'))}
72
- ><md-icon slot="leading-icon">mail</md-icon></md-filled-text-field
73
- >
74
-
75
- <md-outlined-button @click=${this.onCreateUser.bind(this)}
76
- >${capitalize(i18next.t('button.create'))}</md-outlined-button
77
- >
78
- `
79
- }
80
-
81
- async onCreateUser() {
82
- try {
83
- if (!this.usernameInput.value) {
84
- throw new Error(i18next.t('error.value is empty', { value: 'name' }))
85
- }
86
-
87
- if (!this.emailInput.checkValidity()) {
88
- throw new Error(i18next.t('error.not valid pattern of type', { type: 'e-mail' }))
89
- }
90
-
91
- if (!this.nameInput.value) {
92
- throw new Error(i18next.t('error.value is empty', { value: 'name' }))
93
- }
94
-
95
- const user = {
96
- username: this.usernameInput.value.trim(),
97
- name: this.nameInput.value.trim(),
98
- email: this.emailInput.value.trim()
99
- }
100
-
101
- await this.dispatchEvent(new CustomEvent('create-user', { detail: user }))
102
-
103
- this.usernameInput.value = ''
104
- this.nameInput.value = ''
105
- this.emailInput.value = ''
106
- } catch (e: any) {
107
- document.dispatchEvent(
108
- new CustomEvent('notify', {
109
- detail: {
110
- level: 'error',
111
- message: 'message' in e ? e.message : e
112
- }
113
- })
114
- )
115
- }
116
- }
117
- }
@@ -1,64 +0,0 @@
1
- import gql from 'graphql-tag'
2
- import { LitElement, html, css } from 'lit'
3
- import { customElement, property } from 'lit/decorators.js'
4
-
5
- import { client } from '@operato/graphql'
6
-
7
- @customElement('credential-manager')
8
- export class CredentialManager extends LitElement {
9
- @property({ type: Array }) credentials: {
10
- credentialId: string
11
- }[] = []
12
-
13
- static styles = css`
14
- div {
15
- margin: 20px;
16
- }
17
- button {
18
- margin: 5px;
19
- }
20
- `
21
-
22
- connectedCallback() {
23
- super.connectedCallback()
24
- this.fetchCredentials()
25
- }
26
-
27
- async fetchCredentials() {
28
- const response = await fetch('/auth/credentials', {
29
- method: 'GET',
30
- credentials: 'include'
31
- })
32
- this.credentials = await response.json()
33
- }
34
-
35
- async deleteCredential(credentialId: string) {
36
- const response = await fetch(`/credentials/${credentialId}`, {
37
- method: 'DELETE',
38
- credentials: 'include'
39
- })
40
- if (response.ok) {
41
- this.fetchCredentials()
42
- } else {
43
- console.error('Failed to delete credential')
44
- }
45
- }
46
-
47
- render() {
48
- return html`
49
- <div>
50
- <h2>Manage Your WebAuthn Credentials</h2>
51
- <ul>
52
- ${this.credentials.map(
53
- credential => html`
54
- <li>
55
- ${credential.credentialId}
56
- <button @click=${() => this.deleteCredential(credential.credentialId)}>Delete</button>
57
- </li>
58
- `
59
- )}
60
- </ul>
61
- </div>
62
- `
63
- }
64
- }
@@ -1,117 +0,0 @@
1
- import '@operato/i18n/ox-i18n.js'
2
-
3
- import { css, html, LitElement } from 'lit'
4
- import { customElement } from 'lit/decorators.js'
5
-
6
- import { i18next, localize } from '@operato/i18n'
7
- import { notify } from '@operato/layout'
8
- import { auth } from '@things-factory/auth-base/dist-client/auth.js'
9
-
10
- @customElement('delete-user-popup')
11
- export class DeleteUserPopup extends localize(i18next)(LitElement) {
12
- static styles = [
13
- css`
14
- :host {
15
- display: flex;
16
- flex-direction: column;
17
- color: var(--popup-content-color);
18
- background-color: var(--popup-content-background-color);
19
- padding: var(--popup-content-padding);
20
- }
21
-
22
- * {
23
- box-sizing: border-box;
24
- }
25
- *:focus {
26
- outline: none;
27
- }
28
-
29
- label {
30
- font: bold 14px var(--theme-font);
31
- color: var(--md-sys-color-primary);
32
- }
33
-
34
- input {
35
- border: var(--change-password-field-border);
36
- border-radius: var(--change-password-field-border-radius);
37
- padding: var(--change-password-field-padding);
38
-
39
- font: var(--change-password-field-font);
40
- width: var(--change-password-field-width);
41
- }
42
- input:focus {
43
- border: 1px solid var(--focus-background-color);
44
- }
45
-
46
- div.field {
47
- padding-bottom: 10px;
48
- }
49
-
50
- ::placeholder {
51
- font-size: 0.8rem;
52
- text-transform: capitalize;
53
- }
54
-
55
- button {
56
- background-color: var(--status-danger-color, #d14946);
57
- margin: 2px 2px 10px 2px;
58
- height: var(--button-height, 28px);
59
- color: var(--button-color, #fff);
60
- font: var(--button-font);
61
- border-radius: var(--button-radius, 5px);
62
- border: var(--button-border, 1px solid transparent);
63
- line-height: 1.5;
64
- }
65
- button:hover,
66
- button:active {
67
- background-color: var(--button-active-background-color, #22a6a7);
68
- border: var(--button-active-border);
69
- }
70
- `
71
- ]
72
-
73
- render() {
74
- return html`
75
- <h1><ox-i18n msgid="label.delete account"></ox-i18n></h1>
76
- <span><ox-i18n msgid="text.delete account warning message"></ox-i18n></span>
77
- <form @submit=${e => this.submit(e)}>
78
- <div class="field">
79
- <label for="email"><ox-i18n msgid="label.email"></ox-i18n></label>
80
- <input id="email" type="email" name="email" autocapitalize="off" required />
81
- <label for="password"><ox-i18n msgid="label.password"></ox-i18n></label>
82
- <input id="password" type="password" name="password" required />
83
- </div>
84
-
85
- <button class="ui button" type="submit"><ox-i18n msgid="label.delete account"></ox-i18n></button>
86
- </form>
87
- `
88
- }
89
-
90
- async submit(e: Event) {
91
- e.preventDefault()
92
-
93
- const form = e.target as HTMLFormElement
94
-
95
- var params = {}
96
- new FormData(form).forEach((value, key) => {
97
- params[key] = value
98
- })
99
-
100
- try {
101
- const message = await auth.deleteUser(params)
102
- notify({
103
- level: 'info',
104
- message
105
- })
106
-
107
- auth.signout()
108
- } catch (e: any) {
109
- form.reset()
110
-
111
- notify({
112
- level: 'error',
113
- message: 'message' in e ? e.message : e
114
- })
115
- }
116
- }
117
- }
@@ -1,127 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
-
3
- import { css, html, LitElement, nothing } from 'lit'
4
- import { customElement, property } from 'lit/decorators.js'
5
- import { connect } from 'pwa-helpers/connect-mixin'
6
-
7
- import { store } from '@operato/shell'
8
- import { ScrollbarStyles } from '@operato/styles'
9
-
10
- @customElement('domain-switch')
11
- export class DomainSwitch extends connect(store)(LitElement) {
12
- static styles = [
13
- ScrollbarStyles,
14
- css`
15
- :host {
16
- display: flex;
17
- max-width: 100%;
18
- background-color: var(--md-sys-color-primary-container, rgb(215 231 241));
19
- border-bottom: var(--border-dim-color);
20
- }
21
-
22
- :host * {
23
- vertical-align: middle;
24
- }
25
-
26
- div {
27
- flex: 1;
28
- display: flex;
29
- flex-direction: row;
30
- padding: var(--spacing-small);
31
- }
32
-
33
- md-icon {
34
- background-color: var(--md-sys-color-primary, rgb(46 121 190));
35
- margin-right: var(--spacing-small);
36
- padding: 2px;
37
- border-radius: 50%;
38
- font-size: var(--fontsize-large);
39
- color: var(--md-sys-color-on-primary, rgba(255,255,255,.9));
40
- }
41
- span,
42
- select {
43
- flex: 1;
44
- color: var(--md-sys-color-on-primary-container, rgb(50 66 82));
45
- font: bold 14px/20px var(--theme-font);
46
- }
47
-
48
- select {
49
- border: none;
50
- background-color: transparent;
51
- }
52
-
53
- select:focus {
54
- outline: 0;
55
- }
56
- :host([dark]) {
57
- background-color: rgba(0, 0, 0, 0.2);
58
- padding: 0 !important;
59
- border-bottom: none;
60
- }
61
- :host([dark]) md-icon {
62
- background-color: var(--secondary-text-color);
63
- margin: 1px 4px 0px 0px;
64
- padding: 1px 2px;
65
- border-radius: 50%;
66
- line-height: 19px;
67
- }
68
- :host([dark]) span,
69
- :host([dark]) select {
70
- color: var(--md-sys-color-on-primary);
71
- font: bold 13px/13px var(--theme-font);
72
- }
73
- :host([dark]) option {
74
- background-color: var(--primary-color, #585858);
75
- color: var(--md-sys-color-on-primary, #fff);
76
- }
77
- :host([dark]) span {
78
- line-height: 23px;
79
- }
80
-
81
- :host([rounded-corner]) {
82
- height: 30px;
83
- border-radius: 20px;
84
- border: var(--border-dim-color);
85
- }
86
- :host([rounded-corner]) div {
87
- padding: var(--spacing-small) var(--spacing-medium);
88
- }
89
- `
90
- ]
91
-
92
- @property({ type: Array }) domains: any[] = []
93
- @property({ type: Object }) domain: any
94
- @property({ type: String, attribute: true }) attrname: string = 'name'
95
- @property({ type: String, attribute: true }) icon?: string
96
-
97
- render() {
98
- const domains = this.domains || []
99
- const domain = this.domain || {}
100
- const attrname = this.attrname || 'name'
101
-
102
- return html`
103
- <div>
104
- ${this.icon ? html`<md-icon>${this.icon}</md-icon>` : nothing}
105
- ${domains.length <= 1
106
- ? html` <span>${domains[0]?.[attrname] || domain.name}</span> `
107
- : html`
108
- <select
109
- .value=${domain.subdomain}
110
- @change=${e => (window.location.pathname = `/auth/checkin/${e.target.value}`)}
111
- >
112
- ${domains.map(
113
- d => html`
114
- <option .value=${d.subdomain} ?selected=${d.subdomain == domain.subdomain}>${d[attrname]}</option>
115
- `
116
- )}
117
- </select>
118
- `}
119
- </div>
120
- `
121
- }
122
-
123
- stateChanged(state) {
124
- this.domains = state.app.domains
125
- this.domain = state.app.domain
126
- }
127
- }
@@ -1,104 +0,0 @@
1
- import gql from 'graphql-tag'
2
- import { css, html, LitElement } from 'lit'
3
- import { customElement, property, query } from 'lit/decorators.js'
4
-
5
- import { client, gqlContext } from '@operato/graphql'
6
- import { i18next, localize } from '@operato/i18n'
7
- import { OxPrompt } from '@operato/popup/ox-prompt.js'
8
-
9
- @customElement('invite-customer')
10
- class InviteCustomer extends localize(i18next)(LitElement) {
11
- static styles = [
12
- css`
13
- input {
14
- border: var(--border-dim-color);
15
- border-radius: var(--border-radius);
16
- margin: var(--input-margin);
17
- padding: var(--input-padding);
18
- min-width: 250px;
19
- font: var(--input-font);
20
- }
21
- md-outlined-button {
22
- margin: var(--input-margin);
23
- }
24
- @media screen and (max-width: 480px) {
25
- div {
26
- display: grid;
27
- }
28
- }
29
- `
30
- ]
31
-
32
- @property({ type: Array }) customers: any[] = []
33
-
34
- @query('input#customer-name') customerNameInput!: HTMLInputElement
35
-
36
- render() {
37
- return html`
38
- <div>
39
- <input id="customer-name" required />
40
- <md-outlined-button @click=${this.invite.bind(this)}>
41
- <md-icon slot="icon">group_add</md-icon>
42
- ${String(i18next.t('label.invite customer'))}
43
- </md-outlined-button>
44
- </div>
45
- `
46
- }
47
-
48
- async invite() {
49
- try {
50
- if (!this.customerNameInput.value)
51
- throw new Error(i18next.t('error.value is empty', { value: i18next.t('field.name') }))
52
-
53
- if (this.customers.find(c => c.name?.toLowerCase() === this.customerNameInput.value.toLowerCase())) {
54
- throw new Error(
55
- i18next.t('error.x already exists in y', { x: this.customerNameInput.value, y: i18next.t('field.customer') })
56
- )
57
- }
58
-
59
- if (
60
- await OxPrompt.open({
61
- title: i18next.t('text.are_you_sure'),
62
- text: i18next.t('text.do_you_want_to_invite_x', { x: i18next.t(`label.partner`) }),
63
- confirmButton: { text: i18next.t('button.confirm') },
64
- cancelButton: { text: i18next.t('button.cancel') }
65
- })
66
- ) {
67
- const customerDomainName = this.customerNameInput.value
68
-
69
- const response = await client.mutate({
70
- mutation: gql`
71
- mutation inviteCustomer($customerDomainName: String!) {
72
- inviteCustomer(customerDomainName: $customerDomainName)
73
- }
74
- `,
75
- variables: { customerDomainName },
76
- context: gqlContext()
77
- })
78
-
79
- if (!response.errors) {
80
- const answer = this.dispatchEvent(new CustomEvent('invitationCompleted'))
81
-
82
- if (answer) {
83
- await OxPrompt.open({
84
- type: 'success',
85
- title: i18next.t('text.completed'),
86
- confirmButton: { text: i18next.t('button.confirm') }
87
- })
88
- }
89
-
90
- this.customerNameInput.value = ''
91
- }
92
- }
93
- } catch (e: any) {
94
- document.dispatchEvent(
95
- new CustomEvent('notify', {
96
- detail: {
97
- level: 'error',
98
- message: 'message' in e ? e.message : e
99
- }
100
- })
101
- )
102
- }
103
- }
104
- }
@@ -1,104 +0,0 @@
1
- import './user-role-editor'
2
-
3
- import gql from 'graphql-tag'
4
- import { css, html, LitElement } from 'lit'
5
- import { customElement, query } from 'lit/decorators.js'
6
-
7
- import { client, gqlContext } from '@operato/graphql'
8
- import { i18next, localize } from '@operato/i18n'
9
- import { OxPrompt } from '@operato/popup/ox-prompt.js'
10
-
11
- @customElement('invite-user')
12
- class InviteUser extends localize(i18next)(LitElement) {
13
- static styles = css`
14
- :host {
15
- display: grid;
16
- }
17
-
18
- input {
19
- flex: 1;
20
-
21
- border: var(--border-dim-color);
22
- border-radius: var(--border-radius);
23
- margin: var(--input-margin);
24
- padding: var(--input-padding);
25
- min-width: 250px;
26
- font: var(--input-font);
27
- }
28
-
29
- md-outlined-button {
30
- margin: var(--input-margin);
31
- text-transform: capitalize;
32
- }
33
- `
34
-
35
- @query('input[name=username]') userIdInput!: HTMLInputElement
36
-
37
- render() {
38
- return html`
39
- <input
40
- name="username"
41
- type="text"
42
- required
43
- name="username"
44
- autocapitalize="off"
45
- placeholder=${String(i18next.t('text.user invitation prompt'))}
46
- pattern="^(?:[A-Za-z0-9]*|[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,})$"
47
- />
48
- <md-outlined-button @click=${this.invite.bind(this)}>
49
- <md-icon slot="icon">group_add</md-icon>${String(i18next.t('label.invite user'))}
50
- </md-outlined-button>
51
- `
52
- }
53
-
54
- async invite() {
55
- try {
56
- if (!this.userIdInput.checkValidity()) {
57
- throw new Error(i18next.t('error.not valid pattern of type', { type: 'user-id or email' }))
58
- }
59
-
60
- if (
61
- await OxPrompt.open({
62
- title: i18next.t('text.are_you_sure'),
63
- text: i18next.t('text.do_you_want_to_invite_x', { x: i18next.t(`label.user`) }),
64
- confirmButton: { text: i18next.t('button.confirm') },
65
- cancelButton: { text: i18next.t('button.cancel') }
66
- })
67
- ) {
68
- await this.inviteUser(this.userIdInput.value)
69
-
70
- this.dispatchEvent(new CustomEvent('invitationCompleted'))
71
- }
72
- } catch (e: any) {
73
- document.dispatchEvent(
74
- new CustomEvent('notify', {
75
- detail: {
76
- level: 'error',
77
- message: 'message' in e ? e.message : e
78
- }
79
- })
80
- )
81
- }
82
- }
83
-
84
- async inviteUser(username) {
85
- const response = await client.mutate({
86
- mutation: gql`
87
- mutation inviteUser($username: String!) {
88
- inviteUser(username: $username)
89
- }
90
- `,
91
- variables: { username },
92
- context: gqlContext()
93
- })
94
-
95
- if (!response.errors) {
96
- await OxPrompt.open({
97
- title: i18next.t('text.completed'),
98
- confirmButton: { text: i18next.t('button.confirm') }
99
- })
100
-
101
- this.userIdInput.value = ''
102
- }
103
- }
104
- }