Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb28de4d5e | ||
|
|
eb754d12c3 |
@@ -80,6 +80,12 @@ tasks:
|
||||
OPEN: '{{.OPEN | default ""}}'
|
||||
env:
|
||||
BACKEND_URL: '{{.BACKEND_URL}}'
|
||||
# Dev-only browser-tab label so concurrent worktrees are distinguishable.
|
||||
# Only the worktree folder basename (e.g. "wt1") is exposed — never the
|
||||
# full path, hostname, or user. Consumed at dev-serve time by vite.config
|
||||
# and dropped from production builds.
|
||||
STIRLING_DEV_LABEL:
|
||||
sh: basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
|
||||
cmds:
|
||||
- npx vite editor --mode {{.MODE}} --port {{.PORT}}{{if .OPEN}} --open{{end}}
|
||||
|
||||
|
||||
+16
-86
@@ -32,8 +32,6 @@ import stirling.software.proprietary.security.repository.TeamMembershipRepositor
|
||||
import stirling.software.saas.procurement.config.ProcurementConfigurationProperties;
|
||||
import stirling.software.saas.procurement.model.ProcurementDeal;
|
||||
import stirling.software.saas.procurement.model.ProcurementQuote;
|
||||
import stirling.software.saas.procurement.model.QuoteDetails;
|
||||
import stirling.software.saas.procurement.pricing.ProcurementPricingService;
|
||||
import stirling.software.saas.procurement.pricing.QuoteConfig;
|
||||
import stirling.software.saas.procurement.pricing.QuoteLineItem;
|
||||
import stirling.software.saas.procurement.service.ProcurementService;
|
||||
@@ -58,19 +56,16 @@ public class ProcurementController {
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
private final ProcurementService procurement;
|
||||
private final ProcurementPricingService pricing;
|
||||
private final TeamMembershipRepository memberRepo;
|
||||
private final UserRepository userRepository;
|
||||
private final ProcurementConfigurationProperties config;
|
||||
|
||||
public ProcurementController(
|
||||
ProcurementService procurement,
|
||||
ProcurementPricingService pricing,
|
||||
TeamMembershipRepository memberRepo,
|
||||
UserRepository userRepository,
|
||||
ProcurementConfigurationProperties config) {
|
||||
this.procurement = Objects.requireNonNull(procurement);
|
||||
this.pricing = Objects.requireNonNull(pricing);
|
||||
this.memberRepo = Objects.requireNonNull(memberRepo);
|
||||
this.userRepository = Objects.requireNonNull(userRepository);
|
||||
this.config = Objects.requireNonNull(config);
|
||||
@@ -82,53 +77,29 @@ public class ProcurementController {
|
||||
long volume,
|
||||
int users,
|
||||
int intensity, // policy posture (runs/PDF): 2 / 4 / 7; 0 → default Governed
|
||||
double sizeMult, // PDF-size tier multiplier: 1.0 / 1.4 / 2.4; 0 → no uplift
|
||||
String deployment,
|
||||
int termYears,
|
||||
String serviceLevel,
|
||||
boolean indemnification,
|
||||
boolean training,
|
||||
boolean qbr,
|
||||
boolean offlineLicense,
|
||||
String currency,
|
||||
String businessName,
|
||||
// Buyer / AP details (all optional). Country + currency intentionally out of scope.
|
||||
String contactName,
|
||||
String contactEmail,
|
||||
String addressLine1,
|
||||
String addressLine2,
|
||||
String city,
|
||||
String region,
|
||||
String postalCode,
|
||||
String poNumber,
|
||||
String taxId) {
|
||||
String businessName) {
|
||||
QuoteConfig toConfig() {
|
||||
return new QuoteConfig(
|
||||
volume,
|
||||
users,
|
||||
intensity,
|
||||
sizeMult,
|
||||
deployment,
|
||||
termYears,
|
||||
serviceLevel,
|
||||
indemnification,
|
||||
training,
|
||||
qbr,
|
||||
offlineLicense,
|
||||
currency);
|
||||
}
|
||||
|
||||
QuoteDetails toDetails() {
|
||||
return new QuoteDetails(
|
||||
businessName,
|
||||
contactName,
|
||||
contactEmail,
|
||||
addressLine1,
|
||||
addressLine2,
|
||||
city,
|
||||
region,
|
||||
postalCode,
|
||||
poNumber,
|
||||
taxId);
|
||||
}
|
||||
}
|
||||
|
||||
public record QuoteResponse(
|
||||
@@ -138,15 +109,10 @@ public class ProcurementController {
|
||||
String currency,
|
||||
long annualNetMinor,
|
||||
long tcvMinor,
|
||||
// First post-term renewal fee after the CPI escalator, and that escalator as a whole
|
||||
// percent — the committed term is flat, so these describe only the auto-renewal.
|
||||
long renewalAnnualNetMinor,
|
||||
int cpiRatePct,
|
||||
List<QuoteLineItem> lineItems,
|
||||
String validUntil,
|
||||
String stripeQuoteId,
|
||||
String invoiceUrl,
|
||||
String invoicePdf,
|
||||
QuoteConfigEcho config) {}
|
||||
|
||||
/**
|
||||
@@ -158,33 +124,19 @@ public class ProcurementController {
|
||||
long volume,
|
||||
int users,
|
||||
int intensity,
|
||||
double sizeMult,
|
||||
String deployment,
|
||||
int termYears,
|
||||
String serviceLevel,
|
||||
boolean indemnification,
|
||||
boolean training,
|
||||
boolean qbr,
|
||||
boolean offlineLicense,
|
||||
String currency,
|
||||
String businessName,
|
||||
String contactName,
|
||||
String contactEmail,
|
||||
String addressLine1,
|
||||
String addressLine2,
|
||||
String city,
|
||||
String region,
|
||||
String postalCode,
|
||||
String poNumber,
|
||||
String taxId) {}
|
||||
|
||||
/** Trial setup captured before the trial starts: deployment target + seat count. */
|
||||
public record StartTrialRequest(String deployment, int users) {}
|
||||
String businessName) {}
|
||||
|
||||
public record SnapshotResponse(
|
||||
Long dealId,
|
||||
String stage,
|
||||
String deployment,
|
||||
int seats,
|
||||
String trialStartedAt,
|
||||
String trialEndsAt,
|
||||
int trialExtensionsUsed,
|
||||
@@ -213,12 +165,12 @@ public class ProcurementController {
|
||||
}
|
||||
|
||||
private static final SnapshotResponse EMPTY_SNAPSHOT =
|
||||
new SnapshotResponse(null, null, null, 0, null, null, 0, false, null, null);
|
||||
new SnapshotResponse(null, null, null, null, 0, false, null, null);
|
||||
|
||||
/**
|
||||
* Download the offline / air-gapped licence file (.lic) for the team — available for an
|
||||
* air-gapped deployment from the trial licence onward. 404 when there's no licence yet or the
|
||||
* deployment isn't air-gapped, so we don't leak that a licence exists.
|
||||
* Download the offline / air-gapped licence file (.lic) for the team, when the paid offline
|
||||
* add-on was purchased. 404 when there's no licence or the add-on wasn't taken — we don't leak
|
||||
* that a licence exists to a team without the add-on.
|
||||
*/
|
||||
@GetMapping("/license/file")
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@@ -241,15 +193,10 @@ public class ProcurementController {
|
||||
|
||||
@PostMapping("/trial/start")
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
public ResponseEntity<SnapshotResponse> startTrial(
|
||||
@RequestBody(required = false) StartTrialRequest request, Authentication auth) {
|
||||
public ResponseEntity<SnapshotResponse> startTrial(Authentication auth) {
|
||||
Long teamId = requireLeader(auth);
|
||||
if (teamId == null) return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
||||
// Body is optional so an older client (no setup step) still starts a cloud trial.
|
||||
String deployment = request != null ? request.deployment() : null;
|
||||
int seats = request != null ? request.users() : 0;
|
||||
return ResponseEntity.ok(
|
||||
toSnapshot(procurement.startTrial(teamId, deployment, seats), true));
|
||||
return ResponseEntity.ok(toSnapshot(procurement.startTrial(teamId), true));
|
||||
}
|
||||
|
||||
@PostMapping("/trial/extend")
|
||||
@@ -271,7 +218,9 @@ public class ProcurementController {
|
||||
Long teamId = requireLeader(auth);
|
||||
if (teamId == null) return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
|
||||
return ResponseEntity.ok(
|
||||
toQuote(procurement.buildQuote(teamId, request.toConfig(), request.toDetails())));
|
||||
toQuote(
|
||||
procurement.buildQuote(
|
||||
teamId, request.toConfig(), request.businessName())));
|
||||
}
|
||||
|
||||
// Issue + accept are Supabase edge functions (they own Stripe): issue-procurement-quote turns a
|
||||
@@ -374,8 +323,6 @@ public class ProcurementController {
|
||||
return new SnapshotResponse(
|
||||
deal.getDealId(),
|
||||
deal.getStage(),
|
||||
deal.getDeployment(),
|
||||
deal.getSeats(),
|
||||
str(deal.getTrialStartedAt()),
|
||||
str(deal.getTrialEndsAt()),
|
||||
deal.getTrialExtensionsUsed(),
|
||||
@@ -392,40 +339,23 @@ public class ProcurementController {
|
||||
q.getCurrency(),
|
||||
q.getAnnualNetMinor(),
|
||||
q.getTcvMinor(),
|
||||
// Prefer the renewal locked at quote time; fall back to a live projection for
|
||||
// quotes
|
||||
// priced before the column existed.
|
||||
q.getRenewalAnnualMinor() > 0
|
||||
? q.getRenewalAnnualMinor()
|
||||
: pricing.renewalAnnualMinor(q.getAnnualNetMinor()),
|
||||
pricing.cpiRatePct(),
|
||||
parseLineItems(q.getLineItemsJson()),
|
||||
q.getValidUntil() == null ? null : q.getValidUntil().toString(),
|
||||
q.getStripeQuoteId(),
|
||||
q.getStripeInvoiceUrl(),
|
||||
q.getStripeInvoicePdf(),
|
||||
new QuoteConfigEcho(
|
||||
q.getVolume(),
|
||||
0,
|
||||
q.getIntensity(),
|
||||
q.getSizeMult(),
|
||||
q.getDeployment(),
|
||||
q.getTermYears(),
|
||||
q.getServiceLevel(),
|
||||
q.isIndemnification(),
|
||||
q.isTraining(),
|
||||
q.isQbr(),
|
||||
q.isOfflineLicense(),
|
||||
q.getCurrency(),
|
||||
q.getBusinessName(),
|
||||
q.getContactName(),
|
||||
q.getContactEmail(),
|
||||
q.getAddressLine1(),
|
||||
q.getAddressLine2(),
|
||||
q.getCity(),
|
||||
q.getRegion(),
|
||||
q.getPostalCode(),
|
||||
q.getPoNumber(),
|
||||
q.getTaxId()));
|
||||
q.getBusinessName()));
|
||||
}
|
||||
|
||||
private List<QuoteLineItem> parseLineItems(String json) {
|
||||
|
||||
@@ -51,15 +51,6 @@ public class ProcurementDeal implements Serializable {
|
||||
@Column(name = "stage", nullable = false, length = 32)
|
||||
private String stage = STAGE_TRIAL;
|
||||
|
||||
// Deployment target + seat count captured at trial start (the setup step); they seed the quote
|
||||
// builder so it opens on the buyer's real environment. The quote remains the commercial source
|
||||
// of truth — these are just the starting point, editable when the quote is built.
|
||||
@Column(name = "deployment", nullable = false, length = 16)
|
||||
private String deployment = "cloud";
|
||||
|
||||
@Column(name = "seats", nullable = false)
|
||||
private int seats;
|
||||
|
||||
@Column(name = "trial_started_at")
|
||||
private LocalDateTime trialStartedAt;
|
||||
|
||||
|
||||
+3
-46
@@ -66,10 +66,6 @@ public class ProcurementQuote implements Serializable {
|
||||
@Column(name = "intensity", nullable = false)
|
||||
private int intensity = 4;
|
||||
|
||||
/** File-size tier multiplier on the rate (D93): Compact 1.0, Standard 1.4, Heavy 2.4. */
|
||||
@Column(name = "size_mult", nullable = false)
|
||||
private double sizeMult = 1.0;
|
||||
|
||||
@Column(name = "deployment", length = 24)
|
||||
private String deployment;
|
||||
|
||||
@@ -88,17 +84,15 @@ public class ProcurementQuote implements Serializable {
|
||||
@Column(name = "qbr", nullable = false)
|
||||
private boolean qbr;
|
||||
|
||||
@Column(name = "offline_license", nullable = false)
|
||||
private boolean offlineLicense;
|
||||
|
||||
@Column(name = "annual_net_minor", nullable = false)
|
||||
private long annualNetMinor;
|
||||
|
||||
@Column(name = "tcv_minor", nullable = false)
|
||||
private long tcvMinor;
|
||||
|
||||
// First post-term renewal fee (annual net + one CPI step), locked at quote time so the buyer's
|
||||
// quoted renewal doesn't drift if the rate card changes later.
|
||||
@Column(name = "renewal_annual_minor", nullable = false)
|
||||
private long renewalAnnualMinor;
|
||||
|
||||
@Column(name = "line_items", columnDefinition = "text")
|
||||
private String lineItemsJson;
|
||||
|
||||
@@ -111,47 +105,10 @@ public class ProcurementQuote implements Serializable {
|
||||
@Column(name = "stripe_invoice_url", columnDefinition = "text")
|
||||
private String stripeInvoiceUrl;
|
||||
|
||||
// Direct PDF link for that first invoice (Stripe invoice_pdf), set at accept alongside the URL;
|
||||
// persisted so the portal's download button works after a reload, not just in the accept
|
||||
// response.
|
||||
@Column(name = "stripe_invoice_pdf", columnDefinition = "text")
|
||||
private String stripeInvoicePdf;
|
||||
|
||||
// Buyer's company name (shown on the quote/agreement); echoed back so an edit remembers it.
|
||||
@Column(name = "business_name", length = 255)
|
||||
private String businessName;
|
||||
|
||||
// Buyer/AP details captured on the quote's "Your details" step. All optional — they never gate
|
||||
// quote generation; they flow onto the Stripe customer (name + bill-to address) and the invoice
|
||||
// (PO number + tax id as invoice custom fields), and seed the builder on a re-edit. Country and
|
||||
// currency are intentionally out of scope for now.
|
||||
@Column(name = "contact_name", length = 255)
|
||||
private String contactName;
|
||||
|
||||
@Column(name = "contact_email", length = 255)
|
||||
private String contactEmail;
|
||||
|
||||
@Column(name = "address_line1", length = 255)
|
||||
private String addressLine1;
|
||||
|
||||
@Column(name = "address_line2", length = 255)
|
||||
private String addressLine2;
|
||||
|
||||
@Column(name = "city", length = 128)
|
||||
private String city;
|
||||
|
||||
@Column(name = "region", length = 128)
|
||||
private String region;
|
||||
|
||||
@Column(name = "postal_code", length = 32)
|
||||
private String postalCode;
|
||||
|
||||
@Column(name = "po_number", length = 128)
|
||||
private String poNumber;
|
||||
|
||||
@Column(name = "tax_id", length = 64)
|
||||
private String taxId;
|
||||
|
||||
@Column(name = "valid_until")
|
||||
private LocalDate validUntil;
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package stirling.software.saas.procurement.model;
|
||||
|
||||
/**
|
||||
* Buyer / AP details captured on the quote's "Your details" step: the company and signatory
|
||||
* contact, a billing address, and a PO number / tax id for the invoice. These are not pricing
|
||||
* inputs (they never touch {@link stirling.software.saas.procurement.pricing.QuoteConfig}); they
|
||||
* ride alongside the priced config so the quote can be re-seeded on an edit and the fields can flow
|
||||
* onto the Stripe customer and invoice. All fields are optional. Country and currency are out of
|
||||
* scope for now.
|
||||
*/
|
||||
public record QuoteDetails(
|
||||
String businessName,
|
||||
String contactName,
|
||||
String contactEmail,
|
||||
String addressLine1,
|
||||
String addressLine2,
|
||||
String city,
|
||||
String region,
|
||||
String postalCode,
|
||||
String poNumber,
|
||||
String taxId) {}
|
||||
@@ -21,8 +21,7 @@ public record PricingRates(
|
||||
long selfHostDeployMinor, // flat: self-hosted deployment
|
||||
long airgapDeployMinor, // flat: air-gapped deployment
|
||||
long qbrAnnualMinor, // flat: quarterly business reviews
|
||||
long trainingOneTimeMinor, // one-time: onboarding & training
|
||||
double cpiEscalator) { // fixed CPI uplift on the annual fee at each post-term renewal
|
||||
long trainingOneTimeMinor) { // one-time: onboarding & training
|
||||
|
||||
public static PricingRates defaults() {
|
||||
return new PricingRates(
|
||||
@@ -35,8 +34,7 @@ public record PricingRates(
|
||||
1_200_000, // self-hosted $12,000 / yr
|
||||
3_600_000, // air-gapped $36,000 / yr
|
||||
800_000, // QBRs $8,000 / yr
|
||||
750_000, // onboarding & training $7,500 one-time
|
||||
0.03); // 3% CPI escalator per renewal (committed term stays flat)
|
||||
750_000); // onboarding & training $7,500 one-time
|
||||
}
|
||||
|
||||
public double termDiscount(int termYears) {
|
||||
|
||||
+1
-29
@@ -61,11 +61,6 @@ public class ProcurementPricingService {
|
||||
* (Math.log(runVol / (double) RUN_CURVE_KNEE) / LOG2))
|
||||
: 0.0;
|
||||
double rate = Math.max(rates.floorRatePerRun(), rates.listRatePerRun() * (1.0 - volDisc));
|
||||
// File-size multiplier (D93): larger, image-heavy PDFs cost more OCR/compute/storage. Folds
|
||||
// into the per-run rate after the floor, so it flows through the meter, TCV and renewal.
|
||||
// QuoteConfig has already snapped it to a known tier, so a tampered request can't sneak a
|
||||
// cheaper factor in.
|
||||
rate *= cfg.sizeMult();
|
||||
double termDisc = rates.termDiscount(cfg.termYears());
|
||||
|
||||
// The meter is a whole-dollar figure (the quote reads in dollars), then minor units.
|
||||
@@ -87,7 +82,6 @@ public class ProcurementPricingService {
|
||||
|
||||
long annualNet = meterNetMinor + support + deploy + indemnity + qbr;
|
||||
long tcv = annualNet * cfg.termYears() + training;
|
||||
long renewalAnnual = renewalAnnualMinor(annualNet, rates);
|
||||
|
||||
double effectivePerPdf = rate * intensity; // quotes speak per-PDF-at-posture, never per-run
|
||||
|
||||
@@ -157,29 +151,7 @@ public class ProcurementPricingService {
|
||||
QuoteLineItem.Kind.ONE_TIME,
|
||||
training));
|
||||
}
|
||||
return new QuoteBreakdown(lines, annualNet, tcv, renewalAnnual, cfg.currency());
|
||||
}
|
||||
|
||||
/** The default CPI escalator (fraction) applied to the annual fee on each post-term renewal. */
|
||||
public double cpiEscalator() {
|
||||
return PricingRates.defaults().cpiEscalator();
|
||||
}
|
||||
|
||||
/** The CPI escalator as a whole-percent figure for buyer-facing copy (3% → 3). */
|
||||
public int cpiRatePct() {
|
||||
return (int) Math.round(cpiEscalator() * 100.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* The escalated annual fee at the first renewal: the committed annual plus one CPI step. Used
|
||||
* both when pricing a fresh quote and when echoing a stored one, so the two always agree.
|
||||
*/
|
||||
public long renewalAnnualMinor(long annualNetMinor) {
|
||||
return renewalAnnualMinor(annualNetMinor, PricingRates.defaults());
|
||||
}
|
||||
|
||||
private static long renewalAnnualMinor(long annualNetMinor, PricingRates rates) {
|
||||
return Math.round(annualNetMinor * (1.0 + rates.cpiEscalator()));
|
||||
return new QuoteBreakdown(lines, annualNet, tcv, cfg.currency());
|
||||
}
|
||||
|
||||
private static long deployFeeMinor(String deployment, PricingRates rates) {
|
||||
|
||||
+4
-9
@@ -3,15 +3,10 @@ package stirling.software.saas.procurement.pricing;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The priced result of a {@link QuoteConfig}: the itemised lines plus the headline figures the
|
||||
* The priced result of a {@link QuoteConfig}: the itemised lines plus the two headline figures the
|
||||
* order form and Stripe checkout are built from. {@code annualNetMinor} is the recurring annual fee
|
||||
* after the multi-year discount; {@code tcvMinor} is total contract value across the committed term
|
||||
* including one-time fees; {@code renewalAnnualNetMinor} is the annual fee at the first post-term
|
||||
* renewal after the fixed CPI escalator (the committed term itself is flat). Minor units (cents).
|
||||
* after the multi-year discount; {@code tcvMinor} is total contract value across the term including
|
||||
* one-time fees. Minor units (cents).
|
||||
*/
|
||||
public record QuoteBreakdown(
|
||||
List<QuoteLineItem> lineItems,
|
||||
long annualNetMinor,
|
||||
long tcvMinor,
|
||||
long renewalAnnualNetMinor,
|
||||
String currency) {}
|
||||
List<QuoteLineItem> lineItems, long annualNetMinor, long tcvMinor, String currency) {}
|
||||
|
||||
@@ -10,35 +10,23 @@ public record QuoteConfig(
|
||||
long volume, // committed PDFs per year
|
||||
int users, // seats (drives the volume auto-estimate when the buyer hasn't overridden)
|
||||
int intensity, // policy posture: runs per PDF — Essentials 2, Governed 4, Regulated 7
|
||||
double sizeMult, // file-size tier multiplier on the rate — Compact 1.0 / Standard 1.4 /
|
||||
// Heavy 2.4
|
||||
String deployment, // cloud | selfhost | airgap (priced flat; inherited from the trial)
|
||||
int termYears, // 1..5
|
||||
String serviceLevel, // standard | priority (both included) | dedicated (flat SE/CSM fee)
|
||||
boolean indemnification,
|
||||
boolean training,
|
||||
boolean qbr,
|
||||
boolean offlineLicense, // offline .lic availability (gates download; no longer priced here)
|
||||
String currency) { // USD only for now
|
||||
|
||||
/** Default posture when none is chosen — Governed (x4), per the pricing alignment decision. */
|
||||
public static final int DEFAULT_INTENSITY = 4;
|
||||
|
||||
/** Known file-size tier multipliers (D93): Compact 1.0, Standard 1.4, Heavy 2.4. */
|
||||
private static final double[] SIZE_MULTS = {1.0, 1.4, 2.4};
|
||||
|
||||
public QuoteConfig {
|
||||
if (termYears < 1) termYears = 1;
|
||||
if (termYears > 5) termYears = 5;
|
||||
if (intensity < 1) intensity = DEFAULT_INTENSITY;
|
||||
if (serviceLevel == null || serviceLevel.isBlank()) serviceLevel = "standard";
|
||||
if (currency == null || currency.isBlank()) currency = "USD";
|
||||
// Snap the file-size multiplier to a known tier so a tampered request can't invent a
|
||||
// cheaper
|
||||
// one; absent (0.0) or unknown falls back to 1.0 (no uplift).
|
||||
double snapped = 1.0;
|
||||
for (double s : SIZE_MULTS) {
|
||||
if (Math.abs(s - sizeMult) < 1e-9) snapped = s;
|
||||
}
|
||||
sizeMult = snapped;
|
||||
}
|
||||
}
|
||||
|
||||
+23
-48
@@ -24,7 +24,6 @@ import stirling.software.saas.procurement.license.EnterpriseLicenseService;
|
||||
import stirling.software.saas.procurement.license.LicenseEntitlements;
|
||||
import stirling.software.saas.procurement.model.ProcurementDeal;
|
||||
import stirling.software.saas.procurement.model.ProcurementQuote;
|
||||
import stirling.software.saas.procurement.model.QuoteDetails;
|
||||
import stirling.software.saas.procurement.pricing.ProcurementPricingService;
|
||||
import stirling.software.saas.procurement.pricing.QuoteBreakdown;
|
||||
import stirling.software.saas.procurement.pricing.QuoteConfig;
|
||||
@@ -97,46 +96,28 @@ public class ProcurementService {
|
||||
/**
|
||||
* Start (or restart) the free trial for a team: issue a mock trial licence and stamp the trial
|
||||
* window on the deal. No Stripe: a no-card trial has no subscription; the entitlement is the
|
||||
* Keygen licence, and the deal row is the journey state. The buyer's chosen deployment target
|
||||
* ({@code cloud}/{@code selfhost}/{@code airgap}) and seat count are captured here so the quote
|
||||
* builder opens seeded to their environment; both are still editable when the quote is built.
|
||||
* Keygen licence, and the deal row is the journey state.
|
||||
*/
|
||||
@Transactional
|
||||
public ProcurementDeal startTrial(Long teamId, String deployment, int seats) {
|
||||
public ProcurementDeal startTrial(Long teamId) {
|
||||
ProcurementDeal deal =
|
||||
dealRepo.findByTeamId(teamId).orElseGet(() -> new ProcurementDeal(teamId));
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime ends = now.plusDays(config.getTrialDurationDays());
|
||||
deal.setStage(ProcurementDeal.STAGE_TRIAL);
|
||||
deal.setDeployment(normalizeDeployment(deployment));
|
||||
deal.setSeats(Math.max(0, seats));
|
||||
deal.setTrialStartedAt(now);
|
||||
deal.setTrialEndsAt(ends);
|
||||
deal.setTrialExtensionsUsed(0);
|
||||
deal.setLicenseRef(licenses.issueTrialLicense(teamId, leaderEmail(teamId), ends));
|
||||
deal = dealRepo.save(deal);
|
||||
log.info(
|
||||
"[procurement] trial started team={} deal={} deployment={} seats={} ends={}",
|
||||
"[procurement] trial started team={} deal={} ends={}",
|
||||
teamId,
|
||||
deal.getDealId(),
|
||||
deal.getDeployment(),
|
||||
deal.getSeats(),
|
||||
ends);
|
||||
return deal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constrain a caller-supplied deployment to the known set; anything else falls back to cloud.
|
||||
*/
|
||||
private static String normalizeDeployment(String deployment) {
|
||||
if (deployment == null) return "cloud";
|
||||
String d = deployment.trim().toLowerCase(Locale.ROOT);
|
||||
return switch (d) {
|
||||
case "selfhost", "airgap", "cloud" -> d;
|
||||
default -> "cloud";
|
||||
};
|
||||
}
|
||||
|
||||
/** Extend the current trial by the configured increment, up to the cap. */
|
||||
@Transactional
|
||||
public ProcurementDeal extendTrial(Long teamId) {
|
||||
@@ -164,7 +145,7 @@ public class ProcurementService {
|
||||
|
||||
/** Price a quote config server-side and persist it as a draft against the team's deal. */
|
||||
@Transactional
|
||||
public ProcurementQuote buildQuote(Long teamId, QuoteConfig cfg, QuoteDetails details) {
|
||||
public ProcurementQuote buildQuote(Long teamId, QuoteConfig cfg, String businessName) {
|
||||
ProcurementDeal deal =
|
||||
dealRepo.findByTeamId(teamId).orElseGet(() -> new ProcurementDeal(teamId));
|
||||
if (ProcurementDeal.STAGE_LIVE.equals(deal.getStage())) {
|
||||
@@ -187,26 +168,16 @@ public class ProcurementService {
|
||||
quote.setVolume(cfg.volume());
|
||||
quote.setSeats(cfg.users() > 0 ? cfg.users() : null);
|
||||
quote.setIntensity(cfg.intensity());
|
||||
quote.setSizeMult(cfg.sizeMult());
|
||||
quote.setDeployment(cfg.deployment());
|
||||
quote.setTermYears(cfg.termYears());
|
||||
quote.setServiceLevel(cfg.serviceLevel());
|
||||
quote.setIndemnification(cfg.indemnification());
|
||||
quote.setTraining(cfg.training());
|
||||
quote.setQbr(cfg.qbr());
|
||||
quote.setBusinessName(details.businessName());
|
||||
quote.setContactName(details.contactName());
|
||||
quote.setContactEmail(details.contactEmail());
|
||||
quote.setAddressLine1(details.addressLine1());
|
||||
quote.setAddressLine2(details.addressLine2());
|
||||
quote.setCity(details.city());
|
||||
quote.setRegion(details.region());
|
||||
quote.setPostalCode(details.postalCode());
|
||||
quote.setPoNumber(details.poNumber());
|
||||
quote.setTaxId(details.taxId());
|
||||
quote.setOfflineLicense(cfg.offlineLicense());
|
||||
quote.setBusinessName(businessName);
|
||||
quote.setAnnualNetMinor(breakdown.annualNetMinor());
|
||||
quote.setTcvMinor(breakdown.tcvMinor());
|
||||
quote.setRenewalAnnualMinor(breakdown.renewalAnnualNetMinor());
|
||||
quote.setLineItemsJson(writeLineItems(breakdown));
|
||||
quote.setValidUntil(LocalDate.now().plusDays(30));
|
||||
quote = quoteRepo.save(quote);
|
||||
@@ -304,7 +275,7 @@ public class ProcurementService {
|
||||
q != null && q.isIndemnification(),
|
||||
q != null && q.isTraining(),
|
||||
q != null && q.isQbr(),
|
||||
"airgap".equalsIgnoreCase(deployment), // offline .lic = air-gapped deploy
|
||||
q != null && q.isOfflineLicense(),
|
||||
deal.getDealId(),
|
||||
deal.getSubscriptionId());
|
||||
return licenses.issueAnnualLicense(
|
||||
@@ -316,26 +287,30 @@ public class ProcurementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check out the offline/air-gapped licence file (.lic) for a team. Available for an air-gapped
|
||||
* deployment (chosen at trial setup) from the trial licence onward — cloud/self-hosted verify
|
||||
* online against Keygen and don't get a file. Returns empty when there's no licence yet or the
|
||||
* deployment isn't air-gapped, so the controller can 404 rather than leak that a licence
|
||||
* exists. The certificate is generated on demand by Keygen (from whatever licence the deal
|
||||
* currently holds — trial or committed annual) and never stored.
|
||||
*
|
||||
* <p>By design a team can self-select air-gapped at trial and download a real signed .lic
|
||||
* before paying — that's bounded: the trial licence carries {@code expiry = trialEndsAt}, so
|
||||
* the file the verifier accepts self-expires at trial end. The buyer must re-download after
|
||||
* provisioning to get the committed-term file (the portal warns about this).
|
||||
* Check out the offline/air-gapped licence file for a team, when the offline add-on was
|
||||
* purchased. Requires an issued licence on the deal and the accepted quote to carry the offline
|
||||
* add-on; returns empty otherwise (so the controller can 404 rather than leak that a licence
|
||||
* exists). The certificate is generated on demand by Keygen and never stored.
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public Optional<String> offlineLicenseFile(Long teamId) {
|
||||
ProcurementDeal deal = dealRepo.findByTeamId(teamId).orElse(null);
|
||||
if (deal == null || deal.getLicenseRef() == null) return Optional.empty();
|
||||
if (!"airgap".equalsIgnoreCase(deal.getDeployment())) return Optional.empty();
|
||||
if (!hasOfflineAddOn(deal)) return Optional.empty();
|
||||
return Optional.of(licenses.checkOutLicenseFile(deal.getLicenseRef()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the deal's <b>accepted</b> quote carries the paid offline-licence add-on. Gated on
|
||||
* the accepted quote (not the latest) so merely toggling the add-on on an unaccepted draft
|
||||
* can't unlock the offline file — it's only available once the add-on has actually been bought.
|
||||
*/
|
||||
private boolean hasOfflineAddOn(ProcurementDeal deal) {
|
||||
if (deal.getAcceptedQuoteId() == null) return false;
|
||||
ProcurementQuote quote = quoteRepo.findById(deal.getAcceptedQuoteId()).orElse(null);
|
||||
return quote != null && quote.isOfflineLicense();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a team's procurement: delete the deal (quotes + activity cascade). For
|
||||
* re-demos/testing.
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
-- Direct PDF link for a procurement quote's first invoice (Stripe invoice_pdf), stored at accept
|
||||
-- alongside stripe_invoice_url so the portal's "Download invoice" button survives a reload instead
|
||||
-- of relying on the transient accept response. Written by the accept edge function via the
|
||||
-- procurement_set_quote_accepted RPC; read by the Java backend via JPA. A Supabase twin mirrors it.
|
||||
|
||||
ALTER TABLE stirling_pdf.procurement_quote
|
||||
ADD COLUMN IF NOT EXISTS stripe_invoice_pdf TEXT;
|
||||
@@ -1,10 +0,0 @@
|
||||
-- Deployment target + seat count captured at the trial-start step (the setup dialog the demo shows
|
||||
-- before a trial begins), stored on the deal so the quote builder seeds from the buyer's real
|
||||
-- environment instead of a hardcoded default. deployment: cloud | selfhost | airgap. seats: 0 =
|
||||
-- unspecified. Written and read by the Java backend via JPA. A Supabase twin migration mirrors it.
|
||||
|
||||
ALTER TABLE stirling_pdf.procurement_deal
|
||||
ADD COLUMN IF NOT EXISTS deployment VARCHAR(16) NOT NULL DEFAULT 'cloud';
|
||||
|
||||
ALTER TABLE stirling_pdf.procurement_deal
|
||||
ADD COLUMN IF NOT EXISTS seats INTEGER NOT NULL DEFAULT 0;
|
||||
@@ -1,7 +0,0 @@
|
||||
-- Persist the first post-term renewal fee (annual net + one CPI step) computed at quote time, so the
|
||||
-- figure shown to the buyer is locked to what they were quoted rather than recomputed from the
|
||||
-- current rate card on every read. Minor units. Written and read by the Java backend via JPA; a
|
||||
-- Supabase twin migration mirrors it.
|
||||
|
||||
ALTER TABLE stirling_pdf.procurement_quote
|
||||
ADD COLUMN IF NOT EXISTS renewal_annual_minor BIGINT NOT NULL DEFAULT 0;
|
||||
@@ -1,7 +0,0 @@
|
||||
-- File-size tier multiplier on the quote (D93): larger, image-heavy PDFs cost more, so the buyer
|
||||
-- picks a size tier (Compact 1.0 / Standard 1.4 / Heavy 2.4) that scales the per-run rate. Persisted
|
||||
-- so the quote re-prices and re-seeds the builder consistently. Defaults to 1.0 (no uplift) for rows
|
||||
-- that predate the column. Written and read by the Java backend via JPA. A Supabase twin mirrors it.
|
||||
|
||||
ALTER TABLE stirling_pdf.procurement_quote
|
||||
ADD COLUMN IF NOT EXISTS size_mult DOUBLE PRECISION NOT NULL DEFAULT 1.0;
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
-- Buyer / AP details captured on the quote's "Your details" step: the signatory contact and a
|
||||
-- billing address, plus a PO number and tax id for the invoice. All optional (never gate quote
|
||||
-- generation). Persisted so the quote re-seeds the builder on a re-edit and so the issue edge
|
||||
-- function can put them on the Stripe customer (name + bill-to address) and invoice (PO / tax id
|
||||
-- as custom fields). Country and currency are intentionally out of scope for now. Written and read
|
||||
-- by the Java backend via JPA. A Supabase twin mirrors these columns.
|
||||
|
||||
ALTER TABLE stirling_pdf.procurement_quote
|
||||
ADD COLUMN IF NOT EXISTS contact_name VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS contact_email VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS address_line1 VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS address_line2 VARCHAR(255),
|
||||
ADD COLUMN IF NOT EXISTS city VARCHAR(128),
|
||||
ADD COLUMN IF NOT EXISTS region VARCHAR(128),
|
||||
ADD COLUMN IF NOT EXISTS postal_code VARCHAR(32),
|
||||
ADD COLUMN IF NOT EXISTS po_number VARCHAR(128),
|
||||
ADD COLUMN IF NOT EXISTS tax_id VARCHAR(64);
|
||||
+3
-44
@@ -18,13 +18,8 @@ class ProcurementPricingServiceTest {
|
||||
|
||||
private static QuoteConfig cfg(
|
||||
long volume, int intensity, String deployment, int term, String sla) {
|
||||
return cfgSize(volume, intensity, deployment, term, sla, 1.0);
|
||||
}
|
||||
|
||||
private static QuoteConfig cfgSize(
|
||||
long volume, int intensity, String deployment, int term, String sla, double sizeMult) {
|
||||
return new QuoteConfig(
|
||||
volume, 0, intensity, sizeMult, deployment, term, sla, false, false, false, "USD");
|
||||
volume, 0, intensity, deployment, term, sla, false, false, false, false, "USD");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -35,7 +30,6 @@ class ProcurementPricingServiceTest {
|
||||
|
||||
assertThat(q.annualNetMinor()).isEqualTo(175_200_000L); // $1,752,000
|
||||
assertThat(q.tcvMinor()).isEqualTo(525_600_000L); // $5,256,000
|
||||
assertThat(q.renewalAnnualNetMinor()).isEqualTo(180_456_000L); // $1,752,000 + 3% CPI
|
||||
assertThat(lineAmount(q, "support")).isEqualTo(3_000_000L); // dedicated SE/CSM $30K
|
||||
assertThat(lineAmount(q, "deployment")).isEqualTo(1_200_000L); // self-hosted $12K
|
||||
}
|
||||
@@ -52,41 +46,6 @@ class ProcurementPricingServiceTest {
|
||||
assertThat(q.lineItems()).noneMatch(l -> l.key().equals("support"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void renewalAppliesCpiEscalatorAfterAFlatTerm() {
|
||||
// The committed term is flat (TCV = annual × years, asserted above). The 3% CPI escalator
|
||||
// describes only the first post-term renewal: annual + one 3% step. It never touches TCV.
|
||||
QuoteBreakdown q = pricing.price(cfg(6_000_000, 4, "cloud", 3, "standard"));
|
||||
assertThat(q.renewalAnnualNetMinor())
|
||||
.isEqualTo(Math.round(q.annualNetMinor() * 1.03)); // 16,527,800 → 17,023,634
|
||||
assertThat(q.tcvMinor()).isEqualTo(q.annualNetMinor() * 3); // renewal is outside the TCV
|
||||
assertThat(pricing.cpiRatePct()).isEqualTo(3);
|
||||
assertThat(pricing.renewalAnnualMinor(q.annualNetMinor()))
|
||||
.isEqualTo(q.renewalAnnualNetMinor()); // stored-quote echo agrees with pricing
|
||||
}
|
||||
|
||||
@Test
|
||||
void fileSizeTierMultipliesTheMeter() {
|
||||
// D93: the size tier scales the per-run rate, so the meter (hence annual/TCV/renewal) grows
|
||||
// while flat fees stay put. Compact (1.0) is the anchor; Standard is ×1.4, Heavy ×2.4.
|
||||
long compact =
|
||||
pricing.price(cfgSize(6_000_000, 4, "cloud", 3, "standard", 1.0)).annualNetMinor();
|
||||
long standard =
|
||||
pricing.price(cfgSize(6_000_000, 4, "cloud", 3, "standard", 1.4)).annualNetMinor();
|
||||
long heavy =
|
||||
pricing.price(cfgSize(6_000_000, 4, "cloud", 3, "standard", 2.4)).annualNetMinor();
|
||||
|
||||
assertThat(compact).isEqualTo(16_527_800L); // == the Northwind anchor (size 1.0)
|
||||
assertThat(standard).isEqualTo(23_138_900L); // rate ×1.4
|
||||
assertThat(compact).isLessThan(standard);
|
||||
assertThat(standard).isLessThan(heavy);
|
||||
// An unknown/tampered multiplier snaps back to 1.0 (no cheaper factor sneaks through).
|
||||
assertThat(
|
||||
pricing.price(cfgSize(6_000_000, 4, "cloud", 3, "standard", 0.3))
|
||||
.annualNetMinor())
|
||||
.isEqualTo(compact);
|
||||
}
|
||||
|
||||
@Test
|
||||
void rateFloorsAtHalfACent() {
|
||||
// 100M × Regulated(×7) = 700M runs — deep past the knee, so the per-run rate is pinned to
|
||||
@@ -145,7 +104,7 @@ class ProcurementPricingServiceTest {
|
||||
long base = pricing.price(cfg(6_000_000, 4, "cloud", 3, "standard")).annualNetMinor();
|
||||
QuoteConfig c =
|
||||
new QuoteConfig(
|
||||
6_000_000, 0, 4, 1.0, "cloud", 3, "standard", true, false, false, "USD");
|
||||
6_000_000, 0, 4, "cloud", 3, "standard", true, false, false, false, "USD");
|
||||
QuoteBreakdown q = pricing.price(c);
|
||||
assertThat(lineAmount(q, "indemnification")).isEqualTo(Math.round(base * 0.05));
|
||||
}
|
||||
@@ -154,7 +113,7 @@ class ProcurementPricingServiceTest {
|
||||
void trainingIsOneTimeOutsideTheAnnual() {
|
||||
QuoteConfig withTraining =
|
||||
new QuoteConfig(
|
||||
6_000_000, 0, 4, 1.0, "cloud", 3, "standard", false, true, false, "USD");
|
||||
6_000_000, 0, 4, "cloud", 3, "standard", false, true, false, false, "USD");
|
||||
QuoteBreakdown q = pricing.price(withTraining);
|
||||
long baseAnnual = pricing.price(cfg(6_000_000, 4, "cloud", 3, "standard")).annualNetMinor();
|
||||
|
||||
|
||||
-7
@@ -1,8 +1 @@
|
||||
declare module "*.css" {}
|
||||
|
||||
// Vite `?raw` suffix imports a file's contents as a string (used in preview.tsx
|
||||
// to load the English translation TOML synchronously).
|
||||
declare module "*?raw" {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
@@ -21,33 +21,19 @@ import { handlers } from "@portal/mocks/handlers";
|
||||
import { configureSupabase } from "@proprietary/auth/supabase/supabaseClient";
|
||||
import i18next from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import { parse as parseToml } from "smol-toml";
|
||||
// Load the real English copy so stories render human text, not raw keys. Bundled
|
||||
// synchronously via ?raw so it's present on the very first render (no async flash).
|
||||
// eslint-disable-next-line no-restricted-imports -- Storybook-only: read the public i18n asset; no @-alias covers editor/public/.
|
||||
import enTranslationToml from "../editor/public/locales/en-US/translation.toml?raw";
|
||||
|
||||
import "@mantine/core/styles.css";
|
||||
import "@core/tokens/tokens.css";
|
||||
import "@core/tokens/base.css";
|
||||
|
||||
// Storybook-only: init react-i18next with the real English resources parsed from
|
||||
// the app's TOML, so t(key) renders the shipped copy (e.g. "No sources connected
|
||||
// yet") rather than the raw key. Falls back to an empty bundle if parsing ever
|
||||
// fails, so a malformed TOML can't take the whole Storybook down.
|
||||
function parseEnTranslation(): Record<string, unknown> {
|
||||
try {
|
||||
return parseToml(enTranslationToml) as Record<string, unknown>;
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
// Storybook-only: init react-i18next so t(key, fallback, vars) interpolates its
|
||||
// English fallback (there's no backend here to load locale files). Without this,
|
||||
// the default t() returns raw templates like "{{count}} people · led by {{owner}}".
|
||||
if (!i18next.isInitialized) {
|
||||
void i18next.use(initReactI18next).init({
|
||||
lng: "en",
|
||||
fallbackLng: "en",
|
||||
resources: { en: { translation: parseEnTranslation() } },
|
||||
resources: { en: { translation: {} } },
|
||||
interpolation: { escapeValue: false },
|
||||
react: { useSuspense: false },
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -5937,12 +5937,59 @@ keyDescription = "Paste the license key from your email"
|
||||
success = "License Activated!"
|
||||
successMessage = "Your license has been successfully activated. You can now close this window."
|
||||
|
||||
[policies]
|
||||
deleteConfirmBody = "This removes the policy and its workflow. Documents already processed are not affected."
|
||||
deleteConfirmTitle = "Delete {{label}} policy?"
|
||||
|
||||
[policies.activity]
|
||||
enforced = "enforced"
|
||||
enforcing = "Enforcing..."
|
||||
failed = "Enforcement failed"
|
||||
outputsUnavailable = "Policy outputs are no longer available to download."
|
||||
partialOutputsUnavailable = "Some policy outputs are no longer available to download."
|
||||
retrying = "Busy, retrying..."
|
||||
runNotFound = "The enforcement run could no longer be found."
|
||||
step = "step {{current}}/{{total}}"
|
||||
timedOut = "Enforcement timed out before the run could finish."
|
||||
|
||||
[policies.catalog]
|
||||
compliance = "Compliance"
|
||||
ingestion = "Ingestion"
|
||||
retention = "Retention"
|
||||
routing = "Routing"
|
||||
security = "Security"
|
||||
|
||||
[policies.detail]
|
||||
close = "Close"
|
||||
editSettings = "Edit Settings"
|
||||
enforces = "Enforces"
|
||||
managedByOrg = "Managed by your organization. Contact a team leader to change this policy."
|
||||
noActivityDescription = "Documents will appear here once this policy runs."
|
||||
noActivityTitle = "No activity yet"
|
||||
onEveryUpload = "On every upload"
|
||||
originalsNote = "Originals stay untouched • Enforced version saved alongside"
|
||||
pause = "Pause"
|
||||
recentActivity = "Recent Activity"
|
||||
resume = "Resume"
|
||||
retry = "Retry"
|
||||
showLess = "Show less"
|
||||
showMore = "Show more"
|
||||
statActive = "Active"
|
||||
statDataProcessed = "Data processed"
|
||||
statDocsEnforced = "Docs enforced"
|
||||
statusActive = "Active"
|
||||
statusPaused = "Paused"
|
||||
|
||||
[policies.docType]
|
||||
Contracts = "Contracts"
|
||||
"Financial reports" = "Financial reports"
|
||||
"HR records" = "HR records"
|
||||
Insurance = "Insurance"
|
||||
Invoices = "Invoices"
|
||||
"Legal filings" = "Legal filings"
|
||||
"Medical / PHI" = "Medical / PHI"
|
||||
"Tax documents" = "Tax documents"
|
||||
|
||||
[policies.enforcement]
|
||||
applying = "Applying {{names}}"
|
||||
applyingProgress = "Applying {{names}} ({{done}} of {{total}})"
|
||||
@@ -5952,10 +5999,32 @@ failureBody = "{{failures}} of {{total}} file(s) couldn't be processed and were
|
||||
failureTitle = "Exported without full enforcement"
|
||||
printPolicyAppliedBody = "This PDF was updated to meet a policy. Review the changes, then print again."
|
||||
printPolicyAppliedTitle = "Policy applied before printing"
|
||||
queued = "+{{count}} queued"
|
||||
successTitle = "{{names}} applied"
|
||||
summaryMore = "{{first}}, {{second}} and {{more}} more"
|
||||
summaryTwo = "{{first}} and {{second}}"
|
||||
|
||||
[policies.enforcement.triggerVerb]
|
||||
convert = "Enforcing before convert"
|
||||
default = "Enforcing"
|
||||
export = "Enforcing before export"
|
||||
input = "Enforcing on import"
|
||||
print = "Enforcing before print"
|
||||
|
||||
[policies.field]
|
||||
accessLog = "Access log"
|
||||
archiveAfter = "Archive after"
|
||||
auditTrail = "Audit trail"
|
||||
belowThreshold = "Below threshold"
|
||||
destination = "Destination"
|
||||
frameworks = "Frameworks"
|
||||
immutableHold = "Immutable hold"
|
||||
keepFor = "Keep for"
|
||||
minConfidence = "Min confidence"
|
||||
notify = "Notify on route"
|
||||
onViolation = "When non-compliant"
|
||||
webhookUrl = "Webhook URL"
|
||||
|
||||
[policies.fieldOption.archiveAfter]
|
||||
"1 year" = "1 year"
|
||||
"30 days" = "30 days"
|
||||
@@ -6001,6 +6070,9 @@ Indefinite = "Indefinite"
|
||||
"Flag for review" = "Flag for review"
|
||||
"Quarantine document" = "Quarantine document"
|
||||
|
||||
[policies.fields]
|
||||
selectedCount = "{{count}} selected"
|
||||
|
||||
[policies.labels]
|
||||
add = "Add"
|
||||
addPlaceholder = "Add a label…"
|
||||
@@ -6039,6 +6111,90 @@ placeholder = "Select PII types"
|
||||
routing = "US routing numbers (ABA)"
|
||||
ssn = "Social Security numbers"
|
||||
|
||||
[policies.settings]
|
||||
noneExport = "No policies currently run on export."
|
||||
noneUpload = "No policies currently run on upload."
|
||||
onExport = "On export"
|
||||
onUpload = "On upload"
|
||||
reorderHandle = "Drag to reorder"
|
||||
runOrderDesc = "When more than one policy runs on the same trigger, they run in this order — each on the previous policy's output. Drag to reorder."
|
||||
title = "Policy settings"
|
||||
|
||||
[policies.sidebar]
|
||||
activeCount = "{{count}} active"
|
||||
infoTooltip = "A policy is a fixed set of tools that runs automatically whenever it's triggered — for example when a new document arrives — enforcing rules like redacting PII with no manual steps."
|
||||
loading = "Loading…"
|
||||
optionsAriaLabel = "Policy options"
|
||||
policySettings = "Policy settings"
|
||||
railAriaLabel = "{{label}} policy — {{status}}"
|
||||
railSuffixActive = " (Active)"
|
||||
railSuffixPaused = " (Paused)"
|
||||
retryFailed = "Retry failed policies ({{count}})"
|
||||
rowProgress = "{{completed}} of {{total}} files processed"
|
||||
setUp = "Set up"
|
||||
title = "Policies"
|
||||
upgradeToEnterprise = "Upgrade to enterprise"
|
||||
whatIsPolicy = "What is a policy?"
|
||||
|
||||
[policies.status]
|
||||
active = "Active"
|
||||
paused = "Paused"
|
||||
setup = "Set up"
|
||||
|
||||
[policies.toolConfig]
|
||||
enableAriaLabel = "Enable {{tool}}"
|
||||
infoAriaLabel = "What does {{tool}} do?"
|
||||
|
||||
[policies.toolConfig.info]
|
||||
redact = "Automatically finds and blacks out sensitive details — like Social Security and card numbers — so they can't be read in the document."
|
||||
sanitize = "Removes hidden JavaScript from the file, so nothing can run automatically when someone opens it."
|
||||
watermark = "Stamps a visible mark (e.g. \"Confidential\") across every page."
|
||||
|
||||
[policies.wizard]
|
||||
allDocTypesDescription = "Enable the Classification policy to filter by document type."
|
||||
allDocTypesTitle = "All document types"
|
||||
back = "Back"
|
||||
builderDesc = "Build the sequence of tools this policy runs on each document."
|
||||
clear = "Clear"
|
||||
close = "Close"
|
||||
continue = "Continue"
|
||||
docTypesLabel = "Document types"
|
||||
edit = "Edit"
|
||||
editTitle = "Edit {{label}} Policy"
|
||||
enablePolicy = "Enable Policy"
|
||||
filenameAutoNumber = "Auto-number"
|
||||
filenamePositionAria = "Filename position"
|
||||
filenamePrefix = "Prefix"
|
||||
filenameSuffix = "Suffix"
|
||||
filenameTextAria = "Filename text"
|
||||
filenameTextPlaceholder = "Text to add (optional)"
|
||||
lockedDescription = "Contact a team leader to change this policy."
|
||||
lockedTitle = "Managed by your organization"
|
||||
maxRetriesLabel = "Max retries"
|
||||
noToolsError = "Add at least one configured tool to the workflow first."
|
||||
outputAsLabel = "Output as"
|
||||
outputFilenameSubhead = "Output filename"
|
||||
outputModeAria = "Output mode"
|
||||
outputNewFile = "New file"
|
||||
outputNewVersion = "New version"
|
||||
outputRetriesLabel = "Output & retries"
|
||||
outputSubhead = "Output"
|
||||
retryDelayAria = "Retry delay minutes"
|
||||
retryDelayLabel = "Retry delay (min)"
|
||||
runOnExport = "Export"
|
||||
runOnLabel = "Run on"
|
||||
runOnSubhead = "Run on"
|
||||
runOnUpload = "Upload"
|
||||
saveChanges = "Save Changes"
|
||||
saveError = "Couldn't save the policy. Please try again."
|
||||
setupClassification = "Set up Classification"
|
||||
setupTitle = "Set up {{label}} Policy"
|
||||
sourcesDesc = "Choose where this policy runs and which document types it applies to."
|
||||
sourcesLabel = "Sources"
|
||||
stepOf = "Step {{step}} of {{total}}"
|
||||
toolChainDesc = "Configure the tools this policy runs on each document."
|
||||
typesSelected = "{{count}} types selected"
|
||||
|
||||
[policy]
|
||||
badgeEnforcing = "{{name}} enforcing..."
|
||||
badgeRan = "{{name}} policy ran on this file"
|
||||
@@ -6627,8 +6783,6 @@ type = "Type"
|
||||
user = "User"
|
||||
|
||||
[portal.documents.queue.empty]
|
||||
connectSource = "Connect a source"
|
||||
createPipeline = "Create a pipeline"
|
||||
description = "As sources feed documents into your pipelines they'll appear here for review."
|
||||
title = "No documents in the queue"
|
||||
|
||||
@@ -6804,12 +6958,6 @@ sectionsAriaLabel = "Infrastructure sections"
|
||||
subtitle = "Deployments, credentials, security posture, storage, and the audit trail for your Stirling workspace."
|
||||
title = "Infrastructure"
|
||||
|
||||
# Fixed-enum label maps rendered via t(MAP[value]) in the infrastructure tabs.
|
||||
[portal.infrastructure.apiKeyPermission]
|
||||
admin = "Admin"
|
||||
read = "Read"
|
||||
write = "Write"
|
||||
|
||||
[portal.infrastructure.apiKeys]
|
||||
createKey = "Create key"
|
||||
heading = "API keys"
|
||||
@@ -6830,11 +6978,6 @@ usageToday = "Usage today"
|
||||
description = "Create a scoped key to start calling the Stirling API."
|
||||
title = "No API keys yet"
|
||||
|
||||
[portal.infrastructure.attestationLabel]
|
||||
attested = "Attested"
|
||||
inScope = "In scope"
|
||||
notApplicable = "N/A"
|
||||
|
||||
[portal.infrastructure.audit]
|
||||
filterAriaLabel = "Filter audit events by category"
|
||||
heading = "Audit logs"
|
||||
@@ -6891,24 +7034,6 @@ elevation = "Elevation"
|
||||
processing = "Processing"
|
||||
totalEvents = "Total events · 24h"
|
||||
|
||||
[portal.infrastructure.auditCatLabel]
|
||||
auth = "Auth"
|
||||
config = "Config"
|
||||
elevation = "Elevation"
|
||||
processing = "Processing"
|
||||
security = "Security"
|
||||
|
||||
[portal.infrastructure.auditStatusLabel]
|
||||
danger = "Error"
|
||||
info = "Info"
|
||||
success = "Success"
|
||||
warning = "Warning"
|
||||
|
||||
[portal.infrastructure.certLabel]
|
||||
certified = "Certified"
|
||||
inProgress = "In progress"
|
||||
notStarted = "Not started"
|
||||
|
||||
[portal.infrastructure.createKey]
|
||||
cancel = "Cancel"
|
||||
createKey = "Create key"
|
||||
@@ -6925,12 +7050,6 @@ subtitleCreated = "Copy this secret now — it won't be shown again."
|
||||
title = "Create API key"
|
||||
titleCreated = "Key created"
|
||||
|
||||
[portal.infrastructure.deployLabel]
|
||||
live = "Live"
|
||||
queued = "Queued"
|
||||
rolledBack = "Rolled back"
|
||||
rolling = "Rolling out"
|
||||
|
||||
[portal.infrastructure.deployments]
|
||||
msValue = "{{value}} ms"
|
||||
throughputValue = "{{value}}/min"
|
||||
@@ -6966,16 +7085,6 @@ subheading = "Live health for every deployed Stirling region — latency, load,
|
||||
description = "Deployed regions appear here once your workspace is provisioned."
|
||||
title = "No regions deployed"
|
||||
|
||||
[portal.infrastructure.keyLabel]
|
||||
active = "Active"
|
||||
revoked = "Revoked"
|
||||
rotateSoon = "Rotate soon"
|
||||
|
||||
[portal.infrastructure.modelLabel]
|
||||
active = "Active"
|
||||
degraded = "Degraded"
|
||||
disabled = "Disabled"
|
||||
|
||||
[portal.infrastructure.models]
|
||||
heading = "Models"
|
||||
msValue = "{{value}} ms"
|
||||
@@ -7003,10 +7112,6 @@ status = "Status"
|
||||
type = "Type"
|
||||
version = "Version"
|
||||
|
||||
[portal.infrastructure.models.cost]
|
||||
perCall = "{{price}}/call"
|
||||
perThousand = "{{price}}/1k"
|
||||
|
||||
[portal.infrastructure.models.metrics]
|
||||
activeModels = "Active models"
|
||||
avgLatency = "Avg latency"
|
||||
@@ -7030,17 +7135,6 @@ modelForAria = "Model for {{operation}}"
|
||||
operation = "Operation"
|
||||
routedTo = "Routed to"
|
||||
|
||||
[portal.infrastructure.modelTypeLabel]
|
||||
classification = "Classification"
|
||||
extraction = "Extraction"
|
||||
llm = "LLM"
|
||||
ocr = "OCR"
|
||||
|
||||
[portal.infrastructure.regionLabel]
|
||||
degraded = "Degraded"
|
||||
down = "Down"
|
||||
healthy = "Healthy"
|
||||
|
||||
[portal.infrastructure.security.access.byok]
|
||||
description = "Supply a key from your own KMS. Stirling encrypts with it but can still read."
|
||||
label = "Bring your own key (BYOK)"
|
||||
@@ -7270,7 +7364,6 @@ run = "Run now"
|
||||
|
||||
[portal.pipelines.empty]
|
||||
action = "Create a pipeline"
|
||||
connectSource = "Connect a source"
|
||||
description = "Create your first pipeline: pick the sources it runs over, chain the operations, and choose where output goes."
|
||||
title = "No pipelines yet"
|
||||
|
||||
@@ -7571,6 +7664,7 @@ managePlan = "Manage plan"
|
||||
volumeSuffix = "PDFs processed · last 30 days"
|
||||
|
||||
[portal.procurement]
|
||||
reset = "Reset procurement (demo)"
|
||||
subtitle = "Get your team evaluated, contracted, and onboarded. Every document in one place."
|
||||
title = "Procurement"
|
||||
|
||||
@@ -7590,42 +7684,23 @@ title = "Review your enterprise agreement"
|
||||
|
||||
[portal.procurement.builder]
|
||||
addons = "Add-ons"
|
||||
addressLine1 = "Address line 1"
|
||||
addressLine1Placeholder = "500 Howard St"
|
||||
addressLine2 = "Address line 2"
|
||||
addressLine2Placeholder = "Suite, floor, building"
|
||||
back = "Back"
|
||||
businessName = "Business name"
|
||||
businessNamePlaceholder = "Your company"
|
||||
city = "City"
|
||||
cityPlaceholder = "San Francisco"
|
||||
contactEmail = "Contact email"
|
||||
contactEmailPlaceholder = "jane@acme.com"
|
||||
contactName = "Contact name"
|
||||
contactNamePlaceholder = "Jane Doe"
|
||||
continue = "Continue"
|
||||
country = "Country"
|
||||
countryEuro = "Eurozone (EUR €)"
|
||||
countryUK = "United Kingdom (GBP £)"
|
||||
countryUS = "United States (USD $)"
|
||||
eula = "I have read and agree to the Stirling Enterprise EULA. It governs the agreement generated from this quote."
|
||||
generate = "Generate quote"
|
||||
included = "Included"
|
||||
indemnification = "IP indemnification"
|
||||
indemnificationSub = "We defend qualifying IP claims, per the EULA"
|
||||
pdfSize = "PDF size"
|
||||
poNumber = "PO number"
|
||||
poNumberPlaceholder = "Optional"
|
||||
postalCode = "Postal code"
|
||||
postalCodePlaceholder = "94105"
|
||||
posture = "Governance"
|
||||
posture_count = "~{{count}} policies"
|
||||
posture_essentials = "Essentials"
|
||||
posture_essentialsSub = "Classification + Sharing — the defaults"
|
||||
posture_governed = "Governed"
|
||||
posture_governedSub = "Adds Security and Routing"
|
||||
posture_regulated = "Regulated"
|
||||
posture_regulatedSub = "Every category — Compliance, Retention, Ingestion"
|
||||
offlineLicense = "Offline / air-gapped licence"
|
||||
offlineLicenseSub = "A downloadable licence file for an air-gapped self-hosted instance"
|
||||
qbr = "Quarterly business reviews"
|
||||
qbrSub = "Your SE reviews usage and roadmap each quarter"
|
||||
region = "State / region"
|
||||
regionPlaceholder = "California"
|
||||
running = "{{annual}} / yr · {{years}}-yr {{tcv}}"
|
||||
s1Sub = "Your team, and the PDFs you expect to run each year."
|
||||
# Step 1 — volume
|
||||
@@ -7637,21 +7712,13 @@ s3Sub = "For the quote and the agreement it generates."
|
||||
# Step 3 — details
|
||||
s3Title = "Your details"
|
||||
serviceLevel = "Service level"
|
||||
size_compact = "Compact"
|
||||
size_compactSub = "Mostly text, under 1 MB"
|
||||
size_heavy = "Heavy"
|
||||
size_heavySub = "Scanned or image-heavy, 5 MB+"
|
||||
size_standard = "Standard"
|
||||
size_standardSub = "Mixed text and images, 1 to 5 MB"
|
||||
slDedicated = "Dedicated"
|
||||
slDedicatedSub = "4 business hours · dedicated SE / CSM · +$30,000/yr"
|
||||
slDedicatedSub = "4 business hours · dedicated account manager · +30%"
|
||||
slPriority = "Priority"
|
||||
slPrioritySub = "Same business day · named CSM · included"
|
||||
slPrioritySub = "Same business day · named CSM · +15%"
|
||||
slStandard = "Standard"
|
||||
slStandardSub = "Next business day · shared CSM · included"
|
||||
stepOf = "Step {{n}} of {{total}}"
|
||||
taxId = "VAT / Tax ID"
|
||||
taxIdPlaceholder = "Optional"
|
||||
term = "Term"
|
||||
termDiscount = "{{pct}}% multi-year commitment discount applied"
|
||||
title = "Build your quote"
|
||||
@@ -7687,13 +7754,14 @@ title = "Something went wrong"
|
||||
|
||||
[portal.procurement.hero]
|
||||
company = "Your enterprise deal"
|
||||
ctaAgreement = "Review & sign agreement"
|
||||
ctaLive = "You're live"
|
||||
ctaPayment = "Add payment"
|
||||
ctaQuote = "Review your quote"
|
||||
ctaTrial = "Build your quote"
|
||||
eyebrow = "Enterprise procurement"
|
||||
inviteTeammates = "Invite teammates"
|
||||
licenseKey = "Licence key"
|
||||
keyDocs = "Key documents"
|
||||
nextStep = "Next step: {{action}}"
|
||||
notStarted = "Not started"
|
||||
open = "Open procurement"
|
||||
@@ -7748,9 +7816,6 @@ downloadError = "Could not generate the offline licence file just yet — please
|
||||
downloadOffline = "Download offline licence (.lic)"
|
||||
hint = "Paste this key into a self-hosted instance to activate it, or keep it for your records. Keep it safe."
|
||||
label = "Your licence key"
|
||||
subtitle = "Activate a self-hosted instance with this key, or keep it for your records."
|
||||
title = "Your licence key"
|
||||
trialFileHint = "This is your trial licence file. Once your agreement is in place, come back and download it again — unlike the online licence key, the .lic file won't update on its own."
|
||||
|
||||
[portal.procurement.link]
|
||||
cta = "Link account"
|
||||
@@ -7770,9 +7835,16 @@ talkToSales = "Talk to sales"
|
||||
title = "The procurement track opens with Enterprise"
|
||||
|
||||
[portal.procurement.milestone]
|
||||
accept = "Accept & continue"
|
||||
description = "Download the PDF to share it with your team, come back to accept when you're ready, or make changes."
|
||||
download = "Download PDF"
|
||||
downloadError = "Could not download the quote PDF just yet — please try again in a moment."
|
||||
edit = "Edit quote"
|
||||
eyebrow = "Quote {{number}}"
|
||||
perYear = " / yr"
|
||||
preparedFor = "Prepared for {{company}}"
|
||||
tcv = "{{value}} total contract value"
|
||||
title = "Your quote is ready"
|
||||
|
||||
[portal.procurement.modal]
|
||||
cancel = "Cancel"
|
||||
@@ -7799,6 +7871,7 @@ uploadTitle = "Upload your purchase order"
|
||||
[portal.procurement.payment]
|
||||
description = "Your quote is accepted and your licence is already active — your team can start right away. Pay the first invoice when you're ready; you can pay or download it here, no email needed."
|
||||
downloadInvoice = "Download invoice"
|
||||
simulate = "Simulate payment received (demo)"
|
||||
title = "Subscription created"
|
||||
viewInvoice = "View & pay invoice"
|
||||
|
||||
@@ -7808,21 +7881,6 @@ fallbackLink = "Open scheduling in a new tab"
|
||||
subtitle = "Your solutions engineer will walk your team through the rollout. Pick a time that suits you."
|
||||
title = "Schedule a call"
|
||||
|
||||
[portal.procurement.setup]
|
||||
airgap = "Air-gapped"
|
||||
airgapSub = "Fully offline, isolated network. Includes a downloadable licence file."
|
||||
cloud = "Cloud"
|
||||
cloudSub = "Fully managed by Stirling. Nothing for you to run."
|
||||
deployment = "Where will you run Stirling?"
|
||||
seats = "Team size"
|
||||
seatsHint = "Roughly how many people will use it. You can refine this when you build your quote."
|
||||
seatsPlaceholder = "e.g. 250"
|
||||
selfhost = "Self-hosted"
|
||||
selfhostSub = "Run it in your own cloud or data centre."
|
||||
start = "Start trial"
|
||||
subtitle = "Tell us how you plan to run Stirling so we can tailor your trial and quote. No card required."
|
||||
title = "Set up your trial"
|
||||
|
||||
[portal.procurement.status]
|
||||
action = "Action needed"
|
||||
available = "Available"
|
||||
@@ -8056,10 +8114,6 @@ summary = "Owns a team — manages its members' resources and shared configs."
|
||||
2 = "Portal access via the default policy"
|
||||
3 = "Everything Member can do"
|
||||
|
||||
[portal.users.seats]
|
||||
limited = "{{used}} / {{limit}}"
|
||||
unlimited = "{{used}} · Unlimited"
|
||||
|
||||
[portal.welcome]
|
||||
ariaLabel = "Welcome to Stirling PDF"
|
||||
badge = "Open-source"
|
||||
@@ -9989,13 +10043,11 @@ title = "Users"
|
||||
you = "(you)"
|
||||
|
||||
[users.action]
|
||||
cancelInvite = "Cancel invitation"
|
||||
deleteTeam = "Delete team"
|
||||
disableMfa = "Reset MFA"
|
||||
move = "Move to team"
|
||||
reinstate = "Reinstate"
|
||||
remove = "Remove from org"
|
||||
removeTeam = "Remove from team"
|
||||
rename = "Rename team"
|
||||
resetPw = "Reset password"
|
||||
suspend = "Suspend"
|
||||
@@ -10008,14 +10060,11 @@ editor = "Editor"
|
||||
processor = "Processor"
|
||||
|
||||
[users.confirm]
|
||||
cancelInviteBody = "Cancel the invitation to {{email}}? They won't be able to join with the current link."
|
||||
cancelInviteTitle = "Cancel invitation"
|
||||
deleteTeamBody = "Delete the {{name}} team? The team must be empty first - move its members to another team, and it can't still own any integration configs."
|
||||
deleteTeamTitle = "Delete team"
|
||||
disableMfaBody = "Remove {{name}}'s MFA enrolment? They'll set it up again on next login if required."
|
||||
disableMfaTitle = "Reset MFA"
|
||||
removeBody = "Permanently remove {{name}} from the organization? This cannot be undone."
|
||||
removeTeamBody = "Remove {{name}} from the team? They keep their account but lose access to this team's resources."
|
||||
removeTitle = "Remove member"
|
||||
|
||||
[users.empty]
|
||||
@@ -10066,14 +10115,6 @@ username = "Username"
|
||||
usernameError = "Username must be at least 3 characters"
|
||||
usernamePlaceholder = "jsmith"
|
||||
|
||||
[users.invites]
|
||||
by = "Invited by {{who}}"
|
||||
cancel = "Cancel"
|
||||
count = "{{count}} pending"
|
||||
desc = "Invited people who haven't joined yet. They hold a seat until they accept."
|
||||
expires = "Expires"
|
||||
title = "Pending invitations"
|
||||
|
||||
[users.loadError]
|
||||
description = "Something went wrong reaching the backend, or you don't have access. Try again."
|
||||
title = "Couldn't load members"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Core stubs for the right-rail Policies UI.
|
||||
*
|
||||
* The real implementations live in {@code proprietary/components/policies/PoliciesSidebar.tsx}
|
||||
* and shadow these stubs via the {@code @app/*} alias cascade when the proprietary
|
||||
* build is active. Core builds render nothing, so the right rail shows only the
|
||||
* tool list unchanged.
|
||||
*/
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
/** Whether the right rail should host the Policies section. False in core. */
|
||||
export function usePoliciesEnabled(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Whether the Policies list should appear for the current user. False in core. */
|
||||
export function usePoliciesVisible(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a policy is open (its detail should take over the rail). Always false
|
||||
* in core; proprietary bridges to the policy-selection store.
|
||||
*/
|
||||
export function usePolicyDetailActive(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Collapsible policy list rendered above the Tools section. Null in core. */
|
||||
export function PoliciesSection(_props: { leadingControl?: ReactNode } = {}) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Open-policy detail/wizard/settings that replaces the tool area. Null in core. */
|
||||
export function PolicyDetailTakeover() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Collapsed-rail policy icons. Null in core; proprietary renders the rail. */
|
||||
export function PoliciesCollapsedButton(_props: { onExpand: () => void }) {
|
||||
return null;
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/**
|
||||
* Core stub — whether policy enforcement is active for this build. Gates
|
||||
* mounting the headless PolicyAutoRunController. Always false in core; the
|
||||
* proprietary and desktop builds shadow this via the {@code @app/*} alias.
|
||||
*/
|
||||
export function usePoliciesEnabled(): boolean {
|
||||
return false;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import ButtonSelector from "@app/components/shared/ButtonSelector";
|
||||
|
||||
/** Reproduces the redaction "Mode" picker (Automatic / Manual). */
|
||||
const meta: Meta<typeof ButtonSelector> = {
|
||||
title: "Shared/ButtonSelector",
|
||||
component: ButtonSelector,
|
||||
parameters: { layout: "padded" },
|
||||
decorators: [
|
||||
(S) => (
|
||||
<div style={{ maxWidth: "22rem" }}>
|
||||
<S />
|
||||
</div>
|
||||
),
|
||||
],
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof ButtonSelector>;
|
||||
|
||||
function ModeDemo({ disabled }: { disabled?: boolean }) {
|
||||
const [value, setValue] = useState("automatic");
|
||||
return (
|
||||
<ButtonSelector
|
||||
label="Mode"
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
options={[
|
||||
{ value: "automatic", label: "Automatic", disabled },
|
||||
{ value: "manual", label: "Manual", disabled },
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/** Enabled (files present): the selected segment must be dark + readable. */
|
||||
export const RedactionMode: Story = { render: () => <ModeDemo /> };
|
||||
|
||||
/** Both options disabled (no files) — the selected segment must STILL be legible. */
|
||||
export const DisabledOptions: Story = {
|
||||
render: () => <ModeDemo disabled />,
|
||||
};
|
||||
@@ -224,7 +224,6 @@
|
||||
/* ── Individual file row ─────────────────────────── */
|
||||
.fileItem {
|
||||
width: 100%;
|
||||
--sui-btn-py: 0.625rem;
|
||||
padding: 0.625rem 0.875rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
/* ---- File item ---- */
|
||||
.file-sidebar-file-item {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
@@ -38,31 +37,6 @@
|
||||
contain-intrinsic-size: auto 46px;
|
||||
}
|
||||
|
||||
.file-sidebar-file-actions {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 8px;
|
||||
transform: translateY(-50%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.file-sidebar-file-item:hover .file-sidebar-file-actions,
|
||||
.file-sidebar-file-item.viewed .file-sidebar-file-actions {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* Only shrink the name to clear the buttons while they're visible. */
|
||||
.file-sidebar-file-info {
|
||||
transition: padding-right 0.12s ease;
|
||||
}
|
||||
.file-sidebar-file-item:hover .file-sidebar-file-info,
|
||||
.file-sidebar-file-item.viewed .file-sidebar-file-info {
|
||||
padding-right: 3.5rem;
|
||||
}
|
||||
|
||||
.file-sidebar-file-item:hover:not(.selected) {
|
||||
background-color: rgba(59, 130, 246, 0.06);
|
||||
}
|
||||
|
||||
@@ -365,138 +365,133 @@ export function FileItem({
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="file-sidebar-file-actions">
|
||||
<ActionIcon
|
||||
variant="tertiary"
|
||||
size="sm"
|
||||
className="file-sidebar-eye-btn"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onEyeClick(fileId, e);
|
||||
}}
|
||||
tabIndex={-1}
|
||||
aria-label={
|
||||
isViewedInViewer
|
||||
? t("fileSidebar.fileItem.closeViewer", "Close viewer")
|
||||
: t("fileSidebar.fileItem.openInViewer", "Open in viewer")
|
||||
}
|
||||
>
|
||||
<VisibilityOutlinedIcon
|
||||
className="file-sidebar-eye-open"
|
||||
sx={{ fontSize: "1.1rem" }}
|
||||
/>
|
||||
<VisibilityOffOutlinedIcon
|
||||
className="file-sidebar-eye-closed"
|
||||
sx={{ fontSize: "1.1rem" }}
|
||||
/>
|
||||
</ActionIcon>
|
||||
{(onDelete ||
|
||||
(canSaveToCloud && onSaveToCloud) ||
|
||||
(hasVersionHistory && onVersionHistory)) && (
|
||||
<Menu position="bottom-end" withinPortal shadow="md" width={190}>
|
||||
<Menu.Target>
|
||||
<ActionIcon
|
||||
variant="tertiary"
|
||||
size="sm"
|
||||
className="file-sidebar-kebab-btn"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
tabIndex={-1}
|
||||
aria-label={t(
|
||||
"fileSidebar.fileItem.moreActions",
|
||||
"More actions",
|
||||
)}
|
||||
>
|
||||
<MoreVertIcon sx={{ fontSize: "1.1rem" }} />
|
||||
</ActionIcon>
|
||||
</Menu.Target>
|
||||
<Menu.Dropdown onClick={(e) => e.stopPropagation()}>
|
||||
{hasVersionHistory && onVersionHistory && (
|
||||
<Menu.Item
|
||||
leftSection={<HistoryIcon sx={{ fontSize: 16 }} />}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onVersionHistory(fileId);
|
||||
}}
|
||||
>
|
||||
{t(
|
||||
"fileSidebar.fileItem.versionHistory",
|
||||
"Version history",
|
||||
)}
|
||||
</Menu.Item>
|
||||
<ActionIcon
|
||||
variant="tertiary"
|
||||
size="sm"
|
||||
className="file-sidebar-eye-btn"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onEyeClick(fileId, e);
|
||||
}}
|
||||
tabIndex={-1}
|
||||
aria-label={
|
||||
isViewedInViewer
|
||||
? t("fileSidebar.fileItem.closeViewer", "Close viewer")
|
||||
: t("fileSidebar.fileItem.openInViewer", "Open in viewer")
|
||||
}
|
||||
>
|
||||
<VisibilityOutlinedIcon
|
||||
className="file-sidebar-eye-open"
|
||||
sx={{ fontSize: "1.1rem" }}
|
||||
/>
|
||||
<VisibilityOffOutlinedIcon
|
||||
className="file-sidebar-eye-closed"
|
||||
sx={{ fontSize: "1.1rem" }}
|
||||
/>
|
||||
</ActionIcon>
|
||||
{(onDelete ||
|
||||
(canSaveToCloud && onSaveToCloud) ||
|
||||
(hasVersionHistory && onVersionHistory)) && (
|
||||
<Menu position="bottom-end" withinPortal shadow="md" width={190}>
|
||||
<Menu.Target>
|
||||
<ActionIcon
|
||||
variant="tertiary"
|
||||
size="sm"
|
||||
className="file-sidebar-kebab-btn"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
tabIndex={-1}
|
||||
aria-label={t(
|
||||
"fileSidebar.fileItem.moreActions",
|
||||
"More actions",
|
||||
)}
|
||||
{canSaveToCloud &&
|
||||
onSaveToCloud &&
|
||||
(() => {
|
||||
const uploadLabel = isUploadedToCloud
|
||||
? t(
|
||||
"fileSidebar.fileItem.updateOnServer",
|
||||
"Update on server",
|
||||
)
|
||||
: t(
|
||||
"fileSidebar.fileItem.uploadToServer",
|
||||
"Upload to server",
|
||||
);
|
||||
return (
|
||||
<Tooltip
|
||||
label={enforcingTooltip(uploadLabel)}
|
||||
disabled={!policyEnforcing}
|
||||
position="left"
|
||||
offset={6}
|
||||
withArrow
|
||||
>
|
||||
<div>
|
||||
<Menu.Item
|
||||
disabled={policyEnforcing}
|
||||
leftSection={
|
||||
<CloudUploadOutlinedIcon sx={{ fontSize: 16 }} />
|
||||
}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onSaveToCloud(fileId);
|
||||
}}
|
||||
>
|
||||
{uploadLabel}
|
||||
</Menu.Item>
|
||||
</div>
|
||||
</Tooltip>
|
||||
);
|
||||
})()}
|
||||
{onDelete &&
|
||||
(() => {
|
||||
const deleteLabel = t(
|
||||
"fileSidebar.fileItem.delete",
|
||||
"Delete",
|
||||
);
|
||||
return (
|
||||
<Tooltip
|
||||
label={enforcingTooltip(deleteLabel)}
|
||||
disabled={!policyEnforcing}
|
||||
position="left"
|
||||
offset={6}
|
||||
withArrow
|
||||
>
|
||||
<div>
|
||||
<Menu.Item
|
||||
disabled={policyEnforcing}
|
||||
color="red"
|
||||
leftSection={
|
||||
<DeleteOutlineIcon sx={{ fontSize: 16 }} />
|
||||
}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onDelete(fileId);
|
||||
}}
|
||||
>
|
||||
{deleteLabel}
|
||||
</Menu.Item>
|
||||
</div>
|
||||
</Tooltip>
|
||||
);
|
||||
})()}
|
||||
</Menu.Dropdown>
|
||||
</Menu>
|
||||
)}
|
||||
</div>
|
||||
>
|
||||
<MoreVertIcon sx={{ fontSize: "1.1rem" }} />
|
||||
</ActionIcon>
|
||||
</Menu.Target>
|
||||
<Menu.Dropdown onClick={(e) => e.stopPropagation()}>
|
||||
{hasVersionHistory && onVersionHistory && (
|
||||
<Menu.Item
|
||||
leftSection={<HistoryIcon sx={{ fontSize: 16 }} />}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onVersionHistory(fileId);
|
||||
}}
|
||||
>
|
||||
{t("fileSidebar.fileItem.versionHistory", "Version history")}
|
||||
</Menu.Item>
|
||||
)}
|
||||
{canSaveToCloud &&
|
||||
onSaveToCloud &&
|
||||
(() => {
|
||||
const uploadLabel = isUploadedToCloud
|
||||
? t(
|
||||
"fileSidebar.fileItem.updateOnServer",
|
||||
"Update on server",
|
||||
)
|
||||
: t(
|
||||
"fileSidebar.fileItem.uploadToServer",
|
||||
"Upload to server",
|
||||
);
|
||||
return (
|
||||
<Tooltip
|
||||
label={enforcingTooltip(uploadLabel)}
|
||||
disabled={!policyEnforcing}
|
||||
position="left"
|
||||
offset={6}
|
||||
withArrow
|
||||
>
|
||||
<div>
|
||||
<Menu.Item
|
||||
disabled={policyEnforcing}
|
||||
leftSection={
|
||||
<CloudUploadOutlinedIcon sx={{ fontSize: 16 }} />
|
||||
}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onSaveToCloud(fileId);
|
||||
}}
|
||||
>
|
||||
{uploadLabel}
|
||||
</Menu.Item>
|
||||
</div>
|
||||
</Tooltip>
|
||||
);
|
||||
})()}
|
||||
{onDelete &&
|
||||
(() => {
|
||||
const deleteLabel = t(
|
||||
"fileSidebar.fileItem.delete",
|
||||
"Delete",
|
||||
);
|
||||
return (
|
||||
<Tooltip
|
||||
label={enforcingTooltip(deleteLabel)}
|
||||
disabled={!policyEnforcing}
|
||||
position="left"
|
||||
offset={6}
|
||||
withArrow
|
||||
>
|
||||
<div>
|
||||
<Menu.Item
|
||||
disabled={policyEnforcing}
|
||||
color="red"
|
||||
leftSection={
|
||||
<DeleteOutlineIcon sx={{ fontSize: 16 }} />
|
||||
}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onDelete(fileId);
|
||||
}}
|
||||
>
|
||||
{deleteLabel}
|
||||
</Menu.Item>
|
||||
</div>
|
||||
</Tooltip>
|
||||
);
|
||||
})()}
|
||||
</Menu.Dropdown>
|
||||
</Menu>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{useRasterThumb &&
|
||||
|
||||
@@ -5,7 +5,14 @@ import { useSidebarContext } from "@app/contexts/SidebarContext";
|
||||
import { useIsMobile } from "@app/hooks/useIsMobile";
|
||||
import ToolPanel from "@app/components/tools/ToolPanel";
|
||||
import ToolSearch from "@app/components/tools/toolPicker/ToolSearch";
|
||||
import { usePoliciesEnabled } from "@app/components/policies/usePoliciesEnabled";
|
||||
import {
|
||||
PoliciesCollapsedButton,
|
||||
PoliciesSection,
|
||||
PolicyDetailTakeover,
|
||||
usePoliciesEnabled,
|
||||
usePoliciesVisible,
|
||||
usePolicyDetailActive,
|
||||
} from "@app/components/policies/PoliciesSidebar";
|
||||
import { PolicyAutoRunController } from "@app/components/policies/PolicyAutoRunController";
|
||||
import { useFavoriteToolItems } from "@app/hooks/tools/useFavoriteToolItems";
|
||||
import { useToolSections } from "@app/hooks/useToolSections";
|
||||
@@ -59,6 +66,8 @@ export default function RightSidebar() {
|
||||
} = useToolWorkflow();
|
||||
|
||||
const policiesEnabled = usePoliciesEnabled();
|
||||
const policiesVisible = usePoliciesVisible();
|
||||
const rawPolicyDetailActive = usePolicyDetailActive();
|
||||
const fullscreenExpanded = useIsFullscreenExpanded();
|
||||
const fullscreenGeometry = useToolPanelGeometry({
|
||||
enabled: fullscreenExpanded,
|
||||
@@ -91,12 +100,39 @@ export default function RightSidebar() {
|
||||
});
|
||||
};
|
||||
|
||||
// Opening a policy (e.g. from the collapsed rail) lands the rail in the clean
|
||||
// default tool-picker view — the only view the policy takeover renders in — so
|
||||
// it never collides with an open tool or the all-tools/search view.
|
||||
const handleOpenPolicy = () => {
|
||||
withViewTransition(() => {
|
||||
if (readerMode) setReaderMode(false);
|
||||
setLeftPanelView("toolPicker");
|
||||
if (!sidebarsVisible) setSidebarsVisible(true);
|
||||
setAllToolsView(false);
|
||||
setSearchQuery("");
|
||||
});
|
||||
};
|
||||
|
||||
// The header shows [back] [search] when we have somewhere to go back to —
|
||||
// i.e. the user is in a specific tool, or already in the all-tools/search view.
|
||||
const inToolView = leftPanelView !== "toolPicker";
|
||||
// Show X (close) button only when there's somewhere to go back to.
|
||||
const showCloseButton = inToolView || allToolsView;
|
||||
const showHeaderSearch = showCloseButton || leftPanelView === "toolPicker";
|
||||
// Policies sit above the tool list in the default tool-picker view — but only
|
||||
// when the current user actually has policies to see (see usePoliciesVisible),
|
||||
// so regular users with none get the plain tool picker with no empty block.
|
||||
const showPolicies =
|
||||
policiesEnabled &&
|
||||
policiesVisible &&
|
||||
!allToolsView &&
|
||||
leftPanelView === "toolPicker";
|
||||
// When Policies are shown, the search moves OUT of the header to sit between
|
||||
// the Policies and Tools sections (separating them); otherwise it stays in the
|
||||
// header. Show the header search when there's a close button, or in the
|
||||
// default tool-picker view.
|
||||
const showInlineSearch = showPolicies && !showCloseButton;
|
||||
const showHeaderSearch =
|
||||
!showInlineSearch && (showCloseButton || leftPanelView === "toolPicker");
|
||||
|
||||
const handleHeaderBack = () => {
|
||||
if (inToolView) {
|
||||
@@ -129,7 +165,15 @@ export default function RightSidebar() {
|
||||
? (toolRegistry[selectedToolKey as ToolId] ?? null)
|
||||
: null;
|
||||
|
||||
const expandedWidth = "18.5rem";
|
||||
// The detail takeover replaces the tool list ONLY in the same default view —
|
||||
// never over an open tool or the all-tools view (which must keep priority).
|
||||
// A lingering selection is harmless: it stays hidden behind a tool and the
|
||||
// list/takeover reappears on return to the picker (as in the prototype).
|
||||
const policyDetailActive = rawPolicyDetailActive && showPolicies;
|
||||
|
||||
// The rail widens when a policy detail takes it over — the tool list is fine
|
||||
// at 18.5rem, but the policy detail/wizard/settings need more breathing room.
|
||||
const expandedWidth = policyDetailActive ? "25rem" : "18.5rem";
|
||||
|
||||
const computedWidth = () => {
|
||||
if (isMobile) return "100%";
|
||||
@@ -192,6 +236,9 @@ export default function RightSidebar() {
|
||||
</ActionIcon>
|
||||
</div>
|
||||
<div className="tool-panel__collapsed-divider" />
|
||||
{policiesEnabled && (
|
||||
<PoliciesCollapsedButton onExpand={handleOpenPolicy} />
|
||||
)}
|
||||
<div className="tool-panel__collapsed-tools">
|
||||
{collapsedRailItems.map(({ id, tool }) => (
|
||||
<AppTooltip
|
||||
@@ -236,74 +283,109 @@ export default function RightSidebar() {
|
||||
flexDirection: "column",
|
||||
}}
|
||||
>
|
||||
<>
|
||||
{activeTool ? (
|
||||
<ToolPanelHeader
|
||||
icon={
|
||||
<ToolIcon
|
||||
icon={activeTool.icon}
|
||||
marginRight="0"
|
||||
color="currentColor"
|
||||
/>
|
||||
}
|
||||
title={activeTool.name}
|
||||
onClose={handleHeaderBack}
|
||||
closeLabel={
|
||||
inToolView
|
||||
? t("toolPanel.backToAllTools", "Back to all tools")
|
||||
: t("toolPanel.goBack", "Go back")
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<div className="tool-panel__compact-header">
|
||||
{showHeaderSearch ? (
|
||||
<div className="tool-panel__compact-header-search">
|
||||
<ToolSearch
|
||||
value={searchQuery}
|
||||
onChange={handleHeaderSearchChange}
|
||||
toolRegistry={toolRegistry}
|
||||
mode="filter"
|
||||
autoFocus={allToolsView && !inToolView}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
{showCloseButton ? (
|
||||
<ActionIcon
|
||||
variant="tertiary"
|
||||
size="md"
|
||||
shape="circle"
|
||||
onClick={handleHeaderBack}
|
||||
aria-label={
|
||||
{policyDetailActive ? (
|
||||
<div className="pol-takeover">
|
||||
<PolicyDetailTakeover />
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{!showPolicies &&
|
||||
(activeTool ? (
|
||||
<ToolPanelHeader
|
||||
icon={
|
||||
<ToolIcon
|
||||
icon={activeTool.icon}
|
||||
marginRight="0"
|
||||
color="currentColor"
|
||||
/>
|
||||
}
|
||||
title={activeTool.name}
|
||||
onClose={handleHeaderBack}
|
||||
closeLabel={
|
||||
inToolView
|
||||
? t("toolPanel.backToAllTools", "Back to all tools")
|
||||
: t("toolPanel.goBack", "Go back")
|
||||
}
|
||||
className="tool-panel__expand-btn"
|
||||
>
|
||||
<CloseIcon sx={{ fontSize: "1.1rem" }} />
|
||||
</ActionIcon>
|
||||
/>
|
||||
) : (
|
||||
<ActionIcon
|
||||
variant="secondary"
|
||||
size="md"
|
||||
shape="circle"
|
||||
onClick={handleCollapse}
|
||||
aria-label={t("toolPanel.collapse", "Collapse panel")}
|
||||
className="tool-panel__expand-btn tool-panel__toggle-vt"
|
||||
>
|
||||
<ChevronRightIcon sx={{ fontSize: "1.1rem" }} />
|
||||
</ActionIcon>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div className="tool-panel__compact-header">
|
||||
{showHeaderSearch ? (
|
||||
<div className="tool-panel__compact-header-search">
|
||||
<ToolSearch
|
||||
value={searchQuery}
|
||||
onChange={handleHeaderSearchChange}
|
||||
toolRegistry={toolRegistry}
|
||||
mode="filter"
|
||||
autoFocus={allToolsView && !inToolView}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
{showCloseButton ? (
|
||||
<ActionIcon
|
||||
variant="tertiary"
|
||||
size="md"
|
||||
shape="circle"
|
||||
onClick={handleHeaderBack}
|
||||
aria-label={
|
||||
inToolView
|
||||
? t("toolPanel.backToAllTools", "Back to all tools")
|
||||
: t("toolPanel.goBack", "Go back")
|
||||
}
|
||||
className="tool-panel__expand-btn"
|
||||
>
|
||||
<CloseIcon sx={{ fontSize: "1.1rem" }} />
|
||||
</ActionIcon>
|
||||
) : (
|
||||
<ActionIcon
|
||||
variant="secondary"
|
||||
size="md"
|
||||
shape="circle"
|
||||
onClick={handleCollapse}
|
||||
aria-label={t("toolPanel.collapse", "Collapse panel")}
|
||||
className="tool-panel__expand-btn tool-panel__toggle-vt"
|
||||
>
|
||||
<ChevronRightIcon sx={{ fontSize: "1.1rem" }} />
|
||||
</ActionIcon>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
|
||||
<ToolPanel
|
||||
allToolsView={allToolsView}
|
||||
onShowAllTools={handleShowAllTools}
|
||||
onToolSelect={handleToolSelectWithTransition}
|
||||
compact={false}
|
||||
/>
|
||||
</>
|
||||
{showPolicies && (
|
||||
<PoliciesSection
|
||||
leadingControl={
|
||||
<ActionIcon
|
||||
aria-label={t("toolPanel.collapse", "Collapse panel")}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
shape="circle"
|
||||
onClick={handleCollapse}
|
||||
className="tool-panel__expand-btn tool-panel__toggle-vt"
|
||||
>
|
||||
<ChevronRightIcon sx={{ fontSize: "1.1rem" }} />
|
||||
</ActionIcon>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
{showInlineSearch && (
|
||||
<div className="tool-panel__between-search">
|
||||
<ToolSearch
|
||||
value={searchQuery}
|
||||
onChange={handleHeaderSearchChange}
|
||||
toolRegistry={toolRegistry}
|
||||
mode="filter"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<ToolPanel
|
||||
allToolsView={allToolsView}
|
||||
onShowAllTools={handleShowAllTools}
|
||||
onToolSelect={handleToolSelectWithTransition}
|
||||
compact={false}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -511,8 +511,7 @@
|
||||
flex-direction: row;
|
||||
gap: 0.75rem;
|
||||
align-items: flex-start;
|
||||
--sui-btn-py: 1rem;
|
||||
padding: 1rem 0.95rem;
|
||||
padding: 0.85rem 0.95rem;
|
||||
border: 1px solid var(--fullscreen-border-subtle-70);
|
||||
border-radius: 0.95rem;
|
||||
background: var(--fullscreen-bg-item);
|
||||
@@ -527,11 +526,6 @@
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.tool-panel__fullscreen-item .mantine-Button-label {
|
||||
gap: 1rem;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.tool-panel__fullscreen-item:focus-visible {
|
||||
outline: 2px solid var(--fullscreen-accent-selected);
|
||||
outline-offset: 3px;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { SimpleGrid } from "@mantine/core";
|
||||
import { Stack } from "@mantine/core";
|
||||
import { Button } from "@app/ui/Button";
|
||||
import { CertSignParameters } from "@app/hooks/tools/certSign/useCertSignParameters";
|
||||
|
||||
@@ -8,27 +8,106 @@ interface CertificateFormatSettingsProps {
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
const FORMATS = ["PKCS12", "PFX", "PEM", "JKS"] as const;
|
||||
|
||||
const CertificateFormatSettings = ({
|
||||
parameters,
|
||||
onParameterChange,
|
||||
disabled = false,
|
||||
}: CertificateFormatSettingsProps) => {
|
||||
return (
|
||||
<SimpleGrid cols={2} spacing="xs">
|
||||
{FORMATS.map((format) => (
|
||||
<Button
|
||||
key={format}
|
||||
variant={parameters.certType === format ? "primary" : "secondary"}
|
||||
accent="default"
|
||||
fullWidth
|
||||
disabled={disabled}
|
||||
onClick={() => onParameterChange("certType", format)}
|
||||
text={format}
|
||||
/>
|
||||
))}
|
||||
</SimpleGrid>
|
||||
<Stack gap="md">
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: "4px" }}>
|
||||
{/* First row - PKCS#12 and PFX */}
|
||||
<div style={{ display: "flex", gap: "4px" }}>
|
||||
<Button
|
||||
variant={parameters.certType === "PKCS12" ? "primary" : "secondary"}
|
||||
onClick={() => onParameterChange("certType", "PKCS12")}
|
||||
disabled={disabled}
|
||||
style={{
|
||||
flex: 1,
|
||||
height: "auto",
|
||||
minHeight: "40px",
|
||||
fontSize: "11px",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
textAlign: "center",
|
||||
lineHeight: "1.1",
|
||||
fontSize: "11px",
|
||||
}}
|
||||
>
|
||||
PKCS12
|
||||
</div>
|
||||
</Button>
|
||||
<Button
|
||||
variant={parameters.certType === "PFX" ? "primary" : "secondary"}
|
||||
onClick={() => onParameterChange("certType", "PFX")}
|
||||
disabled={disabled}
|
||||
style={{
|
||||
flex: 1,
|
||||
height: "auto",
|
||||
minHeight: "40px",
|
||||
fontSize: "11px",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
textAlign: "center",
|
||||
lineHeight: "1.1",
|
||||
fontSize: "11px",
|
||||
}}
|
||||
>
|
||||
PFX
|
||||
</div>
|
||||
</Button>
|
||||
</div>
|
||||
{/* Second row - PEM and JKS */}
|
||||
<div style={{ display: "flex", gap: "4px" }}>
|
||||
<Button
|
||||
variant={parameters.certType === "PEM" ? "primary" : "secondary"}
|
||||
onClick={() => onParameterChange("certType", "PEM")}
|
||||
disabled={disabled}
|
||||
style={{
|
||||
flex: 1,
|
||||
height: "auto",
|
||||
minHeight: "40px",
|
||||
fontSize: "11px",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
textAlign: "center",
|
||||
lineHeight: "1.1",
|
||||
fontSize: "11px",
|
||||
}}
|
||||
>
|
||||
PEM
|
||||
</div>
|
||||
</Button>
|
||||
<Button
|
||||
variant={parameters.certType === "JKS" ? "primary" : "secondary"}
|
||||
onClick={() => onParameterChange("certType", "JKS")}
|
||||
disabled={disabled}
|
||||
style={{
|
||||
flex: 1,
|
||||
height: "auto",
|
||||
minHeight: "40px",
|
||||
fontSize: "11px",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
textAlign: "center",
|
||||
lineHeight: "1.1",
|
||||
fontSize: "11px",
|
||||
}}
|
||||
>
|
||||
JKS
|
||||
</div>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -521,7 +521,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Compare tool — file selection step (Original / Edited stacked vertically) */
|
||||
/* Compare tool — file selection step (Original / Edited + swap column) */
|
||||
.compare-step-selection {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -532,15 +532,50 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Stacked file cards fill the full available width */
|
||||
.compare-step-selection__thumbs-col {
|
||||
/* Thumbnails + swap only — swap top aligns with first thumbnail, not “Original PDF” heading */
|
||||
.compare-step-selection__thumbs-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: stretch;
|
||||
gap: 0.75rem;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.compare-step-selection__thumbs-col {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
/* Full-height bar to the right of both cards */
|
||||
.compare-step-selection__swap {
|
||||
flex-shrink: 0;
|
||||
width: 36px;
|
||||
min-width: 36px;
|
||||
align-self: stretch;
|
||||
margin: 0;
|
||||
padding: 0.5rem 0.2rem;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
|
||||
.compare-step-selection__swap-icon {
|
||||
font-size: 1.35rem !important;
|
||||
}
|
||||
|
||||
.compare-step-selection__swap-label {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.15;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Pixel compare mode */
|
||||
.compare-pixel-workbench {
|
||||
padding: 16px 24px 32px;
|
||||
|
||||
@@ -240,7 +240,6 @@ const ToolButton: React.FC<ToolButtonProps> = ({
|
||||
variant="tertiary"
|
||||
accent="neutral"
|
||||
size="sm"
|
||||
p="none"
|
||||
fullWidth
|
||||
justify="start"
|
||||
className="tool-button"
|
||||
@@ -265,7 +264,6 @@ const ToolButton: React.FC<ToolButtonProps> = ({
|
||||
variant="tertiary"
|
||||
accent="neutral"
|
||||
size="sm"
|
||||
p="sm"
|
||||
fullWidth
|
||||
justify="start"
|
||||
className="tool-button"
|
||||
@@ -286,7 +284,6 @@ const ToolButton: React.FC<ToolButtonProps> = ({
|
||||
accent="neutral"
|
||||
onClick={() => handleClick(id)}
|
||||
size="sm"
|
||||
p="sm"
|
||||
fullWidth
|
||||
justify="start"
|
||||
className="tool-button"
|
||||
|
||||
@@ -64,23 +64,18 @@
|
||||
--tool-button-selected-bg: var(--mantine-color-dark-4);
|
||||
}
|
||||
|
||||
/* Compact tool buttons (padding via the Button `p`/`py` props).
|
||||
List rows hug their content — drop the shared Button's min-height floor
|
||||
so height = icon/label only and rows sit tight against each other. */
|
||||
/* Compact tool buttons */
|
||||
.tool-button {
|
||||
font-size: 0.875rem;
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
|
||||
.tool-button.sui-btn.mantine-Button-root {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.tool-button .mantine-Button-label {
|
||||
.tool-button .sui-btn__label {
|
||||
font-size: 0.84rem;
|
||||
font-weight: 500;
|
||||
/* ≥1.4 so the overflow:hidden label box contains glyph descenders (g/y/p);
|
||||
row height is icon-bound (~24px) so this doesn't change row size. */
|
||||
line-height: 1.4;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.tool-button-icon {
|
||||
@@ -126,7 +121,13 @@
|
||||
padding: 0.5rem var(--mantine-spacing-sm) var(--mantine-spacing-sm);
|
||||
}
|
||||
|
||||
.tool-picker__compact .tool-button .mantine-Button-label {
|
||||
.tool-picker__compact .tool-button {
|
||||
padding-top: 0.65rem;
|
||||
padding-bottom: 0.65rem;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.tool-picker__compact .tool-button .sui-btn__label {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
|
||||
@@ -442,10 +442,10 @@
|
||||
--gray-800: 218 222 245;
|
||||
--gray-900: 238 241 252;
|
||||
|
||||
/* Dark semantic colors for Tailwind — aligned with portal tokens.css */
|
||||
--surface: 21 28 46; /* #151c2e — portal --color-surface */
|
||||
--background: 9 12 20; /* #090c14 — portal --color-bg */
|
||||
--border: 40 50 72; /* #283248 — portal --color-border */
|
||||
/* Dark semantic colors for Tailwind */
|
||||
--surface: 19 23 41;
|
||||
--background: 9 11 24;
|
||||
--border: 28 35 64;
|
||||
|
||||
/* Dark theme Mantine colors */
|
||||
--color-red-50: #2d1b1b;
|
||||
@@ -524,18 +524,14 @@
|
||||
--color-yellow-800: #fef08a;
|
||||
--color-yellow-900: #fef9c3;
|
||||
|
||||
/* Dark theme semantic colors — deep navy/indigo palette, aligned with portal
|
||||
tokens.css so the editor and portal (Processor) dark modes don't drift.
|
||||
Chrome surfaces (--bg-toolbar, --bg-file-manager) sit at the portal's
|
||||
sidebar level (#0d1120) so the left/right sidebars lift off the darker
|
||||
canvas (--bg-background) instead of blending into it. */
|
||||
--bg-surface: #151c2e; /* portal --color-surface */
|
||||
--bg-raised: #0d1120; /* portal --color-bg-alt */
|
||||
--bg-muted: #0d1120;
|
||||
--bg-background: #090c14; /* portal --color-bg */
|
||||
--bg-toolbar: #0d1120; /* portal --color-sidebar-bg — lifted off the canvas */
|
||||
--bg-file-manager: #0d1120; /* portal --color-sidebar-bg */
|
||||
--bg-file-list: #151c2e; /* portal --color-surface */
|
||||
/* Dark theme semantic colors — deep navy/indigo palette */
|
||||
--bg-surface: #131729;
|
||||
--bg-raised: #0d1020;
|
||||
--bg-muted: #0d1020;
|
||||
--bg-background: #090b18;
|
||||
--bg-toolbar: #090b18;
|
||||
--bg-file-manager: #090b18;
|
||||
--bg-file-list: #131729;
|
||||
--btn-open-file: #4f8ef5;
|
||||
--text-primary: #e8eaf6;
|
||||
--text-secondary: #9299b0;
|
||||
@@ -544,11 +540,11 @@
|
||||
--text-always-dark: #1f2937;
|
||||
--text-always-dark-muted: #6b7280;
|
||||
--border-subtle: rgba(255, 255, 255, 0.05);
|
||||
--border-default: #1e2840; /* portal --color-border-light */
|
||||
--border-strong: #283248; /* portal --color-border */
|
||||
--border-hover: #3d4f6a; /* portal --color-border-hover */
|
||||
--hover-bg: #1c2640; /* portal --color-bg-hover */
|
||||
--active-bg: #243044; /* portal --color-bg-muted */
|
||||
--border-default: #1c2340;
|
||||
--border-strong: #2d3560;
|
||||
--border-hover: #3a4680;
|
||||
--hover-bg: #181d38;
|
||||
--active-bg: #232a50;
|
||||
--automation-entry-hover-bg: var(--color-gray-200);
|
||||
|
||||
/* Icon colors for dark mode */
|
||||
@@ -619,7 +615,7 @@
|
||||
--header-selected-bg: #2040a0;
|
||||
--header-selected-fg: #ffffff;
|
||||
/* file card background (dark) */
|
||||
--file-card-bg: #0d1120;
|
||||
--file-card-bg: #0d1020;
|
||||
--accordion-item-bg: #1c2340; /* accordion item background - more distinguishable */
|
||||
|
||||
/* shadows */
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { test, expect } from "@app/tests/helpers/stub-test-base";
|
||||
|
||||
/**
|
||||
* Policy editing is admin-only (mirrors the backend's enforcement on the
|
||||
* save/delete endpoints). The frontend gate is `canConfigure = !enableLogin ||
|
||||
* isAdmin`, surfaced through `usePolicies()`:
|
||||
* - login enabled + non-admin → read-only: the setup wizard shows the
|
||||
* "Managed by your organization" locked state instead of the steps.
|
||||
* - login enabled + admin → full setup flow ("Step 1 of 2").
|
||||
* - login disabled (single-user/desktop) → open to the local operator.
|
||||
*
|
||||
* Backend-free: the app-config (`enableLogin`/`isAdmin`) and the empty policy
|
||||
* list are stubbed via `mockAppApis`, so this asserts the gating wiring without
|
||||
* a live Spring Boot server. "Security" is the only non-coming-soon policy, so
|
||||
* it's the one we open.
|
||||
*/
|
||||
|
||||
const LOCKED_TITLE = "Managed by your organization";
|
||||
const LOCKED_DESC = "Contact a team leader to change this policy.";
|
||||
|
||||
/** Open the Security policy from the right-sidebar Policies list. */
|
||||
async function openSecurityPolicy(page: import("@playwright/test").Page) {
|
||||
const row = page.locator("button.pol-row").filter({ hasText: "Security" });
|
||||
await expect(row).toBeVisible({ timeout: 15_000 });
|
||||
await row.click();
|
||||
// The wizard header confirms we opened the right policy in either state.
|
||||
await expect(page.getByText("Set up Security Policy")).toBeVisible();
|
||||
}
|
||||
|
||||
// Policies are a SaaS-only feature: POLICIES_ENABLED is off in the proprietary
|
||||
// and core builds this stubbed suite runs against, so the policy UI never
|
||||
// renders here. Skip unless the app under test is built with policies enabled
|
||||
// and the runner opts in via POLICIES_E2E=1.
|
||||
test.beforeEach(() => {
|
||||
const enabled = ["1", "true"].includes(process.env.POLICIES_E2E ?? "");
|
||||
test.skip(!enabled, "Policies are SaaS-only; set POLICIES_E2E=1 to run");
|
||||
});
|
||||
|
||||
test.describe("Policy editing gate — non-admin (login on)", () => {
|
||||
test.use({
|
||||
stubOptions: { enableLogin: true, isAdmin: false },
|
||||
seedJwt: true,
|
||||
});
|
||||
|
||||
test("non-admin gets the read-only locked state", async ({ page }) => {
|
||||
await openSecurityPolicy(page);
|
||||
await expect(page.getByText(LOCKED_TITLE)).toBeVisible();
|
||||
await expect(page.getByText(LOCKED_DESC)).toBeVisible();
|
||||
// The editable flow must NOT be reachable.
|
||||
await expect(page.getByText(/Step \d+ of \d+/)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Policy editing gate — admin (login on)", () => {
|
||||
test.use({
|
||||
stubOptions: { enableLogin: true, isAdmin: true },
|
||||
seedJwt: true,
|
||||
});
|
||||
|
||||
test("admin can reach the setup wizard", async ({ page }) => {
|
||||
await openSecurityPolicy(page);
|
||||
await expect(page.getByText(/Step \d+ of \d+/)).toBeVisible();
|
||||
await expect(page.getByText(LOCKED_TITLE)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
|
||||
test.describe("Policy editing gate — single-user (login off)", () => {
|
||||
test.use({ stubOptions: { enableLogin: false, isAdmin: false } });
|
||||
|
||||
test("local operator can reach the setup wizard with no admin role", async ({
|
||||
page,
|
||||
}) => {
|
||||
await openSecurityPolicy(page);
|
||||
await expect(page.getByText(/Step \d+ of \d+/)).toBeVisible();
|
||||
await expect(page.getByText(LOCKED_TITLE)).toHaveCount(0);
|
||||
});
|
||||
});
|
||||
@@ -370,5 +370,22 @@ export const mantineTheme = createTheme({
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
SegmentedControl: {
|
||||
styles: {
|
||||
root: {
|
||||
backgroundColor: "var(--bg-muted)",
|
||||
border: "1px solid var(--border-subtle)",
|
||||
},
|
||||
control: {
|
||||
color: "var(--text-secondary)",
|
||||
"&[dataActive]": {
|
||||
backgroundColor: "var(--bg-surface)",
|
||||
color: "var(--text-primary)",
|
||||
boxShadow: "var(--shadow-sm)",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -498,27 +498,32 @@ const Compare = (props: BaseToolProps) => {
|
||||
{t("compare.original.label", "Original PDF")}
|
||||
</Text>
|
||||
|
||||
<Stack gap="sm" className="compare-step-selection__thumbs-col">
|
||||
{renderSlot("base")}
|
||||
<div className="compare-step-selection__thumbs-row">
|
||||
<Stack gap="sm" className="compare-step-selection__thumbs-col">
|
||||
{renderSlot("base")}
|
||||
<Text fw={700} size="sm" style={{ margin: 0 }}>
|
||||
{t("compare.edited.label", "Edited PDF")}
|
||||
</Text>
|
||||
{renderSlot("comparison")}
|
||||
</Stack>
|
||||
|
||||
{hasBothSelected && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
className="compare-step-selection__swap"
|
||||
onClick={handleSwap}
|
||||
disabled={base.operation.isLoading}
|
||||
leftSection={<SwapVertRoundedIcon fontSize="small" />}
|
||||
style={{ alignSelf: "center" }}
|
||||
aria-label={t("compare.swap.label", "Swap")}
|
||||
>
|
||||
{t("compare.swap.label", "Swap")}
|
||||
<SwapVertRoundedIcon
|
||||
className="compare-step-selection__swap-icon"
|
||||
fontSize="inherit"
|
||||
/>
|
||||
<span className="compare-step-selection__swap-label">
|
||||
{t("compare.swap.label", "Swap")}
|
||||
</span>
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Text fw={700} size="sm" style={{ margin: 0 }}>
|
||||
{t("compare.edited.label", "Edited PDF")}
|
||||
</Text>
|
||||
{renderSlot("comparison")}
|
||||
</Stack>
|
||||
</div>
|
||||
|
||||
<Modal
|
||||
opened={swapConfirmOpen}
|
||||
|
||||
@@ -35,37 +35,7 @@
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.sui-btn .mantine-Button-label {
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* ---- height: --button-height is a minimum, not a cap ---- */
|
||||
/* Single-line content computes to exactly --button-height (same as ActionIcon /
|
||||
SegmentedControl via CONTROL_HEIGHT); taller content (wrapped label, stacked
|
||||
rows) grows the button instead of clipping mid-glyph. Under height:auto the
|
||||
inner's height:100% resolves to auto on its own, so block-level
|
||||
align-content re-centers short content — deliberately NOT flex on the root:
|
||||
that display would out-specificity consumers' own display (e.g. a
|
||||
width:100% list row) and turn them inline-level. */
|
||||
.sui-btn.mantine-Button-root {
|
||||
height: auto;
|
||||
min-height: var(--button-height);
|
||||
align-content: center;
|
||||
/* Vertical padding via the `py` prop; Mantine has no --button-padding-y.
|
||||
Default 0 keeps height-driven layout unchanged for every other button. */
|
||||
padding-block: var(--sui-btn-py, 0);
|
||||
}
|
||||
|
||||
/* no-hover: !important to beat Mantine's own :hover background rule. */
|
||||
.sui-btn--no-hover:not(:disabled):not([data-disabled]):hover {
|
||||
background: var(--button-bg, transparent) !important;
|
||||
}
|
||||
|
||||
[data-theme="dark"]
|
||||
.sui-btn--primary.mantine-Button-root:disabled:not([data-loading]),
|
||||
[data-theme="dark"]
|
||||
.sui-btn--primary.mantine-Button-root[data-disabled]:not([data-loading]) {
|
||||
background: var(--button-bg);
|
||||
color: var(--button-color);
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
@@ -72,18 +72,6 @@ const meta: Meta<typeof Button> = {
|
||||
],
|
||||
},
|
||||
size: { control: "inline-radio", options: ["sm", "md", "lg", "xl"] },
|
||||
p: {
|
||||
control: "inline-radio",
|
||||
options: [undefined, "none", "xs", "sm", "md", "lg", "xl"],
|
||||
},
|
||||
px: {
|
||||
control: "inline-radio",
|
||||
options: [undefined, "none", "xs", "sm", "md", "lg", "xl"],
|
||||
},
|
||||
py: {
|
||||
control: "inline-radio",
|
||||
options: [undefined, "none", "xs", "sm", "md", "lg", "xl"],
|
||||
},
|
||||
justify: {
|
||||
control: "inline-radio",
|
||||
options: ["center", "start", "end", "between"],
|
||||
@@ -153,34 +141,6 @@ export const Accents: Story = {
|
||||
),
|
||||
};
|
||||
|
||||
/** Loading keeps the button's shape. A labelless loader collapses to an icon
|
||||
square — unless `fullWidth`, which must always span its container (e.g. an
|
||||
execute button whose label is briefly absent while files hydrate). */
|
||||
export const Loading: Story = {
|
||||
render: (args) => (
|
||||
<div
|
||||
style={{ display: "flex", flexDirection: "column", gap: 12, width: 320 }}
|
||||
>
|
||||
<Button {...args} loading text="Save changes" />
|
||||
<Button {...args} loading leftSection={<Plus />} text="Save changes" />
|
||||
{/* fullWidth + loading + no label — must fill width, not shrink to a square */}
|
||||
<Button {...args} text={undefined} fullWidth loading />
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
/** Disabled primary — dark mode keeps a muted accent instead of grey. */
|
||||
export const DisabledDark: Story = {
|
||||
render: () => (
|
||||
<div style={{ background: "var(--bg-surface)", padding: 24, width: 360 }}>
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: 12 }}>
|
||||
<Button data-d="active" fullWidth text="Merge (8 files)" />
|
||||
<Button data-d="disabled" fullWidth disabled text="Merge (8 files)" />
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
/** Real size differences. */
|
||||
export const Sizes: Story = {
|
||||
render: (args) => (
|
||||
@@ -192,12 +152,15 @@ export const Sizes: Story = {
|
||||
),
|
||||
};
|
||||
|
||||
/** Padding override via `p` (both axes); `px`/`py` override a single axis. */
|
||||
export const Padding: Story = {
|
||||
/**
|
||||
* `fontSize` scales the label text independently of `size` (which sets height).
|
||||
* Unset inherits the `size`-derived default (md for a default button).
|
||||
*/
|
||||
export const FontSizes: Story = {
|
||||
render: (args) => (
|
||||
<Wrap>
|
||||
{(["none", "xs", "sm", "md", "lg", "xl"] as const).map((p) => (
|
||||
<Button key={p} {...args} p={p} text={p} />
|
||||
{(["xs", "sm", "md", "lg", "xl"] as const).map((fontSize) => (
|
||||
<Button key={fontSize} {...args} fontSize={fontSize} text={fontSize} />
|
||||
))}
|
||||
</Wrap>
|
||||
),
|
||||
|
||||
@@ -6,13 +6,7 @@ import type {
|
||||
ElementType,
|
||||
ReactNode,
|
||||
} from "react";
|
||||
import {
|
||||
CONTROL_HEIGHT,
|
||||
CONTROL_PADDING,
|
||||
type ControlFontSize,
|
||||
type ControlPadding,
|
||||
resolveFontSize,
|
||||
} from "@app/ui/controlSizes";
|
||||
import { CONTROL_HEIGHT } from "@app/ui/controlSizes";
|
||||
import "@app/ui/Button.css";
|
||||
|
||||
/** primary=solid, secondary=outlined, tertiary=ghost (tinted hover), quiet=plain (no bg, hovers to text colour). */
|
||||
@@ -29,11 +23,11 @@ export type ButtonAccent =
|
||||
| "warning";
|
||||
export type ButtonSize = "sm" | "md" | "lg" | "xl";
|
||||
/**
|
||||
* Relative label-size scale, applied on top of the `size`-derived base. `md`
|
||||
* leaves the base unchanged; other values scale it up/down. Unset inherits
|
||||
* Mantine's size default, so existing buttons are unchanged.
|
||||
* Text-size scale, independent of `size` (which sets the control height). Unset
|
||||
* inherits the `size`-derived default — i.e. `md` for a default button — so
|
||||
* existing buttons are unchanged; set it to size the label on its own axis.
|
||||
*/
|
||||
export type ButtonFontSize = ControlFontSize;
|
||||
export type ButtonFontSize = "xs" | "sm" | "md" | "lg" | "xl";
|
||||
/** `between` pins leftSection/label/rightSection to left/center/right (toolbar rows). */
|
||||
export type ButtonJustify = "center" | "start" | "end" | "between";
|
||||
export type ButtonShape = "default" | "circle" | "pill";
|
||||
@@ -42,14 +36,8 @@ type ButtonOwnProps = {
|
||||
variant?: ButtonVariant;
|
||||
accent?: ButtonAccent;
|
||||
size?: ButtonSize;
|
||||
/** Label size relative to `size`. Defaults to the `size`-derived value. */
|
||||
/** Label text size, independent of `size`. Defaults to the `size`-derived value. */
|
||||
fontSize?: ButtonFontSize;
|
||||
/** Padding override for both axes */
|
||||
p?: ControlPadding;
|
||||
/** Horizontal-padding override */
|
||||
px?: ControlPadding;
|
||||
/** Vertical-padding override */
|
||||
py?: ControlPadding;
|
||||
justify?: ButtonJustify;
|
||||
shape?: ButtonShape;
|
||||
/** Alternative to children; use one or the other. */
|
||||
@@ -117,16 +105,23 @@ const MANTINE_JUSTIFY: Record<ButtonJustify, string> = {
|
||||
between: "space-between",
|
||||
};
|
||||
|
||||
// Maps the fontSize scale onto Mantine's font-size tokens (xs 12 → xl 20px),
|
||||
// the same tokens `size` resolves to — so fontSize is a drop-in override.
|
||||
const FONT_SIZE_VAR: Record<ButtonFontSize, string> = {
|
||||
xs: "var(--mantine-font-size-xs)",
|
||||
sm: "var(--mantine-font-size-sm)",
|
||||
md: "var(--mantine-font-size-md)",
|
||||
lg: "var(--mantine-font-size-lg)",
|
||||
xl: "var(--mantine-font-size-xl)",
|
||||
};
|
||||
|
||||
const ButtonRoot = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
function ButtonRoot(
|
||||
{
|
||||
variant = "primary",
|
||||
accent = "default",
|
||||
size = "sm",
|
||||
size = "md",
|
||||
fontSize,
|
||||
p,
|
||||
px,
|
||||
py,
|
||||
justify = "center",
|
||||
shape = "default",
|
||||
text,
|
||||
@@ -147,15 +142,7 @@ const ButtonRoot = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
) {
|
||||
const label = text ?? children;
|
||||
const hasLabel = label != null && label !== false && label !== "";
|
||||
// A labelless button collapses to a square icon-only button — but never when
|
||||
// `fullWidth` is set (it must span its container, e.g. a loading execute
|
||||
// button whose label is momentarily absent while files hydrate).
|
||||
const iconOnly =
|
||||
!hasLabel && !fullWidth && (!!leftSection || !!rightSection || loading);
|
||||
|
||||
// px/py override p for their axis; each stays undefined (= size default) if unset.
|
||||
const padX = px ?? p;
|
||||
const padY = py ?? p;
|
||||
const iconOnly = !hasLabel && (!!leftSection || !!rightSection || loading);
|
||||
|
||||
// Sections flank a label → spread them without requiring justify="between".
|
||||
const effectiveJustify =
|
||||
@@ -223,19 +210,10 @@ const ButtonRoot = forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
style={{
|
||||
...(accentVars as CSSProperties),
|
||||
...({ "--button-height": CONTROL_HEIGHT[size] } as CSSProperties),
|
||||
// Relative label size, scaled off the `size` base (unset → Mantine default).
|
||||
// fontSize decouples label text size from `size`; unset leaves Mantine's
|
||||
// size-derived --button-fz in place.
|
||||
...(fontSize
|
||||
? ({
|
||||
"--button-fz": resolveFontSize(size, fontSize),
|
||||
} as CSSProperties)
|
||||
: {}),
|
||||
// Padding overrides (inline to beat Mantine's size-based value).
|
||||
// px → Mantine's own var; py → our --sui-btn-py (Mantine has no vertical padding).
|
||||
...(padX
|
||||
? ({ "--button-padding-x": CONTROL_PADDING[padX] } as CSSProperties)
|
||||
: {}),
|
||||
...(padY
|
||||
? ({ "--sui-btn-py": CONTROL_PADDING[padY] } as CSSProperties)
|
||||
? ({ "--button-fz": FONT_SIZE_VAR[fontSize] } as CSSProperties)
|
||||
: {}),
|
||||
// Icon-only: zero the size padding inline so the lone icon centres.
|
||||
...(iconOnly ? ({ "--button-padding-x": "0" } as CSSProperties) : {}),
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/* Carousel pagination dots — active dot widens into a pill. */
|
||||
.sui-carousel-dots {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.sui-carousel-dots__dot {
|
||||
width: 0.4375rem;
|
||||
height: 0.4375rem;
|
||||
padding: 0;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
background: var(--sui-dot-color, var(--color-text-5));
|
||||
opacity: 0.4;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
opacity var(--motion-fast),
|
||||
background var(--motion-fast),
|
||||
width var(--motion-fast);
|
||||
}
|
||||
|
||||
.sui-carousel-dots__dot:hover {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.sui-carousel-dots__dot:focus-visible {
|
||||
outline: 2px solid var(--sui-dot-active-color, var(--color-blue));
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.sui-carousel-dots__dot.is-active {
|
||||
width: 1rem;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--sui-dot-active-color, var(--color-blue));
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* onImage: white dots over dark photography / gradients. */
|
||||
.sui-carousel-dots--onImage {
|
||||
--sui-dot-color: #ffffff;
|
||||
--sui-dot-active-color: #ffffff;
|
||||
}
|
||||
|
||||
.sui-carousel-dots--onImage .sui-carousel-dots__dot {
|
||||
opacity: 0.5;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.sui-carousel-dots--onImage .sui-carousel-dots__dot.is-active {
|
||||
opacity: 1;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { CarouselDots } from "@app/ui/CarouselDots";
|
||||
|
||||
const meta: Meta<typeof CarouselDots> = {
|
||||
title: "Primitives/CarouselDots",
|
||||
component: CarouselDots,
|
||||
tags: ["autodocs"],
|
||||
parameters: { layout: "centered" },
|
||||
args: { count: 3, activeIndex: 0, tone: "default" },
|
||||
argTypes: {
|
||||
count: { control: { type: "number", min: 2, max: 8 } },
|
||||
activeIndex: { control: { type: "number", min: 0, max: 7 } },
|
||||
tone: { control: "inline-radio", options: ["default", "onImage"] },
|
||||
},
|
||||
};
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof CarouselDots>;
|
||||
|
||||
/** Click a dot to move the active pill. */
|
||||
export const Interactive: Story = {
|
||||
render: (args) => {
|
||||
const [index, setIndex] = useState(0);
|
||||
return (
|
||||
<CarouselDots
|
||||
{...args}
|
||||
activeIndex={index}
|
||||
onSelect={setIndex}
|
||||
label="Slides"
|
||||
/>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
/** Blue pill on a light surface (portal hero, light backgrounds). */
|
||||
export const Default: Story = { args: { activeIndex: 1 } };
|
||||
|
||||
/** White dots for use over dark photography (auth carousel). */
|
||||
export const OnImage: Story = {
|
||||
args: { activeIndex: 1, tone: "onImage" },
|
||||
decorators: [
|
||||
(S) => (
|
||||
<div style={{ background: "#1e293b", padding: "2rem", borderRadius: 12 }}>
|
||||
<S />
|
||||
</div>
|
||||
),
|
||||
],
|
||||
};
|
||||
@@ -1,59 +0,0 @@
|
||||
import type { CSSProperties } from "react";
|
||||
import "@app/ui/CarouselDots.css";
|
||||
|
||||
/** default = blue pill on light surfaces; onImage = white dots over dark photography. */
|
||||
export type CarouselDotsTone = "default" | "onImage";
|
||||
|
||||
export interface CarouselDotsProps {
|
||||
/** Number of slides / dots. */
|
||||
count: number;
|
||||
/** Zero-based index of the active slide. */
|
||||
activeIndex: number;
|
||||
/** Called with the clicked dot's index; omit to render non-interactive dots. */
|
||||
onSelect?: (index: number) => void;
|
||||
/** Accessible label for the dot group. */
|
||||
label?: string;
|
||||
/** Accessible label for each dot; receives the zero-based index. */
|
||||
dotLabel?: (index: number) => string;
|
||||
tone?: CarouselDotsTone;
|
||||
className?: string;
|
||||
style?: CSSProperties;
|
||||
}
|
||||
|
||||
/** Carousel pagination indicator: active dot is a wider pill, inactive dots are ovals. */
|
||||
export function CarouselDots({
|
||||
count,
|
||||
activeIndex,
|
||||
onSelect,
|
||||
label,
|
||||
dotLabel,
|
||||
tone = "default",
|
||||
className,
|
||||
style,
|
||||
}: CarouselDotsProps) {
|
||||
const classes = [
|
||||
"sui-carousel-dots",
|
||||
`sui-carousel-dots--${tone}`,
|
||||
className ?? "",
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
|
||||
return (
|
||||
<div className={classes} style={style} role="group" aria-label={label}>
|
||||
{Array.from({ length: Math.max(0, count) }).map((_, i) => {
|
||||
const active = i === activeIndex;
|
||||
return (
|
||||
<button
|
||||
key={i}
|
||||
type="button"
|
||||
className={"sui-carousel-dots__dot" + (active ? " is-active" : "")}
|
||||
aria-current={active ? "true" : undefined}
|
||||
aria-label={dotLabel ? dotLabel(i) : `Go to slide ${i + 1}`}
|
||||
onClick={onSelect ? () => onSelect(i) : undefined}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -48,17 +48,6 @@
|
||||
.sui-chip__label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* Center the label precisely. Mantine sets line-height: var(--pill-height) on
|
||||
the label, which positions the text by its font baseline and reads slightly
|
||||
high; flex-centering with line-height:1 centres the ink in the pill. */
|
||||
.sui-chip .mantine-Pill-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
line-height: 1;
|
||||
overflow: visible;
|
||||
}
|
||||
.sui-chip__spinner {
|
||||
width: 0.75em;
|
||||
height: 0.75em;
|
||||
|
||||
@@ -24,10 +24,6 @@
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.sui-mantine-wrapper .mantine-Input-input {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
/* SUI focus ring — matches .sui-input:focus-within */
|
||||
.sui-mantine-wrapper[data-focused],
|
||||
.sui-mantine-wrapper:focus-within {
|
||||
|
||||
@@ -13,16 +13,9 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-block: 0;
|
||||
}
|
||||
|
||||
.sui-seg .mantine-SegmentedControl-label[data-active][data-disabled] {
|
||||
color: var(--mantine-color-text);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Mantine wraps label content in .innerLabel; flex it so an icon + text sit
|
||||
* centered together with a consistent gap. Without this the inline-block icon
|
||||
* aligns to the text baseline and rides ~3px high. */
|
||||
|
||||
@@ -54,7 +54,7 @@ export function SegmentedControl<T extends string>({
|
||||
value,
|
||||
onChange,
|
||||
accent = "default",
|
||||
size = "sm",
|
||||
size = "md",
|
||||
variant = "primary",
|
||||
fullWidth = false,
|
||||
disabled = false,
|
||||
@@ -72,10 +72,11 @@ export function SegmentedControl<T extends string>({
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
|
||||
// Drive Mantine's indicator/label colour vars from the accent palette.
|
||||
const accentVars =
|
||||
variant === "secondary"
|
||||
? { "--sc-color": "var(--_tint)", "--sc-label-color": "var(--_text)" }
|
||||
: {};
|
||||
variant === "primary"
|
||||
? { "--sc-color": "var(--_solid)", "--sc-label-color": "var(--_on)" }
|
||||
: { "--sc-color": "var(--_tint)", "--sc-label-color": "var(--_text)" };
|
||||
|
||||
return (
|
||||
<MantineSegmentedControl
|
||||
|
||||
@@ -7,44 +7,3 @@ export const CONTROL_HEIGHT = {
|
||||
} as const;
|
||||
|
||||
export type ControlSize = keyof typeof CONTROL_HEIGHT;
|
||||
|
||||
/** Optional padding-override scale for Button (`p`/`px`/`py` props). Undefined = Mantine's size-based default. */
|
||||
export const CONTROL_PADDING = {
|
||||
none: "0",
|
||||
xs: "0.5rem",
|
||||
sm: "0.75rem",
|
||||
md: "1rem",
|
||||
lg: "1.25rem",
|
||||
xl: "1.5rem",
|
||||
} as const;
|
||||
|
||||
export type ControlPadding = keyof typeof CONTROL_PADDING;
|
||||
|
||||
/**
|
||||
* Shared label font-size scale (rem). Both a control's `size` and its optional
|
||||
* `fontSize` prop index into this same scale — `md` is the neutral point.
|
||||
*/
|
||||
export const CONTROL_FONT_SIZE = {
|
||||
xs: 0.75,
|
||||
sm: 0.875,
|
||||
md: 1.0,
|
||||
lg: 1.125,
|
||||
xl: 1.25,
|
||||
} as const;
|
||||
|
||||
export type ControlFontSize = keyof typeof CONTROL_FONT_SIZE;
|
||||
|
||||
/**
|
||||
* Resolve a label font-size from the control `size` and a relative `fontSize`.
|
||||
* The base comes from `size`; `fontSize` scales it relative to `md` (= no
|
||||
* change). Because it scales the size-derived base rather than replacing it, an
|
||||
* `xl` button with `md` text stays larger than a `sm` button with `lg` text.
|
||||
*/
|
||||
export function resolveFontSize(
|
||||
size: ControlSize,
|
||||
fontSize: ControlFontSize,
|
||||
): string {
|
||||
const base = CONTROL_FONT_SIZE[size];
|
||||
const factor = CONTROL_FONT_SIZE[fontSize] / CONTROL_FONT_SIZE.md;
|
||||
return `${(base * factor).toFixed(3)}rem`;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ export * from "@app/ui/NavItem";
|
||||
export * from "@app/ui/PanelHeader";
|
||||
export * from "@app/ui/CodeBlock";
|
||||
export * from "@app/ui/SectionDivider";
|
||||
export * from "@app/ui/CarouselDots";
|
||||
export * from "@app/ui/Card";
|
||||
export * from "@app/ui/Modal";
|
||||
export * from "@app/ui/SettingsShell";
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Prefixes the browser tab title with the current worktree name during local
|
||||
* development so multiple concurrently-running worktrees (e.g. wt1, wt2, spdf1)
|
||||
* are distinguishable at a glance instead of all showing "Stirling PDF".
|
||||
*
|
||||
* The label is injected as a build-time constant by vite.config, sourced from
|
||||
* the top-level dev tasks. It is an empty string in production builds, so this
|
||||
* whole feature compiles away to a no-op outside `vite` dev-serve.
|
||||
*/
|
||||
|
||||
const LABEL =
|
||||
typeof __DEV_WORKTREE_LABEL__ === "string" ? __DEV_WORKTREE_LABEL__ : "";
|
||||
|
||||
export function applyDevWorktreeLabel(): void {
|
||||
if (!LABEL || typeof document === "undefined") {
|
||||
return;
|
||||
}
|
||||
|
||||
const prefix = `[${LABEL}] `;
|
||||
|
||||
const ensurePrefixed = () => {
|
||||
if (!document.title.startsWith(prefix)) {
|
||||
// The app rewrites document.title on route/tool changes; re-apply the
|
||||
// prefix on top of whatever the app just set.
|
||||
document.title = prefix + document.title;
|
||||
}
|
||||
};
|
||||
|
||||
ensurePrefixed();
|
||||
|
||||
const titleEl = document.querySelector("title");
|
||||
if (titleEl) {
|
||||
new MutationObserver(ensurePrefixed).observe(titleEl, {
|
||||
childList: true,
|
||||
characterData: true,
|
||||
subtree: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
/* Vertical padding via the shared Button's --sui-btn-py (beats the Button's
|
||||
own padding-block); horizontal stays in the shorthand. */
|
||||
--sui-btn-py: 1rem; /* 16px (md) */
|
||||
padding: 1rem 1rem; /* 16px */
|
||||
padding: 0.75rem 1rem; /* 12px 16px */
|
||||
border: 1px solid var(--auth-input-border-light-only);
|
||||
border-radius: 0.75rem; /* 12px */
|
||||
background-color: var(--auth-card-bg-light-only);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Desktop shadow of the proprietary Policies right-rail.
|
||||
*
|
||||
* Re-exports the proprietary module unchanged EXCEPT `usePoliciesEnabled`, which
|
||||
* additionally requires an active SaaS connection. Policy runs execute + bill via
|
||||
* the cloud (POST /api/v1/policies/.../run hits the SaaS backend), so on desktop
|
||||
* the feature must be hidden in local ("disconnected") and self-hosted modes —
|
||||
* otherwise the panel + auto-run controller would fire policy runs against a
|
||||
* backend that doesn't serve them. On web the build flavor already gates it.
|
||||
*
|
||||
* `usePoliciesEnabled` is the single gate RightSidebar uses for BOTH the rail
|
||||
* section and mounting PolicyAutoRunController, so this one override covers both.
|
||||
*/
|
||||
import { POLICIES_ENABLED } from "@app/constants/featureFlags";
|
||||
import { useConfirmedSaaSMode } from "@app/hooks/useConfirmedSaaSMode";
|
||||
|
||||
export * from "@proprietary/components/policies/PoliciesSidebar";
|
||||
|
||||
export function usePoliciesEnabled(): boolean {
|
||||
// Pessimistic SaaS-mode check (starts false): this gate also controls whether
|
||||
// PolicyAutoRunController mounts, and that fires GET /api/v1/policies on mount.
|
||||
// useSaaSMode()'s optimistic-true default would leak that request against the
|
||||
// local/self-hosted backend on cold start before the mode resolves.
|
||||
return POLICIES_ENABLED && useConfirmedSaaSMode();
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { POLICIES_ENABLED } from "@app/constants/featureFlags";
|
||||
import { useConfirmedSaaSMode } from "@app/hooks/useConfirmedSaaSMode";
|
||||
|
||||
/**
|
||||
* Desktop shadow: policy runs execute + bill via the cloud (POST
|
||||
* /api/v1/policies/.../run hits the SaaS backend), so the feature must stay
|
||||
* off in local ("disconnected") and self-hosted modes — otherwise the
|
||||
* auto-run controller would fire policy runs against a backend that doesn't
|
||||
* serve them.
|
||||
*
|
||||
* Pessimistic SaaS-mode check (starts false): this gate controls whether
|
||||
* PolicyAutoRunController mounts, and that fires GET /api/v1/policies on
|
||||
* mount. useSaaSMode()'s optimistic-true default would leak that request
|
||||
* against the local/self-hosted backend on cold start before the mode
|
||||
* resolves.
|
||||
*/
|
||||
export function usePoliciesEnabled(): boolean {
|
||||
return POLICIES_ENABLED && useConfirmedSaaSMode();
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
* Desktop-build feature gates. Shadows `proprietary/constants/featureFlags.ts`
|
||||
* (the desktop `@app/*` alias has no saas layer). Re-exports the proprietary
|
||||
* flags and re-enables Policies: the desktop Policies gate additionally requires
|
||||
* an active SaaS connection (see the desktop `usePoliciesEnabled` shadow), so
|
||||
* the flag must be on for that runtime check to ever apply.
|
||||
* an active SaaS connection (see desktop PoliciesSidebar's `usePoliciesEnabled`),
|
||||
* so the flag must be on for that runtime check to ever apply.
|
||||
*/
|
||||
export * from "@proprietary/constants/featureFlags";
|
||||
|
||||
|
||||
@@ -14,9 +14,12 @@ import { BrowserRouter } from "react-router-dom";
|
||||
import App from "@app/App";
|
||||
import "@app/i18n"; // Initialize i18next
|
||||
import { BASE_PATH } from "@app/constants/app";
|
||||
import { applyDevWorktreeLabel } from "@app/utils/applyDevWorktreeLabel";
|
||||
|
||||
import { startEagerWasmCompilation } from "@app/services/wasmPrecompiler";
|
||||
|
||||
applyDevWorktreeLabel();
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
const scheduleCompilation = () => {
|
||||
if (typeof requestIdleCallback === "function") {
|
||||
|
||||
@@ -73,16 +73,6 @@ export const JOURNEY: JourneyStep[] = [
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* The commercial flow's stepper stages. The real backend collapses quote + agreement into one
|
||||
* accept step (accepting the issued quote is accepting the agreement), so the flow shows one fewer
|
||||
* step than the mock ledger's {@link JOURNEY} — the separate "Agreement" step is dropped. Reuses
|
||||
* JOURNEY's i18n keys.
|
||||
*/
|
||||
export const FLOW_JOURNEY: JourneyStep[] = JOURNEY.filter(
|
||||
(s) => s.stage !== "security",
|
||||
);
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────────── */
|
||||
/* Deal header */
|
||||
/* ──────────────────────────────────────────────────────────────────────── */
|
||||
@@ -294,18 +284,12 @@ export interface QuoteResult {
|
||||
currency: string;
|
||||
annualNetMinor: number;
|
||||
tcvMinor: number;
|
||||
/** First post-term renewal fee after the CPI escalator; the committed term itself is flat. */
|
||||
renewalAnnualNetMinor: number;
|
||||
/** The fixed CPI escalator applied per renewal, as a whole percent (e.g. 3). */
|
||||
cpiRatePct: number;
|
||||
lineItems: QuoteLineItem[];
|
||||
validUntil: string | null;
|
||||
/** The Stripe Quote id once issued; null while still a local draft. */
|
||||
stripeQuoteId: string | null;
|
||||
/** Hosted Stripe invoice URL, present once the quote is accepted and the subscription invoice exists. */
|
||||
invoiceUrl: string | null;
|
||||
/** Direct PDF link for that invoice; persisted so the download button survives a reload. */
|
||||
invoicePdf: string | null;
|
||||
/** The inputs this quote was priced from, so the builder can seed itself on re-edit. */
|
||||
config: QuoteConfigInput;
|
||||
}
|
||||
@@ -322,10 +306,6 @@ export interface AcceptResult {
|
||||
export interface ProcurementSnapshot {
|
||||
dealId: number | null;
|
||||
stage: DealStage | null;
|
||||
/** cloud | selfhost | airgap — chosen at the trial-setup step; seeds the quote builder. */
|
||||
deployment: string;
|
||||
/** Seat count captured at trial setup (0 = unspecified); seeds the builder's volume estimate. */
|
||||
seats: number;
|
||||
trialStartedAt: string | null;
|
||||
trialEndsAt: string | null;
|
||||
trialExtensionsUsed: number;
|
||||
@@ -338,35 +318,17 @@ export interface ProcurementSnapshot {
|
||||
export interface QuoteConfigInput {
|
||||
volume: number;
|
||||
users: number;
|
||||
/** Policy posture (governance) as runs per PDF: Essentials 2, Governed 4, Regulated 7. */
|
||||
intensity: number;
|
||||
/** PDF-size tier multiplier on the rate: Compact 1.0, Standard 1.4, Heavy 2.4. */
|
||||
sizeMult: number;
|
||||
/** cloud | selfhost | airgap — set at the trial; drives the flat deployment fee + offline .lic. */
|
||||
deployment: string;
|
||||
termYears: number;
|
||||
serviceLevel: string;
|
||||
indemnification: boolean;
|
||||
training: boolean;
|
||||
qbr: boolean;
|
||||
/** Offline / air-gapped licence file — a paid add-on. */
|
||||
offlineLicense: boolean;
|
||||
currency: string;
|
||||
/** Buyer's company name — shown on the quote/agreement and remembered when re-editing. */
|
||||
businessName: string;
|
||||
// Buyer / AP details (all optional). They flow onto the Stripe customer (name + bill-to address)
|
||||
// and the invoice (PO number + tax id as custom fields). Country + currency are out of scope.
|
||||
/** Signatory / main contact name. */
|
||||
contactName?: string;
|
||||
/** Contact email (billing / signatory). */
|
||||
contactEmail?: string;
|
||||
addressLine1?: string;
|
||||
addressLine2?: string;
|
||||
city?: string;
|
||||
/** State / province / region. */
|
||||
region?: string;
|
||||
postalCode?: string;
|
||||
/** Purchase-order number, shown on the invoice for AP matching. */
|
||||
poNumber?: string;
|
||||
/** VAT / Tax ID, shown on the invoice. */
|
||||
taxId?: string;
|
||||
}
|
||||
|
||||
export function fetchSnapshot(): Promise<ProcurementSnapshot> {
|
||||
@@ -381,17 +343,10 @@ export function fetchLicenseFile(): Promise<string> {
|
||||
return apiClient.saas.text("/api/v1/procurement/license/file");
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the trial with the buyer's chosen deployment target and seat count (captured in the setup
|
||||
* step). These seed the quote builder; both remain editable when the quote is built.
|
||||
*/
|
||||
export function startTrial(
|
||||
deployment: string,
|
||||
seats: number,
|
||||
): Promise<ProcurementSnapshot> {
|
||||
export function startTrial(): Promise<ProcurementSnapshot> {
|
||||
return apiClient.saas.json<ProcurementSnapshot>(
|
||||
"/api/v1/procurement/trial/start",
|
||||
{ method: "POST", body: { deployment, users: seats } },
|
||||
{ method: "POST" },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ export interface Team {
|
||||
userCount: number;
|
||||
/** Usernames of the team's owners (LEADER memberships). */
|
||||
owners: string[];
|
||||
/** SaaS: an auto-created personal team (can't be renamed/deleted). Undefined self-hosted. */
|
||||
isPersonal?: boolean;
|
||||
}
|
||||
|
||||
interface TeamsDto {
|
||||
|
||||
@@ -72,22 +72,6 @@ export interface Role {
|
||||
tone: "purple" | "blue" | "green" | "amber" | "neutral";
|
||||
}
|
||||
|
||||
/**
|
||||
* A pending team invitation (SaaS only). Mapped from SaasTeamController's
|
||||
* InvitationDTO; self-hosted has no pending-invite concept (invites create the
|
||||
* account immediately) so the roster's `invitations` list stays empty there.
|
||||
*/
|
||||
export interface PendingInvitation {
|
||||
/** Backend invitationId, used for cancel. */
|
||||
id: number;
|
||||
/** Invitee email. */
|
||||
email: string;
|
||||
/** Who sent it (inviter email), for context. */
|
||||
invitedBy?: string;
|
||||
/** ISO expiry, if the backend surfaces one. */
|
||||
expiresAt?: string;
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────────── */
|
||||
/* Access controls (tier-scoped) */
|
||||
/* ──────────────────────────────────────────────────────────────────────── */
|
||||
@@ -141,8 +125,6 @@ export interface UsersResponse {
|
||||
members: Member[];
|
||||
roles: Role[];
|
||||
access: AccessControls;
|
||||
/** Pending team invitations (SaaS); undefined/empty on self-hosted. */
|
||||
invitations?: PendingInvitation[];
|
||||
/** Whether SMTP is configured (gates emailing passwords/invites). */
|
||||
mailEnabled: boolean;
|
||||
/** Whether email invites will work: SMTP on AND mail.enableInvites=true. Gates the
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
import {
|
||||
afterAll,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
beforeEach,
|
||||
describe,
|
||||
expect,
|
||||
it,
|
||||
vi,
|
||||
} from "vitest";
|
||||
import { setupServer } from "msw/node";
|
||||
import { http, HttpResponse } from "msw";
|
||||
import {
|
||||
teamSaasHandlers,
|
||||
resetTeamSaasStore,
|
||||
} from "@portal/mocks/handlers/teamSaas";
|
||||
|
||||
// apiClient.local attaches a stored bearer + (transitively) touches the Supabase
|
||||
// client at import; stub both so the local transport stays hermetic. MSW
|
||||
// intercepts the relative /api/v1/team/* URLs regardless of the (absent) token.
|
||||
vi.mock("@app/auth", () => ({
|
||||
getStoredToken: () => null,
|
||||
clearStoredToken: vi.fn(),
|
||||
}));
|
||||
vi.mock("@app/auth/supabase/supabaseClient", () => ({
|
||||
getSupabaseClient: () => null,
|
||||
configureSupabase: vi.fn(),
|
||||
}));
|
||||
vi.mock("@portal/auth/saasSupabase", () => ({ ensureSaasSupabase: vi.fn() }));
|
||||
|
||||
// The SaaS usersBackend lives under src/saas; the portal vitest project resolves
|
||||
// @app to proprietary (there's no @saas alias here), so the SaaS impl can only be
|
||||
// exercised by importing it directly by path.
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { usersBackend } from "../../saas/portal/usersBackend";
|
||||
|
||||
const server = setupServer(...teamSaasHandlers);
|
||||
|
||||
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
beforeEach(() => resetTeamSaasStore());
|
||||
|
||||
describe("saas usersBackend — fetchUsers mapping", () => {
|
||||
it("maps SaasTeamController members + invitations onto UsersResponse", async () => {
|
||||
const res = await usersBackend.fetchUsers("pro");
|
||||
|
||||
// 3 members from the store; leader → team_owner, the rest → member.
|
||||
expect(res.members).toHaveLength(3);
|
||||
const leader = res.members.find((m) => m.email === "leader@acme.com")!;
|
||||
expect(leader.role).toBe("team_owner");
|
||||
expect(leader.teamLead).toBe(true);
|
||||
// Leader is the viewer on SaaS → self (self-remove disabled) + portal access.
|
||||
expect(leader.isSelf).toBe(true);
|
||||
expect(leader.canAccessPortal).toBe(true);
|
||||
expect(leader.teamId).toBe(1);
|
||||
|
||||
const member = res.members.find((m) => m.email === "priya@acme.com")!;
|
||||
expect(member.role).toBe("member");
|
||||
expect(member.isSelf).toBeFalsy();
|
||||
expect(member.canAccessPortal).toBe(false);
|
||||
// Backend numeric id is preserved for the remove call.
|
||||
expect(member.id).toBe("2");
|
||||
|
||||
// One pending invitation mapped onto PendingInvitation.
|
||||
expect(res.invitations).toHaveLength(1);
|
||||
expect(res.invitations![0]).toMatchObject({
|
||||
id: 101,
|
||||
email: "sam.lee@acme.com",
|
||||
invitedBy: "leader@acme.com",
|
||||
});
|
||||
});
|
||||
|
||||
it("derives summary + seats from the resolved team", async () => {
|
||||
const res = await usersBackend.fetchUsers("pro");
|
||||
expect(res.summary.totalMembers).toBe(3);
|
||||
expect(res.summary.pendingInvites).toBe(1);
|
||||
// Store seatsUsed = members (3) + pending (1).
|
||||
expect(res.summary.seatsUsed).toBe(4);
|
||||
expect(res.summary.seatLimit).toBe(10);
|
||||
expect(res.access).toEqual({ tier: "pro", seatsUsed: 4, seatLimit: 10 });
|
||||
// SaaS always has email; not gated on a self-hosted SMTP config.
|
||||
expect(res.mailEnabled).toBe(true);
|
||||
expect(res.emailInvitesEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it("excludes non-pending invitations", async () => {
|
||||
await usersBackend.cancelInvitation(101);
|
||||
const res = await usersBackend.fetchUsers("pro");
|
||||
expect(res.invitations).toHaveLength(0);
|
||||
expect(res.summary.pendingInvites).toBe(0);
|
||||
});
|
||||
|
||||
it("drops PENDING invitations whose expiry has already passed", async () => {
|
||||
server.use(
|
||||
http.get("/api/v1/team/:teamId/invitations", () =>
|
||||
HttpResponse.json([
|
||||
{
|
||||
invitationId: 201,
|
||||
teamName: "Acme",
|
||||
inviterEmail: "leader@acme.com",
|
||||
inviteeEmail: "expired@acme.com",
|
||||
invitationToken: "t1",
|
||||
status: "PENDING",
|
||||
expiresAt: "2000-01-01T00:00:00Z",
|
||||
},
|
||||
{
|
||||
invitationId: 202,
|
||||
teamName: "Acme",
|
||||
inviterEmail: "leader@acme.com",
|
||||
inviteeEmail: "live@acme.com",
|
||||
invitationToken: "t2",
|
||||
status: "PENDING",
|
||||
expiresAt: "2999-01-01T00:00:00Z",
|
||||
},
|
||||
]),
|
||||
),
|
||||
);
|
||||
const res = await usersBackend.fetchUsers("pro");
|
||||
expect(res.invitations!.map((i) => i.email)).toEqual(["live@acme.com"]);
|
||||
expect(res.summary.pendingInvites).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("saas usersBackend — teams + auth config", () => {
|
||||
it("fetchTeams returns the single resolved team", async () => {
|
||||
const teams = await usersBackend.fetchTeams();
|
||||
expect(teams).toEqual([
|
||||
{ id: 1, name: "Acme", userCount: 3, owners: [], isPersonal: false },
|
||||
]);
|
||||
});
|
||||
|
||||
it("fetchAuthConfig is static (no direct-create, no OAuth/SAML)", async () => {
|
||||
const cfg = await usersBackend.fetchAuthConfig();
|
||||
expect(cfg).toEqual({
|
||||
canDirectCreate: false,
|
||||
hasOauth: false,
|
||||
hasSaml: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("saas usersBackend — mutations hit SaasTeamController", () => {
|
||||
it("inviteMember POSTs /invite with teamId+email and shows as pending", async () => {
|
||||
let seenBody: unknown = null;
|
||||
server.events.on("request:start", async ({ request }) => {
|
||||
if (request.method === "POST" && request.url.endsWith("/team/invite")) {
|
||||
seenBody = await request.clone().json();
|
||||
}
|
||||
});
|
||||
const result = await usersBackend.inviteMember("new@acme.com", "member");
|
||||
expect(result.successCount).toBe(1);
|
||||
expect(seenBody).toMatchObject({ teamId: 1, email: "new@acme.com" });
|
||||
server.events.removeAllListeners();
|
||||
|
||||
const res = await usersBackend.fetchUsers("pro");
|
||||
expect(res.invitations!.map((i) => i.email)).toContain("new@acme.com");
|
||||
});
|
||||
|
||||
it("renameTeam POSTs /{teamId}/rename and the new name is read back", async () => {
|
||||
await usersBackend.renameTeam(1, "Beta");
|
||||
const teams = await usersBackend.fetchTeams();
|
||||
expect(teams[0].name).toBe("Beta");
|
||||
});
|
||||
|
||||
it("removeMember DELETEs the team member and drops them from the roster", async () => {
|
||||
const before = await usersBackend.fetchUsers("pro");
|
||||
const target = before.members.find((m) => m.email === "priya@acme.com")!;
|
||||
await usersBackend.removeMember(target);
|
||||
const after = await usersBackend.fetchUsers("pro");
|
||||
expect(after.members.map((m) => m.email)).not.toContain("priya@acme.com");
|
||||
expect(after.members).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("removeMember throws when the member has no team", async () => {
|
||||
await expect(
|
||||
usersBackend.removeMember({
|
||||
id: "9",
|
||||
name: "x",
|
||||
email: "x@acme.com",
|
||||
role: "member",
|
||||
status: "active",
|
||||
lastActive: "-",
|
||||
}),
|
||||
).rejects.toThrow(/no team/i);
|
||||
});
|
||||
|
||||
it("cancelInvitation DELETEs the invitation", async () => {
|
||||
let seenUrl: string | null = null;
|
||||
server.events.on("request:start", ({ request }) => {
|
||||
if (
|
||||
request.method === "DELETE" &&
|
||||
request.url.includes("/invitations/")
|
||||
) {
|
||||
seenUrl = request.url;
|
||||
}
|
||||
});
|
||||
await usersBackend.cancelInvitation(101);
|
||||
expect(seenUrl).toContain("/api/v1/team/invitations/101");
|
||||
server.events.removeAllListeners();
|
||||
});
|
||||
});
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* Per-flavor backend for the Users page.
|
||||
*
|
||||
* The Users page UI is shared, but its data + mutation endpoints differ by
|
||||
* flavor. Self-hosted (org-admin) talks to the proprietary admin endpoints
|
||||
* (`/api/v1/user/admin/*`, `/api/v1/team/*`, `ui-data/admin-settings`), which
|
||||
* require ROLE_ADMIN. SaaS users are always ROLE_USER, so those 403 there;
|
||||
* instead the SaaS build talks to the invitation-based `SaasTeamController`
|
||||
* (`/api/v1/team/{my,invite,{id}/members,{id}/invitations,...}`) as a team
|
||||
* leader. Both go through `apiClient.local` (flavor-aware transport).
|
||||
*
|
||||
* Resolved at build time via the `@app/*` alias, same as `usersCapabilities`:
|
||||
* `src/proprietary/portal/usersBackend.ts` (self-hosted) and
|
||||
* `src/saas/portal/usersBackend.ts` (SaaS). This module is just the shared
|
||||
* contract; only the flavor-divergent operations live here. Self-hosted-only
|
||||
* actions (role changes, suspend, password reset, MFA, grants, create/delete
|
||||
* team) stay in `@portal/api/{users,teams}` and are gated off on SaaS via
|
||||
* `usersCapabilities`.
|
||||
*/
|
||||
import type { Tier } from "@portal/contexts/TierContext";
|
||||
import type { Team } from "@portal/api/teams";
|
||||
import type {
|
||||
AdminAuthConfig,
|
||||
InviteResult,
|
||||
Member,
|
||||
RoleId,
|
||||
UsersResponse,
|
||||
} from "@portal/api/users";
|
||||
|
||||
export interface UsersBackend {
|
||||
/** Roster + summary + (SaaS) pending invitations, adapted onto UsersResponse. */
|
||||
fetchUsers(tier: Tier): Promise<UsersResponse>;
|
||||
/** Teams shown in the roster / invite team picker. */
|
||||
fetchTeams(): Promise<Team[]>;
|
||||
/** Login/auth config that shapes the invite modal (direct-create, OAuth/SAML). */
|
||||
fetchAuthConfig(): Promise<AdminAuthConfig>;
|
||||
/** Invite a member by email (self-hosted: admin invite; SaaS: team invite). */
|
||||
inviteMember(
|
||||
email: string,
|
||||
role: Extract<RoleId, "admin" | "member">,
|
||||
teamId?: number,
|
||||
): Promise<InviteResult>;
|
||||
/** Rename a team. */
|
||||
renameTeam(teamId: number, newName: string): Promise<void>;
|
||||
/** Remove a member (self-hosted: delete account; SaaS: remove from team). */
|
||||
removeMember(member: Member): Promise<void>;
|
||||
/**
|
||||
* Cancel a pending invitation by id (SaaS). Never called on self-hosted
|
||||
* (gated off by `manageInvitations`); the proprietary impl rejects it.
|
||||
*/
|
||||
cancelInvitation(invitationId: number): Promise<void>;
|
||||
}
|
||||
@@ -28,12 +28,6 @@ export interface UsersCapabilities {
|
||||
renameTeam: boolean;
|
||||
/** Invite by email. */
|
||||
emailInvite: boolean;
|
||||
/**
|
||||
* Manage pending invitations (list + cancel). On SaaS an invite is a pending
|
||||
* TeamInvitation until accepted; self-hosted invites create the account at once,
|
||||
* so there's nothing pending to manage - off there.
|
||||
*/
|
||||
manageInvitations: boolean;
|
||||
/** Create an account directly with a password (self-hosted password login). */
|
||||
directCreate: boolean;
|
||||
/** Admin password reset. */
|
||||
|
||||
@@ -5,10 +5,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
* already-subscribed-redirect vs neither-secret-nor-url mapping, the mock flag,
|
||||
* unconfigured Supabase, and the portal-session path.
|
||||
*/
|
||||
const { getClient, invoke, getSession } = vi.hoisted(() => ({
|
||||
const { getClient, invoke } = vi.hoisted(() => ({
|
||||
getClient: vi.fn(),
|
||||
invoke: vi.fn(),
|
||||
getSession: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@portal/auth/saasSupabase", () => ({ ensureSaasSupabase: vi.fn() }));
|
||||
@@ -27,10 +26,7 @@ const req = { teamId: 1, successUrl: "s", cancelUrl: "c" } as const;
|
||||
|
||||
beforeEach(() => {
|
||||
invoke.mockReset();
|
||||
getSession.mockReset().mockResolvedValue({ data: { session: null } });
|
||||
getClient
|
||||
.mockReset()
|
||||
.mockReturnValue({ functions: { invoke }, auth: { getSession } });
|
||||
getClient.mockReset().mockReturnValue({ functions: { invoke } });
|
||||
});
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
@@ -87,51 +83,6 @@ describe("createCheckoutSession", () => {
|
||||
await expect(createCheckoutSession(req)).rejects.toThrow(/neither/);
|
||||
});
|
||||
|
||||
it("prefills billing_owner_email from the signed-in SaaS session", async () => {
|
||||
getSession.mockResolvedValue({
|
||||
data: { session: { user: { email: "leader@acme.com" } } },
|
||||
});
|
||||
invoke.mockResolvedValue({
|
||||
data: { success: true, client_secret: "cs_123" },
|
||||
error: null,
|
||||
});
|
||||
await createCheckoutSession(req);
|
||||
expect(invoke).toHaveBeenCalledWith(
|
||||
"create-checkout-session",
|
||||
expect.objectContaining({
|
||||
body: expect.objectContaining({
|
||||
billing_owner_email: "leader@acme.com",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("omits billing_owner_email when no session email is available", async () => {
|
||||
invoke.mockResolvedValue({
|
||||
data: { success: true, client_secret: "cs_123" },
|
||||
error: null,
|
||||
});
|
||||
await createCheckoutSession(req);
|
||||
const body = invoke.mock.calls[0][1].body as Record<string, unknown>;
|
||||
expect(body).not.toHaveProperty("billing_owner_email");
|
||||
});
|
||||
|
||||
it("an explicit billingOwnerEmail overrides the session", async () => {
|
||||
getSession.mockResolvedValue({
|
||||
data: { session: { user: { email: "session@acme.com" } } },
|
||||
});
|
||||
invoke.mockResolvedValue({
|
||||
data: { success: true, client_secret: "cs_123" },
|
||||
error: null,
|
||||
});
|
||||
await createCheckoutSession({
|
||||
...req,
|
||||
billingOwnerEmail: "explicit@acme.com",
|
||||
});
|
||||
const body = invoke.mock.calls[0][1].body as Record<string, unknown>;
|
||||
expect(body.billing_owner_email).toBe("explicit@acme.com");
|
||||
});
|
||||
|
||||
it("throws unconfigured when there is no Supabase client", async () => {
|
||||
getClient.mockReturnValue(null);
|
||||
const err = await createCheckoutSession(req).catch((e: unknown) => e);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user