Skip to content

Commit

Permalink
Merge pull request #879 from InseeFrLab/fix-title-accordion
Browse files Browse the repository at this point in the history
fix #878
  • Loading branch information
garronej authored Nov 21, 2024
2 parents d80017e + 3de84f5 commit 2328bd8
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe(symToStr({ computeRootForm }), () => {
type: "group",
helmValuesPath: ["services"],
description: undefined,
title: undefined,
nodes: [
{
type: "field",
Expand Down Expand Up @@ -208,6 +209,7 @@ describe(symToStr({ computeRootForm }), () => {
type: "group",
helmValuesPath: ["services"],
description: undefined,
title: undefined,
nodes: [
{
type: "field",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe(symToStr({ computeRootFormFieldGroup }), () => {
type: "group",
helmValuesPath: [],
description: undefined,
title: undefined,
nodes: [
{
type: "field",
Expand Down Expand Up @@ -87,6 +88,7 @@ describe(symToStr({ computeRootFormFieldGroup }), () => {
type: "group",
helmValuesPath: [],
description: undefined,
title: undefined,
nodes: [
{
type: "field",
Expand Down Expand Up @@ -117,6 +119,7 @@ describe(symToStr({ computeRootFormFieldGroup }), () => {
properties: {
persistence: {
description: "Configuration for persistence",
title: "Persistence",
type: "object",
properties: {
enabled: {
Expand Down Expand Up @@ -155,11 +158,13 @@ describe(symToStr({ computeRootFormFieldGroup }), () => {
type: "group",
helmValuesPath: [],
description: undefined,
title: undefined,
nodes: [
{
type: "group",
helmValuesPath: ["persistence"],
description: "Configuration for persistence",
title: "Persistence",
nodes: [
{
type: "field",
Expand Down Expand Up @@ -191,6 +196,7 @@ describe(symToStr({ computeRootFormFieldGroup }), () => {
properties: {
persistence: {
description: "Configuration for persistence",
title: "Persistence",
type: "object",
properties: {
enabled: {
Expand Down Expand Up @@ -228,11 +234,13 @@ describe(symToStr({ computeRootFormFieldGroup }), () => {
type: "group",
helmValuesPath: [],
description: undefined,
title: undefined,
nodes: [
{
type: "group",
helmValuesPath: ["persistence"],
description: "Configuration for persistence",
title: "Persistence",
nodes: [
{
type: "field",
Expand Down Expand Up @@ -289,6 +297,7 @@ describe(symToStr({ computeRootFormFieldGroup }), () => {
type: "group",
helmValuesPath: [],
description: undefined,
title: undefined,
nodes: [
{
type: "field",
Expand All @@ -306,11 +315,13 @@ describe(symToStr({ computeRootFormFieldGroup }), () => {
type: "group",
helmValuesPath: ["b"],
description: undefined,
title: undefined,
nodes: [
{
type: "group",
helmValuesPath: ["b", 0],
description: undefined,
title: undefined,
nodes: [
{
type: "field",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ function computeRootFormFieldGroup_rec(params: {
type: "group",
helmValuesPath,
description: helmValuesSchema.description,
title: helmValuesSchema.title ?? undefined,
nodes: Object.entries(helmValuesSchema.properties)
.map(([segment, helmValuesSchema_child]) =>
computeRootFormFieldGroup_rec({
Expand Down Expand Up @@ -388,6 +389,7 @@ function computeRootFormFieldGroup_rec(params: {
type: "group",
helmValuesPath,
description: helmValuesSchema.description,
title: undefined,
nodes: values
.map((...[, index]) =>
computeRootFormFieldGroup_rec({
Expand Down
2 changes: 1 addition & 1 deletion web/src/core/usecases/launcher/decoupledLogic/formTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type FormFieldGroup = {
type: "group";
helmValuesPath: (string | number)[];
description: string | undefined;

title: string | undefined;
nodes: (FormField | FormFieldGroup)[];
canAdd: boolean;
canRemove: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const rootForm: RootForm = {
type: "group",
helmValuesPath: ["services"],
description: undefined,
title: undefined,
nodes: [
{
type: "field",
Expand All @@ -30,6 +31,7 @@ const rootForm: RootForm = {
type: "group",
helmValuesPath: ["resources"],
description: undefined,
title: undefined,
nodes: [
{
type: "field",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ describe(symToStr({ mutateHelmValues_update }), () => {
type: "group",
helmValuesPath: ["resources"],
description: THROW_IF_ACCESSED,
title: THROW_IF_ACCESSED,
canAdd: THROW_IF_ACCESSED,
canRemove: THROW_IF_ACCESSED,
nodes: [
Expand Down
6 changes: 6 additions & 0 deletions web/src/ui/pages/launcher/RootFormComponent/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Props = {
className?: string;
helmValuesPath: (string | number)[];
description: string | undefined;
title: string | undefined;
nodes: (FormFieldGroup | FormField)[];
canAdd: boolean;
canRemove: boolean;
Expand All @@ -33,6 +34,7 @@ export function Accordion(props: Props) {
className,
helmValuesPath,
description,
title,
nodes,
canAdd,
canRemove,
Expand Down Expand Up @@ -134,6 +136,10 @@ export function Accordion(props: Props) {
>
<Text typo="label 1" componentProps={{ lang: "und" }}>
{(() => {
if (title !== undefined) {
return title;
}

const lastSegment = helmValuesPath[helmValuesPath.length - 1];

assert(typeof lastSegment === "string");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function ConfigurationTopLevelGroup(props: Props) {
{
helmValuesPath: ["Global"],
description: "configuration that applies to all charts",
title: undefined,
canAdd: false,
canRemove: false,
nodes: global
Expand All @@ -61,6 +62,7 @@ export function ConfigurationTopLevelGroup(props: Props) {
{
helmValuesPath: ["Miscellaneous"],
// TODO: i18n
title: undefined,
description: "Top level configuration values",
canAdd: false,
canRemove: false,
Expand All @@ -72,6 +74,7 @@ export function ConfigurationTopLevelGroup(props: Props) {
return {
helmValuesPath: [node.title],
description: node.description,
title: node.title,
canAdd: false,
canRemove: false,
nodes: [
Expand All @@ -92,6 +95,7 @@ export function ConfigurationTopLevelGroup(props: Props) {
return {
helmValuesPath: node.helmValuesPath,
description: node.description,
title: node.title,
canAdd: node.canAdd,
canRemove: node.canRemove,
nodes: node.nodes
Expand All @@ -105,11 +109,12 @@ export function ConfigurationTopLevelGroup(props: Props) {
return (
<div className={cx(classes.root, className)}>
{accordionEntries.map(
({ helmValuesPath, description, canAdd, canRemove, nodes }) => (
({ helmValuesPath, description, title, canAdd, canRemove, nodes }) => (
<Accordion
key={JSON.stringify(helmValuesPath)}
helmValuesPath={helmValuesPath}
description={description}
title={title}
canAdd={canAdd}
canRemove={canRemove}
nodes={nodes}
Expand Down

0 comments on commit 2328bd8

Please sign in to comment.