-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from frappe/develop
chore: merge `develop` into `main`
- Loading branch information
Showing
171 changed files
with
6,625 additions
and
12,159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule frappe-ui
updated
44 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { call, createDocumentResource, createListResource, createResource } from 'frappe-ui' | ||
import getWhitelistedMethods from './whitelistedMethods' | ||
|
||
export const login = (email: string, password: string): Promise<User> => { | ||
return call('login', { usr: email, pwd: password }) | ||
} | ||
export const logout = (): Promise<any> => call('logout') | ||
|
||
export const fetchUserInfo = (): Promise<any> => call('insights.api.get_user_info') | ||
export const trackActiveSite = (): Promise<any> => call('insights.api.telemetry.track_active_site') | ||
|
||
export const createLastViewedLog = (recordType: string, recordName: string) => { | ||
return call('insights.api.home.create_last_viewed_log', { | ||
record_type: recordType, | ||
record_name: recordName, | ||
}) as Promise<any> | ||
} | ||
|
||
export const getListResource = (listResourceOption: ListResourceParams): ListResource => { | ||
return createListResource(listResourceOption) | ||
} | ||
|
||
export const createDataSource: Resource = createResource({ url: 'insights.api.setup.add_database' }) | ||
export const testDataSourceConnection: Resource = createResource({ | ||
url: 'insights.api.setup.test_database_connection', | ||
}) | ||
|
||
export const getDocumentResource = ( | ||
doctype: string, | ||
docname?: string, | ||
options?: object | ||
) => { | ||
const resource = createDocumentResource({ | ||
doctype: doctype, | ||
name: docname || doctype, | ||
whitelistedMethods: getWhitelistedMethods(doctype), | ||
...options, | ||
}) | ||
resource.fetchIfNeeded = async () => { | ||
if (!resource.get.loading) { | ||
await resource.get.fetch() | ||
} | ||
} | ||
return resource | ||
} | ||
|
||
export const fetchTableName = async (data_source: string, table: string) => { | ||
return call('insights.api.get_table_name', { | ||
data_source: data_source, | ||
table: table, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const whitelistedMethods = { | ||
'Insights Settings': { | ||
update_settings: 'update_settings', | ||
send_support_login_link: 'send_support_login_link', | ||
}, | ||
'Insights Data Source': { | ||
enqueue_sync_tables: 'enqueue_sync_tables', | ||
get_tables: 'get_tables', | ||
}, | ||
'Insights Table': { | ||
syncTable: 'sync_table', | ||
updateVisibility: 'update_visibility', | ||
getPreview: 'get_preview', | ||
update_column_type: 'update_column_type', | ||
}, | ||
} | ||
export default function getWhitelistedMethods(doctype: string) { | ||
return whitelistedMethods[doctype as keyof typeof whitelistedMethods] || {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.