mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
fixes: loading app with slug
This commit is contained in:
parent
007f05f0d9
commit
6b96c3c9e3
4 changed files with 31 additions and 17 deletions
|
|
@ -36,7 +36,6 @@ class ManageAppUsersComponent extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchAppUsers = (appId) => {
|
fetchAppUsers = (appId) => {
|
||||||
console.log('---arpit [manager users]:; ', { x: this.props });
|
|
||||||
appService
|
appService
|
||||||
.getAppUsers(appId)
|
.getAppUsers(appId)
|
||||||
.then((data) =>
|
.then((data) =>
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,15 @@ class ViewerComponent extends React.Component {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setStateForApp = (data) => {
|
setStateForApp = (data, byAppSlug = false) => {
|
||||||
const appDefData = buildAppDefinition(data);
|
const appDefData = buildAppDefinition(data);
|
||||||
|
|
||||||
|
if (byAppSlug) {
|
||||||
|
appDefData.globalSettings = data.globalSettings;
|
||||||
|
appDefData.homePageId = data.homePageId;
|
||||||
|
appDefData.showHideViewerNavigation = data.showHideViewerNavigation;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
app: data,
|
app: data,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
|
@ -116,10 +122,17 @@ class ViewerComponent extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
let queryState = {};
|
let queryState = {};
|
||||||
const { data_queries } = await dataqueryService.getAll(appVersionId);
|
let dataQueries = [];
|
||||||
|
|
||||||
if (data_queries.length > 0) {
|
if (appVersionId) {
|
||||||
data_queries.forEach((query) => {
|
const { data_queries } = await dataqueryService.getAll(appVersionId);
|
||||||
|
dataQueries = data_queries;
|
||||||
|
} else {
|
||||||
|
dataQueries = data.data_queries;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dataQueries.length > 0) {
|
||||||
|
dataQueries.forEach((query) => {
|
||||||
if (query.pluginId || query?.plugin?.id) {
|
if (query.pluginId || query?.plugin?.id) {
|
||||||
queryState[query.name] = {
|
queryState[query.name] = {
|
||||||
...query.plugin.manifestFile.data.source.exposedVariables,
|
...query.plugin.manifestFile.data.source.exposedVariables,
|
||||||
|
|
@ -139,12 +152,12 @@ class ViewerComponent extends React.Component {
|
||||||
const constants = await this.fetchOrgEnvironmentConstants(data.slug, data.is_public);
|
const constants = await this.fetchOrgEnvironmentConstants(data.slug, data.is_public);
|
||||||
|
|
||||||
const pages = data.pages;
|
const pages = data.pages;
|
||||||
const homePageId = data.editing_version.homePageId;
|
const homePageId = appVersionId ? data.editing_version.homePageId : data?.homePageId;
|
||||||
const startingPageHandle = this.props?.params?.pageHandle;
|
const startingPageHandle = this.props?.params?.pageHandle;
|
||||||
const currentPageId = pages.filter((page) => page.handle === startingPageHandle)[0]?.id ?? homePageId;
|
const currentPageId = pages.filter((page) => page.handle === startingPageHandle)[0]?.id ?? homePageId;
|
||||||
const currentPage = pages.find((page) => page.id === currentPageId);
|
const currentPage = pages.find((page) => page.id === currentPageId);
|
||||||
|
|
||||||
useDataQueriesStore.getState().actions.setDataQueries(data_queries);
|
useDataQueriesStore.getState().actions.setDataQueries(dataQueries);
|
||||||
this.props.setCurrentState({
|
this.props.setCurrentState({
|
||||||
queries: queryState,
|
queries: queryState,
|
||||||
components: {},
|
components: {},
|
||||||
|
|
@ -179,10 +192,11 @@ class ViewerComponent extends React.Component {
|
||||||
? `${this.state.deviceWindowWidth}px`
|
? `${this.state.deviceWindowWidth}px`
|
||||||
: '1292px',
|
: '1292px',
|
||||||
selectedComponent: null,
|
selectedComponent: null,
|
||||||
dataQueries: data_queries,
|
dataQueries: dataQueries,
|
||||||
currentPageId: currentPage.id,
|
currentPageId: currentPage.id,
|
||||||
pages: {},
|
pages: {},
|
||||||
homepage: appDefData?.pages?.[this.state.appDefinition?.homePageId]?.handle,
|
homepage: appDefData?.pages?.[this.state.appDefinition?.homePageId]?.handle,
|
||||||
|
event: data.events ?? [],
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
const components = appDefData?.pages[currentPageId]?.components || {};
|
const components = appDefData?.pages[currentPageId]?.components || {};
|
||||||
|
|
@ -190,7 +204,7 @@ class ViewerComponent extends React.Component {
|
||||||
computeComponentState(components).then(async () => {
|
computeComponentState(components).then(async () => {
|
||||||
this.setState({ initialComputationOfStateDone: true, defaultComponentStateComputed: true });
|
this.setState({ initialComputationOfStateDone: true, defaultComponentStateComputed: true });
|
||||||
console.log('Default component state computed and set');
|
console.log('Default component state computed and set');
|
||||||
this.runQueries(data_queries);
|
this.runQueries(dataQueries);
|
||||||
// eslint-disable-next-line no-unsafe-optional-chaining
|
// eslint-disable-next-line no-unsafe-optional-chaining
|
||||||
// const { events } = this.state.appDefinition?.pages[this.state.currentPageId];
|
// const { events } = this.state.appDefinition?.pages[this.state.currentPageId];
|
||||||
// for (const event of events ?? []) {
|
// for (const event of events ?? []) {
|
||||||
|
|
@ -264,7 +278,7 @@ class ViewerComponent extends React.Component {
|
||||||
appService
|
appService
|
||||||
.getAppBySlug(slug)
|
.getAppBySlug(slug)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
this.setStateForApp(data);
|
this.setStateForApp(data, true);
|
||||||
this.setStateForContainer(data);
|
this.setStateForContainer(data);
|
||||||
this.setWindowTitle(data.name);
|
this.setWindowTitle(data.name);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,9 @@ export class AppsController {
|
||||||
? await this.appsService.findVersion(app.currentVersionId)
|
? await this.appsService.findVersion(app.currentVersionId)
|
||||||
: await this.appsService.findVersion(app.editingVersion?.id);
|
: await this.appsService.findVersion(app.editingVersion?.id);
|
||||||
|
|
||||||
|
const pagesForVersion = app.editingVersion ? await this.pageService.findPagesForVersion(versionToLoad.id) : [];
|
||||||
|
const eventsForVersion = app.editingVersion ? await this.eventsService.findEventsForVersion(versionToLoad.id) : [];
|
||||||
|
|
||||||
// serialize
|
// serialize
|
||||||
return {
|
return {
|
||||||
current_version_id: app['currentVersionId'],
|
current_version_id: app['currentVersionId'],
|
||||||
|
|
@ -145,6 +148,11 @@ export class AppsController {
|
||||||
is_maintenance_on: app.isMaintenanceOn,
|
is_maintenance_on: app.isMaintenanceOn,
|
||||||
name: app.name,
|
name: app.name,
|
||||||
slug: app.slug,
|
slug: app.slug,
|
||||||
|
events: eventsForVersion,
|
||||||
|
pages: pagesForVersion,
|
||||||
|
homePageId: versionToLoad.homePageId,
|
||||||
|
globalSettings: versionToLoad.globalSettings,
|
||||||
|
showHideViewerNavigation: versionToLoad.showViewerNavigation,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -305,13 +305,6 @@ export class AppImportExportService {
|
||||||
appResourceMappings.dataQueryMapping
|
appResourceMappings.dataQueryMapping
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(
|
|
||||||
'---arpit--- importingAppVersion',
|
|
||||||
JSON.stringify({
|
|
||||||
updatedDefinition,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
// !-----
|
// !-----
|
||||||
|
|
||||||
let updateHomepageId = null;
|
let updateHomepageId = null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue