Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4070bdc
Updated the NPM packages to the latest versions.
cameronterry May 7, 2023
9b762cc
Moved Node to 18+.
cameronterry May 7, 2023
a092daf
Simplified node packages / webpack / build process.
cameronterry May 7, 2023
16501fd
Added a new redux store to get the domains.
cameronterry May 7, 2023
8d3269c
Switched the enqueue to use the new dist/ folder and asset dependencies.
cameronterry May 7, 2023
73d098f
Added the new dist/ folder to the ignores.
cameronterry May 7, 2023
bf5684e
Forgot to set up the selectors needed for wp.data.select().
cameronterry May 7, 2023
250e0ac
Replaced the localize script with inline script call.
cameronterry May 7, 2023
79b5f00
Fixed the nesting and ensuring the dist/ folder is clean on each build.
cameronterry May 8, 2023
6392be7
Got the beginnings of a domain grid / admin UI setup.
cameronterry May 8, 2023
c86df6b
Added some variables to be used.
cameronterry May 8, 2023
17395ca
Created CSS for a toggle / checkbox control.
cameronterry May 8, 2023
d3c8f9e
Removed the capitalisation on the folder names.
cameronterry May 8, 2023
f30be61
Added the imports for the CSS.
cameronterry May 8, 2023
d160ff3
Added a visible label and put together the JSX control.
cameronterry May 8, 2023
651869f
Used the spread operator to pass all domain details.
cameronterry May 8, 2023
98f4e07
Added some margins and dividers for the toggle control.
cameronterry May 8, 2023
4fec487
Added support for updating the checked value.
cameronterry May 10, 2023
7a298b8
Fixed the settings page by having a title and encasing the root el in…
cameronterry May 10, 2023
48e2096
Updated the Card control to make use of the new elements and classes.
cameronterry May 10, 2023
454b2d1
Added an info control.
cameronterry May 10, 2023
bba7b3d
Modernised the Domain Mapping JS to use createRoot.
cameronterry May 10, 2023
c5533a2
Fixed a weird CSS import issue.
cameronterry May 10, 2023
c3faa31
Added some breakpoints.
cameronterry May 10, 2023
e82d05b
Made the UI more responsive.
cameronterry May 10, 2023
9a60626
Removed the right padding, as it isn't needed with the wrap element.
cameronterry May 10, 2023
4b47c31
Switched Card from a function to a class inheriting Component.
cameronterry Jun 18, 2023
4e8efe2
Forget the commenting for the new Card class.
cameronterry Jun 18, 2023
d8f2938
Included a new Remove Domain action to the custom Redux.
cameronterry Jun 18, 2023
2e48c9c
Enqueued the wp components CSS rather than cranking out our own buttons.
cameronterry Jun 18, 2023
7257188
Hooked up the remove domain Redux action to the a button on Card.
cameronterry Jun 18, 2023
87bc597
Added the singular endpoint to the dmp.endpoints.
cameronterry Jun 24, 2023
1af4020
Added the removeDomain action.
cameronterry Jun 24, 2023
b79c7b0
Simplified the removeDomain dispatch.
cameronterry Jun 25, 2023
304d35a
Added an update domain action.
cameronterry Jun 25, 2023
6ba6cac
Upgraded Node minimum version to 20 LTS and updated packages.
cameronterry Dec 26, 2023
3a8f73a
Added classNames NPM Package.
cameronterry Dec 27, 2023
8ab5b8e
Switched the list of domains to a table.
cameronterry Dec 27, 2023
e9d3771
Removed the card/grid system and the custom Toggle control.
cameronterry Dec 27, 2023
27e7683
Brought the styling inline with the new Admin UI ... ish ... and adde…
cameronterry Dec 27, 2023
d8d7557
Added a delete domain modal.
cameronterry Dec 27, 2023
7e59b3a
Completed the implementation of the delete domain modal.
cameronterry Dec 27, 2023
f2b5b4d
Added the ability to force delete a domain with removeDomain action.
cameronterry Dec 27, 2023
87c5d96
Renamed the DeleteDomain to include the word modal. Refactored the on…
cameronterry Dec 28, 2023
f06e370
Changed the root object to DomainManagement with table, rather than j…
cameronterry Dec 28, 2023
cb88daa
Moved the Add New Domain into the DomainManagement component.
cameronterry Dec 28, 2023
498cbf9
Added the basics for the New Domain modal.
cameronterry Dec 28, 2023
68a750d
Added the basic form for a new Domain.
cameronterry Dec 28, 2023
4124930
Completed the form and added the buttons.
cameronterry Dec 28, 2023
d011828
Implemented an addDomain() action to the domains redux.
cameronterry Dec 28, 2023
d143f34
Removed debug code.
cameronterry Dec 28, 2023
cc6d6c1
Implemented the basics for the new domain form.
cameronterry Dec 28, 2023
d85c9de
Reworked the addDomain() action to better handle the return and ADD_D…
cameronterry Dec 28, 2023
8415958
Tweaked the CSS to give the form fields more breathing room.
cameronterry Dec 28, 2023
4f0a7a8
Added notices to the Domain Management, and the notice for a new domain.
cameronterry Dec 28, 2023
0092785
Stopped a success notice appearing when the new domain modal is closed.
cameronterry Dec 28, 2023
b6b3143
Ensured that the whole data record of the new domain is added to the …
cameronterry Jan 7, 2024
80e2571
Reverted the previous change and fixed the response for REST create_item
cameronterry Jan 7, 2024
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 .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"@babel/preset-react"
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-class-properties",
"@babel/plugin-transform-runtime"
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.idea/
node_modules

dist/
domain-mapping/build/*
/vendor/

Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.13.1
20
44 changes: 44 additions & 0 deletions assets/css/DomainMapping.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Globals.
*/
@import "global/breakpoints.css";
@import "global/colors.css";

/**
* Controls.
*/
@import "controls/info.css";
@import "controls/modal.css";
@import "controls/table.css";

.dmp__domain-management {
background-color: var(--bright);
margin-top: 1rem;

& .dmp__domain-management-notices {
padding: 1rem 1rem 0;
}

& .dmp__domain-management-toolbar {
display: flex;
flex-flow: wrap;
gap: calc(.5rem);
padding: 1rem;
width: 100%;

& .components-button {
height: 32px;
}
}

& .dmp__domain-table {

& tr {
& td, th {
&:first-child {
padding-left: 1rem;
}
}
}
}
}
5 changes: 5 additions & 0 deletions assets/css/controls/info.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.dmp__control-info {
display: flex;
justify-content: space-between;
margin-top: .5rem;
}
14 changes: 14 additions & 0 deletions assets/css/controls/modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.dmp__domain-modal {

& form {
display: flex;
flex-direction: column;
gap: calc(.5rem);
}

& .dmp__domain-modal-buttons {
display: flex;
gap: calc(.5rem);
justify-content: right;
}
}
38 changes: 38 additions & 0 deletions assets/css/controls/table.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.dmp__domain-table {
background-color: var(--bright);
border-collapse: collapse;
text-align: left;
width: 100%;

& tbody {

& td {
padding: .5rem;

&.dmp__domain-field-domain {
font-weight: bold;
}

& .dmp__domain-table-toggle {

& .components-toggle-control {
margin-bottom: 0;
}
}
}
}

& thead {
& th {
background-color: var(--gray-two);
border-top: 1px solid var(--gray);
color: var(--dark);
font-weight: normal;
padding: .5rem;
}
}

& tr {
border-top: 1px solid var(--gray);
}
}
6 changes: 6 additions & 0 deletions assets/css/global/breakpoints.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Used by WordPress Core in the admin.
*/
@custom-media --bp-small ( max-width: 600px );
@custom-media --bp-medium ( min-width: 600px );
@custom-media --bp-large ( min-width: 1200px );
11 changes: 11 additions & 0 deletions assets/css/global/colors.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:root {
--primary-color: #044D8C;
--secondary-color: #022340;

--bright: #FFFFFF;
--dark: #000000;
--gray: #F0F0F0;
--gray-two: #FAFAFA;
--primary-green: #3DC910;
--primary-red: #C9221A;
}
26 changes: 26 additions & 0 deletions assets/js/DomainMapping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* WordPress dependencies.
*/
import { createRoot, render } from '@wordpress/element';

/**
* Internal Dependencies
*/
import DomainManagement from './components/DomainManagement';

import '../css/DomainMapping.css';

/**
* Data Store
*/
import '../js/data/domains';

if ( document.body.classList.contains( 'settings_page_domains' ) ) {
const rootElement = document.getElementById( 'dmp-root' );

if ( createRoot ) {
createRoot( rootElement ).render( <DomainManagement /> );
} else {
render( <DomainManagement />, rootElement );
}
}
122 changes: 122 additions & 0 deletions assets/js/components/DomainManagement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/**
* WordPress dependencies
*/
import {
Button,
Notice,
SearchControl,
} from '@wordpress/components';
import { Component } from '@wordpress/element';
import { __, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import Table from './domain/Table';
import NewDomainModal from './domain/modals/NewDomain';

class DomainManagement extends Component {
constructor( props ) {
super( props );

this.state = {
modalNewDomainOpen: false,
notices: [],
};
}

render() {
return (
<div className="dmp__domain-management">
{ this.renderNotices() }
{ this.renderToolbar() }
<Table />
{ this.renderModals() }
</div>
);
}

renderModals() {
const { modalNewDomainOpen } = this.state;

return (
<>
{ modalNewDomainOpen && (
<NewDomainModal
onClose={ ( newDomain ) => {
if ( newDomain ) {
this.setState( {
...this.state,
modalNewDomainOpen: false,
notices: [
...this.state.notices,
{
id: newDomain.id,
message: sprintf(
/* translators: %s: domain */
__( 'Domain, %s, successfully added.', 'darkmatterplugin' ),
newDomain.domain
),
status: 'success',
},
],
} );
} else {
this.setState( {
...this.state,
modalNewDomainOpen: false,
} );
}
} }
/>
) }
</>
);
}

renderNotices() {
const { notices } = this.state;

return (
<div className="dmp__domain-management-notices">
{ notices.length > 0 && notices.map( ( { id, message, status } ) => {
return <Notice
key={ id }
onDismiss={ () => {
const removeIndex = notices.findIndex( ( item ) => {
return id === item.id;
} );

notices.splice( removeIndex, 1 );
this.setState( { ...this.state, notices: [ ...notices ] } );
} }
status={ status }
>
{ message }
</Notice>;
} ) }
</div>
);
}

renderToolbar() {
return (
<div className="dmp__domain-management-toolbar">
<SearchControl
label={ __( 'Filter domains', 'darkmatterplugin' ) }
size="compact"
/>
<Button
onClick={ () => {
this.setState( { modalNewDomainOpen: true } );
} }
variant="secondary"
>
{ __( 'Add New Domain', 'darkmatterplugin' ) }
</Button>
</div>
);
}
}

export default DomainManagement;
Loading