Skip to content

Commit 215cac6

Browse files
AdrinlolNikolayS
authored andcommitted
fix(ui): Fix organization creation (platform#214)
1 parent ff1c91f commit 215cac6

File tree

7 files changed

+23
-64
lines changed

7 files changed

+23
-64
lines changed

ui/packages/platform/src/components/Dashboard/Dashboard.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,13 @@ class Dashboard extends Component<DashboardWithStylesProps, DashboardState> {
214214
}
215215

216216
renderProjects() {
217-
const { classes, org } = this.props
217+
const { classes } = this.props
218+
const org = this.props.org as string | number
219+
const orgId = this.props.orgId
218220
const projectsData =
219221
this.state && this.state.data && this.state.data.projects
220222
? this.state.data.projects
221223
: null
222-
const orgId = this.props.orgId
223224

224225
const breadcrumbs = (
225226
<ConsoleBreadcrumbsWrapper
@@ -260,8 +261,8 @@ class Dashboard extends Component<DashboardWithStylesProps, DashboardState> {
260261

261262
const projects = projectsData.data
262263

263-
const dblabPermitted = this.props.orgPermissions.dblabInstanceCreate
264-
const checkupPermitted = this.props.orgPermissions.checkupReportConfigure
264+
const dblabPermitted = this.props.orgPermissions?.dblabInstanceCreate
265+
const checkupPermitted = this.props.orgPermissions?.checkupReportConfigure
265266

266267
const addDblabInstanceButton = (
267268
<ConsoleButtonWrapper

ui/packages/platform/src/components/Dashboard/DashboardWrapper.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { RouteComponentProps } from 'react-router'
44
import Dashboard from 'components/Dashboard/Dashboard'
55

66
export interface DashboardProps {
7-
org: string | number
8-
orgId: number
7+
org?: string | number
8+
orgId?: number
99
onlyProjects: boolean
1010
history: RouteComponentProps['history']
1111
project?: string | undefined
12-
orgPermissions: {
12+
orgPermissions?: {
1313
dblabInstanceCreate?: boolean
1414
checkupReportConfigure?: boolean
1515
}

ui/packages/platform/src/components/IndexPage/IndexPage.tsx

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ function OrganizationWrapper(parentProps: OrganizationWrapperProps) {
771771
/>
772772
<Route
773773
path="/:org/explain"
774-
render={(props) => <ExplainVisualizationWrapper />}
774+
render={() => <ExplainVisualizationWrapper />}
775775
/>
776776
<Route
777777
path="/:org/sessions"
@@ -1177,13 +1177,7 @@ class IndexPage extends Component<IndexPageWithStylesProps, IndexPageState> {
11771177
<Route
11781178
path="/:org"
11791179
render={(props) => (
1180-
<OrganizationMenu
1181-
{...props}
1182-
raw={this.props.raw}
1183-
auth={this.props.auth}
1184-
classes={classes}
1185-
env={env}
1186-
/>
1180+
<OrganizationMenu {...props} classes={classes} env={env} />
11871181
)}
11881182
/>
11891183
</Switch>
@@ -1268,42 +1262,18 @@ class IndexPage extends Component<IndexPageWithStylesProps, IndexPageState> {
12681262
path={ROUTES.ROOT.path}
12691263
exact
12701264
render={(props) => (
1271-
<DashboardWrapper
1272-
onlyProjects={false}
1273-
{...props}
1274-
org={this.props.org}
1275-
orgId={this.props.orgId}
1276-
orgPermissions={{
1277-
dblabInstanceCreate:
1278-
this.props.orgPermissions?.dblabInstanceCreate,
1279-
checkupReportConfigure:
1280-
this.props.orgPermissions?.checkupReportConfigure,
1281-
}}
1282-
/>
1265+
<DashboardWrapper onlyProjects={false} {...props} />
12831266
)}
12841267
/>
12851268
<Route
12861269
path={ROUTES.CREATE_ORG.path}
1287-
render={(props) => (
1288-
<OrgFormWrapper
1289-
project={this.props.match?.params.project}
1290-
mode={this.props.match?.params.mode}
1291-
org={this.props.org}
1292-
orgId={this.props.orgId}
1293-
orgPermissions={{
1294-
settingsOrganizationUpdate:
1295-
this.props.orgPermissions?.settingsOrganizationUpdate,
1296-
}}
1297-
{...props}
1298-
/>
1299-
)}
1270+
render={(props) => <OrgFormWrapper mode={'new'} {...props} />}
13001271
/>
13011272
<Route
13021273
path="/:org"
13031274
render={(props) => (
13041275
<OrganizationWrapper
13051276
{...props}
1306-
raw={this.props.raw}
13071277
env={env}
13081278
auth={auth}
13091279
classes={classes}

ui/packages/platform/src/components/OrgForm/OrgForm.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,10 @@ import ConsolePageTitle from '../ConsolePageTitle'
3838
import { WarningWrapper } from 'components/Warning/WarningWrapper'
3939
import { messages } from '../../assets/messages'
4040
import { formatAlias } from 'utils/aliases'
41+
import { OrgFormProps } from 'components/OrgForm/OrgFormWrapper'
4142

42-
interface OrgFormProps {
43+
interface OrgFormWithStylesProps extends OrgFormProps {
4344
classes: ClassesType
44-
mode?: string | undefined
45-
project: string | undefined
46-
org: string | number
47-
orgId: number
48-
orgPermissions: {
49-
settingsOrganizationUpdate?: boolean
50-
}
5145
}
5246

5347
interface DomainsType {
@@ -101,7 +95,7 @@ interface OrgFormState {
10195
} | null
10296
}
10397

104-
class OrgForm extends Component<OrgFormProps, OrgFormState> {
98+
class OrgForm extends Component<OrgFormWithStylesProps, OrgFormState> {
10599
state = {
106100
id: null,
107101
name: '',

ui/packages/platform/src/components/OrgForm/OrgFormWrapper.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { makeStyles } from '@material-ui/core'
22
import { styles } from '@postgres.ai/shared/styles/styles'
33
import OrgForm from 'components/OrgForm/OrgForm'
44

5-
interface OrgFormProps {
5+
export interface OrgFormProps {
66
mode?: string | undefined
7-
project: string | undefined
8-
org: string | number
9-
orgId: number
10-
orgPermissions: {
7+
project?: string | undefined
8+
org?: string | number
9+
orgId?: number
10+
orgPermissions?: {
1111
settingsOrganizationUpdate?: boolean
1212
}
1313
}

ui/packages/platform/src/components/ReportFile/ReportFileWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface ReportFileProps extends RouteComponentProps<MatchParams> {
1313
projectId: string | number | undefined
1414
reportId: string
1515
fileType: string
16-
raw: boolean
16+
raw?: boolean
1717
}
1818

1919
export const ReportFileWrapper = (props: ReportFileProps) => {

ui/packages/platform/src/components/types/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface ProjectWrapperProps {
5656
project: string
5757
}
5858
}
59-
raw: boolean
59+
raw?: boolean
6060
org: string | number
6161
orgId: number
6262
userIsOwner: boolean
@@ -105,23 +105,17 @@ export interface OrganizationWrapperProps {
105105
userId: number
106106
token: string
107107
} | null
108-
raw: boolean
108+
raw?: boolean
109109
}
110110

111111
export interface OrganizationMenuProps {
112-
raw: boolean
113112
classes: { [classes: string]: string }
114113
location: RouteComponentProps['location']
115114
match: {
116115
params: {
117116
org: string
118117
}
119118
}
120-
auth: {
121-
isProcessed: boolean
122-
userId: number
123-
token: string
124-
} | null
125119
env: {
126120
data: {
127121
orgs?: Orgs

0 commit comments

Comments
 (0)