Skip to content

Commit

Permalink
v2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Salman0341 committed Aug 26, 2021
1 parent 42dae4d commit 058d78a
Show file tree
Hide file tree
Showing 35 changed files with 513 additions and 110 deletions.
13 changes: 7 additions & 6 deletions extendify-sdk/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
'require-await': 'error',
quotes: ['error', 'single'],
'comma-dangle': ['error', 'always-multiline'],
'multiline-ternary': ['error', 'always'],
'multiline-ternary': ['error', 'always-multiline'],
'array-element-newline': ['error', 'consistent'],
'no-constant-condition': ['error', {
checkLoops: false,
Expand Down Expand Up @@ -50,7 +50,9 @@ module.exports = {
},
],
'quote-props': ['error', 'as-needed'],
'object-curly-spacing': ['error', 'always'],
'object-curly-spacing': ['error', 'always', {
objectsInObjects: false,
}],
'no-multiple-empty-lines': [
'error',
{
Expand All @@ -69,14 +71,13 @@ module.exports = {
'error',
{
ObjectExpression: {
minProperties: 1,
consistent: true, multiline: true, minProperties: 3,
},
ObjectPattern: {
multiline: true,
consistent: true, multiline: true,
},
ImportDeclaration: {
multiline: true,
minProperties: 3,
multiline: true, minProperties: 3,
},
ExportDeclaration: {
multiline: true,
Expand Down
30 changes: 30 additions & 0 deletions extendify-sdk/app/Controllers/MetaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Controls Http requests
*/

namespace Extendify\ExtendifySdk\Controllers;

use Extendify\ExtendifySdk\Http;

if (!defined('ABSPATH')) {
die('No direct access.');
}

/**
* The controller for sending little bits of info
*/
class MetaController
{
/**
* Send data about a specific topic
*
* @param \WP_REST_Request $request - The request.
* @return WP_REST_Response|WP_Error
*/
public static function getAll($request)
{
$response = Http::get('/meta-data', $request->get_params());
return new \WP_REST_Response($response);
}
}
12 changes: 12 additions & 0 deletions extendify-sdk/app/Controllers/TemplateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ public static function index($request)
return new \WP_REST_Response($response);
}

/**
* Get related templates
*
* @param \WP_REST_Request $request - The request.
* @return WP_REST_Response|WP_Error
*/
public static function related($request)
{
$response = Http::post('/templates/related', $request->get_params());
return new \WP_REST_Response($response);
}

/**
* Send data about a specific template
*
Expand Down
13 changes: 13 additions & 0 deletions extendify-sdk/app/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Extendify\ExtendifySdk\Controllers;

use Extendify\ExtendifySdk\Http;
use Extendify\ExtendifySdk\User;

if (!defined('ABSPATH')) {
Expand Down Expand Up @@ -52,4 +53,16 @@ public static function store($request)

return new \WP_REST_Response(User::state());
}

/**
* Sign up the user to the mailing list.
*
* @param \WP_REST_Request $request - The request.
* @return WP_REST_Response|WP_Error
*/
public static function mailingList($request)
{
$response = Http::post('/register-mailing-list', $request->get_params());
return new \WP_REST_Response($response);
}
}
6 changes: 5 additions & 1 deletion extendify-sdk/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
require EXTENDIFYSDK_PATH . 'routes/api.php';
require EXTENDIFYSDK_PATH . 'editorplus/EditorPlus.php';


\add_action(
'init',
function () {
// Hard-coded to run only within Editor Plus for now.
if (isset($GLOBALS['extendifySdkSourcePlugin']) && in_array($GLOBALS['extendifySdkSourcePlugin'], ['Editor Plus'], true)) {
require EXTENDIFYSDK_PATH . 'support/notices.php';
}

\load_plugin_textdomain('extendify-sdk', false, EXTENDIFYSDK_PATH . 'languages');
}
);
2 changes: 1 addition & 1 deletion extendify-sdk/public/build/extendify-sdk.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extendify-sdk/public/build/extendify-sdk.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion extendify-sdk/readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=== Extendify Sdk ===
Requires at least: 5.4
Stable tag: 6.1
Stable tag: 6.5
Requires PHP: 5.6
Tested up to: 5.7.0
4 changes: 4 additions & 0 deletions extendify-sdk/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Extendify\ExtendifySdk\ApiRouter;
use Extendify\ExtendifySdk\Controllers\AuthController;
use Extendify\ExtendifySdk\Controllers\MetaController;
use Extendify\ExtendifySdk\Controllers\PingController;
use Extendify\ExtendifySdk\Controllers\UserController;
use Extendify\ExtendifySdk\Controllers\PluginController;
Expand All @@ -26,14 +27,17 @@ function () {

ApiRouter::post('/templates', [TemplateController::class, 'index']);
ApiRouter::post('/templates/(?P<template_id>[a-zA-Z0-9-]+)', [TemplateController::class, 'ping']);
ApiRouter::post('/related', [TemplateController::class, 'related']);

ApiRouter::get('/user', [UserController::class, 'show']);
ApiRouter::post('/user', [UserController::class, 'store']);
ApiRouter::get('/user-meta', [UserController::class, 'meta']);
ApiRouter::post('/register-mailing-list', [UserController::class, 'mailingList']);

ApiRouter::post('/register', [AuthController::class, 'register']);
ApiRouter::post('/login', [AuthController::class, 'login']);

ApiRouter::get('/meta-data', [MetaController::class, 'getAll']);
ApiRouter::post('/simple-ping', [PingController::class, 'ping']);
}
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Axios as api } from './axios'

export const SimplePing = {
action(action) {
export const General = {
metaData() {
return api.get('meta-data')
},
ping(action) {
return api.post('simple-ping', {
action,
})
Expand Down
15 changes: 15 additions & 0 deletions extendify-sdk/src/api/Templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ export const Templates = {
})
return templates
},
related(
template, queryType, wantedType,
) {
return api.post('related', {
pageSize: 4,
query_type: queryType,
wanted_type: wantedType,
categories: template?.fields?.tax_categories,
pattern_types: template?.fields?.tax_pattern_types,
style: template?.fields?.tax_style,
type: template?.fields?.type,
template_id: template?.id,
})
},

// TODO: Refactor this later to combine the following three
maybeImport(template) {
return api.post(`templates/${template.id}`, {
Expand Down
11 changes: 11 additions & 0 deletions extendify-sdk/src/api/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,15 @@ export const User = {
},
)
},
registerMailingList(email) {
const formData = new FormData()
formData.append('email', email)
return api.post(
'register-mailing-list', formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
},
)
},
}
21 changes: 20 additions & 1 deletion extendify-sdk/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
.extendify-sdk .button-focus {
@apply focus:ring-2 focus:ring-wp-theme-500 ring-offset-1 outline-none;
}
.extendify-sdk select.button-focus,
.extendify-sdk input.button-focus {
@apply focus:border-transparent focus:outline-none;
}

.button-extendify-main {
@apply bg-extendify-main cursor-pointer transition duration-200 p-1.5 px-3 text-white hover:text-white no-underline hover:bg-gray-900 button-focus active:bg-gray-900 active:text-white focus:text-white;
@apply bg-extendify-main button-focus cursor-pointer transition duration-200 p-1.5 px-3 text-white hover:text-white no-underline hover:bg-gray-900 active:bg-gray-900 active:text-white focus:text-white whitespace-nowrap;
}
#extendify-search-input:focus ~ svg,
#extendify-search-input:not(:placeholder-shown) ~ svg {
Expand All @@ -28,3 +32,18 @@
border-bottom: 1px solid #e0e0e0 !important;
@apply bg-transparent;
}
.extendify-sdk .components-modal__header {
@apply border-b border-gray-300;
}

/* Special input animation */
.extendify-special-input:placeholder-shown ~ label {
@apply top-1.5;
@apply text-sm;
@apply text-gray-600;
}
.extendify-special-input:focus ~ label {
@apply -top-3;
@apply text-xs;
@apply text-wp-theme-500;
}
8 changes: 6 additions & 2 deletions extendify-sdk/src/components/ImportButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import { useUserStore } from '../state/User'
import { useGlobalStore } from '../state/GlobalState'
import { __, sprintf } from '@wordpress/i18n'
import { Templates as TemplatesApi } from '../api/Templates'
import { render } from '@wordpress/element'
import ExtendifyLibrary from '../layout/ExtendifyLibrary'

const canImportMiddleware = Middleware(['hasRequiredPlugins', 'hasPluginsActivated'])
const canImportMiddleware = Middleware(['NeedsRegistrationModal', 'hasRequiredPlugins', 'hasPluginsActivated'])
export function ImportButton({ template }) {
const importButtonRef = useRef(null)
const activeTemplateBlocks = useTemplatesStore(state => state.activeTemplateBlocks)
Expand All @@ -24,7 +26,9 @@ export function ImportButton({ template }) {
AuthorizationCheck(canImportMiddleware.stack).then(() => {
// Give it a bit of time for the importing state to render
setTimeout(() => {
injectTemplateBlocks(activeTemplateBlocks, template).then(() => setOpen(false))
injectTemplateBlocks(activeTemplateBlocks, template)
.then(() => setOpen(false))
.then(() => render(<ExtendifyLibrary/>, document.getElementById('extendify-root')))
}, 100)
})
}
Expand Down
51 changes: 0 additions & 51 deletions extendify-sdk/src/components/TemplatesSingle.js

This file was deleted.

11 changes: 11 additions & 0 deletions extendify-sdk/src/hooks/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useRef, useEffect } from '@wordpress/element'

export function useIsMounted() {
const isMounted = useRef(false)

useEffect(() => {
isMounted.current = true
return () => isMounted.current = false
})
return isMounted
}
3 changes: 0 additions & 3 deletions extendify-sdk/src/hooks/useBeacon.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { useEffect } from '@wordpress/element'

export default function useBeacon(show) {
console.log({
show,
})
const showBeacon = () => {
const container = document.getElementById('beacon-container')
if (container) {
Expand Down
9 changes: 9 additions & 0 deletions extendify-sdk/src/layout/MainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import Welcome from '../pages/Welcome'
import useBeacon from '../hooks/useBeacon'
import { useGlobalStore } from '../state/GlobalState'
import { useUserStore } from '../state/User'
import { General as GeneralApi } from '../api/General'

export default function MainWindow() {
const containerRef = useRef(null)
const open = useGlobalStore(state => state.open)
const metaData = useGlobalStore(state => state.metaData)
const setOpen = useGlobalStore(state => state.setOpen)
const currentPage = useGlobalStore(state => state.currentPage)
const hasClickedThroughWelcomePage = useUserStore(state => state.hasClickedThroughWelcomePage)
Expand All @@ -24,6 +26,13 @@ export default function MainWindow() {
})
}, [hasClickedThroughWelcomePage])

useEffect(() => {
if (!open || Object.keys(metaData).length) {
return
}
GeneralApi.metaData().then((data) => useGlobalStore.setState({ metaData: data }))
}, [open, metaData])

return (
<Transition.Root show={open} as={Fragment}>
<Dialog
Expand Down
Loading

0 comments on commit 058d78a

Please sign in to comment.