-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web/satellite: added functionality to update project member's role
Added new API request and dialog responsible for updating project member's role. Issue: storj/storj-private#569 Change-Id: I098f062567d01c3a6e83274c28a872b348858e97
- Loading branch information
1 parent
bb35101
commit 034770a
Showing
11 changed files
with
307 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
web/satellite/src/components/dialogs/ChangeMemberRoleDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// Copyright (C) 2024 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
<template> | ||
<v-dialog | ||
v-model="model" | ||
width="auto" | ||
min-width="400px" | ||
max-width="450px" | ||
transition="fade-transition" | ||
:persistent="isLoading" | ||
> | ||
<v-card rounded="xlg"> | ||
<v-sheet> | ||
<v-card-item class="py-4 pl-6"> | ||
<template #prepend> | ||
<icon-member-color class="mt-1" :size="40" /> | ||
</template> | ||
<v-card-title class="font-weight-bold"> | ||
Change Role | ||
</v-card-title> | ||
<template #append> | ||
<v-btn | ||
icon="$close" | ||
variant="text" | ||
size="small" | ||
color="default" | ||
@click="model = false" | ||
/> | ||
</template> | ||
</v-card-item> | ||
</v-sheet> | ||
|
||
<v-divider /> | ||
|
||
<v-row> | ||
<v-col class="pa-6 mx-3"> | ||
<p class="my-2"> | ||
Selected team member: | ||
</p> | ||
<v-chip class="font-weight-bold text-wrap py-2">{{ email }}</v-chip> | ||
<v-select | ||
v-model="selectedRole" | ||
chips | ||
label="Role" | ||
:items="[ProjectRole.Member, ProjectRole.Admin]" | ||
class="mt-8" | ||
/> | ||
<v-alert color="info" border variant="tonal" class="my-4"> | ||
{{ selectedRole === ProjectRole.Member ? | ||
'Members can only delete API keys and buckets they personally created; they cannot invite new users or remove existing users from the project.' : | ||
'Admins can invite new users, remove existing users (except the project owner), and delete any API keys and buckets, regardless of who created them.' }} | ||
</v-alert> | ||
</v-col> | ||
</v-row> | ||
|
||
<v-divider /> | ||
|
||
<v-card-actions class="pa-6"> | ||
<v-row> | ||
<v-col> | ||
<v-btn variant="outlined" color="default" block @click="model = false">Cancel</v-btn> | ||
</v-col> | ||
<v-col> | ||
<v-btn color="primary" variant="flat" block :loading="isLoading" @click="updateRole"> | ||
Change Role | ||
</v-btn> | ||
</v-col> | ||
</v-row> | ||
</v-card-actions> | ||
</v-card> | ||
</v-dialog> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import { | ||
VAlert, | ||
VBtn, | ||
VCard, | ||
VCardActions, | ||
VCardTitle, | ||
VChip, | ||
VCol, | ||
VDialog, | ||
VDivider, | ||
VRow, | ||
VSelect, | ||
} from 'vuetify/components'; | ||
import { ProjectRole } from '@/types/projectMembers'; | ||
import { useLoading } from '@/composables/useLoading'; | ||
import { useNotify } from '@/utils/hooks'; | ||
import { AnalyticsErrorEventSource } from '@/utils/constants/analyticsEventNames'; | ||
import { useProjectMembersStore } from '@/store/modules/projectMembersStore'; | ||
import { useProjectsStore } from '@/store/modules/projectsStore'; | ||
import IconMemberColor from '@/components/icons/IconMemberColor.vue'; | ||
const props = withDefaults(defineProps<{ | ||
memberId?: string | ||
email?: string | ||
}>(), { | ||
memberId: '', | ||
email: '', | ||
}); | ||
const pmStore = useProjectMembersStore(); | ||
const projectsStore = useProjectsStore(); | ||
const model = defineModel<boolean>({ required: true }); | ||
const selectedRole = ref<ProjectRole>(ProjectRole.Member); | ||
const { isLoading, withLoading } = useLoading(); | ||
const notify = useNotify(); | ||
/** | ||
* Resends project invitation to current project. | ||
*/ | ||
async function updateRole(): Promise<void> { | ||
await withLoading(async () => { | ||
try { | ||
await pmStore.updateRole(projectsStore.state.selectedProject.id, props.memberId, selectedRole.value); | ||
notify.success('Member role was updated successfully'); | ||
model.value = false; | ||
} catch (error) { | ||
error.message = `Error updating role. ${error.message}`; | ||
notify.notifyError(error, AnalyticsErrorEventSource.PROJECT_MEMBERS_PAGE); | ||
} | ||
}); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2024 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
<template> | ||
<svg :width="size" :height="size" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M10.0772 1.5C13.0087 1.5 15.3851 3.87642 15.3851 6.80788C15.3851 8.56688 14.5295 10.126 13.2117 11.0919C15.8554 12.0628 17.9374 14.1988 18.8374 16.8784C18.8652 16.9612 18.8918 17.0445 18.9174 17.1283L18.9548 17.2543C19.1299 17.8598 18.781 18.4927 18.1754 18.6678C18.0724 18.6976 17.9657 18.7127 17.8584 18.7127H2.13186C1.50675 18.7127 1 18.2059 1 17.5808C1 17.4927 1.0103 17.4049 1.03065 17.3192L1.04406 17.2681C1.08085 17.1401 1.12031 17.0133 1.16236 16.8876C2.07214 14.1692 4.19808 12.0091 6.89322 11.0549C5.60362 10.0868 4.76936 8.54476 4.76936 6.80788C4.76936 3.87642 7.14578 1.5 10.0772 1.5ZM10.0014 12.1916C6.85328 12.1916 4.07232 14.1131 2.91359 16.96L2.87976 17.0445H17.1231L17.1225 17.0431C15.9962 14.1805 13.2381 12.2325 10.1006 12.1922L10.0014 12.1916ZM10.0772 3.16819C8.06709 3.16819 6.43755 4.79773 6.43755 6.80788C6.43755 8.81802 8.06709 10.4476 10.0772 10.4476C12.0874 10.4476 13.7169 8.81802 13.7169 6.80788C13.7169 4.79773 12.0874 3.16819 10.0772 3.16819Z" fill="currentColor" /> | ||
</svg> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
withDefaults(defineProps<{ | ||
size?: number; | ||
}>(), { | ||
size: 18, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (C) 2024 Storj Labs, Inc. | ||
// See LICENSE for copying information. | ||
|
||
<template> | ||
<svg :width="size" :height="size" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<rect x="0.5" y="0.5" width="31" height="31" rx="7.5" fill="white" stroke="#EBEEF1" /> | ||
<path d="M16.0695 8.34998C18.7078 8.34998 20.8466 10.4888 20.8466 13.1271C20.8466 14.7102 20.0765 16.1134 18.8905 16.9826C21.2698 17.8565 23.1437 19.7789 23.9536 22.1905C23.9786 22.265 24.0026 22.34 24.0256 22.4154L24.0593 22.5289C24.2169 23.0738 23.9029 23.6434 23.3579 23.801C23.2651 23.8278 23.1691 23.8414 23.0725 23.8414H8.91866C8.35607 23.8414 7.89999 23.3853 7.89999 22.8227C7.89999 22.7434 7.90926 22.6644 7.92758 22.5873L7.93965 22.5412C7.97276 22.4261 8.00827 22.3119 8.04612 22.1988C8.86492 19.7523 10.7783 17.8081 13.2039 16.9494C12.0432 16.0781 11.2924 14.6903 11.2924 13.1271C11.2924 10.4888 13.4312 8.34998 16.0695 8.34998ZM16.0013 17.9724C13.1679 17.9724 10.6651 19.7017 9.62223 22.264L9.59178 22.34H22.4107L22.4102 22.3388C21.3965 19.7624 18.9143 18.0092 16.0905 17.973L16.0013 17.9724ZM16.0695 9.85135C14.2604 9.85135 12.7938 11.3179 12.7938 13.1271C12.7938 14.9362 14.2604 16.4028 16.0695 16.4028C17.8786 16.4028 19.3452 14.9362 19.3452 13.1271C19.3452 11.3179 17.8786 9.85135 16.0695 9.85135Z" fill="black" /> | ||
</svg> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
withDefaults(defineProps<{ | ||
size?: number; | ||
}>(), { | ||
size: 32, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.