Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable28] Small UI fixes #2259

Merged
merged 11 commits into from
Feb 2, 2024
20 changes: 10 additions & 10 deletions lib/Helper/JSActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
namespace OCA\Libresign\Helper;

final class JSActions {
public const ACTION_REDIRECT = 100;
public const ACTION_CREATE_USER = 150;
public const ACTION_DO_NOTHING = 200;
public const ACTION_SIGN = 250;
public const ACTION_SIGN_ACCOUNT_FILE = 275;
public const ACTION_SHOW_ERROR = 300;
public const ACTION_SIGNED = 350;
public const ACTION_CREATE_SIGNATURE_PASSWORD = 400;
public const ACTION_RENEW_EMAIL = 450;
public const ACTION_INCOMPLETE_SETUP = 500;
public const ACTION_REDIRECT = 1000;
public const ACTION_CREATE_USER = 1500;
public const ACTION_DO_NOTHING = 2000;
public const ACTION_SIGN = 2500;
public const ACTION_SIGN_ACCOUNT_FILE = 2750;
public const ACTION_SHOW_ERROR = 3000;
public const ACTION_SIGNED = 3500;
public const ACTION_CREATE_SIGNATURE_PASSWORD = 4000;
public const ACTION_RENEW_EMAIL = 4500;
public const ACTION_INCOMPLETE_SETUP = 5000;
}
4 changes: 4 additions & 0 deletions src/Components/PdfEditor/PdfEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ export default {
audio, canvas, embed, iframe, img, object, svg, video {
display: unset;
}

canvas {
border-bottom: 2px solid #eee;
}
</style>
1 change: 1 addition & 0 deletions src/Components/Request/RequestSignature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
</template>
</Signers>
<NcButton v-if="canSave"
type="primary"
@click="save()">
{{ t('libresign', 'Next') }}
</NcButton>
Expand Down
5 changes: 3 additions & 2 deletions src/Components/Request/VisibleElements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</template>

<script>
import { showError } from '@nextcloud/dialogs'
import { showError, showSuccess } from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'
Expand Down Expand Up @@ -234,7 +234,7 @@ export default {
})
})
})
await axios.patch(generateOcsUrl('/apps/libresign/api/v1/request-signature'), {
const response = await axios.patch(generateOcsUrl('/apps/libresign/api/v1/request-signature'), {
users: [],
// Only add to array if not empty
...(this.file.uuid && { uuid: this.file.uuid }),
Expand All @@ -243,6 +243,7 @@ export default {
status: 0,
})
this.showConfirm = false
showSuccess(t('libresign', response.data.message))
this.closeModal()
} catch (err) {
this.onError(err)
Expand Down
20 changes: 10 additions & 10 deletions src/helpers/SelectAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ const redirectURL = loadState('libresign', 'redirect', 'Home')

export const selectAction = (action) => {
switch (action) {
case 100: // ACTION_REDIRECT
case 1000: // ACTION_REDIRECT
window.location.replace(redirectURL.toString())
break
case 150: // ACTION_CREATE_USER
case 1500: // ACTION_CREATE_USER
return 'CreateUser'
case 200: // ACTION_DO_NOTHING
case 2000: // ACTION_DO_NOTHING
return 'DefaultPageError'
case 250: // ACTION_SIGN
case 2500: // ACTION_SIGN
return 'SignPDF'
case 275: // ACTION_SIGN_ACCOUNT_FILE
case 2750: // ACTION_SIGN_ACCOUNT_FILE
return 'AccountFileApprove'
case 300: // ACTION_SHOW_ERROR
case 3000: // ACTION_SHOW_ERROR
return 'DefaultPageSuccess'
case 350: // ACTION_SIGNED
case 3500: // ACTION_SIGNED
return 'DefaultPageSuccess'
case 400: // ACTION_CREATE_SIGNATURE_PASSWORD
case 4000: // ACTION_CREATE_SIGNATURE_PASSWORD
return 'CreatePassword'
case 450: // ACTION_RENEW_EMAIL
case 4500: // ACTION_RENEW_EMAIL
return 'RenewEmail'
case 500: // ACTION_INCOMPLETE_SETUP
case 5000: // ACTION_INCOMPLETE_SETUP
return 'incomplete'
default:
break
Expand Down
5 changes: 5 additions & 0 deletions src/views/Request.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export default {
} catch (err) {
this.error = err.response.data.errors
this.loading = false
onError(err)
return
}
await this.closeModalUploadFromUrl()
Expand Down Expand Up @@ -319,4 +320,8 @@ button {
background-position-x: 8%;
padding: 13px 13px 13px 45px;
}

h2 {
font-weight: bold;
}
</style>
2 changes: 1 addition & 1 deletion src/views/Settings/RootCertificateCfssl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</tr>
</tbody>
</table>
<NcButton @click="showModal">
<NcButton type="primary" @click="showModal">
{{ t('libresign', 'Regenerate root certificate') }}
</NcButton>
<NcModal v-if="modal"
Expand Down
3 changes: 2 additions & 1 deletion src/views/Settings/RootCertificateOpenSsl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</tr>
</tbody>
</table>
<NcButton @click="showModal">
<NcButton type="primary" @click="showModal">
{{ t('libresign', 'Regenerate root certificate') }}
</NcButton>
<NcModal v-if="modal"
Expand Down Expand Up @@ -92,6 +92,7 @@
:disabled="formDisabled" />
</div>
<NcButton :disabled="formDisabled"
type="primary"
@click="generateCertificate">
{{ submitLabel }}
</NcButton>
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Controller/AEnvironmentPageAwareControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testLoadFileUuidWithEmptyUuid(): void {
$this->expectException(LibresignException::class);
$this->getExpectedExceptionCode(404);
$this->expectExceptionMessage(json_encode([
'action' => 200,
'action' => 2000,
'errors' => ['Invalid UUID'],
]));
$this->controller->loadNextcloudFileFromSignRequestUuid('');
Expand Down Expand Up @@ -111,7 +111,7 @@ public function testLoadFileUuidWhenFileNotFound(): void {
$this->expectException(LibresignException::class);
$this->getExpectedExceptionCode(404);
$this->expectExceptionMessage(json_encode([
'action' => 200,
'action' => 2000,
'errors' => ['File not found'],
]));

Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Middleware/InjectionMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function testAfterException(string $message, int $code, string $exception
public static function providerAfterException(): array {
return [
[
json_encode(['action' => 100]), 1, LibresignException::class,
json_encode(['action' => 1000]), 1, LibresignException::class,
function (self $self, $message, int $code, $actual) {
/** @var JSONResponse $actual */
$self->assertInstanceOf(
Expand Down Expand Up @@ -182,7 +182,7 @@ function (self $self, $message, int $code, $actual) {
},
],
[
json_encode(['action' => 100]), 1, PageException::class,
json_encode(['action' => 1000]), 1, PageException::class,
function (self $self, $message, int $code, $actual) {
/** @var TemplateResponse $actual */
$self->assertInstanceOf(
Expand All @@ -193,7 +193,7 @@ function (self $self, $message, int $code, $actual) {
$states = $self->initialStateService->getInitialStates();
$self->assertJsonStringEqualsJsonString(
json_encode([
'libresign-action' => '100',
'libresign-action' => '1000',
]),
json_encode($states),
'Invalid response params content'
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/features/account/create_to_sign.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: account/create_to_sign
And the response should have a status code 422
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 150 |
| action | 1500 |
Then sending "post" to ocs "/apps/libresign/api/v1/account/create/<SIGN_UUID>"
| uuid | <SIGN_UUID> |
| email | invalid@domain.test |
Expand All @@ -30,7 +30,7 @@ Feature: account/create_to_sign
And the response should be a JSON array with the following mandatory values
| key | value |
| message | This is not your file |
| action | 200 |
| action | 2000 |


Scenario: Create with valid data
Expand All @@ -42,7 +42,7 @@ Feature: account/create_to_sign
And the response should have a status code 422
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 150 |
| action | 1500 |
Then sending "post" to ocs "/apps/libresign/api/v1/account/create/<SIGN_UUID>"
| uuid | <SIGN_UUID> |
| email | signer1@domain.test |
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/features/page/sign_identify_account.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ Feature: page/sign_identify_account
Then the response should have a status code 404
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 200 |
| action | 2000 |
| errors | ["Invalid UUID"] |
# invalid user
When as user "admin"
And sending "get" to "/apps/libresign/p/sign/<SIGN_UUID>"
Then the response should have a status code 422
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 200 |
| action | 2000 |
| errors | ["Invalid user"] |
# unauthenticated user
When as user ""
And sending "get" to "/apps/libresign/p/sign/<SIGN_UUID>"
Then the response should have a status code 422
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 100 |
| action | 1000 |
| errors | ["You are not logged in. Please log in."] |

Scenario: Open sign file with all data valid
Expand Down Expand Up @@ -91,7 +91,7 @@ Feature: page/sign_identify_account
And sending "get" to "/apps/libresign/p/sign/<SIGN_UUID>"
And the response should contain the initial state "libresign-action" with the following values:
"""
250
2500
"""
And the response should contain the initial state "libresign-pdf" with the following values:
"""
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/features/sign/request.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: request-signature
Then the response should have a status code 422
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 200 |
| action | 2000 |
| errors | ["You are not allowed to request signing"] |

Scenario: Get error when try to request to sign without file name
Expand Down Expand Up @@ -45,7 +45,7 @@ Feature: request-signature
Then the response should have a status code 422
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 200 |
| action | 2000 |
| errors | ["Invalid user"] |

Scenario: Request to sign with error when the user is not authenticated
Expand All @@ -65,7 +65,7 @@ Feature: request-signature
Then the response should have a status code 422
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 100 |
| action | 1000 |
| errors | ["You are not logged in. Please log in."] |

Scenario: Request to sign with error when the authenticated user have an email different of signer
Expand All @@ -89,7 +89,7 @@ Feature: request-signature
Then the response should have a status code 422
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 100 |
| action | 1000 |
| errors | ["User already exists. Please login."] |

Scenario: Request to sign with error when the link was expired
Expand All @@ -112,7 +112,7 @@ Feature: request-signature
Then the response should have a status code 422
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 200 |
| action | 2000 |
| errors | ["Link expired."] |

Scenario: Request to sign with success when is necessary to renew the link
Expand All @@ -138,7 +138,7 @@ Feature: request-signature
Then the response should have a status code 422
And the response should be a JSON array with the following mandatory values
| key | value |
| action | 450 |
| action | 4500 |
| title | Link expired |
Given my inbox is empty
When sending "post" to ocs "/apps/libresign/api/v1/sign/uuid/<SIGN_UUID>/renew/email"
Expand All @@ -164,7 +164,7 @@ Feature: request-signature
Then the response should have a status code 200
And the response should contain the initial state "libresign-action" with the following values:
"""
250
2500
"""

Scenario: Request to sign with error using account as identifier when the user don't exists
Expand Down
Loading