Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 2 additions & 13 deletions assets/src/admin/search/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* WordPress dependencies
*/
import { Button, Modal, Snackbar } from '@wordpress/components';
import {
createRoot,
Expand All @@ -11,20 +8,12 @@ import {
} from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import apiFetch from '@wordpress/api-fetch';

/**
* External dependencies
*/
import type { NoticeType } from '@/admin/settings/page';
import SiteIndexableEntities from '@/components/SiteIndexableEntities';
import SiteSearchSettings, {
type PostTypeOption,
} from '@/components/SiteSearchSettings';
import {
CURRENT_SITE_URL,
REST_NAMESPACE,
withTrailingSlash,
} from '@/js/utils';
import { CURRENT_SITE_URL, withTrailingSlash } from '@/js/utils';
import type { SiteType } from '@/types/global';

interface AllPostTypesMap {
Expand Down Expand Up @@ -147,7 +136,7 @@ const OneSearchSettingsPage = () => {
const fetchAllPostTypes = async () => {
try {
const data = await apiFetch< FetchAllPostTypesResponse >( {
path: `/${ REST_NAMESPACE }/all-post-types`,
path: '/onesearch/v1/all-post-types',
} );
const mapped = toEntitiesMap( data );
setAllPostTypes( mapped );
Expand Down
7 changes: 0 additions & 7 deletions assets/src/admin/settings/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/**
* External dependencies
*/
import { createRoot } from 'react-dom/client';

/**
* Internal dependencies
*/
import SettingsPage from './page';

// Render to Gutenberg admin page with ID: onesearch-settings-page
Expand Down
15 changes: 2 additions & 13 deletions assets/src/admin/settings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
/**
* WordPress dependencies
*/
/**
* External dependencies
*/
import { useState, useRef, useCallback } from 'react';
import { useState, useRef, useCallback } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Notice, Snackbar } from '@wordpress/components';

Check warning on line 3 in assets/src/admin/settings/page.tsx

View workflow job for this annotation

GitHub Actions / CSS/JS Lint / JS Lint & TypeScript

Use `Notice` from `@wordpress/ui` instead
import apiFetch from '@wordpress/api-fetch';

/**
* Internal dependencies
*/
import SiteTable from '@/components/SiteTable';
import SiteModal from '@/components/SiteModal';
import SiteSettings from '@/components/SiteSettings';
import AlgoliaSettings from '@/components/AlgoliaSettings';
import SiteTypeSettings from '@/components/SiteTypeSettings';
import DeactivationSettings from '@/components/deactivation-settings';
import { REST_NAMESPACE } from '@/js/utils';

export interface NoticeType {
// Set by the settings page, so each notice gets its own Snackbar.
Expand All @@ -44,7 +33,7 @@
export type EditingIndex = number | null;

const SITE_TYPE = window.OneSearchSettings.siteType || null;
const SHARED_SITES_ENDPOINT = `/${ REST_NAMESPACE }/shared-sites`;
const SHARED_SITES_ENDPOINT = '/onesearch/v1/shared-sites';

interface DeleteSiteResponse {
governing_site_notified?: boolean;
Expand Down
15 changes: 2 additions & 13 deletions assets/src/components/AlgoliaSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
/**
* WordPress dependencies
*/
/**
* External dependencies
*/
import { useState } from 'react';
import { useState } from '@wordpress/element';
import {
Button,
CardBody,

Check warning on line 4 in assets/src/components/AlgoliaSettings.tsx

View workflow job for this annotation

GitHub Actions / CSS/JS Lint / JS Lint & TypeScript

Use `Card.Content` from `@wordpress/ui` instead
Card,

Check warning on line 5 in assets/src/components/AlgoliaSettings.tsx

View workflow job for this annotation

GitHub Actions / CSS/JS Lint / JS Lint & TypeScript

Use `Card.Root` from `@wordpress/ui` instead
CardHeader,

Check warning on line 6 in assets/src/components/AlgoliaSettings.tsx

View workflow job for this annotation

GitHub Actions / CSS/JS Lint / JS Lint & TypeScript

Use `Card.Header` (and optionally `Card.Title`) from `@wordpress/ui` instead
TextControl,

Check warning on line 7 in assets/src/components/AlgoliaSettings.tsx

View workflow job for this annotation

GitHub Actions / CSS/JS Lint / JS Lint & TypeScript

Use `InputControl` from `@wordpress/ui` instead. See the migration guide: https://wordpress.github.io/gutenberg/?path=/docs/components-inputcontrol--migration-guide
__experimentalGrid as Grid,

Check warning on line 8 in assets/src/components/AlgoliaSettings.tsx

View workflow job for this annotation

GitHub Actions / CSS/JS Lint / JS Lint & TypeScript

__experimentalGrid is planned for deprecation. Write your own CSS instead
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import apiFetch from '@wordpress/api-fetch';

/**
* Internal dependencies
*/
import type { NoticeType } from '@/admin/settings/page';
import { REST_NAMESPACE } from '@/js/utils';

interface AlgoliaCredentials {
app_id: string;
write_key: string;
}

const CREDENTIALS_ENDPOINT = `/${ REST_NAMESPACE }/algolia-credentials`;
const CREDENTIALS_ENDPOINT = '/onesearch/v1/algolia-credentials';

const AlgoliaSettings = ( {
setNotice,
Expand Down
7 changes: 0 additions & 7 deletions assets/src/components/IndexSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
/**
* WordPress dependencies
*/
import { Button } from '@wordpress/components';
import { useState } from '@wordpress/element';
import { __, _n, sprintf } from '@wordpress/i18n';

/**
* External dependencies
*/
import type { IndexSummaryData } from '@/js/use-index-status';

// How many failed posts to show before the rest are asked for.
Expand Down
7 changes: 0 additions & 7 deletions assets/src/components/JobStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/**
* WordPress dependencies
*/
import { __, _n, sprintf } from '@wordpress/i18n';

/**
* External dependencies
*/
import type { JobStatusData } from '@/js/use-index-status';

// What each job is, and what its failure means for search and what to do.
Expand Down
9 changes: 1 addition & 8 deletions assets/src/components/MultiSelectChips.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
/**
* WordPress dependencies
*/
import { Popover, Icon } from '@wordpress/components';
import { chevronDown, closeSmall } from '@wordpress/icons';
import { __, sprintf } from '@wordpress/i18n';

/**
* External dependencies
*/
import { useState, useRef, useEffect } from 'react';
import { useState, useRef, useEffect } from '@wordpress/element';

interface MultiSelectChipsProps {
label?: string;
Expand Down
13 changes: 1 addition & 12 deletions assets/src/components/SiteIndexableEntities.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
/**
* WordPress dependencies
*/
import {
Card,

Check warning on line 2 in assets/src/components/SiteIndexableEntities.tsx

View workflow job for this annotation

GitHub Actions / CSS/JS Lint / JS Lint & TypeScript

Use `Card.Root` from `@wordpress/ui` instead
CardHeader,

Check warning on line 3 in assets/src/components/SiteIndexableEntities.tsx

View workflow job for this annotation

GitHub Actions / CSS/JS Lint / JS Lint & TypeScript

Use `Card.Header` (and optionally `Card.Title`) from `@wordpress/ui` instead
CardBody,

Check warning on line 4 in assets/src/components/SiteIndexableEntities.tsx

View workflow job for this annotation

GitHub Actions / CSS/JS Lint / JS Lint & TypeScript

Use `Card.Content` from `@wordpress/ui` instead
Button,
__experimentalText as Text,

Check warning on line 6 in assets/src/components/SiteIndexableEntities.tsx

View workflow job for this annotation

GitHub Actions / CSS/JS Lint / JS Lint & TypeScript

Use `Text` from `@wordpress/ui` instead
Modal,
Notice,
} from '@wordpress/components';

/**
* External dependencies
*/
import { useState, useEffect } from 'react';
import { useState, useEffect } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';
import apiFetch from '@wordpress/api-fetch';

/**
* Internal dependencies
*/
import MultiSelectChips from './MultiSelectChips';
import IndexSummary from './IndexSummary';
import JobStatus from './JobStatus';
Expand Down
15 changes: 3 additions & 12 deletions assets/src/components/SiteModal.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/**
* WordPress dependencies
*/
/**
* External dependencies
*/
import {
Button,
Modal,
Expand All @@ -12,13 +6,10 @@ import {
TextareaControl,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useMemo, useState } from 'react';

/**
* Internal dependencies
*/
import { useMemo, useState } from '@wordpress/element';
import type { defaultBrandSite } from '@/admin/settings/page';
import { isValidUrl, withTrailingSlash } from '../js/utils';
import { isValidUrl, withTrailingSlash } from '@/js/utils';

interface ErrorsType {
name: string;
url: string;
Expand Down
15 changes: 2 additions & 13 deletions assets/src/components/SiteSearchSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* WordPress dependencies
*/
import apiFetch from '@wordpress/api-fetch';
import {
Button,
Expand All @@ -12,17 +9,9 @@ import {
ToggleControl,
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';

/**
* External dependencies
*/
import { useCallback, useEffect, useRef, useState } from 'react';

/**
* Internal dependencies
*/
import { useCallback, useEffect, useRef, useState } from '@wordpress/element';
import type { NoticeType } from '@/admin/settings/page';
import { withTrailingSlash } from '../js/utils';
import { withTrailingSlash } from '@/js/utils';

export interface PostTypeOption {
slug: string;
Expand Down
18 changes: 4 additions & 14 deletions assets/src/components/SiteSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
/**
* WordPress dependencies
*/
/**
* External dependencies
*/
import { useEffect, useState, useCallback } from 'react';
import { useEffect, useState, useCallback } from '@wordpress/element';
import {
TextareaControl,
Button,
Expand All @@ -18,12 +12,8 @@ import {
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import apiFetch from '@wordpress/api-fetch';

/**
* Internal dependencies
*/
import type { NoticeType } from '@/admin/settings/page';
import { API_KEY, REST_NAMESPACE } from '@/js/utils';
import { API_KEY } from '@/js/utils';

const SiteSettings = () => {
const [ apiKey, setApiKey ] = useState( API_KEY );
Expand All @@ -36,7 +26,7 @@ const SiteSettings = () => {
const regenerateApiKey = useCallback( async () => {
try {
const data = await apiFetch< { secret_key?: string } >( {
path: `/${ REST_NAMESPACE }/secret-key`,
path: '/onesearch/v1/secret-key',
method: 'POST',
} );
if ( data?.secret_key ) {
Expand Down Expand Up @@ -95,7 +85,7 @@ const SiteSettings = () => {
governing_site_notified: boolean;
message: string;
} >( {
path: `/${ REST_NAMESPACE }/governing-site`,
path: '/onesearch/v1/governing-site',
method: 'DELETE',
} );
setGoverningSite( '' );
Expand Down
8 changes: 1 addition & 7 deletions assets/src/components/SiteTable.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
/**
* WordPress dependencies
*/
/**
* External dependencies
*/
import { useState } from 'react';
import { useState } from '@wordpress/element';
import {
Button,
Card,
Expand Down
13 changes: 1 addition & 12 deletions assets/src/components/SiteTypeSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/**
* External dependencies
*/
import { useState } from 'react';

/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';
import apiFetch from '@wordpress/api-fetch';
import { __ } from '@wordpress/i18n';
import {
Expand All @@ -16,10 +9,6 @@ import {
Button,
SelectControl,
} from '@wordpress/components';

/**
* Internal dependencies
*/
import type { SiteType } from '@/types/global';

const BRAND_SITE = 'brand-site' as const;
Expand Down
13 changes: 1 addition & 12 deletions assets/src/components/deactivation-settings.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
/**
* External dependencies
*/
import { useState } from 'react';

/**
* WordPress dependencies
*/
import apiFetch from '@wordpress/api-fetch';
import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import {
Card,
CardBody,
CardHeader,
ToggleControl,
} from '@wordpress/components';

/**
* Internal dependencies
*/
import type { NoticeType } from '@/admin/settings/page';
import type { SiteType } from '@/types/global';

Expand Down
10 changes: 1 addition & 9 deletions assets/src/js/use-index-status.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
/**
* WordPress dependencies
*/
import { useCallback, useEffect, useState } from '@wordpress/element';
import apiFetch from '@wordpress/api-fetch';

/**
* Internal dependencies
*/
import { REST_NAMESPACE } from './utils';

export type JobState = 'queued' | 'running' | 'completed' | 'failed';

/**
Expand Down Expand Up @@ -49,7 +41,7 @@ interface StatusResponse {
jobs: JobStatusData[];
}

const INDEXER_PATH = `/${ REST_NAMESPACE }/indexer`;
const INDEXER_PATH = '/onesearch/v1/indexer';

// How often to check on the jobs while any of them is going, in milliseconds.
export const POLL_INTERVAL = 10000;
Expand Down
8 changes: 0 additions & 8 deletions assets/src/js/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ export const withTrailingSlash = ( url: string ): string => {
*/
export const API_KEY = window.OneSearchSettings.api_key;

/**
* REST namespace used by the OneSearch plugin.
*
* @constant
* @type {string}
*/
export const REST_NAMESPACE = window.OneSearchSettings.restNamespace;

/**
* Current site’s base URL.
*
Expand Down
1 change: 0 additions & 1 deletion assets/src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export interface OneSearchSettings {
setupUrl: string;
siteType: SiteType | null;
sharedSites?: OneSearchSharedSite[];
restNamespace: string;
currentSiteUrl: string;
algoliaAppId?: string;
hasAlgoliaCredentials?: '1' | '';
Expand Down
3 changes: 0 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* WordPress dependencies
*/
const defaultConfig = require( '@wordpress/babel-preset-default' );

module.exports = function ( api ) {
Expand Down
Loading
Loading