Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
AruSeito committed Jan 29, 2024
2 parents 9a18d09 + 73b8035 commit 26095e2
Show file tree
Hide file tree
Showing 17 changed files with 168 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ jobs:
- name: Deploy to Kubernetes
run: |
cd k8s-application-do/namespace-$ILLA_APP_ENV
kubectl delete pod -n $ILLA_APP_ENV -l repo=illa-builder-frontend
kubectl apply -f ./illa-builder-frontend/ -n $ILLA_APP_ENV
kubectl -n $ILLA_APP_ENV rollout restart deployment illa-builder-frontend
3 changes: 2 additions & 1 deletion apps/builder/.env.cloud
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ ILLA_APP_ENV=production
ILLA_GOOGLE_MAP_KEY=google_map_key
ILLA_MIXPANEL_API_KEY=0
ILLA_BUILDER_URL=BUILDER_PATH
ILLA_MARKET_URL=MARKET_PATH
ILLA_MARKET_URL=MARKET_PATH
ILLA_SENTRY_AUTH_TOKEN=SENTRY_AUTH_TOKEN
11 changes: 10 additions & 1 deletion apps/builder/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ if (
) {
Sentry.init({
dsn: import.meta.env.ILLA_SENTRY_SERVER_API,
integrations: [new Sentry.BrowserTracing()],
integrations: [
new Sentry.BrowserTracing({
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ["localhost"],
}),
new Sentry.Replay({
maskAllText: false,
blockAllMedia: false,
}),
],
environment: import.meta.env.ILLA_APP_ENV,
tracesSampleRate: 1.0,
release: `illa-builder@${import.meta.env.ILLA_APP_VERSION}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MSSQLModeProps } from "@/page/App/components/Actions/ActionPanel/Micros
import { InputEditor } from "@/page/App/components/Actions/InputEditor"

export const MSSQLSqlMode: FC<MSSQLModeProps> = (props) => {
const { modeContent, onChange } = props
const { modeContent, showSafeModeTips, onChange } = props
const { t } = useTranslation()

return (
Expand All @@ -16,7 +16,7 @@ export const MSSQLSqlMode: FC<MSSQLModeProps> = (props) => {
lineNumbers={true}
value={(modeContent as MicrosoftSqlActionSqlMode).sql}
onChange={(value) => onChange(value, "sql")}
showSafeModeTips
showSafeModeTips={showSafeModeTips}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const MicrosoftSqlPanel: FC = () => {
<MSSQLSqlMode
modeContent={sqlModeInitial}
onChange={handleQueryChange}
showSafeModeTips={content.mode === "sql-safe"}
/>
) : (
<MSSQLGUIMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export interface MSSQLModeProps {
modeContent: MicrosoftSqlActionType
onChange: (value: string, name: string) => void
resourceID?: string
showSafeModeTips?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const MysqlLikePanel: FC = () => {
onChange={handleQueryChange}
onBlur={onBlurOnCodeMirror}
/>
<SQLModeTip value={value} />
{mysqlContent.mode === "sql-safe" && <SQLModeTip value={value} />}
</div>
{(mysqlContent.mode === "sql" || mysqlContent.mode === "sql-safe") && (
<div css={modeContainerStyle}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const OracleDBPanel: FC = () => {
value={(content.opts as OracleDBActionSQLMode).raw}
onChange={handleValueChange("raw")}
sqlScheme={sqlTable}
showSafeModeTips={content.mode === "sql-safe"}
/>
<TransformerComponent fullWidth />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export const InputEditor: FC<ControlledInputProps> = (props) => {
<span>{tips}</span>
</div>
)}
{showSafeModeTips && <SQLModeTip value={value} _css={sqlModeTipStyle} />}
{showSafeModeTips && (
<SQLModeTip value={value} _css={sqlModeTipStyle(!!title)} />
)}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export const actionItemTip = css`
color: ${getColor("grayBlue", "04")};
`

export const sqlModeTipStyle = css`
margin-left: 192px;
export const sqlModeTipStyle = (hasTitle: boolean) => css`
margin-left: ${hasTitle ? "192px" : "32px"};
margin-top: 0;
margin-right: 16px;
`
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { dealRawData2ArrayData } from "@/page/App/components/InspectPanel/PanelS
import { ColumnContainer } from "@/page/App/components/InspectPanel/PanelSetters/DragMoveComponent/ColumnContainer"
import { getExecutionResult } from "@/redux/currentApp/executionTree/executionSelector"
import { RootState } from "@/store"
import { getColumnTypeFromValue } from "@/widgetLibrary/DataGridWidget/columnDeal"
import { getColumnsTypeSetter } from "@/widgetLibrary/DataGridWidget/panelConfig"
import { Column } from "../../DragMoveComponent/Column"
import { ColumnEmpty } from "../../DragMoveComponent/Empty"
Expand Down Expand Up @@ -57,28 +58,25 @@ const ColumnSetter: FC<ColumnSetterProps> = (props) => {
undefined,
)

const calculateColumns: ColumnConfig[] = useMemo(() => {
const dataSourceMode = get(
targetComponentProps,
"dataSourceMode",
"dynamic",
)
const rawData = get(
targetComponentProps,
dataSourceMode === "dynamic" ? "dataSourceJS" : "dataSource",
undefined,
)
const dataSourceMode = get(targetComponentProps, "dataSourceMode", "dynamic")

const rawData = get(
targetComponentProps,
dataSourceMode === "dynamic" ? "dataSourceJS" : "dataSource",
undefined,
)

const arrayData: object[] = dealRawData2ArrayData(rawData)
const arrayData: object[] = dealRawData2ArrayData(rawData)

const calculateColumns: ColumnConfig[] = useMemo(() => {
if (arrayData.length == 0) {
return []
} else {
return Object.keys(arrayData[0]).map((key) => {
return generateCalcColumnConfig(key, true, false)
})
}
}, [targetComponentProps])
}, [arrayData])

const mixedColumns: ColumnConfig[] = useMemo(() => {
if (calculateColumns.length === 0) {
Expand Down Expand Up @@ -154,7 +152,10 @@ const ColumnSetter: FC<ColumnSetterProps> = (props) => {
[attrName]: finalColumns,
})
}}
childrenSetter={getColumnsTypeSetter(config.columnType)}
childrenSetter={getColumnsTypeSetter(
config.columnType,
getColumnTypeFromValue(get(arrayData[0], config.field)),
)}
showDelete={!config.isCalc}
attrPath={`${attrName}.${index}`}
widgetDisplayName={widgetDisplayName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface ColumnConfig {
resizable: boolean
disableReorder: boolean
headerAlign: GridAlignment
aggregationModel?: string
valueGetter?: (params: GridValueGetterParams) => any
renderCell?: (params: GridRenderCellParams) => ReactNode
}
Expand Down
46 changes: 45 additions & 1 deletion apps/builder/src/widgetLibrary/DataGridWidget/dataGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { StyledEngineProvider, ThemeProvider, createTheme } from "@mui/material"
import { DataGridPremium, GridColDef } from "@mui/x-data-grid-premium"
import {
DataGridPremium,
GridAggregationModel,
GridColDef,
} from "@mui/x-data-grid-premium"
import { GridApiPremium } from "@mui/x-data-grid-premium/models/gridApiPremium"
import { get, isArray, isNumber, isPlainObject } from "lodash-es"
import {
Expand Down Expand Up @@ -67,6 +71,34 @@ export const DataGridWidget: FC<BaseDataGridProps> = (props) => {

const dispatch = useDispatch()

const handleAggregationModelChange = (modal: GridAggregationModel) => {
if (!columns || !Array.isArray(columns)) return
let curColumns = [...(columns || [])]
Object.keys(modal).forEach((key) => {
const index = columns.findIndex((column) => {
return column?.field === key
})
if (!columns || index === -1) return
curColumns = [
...curColumns.slice(0, index),
{
...columns[index],
aggregationModel: modal[key],
},
...curColumns.slice(index + 1),
]
})

handleUpdateMultiExecutionResult([
{
displayName,
value: {
columns: curColumns,
},
},
])
}

const isInnerDragging = useRef(false)

const toolbar = useCallback(
Expand Down Expand Up @@ -202,6 +234,16 @@ export const DataGridWidget: FC<BaseDataGridProps> = (props) => {
})
}, [arrayData, columns, triggerEventHandler])

const aggregationModel = useMemo(() => {
const curAggregationModel: GridAggregationModel = {}
columns?.forEach((column) => {
if (column?.aggregationModel) {
curAggregationModel[column.field] = column.aggregationModel
}
})
return curAggregationModel
}, [columns])

return (
<StyledEngineProvider injectFirst>
<ThemeProvider
Expand All @@ -225,6 +267,8 @@ export const DataGridWidget: FC<BaseDataGridProps> = (props) => {
return get(row, primaryKey)
}
}}
aggregationModel={aggregationModel}
onAggregationModelChange={handleAggregationModelChange}
filterModel={
filterModel !== undefined
? {
Expand Down
2 changes: 2 additions & 0 deletions apps/builder/src/widgetLibrary/DataGridWidget/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
GridAggregationModel,
GridColumnVisibilityModel,
GridFilterModel,
GridInputRowSelectionModel,
Expand Down Expand Up @@ -36,6 +37,7 @@ export interface BaseDataGridProps extends BaseWidgetProps {
selectedRowsPrimaryKeys?: GridInputRowSelectionModel
columns?: ColumnConfig[]
enablePagination?: boolean
aggregationModel?: GridAggregationModel
}

export const ColumnTypeList = [
Expand Down
63 changes: 62 additions & 1 deletion apps/builder/src/widgetLibrary/DataGridWidget/panelConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,71 @@ import { generatorEventHandlerConfig } from "@/widgetLibrary/PublicSector/utils/

const baseWidgetName = "dataGrid"

export function getColumnsTypeSetter(type: ColumnType): PanelFieldConfig[] {
export const getAggregationSetter = (type: ColumnType): PanelFieldConfig => {
let aggregationOptions = [
{
label: i18n.t("editor.inspect.setter_option.aggregation.size"),
value: "size",
},
]

switch (type) {
case "number":
aggregationOptions = [
{
label: i18n.t("editor.inspect.setter_option.aggregation.sum"),
value: "sum",
},
{
label: i18n.t("editor.inspect.setter_option.aggregation.avg"),
value: "avg",
},
{
label: i18n.t("editor.inspect.setter_option.aggregation.min"),
value: "min",
},
{
label: i18n.t("editor.inspect.setter_option.aggregation.max"),
value: "max",
},
...aggregationOptions,
]
break
case "date":
case "datetime":
aggregationOptions = [
{
label: i18n.t("editor.inspect.setter_option.aggregation.min"),
value: "min",
},
{
label: i18n.t("editor.inspect.setter_option.aggregation.max"),
value: "max",
},
...aggregationOptions,
]
break
}

return {
id: `${baseWidgetName}-column-aggregationModel`,
labelName: i18n.t("editor.inspect.setter_label.aggregation"),
attrName: "aggregationModel",
bindAttrName: ["aggregable"],
shown: (value) => value,
setterType: "BASE_SELECT_SETTER",
options: aggregationOptions,
}
}

export function getColumnsTypeSetter(
type: ColumnType,
defaultValueType: ColumnType,
): PanelFieldConfig[] {
return [
...DATA_GRID_COMMON_COLUMN_SETTER_CONFIG.slice(0, 4),
...getColumnsTypeSubSetter(type),
getAggregationSetter(type !== "auto" ? type : defaultValueType),
...DATA_GRID_COMMON_COLUMN_SETTER_CONFIG.slice(
4,
DATA_GRID_COMMON_COLUMN_SETTER_CONFIG.length,
Expand Down
40 changes: 18 additions & 22 deletions apps/builder/vite.config.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mdx from "@mdx-js/rollup"
// import { sentryVitePlugin } from "@sentry/vite-plugin"
import { sentryVitePlugin } from "@sentry/vite-plugin"
import basicSsl from "@vitejs/plugin-basic-ssl"
import react from "@vitejs/plugin-react-swc"
import { writeFileSync } from "fs"
Expand Down Expand Up @@ -74,27 +74,23 @@ export default defineConfig(({ command, mode }) => {
if (command === "serve" && useHttps) {
plugin.push(basicSsl())
} else {
// if (env.ILLA_INSTANCE_ID === "CLOUD" && env.ILLA_SENTRY_AUTH_TOKEN) {
// plugin.push(
// sentryVitePlugin({
// org: "sentry",
// project: "illa-builder",
// url: "https://sentry.illasoft.com/",
// authToken: env.ILLA_SENTRY_AUTH_TOKEN,
// release: {
// name: `illa-builder@${version}`,
// uploadLegacySourcemaps: {
// urlPrefix: "~/assets",
// paths: ["./dist/assets"],
// ignore: ["node_modules"],
// },
// deploy: {
// env: env.ILLA_APP_ENV,
// },
// },
// }),
// )
// }
if (
env.ILLA_INSTANCE_ID === "CLOUD" &&
env.ILLA_SENTRY_AUTH_TOKEN &&
env.ILLA_APP_ENV === "production"
) {
plugin.push(
sentryVitePlugin({
authToken: env.ILLA_SENTRY_AUTH_TOKEN,
org: "illa-cloud",
project: "illa-builder",
release: {
name: `illa-builder@${version}`,
dist: env.ILLA_APP_ENV,
},
}),
)
}
}
writeFileSync("./public/appInfo.json", `{"version":${version}}`)

Expand Down

0 comments on commit 26095e2

Please sign in to comment.