Merge branch 'main' into feat/protect-users-endpoint
This commit is contained in:
commit
f4df97494a
7 changed files with 49 additions and 12 deletions
|
@ -1,5 +1,16 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.0.5]
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
|
||||||
|
* Propagate admin access to all apps for dashboard admins #62
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Update dashboard to v0.2.6
|
||||||
|
* Update dashboard-backend to v0.2.7
|
||||||
|
|
||||||
## [1.0.4]
|
## [1.0.4]
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
annotations:
|
annotations:
|
||||||
category: Dashboard
|
category: Dashboard
|
||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
appVersion: 0.2.5
|
appVersion: 0.2.6
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: common
|
- name: common
|
||||||
# https://artifacthub.io/packages/helm/bitnami/common
|
# https://artifacthub.io/packages/helm/bitnami/common
|
||||||
|
@ -23,4 +23,4 @@ name: stackspin-dashboard
|
||||||
sources:
|
sources:
|
||||||
- https://open.greenhost.net/stackspin/dashboard/
|
- https://open.greenhost.net/stackspin/dashboard/
|
||||||
- https://open.greenhost.net/stackspin/dashboard-backend/
|
- https://open.greenhost.net/stackspin/dashboard-backend/
|
||||||
version: 1.0.4
|
version: 1.0.5
|
||||||
|
|
|
@ -68,7 +68,7 @@ dashboard:
|
||||||
image:
|
image:
|
||||||
registry: open.greenhost.net:4567
|
registry: open.greenhost.net:4567
|
||||||
repository: stackspin/dashboard/dashboard
|
repository: stackspin/dashboard/dashboard
|
||||||
tag: 0-2-5
|
tag: 0-2-6
|
||||||
## Optionally specify an array of imagePullSecrets.
|
## Optionally specify an array of imagePullSecrets.
|
||||||
## Secrets must be manually created in the namespace.
|
## Secrets must be manually created in the namespace.
|
||||||
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
|
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
|
||||||
|
@ -235,7 +235,7 @@ backend:
|
||||||
image:
|
image:
|
||||||
registry: open.greenhost.net:4567
|
registry: open.greenhost.net:4567
|
||||||
repository: stackspin/dashboard-backend/dashboard-backend
|
repository: stackspin/dashboard-backend/dashboard-backend
|
||||||
tag: 0-2-6
|
tag: 0-2-7
|
||||||
## Optionally specify an array of imagePullSecrets.
|
## Optionally specify an array of imagePullSecrets.
|
||||||
## Secrets must be manually created in the namespace.
|
## Secrets must be manually created in the namespace.
|
||||||
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
|
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import { useController } from 'react-hook-form';
|
import { useController } from 'react-hook-form';
|
||||||
|
|
||||||
/* eslint-disable react/react-in-jsx-scope */
|
/* eslint-disable react/react-in-jsx-scope */
|
||||||
export const Select = ({ control, name, label, options }: SelectProps) => {
|
export const Select = ({ control, name, label, options, disabled = false }: SelectProps) => {
|
||||||
const {
|
const {
|
||||||
field,
|
field,
|
||||||
// fieldState: { invalid, isTouched, isDirty },
|
// fieldState: { invalid, isTouched, isDirty },
|
||||||
|
@ -27,6 +27,7 @@ export const Select = ({ control, name, label, options }: SelectProps) => {
|
||||||
name={name} // send down the input name
|
name={name} // send down the input name
|
||||||
ref={field.ref} // send input ref, so we can focus on input when error appear
|
ref={field.ref} // send input ref, so we can focus on input when error appear
|
||||||
className="shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-300 rounded-md"
|
className="shadow-sm focus:ring-primary-500 focus:border-primary-500 block w-full sm:text-sm border-gray-300 rounded-md"
|
||||||
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
{options?.map((option) => (
|
{options?.map((option) => (
|
||||||
<option key={option.value} value={option.value}>
|
<option key={option.value} value={option.value}>
|
||||||
|
@ -43,4 +44,5 @@ type SelectProps = {
|
||||||
name: string;
|
name: string;
|
||||||
label?: string;
|
label?: string;
|
||||||
options?: any[];
|
options?: any[];
|
||||||
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
|
@ -173,7 +173,9 @@ const Header: React.FC<HeaderProps> = () => {
|
||||||
)}
|
)}
|
||||||
</Disclosure>
|
</Disclosure>
|
||||||
|
|
||||||
|
{currentUserModal && (
|
||||||
<UserModal open={currentUserModal} onClose={currentUserModalClose} userId={currentUserId} setUserId={_.noop} />
|
<UserModal open={currentUserModal} onClose={currentUserModalClose} userId={currentUserId} setUserId={_.noop} />
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { TrashIcon } from '@heroicons/react/outline';
|
import { TrashIcon } from '@heroicons/react/outline';
|
||||||
import { useFieldArray, useForm } from 'react-hook-form';
|
import { useFieldArray, useForm, useWatch } from 'react-hook-form';
|
||||||
import { Modal, ConfirmationModal } from 'src/components';
|
import { Banner, Modal, ConfirmationModal } from 'src/components';
|
||||||
import { Input, Select } from 'src/components/Form';
|
import { Input, Select } from 'src/components/Form';
|
||||||
import { User, UserRole, useUsers } from 'src/services/users';
|
import { User, UserRole, useUsers } from 'src/services/users';
|
||||||
import { useAuth } from 'src/services/auth';
|
import { useAuth } from 'src/services/auth';
|
||||||
|
@ -29,7 +29,7 @@ export const UserModal = ({ open, onClose, userId, setUserId }: UserModalProps)
|
||||||
defaultValues: initialUserForm,
|
defaultValues: initialUserForm,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { fields } = useFieldArray({
|
const { fields, update } = useFieldArray({
|
||||||
control,
|
control,
|
||||||
name: 'app_roles',
|
name: 'app_roles',
|
||||||
});
|
});
|
||||||
|
@ -44,8 +44,6 @@ export const UserModal = ({ open, onClose, userId, setUserId }: UserModalProps)
|
||||||
loadUser(userId);
|
loadUser(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reset(initialUserForm);
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [userId, open]);
|
}, [userId, open]);
|
||||||
|
|
||||||
|
@ -59,6 +57,18 @@ export const UserModal = ({ open, onClose, userId, setUserId }: UserModalProps)
|
||||||
};
|
};
|
||||||
}, [user, reset, open]);
|
}, [user, reset, open]);
|
||||||
|
|
||||||
|
const dashboardRole = useWatch({
|
||||||
|
control,
|
||||||
|
name: 'app_roles.0.role',
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (dashboardRole === UserRole.Admin) {
|
||||||
|
fields.forEach((field, index) => update(index, { name: field.name, role: UserRole.Admin }));
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [dashboardRole]);
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
try {
|
try {
|
||||||
if (isPersonalModal) {
|
if (isPersonalModal) {
|
||||||
|
@ -193,6 +203,15 @@ export const UserModal = ({ open, onClose, userId, setUserId }: UserModalProps)
|
||||||
<h3 className="text-lg leading-6 font-medium text-gray-900">App Access</h3>
|
<h3 className="text-lg leading-6 font-medium text-gray-900">App Access</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{dashboardRole === UserRole.Admin && (
|
||||||
|
<div className="sm:col-span-6">
|
||||||
|
<Banner
|
||||||
|
title="Admin users automatically have admin-level access to all apps."
|
||||||
|
titleSm="Admin user"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div className="flow-root mt-6">
|
<div className="flow-root mt-6">
|
||||||
<ul className="-my-5 divide-y divide-gray-200 ">
|
<ul className="-my-5 divide-y divide-gray-200 ">
|
||||||
|
@ -219,6 +238,7 @@ export const UserModal = ({ open, onClose, userId, setUserId }: UserModalProps)
|
||||||
key={item.id}
|
key={item.id}
|
||||||
control={control}
|
control={control}
|
||||||
name={`app_roles.${index}.role`}
|
name={`app_roles.${index}.role`}
|
||||||
|
disabled={dashboardRole === UserRole.Admin}
|
||||||
options={[
|
options={[
|
||||||
{ value: UserRole.NoAccess, name: 'No Access' },
|
{ value: UserRole.NoAccess, name: 'No Access' },
|
||||||
{ value: UserRole.User, name: 'User' },
|
{ value: UserRole.User, name: 'User' },
|
||||||
|
|
|
@ -163,7 +163,9 @@ export const Users: React.FC = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{configureModal && (
|
||||||
<UserModal open={configureModal} onClose={configureModalClose} userId={userId} setUserId={setUserId} />
|
<UserModal open={configureModal} onClose={configureModalClose} userId={userId} setUserId={setUserId} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue