Skip to content

Commit

Permalink
Merge pull request #1918 from ever-co/improve/team-danger-zone-disabl…
Browse files Browse the repository at this point in the history
…ing-conditions

added conditionally disabling same as web app to team danger zone
  • Loading branch information
evereq authored Nov 30, 2023
2 parents ac517e0 + 4fb8e31 commit 9507fa1
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/mobile/app/i18n/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const ar: Translations = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/i18n/bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const bg = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const en = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/i18n/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const es = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/i18n/he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const he = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/i18n/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const ko: Translations = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/i18n/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const ru = {
removeAccount: 'Remove Account',
removeAccountHint: 'Account will be removed from all teams, except where you are the only manager',
deleteAccount: 'Delete Account',
deleteAccountHint: 'Your account will be deleted permanently with remolving from all teams',
deleteAccountHint: 'Your account will be deleted permanently with removing from all teams',
detect: 'Detect'
},
teamSection: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const TeamSettings: FC<ITeamSettingProps> = observer(({ props, onOpenBottomSheet
const {
teamStore: { activeTeam }
} = useStores();
const { isTeamManager } = useOrganizationTeam();
const { isTeamManager, activeTeamManagers, currentUser } = useOrganizationTeam();

const [open, setOpen] = useState(false);
const { navigation } = props;
Expand Down Expand Up @@ -99,16 +99,25 @@ const TeamSettings: FC<ITeamSettingProps> = observer(({ props, onOpenBottomSheet
title={translate('settingScreen.teamSection.transferOwnership')}
value={translate('settingScreen.teamSection.transferOwnership')}
onPress={() => setOpen(true)}
disabled={!(isTeamManager && activeTeamManagers.length >= 2)}
/>
<SingleInfo
title={translate('settingScreen.teamSection.removeTeam')}
value={translate('settingScreen.teamSection.removeTeamHint')}
onPress={() => onOpenBottomSheet('Remove Team', 5)}
disabled={!(isTeamManager && activeTeamManagers.length === 1)}
/>
<SingleInfo
title={translate('settingScreen.teamSection.quitTeam')}
value={translate('settingScreen.teamSection.quitTeamHint')}
onPress={() => onOpenBottomSheet('Quit Team', 5)}
disabled={
!(
(isTeamManager && activeTeamManagers.length > 1) ||
(!isTeamManager &&
activeTeam?.members?.some((member) => member.employee.userId === currentUser?.id))
)
}
/>
</View>
</ScrollView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import { moonDarkLarge, moonLightLarge, sunDarkLarge, sunLightLarge } from '../.
interface Props {
title: string;
value: string;
disabled?: boolean;
onPress?: () => unknown;
onDetectTimezone?: () => unknown;
}
const SingleInfo: FC<Props> = ({ title, value, onPress, onDetectTimezone }) => {
const SingleInfo: FC<Props> = ({ title, value, onPress, onDetectTimezone, disabled = false }) => {
const { colors, dark } = useAppTheme();

return (
Expand All @@ -38,7 +39,11 @@ const SingleInfo: FC<Props> = ({ title, value, onPress, onDetectTimezone }) => {
) : null}

{title !== translate('settingScreen.personalSection.themes') ? (
<TouchableOpacity onPress={() => (onPress ? onPress() : {})}>
<TouchableOpacity
disabled={disabled}
style={{ opacity: disabled ? 0.5 : 1 }}
onPress={() => (onPress ? onPress() : {})}
>
<AntDesign name="right" size={24} color="#938FA4" />
</TouchableOpacity>
) : (
Expand Down

0 comments on commit 9507fa1

Please sign in to comment.