Yes, Remove
diff --git a/frontend/src/team/team.js b/frontend/src/team/team.js
index 0e8b3f4..11a4c6f 100644
--- a/frontend/src/team/team.js
+++ b/frontend/src/team/team.js
@@ -11,6 +11,7 @@ module.exports = app => app.component('team', {
invitations: null,
showNewInvitationModal: false,
showRemoveModal: null,
+ showEditModal: null,
status: 'loading'
}),
async mounted() {
@@ -32,15 +33,60 @@ module.exports = app => app.component('team', {
getRolesForUser(user) {
return this.workspace.members.find(member => member.userId === user._id)?.roles ?? [];
},
+ openEditModal(user) {
+ if (this.getRolesForUser(user).includes('owner')) {
+ return;
+ }
+
+ const roles = this.getRolesForUser(user);
+ const nonOwnerRoles = roles.filter(role => role !== 'owner');
+ const currentRole = nonOwnerRoles[0] ?? null;
+ const editableRole = currentRole ?? (this.workspace?.subscriptionTier ? 'member' : 'dashboards');
+
+ this.showEditModal = {
+ user,
+ role: editableRole,
+ originalRole: currentRole
+ };
+ },
+ closeEditModal() {
+ this.showEditModal = null;
+ },
+ async updateWorkspaceMember() {
+ if (this.showEditModal.role === this.showEditModal.originalRole) {
+ this.closeEditModal();
+ return;
+ }
+
+ const { workspace, users } = await mothership.updateWorkspaceMember({
+ userId: this.showEditModal.user._id,
+ roles: [this.showEditModal.role]
+ });
+
+ this.workspace = workspace;
+ this.users = users;
+ this.closeEditModal();
+ },
async removeFromWorkspace() {
const { workspace, users } = await mothership.removeFromWorkspace({ userId: this.showRemoveModal._id });
this.workspace = workspace;
this.users = users;
- this.showRemoveModal = false;
+ this.showRemoveModal = null;
},
async getWorkspaceCustomerPortalLink() {
const { url } = await mothership.getWorkspaceCustomerPortalLink();
window.open(url, '_self');
+ },
+ disableRoleOption(option) {
+ if (this.workspace?.subscriptionTier) {
+ return false;
+ }
+
+ if (this.showEditModal?.originalRole === option) {
+ return false;
+ }
+
+ return option !== 'dashboards';
}
}
});