mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-08-01 16:41:53 +00:00
Updated styles in javascript to fulfill adidas rules
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
import ShlinkApiClient from '../../api/ShlinkApiClient';
|
||||
import { curry } from 'ramda';
|
||||
import PropTypes from 'prop-types';
|
||||
import shlinkApiClient from '../../api/ShlinkApiClient';
|
||||
|
||||
const CREATE_SHORT_URL_START = 'shlink/createShortUrl/CREATE_SHORT_URL_START';
|
||||
const CREATE_SHORT_URL_ERROR = 'shlink/createShortUrl/CREATE_SHORT_URL_ERROR';
|
||||
const CREATE_SHORT_URL = 'shlink/createShortUrl/CREATE_SHORT_URL';
|
||||
const RESET_CREATE_SHORT_URL = 'shlink/createShortUrl/RESET_CREATE_SHORT_URL';
|
||||
|
||||
export const createShortUrlResultType = {
|
||||
result: PropTypes.shape({
|
||||
shortUrl: PropTypes.string,
|
||||
}),
|
||||
saving: PropTypes.bool,
|
||||
error: PropTypes.bool,
|
||||
};
|
||||
|
||||
const defaultState = {
|
||||
result: null,
|
||||
saving: false,
|
||||
@@ -38,16 +47,18 @@ export default function reducer(state = defaultState, action) {
|
||||
}
|
||||
}
|
||||
|
||||
export const _createShortUrl = (ShlinkApiClient, data) => async dispatch => {
|
||||
export const _createShortUrl = (shlinkApiClient, data) => async (dispatch) => {
|
||||
dispatch({ type: CREATE_SHORT_URL_START });
|
||||
|
||||
try {
|
||||
const result = await ShlinkApiClient.createShortUrl(data);
|
||||
const result = await shlinkApiClient.createShortUrl(data);
|
||||
|
||||
dispatch({ type: CREATE_SHORT_URL, result });
|
||||
} catch (e) {
|
||||
dispatch({ type: CREATE_SHORT_URL_ERROR });
|
||||
}
|
||||
};
|
||||
export const createShortUrl = curry(_createShortUrl)(ShlinkApiClient);
|
||||
|
||||
export const createShortUrl = curry(_createShortUrl)(shlinkApiClient);
|
||||
|
||||
export const resetCreateShortUrl = () => ({ type: RESET_CREATE_SHORT_URL });
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import ShlinkApiClient from '../../api/ShlinkApiClient';
|
||||
import { curry } from 'ramda';
|
||||
import PropTypes from 'prop-types';
|
||||
import shlinkApiClient from '../../api/ShlinkApiClient';
|
||||
|
||||
export const EDIT_SHORT_URL_TAGS_START = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS_START';
|
||||
|
||||
export const EDIT_SHORT_URL_TAGS_ERROR = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS_ERROR';
|
||||
|
||||
export const EDIT_SHORT_URL_TAGS = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS';
|
||||
|
||||
export const RESET_EDIT_SHORT_URL_TAGS = 'shlink/shortUrlTags/RESET_EDIT_SHORT_URL_TAGS';
|
||||
|
||||
export const SHORT_URL_TAGS_EDITED = 'shlink/shortUrlTags/SHORT_URL_TAGS_EDITED';
|
||||
|
||||
export const shortUrlTagsType = PropTypes.shape({
|
||||
@@ -50,19 +54,21 @@ export default function reducer(state = defaultState, action) {
|
||||
}
|
||||
}
|
||||
|
||||
export const _editShortUrlTags = (ShlinkApiClient, shortCode, tags) => async (dispatch, getState) => {
|
||||
export const _editShortUrlTags = (shlinkApiClient, shortCode, tags) => async (dispatch) => {
|
||||
dispatch({ type: EDIT_SHORT_URL_TAGS_START });
|
||||
|
||||
try {
|
||||
// Update short URL tags
|
||||
await ShlinkApiClient.updateShortUrlTags(shortCode, tags);
|
||||
await shlinkApiClient.updateShortUrlTags(shortCode, tags);
|
||||
dispatch({ tags, shortCode, type: EDIT_SHORT_URL_TAGS });
|
||||
} catch (e) {
|
||||
dispatch({ type: EDIT_SHORT_URL_TAGS_ERROR });
|
||||
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
export const editShortUrlTags = curry(_editShortUrlTags)(ShlinkApiClient);
|
||||
|
||||
export const editShortUrlTags = curry(_editShortUrlTags)(shlinkApiClient);
|
||||
|
||||
export const resetShortUrlsTags = () => ({ type: RESET_EDIT_SHORT_URL_TAGS });
|
||||
|
||||
|
||||
@@ -1,50 +1,60 @@
|
||||
import ShlinkApiClient from '../../api/ShlinkApiClient';
|
||||
import { curry } from 'ramda';
|
||||
import PropTypes from 'prop-types';
|
||||
import shlinkApiClient from '../../api/ShlinkApiClient';
|
||||
import { shortUrlType } from './shortUrlsList';
|
||||
|
||||
const GET_SHORT_URL_VISITS_START = 'shlink/shortUrlVisits/GET_SHORT_URL_VISITS_START';
|
||||
const GET_SHORT_URL_VISITS_ERROR = 'shlink/shortUrlVisits/GET_SHORT_URL_VISITS_ERROR';
|
||||
const GET_SHORT_URL_VISITS = 'shlink/shortUrlVisits/GET_SHORT_URL_VISITS';
|
||||
|
||||
export const shortUrlVisitsType = {
|
||||
shortUrl: shortUrlType,
|
||||
visits: PropTypes.array,
|
||||
loading: PropTypes.bool,
|
||||
error: PropTypes.bool,
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
shortUrl: {},
|
||||
visits: [],
|
||||
loading: false,
|
||||
error: false
|
||||
error: false,
|
||||
};
|
||||
|
||||
export default function dispatch (state = initialState, action) {
|
||||
export default function dispatch(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case GET_SHORT_URL_VISITS_START:
|
||||
return {
|
||||
...state,
|
||||
loading: true
|
||||
loading: true,
|
||||
};
|
||||
case GET_SHORT_URL_VISITS_ERROR:
|
||||
return {
|
||||
...state,
|
||||
loading: false,
|
||||
error: true
|
||||
error: true,
|
||||
};
|
||||
case GET_SHORT_URL_VISITS:
|
||||
return {
|
||||
shortUrl: action.shortUrl,
|
||||
visits: action.visits,
|
||||
loading: false,
|
||||
error: false
|
||||
error: false,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export const _getShortUrlVisits = (ShlinkApiClient, shortCode, dates) => dispatch => {
|
||||
export const _getShortUrlVisits = (shlinkApiClient, shortCode, dates) => (dispatch) => {
|
||||
dispatch({ type: GET_SHORT_URL_VISITS_START });
|
||||
|
||||
Promise.all([
|
||||
ShlinkApiClient.getShortUrlVisits(shortCode, dates),
|
||||
ShlinkApiClient.getShortUrl(shortCode)
|
||||
shlinkApiClient.getShortUrlVisits(shortCode, dates),
|
||||
shlinkApiClient.getShortUrl(shortCode),
|
||||
])
|
||||
.then(([visits, shortUrl]) => dispatch({ visits, shortUrl, type: GET_SHORT_URL_VISITS }))
|
||||
.then(([ visits, shortUrl ]) => dispatch({ visits, shortUrl, type: GET_SHORT_URL_VISITS }))
|
||||
.catch(() => dispatch({ type: GET_SHORT_URL_VISITS_ERROR }));
|
||||
};
|
||||
export const getShortUrlVisits = curry(_getShortUrlVisits)(ShlinkApiClient);
|
||||
|
||||
export const getShortUrlVisits = curry(_getShortUrlVisits)(shlinkApiClient);
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
import ShlinkApiClient from '../../api/ShlinkApiClient';
|
||||
import { SHORT_URL_TAGS_EDITED } from './shortUrlTags';
|
||||
import { assoc, assocPath } from 'ramda';
|
||||
import PropTypes from 'prop-types';
|
||||
import shlinkApiClient from '../../api/ShlinkApiClient';
|
||||
import { SHORT_URL_TAGS_EDITED } from './shortUrlTags';
|
||||
|
||||
const LIST_SHORT_URLS_START = 'shlink/shortUrlsList/LIST_SHORT_URLS_START';
|
||||
const LIST_SHORT_URLS_ERROR = 'shlink/shortUrlsList/LIST_SHORT_URLS_ERROR';
|
||||
|
||||
export const LIST_SHORT_URLS = 'shlink/shortUrlsList/LIST_SHORT_URLS';
|
||||
|
||||
export const shortUrlType = PropTypes.shape({
|
||||
tags: PropTypes.arrayOf(PropTypes.string),
|
||||
shortCode: PropTypes.string,
|
||||
originalUrl: PropTypes.string,
|
||||
});
|
||||
|
||||
const initialState = {
|
||||
shortUrls: {},
|
||||
loading: true,
|
||||
@@ -19,34 +27,36 @@ export default function reducer(state = initialState, action) {
|
||||
return {
|
||||
loading: false,
|
||||
error: false,
|
||||
shortUrls: action.shortUrls
|
||||
shortUrls: action.shortUrls,
|
||||
};
|
||||
case LIST_SHORT_URLS_ERROR:
|
||||
return {
|
||||
loading: false,
|
||||
error: true,
|
||||
shortUrls: []
|
||||
shortUrls: [],
|
||||
};
|
||||
case SHORT_URL_TAGS_EDITED:
|
||||
const { data } = state.shortUrls;
|
||||
return assocPath(['shortUrls', 'data'], data.map(shortUrl =>
|
||||
|
||||
return assocPath([ 'shortUrls', 'data' ], data.map((shortUrl) =>
|
||||
shortUrl.shortCode === action.shortCode
|
||||
? assoc('tags', action.tags, shortUrl)
|
||||
: shortUrl
|
||||
), state);
|
||||
: shortUrl), state);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export const _listShortUrls = (ShlinkApiClient, params = {}) => async dispatch => {
|
||||
export const _listShortUrls = (shlinkApiClient, params = {}) => async (dispatch) => {
|
||||
dispatch({ type: LIST_SHORT_URLS_START });
|
||||
|
||||
try {
|
||||
const shortUrls = await ShlinkApiClient.listShortUrls(params);
|
||||
const shortUrls = await shlinkApiClient.listShortUrls(params);
|
||||
|
||||
dispatch({ type: LIST_SHORT_URLS, shortUrls, params });
|
||||
} catch (e) {
|
||||
dispatch({ type: LIST_SHORT_URLS_ERROR, params });
|
||||
}
|
||||
};
|
||||
export const listShortUrls = (params = {}) => _listShortUrls(ShlinkApiClient, params);
|
||||
|
||||
export const listShortUrls = (params = {}) => _listShortUrls(shlinkApiClient, params);
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { LIST_SHORT_URLS } from './shortUrlsList';
|
||||
|
||||
export const RESET_SHORT_URL_PARAMS = 'shlink/shortUrlsListParams/RESET_SHORT_URL_PARAMS';
|
||||
|
||||
export const shortUrlsListParamsType = {
|
||||
page: PropTypes.string,
|
||||
tags: PropTypes.arrayOf(PropTypes.string),
|
||||
searchTerm: PropTypes.string,
|
||||
};
|
||||
|
||||
const defaultState = { page: '1' };
|
||||
|
||||
export default function reducer(state = defaultState, action) {
|
||||
|
||||
Reference in New Issue
Block a user