@coffre/ui 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dist/audit-sentences.d.ts +56 -0
  2. package/dist/audit-sentences.js +886 -0
  3. package/dist/audit-sentences.js.map +1 -0
  4. package/dist/chunks/audit-sentence-C8NnAdjF.js +48 -0
  5. package/dist/chunks/audit-sentence-C8NnAdjF.js.map +1 -0
  6. package/dist/chunks/{connected-apps-CGUQlFMx.js → connected-apps-6sMSgQ9U.js} +5 -5
  7. package/dist/chunks/{connected-apps-CGUQlFMx.js.map → connected-apps-6sMSgQ9U.js.map} +1 -1
  8. package/dist/chunks/{delete-place-CswZ-meh.js → delete-place-T469tSN9.js} +5 -5
  9. package/dist/chunks/{delete-place-CswZ-meh.js.map → delete-place-T469tSN9.js.map} +1 -1
  10. package/dist/chunks/{directory-DrswWQLT.js → directory-B_gVf7UL.js} +18 -17
  11. package/dist/chunks/directory-B_gVf7UL.js.map +1 -0
  12. package/dist/chunks/{folders-A6sbR_PG.js → folders-CVYauIDz.js} +3 -3
  13. package/dist/chunks/{folders-A6sbR_PG.js.map → folders-CVYauIDz.js.map} +1 -1
  14. package/dist/chunks/{grants-C0cb2oii.js → grants-Dn_EW2XW.js} +8 -8
  15. package/dist/chunks/grants-Dn_EW2XW.js.map +1 -0
  16. package/dist/chunks/{multi-combobox-B3SEv1gq.js → multi-combobox-fbBRzi9z.js} +3 -3
  17. package/dist/chunks/{multi-combobox-B3SEv1gq.js.map → multi-combobox-fbBRzi9z.js.map} +1 -1
  18. package/dist/chunks/{offboarding-C1jbG_dk.js → offboarding-CXM464J_.js} +81 -80
  19. package/dist/chunks/offboarding-CXM464J_.js.map +1 -0
  20. package/dist/chunks/{page-CfhC9Hp1.js → page-Cb0ZjGda.js} +7 -12
  21. package/dist/chunks/page-Cb0ZjGda.js.map +1 -0
  22. package/dist/chunks/{personal-tokens-xC9wulhg.js → personal-tokens-CSHMlRHy.js} +7 -7
  23. package/dist/chunks/personal-tokens-CSHMlRHy.js.map +1 -0
  24. package/dist/chunks/{principal-CI17XK13.js → principal-BKJxbAtE.js} +2 -2
  25. package/dist/chunks/{principal-CI17XK13.js.map → principal-BKJxbAtE.js.map} +1 -1
  26. package/dist/chunks/{principal-page-CdSeftGD.js → principal-page-COPmTDVW.js} +132 -19
  27. package/dist/chunks/principal-page-COPmTDVW.js.map +1 -0
  28. package/dist/chunks/{project-page-CHxjBE97.js → project-page-g5_n46Nz.js} +3 -3
  29. package/dist/chunks/{project-page-CHxjBE97.js.map → project-page-g5_n46Nz.js.map} +1 -1
  30. package/dist/chunks/protected-DEWeOrmI.js +77 -0
  31. package/dist/chunks/protected-DEWeOrmI.js.map +1 -0
  32. package/dist/chunks/{queries-D1JuimTu.js → queries-D4_o-bz3.js} +22 -155
  33. package/dist/chunks/queries-D4_o-bz3.js.map +1 -0
  34. package/dist/chunks/{references-D5llUGQL.js → references-wTh_DT0M.js} +27 -23
  35. package/dist/chunks/references-wTh_DT0M.js.map +1 -0
  36. package/dist/chunks/{role-field-CoCv8wse.js → role-field-BiP09qfN.js} +5 -5
  37. package/dist/chunks/role-field-BiP09qfN.js.map +1 -0
  38. package/dist/chunks/{row-state-CYH7kZHl.js → row-state-CYhtmUkc.js} +3 -3
  39. package/dist/chunks/{row-state-CYH7kZHl.js.map → row-state-CYhtmUkc.js.map} +1 -1
  40. package/dist/chunks/{signin-errors-TlQmQe0t.js → signin-errors-BMnox7XD.js} +5 -19
  41. package/dist/chunks/signin-errors-BMnox7XD.js.map +1 -0
  42. package/dist/chunks/{theme-rF44Wbmm.js → theme-imSolE1q.js} +3 -3
  43. package/dist/chunks/{theme-rF44Wbmm.js.map → theme-imSolE1q.js.map} +1 -1
  44. package/dist/chunks/{ui-CGdORVzW.js → ui-Q_Eczt7m.js} +7 -3
  45. package/dist/chunks/{ui-CGdORVzW.js.map → ui-Q_Eczt7m.js.map} +1 -1
  46. package/dist/chunks/{use-action-BxrHTBZw.js → use-action-BfnN-De2.js} +3 -3
  47. package/dist/chunks/{use-action-BxrHTBZw.js.map → use-action-BfnN-De2.js.map} +1 -1
  48. package/dist/chunks/{use-change-BorW2R6C.js → use-change-Cc0X4sF3.js} +6 -4
  49. package/dist/chunks/use-change-Cc0X4sF3.js.map +1 -0
  50. package/dist/chunks/{use-roles-BZnJ9Cq0.js → use-roles-stcv2QFj.js} +13 -56
  51. package/dist/chunks/use-roles-stcv2QFj.js.map +1 -0
  52. package/dist/chunks/{use-shell-CPskgi1k.js → use-shell-DMhLa2sh.js} +3 -3
  53. package/dist/chunks/{use-shell-CPskgi1k.js.map → use-shell-DMhLa2sh.js.map} +1 -1
  54. package/dist/index.d.ts +23 -55
  55. package/dist/index.js +12 -31
  56. package/dist/index.js.map +1 -1
  57. package/dist/pages/account.js +12 -12
  58. package/dist/pages/account.js.map +1 -1
  59. package/dist/pages/approval.js +2 -2
  60. package/dist/pages/audit.js +173 -196
  61. package/dist/pages/audit.js.map +1 -1
  62. package/dist/pages/device-login.js +2 -2
  63. package/dist/pages/environment.js +445 -252
  64. package/dist/pages/environment.js.map +1 -1
  65. package/dist/pages/login.js +6 -15
  66. package/dist/pages/login.js.map +1 -1
  67. package/dist/pages/oauth-authorize.js +2 -2
  68. package/dist/pages/project-access.js +11 -11
  69. package/dist/pages/project-environments.js +359 -28
  70. package/dist/pages/project-environments.js.map +1 -1
  71. package/dist/pages/project-settings.js +8 -8
  72. package/dist/pages/project.js +3 -3
  73. package/dist/pages/projects.js +8 -8
  74. package/dist/pages/service-account.js +19 -16
  75. package/dist/pages/service-account.js.map +1 -1
  76. package/dist/pages/service-accounts.js +6 -7
  77. package/dist/pages/service-accounts.js.map +1 -1
  78. package/dist/pages/settings.d.ts +1 -6
  79. package/dist/pages/settings.js +155 -286
  80. package/dist/pages/settings.js.map +1 -1
  81. package/dist/pages/unregistered.js +2 -2
  82. package/dist/pages/user.js +7 -8
  83. package/dist/pages/user.js.map +1 -1
  84. package/dist/pages/users.js +6 -7
  85. package/dist/pages/users.js.map +1 -1
  86. package/package.json +8 -3
  87. package/src/components/actions-log.tsx +8 -61
  88. package/src/components/directory.tsx +10 -9
  89. package/src/components/grants.tsx +2 -2
  90. package/src/components/icons.tsx +0 -2
  91. package/src/components/offboarding.tsx +9 -16
  92. package/src/components/page.tsx +2 -3
  93. package/src/components/personal-tokens.tsx +5 -2
  94. package/src/components/principal-page.tsx +5 -4
  95. package/src/components/protected.tsx +39 -52
  96. package/src/components/references.tsx +18 -7
  97. package/src/components/role-editor.tsx +68 -99
  98. package/src/components/role-field.tsx +1 -1
  99. package/src/components/trusted-workloads.tsx +6 -5
  100. package/src/components/ui.tsx +5 -0
  101. package/src/lib/audit-proofs.ts +51 -0
  102. package/src/lib/audit-sentences.ts +490 -529
  103. package/src/lib/bindings.ts +6 -0
  104. package/src/lib/changes.ts +3 -1
  105. package/src/lib/coffre.ts +2 -2
  106. package/src/lib/queries.ts +19 -168
  107. package/src/lib/reveal.ts +32 -5
  108. package/src/lib/roles.ts +10 -36
  109. package/src/lib/row-reads.ts +2 -2
  110. package/src/lib/signin-errors.ts +5 -33
  111. package/src/options.ts +3 -19
  112. package/src/pages/account.tsx +1 -1
  113. package/src/pages/audit.tsx +151 -228
  114. package/src/pages/environment.tsx +373 -247
  115. package/src/pages/login.tsx +2 -4
  116. package/src/pages/project-environments.tsx +322 -20
  117. package/src/pages/service-accounts.tsx +1 -1
  118. package/src/pages/settings.tsx +49 -134
  119. package/src/pages/user.tsx +2 -2
  120. package/src/pages/users.tsx +1 -1
  121. package/src/parity.ts +11 -20
  122. package/src/styles/globals.css +107 -273
  123. package/dist/chunks/actions-log-DupYCEyV.js +0 -1134
  124. package/dist/chunks/actions-log-DupYCEyV.js.map +0 -1
  125. package/dist/chunks/directory-DrswWQLT.js.map +0 -1
  126. package/dist/chunks/environment-actions-8rL9Cw6X.js +0 -576
  127. package/dist/chunks/environment-actions-8rL9Cw6X.js.map +0 -1
  128. package/dist/chunks/grants-C0cb2oii.js.map +0 -1
  129. package/dist/chunks/offboarding-C1jbG_dk.js.map +0 -1
  130. package/dist/chunks/page-CfhC9Hp1.js.map +0 -1
  131. package/dist/chunks/personal-tokens-xC9wulhg.js.map +0 -1
  132. package/dist/chunks/principal-page-CdSeftGD.js.map +0 -1
  133. package/dist/chunks/queries-D1JuimTu.js.map +0 -1
  134. package/dist/chunks/references-D5llUGQL.js.map +0 -1
  135. package/dist/chunks/role-field-CoCv8wse.js.map +0 -1
  136. package/dist/chunks/signin-errors-TlQmQe0t.js.map +0 -1
  137. package/dist/chunks/use-change-BorW2R6C.js.map +0 -1
  138. package/dist/chunks/use-roles-BZnJ9Cq0.js.map +0 -1
  139. package/src/components/environment-actions.tsx +0 -508
@@ -1,7 +1,7 @@
1
- import { a as ErrorLine, l as Spinner } from "../chunks/ui-CGdORVzW.js";
2
- import { R as Lock, Z as ShieldCheck, n as ClosedDoor, q as ProviderMark } from "../chunks/page-CfhC9Hp1.js";
3
- import { t as useShell } from "../chunks/use-shell-CPskgi1k.js";
4
- import { n as signinErrorMessage } from "../chunks/signin-errors-TlQmQe0t.js";
1
+ import { a as ErrorLine, l as Spinner } from "../chunks/ui-Q_Eczt7m.js";
2
+ import { K as ProviderMark, L as Lock, X as ShieldCheck, n as ClosedDoor } from "../chunks/page-Cb0ZjGda.js";
3
+ import { t as useShell } from "../chunks/use-shell-DMhLa2sh.js";
4
+ import { n as signinErrorMessage } from "../chunks/signin-errors-BMnox7XD.js";
5
5
  import { t as useOneTime } from "../chunks/one-time-DXEl9hbg.js";
6
6
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
7
7
  import { useState } from "react";
@@ -39,17 +39,8 @@ function CloudflareAuthenticationFailed() {
39
39
  function ProviderLoginPage({ title, note, providers }) {
40
40
  const search = Route.useSearch();
41
41
  const { next } = search;
42
- const once = useOneTime(search, [
43
- "error",
44
- "with",
45
- "via"
46
- ]);
47
- const label = (id) => providers.find((provider) => provider.id === id)?.label;
48
- const already = (once.with ?? "").split(",").map(label).filter((name) => name !== void 0);
49
- const message = signinErrorMessage(once.error, {
50
- providers: already,
51
- via: once.via === void 0 ? void 0 : label(once.via)
52
- });
42
+ const { error } = useOneTime(search, ["error"]);
43
+ const message = signinErrorMessage(error);
53
44
  const [leaving, setLeaving] = useState(null);
54
45
  const query = next === void 0 ? "" : `?next=${encodeURIComponent(next)}`;
55
46
  return /* @__PURE__ */ jsxs("section", {
@@ -1 +1 @@
1
- {"version":3,"file":"login.js","names":[],"sources":["../../src/pages/login.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport { useShell } from '../lib/use-shell';\nimport { signinErrorMessage } from '../lib/signin-errors';\nimport { useOneTime } from '../lib/one-time';\nimport { ErrorLine, Spinner } from '../components/ui';\nimport { ClosedDoor } from '../components/page';\nimport { Lock, ProviderMark, ShieldCheck } from '../components/icons';\nimport { pageRoute } from '../lib/page-route';\nimport type { login } from '../options';\n\nconst Route = pageRoute<typeof login>();\n\n/**\n * The front door, as `GET /api/auth` describes it.\n *\n * With coffre's own sign-in, one button per provider. Behind Cloudflare\n * Access, Access authenticates people before any request arrives, so this\n * page only explains why it is showing at all.\n */\nexport function LoginPage() {\n const { signin, access } = useShell().auth;\n if (signin !== null) return <ProviderLoginPage {...signin} />;\n return access?.assertion ? <CloudflareAuthenticationFailed /> : <CloudflareAccessRequired />;\n}\n\nfunction CloudflareAccessRequired() {\n return (\n <ClosedDoor icon={<Lock size={18} />} label=\"Cloudflare Access\" title=\"Open coffre through Access\">\n <p>\n Cloudflare Access signs you in to coffre, and this request did not come through it.\n Open coffre at its Access-protected hostname.\n </p>\n </ClosedDoor>\n );\n}\n\nfunction CloudflareAuthenticationFailed() {\n return (\n <ClosedDoor\n icon={<ShieldCheck size={18} />}\n label=\"Cloudflare Access\"\n title=\"Your identity could not be confirmed\"\n >\n <p>\n coffre could not verify the identity Cloudflare Access sent. Your Access session may\n have expired.\n </p>\n <p>\n Reopen coffre through its Access-protected hostname. If this keeps happening, tell\n whoever runs coffre.\n </p>\n </ClosedDoor>\n );\n}\n\nfunction ProviderLoginPage({\n title,\n note,\n providers,\n}: {\n title: string;\n note: string | null;\n providers: { id: string; label: string; brand: string }[];\n}) {\n const search = Route.useSearch();\n const { next } = search;\n // Shown once: a reload is a clean retry.\n const once = useOneTime(search, ['error', 'with', 'via']);\n const label = (id: string) => providers.find((provider) => provider.id === id)?.label;\n const already = (once.with ?? '').split(',').map(label).filter((name): name is string => name !== undefined);\n const message = signinErrorMessage(once.error, { providers: already, via: once.via === undefined ? undefined : label(once.via) });\n const [leaving, setLeaving] = useState<string | null>(null);\n const query = next === undefined ? '' : `?next=${encodeURIComponent(next)}`;\n\n return (\n <section className=\"card signin\" aria-labelledby=\"signin-title\">\n <div className=\"signin-head\">\n <h1 className=\"signin-title\" id=\"signin-title\">\n {title}\n </h1>\n <p className=\"signin-lede\">\n {note ?? 'Sign in with your organization’s account. Only people an admin has invited can get in.'}\n </p>\n </div>\n\n {message !== null && (\n <div className=\"signin-error\">\n <ErrorLine error={message} />\n </div>\n )}\n\n {providers.length === 0 ? (\n <p className=\"signin-empty\">\n No sign-in provider is configured. Whoever runs coffre lists them in{' '}\n <span className=\"mono\">signin({'{'} providers {'}'})</span>.\n </p>\n ) : (\n <ul className=\"providers\">\n {providers.map((provider) => (\n <li key={provider.id}>\n {/* A plain link: the provider's page is a full navigation away. */}\n <a\n className=\"btn provider\"\n href={`/auth/signin/${encodeURIComponent(provider.id)}${query}`}\n aria-busy={leaving === provider.id}\n onClick={() => setLeaving(provider.id)}\n >\n <span className=\"provider-mark\" aria-hidden>\n {leaving === provider.id ? <Spinner /> : <ProviderMark brand={provider.brand} />}\n </span>\n Continue with {provider.label}\n </a>\n </li>\n ))}\n </ul>\n )}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;AAWA,IAAM,QAAQ,UAAwB;;;;;;;;AAStC,SAAgB,YAAY;CAC1B,MAAM,EAAE,QAAQ,WAAW,SAAS,CAAC,CAAC;CACtC,IAAI,WAAW,MAAM,OAAO,oBAAC,mBAAD,EAAmB,GAAI,OAAS,CAAA;CAC5D,OAAO,QAAQ,YAAY,oBAAC,gCAAD,CAAiC,CAAA,IAAI,oBAAC,0BAAD,CAA2B,CAAA;AAC7F;AAEA,SAAS,2BAA2B;CAClC,OACE,oBAAC,YAAD;EAAY,MAAM,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;EAAG,OAAM;EAAoB,OAAM;YACpE,oBAAC,KAAD,EAAA,UAAG,oIAGA,CAAA;CACO,CAAA;AAEhB;AAEA,SAAS,iCAAiC;CACxC,OACE,qBAAC,YAAD;EACE,MAAM,oBAAC,aAAD,EAAa,MAAM,GAAK,CAAA;EAC9B,OAAM;EACN,OAAM;YAHR,CAKE,oBAAC,KAAD,EAAA,UAAG,qGAGA,CAAA,GACH,oBAAC,KAAD,EAAA,UAAG,0GAGA,CAAA,CACO;;AAEhB;AAEA,SAAS,kBAAkB,EACzB,OACA,MACA,aAKC;CACD,MAAM,SAAS,MAAM,UAAU;CAC/B,MAAM,EAAE,SAAS;CAEjB,MAAM,OAAO,WAAW,QAAQ;EAAC;EAAS;EAAQ;CAAK,CAAC;CACxD,MAAM,SAAS,OAAe,UAAU,MAAM,aAAa,SAAS,OAAO,EAAE,CAAC,EAAE;CAChF,MAAM,WAAW,KAAK,QAAQ,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,QAAQ,SAAyB,SAAS,KAAA,CAAS;CAC3G,MAAM,UAAU,mBAAmB,KAAK,OAAO;EAAE,WAAW;EAAS,KAAK,KAAK,QAAQ,KAAA,IAAY,KAAA,IAAY,MAAM,KAAK,GAAG;CAAE,CAAC;CAChI,MAAM,CAAC,SAAS,cAAc,SAAwB,IAAI;CAC1D,MAAM,QAAQ,SAAS,KAAA,IAAY,KAAK,SAAS,mBAAmB,IAAI;CAExE,OACE,qBAAC,WAAD;EAAS,WAAU;EAAc,mBAAgB;YAAjD;GACE,qBAAC,OAAD;IAAK,WAAU;cAAf,CACE,oBAAC,MAAD;KAAI,WAAU;KAAe,IAAG;eAC7B;IACC,CAAA,GACJ,oBAAC,KAAD;KAAG,WAAU;eACV,QAAQ;IACR,CAAA,CACA;;GAEJ,YAAY,QACX,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,WAAD,EAAW,OAAO,QAAU,CAAA;GACzB,CAAA;GAGN,UAAU,WAAW,IACpB,qBAAC,KAAD;IAAG,WAAU;cAAb;KAA4B;KAC2C;KACrE,qBAAC,QAAD;MAAM,WAAU;gBAAhB;OAAuB;OAAQ;OAAI;OAAY;OAAI;MAAO;;KAAC;IAC1D;QAEH,oBAAC,MAAD;IAAI,WAAU;cACX,UAAU,KAAK,aACd,oBAAC,MAAD,EAAA,UAEE,qBAAC,KAAD;KACE,WAAU;KACV,MAAM,gBAAgB,mBAAmB,SAAS,EAAE,IAAI;KACxD,aAAW,YAAY,SAAS;KAChC,eAAe,WAAW,SAAS,EAAE;eAJvC;MAME,oBAAC,QAAD;OAAM,WAAU;OAAgB,eAAA;iBAC7B,YAAY,SAAS,KAAK,oBAAC,SAAD,CAAU,CAAA,IAAI,oBAAC,cAAD,EAAc,OAAO,SAAS,MAAQ,CAAA;MAC3E,CAAA;MAAC;MACQ,SAAS;KACvB;OACD,GAbK,SAAS,EAad,CACL;GACC,CAAA;EAEC;;AAEb"}
1
+ {"version":3,"file":"login.js","names":[],"sources":["../../src/pages/login.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport { useShell } from '../lib/use-shell';\nimport { signinErrorMessage } from '../lib/signin-errors';\nimport { useOneTime } from '../lib/one-time';\nimport { ErrorLine, Spinner } from '../components/ui';\nimport { ClosedDoor } from '../components/page';\nimport { Lock, ProviderMark, ShieldCheck } from '../components/icons';\nimport { pageRoute } from '../lib/page-route';\nimport type { login } from '../options';\n\nconst Route = pageRoute<typeof login>();\n\n/**\n * The front door, as `GET /api/auth` describes it.\n *\n * With coffre's own sign-in, one button per provider. Behind Cloudflare\n * Access, Access authenticates people before any request arrives, so this\n * page only explains why it is showing at all.\n */\nexport function LoginPage() {\n const { signin, access } = useShell().auth;\n if (signin !== null) return <ProviderLoginPage {...signin} />;\n return access?.assertion ? <CloudflareAuthenticationFailed /> : <CloudflareAccessRequired />;\n}\n\nfunction CloudflareAccessRequired() {\n return (\n <ClosedDoor icon={<Lock size={18} />} label=\"Cloudflare Access\" title=\"Open coffre through Access\">\n <p>\n Cloudflare Access signs you in to coffre, and this request did not come through it.\n Open coffre at its Access-protected hostname.\n </p>\n </ClosedDoor>\n );\n}\n\nfunction CloudflareAuthenticationFailed() {\n return (\n <ClosedDoor\n icon={<ShieldCheck size={18} />}\n label=\"Cloudflare Access\"\n title=\"Your identity could not be confirmed\"\n >\n <p>\n coffre could not verify the identity Cloudflare Access sent. Your Access session may\n have expired.\n </p>\n <p>\n Reopen coffre through its Access-protected hostname. If this keeps happening, tell\n whoever runs coffre.\n </p>\n </ClosedDoor>\n );\n}\n\nfunction ProviderLoginPage({\n title,\n note,\n providers,\n}: {\n title: string;\n note: string | null;\n providers: { id: string; label: string; brand: string }[];\n}) {\n const search = Route.useSearch();\n const { next } = search;\n // Shown once: a reload is a clean retry.\n const { error } = useOneTime(search, ['error']);\n const message = signinErrorMessage(error);\n const [leaving, setLeaving] = useState<string | null>(null);\n const query = next === undefined ? '' : `?next=${encodeURIComponent(next)}`;\n\n return (\n <section className=\"card signin\" aria-labelledby=\"signin-title\">\n <div className=\"signin-head\">\n <h1 className=\"signin-title\" id=\"signin-title\">\n {title}\n </h1>\n <p className=\"signin-lede\">\n {note ?? 'Sign in with your organization’s account. Only people an admin has invited can get in.'}\n </p>\n </div>\n\n {message !== null && (\n <div className=\"signin-error\">\n <ErrorLine error={message} />\n </div>\n )}\n\n {providers.length === 0 ? (\n <p className=\"signin-empty\">\n No sign-in provider is configured. Whoever runs coffre lists them in{' '}\n <span className=\"mono\">signin({'{'} providers {'}'})</span>.\n </p>\n ) : (\n <ul className=\"providers\">\n {providers.map((provider) => (\n <li key={provider.id}>\n {/* A plain link: the provider's page is a full navigation away. */}\n <a\n className=\"btn provider\"\n href={`/auth/signin/${encodeURIComponent(provider.id)}${query}`}\n aria-busy={leaving === provider.id}\n onClick={() => setLeaving(provider.id)}\n >\n <span className=\"provider-mark\" aria-hidden>\n {leaving === provider.id ? <Spinner /> : <ProviderMark brand={provider.brand} />}\n </span>\n Continue with {provider.label}\n </a>\n </li>\n ))}\n </ul>\n )}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;AAWA,IAAM,QAAQ,UAAwB;;;;;;;;AAStC,SAAgB,YAAY;CAC1B,MAAM,EAAE,QAAQ,WAAW,SAAS,CAAC,CAAC;CACtC,IAAI,WAAW,MAAM,OAAO,oBAAC,mBAAD,EAAmB,GAAI,OAAS,CAAA;CAC5D,OAAO,QAAQ,YAAY,oBAAC,gCAAD,CAAiC,CAAA,IAAI,oBAAC,0BAAD,CAA2B,CAAA;AAC7F;AAEA,SAAS,2BAA2B;CAClC,OACE,oBAAC,YAAD;EAAY,MAAM,oBAAC,MAAD,EAAM,MAAM,GAAK,CAAA;EAAG,OAAM;EAAoB,OAAM;YACpE,oBAAC,KAAD,EAAA,UAAG,oIAGA,CAAA;CACO,CAAA;AAEhB;AAEA,SAAS,iCAAiC;CACxC,OACE,qBAAC,YAAD;EACE,MAAM,oBAAC,aAAD,EAAa,MAAM,GAAK,CAAA;EAC9B,OAAM;EACN,OAAM;YAHR,CAKE,oBAAC,KAAD,EAAA,UAAG,qGAGA,CAAA,GACH,oBAAC,KAAD,EAAA,UAAG,0GAGA,CAAA,CACO;;AAEhB;AAEA,SAAS,kBAAkB,EACzB,OACA,MACA,aAKC;CACD,MAAM,SAAS,MAAM,UAAU;CAC/B,MAAM,EAAE,SAAS;CAEjB,MAAM,EAAE,UAAU,WAAW,QAAQ,CAAC,OAAO,CAAC;CAC9C,MAAM,UAAU,mBAAmB,KAAK;CACxC,MAAM,CAAC,SAAS,cAAc,SAAwB,IAAI;CAC1D,MAAM,QAAQ,SAAS,KAAA,IAAY,KAAK,SAAS,mBAAmB,IAAI;CAExE,OACE,qBAAC,WAAD;EAAS,WAAU;EAAc,mBAAgB;YAAjD;GACE,qBAAC,OAAD;IAAK,WAAU;cAAf,CACE,oBAAC,MAAD;KAAI,WAAU;KAAe,IAAG;eAC7B;IACC,CAAA,GACJ,oBAAC,KAAD;KAAG,WAAU;eACV,QAAQ;IACR,CAAA,CACA;;GAEJ,YAAY,QACX,oBAAC,OAAD;IAAK,WAAU;cACb,oBAAC,WAAD,EAAW,OAAO,QAAU,CAAA;GACzB,CAAA;GAGN,UAAU,WAAW,IACpB,qBAAC,KAAD;IAAG,WAAU;cAAb;KAA4B;KAC2C;KACrE,qBAAC,QAAD;MAAM,WAAU;gBAAhB;OAAuB;OAAQ;OAAI;OAAY;OAAI;MAAO;;KAAC;IAC1D;QAEH,oBAAC,MAAD;IAAI,WAAU;cACX,UAAU,KAAK,aACd,oBAAC,MAAD,EAAA,UAEE,qBAAC,KAAD;KACE,WAAU;KACV,MAAM,gBAAgB,mBAAmB,SAAS,EAAE,IAAI;KACxD,aAAW,YAAY,SAAS;KAChC,eAAe,WAAW,SAAS,EAAE;eAJvC;MAME,oBAAC,QAAD;OAAM,WAAU;OAAgB,eAAA;iBAC7B,YAAY,SAAS,KAAK,oBAAC,SAAD,CAAU,CAAA,IAAI,oBAAC,cAAD,EAAc,OAAO,SAAS,MAAQ,CAAA;MAC3E,CAAA;MAAC;MACQ,SAAS;KACvB;OACD,GAbK,SAAS,EAad,CACL;GACC,CAAA;EAEC;;AAEb"}
@@ -1,5 +1,5 @@
1
- import { a as ErrorLine, c as Notice, l as Spinner } from "../chunks/ui-CGdORVzW.js";
2
- import { I as Link, c as statusOf, et as SlashCircle, g as ArrowRight, n as ClosedDoor, o as failureMessage, u as useCoffre } from "../chunks/page-CfhC9Hp1.js";
1
+ import { a as ErrorLine, c as Notice, l as Spinner } from "../chunks/ui-Q_Eczt7m.js";
2
+ import { $ as SlashCircle, F as Link, c as statusOf, g as ArrowRight, n as ClosedDoor, o as failureMessage, u as useCoffre } from "../chunks/page-Cb0ZjGda.js";
3
3
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
4
4
  import { useState } from "react";
5
5
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -1,15 +1,15 @@
1
- import { c as listsServices, x as queries } from "../chunks/queries-D1JuimTu.js";
2
- import { c as Notice, i as EmptyState, l as Spinner, s as Modal } from "../chunks/ui-CGdORVzW.js";
3
- import { K as Plus, N as Key, Y as Search, _ as Check, at as User, u as useCoffre } from "../chunks/page-CfhC9Hp1.js";
4
- import { t as useShell } from "../chunks/use-shell-CPskgi1k.js";
5
- import { Z as projectAccessLabel, t as useChange, v as grantAccess, y as grantId } from "../chunks/use-change-BorW2R6C.js";
6
- import { m as roleNameOf, t as useRoles } from "../chunks/use-roles-BZnJ9Cq0.js";
7
- import { n as PrincipalLink, t as PrincipalAvatar } from "../chunks/principal-CI17XK13.js";
8
- import { r as KIND } from "../chunks/directory-DrswWQLT.js";
1
+ import { o as listsServices, y as queries } from "../chunks/queries-D4_o-bz3.js";
2
+ import { c as Notice, i as EmptyState, l as Spinner, s as Modal } from "../chunks/ui-Q_Eczt7m.js";
3
+ import { G as Plus, J as Search, M as Key, _ as Check, it as User, u as useCoffre } from "../chunks/page-Cb0ZjGda.js";
4
+ import { t as useShell } from "../chunks/use-shell-DMhLa2sh.js";
5
+ import { Z as projectAccessLabel, t as useChange, v as grantAccess, y as grantId } from "../chunks/use-change-Cc0X4sF3.js";
6
+ import { f as roleNameOf, t as useRoles } from "../chunks/use-roles-stcv2QFj.js";
7
+ import { n as PrincipalLink, t as PrincipalAvatar } from "../chunks/principal-BKJxbAtE.js";
8
+ import { r as KIND } from "../chunks/directory-B_gVf7UL.js";
9
9
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
10
- import { a as ReferencesInto } from "../chunks/references-D5llUGQL.js";
11
- import { i as useRefusedGrants, n as GrantsTable, r as RefusedGrants, t as GrantRowView } from "../chunks/grants-C0cb2oii.js";
12
- import { t as useProject } from "../chunks/project-page-CHxjBE97.js";
10
+ import { a as ReferencesInto } from "../chunks/references-wTh_DT0M.js";
11
+ import { i as useRefusedGrants, n as GrantsTable, r as RefusedGrants, t as GrantRowView } from "../chunks/grants-Dn_EW2XW.js";
12
+ import { t as useProject } from "../chunks/project-page-g5_n46Nz.js";
13
13
  import { useId, useState } from "react";
14
14
  import { Link } from "@tanstack/react-router";
15
15
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -1,17 +1,21 @@
1
- import { M as isActiveAccessibleEnvironment, j as hasEnvironmentDetails, n as affects, o as keys, x as queries } from "../chunks/queries-D1JuimTu.js";
2
- import { a as ErrorLine, i as EmptyState, n as ConfirmDialog, u as Timestamp } from "../chunks/ui-CGdORVzW.js";
3
- import { K as Plus, b as ChevronRight, rt as Trash, t as Card, u as useCoffre } from "../chunks/page-CfhC9Hp1.js";
4
- import { a as rowClass, i as RowPending, t as ItemFailure } from "../chunks/row-state-CYH7kZHl.js";
5
- import { t as useShell } from "../chunks/use-shell-CPskgi1k.js";
6
- import { g as environmentId, n as useChangeStatus } from "../chunks/use-change-BorW2R6C.js";
7
- import { t as PrincipalAvatar } from "../chunks/principal-CI17XK13.js";
1
+ import { D as isActiveAccessibleEnvironment, E as hasEnvironmentDetails, i as keys, t as affects, y as queries } from "../chunks/queries-D4_o-bz3.js";
2
+ import { a as ErrorLine, c as Notice, i as EmptyState, n as ConfirmDialog, o as MenuPopup, s as Modal, u as Timestamp } from "../chunks/ui-Q_Eczt7m.js";
3
+ import { G as Plus, H as MoreHorizontal, W as Pencil, b as ChevronRight, h as Archive, nt as Trash, q as RotateBack, t as Card, u as useCoffre } from "../chunks/page-Cb0ZjGda.js";
4
+ import { a as rowClass, i as RowPending, t as ItemFailure } from "../chunks/row-state-CYhtmUkc.js";
5
+ import { t as useShell } from "../chunks/use-shell-DMhLa2sh.js";
6
+ import { O as renameEnvironment, g as environmentId, l as createEnvironment, n as useChangeStatus, o as archiveEnvironment, t as useChange } from "../chunks/use-change-Cc0X4sF3.js";
7
+ import { t as environmentSlugProblem } from "../chunks/validation-DiHIwZRA.js";
8
+ import { t as PrincipalAvatar } from "../chunks/principal-BKJxbAtE.js";
8
9
  import { t as pageRoute } from "../chunks/page-route-Drfw7lmn.js";
9
- import { t as useAction } from "../chunks/use-action-BxrHTBZw.js";
10
- import { n as NewEnvironment, r as Protection, t as EnvironmentMenu } from "../chunks/environment-actions-8rL9Cw6X.js";
11
- import { t as useProject } from "../chunks/project-page-CHxjBE97.js";
10
+ import { t as useAction } from "../chunks/use-action-BfnN-De2.js";
11
+ import { t as Protection } from "../chunks/protected-DEWeOrmI.js";
12
+ import { o as archiveBlockers, t as ArchiveBlocked } from "../chunks/references-wTh_DT0M.js";
13
+ import { t as useProject } from "../chunks/project-page-g5_n46Nz.js";
14
+ import { t as DeletePlaceDialog } from "../chunks/delete-place-T469tSN9.js";
12
15
  import { useState } from "react";
13
16
  import { Link } from "@tanstack/react-router";
14
17
  import { toast } from "sonner";
18
+ import { Menu } from "@base-ui/react/menu";
15
19
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
16
20
  import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
17
21
  //#region src/pages/project-environments.tsx
@@ -56,6 +60,7 @@ function EnvironmentsPanel({ project, canManage, grants }) {
56
60
  children: [current.map((environment) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(EnvironmentCard, {
57
61
  project: project.slug,
58
62
  environment,
63
+ isAdmin: canManage,
59
64
  grants
60
65
  }) }, `${project.slug}:${environment.slug}`)), refused.map(({ mutationId, vars, status }) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("div", {
61
66
  className: "env-card is-muted is-failed",
@@ -74,7 +79,11 @@ function EnvironmentsPanel({ project, canManage, grants }) {
74
79
  }),
75
80
  canManage && /* @__PURE__ */ jsx("div", {
76
81
  className: "table-actions",
77
- children: /* @__PURE__ */ jsx(AddEnvironment, { project: project.slug })
82
+ children: /* @__PURE__ */ jsx(NewEnvironment, {
83
+ project: project.slug,
84
+ sources: current.filter((environment) => isActiveAccessibleEnvironment(environment) && !environment.personal).map((environment) => environment.slug),
85
+ guarded: current.filter((environment) => environment.protected).map((environment) => environment.slug)
86
+ })
78
87
  }),
79
88
  canManage && /* @__PURE__ */ jsx(PersonalConfigs, { project: project.slug }),
80
89
  archived.length > 0 && /* @__PURE__ */ jsxs("section", {
@@ -88,6 +97,7 @@ function EnvironmentsPanel({ project, canManage, grants }) {
88
97
  children: archived.map((environment) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(EnvironmentCard, {
89
98
  project: project.slug,
90
99
  environment,
100
+ isAdmin: canManage,
91
101
  grants
92
102
  }) }, environment.slug))
93
103
  })]
@@ -126,8 +136,23 @@ function useLastChange(project, environment, enabled) {
126
136
  return last;
127
137
  }
128
138
  var SHOWN_HOLDERS = 4;
129
- function EnvironmentCard({ project, environment, grants }) {
130
- const { principal } = useShell();
139
+ function EnvironmentCard({ project, environment, isAdmin, grants }) {
140
+ const [renaming, setRenaming] = useState(false);
141
+ const [confirming, setConfirming] = useState(false);
142
+ const [deleting, setDeleting] = useState(false);
143
+ const { capabilities } = useShell();
144
+ const [slug, setSlug] = useState(environment.slug);
145
+ const coffre = useCoffre();
146
+ const rename = useChange(renameEnvironment(coffre, project));
147
+ const archive = useChange(archiveEnvironment(coffre, project));
148
+ const place = `${project}/${environment.slug}`;
149
+ const archiving = confirming && environment.details?.archivedAt == null;
150
+ const { data: lent } = useQuery({
151
+ ...queries.references(coffre, place),
152
+ enabled: archiving
153
+ });
154
+ const blockers = archiving && lent?.ok === true ? archiveBlockers(place, lent.references) : [];
155
+ const asking = archiving && lent === void 0;
131
156
  const { status, dismiss } = useChangeStatus(keys.projects);
132
157
  const state = status(environmentId(project, environment.slug));
133
158
  const pending = state.state === "pending";
@@ -135,8 +160,12 @@ function EnvironmentCard({ project, environment, grants }) {
135
160
  const isArchived = details !== null && details.archivedAt !== null;
136
161
  const secretCount = details?.secretCount ?? null;
137
162
  const opens = details !== null && !isArchived && environment.accessible && !pending;
163
+ const manageable = isAdmin && details !== null;
164
+ const deletable = manageable && isArchived && capabilities.runsInstance;
165
+ const slugError = slug === "" ? null : environmentSlugProblem(slug);
138
166
  const lastChange = useLastChange(project, environment.slug, opens);
139
167
  const holders = environment.personal === true ? [] : holdersOf(grants, environment.slug);
168
+ const reslugged = slug !== environment.slug && slug !== "" && slugError === null;
140
169
  return /* @__PURE__ */ jsxs("div", {
141
170
  className: `env-card${opens ? " is-link" : " is-muted"} ${rowClass(state)}`,
142
171
  children: [
@@ -159,8 +188,8 @@ function EnvironmentCard({ project, environment, grants }) {
159
188
  children: environment.slug
160
189
  }),
161
190
  /* @__PURE__ */ jsx(Protection, {
162
- environment,
163
- compact: true
191
+ project,
192
+ environment
164
193
  }),
165
194
  environment.personal === true ? /* @__PURE__ */ jsx("span", {
166
195
  className: "tag tag-blue",
@@ -223,14 +252,169 @@ function EnvironmentCard({ project, environment, grants }) {
223
252
  "aria-hidden": true
224
253
  }),
225
254
  pending && /* @__PURE__ */ jsx(RowPending, { status: state }),
226
- !pending && /* @__PURE__ */ jsx(EnvironmentMenu, {
227
- project,
228
- environment: environment.slug,
229
- inProject: environment,
230
- ownConfig: principal?.type === "user" && isActiveAccessibleEnvironment(environment) && environment.personal !== true,
231
- busy: false,
232
- follow: false,
233
- className: "act act-quiet env-card-menu"
255
+ manageable && !pending && environment.personal !== true && /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
256
+ className: "act act-quiet env-card-menu",
257
+ "aria-label": `Actions for ${environment.slug}`,
258
+ children: /* @__PURE__ */ jsx(MoreHorizontal, { size: 16 })
259
+ }), /* @__PURE__ */ jsxs(MenuPopup, {
260
+ align: "end",
261
+ children: [
262
+ /* @__PURE__ */ jsxs(Menu.Item, {
263
+ className: "menu-item",
264
+ onClick: () => {
265
+ setSlug(environment.slug);
266
+ setRenaming(true);
267
+ },
268
+ children: [/* @__PURE__ */ jsx(Pencil, { size: 14 }), "Rename"]
269
+ }),
270
+ /* @__PURE__ */ jsx(Menu.Separator, { className: "menu-sep" }),
271
+ /* @__PURE__ */ jsxs(Menu.Item, {
272
+ className: `menu-item${isArchived ? "" : " menu-item-danger"}`,
273
+ onClick: () => setConfirming(true),
274
+ children: [isArchived ? /* @__PURE__ */ jsx(RotateBack, { size: 14 }) : /* @__PURE__ */ jsx(Archive, { size: 14 }), isArchived ? "Restore" : "Archive…"]
275
+ }),
276
+ deletable && /* @__PURE__ */ jsxs(Menu.Item, {
277
+ className: "menu-item menu-item-danger",
278
+ onClick: () => setDeleting(true),
279
+ children: [/* @__PURE__ */ jsx(Trash, { size: 14 }), "Delete…"]
280
+ })
281
+ ]
282
+ })] }),
283
+ manageable && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Modal, {
284
+ open: renaming,
285
+ onOpenChange: setRenaming,
286
+ title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
287
+ "Rename",
288
+ " ",
289
+ /* @__PURE__ */ jsxs("span", {
290
+ className: "mono",
291
+ children: [
292
+ project,
293
+ "/",
294
+ environment.slug
295
+ ]
296
+ })
297
+ ] }),
298
+ children: /* @__PURE__ */ jsxs("form", {
299
+ className: "form",
300
+ onSubmit: (event) => {
301
+ event.preventDefault();
302
+ rename({
303
+ from: environment.slug,
304
+ slug
305
+ });
306
+ setRenaming(false);
307
+ },
308
+ children: [
309
+ /* @__PURE__ */ jsxs("label", {
310
+ className: "field",
311
+ children: [
312
+ /* @__PURE__ */ jsx("span", {
313
+ className: "label",
314
+ children: "Slug"
315
+ }),
316
+ /* @__PURE__ */ jsx("input", {
317
+ className: "input input-mono",
318
+ autoFocus: true,
319
+ spellCheck: false,
320
+ value: slug,
321
+ "aria-invalid": slugError !== null,
322
+ onChange: (event) => setSlug(event.target.value)
323
+ }),
324
+ /* @__PURE__ */ jsx("span", {
325
+ className: `hint${slugError !== null ? " edit-note-error" : ""}`,
326
+ children: slugError ?? `Anything running coffre run ${project}/${environment.slug} will need the new path.`
327
+ })
328
+ ]
329
+ }),
330
+ reslugged && /* @__PURE__ */ jsxs(Notice, {
331
+ tone: "info",
332
+ children: [
333
+ "Instance roles scoped to ",
334
+ /* @__PURE__ */ jsx("span", {
335
+ className: "mono",
336
+ children: environment.slug
337
+ }),
338
+ " stop reaching it; those scoped to ",
339
+ /* @__PURE__ */ jsx("span", {
340
+ className: "mono",
341
+ children: slug
342
+ }),
343
+ " start."
344
+ ]
345
+ }),
346
+ /* @__PURE__ */ jsxs("div", {
347
+ className: "dialog-actions",
348
+ children: [/* @__PURE__ */ jsx("button", {
349
+ className: "btn",
350
+ type: "button",
351
+ onClick: () => setRenaming(false),
352
+ children: "Cancel"
353
+ }), /* @__PURE__ */ jsx("button", {
354
+ className: "btn btn-primary",
355
+ type: "submit",
356
+ disabled: slug === environment.slug || slug === "" || slugError !== null,
357
+ children: "Save"
358
+ })]
359
+ })
360
+ ]
361
+ })
362
+ }), /* @__PURE__ */ jsx(ConfirmDialog, {
363
+ open: confirming,
364
+ onOpenChange: setConfirming,
365
+ title: /* @__PURE__ */ jsxs(Fragment$1, { children: [
366
+ isArchived ? "Restore" : "Archive",
367
+ " ",
368
+ /* @__PURE__ */ jsxs("span", {
369
+ className: "mono",
370
+ children: [
371
+ project,
372
+ "/",
373
+ environment.slug
374
+ ]
375
+ }),
376
+ "?"
377
+ ] }),
378
+ body: secretCount === null ? /* @__PURE__ */ jsx(Fragment$1, { children: "This changes whether the environment serves its secrets. Values and history stay stored." }) : isArchived ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
379
+ "It serves its ",
380
+ secretCount,
381
+ " secret",
382
+ secretCount === 1 ? "" : "s",
383
+ " again, to everyone with a grant on it."
384
+ ] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
385
+ "Its ",
386
+ secretCount,
387
+ " secret",
388
+ secretCount === 1 ? "" : "s",
389
+ " stop being served, so anything running ",
390
+ /* @__PURE__ */ jsx("code", { children: "coffre run" }),
391
+ " against",
392
+ " ",
393
+ /* @__PURE__ */ jsxs("span", {
394
+ className: "mono",
395
+ children: [
396
+ project,
397
+ "/",
398
+ environment.slug
399
+ ]
400
+ }),
401
+ " ",
402
+ "loses them at its next start. Values and history survive, and restoring is one click."
403
+ ] }),
404
+ detail: /* @__PURE__ */ jsx(ArchiveBlocked, { references: blockers }),
405
+ confirmLabel: isArchived ? "Restore environment" : "Archive environment",
406
+ confirmDisabled: asking || blockers.length > 0,
407
+ destructive: !isArchived,
408
+ onConfirm: () => archive({
409
+ slug: environment.slug,
410
+ archived: !isArchived
411
+ })
412
+ })] }),
413
+ deletable && /* @__PURE__ */ jsx(DeletePlaceDialog, {
414
+ path: `${project}/${environment.slug}`,
415
+ open: deleting,
416
+ onOpenChange: setDeleting,
417
+ onDeleted: () => toast.success(`${project}/${environment.slug} deleted`)
234
418
  }),
235
419
  /* @__PURE__ */ jsx(ItemFailure, {
236
420
  status: state,
@@ -312,17 +496,164 @@ function PersonalConfigs({ project }) {
312
496
  ]
313
497
  });
314
498
  }
315
- /** Add environment, and the dialog it opens. */
316
- function AddEnvironment({ project }) {
499
+ /**
500
+ * A new environment, empty, or forked from one you can read: inheriting
501
+ * its keys live (docs/design/forking.md), or each of them copied, value and
502
+ * folder, without history, or a reference to it. Copying is a read, and
503
+ * logged as one; inheriting reads nothing until the fork is read.
504
+ */
505
+ function NewEnvironment({ project, sources, guarded }) {
317
506
  const [open, setOpen] = useState(false);
507
+ const [slug, setSlug] = useState("");
508
+ const [start, setStart] = useState("");
509
+ const [how, from] = start === "" ? ["", ""] : start.split(":");
510
+ const coffre = useCoffre();
511
+ const { data: parent } = useQuery({
512
+ ...queries.secrets(coffre, {
513
+ project,
514
+ environment: from
515
+ }),
516
+ enabled: how === "ref"
517
+ });
518
+ const copied = how === "ref" && parent?.ok === true ? parent.keys.filter((key) => !key.archived && key.reference !== null && !key.reference.canOpenSource).map((key) => key.key) : [];
519
+ const create = useChange(createEnvironment(coffre, project));
520
+ const slugError = slug === "" ? null : environmentSlugProblem(slug);
521
+ function close() {
522
+ setOpen(false);
523
+ }
318
524
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("button", {
319
525
  className: "btn btn-primary",
320
526
  onClick: () => setOpen(true),
321
527
  children: [/* @__PURE__ */ jsx(Plus, { size: 14 }), "Add environment"]
322
- }), /* @__PURE__ */ jsx(NewEnvironment, {
323
- project,
528
+ }), /* @__PURE__ */ jsx(Modal, {
324
529
  open,
325
- onOpenChange: setOpen
530
+ onOpenChange: (next) => next ? setOpen(true) : close(),
531
+ title: /* @__PURE__ */ jsxs(Fragment$1, { children: ["New environment in ", /* @__PURE__ */ jsx("span", {
532
+ className: "mono",
533
+ children: project
534
+ })] }),
535
+ children: /* @__PURE__ */ jsxs("form", {
536
+ className: "form",
537
+ onSubmit: (event) => {
538
+ event.preventDefault();
539
+ create({
540
+ slug,
541
+ ...from === "" ? {} : { from },
542
+ ...how === "ref" ? { references: true } : {},
543
+ ...how === "inherit" ? { inherit: true } : {}
544
+ });
545
+ setSlug("");
546
+ setStart("");
547
+ close();
548
+ },
549
+ children: [
550
+ /* @__PURE__ */ jsxs("label", {
551
+ className: "field",
552
+ children: [
553
+ /* @__PURE__ */ jsx("span", {
554
+ className: "label",
555
+ children: "Slug"
556
+ }),
557
+ /* @__PURE__ */ jsx("input", {
558
+ className: "input input-mono",
559
+ autoFocus: true,
560
+ spellCheck: false,
561
+ autoComplete: "off",
562
+ placeholder: "staging",
563
+ value: slug,
564
+ "aria-invalid": slugError !== null,
565
+ onChange: (event) => setSlug(event.target.value)
566
+ }),
567
+ /* @__PURE__ */ jsx("span", {
568
+ className: `hint${slugError !== null ? " edit-note-error" : ""}`,
569
+ children: slugError ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [
570
+ "The CLI will address it as",
571
+ " ",
572
+ /* @__PURE__ */ jsxs("span", {
573
+ className: "mono",
574
+ children: [
575
+ project,
576
+ "/",
577
+ slug === "" ? "staging" : slug
578
+ ]
579
+ }),
580
+ "."
581
+ ] })
582
+ })
583
+ ]
584
+ }),
585
+ sources.length > 0 && /* @__PURE__ */ jsxs("label", {
586
+ className: "field",
587
+ children: [
588
+ /* @__PURE__ */ jsx("span", {
589
+ className: "label",
590
+ children: "Start from"
591
+ }),
592
+ /* @__PURE__ */ jsxs("select", {
593
+ className: "select",
594
+ value: start,
595
+ onChange: (event) => setStart(event.target.value),
596
+ children: [
597
+ /* @__PURE__ */ jsx("option", {
598
+ value: "",
599
+ children: "Empty"
600
+ }),
601
+ sources.map((source) => /* @__PURE__ */ jsxs("option", {
602
+ value: `inherit:${source}`,
603
+ children: ["Inheriting from ", source]
604
+ }, `inherit:${source}`)),
605
+ sources.map((source) => /* @__PURE__ */ jsxs("option", {
606
+ value: `copy:${source}`,
607
+ children: ["A copy of ", source]
608
+ }, `copy:${source}`)),
609
+ sources.map((source) => /* @__PURE__ */ jsxs("option", {
610
+ value: `ref:${source}`,
611
+ children: ["References to ", source]
612
+ }, `ref:${source}`))
613
+ ]
614
+ }),
615
+ /* @__PURE__ */ jsx("span", {
616
+ className: "hint",
617
+ children: how === "" ? "No secrets yet." : how === "inherit" ? `Keeps reading ${from}'s keys, live, except those you set or remove here. Whoever reads ${slug === "" ? "the new environment" : slug} needs read on ${from} too, for those.` : how === "copy" ? `Each of ${from}'s keys, with its current value and folder, without history.` : `Each key follows ${from}'s until it gets a value of its own. Whoever can read ${slug === "" ? "the new environment" : slug} will read ${from}'s values through them, even without access to ${from}.`
618
+ }),
619
+ from !== "" && guarded.includes(from) && /* @__PURE__ */ jsxs("span", {
620
+ className: "hint",
621
+ children: [/* @__PURE__ */ jsx("span", {
622
+ className: "mono",
623
+ children: from
624
+ }), " is protected, so the new environment is too, from its first moment."]
625
+ }),
626
+ copied.length > 0 && /* @__PURE__ */ jsxs("span", {
627
+ className: "hint",
628
+ children: [
629
+ "Copied instead, since you read their source only through ",
630
+ from,
631
+ ": ",
632
+ /* @__PURE__ */ jsx("span", {
633
+ className: "mono",
634
+ children: copied.join(", ")
635
+ }),
636
+ "."
637
+ ]
638
+ })
639
+ ]
640
+ }),
641
+ /* @__PURE__ */ jsxs("div", {
642
+ className: "dialog-actions",
643
+ children: [/* @__PURE__ */ jsx("button", {
644
+ className: "btn",
645
+ type: "button",
646
+ onClick: close,
647
+ children: "Cancel"
648
+ }), /* @__PURE__ */ jsx("button", {
649
+ className: "btn btn-primary",
650
+ type: "submit",
651
+ disabled: slug === "" || slugError !== null,
652
+ children: "Add environment"
653
+ })]
654
+ })
655
+ ]
656
+ })
326
657
  })] });
327
658
  }
328
659
  //#endregion