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

🍒 Cherry pick PR #15392 to staging 🍒 #15739

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001028000
versionName "1.2.80-0"
versionCode 1001028001
versionName "1.2.80-1"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

if (isNewArchitectureEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.2.80.0</string>
<string>1.2.80.1</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.2.80.0</string>
<string>1.2.80.1</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.2.80-0",
"version": "1.2.80-1",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
4 changes: 3 additions & 1 deletion src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,10 @@ const CONST = {
ALWAYS: 'always',
},
VISIBILITY: {
RESTRICTED: 'restricted',
PUBLIC: 'public',
PUBLIC_ANNOUNCE: 'public_announce',
PRIVATE: 'private',
RESTRICTED: 'restricted',
},
RESERVED_ROOM_NAMES: ['#admins', '#announce'],
MAX_PREVIEW_AVATARS: 4,
Expand Down
3 changes: 3 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@ export default {
visibility: 'Visibility',
restrictedDescription: 'People in your workspace can find this room',
privateDescription: 'People invited to this room can find it',
publicDescription: 'Anyone can find it',
createRoom: 'Create room',
roomAlreadyExistsError: 'A room with this name already exists',
roomNameReservedError: 'A room on this workspace already uses this name',
Expand All @@ -1126,6 +1127,8 @@ export default {
visibilityOptions: {
restricted: 'Restricted',
private: 'Private',
public: 'Public',
public_announce: 'Public Announce',
},
},
statementPage: {
Expand Down
3 changes: 3 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@ export default {
visibility: 'Visibilidad',
restrictedDescription: 'Sólo las personas en tu espacio de trabajo pueden encontrar esta sala',
privateDescription: 'Sólo las personas que están invitadas a esta sala pueden encontrarla',
publicDescription: 'Cualquiera puede encontrarlo',
createRoom: 'Crea una sala de chat',
roomAlreadyExistsError: 'Ya existe una sala con este nombre',
roomNameReservedError: 'Una sala en este espacio de trabajo ya usa este nombre',
Expand All @@ -1128,6 +1129,8 @@ export default {
visibilityOptions: {
restricted: 'Restringida',
private: 'Privada',
public: 'Público',
public_announce: 'Anuncio Público',
},
},
statementPage: {
Expand Down
32 changes: 32 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1587,12 +1587,44 @@ function getIOUOptions(report, reportParticipants, betas) {
];
}

/**
* Allows a user to leave a policy room according to the following conditions of the visibility or chatType rNVP:
* `public` - Anyone can leave (because anybody can join)
* `public_announce` - Only non-policy members can leave (it's auto-shared with policy members)
* `policy_admins` - Nobody can leave (it's auto-shared with all policy admins)
* `policy_announce` - Nobody can leave (it's auto-shared with all policy members)
* `policy` - Anyone can leave (though only policy members can join)
* `domain` - Nobody can leave (it's auto-shared with domain members)
* `dm` - Nobody can leave (it's auto-shared with users)
* `private` - Anybody can leave (though you can only be invited to join)
*
* @param {Object} report
* @param {String} report.visibility
* @param {String} report.chatType
* @param {Boolean} isPolicyMember
* @returns {Boolean}
*/
function canLeaveRoom(report, isPolicyMember) {
if (_.isEmpty(report.visibility)) {
if (report.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ADMINS
|| report.chatType === CONST.REPORT.CHAT_TYPE.POLICY_ANNOUNCE
|| report.chatType === CONST.REPORT.CHAT_TYPE.DOMAIN_ALL
|| _.isEmpty(report.chatType)) { // DM chats don't have a chatType
return false;
}
} else if (report.visibility === CONST.REPORT.VISIBILITY.PUBLIC_ANNOUNCE && isPolicyMember) {
return false;
}
return true;
}

export {
getReportParticipantsTitle,
isReportMessageAttachment,
findLastAccessedReport,
canEditReportAction,
canDeleteReportAction,
canLeaveRoom,
sortReportsByLastRead,
isDefaultRoom,
isAdminRoom,
Expand Down
34 changes: 34 additions & 0 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as OptionsListUtils from '../OptionsListUtils';
import DateUtils from '../DateUtils';
import * as ReportUtils from '../ReportUtils';
import Log from '../Log';
import * as Report from './Report';

const allPolicies = {};
Onyx.connect({
Expand Down Expand Up @@ -1000,6 +1001,38 @@ function openWorkspaceInvitePage(policyID, clientMemberEmails) {
});
}

/**
*
* @param {String} reportID
*/
function leaveRoom(reportID) {
API.write('LeaveRoom', {
reportID,
}, {
optimisticData: [
{
onyxMethod: CONST.ONYX.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS.CLOSED,
},
},
],
failureData: [
{
onyxMethod: CONST.ONYX.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
value: {
stateNum: CONST.REPORT.STATE_NUM.OPEN,
statusNum: CONST.REPORT.STATUS.OPEN,
},
},
],
});
Report.navigateToConciergeChat();
}

export {
removeMembers,
addMembersToWorkspace,
Expand Down Expand Up @@ -1027,4 +1060,5 @@ export {
openWorkspaceMembersPage,
openWorkspaceInvitePage,
removeWorkspace,
leaveRoom,
};
12 changes: 9 additions & 3 deletions src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import styles from '../styles/styles';
import DisplayNames from '../components/DisplayNames';
import * as OptionsListUtils from '../libs/OptionsListUtils';
import * as ReportUtils from '../libs/ReportUtils';
import * as Policy from '../libs/actions/Policy';
import participantPropTypes from '../components/participantPropTypes';
import * as Expensicons from '../components/Icon/Expensicons';
import ROUTES from '../ROUTES';
Expand Down Expand Up @@ -86,14 +87,19 @@ class ReportDetailsPage extends Component {
translationKey: 'common.invite',
icon: Expensicons.Plus,
action: () => { /* Placeholder for when inviting other users is built in */ },
},
{
});
}

const policy = this.props.policies[`${ONYXKEYS.COLLECTION.POLICY}${this.props.report.policyID}`];
if (ReportUtils.isUserCreatedPolicyRoom(this.props.report) || ReportUtils.canLeaveRoom(this.props.report, !_.isEmpty(policy))) {
menuItems.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.LEAVE_ROOM,
translationKey: 'common.leaveRoom',
icon: Expensicons.Exit,
action: () => { /* Placeholder for when leaving rooms is built in */ },
action: () => Policy.leaveRoom(this.props.report.reportID),
});
}

return menuItems;
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class WorkspaceNewRoomPage extends React.Component {
policy => ({label: policy.name, key: policy.id, value: policy.id}),
);

const visibilityOptions = _.map(_.values(CONST.REPORT.VISIBILITY), visibilityOption => ({
const visibilityOptions = _.map(_.filter(_.values(CONST.REPORT.VISIBILITY), visibilityOption => visibilityOption !== CONST.REPORT.VISIBILITY.PUBLIC_ANNOUNCE), visibilityOption => ({
label: this.props.translate(`newRoomPage.visibilityOptions.${visibilityOption}`),
value: visibilityOption,
description: this.props.translate(`newRoomPage.${visibilityOption}Description`),
Expand Down