utils.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright 2023 Avaiga Private Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  5. * the License. You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  10. * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  11. * specific language governing permissions and limitations under the License.
  12. */
  13. import { useDynamicProperty } from "taipy-gui";
  14. // id, is_primary, config_id, creation_date, label, tags, properties(key, value), pipelines(id, label), authorized_tags, deletable
  15. export type ScenarioFull = [
  16. string,
  17. boolean,
  18. string,
  19. string,
  20. string,
  21. string[],
  22. Array<[string, string]>,
  23. Array<[string, string, boolean]>,
  24. string[],
  25. boolean,
  26. boolean,
  27. boolean
  28. ];
  29. export enum ScFProps {
  30. id,
  31. is_primary,
  32. config_id,
  33. creation_date,
  34. label,
  35. tags,
  36. properties,
  37. pipelines,
  38. authorized_tags,
  39. deletable,
  40. promotable,
  41. submittable,
  42. }
  43. export const ScenarioFullLength = Object.keys(ScFProps).length / 2;
  44. export interface ScenarioDict {
  45. config: string;
  46. name: string;
  47. date: string;
  48. properties: Array<[string, string]>;
  49. }
  50. export const FlagSx = {
  51. color: "common.white",
  52. fontSize: "0.75em",
  53. };
  54. export const BadgePos = {
  55. vertical: "top",
  56. horizontal: "left",
  57. };
  58. export const BadgeSx = {
  59. flex: "0 0 auto",
  60. "& .MuiBadge-badge": {
  61. fontSize: "1rem",
  62. width: "1em",
  63. height: "1em",
  64. p: 0,
  65. minWidth: "0",
  66. },
  67. };
  68. export const MainBoxSx = {
  69. maxWidth: 300,
  70. overflowY: "auto",
  71. };
  72. export const BaseTreeViewSx = {
  73. mb: 2,
  74. "& .MuiTreeItem-root .MuiTreeItem-content": {
  75. mb: 0.5,
  76. py: 1,
  77. px: 2,
  78. borderRadius: 0.5,
  79. },
  80. "& .MuiTreeItem-iconContainer:empty": {
  81. display: "none",
  82. },
  83. maxHeight: "50vh",
  84. overflowY: "auto",
  85. };
  86. export const ParentItemSx = {
  87. "& > .MuiTreeItem-content": {
  88. ".MuiTreeItem-label": {
  89. fontWeight: "fontWeightBold",
  90. },
  91. },
  92. };
  93. export const useClassNames = (libClassName?: string, dynamicClassName?: string, className?: string) =>
  94. ((libClassName || "") + " " + (useDynamicProperty(dynamicClassName, className, undefined) || "")).trim();
  95. export const disableColor = <T>(color: T, disabled: boolean) => (disabled ? ("disabled" as T) : color);