Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: My Projects Redo #4240

Merged
merged 208 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
8435f3e
reuse code for my projects route
magicznyleszek Jan 12, 2023
11f3965
Merge branch 'custom-views-integrate-endpoints-into-front-end' into 4…
magicznyleszek Jan 18, 2023
2894318
use different orderable fields for my projects and custom views
magicznyleszek Jan 18, 2023
3396a22
use /projects/home instead of /forms
magicznyleszek Jan 18, 2023
1728ffb
remove all old code /forms route used
magicznyleszek Jan 18, 2023
75d8420
fix typo
magicznyleszek Jan 18, 2023
b0bc3da
add todo comment
magicznyleszek Jan 18, 2023
c7145e6
Merge branch 'custom-views-integrate-endpoints-into-front-end' into 4…
magicznyleszek Jan 18, 2023
b718628
Merge branch 'custom-views-integrate-endpoints-into-front-end' into 4…
magicznyleszek Jan 19, 2023
c0e11a3
add comment
magicznyleszek Jan 19, 2023
5ff876d
use fetchPostUrl
magicznyleszek Jan 19, 2023
198923a
Merge branch 'feature/regional_projects' into 4209-my-projects-redo
magicznyleszek Jan 23, 2023
6bec172
use proper route in nav link
magicznyleszek Jan 23, 2023
df1d964
add checkboxes to ProejctsTable
magicznyleszek Jan 24, 2023
8230712
display action buttons in custom view (WIP)
magicznyleszek Jan 24, 2023
0e3b969
Merge branch 'beta' into 4209-my-projects-redo
magicznyleszek Jan 30, 2023
123ba15
change KoboDropdown option from enum to type to simplify code
magicznyleszek Jan 30, 2023
a2ee273
fix placements leftovers
magicznyleszek Jan 31, 2023
dd5cf75
introduce floatingRoundedBox mixin
magicznyleszek Jan 31, 2023
2f4af7c
split code out of mixins file
magicznyleszek Feb 1, 2023
6988395
define two components for quick action buttons
magicznyleszek Feb 1, 2023
fb3fbea
Merge branch 'beta' into 4209-my-projects-redo
magicznyleszek Feb 1, 2023
45d6591
Merge branch 'cleanup-permissions-mixin' into feature/my-projects
magicznyleszek Feb 1, 2023
9e6d0eb
Merge branch 'feature/my-projects' into 4209-my-projects-redo
magicznyleszek Feb 1, 2023
88d2a6e
Merge branch 'cleanup-permissions-mixin' into feature/my-projects
magicznyleszek Feb 1, 2023
a9b8ea7
Merge branch 'feature/my-projects' into 4209-my-projects-redo
magicznyleszek Feb 1, 2023
d5eef38
import userCan from new place
magicznyleszek Feb 1, 2023
0732dfb
fix userCan in projectQuickActions component
magicznyleszek Feb 2, 2023
c2401c7
proejct quick actions done
magicznyleszek Feb 6, 2023
8737f96
remove bulk actions for now
magicznyleszek Feb 6, 2023
aa0cf37
Merge branch '4209-fix-unaborted-calls--2.023.04' into feature/my-pro…
magicznyleszek Feb 6, 2023
21a287e
Merge branch 'feature/my-projects' into 4209-my-projects-redo
magicznyleszek Feb 6, 2023
900cc31
WIP handling changes to assets
magicznyleszek Feb 7, 2023
c3a4e66
make sure deleted asset is removed from the list
magicznyleszek Feb 7, 2023
601796c
finish up refetching data code
magicznyleszek Feb 9, 2023
c6a4d82
run prettier on modified code
magicznyleszek Feb 9, 2023
0df968d
Add asset_type and downloads to serializer for Project Views feature
magicznyleszek Feb 9, 2023
a85d6ef
remove leftover todo comment
magicznyleszek Feb 10, 2023
4e75293
update comment
magicznyleszek Feb 10, 2023
2f3028e
remove leftover commented out code
magicznyleszek Feb 10, 2023
925c026
new component FormSummaryProjectInfo for FormSummary
magicznyleszek Feb 13, 2023
f0e6b8e
new component FormSummaryProjectInfo for FormSummary
magicznyleszek Feb 13, 2023
cf8d5e4
Merge branch '4233-project-summary-details-improvement' of github.com…
magicznyleszek Feb 13, 2023
8c3a455
AssetStatusBadge component
magicznyleszek Feb 15, 2023
ada6844
add all missing parts to FormSummaryProjectInfo component
magicznyleszek Feb 15, 2023
3db9770
Make ViewSwitcher display "My Projects" for no views defined
magicznyleszek Feb 22, 2023
192bd80
bring back Dropzone for My Projects route
magicznyleszek Feb 22, 2023
bc10eb0
missing semicolon and run prettier
magicznyleszek Feb 22, 2023
e104595
Merge branch 'cleanup-permissions-mixin' into feature/my-projects
magicznyleszek Feb 22, 2023
72573b4
Merge branch 'feature/my-projects' into 4209-my-projects-redo
magicznyleszek Feb 22, 2023
1e5dbbc
Merge branch '4209-my-projects-redo' into 4233-project-summary-detail…
magicznyleszek Feb 22, 2023
d11fe9e
tidying some code
magicznyleszek Feb 22, 2023
2835d2c
typescriptize HeaderTitleEditor
magicznyleszek Feb 22, 2023
ab171b8
typescriptize SearchBox component
magicznyleszek Feb 22, 2023
1ac9de6
move header component to better directory, split out and typescriptiz…
magicznyleszek Feb 22, 2023
4e2af4f
migrate searchBoxStore to MobX
magicznyleszek Feb 22, 2023
6ffcd72
Make the checkbox clicking experience a bit more generous and forgiving
p2edwards Feb 25, 2023
88ec2ec
Merge branch 'beta' into feature/my-projects
magicznyleszek Feb 28, 2023
cdd430e
Merge branch 'beta' into feature/my-projects
magicznyleszek Mar 1, 2023
ecb7fb1
Merge branch 'feature/my-projects' into 4209-my-projects-redo
magicznyleszek Mar 1, 2023
6a1a48c
split translation strings
magicznyleszek Mar 1, 2023
e06834d
Merge branch '4209-my-projects-redo' into 4063-use-searchbox-in-proje…
magicznyleszek Mar 1, 2023
555e223
rebuild searchBoxStore with context prop and use it in customViewStore
magicznyleszek Mar 1, 2023
d5f7e82
use new searchBoxStore in library stores
magicznyleszek Mar 6, 2023
fa8b60b
remove unnecessary methods
magicznyleszek Mar 6, 2023
04721d9
change order of context storing
magicznyleszek Mar 6, 2023
11cbdb4
change default ordering to dateModified (was by name)
magicznyleszek Mar 6, 2023
9fd02d2
Merge pull request #4219 from kobotoolbox/4209-my-projects-redo
p2edwards Mar 8, 2023
8c0b56d
Merge pull request #4286 from kobotoolbox/4233-project-summary-detail…
p2edwards Mar 8, 2023
e38a10a
Merge branch '4209-my-projects-redo' into feature/my-projects
p2edwards Mar 8, 2023
bf6a071
run prettier on projects code
magicznyleszek Mar 8, 2023
f342784
Merge pull request #4326 from kobotoolbox/4209-my-projects-redo
magicznyleszek Mar 8, 2023
d3672ae
Merge branch 'beta' into feature/my-projects
magicznyleszek Mar 17, 2023
0776a8a
Merge branch 'feature/my-projects' into 4063-use-searchbox-in-project…
magicznyleszek Mar 17, 2023
538afab
Merge branch 'beta' into feature/my-projects
magicznyleszek Mar 20, 2023
03e7b28
Merge branch 'feature/my-projects' into 4063-use-searchbox-in-project…
magicznyleszek Mar 20, 2023
e8675b7
Edit comments - Apply suggestions from code review
p2edwards Mar 21, 2023
2c033f1
Merge pull request #4310 from kobotoolbox/4063-use-searchbox-in-proje…
p2edwards Mar 21, 2023
aee57b2
Merge branch 'beta' into feature/my-projects
magicznyleszek Mar 21, 2023
b0992b6
Merge branch 'feature/my-projects' of github.com:kobotoolbox/kpi into…
magicznyleszek Mar 21, 2023
02728c5
Merge branch 'beta' into feature/my-projects
magicznyleszek Mar 22, 2023
5470c40
improve styles for project quick actions
magicznyleszek Mar 23, 2023
047612f
safer checks for getting lastDeployedDate
magicznyleszek Mar 23, 2023
0ebc77c
use new util function for My Projects route Dropzone
magicznyleszek Mar 23, 2023
37317d6
Merge branch 'beta' into feature/my-projects
magicznyleszek Mar 24, 2023
2355db5
Merge branch 'feature/my-projects' into 4374-fix-dropzone-on-my-projects
magicznyleszek Mar 24, 2023
c01d0d2
Merge branch 'feature/my-projects' into 4377-fix-ui-crash-for-drafts
magicznyleszek Mar 24, 2023
7821e1a
Fix data not being fetched when navigating back to My Projects from a…
magicznyleszek Mar 24, 2023
e332b2e
Merge pull request #4386 from kobotoolbox/4375-fix-infinite-spinner
p2edwards Mar 24, 2023
03e8f13
simplify code
magicznyleszek Mar 27, 2023
8ef4073
Merge pull request #4382 from kobotoolbox/4377-fix-ui-crash-for-drafts
magicznyleszek Mar 27, 2023
72ea584
fix left divider for project name column
magicznyleszek Mar 27, 2023
8062169
update ProjectsFieldsSelector modal consistently
magicznyleszek Mar 27, 2023
9589fc4
create ProjectBulkActions component
magicznyleszek Mar 27, 2023
ca49df2
Merge branch '4379-add-date-deployed-to-assets-list--beta' into featu…
magicznyleszek Mar 27, 2023
22b662c
Merge branch 'feature/my-projects' into 4376-bulk-delete-projects
magicznyleszek Mar 27, 2023
8edf338
Merge branch 'feature/my-projects' into 4374-fix-dropzone-on-my-projects
p2edwards Mar 29, 2023
08b094d
Merge branch 'beta' into feature/my-projects
magicznyleszek Mar 30, 2023
a0be66c
split dropzone utils method to separately handle single and multiple …
magicznyleszek Mar 30, 2023
dd481df
fix typo in "successfully"
magicznyleszek Mar 30, 2023
b8c6d9b
add deprecated comment
magicznyleszek Mar 30, 2023
323a5a9
Update jsapp/js/mixins.tsx
magicznyleszek Apr 3, 2023
233b2f0
Update jsapp/js/dropzone.utils.tsx
magicznyleszek Apr 3, 2023
310edaa
add helpful comment
magicznyleszek Apr 3, 2023
9482332
Merge pull request #4383 from kobotoolbox/4374-fix-dropzone-on-my-pro…
p2edwards Apr 3, 2023
0705b71
Re-hide left divider without decreasing checkbox target size
p2edwards Mar 27, 2023
2414e11
Merge branch 'feature/my-projects' into 4376-bulk-delete-projects
magicznyleszek Apr 3, 2023
139b479
introduce bulk delete prompt
magicznyleszek Apr 3, 2023
3e870f6
finalize bulk delete flow
magicznyleszek Apr 4, 2023
40c06dc
Merge branch 'beta' into feature/my-projects.bak
noliveleger Apr 6, 2023
ccd6236
hide search box for access denied routes
magicznyleszek Apr 6, 2023
bfec2f3
Merge branch 'feature/my-projects' into 4376-bulk-delete-projects
noliveleger Apr 6, 2023
8f15732
update bulk api handling
magicznyleszek Apr 6, 2023
5cdb441
make failed api calls throw
magicznyleszek Apr 6, 2023
12f6884
Add _deployment_status to asset and use it for sort and search
noliveleger Apr 4, 2023
4c51de5
Use `_deployment_status` instead of `_deployment_data__active`
noliveleger Apr 4, 2023
850fea1
Use XForm cached field to get number of submissions
noliveleger Apr 4, 2023
ffb3071
Set deployment status on surveys only
noliveleger Apr 4, 2023
6fc2f0f
Add unit test to test default ordering
noliveleger Apr 4, 2023
7244dc3
Add support to sort by deployment status
noliveleger Apr 5, 2023
208a08e
Add default sorting button
noliveleger Apr 5, 2023
dfcb4fa
Expose _deployment_status value instead of label
noliveleger Apr 6, 2023
2fcce88
Show success notification on bulk deletion
magicznyleszek Apr 6, 2023
ec542a1
fix tooltip placement
magicznyleszek Apr 6, 2023
b3713cc
cleanup sort-default icon file
magicznyleszek Apr 6, 2023
f973052
Fix redeploy message
magicznyleszek Apr 6, 2023
5695661
improve deployment_status typings
magicznyleszek Apr 6, 2023
67c9205
fix archive and unarchive asset prompt self-closing on success
magicznyleszek Apr 6, 2023
da718b8
Move deployment serializer to v2
noliveleger Apr 7, 2023
4d95f8a
Save deployment status when archiving project
noliveleger Apr 7, 2023
b3ad817
Merge branch '4312-sort-by-deployment-status' of github.com:kobotoolb…
noliveleger Apr 7, 2023
7790ee1
make getOrderQuery return null for default (for no query)
magicznyleszek Apr 7, 2023
51dd68c
fix (un)archive flow in Project Settings
magicznyleszek Apr 7, 2023
4c4492a
Col Resize Perf: Skip re-rendering DraggingStyle between drag start/end
p2edwards Apr 10, 2023
d84d749
Adjust Project Name hover link styles
p2edwards Apr 10, 2023
f5e4769
Left-align all columns in project table
p2edwards Apr 10, 2023
0b1450a
Merge branch 'beta' into feature/my-projects
magicznyleszek Apr 10, 2023
238aad7
add option for project views to exclude some fields from UI
magicznyleszek Apr 11, 2023
05b1422
improve safety of loading settings from me endpoint
magicznyleszek Apr 11, 2023
fb71d20
Fix a checkbox column layout bug during Project name resize
p2edwards Apr 11, 2023
37fdb1d
Rearrange/recolor dropdown triangle and sorting indicators (legibility)
p2edwards Apr 11, 2023
ebd64a4
Redo checkbox forgiveness css for better filter support
p2edwards Apr 12, 2023
79ffed1
More predictable row click behavior, with matching hover styles
p2edwards Apr 12, 2023
789044d
Merge pull request #4409 from kobotoolbox/4378-exclude-fields-from-my…
magicznyleszek Apr 12, 2023
dae49fd
Merge branch 'feature/my-projects' into 4376-bulk-delete-projects
magicznyleszek Apr 12, 2023
4bf22f9
Force refresh sidebar projects list after successful bulk deletion
magicznyleszek Apr 12, 2023
cf8826a
Add simple focus styles for radio and checkbox components
magicznyleszek Apr 12, 2023
4b7bad2
cleanup focus outline related styles
magicznyleszek Apr 12, 2023
74bc8ce
run prettier on touched files
magicznyleszek Apr 12, 2023
ee63a74
Merge pull request #4404 from kobotoolbox/4376-bulk-delete-projects
magicznyleszek Apr 12, 2023
07c3679
Rephrase some comments
p2edwards Apr 17, 2023
9823da4
Use clearer language in comments
p2edwards Apr 17, 2023
2cc98c9
Simplify code and comments
p2edwards Apr 17, 2023
b52540b
Merge branch 'feature/my-projects' into 4313-table-ux-tweaks
p2edwards May 18, 2023
011a357
Merge branch 'beta' into feature/my-projects
p2edwards May 18, 2023
9a4856d
Merge branch 'feature/my-projects' into 4313-table-ux-tweaks
p2edwards May 18, 2023
c165c4a
Merge remote-tracking branch 'origin/4306-update-radio-and-checkbox-s…
p2edwards May 18, 2023
18d1e66
Project Table: Adapt checkbox appearance for #4442
p2edwards May 18, 2023
4716d5a
Make full dropdown headers clickable
p2edwards May 19, 2023
7a075d9
Merge remote-tracking branch 'origin/beta' into feature/my-projects
p2edwards May 22, 2023
c1f5278
Merge branch 'feature/my-projects' into 4313-table-ux-tweaks
p2edwards May 22, 2023
75b5fb8
fix getCountryDisplayString returning empty string instead of dash fo…
magicznyleszek May 22, 2023
9e5f153
Use default cursor on checkbox header
p2edwards May 23, 2023
9ae7549
Merge pull request #4402 from kobotoolbox/4312-sort-by-deployment-status
magicznyleszek May 24, 2023
e6fc3f5
Merge pull request #4408 from kobotoolbox/4313-table-ux-tweaks
magicznyleszek May 24, 2023
597d554
split top tabs from `formViewTabs` file and remove x button
magicznyleszek May 24, 2023
5c21054
Merge branch 'beta' into feature/my-projects
magicznyleszek May 30, 2023
d55eebf
Merge branch 'beta' into feature/my-projects
magicznyleszek Jun 13, 2023
4f1d9ab
Resolve migration conflict
jnm Jun 14, 2023
d3007eb
split default visible columns between My Projects and other views
magicznyleszek Jun 15, 2023
c606e62
Merge remote-tracking branch 'origin/beta' into feature/my-projects
jnm Jun 15, 2023
ef5691a
More compact styles for ProjectsTable component to display more data
magicznyleszek Jun 19, 2023
5b4d0d1
Merge pull request #4502 from kobotoolbox/my-projects-display-more-info
magicznyleszek Jun 19, 2023
e1e8974
Merge branch 'beta' into feature/my-projects
magicznyleszek Jun 19, 2023
f013820
Merge branch 'feature/my-projects' into 4234-remove-x-button-from-pro…
magicznyleszek Jun 19, 2023
34fafae
Merge remote-tracking branch 'origin/beta' into feature/my-projects
jnm Jul 3, 2023
2044cdb
Clarify where (re)deployment writes to database
jnm Jul 4, 2023
e08e630
Revert #4387
magicznyleszek Jul 4, 2023
07c37bc
Merge branch 'revert--ts-plugin-css-modules' into feature/my-projects
magicznyleszek Jul 4, 2023
799f018
Merge pull request #4521 from kobotoolbox/clarify-deployment-database…
noliveleger Jul 4, 2023
e7f54b7
Revert "Merge branch 'revert--ts-plugin-css-modules' into feature/my-…
magicznyleszek Jul 4, 2023
5bdaebb
make project table row name <a> tag link for better UX
magicznyleszek Jul 6, 2023
75adb9d
Merge pull request #4450 from kobotoolbox/4234-remove-x-button-from-p…
magicznyleszek Jul 6, 2023
87854e2
Merge branch 'beta' into feature/my-projects
magicznyleszek Jul 6, 2023
924a810
Merge remote-tracking branch 'origin/feature/my-projects' into 4524-p…
p2edwards Jul 7, 2023
7c56774
Add a keyboard focus ring for project table links
p2edwards Jul 7, 2023
12a0774
Remove unused variable
p2edwards Jul 7, 2023
a7a9260
Merge pull request #4529 from kobotoolbox/4524-project-row-a-link
magicznyleszek Jul 10, 2023
583c033
typescriptize MainHeader component
magicznyleszek Jul 10, 2023
3ae4845
Merge branch 'beta' into feature/my-projects
magicznyleszek Jul 17, 2023
e982d97
Merge remote-tracking branch 'origin/beta' into feature/my-projects
p2edwards Jul 22, 2023
af65c7c
(auto/format) Apply automated eslint and prettier changes to some files…
p2edwards Jul 22, 2023
f2fa32c
Preempt merge conflicts between react-router-6-14 and my-projects
p2edwards Jul 22, 2023
1d8751a
Merge branch 'beta' into feature/my-projects
p2edwards Jul 22, 2023
b6ddfa2
Resolve migration conflict between `feature/my-projects` and `beta`
p2edwards Jul 24, 2023
0aa13a7
(mark auto/format commit in .git-blame-ignore-revs)
p2edwards Jul 25, 2023
6339abf
use the const value instead of separate variable
magicznyleszek Aug 1, 2023
77246f1
use route const instead of comment
magicznyleszek Aug 1, 2023
b475c07
add comment about setTimeout hack
magicznyleszek Aug 1, 2023
a9f9421
add comment instead of useless and unused code
magicznyleszek Aug 1, 2023
8ca284d
code review fixes
magicznyleszek Aug 1, 2023
41a86e3
Merge pull request #4548 from kobotoolbox/merge-my-projects-react-rou…
magicznyleszek Aug 3, 2023
9b84ba7
Merge branch 'feature/my-projects' into typescriptize-main-header-com…
magicznyleszek Aug 3, 2023
df169c9
post merge fixes
magicznyleszek Aug 4, 2023
fc5f293
fix My Library icons
magicznyleszek Aug 4, 2023
3b82b11
run prettier
magicznyleszek Aug 4, 2023
66e27c9
Merge pull request #4535 from kobotoolbox/typescriptize-main-header-c…
magicznyleszek Aug 4, 2023
c37cd7a
Merge branch 'beta' into feature/my-projects
magicznyleszek Aug 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

# Applied automated eslint autofixes and prettier to map.es6
be3a9b6041e451b02c671220be50b5ca33cae1a8
# Prettier/ESLint autofixes to reduce merge noise between diverging branches
# (beta after react router 6.14 upgrade; feature/my-projects)
af65c7c161a3e044ec7a5910716edbb09f326462
3 changes: 2 additions & 1 deletion hub/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
SearchQueryTooShortException,
)
from kpi.filters import SearchFilter
from kpi.models.asset import AssetDeploymentStatus
from .models import (
ExtraUserDetail,
ConfigurationFile,
Expand Down Expand Up @@ -179,7 +180,7 @@ def deployed_forms_count(self, obj):
Django admin user changelist page
"""
assets_count = obj.assets.filter(
_deployment_data__active=True
_deployment_status=AssetDeploymentStatus.DEPLOYED
).aggregate(count=Count('pk'))
return assets_count['count']

Expand Down
5 changes: 4 additions & 1 deletion jsapp/js/actions.es6
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,13 @@ actions.resources.deployAsset.failed.listen(function(data, redeployment){
alertify.alert(t('unable to deploy'), failure_message);
});

actions.resources.setDeploymentActive.listen(function(details) {
actions.resources.setDeploymentActive.listen(function(details, onComplete) {
dataInterface.setDeploymentActive(details)
.done((data) => {
actions.resources.setDeploymentActive.completed(data.asset);
if (typeof onComplete === 'function') {
onComplete(data);
}
})
.fail(actions.resources.setDeploymentActive.failed);
});
Expand Down
4 changes: 2 additions & 2 deletions jsapp/js/actions/library.es6
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ libraryActions.getCollections.listen((params) => {

libraryActions.moveToCollection.completed.listen((asset) => {
if (asset.parent === null) {
notify(t('Successfuly removed from collection'));
notify(t('Successfully removed from collection'));
} else {
notify(t('Successfuly moved to collection'));
notify(t('Successfully moved to collection'));
}
});
libraryActions.moveToCollection.failed.listen(() => {
Expand Down
12 changes: 12 additions & 0 deletions jsapp/js/alertify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import alertify from 'alertifyjs';
import {KeyNames} from 'js/constants';
import type {IconName} from 'jsapp/fonts/k-icons';
import {escapeHtml} from 'js/utils';
import type {ReactElement} from 'react';
import {render} from 'react-dom';

interface MultiConfirmButton {
label: string;
Expand Down Expand Up @@ -184,3 +186,13 @@ export function destroyConfirm(

return dialog;
}

/**
* Useful to pass a complex JSX message into alertify (which accepts only
* strings).
*/
export function renderJSXMessage(jsx: ReactElement) {
const domNode = document.createElement('div');
render(jsx, domNode);
return domNode.outerHTML;
}
20 changes: 18 additions & 2 deletions jsapp/js/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ const JSON_HEADER = 'application/json';
// 500 // half second
// );

const fetchData = async <T>(path: string, method = 'GET', data?: Json) => {
const fetchData = async <T>(
/** If you have full url to be called, remember to use `prependRootUrl`. */
path: string,
method = 'GET',
data?: Json,
/**
* Useful if you already have a full URL to be called and there is no point
* adding `ROOT_URL` to it.
*/
prependRootUrl = true
) => {
const headers: {[key: string]: string} = {
Accept: JSON_HEADER,
};
Expand All @@ -30,7 +40,9 @@ const fetchData = async <T>(path: string, method = 'GET', data?: Json) => {
headers['Content-Type'] = JSON_HEADER;
}

const response = await fetch(ROOT_URL + path, {
const url = prependRootUrl ? ROOT_URL + path : path;

const response = await fetch(url, {
method: method,
headers,
body: JSON.stringify(data),
Expand Down Expand Up @@ -92,6 +104,10 @@ export const fetchGet = async <T>(path: string) => fetchData<T>(path);
export const fetchPost = async <T>(path: string, data: Json) =>
fetchData<T>(path, 'POST', data);

/** POST data to Kobo API at url */
export const fetchPostUrl = async <T>(url: string, data: Json) =>
fetchData<T>(url, 'POST', data, false);

/** PATCH (update) data to Kobo API at path */
export const fetchPatch = async <T>(path: string, data: Json) =>
fetchData<T>(path, 'PATCH', data);
Expand Down
11 changes: 6 additions & 5 deletions jsapp/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import 'js/surveyCompanionStore'; // importing it so it exists
import {} from 'js/bemComponents'; // importing it so it exists
import bem from 'js/bem';
import mixins from 'js/mixins';
import MainHeader from 'js/components/header';
import MainHeader from 'js/components/header/mainHeader.component';
import Drawer from 'js/components/drawer';
import FormViewTabs from 'js/components/formViewTabs';
import FormViewSideTabs from 'js/components/formViewSideTabs';
import ProjectTopTabs from 'js/project/projectTopTabs.component';
import PermValidator from 'js/components/permissions/permValidator';
import {assign} from 'utils';
import BigModal from 'js/components/bigModal/bigModal';
Expand Down Expand Up @@ -86,7 +87,7 @@ class App extends React.Component {

{!this.isFormBuilder() && (
<React.Fragment>
<MainHeader assetid={assetid} />
<MainHeader assetUid={assetid} />
<Drawer />
</React.Fragment>
)}
Expand All @@ -97,8 +98,8 @@ class App extends React.Component {
>
{!this.isFormBuilder() && (
<React.Fragment>
<FormViewTabs type={'top'} show={this.isFormSingle()} />
<FormViewTabs type={'side'} show={this.isFormSingle()} />
{this.isFormSingle() && <ProjectTopTabs />}
<FormViewSideTabs show={this.isFormSingle()} />
</React.Fragment>
)}
<Outlet />
Expand Down
Loading
Loading