Skip to content

Commit

Permalink
329 target only the base url (#279)
Browse files Browse the repository at this point in the history
* feat: Add URL match option in ConfigSettingsModal

The code changes add a new form group in the `ConfigSettingsModal` component to allow users to select the URL match option. This is achieved by adding a new property `url_match` to the `Configuration` type and updating the form group in the component. The commit also includes updates to the `URL_MATCH` enum in the `config-model.ts` file.

Recent user commits and repository commits are not relevant for generating the commit message.

* refactor: Remove unused files and configurations for acf-options-page-e2e

* refactor: Remove unused files and configurations for acf-options-page-e2e

* chore: Remove setupFiles from jest.config.ts
  • Loading branch information
dharmesh-hemaram authored May 12, 2024
1 parent 1553740 commit 09ff4c4
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 230 deletions.
10 changes: 0 additions & 10 deletions apps/acf-extension-e2e/.eslintrc.json

This file was deleted.

17 changes: 0 additions & 17 deletions apps/acf-extension-e2e/jest.config.ts

This file was deleted.

18 changes: 0 additions & 18 deletions apps/acf-extension-e2e/project.json

This file was deleted.

12 changes: 0 additions & 12 deletions apps/acf-extension-e2e/src/acf-extension/acf-extension.spec.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/acf-extension-e2e/src/test-setup.ts

This file was deleted.

13 changes: 0 additions & 13 deletions apps/acf-extension-e2e/tsconfig.json

This file was deleted.

9 changes: 0 additions & 9 deletions apps/acf-extension-e2e/tsconfig.spec.json

This file was deleted.

10 changes: 0 additions & 10 deletions apps/acf-options-page-e2e/.eslintrc.json

This file was deleted.

6 changes: 0 additions & 6 deletions apps/acf-options-page-e2e/cypress.config.ts

This file was deleted.

30 changes: 0 additions & 30 deletions apps/acf-options-page-e2e/project.json

This file was deleted.

13 changes: 0 additions & 13 deletions apps/acf-options-page-e2e/src/e2e/app.cy.ts

This file was deleted.

4 changes: 0 additions & 4 deletions apps/acf-options-page-e2e/src/fixtures/example.json

This file was deleted.

1 change: 0 additions & 1 deletion apps/acf-options-page-e2e/src/support/app.po.ts

This file was deleted.

33 changes: 0 additions & 33 deletions apps/acf-options-page-e2e/src/support/commands.ts

This file was deleted.

17 changes: 0 additions & 17 deletions apps/acf-options-page-e2e/src/support/e2e.ts

This file was deleted.

10 changes: 0 additions & 10 deletions apps/acf-options-page-e2e/tsconfig.json

This file was deleted.

50 changes: 27 additions & 23 deletions apps/acf-options-page/src/modal/config-settings.modal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { Card, Col, Form, FormControl, Modal, Row } from 'react-bootstrap';
import { LOAD_TYPES, START_TYPES, defaultHotkey } from '@dhruv-techapps/acf-common';
import { LOAD_TYPES, START_TYPES, URL_MATCH, defaultHotkey } from '@dhruv-techapps/acf-common';
import { Trans, useTranslation } from 'react-i18next';

import { HotkeyPopover } from '../popover';
Expand All @@ -15,7 +15,7 @@ import { REGEX } from '../util';
const ConfigSettingsModal = () => {
const { t } = useTranslation();

const { visible, message, dev } = useAppSelector(configSettingsSelector);
const { visible, message } = useAppSelector(configSettingsSelector);
const config = useAppSelector(selectedConfigSelector);
const dispatch = useAppDispatch();

Expand Down Expand Up @@ -71,7 +71,7 @@ const ConfigSettingsModal = () => {
<Modal.Title as='h6'>{t('modal.configSettings.title')}</Modal.Title>
</Modal.Header>
<Modal.Body>
<Card className='mb-3'>
<Card className='mb-2'>
<Card.Body>
<Row>
<Col md={12} sm={12}>
Expand Down Expand Up @@ -172,26 +172,30 @@ const ConfigSettingsModal = () => {
<Card.Body>
<Row>
<Col md='12' sm='12'>
{dev ? (
<Form.Group controlId='config-start-time'>
<FormControl name='startTime' pattern={REGEX.START_TIME} autoComplete='off' defaultValue={config.startTime} onBlur={onUpdate} placeholder='HH:mm:ss:fff' list='start-time' />
<Form.Label>{t('configuration.startTime')}&nbsp;</Form.Label>
<StartTimePopover />
<Form.Control.Feedback type='invalid'>{t('error.startTime')}</Form.Control.Feedback>
</Form.Group>
) : (
<>
<b className='me-2'>Start Time :</b>
<Trans i18nKey='popover.startTime.content'>
Try
<a href='https://scheduleurl.com/docs/1.0/getting-started/download/' target='_blank' rel='noopener noreferrer'>
Schedule URL
</a>
our new browser extension.
<br /> it&apos;s used to schedule webpage / URL at particular day and time.
</Trans>
</>
)}
<Form.Group controlId='config-start-time'>
<FormControl name='startTime' pattern={REGEX.START_TIME} autoComplete='off' defaultValue={config.startTime} onBlur={onUpdate} placeholder='HH:mm:ss:fff' list='start-time' />
<Form.Label>{t('configuration.startTime')}&nbsp;</Form.Label>
<StartTimePopover />
<Form.Control.Feedback type='invalid'>{t('error.startTime')}</Form.Control.Feedback>
</Form.Group>
</Col>
</Row>
</Card.Body>
</Card>
<Card className='mb-2'>
<Card.Body>
<Row>
<Col md='12' sm='12'>
<Form.Group controlId='config-url-match'>
<Form.Select value={config.url_match} onChange={onUpdate} name='url_match' required>
{Object.entries(URL_MATCH).map((condition) => (
<option key={condition[1]} value={condition[1]}>
{condition[0]}
</option>
))}
</Form.Select>
<Form.Label>URL Match</Form.Label>
</Form.Group>
</Col>
</Row>
</Card.Body>
Expand Down
6 changes: 6 additions & 0 deletions libs/acf/common/src/lib/model/config-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export enum CONFIG_SOURCE {
WEB = 'web',
}

export enum URL_MATCH {
REGEX = 'regex',
EXACT = 'exact',
}

export type Configuration = {
url: string;
enable: boolean;
Expand All @@ -35,6 +40,7 @@ export type Configuration = {
batch?: Batch;
source?: CONFIG_SOURCE;
new?: boolean;
url_match?: URL_MATCH;
};

export const getDefaultConfig = (source?: CONFIG_SOURCE, actions?: Array<Action>): Configuration => ({
Expand Down
4 changes: 2 additions & 2 deletions libs/acf/store/src/lib/config-storage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Configuration, LOCAL_STORAGE_KEY, START_TYPES } from '@dhruv-techapps/acf-common';
import { Configuration, LOCAL_STORAGE_KEY, START_TYPES, URL_MATCH } from '@dhruv-techapps/acf-common';

export type GetConfigResult = {
autoConfig: Configuration | undefined;
Expand All @@ -17,7 +17,7 @@ export class ConfigStorage {
configs
.filter((config) => config.enable && config.url)
.forEach((config) => {
if (this.urlMatcher(config.url, href)) {
if (config.url_match !== URL_MATCH.EXACT && this.urlMatcher(config.url, href)) {
manualConfigs.push(config);
if (!autoConfig && config.startType === START_TYPES.AUTO) {
autoConfig = config;
Expand Down
1 change: 0 additions & 1 deletion libs/core/common/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ export default {
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../coverage/libs/core/common',
setupFiles: ['./jest.setup.js'], // Optional: if you need a setup file
};

0 comments on commit 09ff4c4

Please sign in to comment.