Skip to content

Commit 7435125

Browse files
authored
Merge pull request #56570 from nextcloud/artonge/debt/migrate_user_ldap_vu3
refactor(user_ldap): Migrate to Vue3
2 parents e0cadec + d4d6df5 commit 7435125

File tree

262 files changed

+1240
-1688
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+1240
-1688
lines changed

apps/user_ldap/lib/AppInfo/Application.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@
4545
use Psr\Log\LoggerInterface;
4646

4747
class Application extends App implements IBootstrap {
48+
public const APP_ID = 'user_ldap';
49+
4850
public function __construct() {
49-
parent::__construct('user_ldap');
51+
parent::__construct(self::APP_ID);
5052
$container = $this->getContainer();
5153

5254
/**

apps/user_ldap/lib/Settings/Admin.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
namespace OCA\User_LDAP\Settings;
88

9+
use OCA\User_LDAP\AppInfo\Application;
910
use OCA\User_LDAP\Configuration;
1011
use OCA\User_LDAP\Helper;
1112
use OCP\AppFramework\Http\TemplateResponse;
@@ -59,7 +60,9 @@ public function getForm(): TemplateResponse {
5960
$this->initialState->provideInitialState('ldapConfigs', $ldapConfigs);
6061
$this->initialState->provideInitialState('ldapModuleInstalled', function_exists('ldap_connect'));
6162

62-
return new TemplateResponse('user_ldap', 'settings', $parameters);
63+
\OCP\Util::addStyle(Application::APP_ID, 'settings-admin');
64+
\OCP\Util::addScript(Application::APP_ID, 'settings-admin');
65+
return new TemplateResponse(Application::APP_ID, 'settings', $parameters);
6366
}
6467

6568
public function getSection(): string {

apps/user_ldap/src/components/SettingsTabs/AdvancedTab.vue

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@
99

1010
<NcTextField
1111
autocomplete="off"
12-
:label=" t('user_ldap', 'Backup (Replica) Host')"
12+
:label="t('user_ldap', 'Backup (Replica) Host')"
1313
:value="ldapConfigProxy.ldapBackupHost"
1414
:helper-text="t('user_ldap', 'Give an optional backup host. It must be a replica of the main LDAP/AD server.')"
15-
@change.native="(event) => ldapConfigProxy.ldapBackupHost = event.target.value" />
15+
@change="(event) => ldapConfigProxy.ldapBackupHost = event.target.value" />
1616

1717
<NcTextField
1818
type="number"
1919
:value="ldapConfigProxy.ldapBackupPort"
20-
:label="t('user_ldap', 'Backup (Replica) Port') "
21-
@change.native="(event) => ldapConfigProxy.ldapBackupPort = event.target.value" />
20+
:label="t('user_ldap', 'Backup (Replica) Port')"
21+
@change="(event) => ldapConfigProxy.ldapBackupPort = event.target.value" />
2222

2323
<NcCheckboxRadioSwitch
24-
:checked="ldapConfigProxy.ldapOverrideMainServer === '1'"
24+
:model-value="ldapConfigProxy.ldapOverrideMainServer === '1'"
2525
type="switch"
2626
:aria-label="t('user_ldap', 'Only connect to the replica server.')"
27-
@update:checked="ldapConfigProxy.ldapOverrideMainServer = $event ? '1' : '0'">
27+
@update:model-value="ldapConfigProxy.ldapOverrideMainServer = $event ? '1' : '0'">
2828
{{ t('user_ldap', 'Disable Main Server') }}
2929
</NcCheckboxRadioSwitch>
3030

3131
<NcCheckboxRadioSwitch
32-
:checked="ldapConfigProxy.turnOffCertCheck === '1'"
32+
:model-value="ldapConfigProxy.turnOffCertCheck === '1'"
3333
:aria-label="t('user_ldap', 'Not recommended, use it for testing only! If connection only works with this option, import the LDAP server\'s SSL certificate in your {instanceName} server.', { instanceName })"
34-
@update:checked="ldapConfigProxy.turnOffCertCheck = $event ? '1' : '0'">
34+
@update:model-value="ldapConfigProxy.turnOffCertCheck = $event ? '1' : '0'">
3535
{{ t('user_ldap', 'Turn off SSL certificate validation.') }}
3636
</NcCheckboxRadioSwitch>
3737

@@ -40,7 +40,7 @@
4040
:label="t('user_ldap', 'Cache Time-To-Live')"
4141
:value="ldapConfigProxy.ldapCacheTTL"
4242
:helper-text="t('user_ldap', 'in seconds. A change empties the cache.')"
43-
@change.native="(event) => ldapConfigProxy.ldapCacheTTL = event.target.value" />
43+
@change="(event) => ldapConfigProxy.ldapCacheTTL = event.target.value" />
4444
</details>
4545

4646
<details name="ldap-wizard__advanced__section" class="ldap-wizard__advanced__section">
@@ -51,31 +51,31 @@
5151
:value="ldapConfigProxy.ldapUserDisplayName"
5252
:label="t('user_ldap', 'User Display Name Field')"
5353
:helper-text="t('user_ldap', 'The LDAP attribute to use to generate the user\'s display name.')"
54-
@change.native="(event) => ldapConfigProxy.ldapUserDisplayName = event.target.value" />
54+
@change="(event) => ldapConfigProxy.ldapUserDisplayName = event.target.value" />
5555

5656
<NcTextField
5757
autocomplete="off"
5858
:value="ldapConfigProxy.ldapUserDisplayName2"
5959
:label="t('user_ldap', '2nd User Display Name Field')"
6060
:helper-text="t('user_ldap', 'Optional. An LDAP attribute to be added to the display name in brackets. Results in e.g. »John Doe ([email protected])«.')"
61-
@change.native="(event) => ldapConfigProxy.ldapUserDisplayName2 = event.target.value" />
61+
@change="(event) => ldapConfigProxy.ldapUserDisplayName2 = event.target.value" />
6262

6363
<NcTextArea
64-
:value="ldapConfigProxy.ldapBaseUsers"
64+
:model-value="ldapConfigProxy.ldapBaseUsers"
6565
:placeholder="t('user_ldap', 'One User Base DN per line')"
6666
:label="t('user_ldap', 'Base User Tree')"
67-
@change.native="(event) => ldapConfigProxy.ldapBaseUsers = event.target.value" />
67+
@change="(event) => ldapConfigProxy.ldapBaseUsers = event.target.value" />
6868

6969
<NcTextArea
70-
:value="ldapConfigProxy.ldapAttributesForUserSearch"
70+
:model-value="ldapConfigProxy.ldapAttributesForUserSearch"
7171
:placeholder="t('user_ldap', 'Optional; one attribute per line')"
7272
:label="t('user_ldap', 'User Search Attributes')"
73-
@change.native="(event) => ldapConfigProxy.ldapAttributesForUserSearch = event.target.value" />
73+
@change="(event) => ldapConfigProxy.ldapAttributesForUserSearch = event.target.value" />
7474

7575
<NcCheckboxRadioSwitch
76-
:checked="ldapConfigProxy.markRemnantsAsDisabled === '1'"
76+
:model-value="ldapConfigProxy.markRemnantsAsDisabled === '1'"
7777
:aria-label="t('user_ldap', 'When switched on, users imported from LDAP which are then missing will be disabled')"
78-
@update:checked="ldapConfigProxy.markRemnantsAsDisabled = $event ? '1' : '0'">
78+
@update:model-value="ldapConfigProxy.markRemnantsAsDisabled = $event ? '1' : '0'">
7979
{{ t('user_ldap', 'Disable users missing from LDAP') }}
8080
</NcCheckboxRadioSwitch>
8181

@@ -84,19 +84,19 @@
8484
:value="ldapConfigProxy.ldapGroupDisplayName"
8585
:label="t('user_ldap', 'Group Display Name Field')"
8686
:title="t('user_ldap', 'The LDAP attribute to use to generate the groups\'s display name.')"
87-
@change.native="(event) => ldapConfigProxy.ldapGroupDisplayName = event.target.value" />
87+
@change="(event) => ldapConfigProxy.ldapGroupDisplayName = event.target.value" />
8888

8989
<NcTextArea
90-
:value="ldapConfigProxy.ldapBaseGroups"
90+
:model-value="ldapConfigProxy.ldapBaseGroups"
9191
:placeholder="t('user_ldap', 'One Group Base DN per line')"
9292
:label="t('user_ldap', 'Base Group Tree')"
93-
@change.native="(event) => ldapConfigProxy.ldapBaseGroups = event.target.value" />
93+
@change="(event) => ldapConfigProxy.ldapBaseGroups = event.target.value" />
9494

9595
<NcTextArea
96-
:value="ldapConfigProxy.ldapAttributesForGroupSearch"
96+
:model-value="ldapConfigProxy.ldapAttributesForGroupSearch"
9797
:placeholder="t('user_ldap', 'Optional; one attribute per line')"
9898
:label="t('user_ldap', 'Group Search Attributes')"
99-
@change.native="(event) => ldapConfigProxy.ldapAttributesForGroupSearch = event.target.value" />
99+
@change="(event) => ldapConfigProxy.ldapAttributesForGroupSearch = event.target.value" />
100100

101101
<NcSelect
102102
v-model="ldapConfigProxy.ldapGroupMemberAssocAttr"
@@ -115,12 +115,12 @@
115115
:label="t('user_ldap', 'Dynamic Group Member URL')"
116116
:value="ldapConfigProxy.ldapDynamicGroupMemberURL"
117117
:helper-text="t('user_ldap', 'The LDAP attribute that on group objects contains an LDAP search URL that determines what objects belong to the group. (An empty setting disables dynamic group membership functionality.)')"
118-
@change.native="(event) => ldapConfigProxy.ldapDynamicGroupMemberURL = event.target.value" />
118+
@change="(event) => ldapConfigProxy.ldapDynamicGroupMemberURL = event.target.value" />
119119

120120
<NcCheckboxRadioSwitch
121-
:checked="ldapConfigProxy.ldapNestedGroups === '1'"
121+
:model-value="ldapConfigProxy.ldapNestedGroups === '1'"
122122
:aria-label="t('user_ldap', 'When switched on, groups that contain groups are supported. (Only works if the group member attribute contains DNs.)')"
123-
@update:checked="ldapConfigProxy.ldapNestedGroups = $event ? '1' : '0'">
123+
@update:model-value="ldapConfigProxy.ldapNestedGroups = $event ? '1' : '0'">
124124
{{ t('user_ldap', 'Nested Groups') }}
125125
</NcCheckboxRadioSwitch>
126126

@@ -129,12 +129,12 @@
129129
:label="t('user_ldap', 'Paging chunksize')"
130130
:value="ldapConfigProxy.ldapPagingSize"
131131
:helper-text="t('user_ldap', 'Chunksize used for paged LDAP searches that may return bulky results like user or group enumeration. (Setting it 0 disables paged LDAP searches in those situations.)')"
132-
@change.native="(event) => ldapConfigProxy.ldapPagingSize = event.target.value" />
132+
@change="(event) => ldapConfigProxy.ldapPagingSize = event.target.value" />
133133

134134
<NcCheckboxRadioSwitch
135-
:checked="ldapConfigProxy.turnOnPasswordChange === '1'"
135+
:model-value="ldapConfigProxy.turnOnPasswordChange === '1'"
136136
:aria-label="t('user_ldap', 'Allow LDAP users to change their password and allow Super Administrators and Group Administrators to change the password of their LDAP users. Only works when access control policies are configured accordingly on the LDAP server. As passwords are sent in plaintext to the LDAP server, transport encryption must be used and password hashing should be configured on the LDAP server.')"
137-
@update:checked="ldapConfigProxy.turnOnPasswordChange = $event ? '1' : '0'">
137+
@update:model-value="ldapConfigProxy.turnOnPasswordChange = $event ? '1' : '0'">
138138
{{ t('user_ldap', 'Enable LDAP password changes per user') }}
139139
</NcCheckboxRadioSwitch>
140140
<span class="tablecell">
@@ -146,7 +146,7 @@
146146
:label="t('user_ldap', 'Default password policy DN')"
147147
:value="ldapConfigProxy.ldapDefaultPPolicyDN"
148148
:helper-text="t('user_ldap', 'The DN of a default password policy that will be used for password expiry handling. Works only when LDAP password changes per user are enabled and is only supported by OpenLDAP. Leave empty to disable password expiry handling.')"
149-
@change.native="(event) => ldapConfigProxy.ldapDefaultPPolicyDN = event.target.value" />
149+
@change="(event) => ldapConfigProxy.ldapDefaultPPolicyDN = event.target.value" />
150150
</details>
151151

152152
<details name="ldap-wizard__advanced__section" class="ldap-wizard__advanced__section">
@@ -157,35 +157,35 @@
157157
:value="ldapConfigProxy.ldapQuotaAttribute"
158158
:label="t('user_ldap', 'Quota Field')"
159159
:helper-text="t('user_ldap', 'Leave empty for user\'s default quota. Otherwise, specify an LDAP/AD attribute.')"
160-
@change.native="(event) => ldapConfigProxy.ldapQuotaAttribute = event.target.value" />
160+
@change="(event) => ldapConfigProxy.ldapQuotaAttribute = event.target.value" />
161161

162162
<NcTextField
163163
autocomplete="off"
164164
:value="ldapConfigProxy.ldapQuotaDefault"
165165
:label="t('user_ldap', 'Quota Default')"
166166
:helper-text="t('user_ldap', 'Override default quota for LDAP users who do not have a quota set in the Quota Field.')"
167-
@change.native="(event) => ldapConfigProxy.ldapQuotaDefault = event.target.value" />
167+
@change="(event) => ldapConfigProxy.ldapQuotaDefault = event.target.value" />
168168

169169
<NcTextField
170170
autocomplete="off"
171171
:value="ldapConfigProxy.ldapEmailAttribute"
172172
:label="t('user_ldap', 'Email Field')"
173173
:helper-text="t('user_ldap', 'Set the user\'s email from their LDAP attribute. Leave it empty for default behaviour.')"
174-
@change.native="(event) => ldapConfigProxy.ldapEmailAttribute = event.target.value" />
174+
@change="(event) => ldapConfigProxy.ldapEmailAttribute = event.target.value" />
175175

176176
<NcTextField
177177
autocomplete="off"
178178
:label="t('user_ldap', 'User Home Folder Naming Rule')"
179179
:value="ldapConfigProxy.homeFolderNamingRule"
180180
:helper-text="t('user_ldap', 'Leave empty for username (default). Otherwise, specify an LDAP/AD attribute.')"
181-
@change.native="(event) => ldapConfigProxy.homeFolderNamingRule = event.target.value" />
181+
@change="(event) => ldapConfigProxy.homeFolderNamingRule = event.target.value" />
182182

183183
<NcTextField
184184
autocomplete="off"
185185
:label="t('user_ldap', '`$home` Placeholder Field')"
186186
:value="ldapConfigProxy.ldapExtStorageHomeAttribute"
187187
:helper-text="t('user_ldap', '$home in an external storage configuration will be replaced with the value of the specified attribute')"
188-
@change.native="(event) => ldapConfigProxy.ldapExtStorageHomeAttribute = event.target.value" />
188+
@change="(event) => ldapConfigProxy.ldapExtStorageHomeAttribute = event.target.value" />
189189
</details>
190190

191191
<details name="ldap-wizard__advanced__section" class="ldap-wizard__advanced__section">
@@ -196,70 +196,70 @@
196196
:label="t('user_ldap', 'Phone Field')"
197197
:value="ldapConfigProxy.ldapAttributePhone"
198198
:helper-text="t('user_ldap', 'User profile Phone will be set from the specified attribute')"
199-
@change.native="(event) => ldapConfigProxy.ldapAttributePhone = event.target.value" />
199+
@change="(event) => ldapConfigProxy.ldapAttributePhone = event.target.value" />
200200

201201
<NcTextField
202202
autocomplete="off"
203203
:label="t('user_ldap', 'Website Field')"
204204
:value="ldapConfigProxy.ldapAttributeWebsite"
205205
:helper-text="t('user_ldap', 'User profile Website will be set from the specified attribute')"
206-
@change.native="(event) => ldapConfigProxy.ldapAttributeWebsite = event.target.value" />
206+
@change="(event) => ldapConfigProxy.ldapAttributeWebsite = event.target.value" />
207207

208208
<NcTextField
209209
autocomplete="off"
210210
:label="t('user_ldap', 'Address Field')"
211211
:value="ldapConfigProxy.ldapAttributeAddress"
212212
:helper-text="t('user_ldap', 'User profile Address will be set from the specified attribute')"
213-
@change.native="(event) => ldapConfigProxy.ldapAttributeAddress = event.target.value" />
213+
@change="(event) => ldapConfigProxy.ldapAttributeAddress = event.target.value" />
214214

215215
<NcTextField
216216
autocomplete="off"
217217
:label="t('user_ldap', 'Twitter Field')"
218218
:value="ldapConfigProxy.ldapAttributeTwitter"
219219
:helper-text="t('user_ldap', 'User profile Twitter will be set from the specified attribute')"
220-
@change.native="(event) => ldapConfigProxy.ldapAttributeTwitter = event.target.value" />
220+
@change="(event) => ldapConfigProxy.ldapAttributeTwitter = event.target.value" />
221221

222222
<NcTextField
223223
autocomplete="off"
224224
:label="t('user_ldap', 'Fediverse Field')"
225225
:value="ldapConfigProxy.ldapAttributeFediverse"
226226
:helper-text="t('user_ldap', 'User profile Fediverse will be set from the specified attribute')"
227-
@change.native="(event) => ldapConfigProxy.ldapAttributeFediverse = event.target.value" />
227+
@change="(event) => ldapConfigProxy.ldapAttributeFediverse = event.target.value" />
228228

229229
<NcTextField
230230
autocomplete="off"
231231
:label="t('user_ldap', 'Organisation Field')"
232232
:value="ldapConfigProxy.ldapAttributeOrganisation"
233233
:helper-text="t('user_ldap', 'User profile Organisation will be set from the specified attribute')"
234-
@change.native="(event) => ldapConfigProxy.ldapAttributeOrganisation = event.target.value" />
234+
@change="(event) => ldapConfigProxy.ldapAttributeOrganisation = event.target.value" />
235235

236236
<NcTextField
237237
autocomplete="off"
238238
:label="t('user_ldap', 'Role Field')"
239239
:value="ldapConfigProxy.ldapAttributeRole"
240240
:helper-text="t('user_ldap', 'User profile Role will be set from the specified attribute')"
241-
@change.native="(event) => ldapConfigProxy.ldapAttributeRole = event.target.value" />
241+
@change="(event) => ldapConfigProxy.ldapAttributeRole = event.target.value" />
242242

243243
<NcTextField
244244
autocomplete="off"
245245
:label="t('user_ldap', 'Headline Field')"
246246
:value="ldapConfigProxy.ldapAttributeHeadline"
247247
:helper-text="t('user_ldap', 'User profile Headline will be set from the specified attribute')"
248-
@change.native="(event) => ldapConfigProxy.ldapAttributeHeadline = event.target.value" />
248+
@change="(event) => ldapConfigProxy.ldapAttributeHeadline = event.target.value" />
249249

250250
<NcTextField
251251
autocomplete="off"
252252
:label="t('user_ldap', 'Biography Field')"
253253
:value="ldapConfigProxy.ldapAttributeBiography"
254254
:helper-text="t('user_ldap', 'User profile Biography will be set from the specified attribute')"
255-
@change.native="(event) => ldapConfigProxy.ldapAttributeBiography = event.target.value" />
255+
@change="(event) => ldapConfigProxy.ldapAttributeBiography = event.target.value" />
256256

257257
<NcTextField
258258
autocomplete="off"
259259
:label="t('user_ldap', 'Birthdate Field')"
260260
:value="ldapConfigProxy.ldapAttributeBirthDate"
261261
:helper-text="t('user_ldap', 'User profile Date of birth will be set from the specified attribute')"
262-
@change.native="(event) => ldapConfigProxy.ldapAttributeBirthDate = event.target.value" />
262+
@change="(event) => ldapConfigProxy.ldapAttributeBirthDate = event.target.value" />
263263
</details>
264264
</fieldset>
265265
</template>

apps/user_ldap/src/components/SettingsTabs/ExpertTab.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
autocomplete="off"
1515
:label="t('user_ldap', 'Internal Username Attribute:')"
1616
:value="ldapConfigProxy.ldapExpertUsernameAttr"
17-
:label-outside="true"
18-
@change.native="(event) => ldapConfigProxy.ldapExpertUsernameAttr = event.target.value" />
17+
@change="(event) => ldapConfigProxy.ldapExpertUsernameAttr = event.target.value" />
1918
</div>
2019

2120
<div class="ldap-wizard__expert__line">
@@ -28,12 +27,12 @@
2827
autocomplete="off"
2928
:label="t('user_ldap', 'UUID Attribute for Users')"
3029
:value="ldapConfigProxy.ldapExpertUUIDUserAttr"
31-
@change.native="(event) => ldapConfigProxy.ldapExpertUUIDUserAttr = event.target.value" />
30+
@change="(event) => ldapConfigProxy.ldapExpertUUIDUserAttr = event.target.value" />
3231
<NcTextField
3332
autocomplete="off"
3433
:label="t('user_ldap', 'UUID Attribute for Groups')"
3534
:value="ldapConfigProxy.ldapExpertUUIDGroupAttr"
36-
@change.native="(event) => ldapConfigProxy.ldapExpertUUIDGroupAttr = event.target.value" />
35+
@change="(event) => ldapConfigProxy.ldapExpertUUIDGroupAttr = event.target.value" />
3736
</div>
3837
</fieldset>
3938
</template>

apps/user_ldap/src/components/SettingsTabs/GroupsTab.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828

2929
<div class="ldap-wizard__groups__line ldap-wizard__groups__groups-filter">
3030
<NcCheckboxRadioSwitch
31-
:checked="ldapConfigProxy.ldapGroupFilterMode === '1'"
32-
@update:checked="toggleFilterMode">
31+
:model-value="ldapConfigProxy.ldapGroupFilterMode === '1'"
32+
@update:model-value="toggleFilterMode">
3333
{{ t('user_ldap', 'Edit LDAP Query') }}
3434
</NcCheckboxRadioSwitch>
3535

3636
<div v-if="ldapConfigProxy.ldapGroupFilterMode === '1'">
3737
<NcTextArea
38-
:value.sync="ldapConfigProxy.ldapGroupFilter"
38+
v-model="ldapConfigProxy.ldapGroupFilter"
3939
:placeholder="t('user_ldap', 'Edit LDAP Query')"
4040
:helper-text="t('user_ldap', 'The filter specifies which LDAP groups shall have access to the {instanceName} instance.', { instanceName })" />
4141
</div>
@@ -96,10 +96,10 @@ const ldapGroupFilterGroups = computed({
9696
*/
9797
async function init() {
9898
const response1 = await callWizard('determineGroupObjectClasses', props.configId)
99-
groupObjectClasses.value = response1.options!.ldap_groupfilter_objectclass
99+
groupObjectClasses.value = response1.options?.ldap_groupfilter_objectclass ?? []
100100
101101
const response2 = await callWizard('determineGroupsForGroups', props.configId)
102-
groupGroups.value = response2.options!.ldap_groupfilter_groups
102+
groupGroups.value = response2.options?.ldap_groupfilter_groups ?? []
103103
}
104104
105105
init()
@@ -110,7 +110,7 @@ init()
110110
async function getGroupFilter() {
111111
const response = await callWizard('getGroupFilter', props.configId)
112112
// Not using ldapConfig to avoid triggering the save logic.
113-
ldapConfigs.value[props.configId].ldapGroupFilter = response.changes!.ldap_group_filter as string
113+
ldapConfigs.value[props.configId]!.ldapGroupFilter = (response.changes?.ldap_group_filter as string | undefined) ?? ''
114114
}
115115
116116
/**

0 commit comments

Comments
 (0)