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

Feat(tenant): Update tenant name when delete database or unpublish #1711

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Changes from all 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
11 changes: 4 additions & 7 deletions src/app/js/admin/Appbar/ClearDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ import {
} from '../clear';

import { fromClear, fromPublication } from '../selectors';
import { getHost } from '../../../../common/uris';
import fieldApi from '../api/field';
import { toast } from '../../../../common/tools/toast';
import { loadField } from '../../fields';
import { loadPublication } from '../publication';
import CancelButton from '../../lib/components/CancelButton';
import { loadSubresources } from '../subresource';

const baseUrl = getHost();
import { extractTenantFromUrl } from '../../public/tenantTools';

const TRANSLATION_KEY = new Map([
['dataset', 'clear_dataset'],
Expand All @@ -50,6 +48,8 @@ const ClearDialogComponent = props => {
hasPublishedDataset,
} = props;

const instanceName = extractTenantFromUrl(window.location.href);

useEffect(() => {
if (succeeded) {
if (type === 'dataset') {
Expand All @@ -61,10 +61,7 @@ const ClearDialogComponent = props => {
}
}, [succeeded]);

const getInstanceName = () => /\/\/([a-z0-9-]+)./.exec(baseUrl)[1];

const handleChangeField = e => {
const instanceName = getInstanceName();
setValidName(e.target.value === instanceName);
};

Expand Down Expand Up @@ -147,7 +144,7 @@ const ClearDialogComponent = props => {
<br />
<br />
<div>
{polyglot.t('enter_name')} :<b> {getInstanceName()}</b>
{polyglot.t('enter_name')} :<b> {instanceName}</b>
<TextField
name="field-name-instance"
placeholder={polyglot.t('instance_name')}
Expand Down