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

[No QA]Fix Free Workspace transitions, add Admin badge to all admins #11774

Merged
merged 4 commits into from
Oct 12, 2022
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
7 changes: 6 additions & 1 deletion src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,16 @@ function setUpPoliciesAndNavigate(session) {
const url = new URL(currentUrl);
const exitTo = url.searchParams.get('exitTo');

// Approved Accountants and Guides can enter a flow where they make a workspace for other users,
// and those are passed as a search parameter when using transition links
const ownerEmail = url.searchParams.get('ownerEmail');
const makeMeAdmin = url.searchParams.get('makeMeAdmin');
Comment on lines +193 to +194
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if alex was my guide and created the policy for me:

  • Alex is hitting this URL via his new dot
  • ownerEmail is andrew@email.com
  • makeMeAdmin is true

Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, Alex would be hitting this through a transition link generated by OldDot


const shouldCreateFreePolicy = !isLoggingInAsNewUser
&& Str.startsWith(url.pathname, Str.normalizeUrl(ROUTES.TRANSITION_FROM_OLD_DOT))
&& exitTo === ROUTES.WORKSPACE_NEW;
if (shouldCreateFreePolicy) {
Policy.createWorkspace();
Policy.createWorkspace(ownerEmail, makeMeAdmin);
return;
}
if (!isLoggingInAsNewUser && exitTo) {
Expand Down
7 changes: 6 additions & 1 deletion src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,11 @@ function generatePolicyID() {

/**
* Optimistically creates a new workspace and default workspace chats
*
* @param {String} [ownerEmail] Optional, the email of the account to make the owner of the policy
* @param {Boolean} [makeMeAdmin] Optional, leave the calling account as an admin on the policy
*/
function createWorkspace() {
function createWorkspace(ownerEmail = '', makeMeAdmin = false) {
const policyID = generatePolicyID();
const workspaceName = generateDefaultWorkspaceName();

Expand All @@ -785,6 +788,8 @@ function createWorkspace() {
announceChatReportID,
adminsChatReportID,
expenseChatReportID,
ownerEmail,
makeMeAdmin,
policyName: workspaceName,
type: CONST.POLICY.TYPE.FREE,
},
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ class WorkspaceMembersPage extends React.Component {
}}
/>
</View>
{this.props.session.email === item.login && (
{(this.props.session.email === item.login || item.role === 'admin') && (
<View style={styles.peopleRowCell}>
<View style={[styles.badge, styles.peopleBadge]}>
<Text style={[styles.peopleBadgeText]}>
Expand Down