Skip to content

Commit

Permalink
[OP#49435] Nextcloud oauth section should not be disabled when the us…
Browse files Browse the repository at this point in the history
…er deletes the oauth credentials (#457)

* [#49435] Nextcloud oauth section should not be disabled when the user deletes the oauth credentials

https://community.openproject.org/work_packages/49435
Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix project folder form

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix and add unit tests

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

* fix the feature

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>

---------

Signed-off-by: Swikriti Tripathi <swikriti808@gmail.com>
  • Loading branch information
SwikritiT committed Aug 18, 2023
1 parent 3724f83 commit e7db73a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@
</NcButton>
</div>
</div>
<div v-if="!state.nc_oauth_client && isOPOAuthFormComplete && isOPOAuthFormInView && showDefaultManagedProjectFolders">
<NcButton data-test-id="reset-nc-oauth-btn"
@click="resetNcOauthValues">
<template #icon>
<AutoRenewIcon :size="20" />
</template>
{{ t('integration_openproject', 'Create Nextcloud OAuth values') }}
</NcButton>
</div>
</div>
<div class="project-folder-setup">
<FormHeading index="4"
Expand Down Expand Up @@ -576,6 +585,15 @@ export default {
this.formMode.ncOauth = F_MODES.VIEW
this.isFormCompleted.ncOauth = true
}
if (!this.state.nc_oauth_client
&& this.state.openproject_instance_url
&& this.state.openproject_client_id
&& this.state.openproject_client_secret
&& this.textLabelProjectFolderSetupButton === 'Keep current setup') {
this.showDefaultManagedProjectFolders = true
this.formMode.projectFolderSetUp = F_MODES.VIEW
this.isFormCompleted.projectFolderSetUp = true
}
if (this.formMode.ncOauth === F_MODES.VIEW) {
this.showDefaultManagedProjectFolders = true
}
Expand Down
25 changes: 25 additions & 0 deletions tests/jest/components/AdminSettings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ describe('AdminSettings.vue', () => {
openproject_client_id: 'abcd',
openproject_client_secret: 'abcdefgh',
nc_oauth_client: null,
fresh_project_folder_setup: true,
},
{
server: F_MODES.VIEW,
Expand Down Expand Up @@ -745,6 +746,30 @@ describe('AdminSettings.vue', () => {
})
})
})
describe('recreate button', () => {
it('should be displayed if nextcloud oauth credentials is empty and everything is set', async () => {
const wrapper = getMountedWrapper({
state: {
openproject_instance_url: 'http://openproject.com',
openproject_client_id: 'op-client-id',
openproject_client_secret: 'op-client-secret',
nc_oauth_client: null,
},
formMode: {
projectFolderSetUp: F_MODES.VIEW,
},
showDefaultManagedProjectFolders: true,
isFormCompleted: {
projectFolderSetUp: true,
},

})
const resetButton = wrapper.find(selectors.resetNcOAuthFormButton)
expect(resetButton.isVisible()).toBe(true)
expect(resetButton.text()).toBe('Create Nextcloud OAuth values')
wrapper.destroy()
})
})
describe('edit mode', () => {
it('should show the form and hide the field values', async () => {
const wrapper = getWrapper({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports[`AdminSettings.vue Nextcloud OAuth values form edit mode should show the
</ncbutton-stub>
</div>
</div>
<!---->
</div>
`;

Expand All @@ -27,6 +28,7 @@ exports[`AdminSettings.vue Nextcloud OAuth values form view mode with complete v
</ncbutton-stub>
</div>
</div>
<!---->
</div>
`;

Expand Down

0 comments on commit e7db73a

Please sign in to comment.