Skip to content

Commit

Permalink
Add makeMeAdmin and ownerEmail parameters to createWorkspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mechler committed Oct 11, 2022
1 parent 296cf4d commit 9170edf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,14 @@ function setUpPoliciesAndNavigate(session) {
const isLoggingInAsNewUser = SessionUtils.isLoggingInAsNewUser(currentUrl, session.email);
const url = new URL(currentUrl);
const exitTo = url.searchParams.get('exitTo');
const ownerEmail = url.searchParams.get('ownerEmail');
const makeMeAdmin = url.searchParams.get('makeMeAdmin');

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
4 changes: 3 additions & 1 deletion src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ function generatePolicyID() {
/**
* Optimistically creates a new workspace and default workspace chats
*/
function createWorkspace() {
function createWorkspace(ownerEmail = '', makeMeAdmin = false) {
const policyID = generatePolicyID();
const workspaceName = generateDefaultWorkspaceName();

Expand All @@ -785,6 +785,8 @@ function createWorkspace() {
announceChatReportID,
adminsChatReportID,
expenseChatReportID,
ownerEmail,
makeMeAdmin,
policyName: workspaceName,
type: CONST.POLICY.TYPE.FREE,
},
Expand Down

0 comments on commit 9170edf

Please sign in to comment.