mirror of https://github.com/portainer/portainer
fix(image): Add hide default registry teaser for CE version [EE-4038] (#7533)
* fix(image): Add hide default registry teaser for CE version [EE-4038]. * fix(image): Hide advanced mode only if there is no docker hub registries [EE-3734] * sync with EEpull/7566/head
parent
234627f278
commit
c6ab5d5717
@ -0,0 +1,81 @@
|
||||
import {
|
||||
usePublicSettings,
|
||||
useUpdateDefaultRegistrySettingsMutation,
|
||||
} from 'Portainer/settings/queries';
|
||||
import { notifySuccess } from 'Portainer/services/notifications';
|
||||
import { FeatureId } from 'Portainer/feature-flags/enums';
|
||||
|
||||
import { isLimitedToBE } from '@/portainer/feature-flags/feature-flags.service';
|
||||
|
||||
import { Tooltip } from '@@/Tip/Tooltip';
|
||||
import { Button } from '@@/buttons';
|
||||
import { Icon } from '@@/Icon';
|
||||
import { BEFeatureIndicator } from '@@/BEFeatureIndicator';
|
||||
|
||||
export function DefaultRegistryAction() {
|
||||
const settingsQuery = usePublicSettings({
|
||||
select: (settings) => settings.DefaultRegistry?.Hide,
|
||||
});
|
||||
const defaultRegistryMutation = useUpdateDefaultRegistrySettingsMutation();
|
||||
|
||||
if (!settingsQuery.isSuccess) {
|
||||
return null;
|
||||
}
|
||||
const hideDefaultRegistry = settingsQuery.data;
|
||||
|
||||
const isLimited = isLimitedToBE(FeatureId.HIDE_DOCKER_HUB_ANONYMOUS);
|
||||
|
||||
return (
|
||||
<>
|
||||
{!hideDefaultRegistry ? (
|
||||
<div className="vertical-center">
|
||||
<Button
|
||||
className="btn btn-xs btn-light vertical-center"
|
||||
onClick={() => handleShowOrHide(true)}
|
||||
disabled={isLimited}
|
||||
>
|
||||
<Icon icon="eye-off" feather />
|
||||
Hide for all users
|
||||
</Button>
|
||||
<BEFeatureIndicator featureId={FeatureId.HIDE_DOCKER_HUB_ANONYMOUS} />
|
||||
{isLimited ? null : (
|
||||
<Tooltip
|
||||
message="This hides the option in any registry dropdown prompts but does not prevent a user from deploying anonymously from Docker Hub directly via YAML.
|
||||
Note: Docker Hub (anonymous) will continue to show as the ONLY option if there are NO other registries available to the user."
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="vertical-center">
|
||||
<Button
|
||||
className="btn btn-xs btn-success vertical-center"
|
||||
onClick={() => handleShowOrHide(false)}
|
||||
>
|
||||
<Icon icon="eye" feather />
|
||||
Show for all users
|
||||
</Button>
|
||||
<Tooltip
|
||||
message="This reveals the option in any registry dropdown prompts.
|
||||
(but note that the Docker Hub (anonymous) option only shows if there is no credentialled Docker Hub option available to the user)."
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
function handleShowOrHide(hideDefaultRegistry: boolean) {
|
||||
defaultRegistryMutation.mutate(
|
||||
{
|
||||
Hide: hideDefaultRegistry,
|
||||
},
|
||||
{
|
||||
onSuccess() {
|
||||
notifySuccess(
|
||||
'Success',
|
||||
'Default registry Settings updated successfully'
|
||||
);
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
import clsx from 'clsx';
|
||||
import { usePublicSettings } from 'Portainer/settings/queries';
|
||||
|
||||
export function DefaultRegistryDomain() {
|
||||
const settingsQuery = usePublicSettings({
|
||||
select: (settings) => settings.DefaultRegistry?.Hide,
|
||||
});
|
||||
|
||||
return (
|
||||
<span
|
||||
className={clsx({
|
||||
'cm-strikethrough': settingsQuery.isSuccess && settingsQuery.data,
|
||||
})}
|
||||
>
|
||||
docker.io
|
||||
</span>
|
||||
);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
import { usePublicSettings } from 'Portainer/settings/queries';
|
||||
import clsx from 'clsx';
|
||||
|
||||
export function DefaultRegistryName() {
|
||||
const settingsQuery = usePublicSettings({
|
||||
select: (settings) => settings.DefaultRegistry?.Hide,
|
||||
});
|
||||
|
||||
return (
|
||||
<span
|
||||
className={clsx({
|
||||
'cm-strikethrough': settingsQuery.isSuccess && settingsQuery.data,
|
||||
})}
|
||||
>
|
||||
Docker Hub (anonymous)
|
||||
</span>
|
||||
);
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
export { DefaultRegistryAction } from './DefaultRegistryAction';
|
||||
export { DefaultRegistryDomain } from './DefaultRegistryDomain';
|
||||
export { DefaultRegistryName } from './DefaultRegistryName';
|
Loading…
Reference in new issue