Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imprv: Documentation URL for g2gtransfer #9157

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/app/public/static/locales/en_US/commons.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@
"publish_transfer_key": "Publish transfer key",
"transfer_key_limit": "Transfer keys are valid for 1 hour after issuance.",
"once_transfer_key_used": "Once the transfer key is used for transfer, it cannot be used for any other transfer.",
"transfer_to_growi_cloud": "For more details, please click <a href='https://{{documentationUrl}}/ja/admin-guide/management-cookbook/g2g-transfer.html'>here.</a>"
"transfer_to_growi_cloud": "For more details, please click <a href='{{documentationUrl}}/ja/admin-guide/management-cookbook/g2g-transfer.html'>here.</a>"
}
}
2 changes: 1 addition & 1 deletion apps/app/public/static/locales/fr_FR/commons.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@
"publish_transfer_key": "Publier la clé de transfert",
"transfer_key_limit": "Les clés de transfert sont valides durant une heure.",
"once_transfer_key_used": "Les clés de transfert sont à usage unique.",
"transfer_to_growi_cloud": "Pour plus de détails, veuillez cliquer <a href='https://{{documentationUrl}}/ja/admin-guide/management-cookbook/g2g-transfer.html'>ici.</a>"
"transfer_to_growi_cloud": "Pour plus de détails, veuillez cliquer <a href='{{documentationUrl}}/ja/admin-guide/management-cookbook/g2g-transfer.html'>ici.</a>"
}
}
2 changes: 1 addition & 1 deletion apps/app/public/static/locales/ja_JP/commons.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@
"publish_transfer_key": "移行キーを発行する",
"transfer_key_limit": "※ 移行キーの有効期限は発行から1時間となります。",
"once_transfer_key_used": "※ 移行キーは一度移行に利用するとそれ以降はご利用いただけなくなります。",
"transfer_to_growi_cloud": "※ 詳しくは <a href='https://{{documentationUrl}}/ja/admin-guide/management-cookbook/g2g-transfer.html'> GROWI お引越し機能</a>をご確認ください。"
"transfer_to_growi_cloud": "※ 詳しくは <a href='{{documentationUrl}}/ja/admin-guide/management-cookbook/g2g-transfer.html'> GROWI お引越し機能</a>をご確認ください。"
}
}
2 changes: 1 addition & 1 deletion apps/app/src/client/components/Admin/G2GDataTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ const G2GDataTransfer = (): JSX.Element => {
className="mb-0"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: t('commons:g2g_data_transfer.transfer_to_growi_cloud', { documentationUrl: documentationUrl || 'docs.growi.org' }),
__html: t('commons:g2g_data_transfer.transfer_to_growi_cloud', { documentationUrl }),
}}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/app/src/client/components/DataTransferForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const DataTransferForm = (): JSX.Element => {
className="mb-0"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: t('g2g_data_transfer.transfer_to_growi_cloud', { documentationUrl: documentationUrl || 'docs.growi.org' }),
__html: t('g2g_data_transfer.transfer_to_growi_cloud', { documentationUrl }),
}}
/>
</div>
Expand Down
12 changes: 10 additions & 2 deletions apps/app/src/pages/admin/data-transfer.page.tsx
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://redmine.weseek.co.jp/issues/154311 のための修正はこのファイルの差分のみ

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import Head from 'next/head';
import type { Container } from 'unstated';
import { Provider } from 'unstated';

import type { CrowiRequest } from '~/interfaces/crowi-request';
import type { CommonProps } from '~/pages/utils/commons';
import { useCurrentUser } from '~/stores-universal/context';
import { useCurrentUser, useGrowiCloudUri } from '~/stores-universal/context';

import { retrieveServerSideProps } from '../../utils/admin-page-util';

Expand All @@ -25,6 +26,7 @@ type Props = CommonProps;
const DataTransferPage: NextPage<Props> = (props) => {
const { t } = useTranslation('commons');
useCurrentUser(props.currentUser ?? null);
useGrowiCloudUri(props.growiCloudUri);

const title = t('g2g_data_transfer.data_transfer');

Expand Down Expand Up @@ -54,9 +56,15 @@ const DataTransferPage: NextPage<Props> = (props) => {
);
};

const injectServerConfigurations = async(context: GetServerSidePropsContext, props: Props): Promise<void> => {
const req: CrowiRequest = context.req as CrowiRequest;
const { crowi } = req;

props.growiCloudUri = await crowi.configManager.getConfig('crowi', 'app:growiCloudUri');
};

export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
const props = await retrieveServerSideProps(context);
const props = await retrieveServerSideProps(context, injectServerConfigurations);
return props;
};

Expand Down
25 changes: 14 additions & 11 deletions apps/app/src/stores-universal/context.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { useCallback, useEffect } from 'react';

import type EventEmitter from 'events';

import { AcceptedUploadFileType } from '@growi/core';
Expand Down Expand Up @@ -286,17 +284,22 @@ export const useAcceptedUploadFileType = (): SWRResponse<AcceptedUploadFileType,
);
};

export const useGrowiDocumentationUrl = (): SWRResponse<'growi.cloud/help' | 'docs.growi.org', Error> => {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const useGrowiDocumentationUrl = () => {
const { data: growiCloudUri } = useGrowiCloudUri();
const { data: growiAppIdForGrowiCloud } = useGrowiAppIdForGrowiCloud();

return useSWRImmutable(
['documentationUrl', growiCloudUri, growiAppIdForGrowiCloud],
([growiCloudUri, growiAppIdForGrowiCloud]) => {
if (growiCloudUri != null && growiAppIdForGrowiCloud != null) {
return 'growi.cloud/help';
}
return 'docs.growi.org';
return useSWR(
['documentationUrl', growiCloudUri],
([, growiCloudUri]) => {
const url = growiCloudUri != null
? new URL('/help', growiCloudUri)
: new URL('https://docs.growi.org');
return url.toString();
},
{
fallbackData: 'https://docs.growi.org',
revalidateOnFocus: false,
revalidateOnReconnect: false,
},
);
};
Loading