mirror of https://github.com/portainer/portainer
fix(access-control): show only environment users [EE-6315] (#10614)
parent
3525a1af77
commit
51474262eb
|
@ -56,6 +56,7 @@
|
|||
resource-control="config.ResourceControl"
|
||||
resource-type="resourceType"
|
||||
on-update-success="(onUpdateResourceControlSuccess)"
|
||||
environment-id="endpoint.Id"
|
||||
>
|
||||
</access-control-panel>
|
||||
<!-- !access-control-panel -->
|
||||
|
|
|
@ -9,6 +9,7 @@ angular.module('portainer.docker').controller('ConfigController', [
|
|||
'endpoint',
|
||||
function ($scope, $transition$, $state, ConfigService, Notifications, endpoint) {
|
||||
$scope.resourceType = ResourceControlType.Config;
|
||||
$scope.endpoint = endpoint;
|
||||
|
||||
$scope.onUpdateResourceControlSuccess = function () {
|
||||
$state.reload();
|
||||
|
|
|
@ -172,6 +172,7 @@
|
|||
resource-control="container.ResourceControl"
|
||||
resource-type="resourceType"
|
||||
on-update-success="(onUpdateResourceControlSuccess)"
|
||||
environment-id="endpoint.Id"
|
||||
>
|
||||
</access-control-panel>
|
||||
<!-- !access-control-panel -->
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
resource-control="secret.ResourceControl"
|
||||
resource-type="resourceType"
|
||||
on-update-success="(onUpdateResourceControlSuccess)"
|
||||
environment-id="endpoint.Id"
|
||||
>
|
||||
</access-control-panel>
|
||||
<!-- !access-control-panel -->
|
||||
|
|
|
@ -1,39 +1,35 @@
|
|||
import { ResourceControlType } from '@/react/portainer/access-control/types';
|
||||
|
||||
angular.module('portainer.docker').controller('SecretController', [
|
||||
'$scope',
|
||||
'$transition$',
|
||||
'$state',
|
||||
'SecretService',
|
||||
'Notifications',
|
||||
function ($scope, $transition$, $state, SecretService, Notifications) {
|
||||
$scope.resourceType = ResourceControlType.Secret;
|
||||
angular.module('portainer.docker').controller('SecretController', SecretController);
|
||||
|
||||
$scope.onUpdateResourceControlSuccess = function () {
|
||||
$state.reload();
|
||||
};
|
||||
/* @ngInject */
|
||||
function SecretController($scope, $transition$, $state, SecretService, Notifications, endpoint) {
|
||||
$scope.resourceType = ResourceControlType.Secret;
|
||||
$scope.endpoint = endpoint;
|
||||
$scope.onUpdateResourceControlSuccess = function () {
|
||||
$state.reload();
|
||||
};
|
||||
|
||||
$scope.removeSecret = function removeSecret(secretId) {
|
||||
SecretService.remove(secretId)
|
||||
.then(function success() {
|
||||
Notifications.success('Success', 'Secret successfully removed');
|
||||
$state.go('docker.secrets', {});
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to remove secret');
|
||||
});
|
||||
};
|
||||
$scope.removeSecret = function removeSecret(secretId) {
|
||||
SecretService.remove(secretId)
|
||||
.then(function success() {
|
||||
Notifications.success('Success', 'Secret successfully removed');
|
||||
$state.go('docker.secrets', {});
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to remove secret');
|
||||
});
|
||||
};
|
||||
|
||||
function initView() {
|
||||
SecretService.secret($transition$.params().id)
|
||||
.then(function success(data) {
|
||||
$scope.secret = data;
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to retrieve secret details');
|
||||
});
|
||||
}
|
||||
function initView() {
|
||||
SecretService.secret($transition$.params().id)
|
||||
.then(function success(data) {
|
||||
$scope.secret = data;
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error('Failure', err, 'Unable to retrieve secret details');
|
||||
});
|
||||
}
|
||||
|
||||
initView();
|
||||
},
|
||||
]);
|
||||
initView();
|
||||
}
|
||||
|
|
|
@ -209,6 +209,7 @@
|
|||
resource-control="service.ResourceControl"
|
||||
resource-type="resourceType"
|
||||
on-update-success="(onUpdateResourceControlSuccess)"
|
||||
environment-id="endpoint.Id"
|
||||
>
|
||||
</access-control-panel>
|
||||
<!-- !access-control-panel -->
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
resource-control="volume.ResourceControl"
|
||||
resource-type="resourceType"
|
||||
on-update-success="(onUpdateResourceControlSuccess)"
|
||||
environment-id="endpoint.Id"
|
||||
>
|
||||
</access-control-panel>
|
||||
<!-- !access-control-panel -->
|
||||
|
|
|
@ -12,6 +12,7 @@ angular.module('portainer.docker').controller('VolumeController', [
|
|||
'endpoint',
|
||||
function ($scope, $state, $transition$, VolumeService, ContainerService, Notifications, HttpRequestHelper, endpoint) {
|
||||
$scope.resourceType = ResourceControlType.Volume;
|
||||
$scope.endpoint = endpoint;
|
||||
|
||||
$scope.onUpdateResourceControlSuccess = function () {
|
||||
$state.reload();
|
||||
|
|
|
@ -39,7 +39,7 @@ export function useUsers<T = User[]>(
|
|||
select: (data: User[]) => T = (data) => data as unknown as T
|
||||
) {
|
||||
const users = useQuery(
|
||||
['users'],
|
||||
['users', { includeAdministrator, environmentId }],
|
||||
() => getUsers(includeAdministrator, environmentId),
|
||||
{
|
||||
meta: {
|
||||
|
|
|
@ -187,6 +187,7 @@ export function CreateContainerInstanceForm() {
|
|||
onChange={(values) => setFieldValue('accessControl', values)}
|
||||
values={values.accessControl}
|
||||
errors={errors.accessControl}
|
||||
environmentId={environmentId}
|
||||
/>
|
||||
|
||||
<div className="form-group">
|
||||
|
|
|
@ -169,6 +169,7 @@ export function BaseForm({
|
|||
}
|
||||
errors={errors?.accessControl}
|
||||
values={values.accessControl}
|
||||
environmentId={environment.Id}
|
||||
/>
|
||||
|
||||
<div className="form-group">
|
||||
|
|
|
@ -43,7 +43,12 @@ function Template({ userRole }: Args) {
|
|||
return (
|
||||
<QueryClientProvider client={testQueryClient}>
|
||||
<UserContext.Provider value={userProviderState}>
|
||||
<AccessControlForm values={value} onChange={setValue} errors={{}} />
|
||||
<AccessControlForm
|
||||
values={value}
|
||||
onChange={setValue}
|
||||
errors={{}}
|
||||
environmentId={1}
|
||||
/>
|
||||
</UserContext.Provider>
|
||||
</QueryClientProvider>
|
||||
);
|
||||
|
|
|
@ -315,6 +315,7 @@ async function renderComponent(
|
|||
const renderResult = renderWithQueryClient(
|
||||
<UserContext.Provider value={state}>
|
||||
<AccessControlForm
|
||||
environmentId={1}
|
||||
errors={{}}
|
||||
values={values}
|
||||
onChange={onChange}
|
||||
|
|
|
@ -7,6 +7,7 @@ import { SwitchField } from '@@/form-components/SwitchField';
|
|||
|
||||
import { EditDetails } from '../EditDetails';
|
||||
import { ResourceControlOwnership, AccessControlFormData } from '../types';
|
||||
import { EnvironmentId } from '../../environments/types';
|
||||
|
||||
export interface Props {
|
||||
values: AccessControlFormData;
|
||||
|
@ -14,6 +15,7 @@ export interface Props {
|
|||
hideTitle?: boolean;
|
||||
formNamespace?: string;
|
||||
errors?: FormikErrors<AccessControlFormData>;
|
||||
environmentId: EnvironmentId;
|
||||
}
|
||||
|
||||
export function AccessControlForm({
|
||||
|
@ -22,6 +24,7 @@ export function AccessControlForm({
|
|||
hideTitle,
|
||||
formNamespace,
|
||||
errors,
|
||||
environmentId,
|
||||
}: Props) {
|
||||
const { isAdmin } = useUser();
|
||||
|
||||
|
@ -50,6 +53,7 @@ export function AccessControlForm({
|
|||
values={values}
|
||||
errors={errors}
|
||||
formNamespace={formNamespace}
|
||||
environmentId={environmentId}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
|
|
@ -30,7 +30,7 @@ interface Props {
|
|||
resourceType: ResourceControlType;
|
||||
resourceId: ResourceId;
|
||||
resourceControl?: ResourceControlViewModel;
|
||||
environmentId?: EnvironmentId;
|
||||
environmentId: EnvironmentId;
|
||||
onCancelClick(): void;
|
||||
onUpdateSuccess(): Promise<void>;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ interface Props {
|
|||
isPublicVisible?: boolean;
|
||||
errors?: FormikErrors<AccessControlFormData>;
|
||||
formNamespace?: string;
|
||||
environmentId?: EnvironmentId;
|
||||
environmentId: EnvironmentId;
|
||||
}
|
||||
|
||||
export function EditDetails({
|
||||
|
|
|
@ -2,7 +2,7 @@ import { useTeams } from '@/react/portainer/users/teams/queries';
|
|||
import { useUsers } from '@/portainer/users/queries';
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
|
||||
export function useLoadState(environmentId?: EnvironmentId, enabled = true) {
|
||||
export function useLoadState(environmentId: EnvironmentId, enabled = true) {
|
||||
const teams = useTeams(false, environmentId);
|
||||
|
||||
const users = useUsers(false, environmentId, enabled);
|
||||
|
|
Loading…
Reference in New Issue