Skip to content

Commit

Permalink
small fix: don't allow edit on published iterations (for decision thr…
Browse files Browse the repository at this point in the history
…esholds)
  • Loading branch information
Pascal-Delange authored and balzdur committed Jul 12, 2023
1 parent 7daa7f2 commit f91535e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/app-builder/public/locales/en/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"logical_operator.if": "if",
"logical_operator.and": "and",
"logical_operator.where": "where",
"edit.forbidden_not_draft": "You can only edit a draft version of a scenario.",
"operator.is_in": "is in",
"false": "false",
"true": "true",
Expand Down
1 change: 1 addition & 0 deletions packages/app-builder/public/locales/fr/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"deployment_modal_success.deactivate.title": "Version désactivée",
"deployment_modal_success.reactivate.description": "Un duplicata de cette version a été créé et activé avec succès. \nIl fonctionne maintenant sur des données en direct.",
"deployment_modal_success.reactivate.title": "Version réactivée",
"edit.forbidden_not_draft": "Vous ne pouvez modifier qu'une version brouillon d'un scénario.",
"draft": "brouillon",
"empty_scenario_list": "Contactez Marble pour créer votre premier scénario.",
"false": "FAUX",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,12 @@ export async function action({ request, params }: ActionArgs) {
export default function Decision() {
const { t } = useTranslation(handle.i18n);
const {
version,
body: { scoreRejectThreshold, scoreReviewThreshold },
} = useCurrentScenarioIteration();
const submit = useSubmit();
const isEditable = version === null;
const hoverLabel = isEditable ? '' : t('scenarios:edit.forbidden_not_draft');

const {
control,
Expand Down Expand Up @@ -123,9 +126,11 @@ export default function Decision() {
<div className="flex flex-row items-center gap-1 lg:gap-2">
{t('scenarios:decision.score_based.approve_condition')}
<Input
title={hoverLabel}
{...register('thresholds.0')}
type="number"
className="relative w-fit"
disabled={!isEditable}
/>
</div>

Expand All @@ -136,12 +141,16 @@ export default function Decision() {
<div className="flex flex-row items-center gap-1 lg:gap-2">
{t('scenarios:decision.score_based.decline_condition')}
<Input
title={hoverLabel}
className="relative w-fit"
{...register('thresholds.1')}
type="number"
disabled={!isEditable}
/>
</div>
<Button type="submit">Submit</Button>
<Button type="submit" title={hoverLabel} disabled={!isEditable}>
Submit
</Button>
{errors.thresholds?.message && (
<div className="bg-grey-00 text-s text-red-100">
{errors.thresholds?.message}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-builder/src/services/auth/firebase.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function getServerAuth({ sessionStorage }: FirebaseStrategyOptions) {
idToken: z.string(),
})
);

console.log(idToken);
await verifyAuthenticityToken(request, session);

const marbleToken = await marbleApi.postToken(
Expand Down

0 comments on commit f91535e

Please sign in to comment.