@things-factory/auth-ui 6.2.6 → 6.2.8

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 (41) hide show
  1. package/client/components/create-domain-popup.ts +2 -2
  2. package/client/components/create-role.ts +38 -34
  3. package/client/components/create-user.ts +27 -52
  4. package/client/components/invite-customer.ts +29 -29
  5. package/client/components/invite-user.ts +15 -14
  6. package/client/components/ownership-transfer-popup.ts +29 -30
  7. package/client/components/partner-role-editor.ts +28 -28
  8. package/client/components/role-privilege-editor.ts +30 -29
  9. package/client/components/role-selector.ts +2 -2
  10. package/client/components/user-role-editor.ts +64 -66
  11. package/client/entries/oauth2/oauth2-decision-page.ts +2 -2
  12. package/client/pages/role/role-management.ts +0 -1
  13. package/client/pages/user/user-management.ts +26 -26
  14. package/dist-client/components/create-domain-popup.js +2 -2
  15. package/dist-client/components/create-domain-popup.js.map +1 -1
  16. package/dist-client/components/create-role.js +30 -27
  17. package/dist-client/components/create-role.js.map +1 -1
  18. package/dist-client/components/create-user.js +26 -51
  19. package/dist-client/components/create-user.js.map +1 -1
  20. package/dist-client/components/invite-customer.js +24 -25
  21. package/dist-client/components/invite-customer.js.map +1 -1
  22. package/dist-client/components/invite-user.js +8 -9
  23. package/dist-client/components/invite-user.js.map +1 -1
  24. package/dist-client/components/ownership-transfer-popup.js +23 -23
  25. package/dist-client/components/ownership-transfer-popup.js.map +1 -1
  26. package/dist-client/components/partner-role-editor.js +21 -22
  27. package/dist-client/components/partner-role-editor.js.map +1 -1
  28. package/dist-client/components/role-privilege-editor.js +23 -23
  29. package/dist-client/components/role-privilege-editor.js.map +1 -1
  30. package/dist-client/components/role-selector.js +2 -2
  31. package/dist-client/components/role-selector.js.map +1 -1
  32. package/dist-client/components/user-role-editor.js +54 -58
  33. package/dist-client/components/user-role-editor.js.map +1 -1
  34. package/dist-client/entries/oauth2/oauth2-decision-page.js +2 -2
  35. package/dist-client/entries/oauth2/oauth2-decision-page.js.map +1 -1
  36. package/dist-client/pages/role/role-management.js +0 -1
  37. package/dist-client/pages/role/role-management.js.map +1 -1
  38. package/dist-client/pages/user/user-management.js +19 -20
  39. package/dist-client/pages/user/user-management.js.map +1 -1
  40. package/dist-client/tsconfig.tsbuildinfo +1 -1
  41. package/package.json +3 -4
@@ -6,7 +6,7 @@ import { customElement, query } from 'lit/decorators.js'
6
6
 
7
7
  import { client } from '@operato/graphql'
8
8
  import { i18next, localize } from '@operato/i18n'
9
- import { CustomAlert } from '@things-factory/shell/client'
9
+ import { OxPrompt } from '@operato/popup/ox-prompt.js'
10
10
 
11
11
  @customElement('create-domain-popup')
12
12
  class CreateDomainPopup extends localize(i18next)(LitElement) {
@@ -118,7 +118,7 @@ class CreateDomainPopup extends localize(i18next)(LitElement) {
118
118
  })
119
119
 
120
120
  if (!response.errors) {
121
- await CustomAlert({
121
+ await OxPrompt.open({
122
122
  type: 'success',
123
123
  title: i18next.t('text.completed'),
124
124
  text: i18next.t('text.x_created_successfully', { x: i18next.t('label.domain') }),
@@ -6,7 +6,7 @@ import { customElement, query } from 'lit/decorators.js'
6
6
 
7
7
  import { client, gqlContext } from '@operato/graphql'
8
8
  import { i18next, localize } from '@operato/i18n'
9
- import { CustomAlert } from '@things-factory/shell/client'
9
+ import { OxPrompt } from '@operato/popup/ox-prompt.js'
10
10
 
11
11
  @customElement('create-role')
12
12
  class CreateRole extends localize(i18next)(LitElement) {
@@ -53,15 +53,19 @@ class CreateRole extends localize(i18next)(LitElement) {
53
53
  <mwc-textfield
54
54
  type="text"
55
55
  name="name"
56
- label=${i18next.t('label.x name', { x: i18next.t('label.role') })}
56
+ label=${String(i18next.t('label.x name', { x: i18next.t('label.role') }))}
57
57
  ></mwc-textfield>
58
58
  <mwc-textfield
59
59
  type="text"
60
60
  name="description"
61
- label=${i18next.t('label.x description', { x: i18next.t('label.role') })}
61
+ label=${String(i18next.t('label.x description', { x: i18next.t('label.role') }))}
62
62
  ></mwc-textfield>
63
63
 
64
- <mwc-button @click=${this.onCreateRole.bind(this)} outlined label="${i18next.t('button.create')}"></mwc-button>
64
+ <mwc-button
65
+ @click=${this.onCreateRole.bind(this)}
66
+ outlined
67
+ label=${String(i18next.t('button.create'))}
68
+ ></mwc-button>
65
69
  `
66
70
  }
67
71
 
@@ -78,39 +82,39 @@ class CreateRole extends localize(i18next)(LitElement) {
78
82
  role.name = name
79
83
  role.description = description
80
84
 
81
- const result = await CustomAlert({
82
- title: i18next.t('text.are_you_sure'),
83
- text: i18next.t('text.do_you_want_to_create_x', { x: i18next.t('label.role') }),
84
- confirmButton: { text: i18next.t('button.confirm') },
85
- cancelButton: { text: i18next.t('button.cancel') }
86
- })
87
-
88
- if (!result.value) return
89
-
90
- const response = await client.mutate({
91
- mutation: gql`
92
- mutation createRole($role: NewRole!) {
93
- createRole(role: $role) {
94
- name
85
+ if (
86
+ await OxPrompt.open({
87
+ title: i18next.t('text.are_you_sure'),
88
+ text: i18next.t('text.do_you_want_to_create_x', { x: i18next.t('label.role') }),
89
+ confirmButton: { text: i18next.t('button.confirm') },
90
+ cancelButton: { text: i18next.t('button.cancel') }
91
+ })
92
+ ) {
93
+ const response = await client.mutate({
94
+ mutation: gql`
95
+ mutation createRole($role: NewRole!) {
96
+ createRole(role: $role) {
97
+ name
98
+ }
95
99
  }
96
- }
97
- `,
98
- variables: { role },
99
- context: gqlContext()
100
- })
101
-
102
- if (!response.errors) {
103
- await this.dispatchEvent(new CustomEvent('fetch-roles'))
104
-
105
- await CustomAlert({
106
- type: 'success',
107
- title: i18next.t('text.completed'),
108
- text: i18next.t('text.data_uploaded_successfully'),
109
- confirmButton: { text: i18next.t('button.confirm') }
100
+ `,
101
+ variables: { role },
102
+ context: gqlContext()
110
103
  })
111
104
 
112
- this.nameInput.value = ''
113
- this.descriptionInput.value = ''
105
+ if (!response.errors) {
106
+ await this.dispatchEvent(new CustomEvent('fetch-roles'))
107
+
108
+ await OxPrompt.open({
109
+ type: 'success',
110
+ title: i18next.t('text.completed'),
111
+ text: i18next.t('text.data_uploaded_successfully'),
112
+ confirmButton: { text: i18next.t('button.confirm') }
113
+ })
114
+
115
+ this.nameInput.value = ''
116
+ this.descriptionInput.value = ''
117
+ }
114
118
  }
115
119
  }
116
120
 
@@ -6,83 +6,58 @@ import { i18next } from '@operato/i18n'
6
6
  @customElement('create-user')
7
7
  class CreateUser extends LitElement {
8
8
  static styles = css`
9
- [field-2column] {
9
+ :host {
10
+ --mdc-text-field-fill-color: var(--theme-white-color);
10
11
  background-color: var(--theme-white-color);
11
12
  margin: var(--margin-wide) 0;
12
13
  padding: var(--padding-wide);
13
14
  border-radius: var(--border-radius);
14
15
  box-shadow: var(--box-shadow);
16
+
15
17
  display: grid;
16
- grid-template-columns: 1fr 1fr;
18
+ grid-template-columns: 1fr 2fr auto;
17
19
  gap: 5px 15px;
18
20
  clear: both;
19
21
  max-width: var(--input-container-max-width);
20
- }
21
- [field] {
22
- display: flex;
23
- flex-direction: column;
24
- padding-bottom: var(--padding-default);
25
- }
26
- [grid-span] {
27
- grid-column: span 2;
28
- }
29
22
 
30
- input {
31
- border: var(--border-dark-color);
32
- border-radius: var(--border-radius);
33
- margin: var(--input-margin);
34
- padding: var(--input-padding);
35
- min-width: 250px;
36
- font: var(--input-font);
23
+ align-items: center;
37
24
  }
38
- label {
39
- display: flex;
40
- flex-direction: column;
41
25
 
42
- font: var(--label-font);
43
- color: var(--label-color);
44
- text-transform: var(--label-text-transform);
45
- }
46
26
  mwc-button {
47
27
  margin: var(--input-margin);
48
28
  }
29
+
49
30
  @media screen and (max-width: 480px) {
50
- div {
51
- display: grid;
31
+ :host {
32
+ grid-template-columns: 1fr 1fr;
52
33
  }
53
- [field] {
34
+
35
+ mwc-button {
54
36
  grid-column: span 2;
37
+
38
+ margin: var(--input-margin);
55
39
  }
56
40
  }
57
41
  `
58
42
 
59
- @query('input[name=name]') nameInput!: HTMLInputElement
60
- @query('input[name=email]') emailInput!: HTMLInputElement
43
+ @query('[name=name]') nameInput!: HTMLInputElement
44
+ @query('[name=email]') emailInput!: HTMLInputElement
61
45
 
62
46
  render() {
63
47
  return html`
64
- <div field-2column>
65
- <div field>
66
- <label
67
- >${i18next.t('label.x name', { x: i18next.t('label.user') })}
68
- <input name="name" type="text" required />
69
- </label>
70
- </div>
71
- <div field>
72
- <label
73
- >${i18next.t('field.email')}
74
- <input name="email" type="email" required autocapitalize="off" />
75
- </label>
76
- </div>
77
-
78
- <div>
79
- <mwc-button
80
- @click=${this.onCreateUser.bind(this)}
81
- outlined
82
- label="${i18next.t('button.create')}"
83
- ></mwc-button>
84
- </div>
85
- </div>
48
+ <mwc-textfield
49
+ type="text"
50
+ name="name"
51
+ label=${String(i18next.t('label.x name', { x: i18next.t('label.user') }))}
52
+ ></mwc-textfield>
53
+
54
+ <mwc-textfield type="email" name="email" label=${String(i18next.t('field.email'))}></mwc-textfield>
55
+
56
+ <mwc-button
57
+ @click=${this.onCreateUser.bind(this)}
58
+ outlined
59
+ label=${String(i18next.t('button.create'))}
60
+ ></mwc-button>
86
61
  `
87
62
  }
88
63
 
@@ -6,7 +6,7 @@ import { customElement, property, query } from 'lit/decorators.js'
6
6
 
7
7
  import { client, gqlContext } from '@operato/graphql'
8
8
  import { i18next, localize } from '@operato/i18n'
9
- import { CustomAlert } from '@things-factory/shell/client'
9
+ import { OxPrompt } from '@operato/popup/ox-prompt.js'
10
10
 
11
11
  @customElement('invite-customer')
12
12
  class InviteCustomer extends localize(i18next)(LitElement) {
@@ -43,7 +43,7 @@ class InviteCustomer extends localize(i18next)(LitElement) {
43
43
  @click=${this.invite.bind(this)}
44
44
  outlined
45
45
  icon="group_add"
46
- label="${i18next.t('label.invite customer')}"
46
+ label=${String(i18next.t('label.invite customer'))}
47
47
  ></mwc-button>
48
48
  </div>
49
49
  `
@@ -60,39 +60,39 @@ class InviteCustomer extends localize(i18next)(LitElement) {
60
60
  )
61
61
  }
62
62
 
63
- const result = await CustomAlert({
64
- title: i18next.t('text.are_you_sure'),
65
- text: i18next.t('text.do_you_want_to_invite_x', { x: i18next.t(`label.partner`) }),
66
- confirmButton: { text: i18next.t('button.confirm') },
67
- cancelButton: { text: i18next.t('button.cancel') }
68
- })
63
+ if (
64
+ await OxPrompt.open({
65
+ title: i18next.t('text.are_you_sure'),
66
+ text: i18next.t('text.do_you_want_to_invite_x', { x: i18next.t(`label.partner`) }),
67
+ confirmButton: { text: i18next.t('button.confirm') },
68
+ cancelButton: { text: i18next.t('button.cancel') }
69
+ })
70
+ ) {
71
+ const customerDomainName = this.customerNameInput.value
69
72
 
70
- if (!result.value) return
73
+ const response = await client.mutate({
74
+ mutation: gql`
75
+ mutation inviteCustomer($customerDomainName: String!) {
76
+ inviteCustomer(customerDomainName: $customerDomainName)
77
+ }
78
+ `,
79
+ variables: { customerDomainName },
80
+ context: gqlContext()
81
+ })
71
82
 
72
- const customerDomainName = this.customerNameInput.value
83
+ if (!response.errors) {
84
+ const answer = this.dispatchEvent(new CustomEvent('invitationCompleted'))
73
85
 
74
- const response = await client.mutate({
75
- mutation: gql`
76
- mutation inviteCustomer($customerDomainName: String!) {
77
- inviteCustomer(customerDomainName: $customerDomainName)
86
+ if (answer) {
87
+ await OxPrompt.open({
88
+ type: 'success',
89
+ title: i18next.t('text.completed'),
90
+ confirmButton: { text: i18next.t('button.confirm') }
91
+ })
78
92
  }
79
- `,
80
- variables: { customerDomainName },
81
- context: gqlContext()
82
- })
83
93
 
84
- if (!response.errors) {
85
- const answer = this.dispatchEvent(new CustomEvent('invitationCompleted'))
86
-
87
- if (answer) {
88
- await CustomAlert({
89
- type: 'success',
90
- title: i18next.t('text.completed'),
91
- confirmButton: { text: i18next.t('button.confirm') }
92
- })
94
+ this.customerNameInput.value = ''
93
95
  }
94
-
95
- this.customerNameInput.value = ''
96
96
  }
97
97
  } catch (e: any) {
98
98
  document.dispatchEvent(
@@ -6,7 +6,7 @@ import { customElement, query } from 'lit/decorators.js'
6
6
 
7
7
  import { client, gqlContext } from '@operato/graphql'
8
8
  import { i18next, localize } from '@operato/i18n'
9
- import { CustomAlert } from '@things-factory/shell/client'
9
+ import { OxPrompt } from '@operato/popup/ox-prompt.js'
10
10
 
11
11
  @customElement('invite-user')
12
12
  class InviteUser extends localize(i18next)(LitElement) {
@@ -40,7 +40,7 @@ class InviteUser extends localize(i18next)(LitElement) {
40
40
  @click=${this.invite.bind(this)}
41
41
  outlined
42
42
  icon="group_add"
43
- label="${i18next.t('label.invite user')}"
43
+ label=${String(i18next.t('label.invite user'))}
44
44
  ></mwc-button>
45
45
  `
46
46
  }
@@ -51,18 +51,18 @@ class InviteUser extends localize(i18next)(LitElement) {
51
51
  throw new Error(i18next.t('error.not valid pattern of type', { type: 'e-mail' }))
52
52
  }
53
53
 
54
- const result = await CustomAlert({
55
- title: i18next.t('text.are_you_sure'),
56
- text: i18next.t('text.do_you_want_to_invite_x', { x: i18next.t(`label.user`) }),
57
- confirmButton: { text: i18next.t('button.confirm') },
58
- cancelButton: { text: i18next.t('button.cancel') }
59
- })
60
-
61
- if (!result.value) return
62
-
63
- await this.inviteUser(this.emailInput.value)
54
+ if (
55
+ await OxPrompt.open({
56
+ title: i18next.t('text.are_you_sure'),
57
+ text: i18next.t('text.do_you_want_to_invite_x', { x: i18next.t(`label.user`) }),
58
+ confirmButton: { text: i18next.t('button.confirm') },
59
+ cancelButton: { text: i18next.t('button.cancel') }
60
+ })
61
+ ) {
62
+ await this.inviteUser(this.emailInput.value)
64
63
 
65
- this.dispatchEvent(new CustomEvent('invitationCompleted'))
64
+ this.dispatchEvent(new CustomEvent('invitationCompleted'))
65
+ }
66
66
  } catch (e: any) {
67
67
  document.dispatchEvent(
68
68
  new CustomEvent('notify', {
@@ -87,10 +87,11 @@ class InviteUser extends localize(i18next)(LitElement) {
87
87
  })
88
88
 
89
89
  if (!response.errors) {
90
- await CustomAlert({
90
+ await OxPrompt.open({
91
91
  title: i18next.t('text.completed'),
92
92
  confirmButton: { text: i18next.t('button.confirm') }
93
93
  })
94
+
94
95
  this.emailInput.value = ''
95
96
  }
96
97
  }
@@ -6,7 +6,7 @@ import { customElement, property, query } from 'lit/decorators.js'
6
6
 
7
7
  import { client, gqlContext } from '@operato/graphql'
8
8
  import { i18next, localize } from '@operato/i18n'
9
- import { CustomAlert } from '@things-factory/shell/client'
9
+ import { OxPrompt } from '@operato/popup/ox-prompt.js'
10
10
 
11
11
  @customElement('ownership-transfer-popup')
12
12
  class OwnershipTransferPopup extends localize(i18next)(LitElement) {
@@ -65,39 +65,38 @@ class OwnershipTransferPopup extends localize(i18next)(LitElement) {
65
65
  return
66
66
  }
67
67
 
68
- const answer = await CustomAlert({
69
- title: i18next.t('text.are_you_sure'),
70
- text: i18next.t('text.are_you_sure_to_transfer_owner'),
71
- confirmButton: { text: i18next.t('button.confirm') },
72
- cancelButton: { text: i18next.t('button.cancel') }
73
- })
74
-
75
- if (!answer.value) {
76
- history.back()
77
- return
78
- }
68
+ if (
69
+ await OxPrompt.open({
70
+ title: i18next.t('text.are_you_sure'),
71
+ text: i18next.t('text.are_you_sure_to_transfer_owner'),
72
+ confirmButton: { text: i18next.t('button.confirm') },
73
+ cancelButton: { text: i18next.t('button.cancel') }
74
+ })
75
+ ) {
76
+ const response = await client.mutate({
77
+ mutation: gql`
78
+ mutation transferOwner($email: String!) {
79
+ transferOwner(email: $email)
80
+ }
81
+ `,
82
+ variables: { email: this.user.email },
83
+ context: gqlContext()
84
+ })
79
85
 
80
- const response = await client.mutate({
81
- mutation: gql`
82
- mutation transferOwner($email: String!) {
83
- transferOwner(email: $email)
84
- }
85
- `,
86
- variables: { email: this.user.email },
87
- context: gqlContext()
88
- })
86
+ if (!response.errors?.length) {
87
+ await OxPrompt.open({
88
+ type: 'success',
89
+ title: i18next.t('text.completed'),
90
+ text: i18next.t('text.owner_transfer_completed'),
91
+ confirmButton: { text: i18next.t('button.confirm') }
92
+ })
89
93
 
90
- if (!response.errors?.length) {
91
- await CustomAlert({
92
- type: 'success',
93
- title: i18next.t('text.completed'),
94
- text: i18next.t('text.owner_transfer_completed'),
95
- confirmButton: { text: i18next.t('button.confirm') }
96
- })
94
+ history.back()
97
95
 
96
+ this.dispatchEvent(new CustomEvent('ownershipTransferred', { bubbles: true, composed: true }))
97
+ }
98
+ } else {
98
99
  history.back()
99
-
100
- this.dispatchEvent(new CustomEvent('ownershipTransferred', { bubbles: true, composed: true }))
101
100
  }
102
101
  }
103
102
 
@@ -7,7 +7,7 @@ import { customElement, property, query } from 'lit/decorators.js'
7
7
 
8
8
  import { client, gqlContext } from '@operato/graphql'
9
9
  import { i18next, localize } from '@operato/i18n'
10
- import { CustomAlert } from '@things-factory/shell/client'
10
+ import { OxPrompt } from '@operato/popup/ox-prompt.js'
11
11
 
12
12
  import { RoleSelector } from './role-selector'
13
13
 
@@ -123,34 +123,34 @@ class PartnerRoleEditor extends localize(i18next)(LitElement) {
123
123
  }
124
124
 
125
125
  async onTerminateContract() {
126
- const answer = await CustomAlert({
127
- title: i18next.t('text.are_you_sure'),
128
- text: i18next.t('text.are_you_sure_to_terminate_contract'),
129
- confirmButton: { text: i18next.t('button.terminate contract') },
130
- cancelButton: { text: i18next.t('button.cancel') }
131
- })
132
-
133
- if (!answer.value) return
134
-
135
- const response = await client.mutate({
136
- mutation: gql`
137
- mutation terminateContract($partnerName: String!) {
138
- terminateContract(partnerName: $partnerName)
126
+ if (
127
+ await OxPrompt.open({
128
+ title: i18next.t('text.are_you_sure'),
129
+ text: i18next.t('text.are_you_sure_to_terminate_contract'),
130
+ confirmButton: { text: i18next.t('button.terminate contract') },
131
+ cancelButton: { text: i18next.t('button.cancel') }
132
+ })
133
+ ) {
134
+ const response = await client.mutate({
135
+ mutation: gql`
136
+ mutation terminateContract($partnerName: String!) {
137
+ terminateContract(partnerName: $partnerName)
138
+ }
139
+ `,
140
+ variables: { partnerName: this.customer.name },
141
+ context: gqlContext()
142
+ })
143
+
144
+ if (!response.errors?.length) {
145
+ const answer = this.dispatchEvent(new CustomEvent('contractTerminated'))
146
+
147
+ if (answer) {
148
+ await OxPrompt.open({
149
+ type: 'success',
150
+ title: i18next.t('text.completed'),
151
+ confirmButton: { text: i18next.t('button.confirm') }
152
+ })
139
153
  }
140
- `,
141
- variables: { partnerName: this.customer.name },
142
- context: gqlContext()
143
- })
144
-
145
- if (!response.errors?.length) {
146
- const answer = this.dispatchEvent(new CustomEvent('contractTerminated'))
147
-
148
- if (answer) {
149
- await CustomAlert({
150
- type: 'success',
151
- title: i18next.t('text.completed'),
152
- confirmButton: { text: i18next.t('button.confirm') }
153
- })
154
154
  }
155
155
  }
156
156
  }
@@ -4,7 +4,7 @@ import { customElement, property } from 'lit/decorators.js'
4
4
 
5
5
  import { client, gqlContext } from '@operato/graphql'
6
6
  import { i18next, localize } from '@operato/i18n'
7
- import { CustomAlert } from '@things-factory/shell/client'
7
+ import { OxPrompt } from '@operato/popup/ox-prompt.js'
8
8
 
9
9
  @customElement('role-privilege-editor')
10
10
  class RolePrivilegeEditor extends localize(i18next)(LitElement) {
@@ -51,14 +51,15 @@ class RolePrivilegeEditor extends localize(i18next)(LitElement) {
51
51
 
52
52
  [buttons] {
53
53
  margin: 0;
54
- padding: var(--padding-default);
54
+ padding: 5px;
55
55
  background-color: rgba(var(--primary-color-rgb), 0.2);
56
56
  }
57
57
 
58
58
  mwc-button {
59
+ margin: 5px;
59
60
  background-color: var(--theme-white-color);
60
- overflow: hidden;
61
61
  }
62
+
62
63
  [danger] {
63
64
  --mdc-theme-primary: var(--mdc-danger-button-primary-color);
64
65
  }
@@ -172,34 +173,34 @@ class RolePrivilegeEditor extends localize(i18next)(LitElement) {
172
173
  }
173
174
 
174
175
  async onDeleteRole() {
175
- const answer = await CustomAlert({
176
- title: i18next.t('text.are_you_sure'),
177
- text: i18next.t('text.are_you_sure_to_delete_x', { x: i18next.t('label.role') }),
178
- confirmButton: { text: i18next.t('button.delete') },
179
- cancelButton: { text: i18next.t('button.cancel') }
180
- })
181
-
182
- if (!answer.value) return
183
-
184
- const response = await client.mutate({
185
- mutation: gql`
186
- mutation ($id: String!) {
187
- deleteRole(id: $id)
188
- }
189
- `,
190
- variables: { id: this.role.id },
191
- context: gqlContext()
192
- })
176
+ if (
177
+ await OxPrompt.open({
178
+ title: i18next.t('text.are_you_sure'),
179
+ text: i18next.t('text.are_you_sure_to_delete_x', { x: i18next.t('label.role') }),
180
+ confirmButton: { text: i18next.t('button.delete') },
181
+ cancelButton: { text: i18next.t('button.cancel') }
182
+ })
183
+ ) {
184
+ const response = await client.mutate({
185
+ mutation: gql`
186
+ mutation ($id: String!) {
187
+ deleteRole(id: $id)
188
+ }
189
+ `,
190
+ variables: { id: this.role.id },
191
+ context: gqlContext()
192
+ })
193
193
 
194
- if (!response.errors) {
195
- await this.dispatchEvent(new CustomEvent('fetch-roles'))
194
+ if (!response.errors) {
195
+ await this.dispatchEvent(new CustomEvent('fetch-roles'))
196
196
 
197
- await CustomAlert({
198
- type: 'success',
199
- title: i18next.t('text.completed'),
200
- text: i18next.t('text.x_deleted_successfully', { x: i18next.t('label.role') }),
201
- confirmButton: { text: i18next.t('button.confirm') }
202
- })
197
+ await OxPrompt.open({
198
+ type: 'success',
199
+ title: i18next.t('text.completed'),
200
+ text: i18next.t('text.x_deleted_successfully', { x: i18next.t('label.role') }),
201
+ confirmButton: { text: i18next.t('button.confirm') }
202
+ })
203
+ }
203
204
  }
204
205
  }
205
206
 
@@ -1,4 +1,4 @@
1
- import { css, html, LitElement } from 'lit'
1
+ import { css, html, LitElement, nothing } from 'lit'
2
2
  import { customElement, property } from 'lit/decorators.js'
3
3
 
4
4
  @customElement('role-selector')
@@ -59,7 +59,7 @@ export class RoleSelector extends LitElement {
59
59
  ${this.roles.length
60
60
  ? html`
61
61
  <div>
62
- <h3 subtitle>${this.roleCategory}</h3>
62
+ ${this.roleCategory ? html`<h3 subtitle>${this.roleCategory}</h3>` : nothing}
63
63
  <input id="checkAll" type="checkbox" @change=${this.checkAll.bind(this)} />
64
64
  <label for="checkAll">Check all</label>
65
65
  </div>