mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-05 16:10:43 +00:00
fix: show edit button for users in cloud version (#12432)
This commit is contained in:
@@ -263,6 +263,10 @@ pub async fn update_user(
|
||||
mut user: UpdateUser,
|
||||
) -> Result<Response, Error> {
|
||||
let mut allow_password_update = false;
|
||||
#[cfg(feature = "cloud")]
|
||||
let is_cloud = true;
|
||||
#[cfg(not(feature = "cloud"))]
|
||||
let is_cloud = false;
|
||||
if !is_valid_email(email) {
|
||||
return Ok(MetaHttpResponse::bad_request("Invalid email"));
|
||||
}
|
||||
@@ -315,6 +319,7 @@ pub async fn update_user(
|
||||
let mut custom_roles_need_change = false;
|
||||
match existing_user {
|
||||
Some(local_user) => {
|
||||
#[cfg(not(feature = "cloud"))]
|
||||
if local_user.is_external {
|
||||
return Ok(MetaHttpResponse::bad_request(
|
||||
"Updates not allowed with external users, please update with source system",
|
||||
@@ -401,7 +406,7 @@ pub async fn update_user(
|
||||
is_updated = true;
|
||||
}
|
||||
if let Some(role) = user.role
|
||||
&& !local_user.is_external
|
||||
&& (!local_user.is_external || is_cloud)
|
||||
&& (!update_mode.is_self_update()
|
||||
|| (local_user.role.eq(&UserRole::Admin)
|
||||
// Editor can update other's roles, but viewer can update only self
|
||||
|
||||
@@ -73,7 +73,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
</div>
|
||||
|
||||
<OInput
|
||||
v-if="!existingUser"
|
||||
v-if="!existingUser && !isCloud"
|
||||
v-model="formData.first_name"
|
||||
:label="t('user.firstName')"
|
||||
class="showLabelOnTop tw:mt-2"
|
||||
@@ -81,7 +81,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/>
|
||||
|
||||
<OInput
|
||||
v-if="!existingUser"
|
||||
v-if="!existingUser && !isCloud"
|
||||
v-model="formData.last_name"
|
||||
:label="t('user.lastName')"
|
||||
class="showLabelOnTop tw:mt-2"
|
||||
@@ -115,16 +115,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
class="showLabelOnTop tw:mt-2"
|
||||
multiple
|
||||
data-test="user-custom-role-field"
|
||||
:disable="filterdOption.length === 0 || !!formData.is_external"
|
||||
:disable="isCloud ? filterdOption.length === 0 : (filterdOption.length === 0 || !!formData.is_external)"
|
||||
:hint="
|
||||
formData.is_external
|
||||
? t('user.externalUserCustomRoleHint')
|
||||
: filterdOption.length === 0
|
||||
? t('user.noCustomRolesHint')
|
||||
: ''
|
||||
isCloud
|
||||
? (filterdOption.length === 0 ? t('user.noCustomRolesHint') : '')
|
||||
: formData.is_external
|
||||
? t('user.externalUserCustomRoleHint')
|
||||
: filterdOption.length === 0
|
||||
? t('user.noCustomRolesHint')
|
||||
: ''
|
||||
"
|
||||
/>
|
||||
<div v-if="beingUpdated" class="tw:mt-2">
|
||||
<div v-if="beingUpdated && !isCloud" class="tw:mt-2">
|
||||
<OSwitch
|
||||
v-model="formData.change_password"
|
||||
:label="t('user.changePassword')"
|
||||
@@ -300,6 +302,10 @@ export default defineComponent({
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
isCloud: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
emits: ["update:modelValue", "updated", "update:open"],
|
||||
setup(props) {
|
||||
|
||||
@@ -132,7 +132,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
<OIcon name="cancel" size="sm" />
|
||||
</OButton>
|
||||
<OButton
|
||||
v-if="row.enableEdit && row.status != 'pending' && config.isCloud == 'false'"
|
||||
v-if="row.enableEdit && row.status != 'pending'"
|
||||
:title="t('user.update')"
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
@@ -168,12 +168,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
<add-user
|
||||
v-model:open="showAddUserDialog"
|
||||
v-if="config.isCloud == 'false'"
|
||||
v-model="selectedUser"
|
||||
:isUpdated="isUpdated"
|
||||
:userRole="currentUserRole"
|
||||
:roles="options"
|
||||
:customRoles="customRoles"
|
||||
:isCloud="config.isCloud == 'true'"
|
||||
@updated="addMember"
|
||||
/>
|
||||
|
||||
@@ -748,6 +748,12 @@ export default defineComponent({
|
||||
if (user.role?.toLowerCase() === "root") {
|
||||
return store.state.userInfo.email === user.email;
|
||||
}
|
||||
// Cloud: cannot edit self (same as delete behavior)
|
||||
if (config.isCloud == "true") {
|
||||
return (
|
||||
store.state.userInfo.email.toLowerCase() !== user.email.toLowerCase()
|
||||
);
|
||||
}
|
||||
// Allow editing for all other users
|
||||
return true;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user