fix(docs): make all doc links versioned [EE-6861] (#11382)

pull/11387/head
Matt Hook 2024-03-15 16:57:51 +13:00 committed by GitHub
parent 9ea5efb6ba
commit 73307e164b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 66 additions and 23 deletions

View File

@ -18,7 +18,7 @@
<p class="text-muted" ng-if="applicationState.endpoint.mode.role === 'MANAGER'"> <p class="text-muted" ng-if="applicationState.endpoint.mode.role === 'MANAGER'">
<pr-icon icon="'alert-circle'" mode="'primary'"></pr-icon> <pr-icon icon="'alert-circle'" mode="'primary'"></pr-icon>
Portainer is connected to a node that is part of a Swarm cluster. Some resources located on other nodes in the cluster might not be available for management, have a look at Portainer is connected to a node that is part of a Swarm cluster. Some resources located on other nodes in the cluster might not be available for management, have a look at
<a href="https://docs.portainer.io/admin/environments/add/swarm/agent" target="_blank">our agent setup</a> for more details. <help-link doc-link="'/admin/environments/add/swarm/agent'" target="'_blank'" children="'our agent setup'"></help-link> for more details.
</p> </p>
<p class="text-muted" ng-if="applicationState.endpoint.mode.role === 'WORKER'"> <p class="text-muted" ng-if="applicationState.endpoint.mode.role === 'WORKER'">
<pr-icon icon="'alert-circle'" mode="'primary'"></pr-icon> <pr-icon icon="'alert-circle'" mode="'primary'"></pr-icon>

View File

@ -106,7 +106,7 @@
deploy-method="{{ ctrl.state.DeployType === ctrl.ManifestDeployTypes.COMPOSE ? 'compose' : 'manifest' }}" deploy-method="{{ ctrl.state.DeployType === ctrl.ManifestDeployTypes.COMPOSE ? 'compose' : 'manifest' }}"
base-webhook-url="{{ ctrl.state.baseWebhookUrl }}" base-webhook-url="{{ ctrl.state.baseWebhookUrl }}"
webhook-id="{{ ctrl.state.webhookId }}" webhook-id="{{ ctrl.state.webhookId }}"
webhooks-docs="https://docs.portainer.io/user/kubernetes/applications/webhooks" webhooks-docs="/user/kubernetes/applications/webhooks"
></git-form> ></git-form>
<!-- !repository --> <!-- !repository -->

View File

@ -12,7 +12,7 @@
is-force-pull-visible="false" is-force-pull-visible="false"
base-webhook-url="{{ $ctrl.state.baseWebhookUrl }}" base-webhook-url="{{ $ctrl.state.baseWebhookUrl }}"
webhook-id="{{ $ctrl.state.webhookId }}" webhook-id="{{ $ctrl.state.webhookId }}"
webhooks-docs="https://docs.portainer.io/user/kubernetes/applications/webhooks" webhooks-docs="/user/kubernetes/applications/webhooks"
></git-form-auto-update-fieldset> ></git-form-auto-update-fieldset>
<time-window-display></time-window-display> <time-window-display></time-window-display>

View File

@ -16,7 +16,7 @@
is-force-pull-visible="$ctrl.stack.Type !== 3" is-force-pull-visible="$ctrl.stack.Type !== 3"
base-webhook-url="{{ $ctrl.state.baseWebhookUrl }}" base-webhook-url="{{ $ctrl.state.baseWebhookUrl }}"
webhook-id="{{ $ctrl.state.webhookId }}" webhook-id="{{ $ctrl.state.webhookId }}"
webhooks-docs="https://docs.portainer.io/user/docker/stacks/webhooks" webhooks-docs="/user/docker/stacks/webhooks"
></git-form-auto-update-fieldset> ></git-form-auto-update-fieldset>
<div class="form-group"> <div class="form-group">

View File

@ -36,6 +36,7 @@ import { Slider } from '@@/form-components/Slider';
import { TagButton } from '@@/TagButton'; import { TagButton } from '@@/TagButton';
import { BETeaserButton } from '@@/BETeaserButton'; import { BETeaserButton } from '@@/BETeaserButton';
import { CodeEditor } from '@@/CodeEditor'; import { CodeEditor } from '@@/CodeEditor';
import { HelpLink } from '@@/PageHeader/HelpLink';
import { fileUploadField } from './file-upload-field'; import { fileUploadField } from './file-upload-field';
import { switchField } from './switch-field'; import { switchField } from './switch-field';
@ -126,6 +127,14 @@ export const ngModule = angular
'reactQueryDevTools', 'reactQueryDevTools',
r2a(withReactQuery(ReactQueryDevtoolsWrapper), []) r2a(withReactQuery(ReactQueryDevtoolsWrapper), [])
) )
.component(
'helpLink',
r2a(withUIRouter(withReactQuery(HelpLink)), [
'docLink',
'target',
'children',
])
)
.component( .component(
'dashboardItem', 'dashboardItem',
r2a(DashboardItem, [ r2a(DashboardItem, [

View File

@ -87,7 +87,7 @@
is-force-pull-visible="true" is-force-pull-visible="true"
base-webhook-url="{{ state.baseWebhookUrl }}" base-webhook-url="{{ state.baseWebhookUrl }}"
webhook-id="{{ state.webhookId }}" webhook-id="{{ state.webhookId }}"
webhooks-docs="https://docs.portainer.io/user/docker/stacks/webhooks" webhooks-docs="/user/docker/stacks/webhooks"
></git-form> ></git-form>
<div ng-show="state.Method === 'template'"> <div ng-show="state.Method === 'template'">

View File

@ -32,11 +32,11 @@ export function ContextHelp() {
); );
} }
function useDocsUrl(): string { export function useDocsUrl(doc?: string): string {
const { state } = useCurrentStateAndParams(); const { state } = useCurrentStateAndParams();
const versionQuery = useSystemVersion(); const versionQuery = useSystemVersion();
if (!state) { if (!doc && !state) {
return ''; return '';
} }
@ -54,6 +54,10 @@ function useDocsUrl(): string {
} }
} }
if (doc) {
return url + doc;
}
const { data } = state; const { data } = state;
if ( if (
data && data &&

View File

@ -0,0 +1,21 @@
import { useDocsUrl } from '../ContextHelp/ContextHelp';
type HelpLinkProps = {
docLink?: string;
target?: string;
children?: React.ReactNode;
};
export function HelpLink({
docLink,
target = '_blank',
children,
}: HelpLinkProps) {
const docsUrl = useDocsUrl(docLink);
return (
<a href={docsUrl} target={target} rel="noreferrer">
{children}
</a>
);
}

View File

@ -0,0 +1 @@
export { HelpLink } from './HelpLink';

View File

@ -17,6 +17,7 @@ import { confirmDestructive } from '@@/modals/confirm';
import { buildConfirmButton } from '@@/modals/utils'; import { buildConfirmButton } from '@@/modals/utils';
import { InformationPanel } from '@@/InformationPanel'; import { InformationPanel } from '@@/InformationPanel';
import { TextTip } from '@@/Tip/TextTip'; import { TextTip } from '@@/Tip/TextTip';
import { useDocsUrl } from '@@/PageHeader/ContextHelp/ContextHelp';
import { useContainers } from '../queries/containers'; import { useContainers } from '../queries/containers';
import { useSystemLimits } from '../../proxy/queries/useInfo'; import { useSystemLimits } from '../../proxy/queries/useInfo';
@ -77,6 +78,8 @@ function CreateForm() {
isDockerhubRateLimited, isDockerhubRateLimited,
}); });
const createContDocUrl = useDocsUrl('/docker/containers/create');
if (!envQuery.data || !initialValuesQuery) { if (!envQuery.data || !initialValuesQuery) {
return null; return null;
} }
@ -101,11 +104,7 @@ function CreateForm() {
The new container may fail to start if the image is changed, and The new container may fail to start if the image is changed, and
settings from the previous container aren&apos;t compatible. Common settings from the previous container aren&apos;t compatible. Common
causes include entrypoint, cmd or causes include entrypoint, cmd or
<a <a href={createContDocUrl} target="_blank" rel="noreferrer">
href="https://docs.portainer.io/user/docker/containers/advanced"
target="_blank"
rel="noreferrer"
>
other settings other settings
</a>{' '} </a>{' '}
set by an image. set by an image.

View File

@ -7,6 +7,7 @@ import { FormSectionTitle } from '@@/form-components/FormSectionTitle';
import { Input } from '@@/form-components/Input'; import { Input } from '@@/form-components/Input';
import { Button } from '@@/buttons'; import { Button } from '@@/buttons';
import { TextTip } from '@@/Tip/TextTip'; import { TextTip } from '@@/Tip/TextTip';
import { useDocsUrl } from '@@/PageHeader/ContextHelp/ContextHelp';
const initialValues = { const initialValues = {
kubeConfig: '', kubeConfig: '',
@ -18,6 +19,10 @@ const initialValues = {
}; };
export function KubeConfigTeaserForm() { export function KubeConfigTeaserForm() {
const kubeConfigImportDocUrl = useDocsUrl(
'admin/environments/add/kubernetes/import'
);
return ( return (
<Formik initialValues={initialValues} onSubmit={() => {}} validateOnMount> <Formik initialValues={initialValues} onSubmit={() => {}} validateOnMount>
{() => ( {() => (
@ -28,7 +33,7 @@ export function KubeConfigTeaserForm() {
<TextTip color="blue"> <TextTip color="blue">
<span className="text-muted"> <span className="text-muted">
<a <a
href="https://docs.portainer.io/admin/environments/add/kubernetes/import" href={kubeConfigImportDocUrl}
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
> >

View File

@ -11,6 +11,7 @@ import { TimeWindowDisplay } from '@/react/portainer/gitops/TimeWindowDisplay';
import { FormSection } from '@@/form-components/FormSection'; import { FormSection } from '@@/form-components/FormSection';
import { validateForm } from '@@/form-components/validate-form'; import { validateForm } from '@@/form-components/validate-form';
import { SwitchField } from '@@/form-components/SwitchField'; import { SwitchField } from '@@/form-components/SwitchField';
import { useDocsUrl } from '@@/PageHeader/ContextHelp/ContextHelp';
import { GitCredential } from '../account/git-credentials/types'; import { GitCredential } from '../account/git-credentials/types';
@ -50,6 +51,8 @@ export function GitForm({
webhooksDocs, webhooksDocs,
}: Props) { }: Props) {
const [value, setValue] = useState(initialValue); // TODO: remove this state when form is not inside angularjs const [value, setValue] = useState(initialValue); // TODO: remove this state when form is not inside angularjs
const webhooksDocsUrl = useDocsUrl(webhooksDocs);
return ( return (
<FormSection title="Git repository"> <FormSection title="Git repository">
<AuthFieldset <AuthFieldset
@ -105,7 +108,7 @@ export function GitForm({
onChange={(value) => handleChange({ AutoUpdate: value })} onChange={(value) => handleChange({ AutoUpdate: value })}
isForcePullVisible={isForcePullVisible} isForcePullVisible={isForcePullVisible}
errors={errors.AutoUpdate as FormikErrors<GitFormModel['AutoUpdate']>} errors={errors.AutoUpdate as FormikErrors<GitFormModel['AutoUpdate']>}
webhooksDocs={webhooksDocs} webhooksDocs={webhooksDocsUrl}
/> />
)} )}

View File

@ -10,6 +10,7 @@ import { SwitchField } from '@@/form-components/SwitchField';
import { TextTip } from '@@/Tip/TextTip'; import { TextTip } from '@@/Tip/TextTip';
import { FormControl } from '@@/form-components/FormControl'; import { FormControl } from '@@/form-components/FormControl';
import { Input, Select } from '@@/form-components/Input'; import { Input, Select } from '@@/form-components/Input';
import { useDocsUrl } from '@@/PageHeader/ContextHelp/ContextHelp';
import { RelativePathModel, getPerDevConfigsFilterType } from './types'; import { RelativePathModel, getPerDevConfigsFilterType } from './types';
@ -37,6 +38,10 @@ export function RelativePathFieldset({
const { enableFsPath0, enableFsPath1, toggleFsPath } = useEnableFsPath(value); const { enableFsPath0, enableFsPath1, toggleFsPath } = useEnableFsPath(value);
const gitoptsEdgeConfigDocUrl = useDocsUrl(
'/user/edge/stacks/add#gitops-edge-configurations'
);
const pathTip0 = const pathTip0 =
'For relative path volumes use with Docker Swarm, you must have a network filesystem which all of your nodes can access.'; 'For relative path volumes use with Docker Swarm, you must have a network filesystem which all of your nodes can access.';
const pathTip1 = const pathTip1 =
@ -279,10 +284,7 @@ export function RelativePathFieldset({
./config/$&#123;PORTAINER_EDGE_GROUP&#125;:/myapp/groupconfig ./config/$&#123;PORTAINER_EDGE_GROUP&#125;:/myapp/groupconfig
</code> </code>
. More documentation can be found{' '} . More documentation can be found{' '}
<a href="https://docs.portainer.io/user/edge/stacks/add#gitops-edge-configurations"> <a href={gitoptsEdgeConfigDocUrl}>here</a>.
here
</a>
.
</div> </div>
</TextTip> </TextTip>
</div> </div>

View File

@ -3,6 +3,7 @@ import { useField, Field } from 'formik';
import { FormControl } from '@@/form-components/FormControl'; import { FormControl } from '@@/form-components/FormControl';
import { FormSection } from '@@/form-components/FormSection'; import { FormSection } from '@@/form-components/FormSection';
import { Input } from '@@/form-components/Input'; import { Input } from '@@/form-components/Input';
import { useDocsUrl } from '@@/PageHeader/ContextHelp/ContextHelp';
// this value is taken from https://github.com/portainer/portainer/blob/develop/api/portainer.go#L1628 // this value is taken from https://github.com/portainer/portainer/blob/develop/api/portainer.go#L1628
const DEFAULT_URL = const DEFAULT_URL =
@ -11,6 +12,8 @@ const DEFAULT_URL =
export function TemplatesUrlSection() { export function TemplatesUrlSection() {
const [{ name }, { error }] = useField<string>('templatesUrl'); const [{ name }, { error }] = useField<string>('templatesUrl');
const buildTemplateDocUrl = useDocsUrl('/advanced/app-templates/build');
return ( return (
<FormSection title="App Templates"> <FormSection title="App Templates">
<div className="form-group"> <div className="form-group">
@ -18,11 +21,7 @@ export function TemplatesUrlSection() {
<p> <p>
You can specify the URL to your own template definitions file here. You can specify the URL to your own template definitions file here.
See{' '} See{' '}
<a <a href={buildTemplateDocUrl} target="_blank" rel="noreferrer">
href="https://docs.portainer.io/advanced/app-templates/build"
target="_blank"
rel="noreferrer"
>
Portainer documentation Portainer documentation
</a>{' '} </a>{' '}
for more details. for more details.