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

Allow the reservation email frontend to be blank #1023

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions charts/traction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ kubectl delete secret,pvc --selector "app.kubernetes.io/instance"=my-release
| `ui.enabled` | Deploy tenant-ui | `true` |
| `ui.showOIDCReservationLogin` | Use OIDC to make reservations | `false` |
| `ui.quickConnectEndorserName` | Flag a ledger as auto-accept/endorse so the Tenant UI can quick connect | `""` |
| `ui.requireEmailForReservation` | Whether the Email field is needed for a reservation (if false will default [email protected] to API) | `true` |
| `ui.image.repository` | | `ghcr.io/bcgov/traction-tenant-ui` |
| `ui.image.pullPolicy` | | `IfNotPresent` |
| `ui.image.pullSecrets` | | `[]` |
Expand Down
1 change: 1 addition & 0 deletions charts/traction/templates/ui/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ data:
FRONTEND_TENANT_SHOW_WRITABLE_COMPONENTS: {{ .Values.ui.oidc.showWritableComponents | quote }}
FRONTEND_SHOW_OIDC_RESERVATION_LOGIN: {{ .Values.ui.showOIDCReservationLogin | quote }}
FRONTEND_QUICK_CONNECT_ENDORSER_NAME: {{ .Values.ui.quickConnectEndorserName | quote }}
FRONTEND_REQUIRE_EMAIL_FOR_RESERVATION: {{ .Values.ui.requireEmailForReservation | quote }}
FRONTEND_SESSION_TIMEOUT_SECONDS: {{ .Values.ui.oidc.session.timeoutSeconds | quote }}
FRONTEND_SESSION_COUNTDOWN_SECONDS: {{ .Values.ui.oidc.session.countdownSeconds | quote }}
FRONTEND_TENANT_PROXY_URL: https://{{ include "tenant_proxy.host" . }}
Expand Down
3 changes: 3 additions & 0 deletions charts/traction/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ ui:
showOIDCReservationLogin: false
## @param ui.oidc.quickConnectEndorserName A ledger that has endorser auto-accept/transact enabled
quickConnectEndorserName: ""
## @param ui.requireEmailForReservation Whether the Email field is needed for a tenant reservation
## If false will default [email protected] to API
requireEmailForReservation: true
image:
## @param ui.image.repository
repository: ghcr.io/bcgov/traction-tenant-ui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"showWritableComponents": "FRONTEND_TENANT_SHOW_WRITABLE_COMPONENTS",
"showOIDCReservationLogin": "FRONTEND_SHOW_OIDC_RESERVATION_LOGIN",
"quickConnectEndorserName": "FRONTEND_QUICK_CONNECT_ENDORSER_NAME",
"requireEmailForReservation": "FRONTEND_REQUIRE_EMAIL_FOR_RESERVATION",
"session": {
"timeoutSeconds": "FRONTEND_SESSION_TIMEOUT_SECONDS",
"countdownSeconds": "FRONTEND_SESSION_COUNTDOWN_SECONDS"
Expand Down
1 change: 1 addition & 0 deletions services/tenant-ui/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"showOIDCReservationLogin": false,
"showWritableComponents": true,
"quickConnectEndorserName": "",
"requireEmailForReservation": true,
"session": {
"timeoutSeconds": "600",
"countdownSeconds": "30"
Expand Down
10 changes: 5 additions & 5 deletions services/tenant-ui/config/forms/reservation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"formDataSchema": {
"type": "object",
"properties": {
"mySillyExtraValue": {
"organization": {
"type": "string"
}
},
"required": []
}
},
"formUISchema": {
"type": "VerticalLayout",
"elements": [
{
"type": "Control",
"scope": "#/properties/mySillyExtraValue"
"scope": "#/properties/organization",
"label": "Company/organization "
}
]
}
}
}
2 changes: 1 addition & 1 deletion services/tenant-ui/frontend/public/forms/reservation.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
}
]
}
}
}
17 changes: 15 additions & 2 deletions services/tenant-ui/frontend/src/components/reservation/Reserve.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,20 @@ import { useToast } from 'vue-toastification';
import { JsonForms, JsonFormsChangeEvent } from '@jsonforms/vue';
import { vanillaRenderers } from '@jsonforms/vue-vanilla';
// State
import { useReservationStore } from '@/store';
import { useConfigStore, useReservationStore } from '@/store';
import { storeToRefs } from 'pinia';
// Components
import { RESERVATION_STATUSES } from '@/helpers/constants';
import ShowWallet from './status/ShowWallet.vue';
import ReservationConfirmation from './ReservationConfirmation.vue';
import axios from 'axios';
import { stringOrBooleanTruthy } from '@/helpers';

const toast = useToast();

// State setup
const configStore = useConfigStore();
const { config } = storeToRefs(useConfigStore());
const reservationStore = useReservationStore();
const { loading, status } = storeToRefs(useReservationStore());

Expand Down Expand Up @@ -129,8 +132,11 @@ const manProperties = {
type: 'string',
},
};
const manRequired = ['tenantName'];
if (stringOrBooleanTruthy(config.value?.frontend?.requireEmailForReservation)) {
manRequired.push('emailAddress');
}

const manRequired = ['emailAddress', 'tenantName'];
const manElements = [
{
type: 'Control',
Expand Down Expand Up @@ -295,6 +301,13 @@ const handleSubmit = async (event: any) => {
tenant_name: tenantName,
context_data: contextData,
};
// If the email address is blank and not required, put a dummy value in.
if (
!emailAddress &&
!stringOrBooleanTruthy(config.value?.frontend?.requireEmailForReservation)
) {
formFields.value.contact_email = '[email protected]';
}

const res = await reservationStore.makeReservation(formFields.value);
reservationIdResult.value = res.reservation_id;
Expand Down
Loading