Skip to content

Commit

Permalink
feat: Add modals for deleting site and removing from project (#552)
Browse files Browse the repository at this point in the history
* feat: Add modals for deleting site and removing from project

* chore: Remove unused lodash types

* chore: Bump client-shared

* fix: Apply suggestions from code review

Co-authored-by: Paul Schreiber <paul@techmatters.org>

* chore(deps): bump actions/setup-node from 3 to 4 (#553)

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](actions/setup-node@v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump cocoapods from 1.14.0 to 1.14.2 in /dev-client (#554)

Bumps [cocoapods](https://github.com/CocoaPods/CocoaPods) from 1.14.0 to 1.14.2.
- [Release notes](https://github.com/CocoaPods/CocoaPods/releases)
- [Changelog](https://github.com/CocoaPods/CocoaPods/blob/1.14.2/CHANGELOG.md)
- [Commits](CocoaPods/CocoaPods@1.14.0...1.14.2)

---
updated-dependencies:
- dependency-name: cocoapods
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: Site Transfer (#549)

* build: Bump client-shared

* feat: Add Checkbox Group

* feat: Add proper logic to site transfer

* feat: Dispatch transfer mutation

* fix: Render checkboxes in FlatList

* fix: Don't display sites of empty projects

* fix: Do some sorting

* feat: Navigate back after transfer

* fix: Styling changes

* feat: Add unaffiliated sites to site transfer

* fix: Fix unaffiliated search, allow scrolling

* fix: Allow transferring unaffiliated sites

* fix(lint): Fix linting errors

* fix: Pass params to translation

* chore: Bump client shared

* chore: Update remove site modal text

* chore(deps): Update client-shared

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Paul Schreiber <paul@techmatters.org>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 1, 2023
1 parent 5e9226f commit cc84405
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 13 deletions.
13 changes: 8 additions & 5 deletions dev-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"react-native-svg": "^13.14.0",
"react-native-tab-view": "^3.5.2",
"react-native-vector-icons": "^10.0.1",
"terraso-client-shared": "github:techmatters/terraso-client-shared#babc75d",
"terraso-client-shared": "github:techmatters/terraso-client-shared#ed971c1",
"uuid": "^9.0.1",
"yup": "^1.3.2"
},
Expand Down
44 changes: 38 additions & 6 deletions dev-client/src/components/projects/ProjectSitesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import {
MaterialCommunityIcons,
} from 'terraso-mobile-client/components/common/Icons';
import {RootStackScreenProps} from 'terraso-mobile-client/screens/AppScaffold';
import {Site, deleteSite} from 'terraso-client-shared/site/siteSlice';
import {
Site,
deleteSite,
updateSite,
} from 'terraso-client-shared/site/siteSlice';
import {
useDispatch,
useSelector,
Expand All @@ -36,6 +40,7 @@ import {
import {SiteCard} from 'terraso-mobile-client/components/sites/SiteCard';
import {useTextSearch} from 'terraso-mobile-client/components/common/search/search';
import {CardTopRightButton} from 'terraso-mobile-client/components/common/Card';
import ConfirmModal from 'terraso-mobile-client/components/common/ConfirmModal';

type SiteMenuProps = {
iconName: string;
Expand Down Expand Up @@ -69,8 +74,14 @@ const SiteMenu = ({site}: SiteProps) => {
dispatch(removeSiteFromAllProjects(site.id));
};

const removeSiteFromProjectCallback = async () => {
const input = {id: site.id, projectId: null};
return dispatch(updateSite(input));
};

return (
<Menu
closeOnSelect={true}
trigger={triggerProps => (
<CardTopRightButton
as={MaterialCommunityIcons}
Expand All @@ -79,11 +90,32 @@ const SiteMenu = ({site}: SiteProps) => {
{...triggerProps}
/>
)}>
<SiteMenuItem iconName="remove" text={t('projects.sites.remove_site')} />
<SiteMenuItem
iconName="delete"
onPress={deleteSiteCallback}
text={t('projects.sites.delete_site')}
<ConfirmModal
trigger={onOpen => (
<SiteMenuItem
iconName="remove"
text={t('projects.sites.remove_site')}
onPress={onOpen}
/>
)}
title={t('projects.sites.remove_site_modal.title')}
body={t('projects.sites.remove_site_modal.body', {siteName: site.name})}
actionName={t('projects.sites.remove_site_modal.action_name')}
handleConfirm={removeSiteFromProjectCallback}
/>

<ConfirmModal
trigger={onOpen => (
<SiteMenuItem
iconName="delete"
onPress={onOpen}
text={t('projects.sites.delete_site')}
/>
)}
title={t('projects.sites.delete_site_modal.title')}
body={t('projects.sites.delete_site_modal.body', {siteName: site.name})}
actionName={t('projects.sites.delete_site_modal.action_name')}
handleConfirm={deleteSiteCallback}
/>
</Menu>
);
Expand Down
12 changes: 11 additions & 1 deletion dev-client/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,17 @@
"go_to": "Go to Site",
"audit_log": "Audit Log",
"remove_site": "Remove from Project",
"delete_site": "Delete Site"
"delete_site": "Delete Site",
"delete_site_modal": {
"title": "Delete site?",
"body": "This will permanently delete the site {{siteName}} and all of its data. This cannot be undone.\n\nProject managers can remove the site from this project to retain its data.",
"action_name": "Delete"
},
"remove_site_modal": {
"title": "Remove site from project?",
"body": "Only you will have access to this site and its data. Other project team members will no longer have access.",
"action_name": "Remove Site"
}
},
"add": {
"name": "Project Name",
Expand Down

0 comments on commit cc84405

Please sign in to comment.