From df279b0332e56231e2c9bdc7fef65568248f7ce6 Mon Sep 17 00:00:00 2001 From: Avtonomova Ksenia Date: Fri, 20 Dec 2019 13:15:46 +0300 Subject: [PATCH 1/5] Change tags for log request to show tags in log header --- npm-shrinkwrap.json | 147 +++++++++++++++------------- src/app/constants/apiUrls.ts | 2 +- src/app/organisms/Log.tsx | 9 +- src/app/redux/ducks/tag/reducers.ts | 2 +- 4 files changed, 88 insertions(+), 72 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 535f15e..9504aba 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1043,7 +1043,8 @@ "chownr": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", - "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==" + "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", + "dev": true }, "chrome-trace-event": { "version": "1.0.0", @@ -2311,8 +2312,7 @@ "version": "2.1.1", "resolved": false, "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -2334,14 +2334,12 @@ "version": "1.0.0", "resolved": false, "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2351,22 +2349,19 @@ "version": "1.1.0", "resolved": false, "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": false, "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "resolved": false, "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -2475,8 +2470,7 @@ "version": "2.0.3", "resolved": false, "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -2488,7 +2482,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2503,7 +2496,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2512,14 +2504,12 @@ "version": "0.0.8", "resolved": false, "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true, - "optional": true + "dev": true }, "mkdirp": { "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -2530,6 +2520,13 @@ "dev": true, "optional": true }, + "nan": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", + "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "dev": true, + "optional": true + }, "needle": { "version": "2.3.0", "bundled": true, @@ -2601,8 +2598,7 @@ "version": "1.0.1", "resolved": false, "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -2614,7 +2610,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -2701,8 +2696,7 @@ "version": "5.1.1", "resolved": false, "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -2738,7 +2732,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2758,7 +2751,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2813,8 +2805,7 @@ "version": "1.0.2", "resolved": false, "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", @@ -2825,18 +2816,6 @@ } } }, - "fstream": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", - "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "inherits": "~2.0.0", - "mkdirp": ">=0.5 0", - "rimraf": "2" - } - }, "gauge": { "version": "2.7.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", @@ -3721,18 +3700,6 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" }, - "lodash.camelcase": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", - "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", - "dev": true - }, - "lodash.debounce": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", - "dev": true - }, "lodash.tail": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.tail/-/lodash.tail-4.1.1.tgz", @@ -3996,7 +3963,6 @@ "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -4006,8 +3972,7 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true, - "optional": true + "dev": true } } }, @@ -4153,13 +4118,6 @@ "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=", "dev": true }, - "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", - "dev": true, - "optional": true - }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -5344,7 +5302,8 @@ "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true }, "safe-regex": { "version": "1.1.0", @@ -6106,14 +6065,64 @@ "dev": true }, "tar": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.2.tgz", - "integrity": "sha512-FCEhQ/4rE1zYv9rYXJw/msRqsnmlje5jHP6huWeBZ704jUTy02c5AZyWujpMR1ax6mVw9NyJMfuK2CMDWVIfgA==", + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/tar/-/tar-5.0.5.tgz", + "integrity": "sha512-MNIgJddrV2TkuwChwcSNds/5E9VijOiw7kAc1y5hTNJoLDSuIyid2QtLYiCYNnICebpuvjhPQZsXwUL0O3l7OQ==", + "requires": { + "chownr": "^1.1.3", + "fs-minipass": "^2.0.0", + "minipass": "^3.0.0", + "minizlib": "^2.1.0", + "mkdirp": "^0.5.0", + "yallist": "^4.0.0" + }, + "dependencies": { + "chownr": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", + "integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==" + }, + "fs-minipass": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.0.0.tgz", + "integrity": "sha512-40Qz+LFXmd9tzYVnnBmZvFfvAADfUA14TXPK1s7IfElJTIZ97rA8w4Kin7Wt5JBrC3ShnnFJO/5vPjPEeJIq9A==", + "requires": { + "minipass": "^3.0.0" + } + }, + "minipass": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.1.1.tgz", + "integrity": "sha512-UFqVihv6PQgwj8/yTGvl9kPz7xIAY+R5z6XYjRInD3Gk3qx6QGSD6zEcpeG4Dy/lQnv1J6zv8ejV90hyYIKf3w==", + "requires": { + "yallist": "^4.0.0" + } + }, + "minizlib": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.0.tgz", + "integrity": "sha512-EzTZN/fjSvifSX0SlqUERCN39o6T40AMarPbv0MrarSFtIITCBh7bi+dU8nxGFHuqs9jdIAeoYoKuQAAASsPPA==", + "requires": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } + }, + "terser": { + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-3.17.0.tgz", + "integrity": "sha512-/FQzzPJmCpjAH9Xvk2paiWrFq+5M6aVOf+2KRbwhByISDX/EujxsK+BAvrhb6H+2rtrLCHK9N01wO014vrIwVQ==", "dev": true, "requires": { - "block-stream": "*", - "fstream": "^1.0.12", - "inherits": "2" + "commander": "^2.19.0", + "source-map": "~0.6.1", + "source-map-support": "~0.5.10" } }, "terser-webpack-plugin": { diff --git a/src/app/constants/apiUrls.ts b/src/app/constants/apiUrls.ts index 9ff1eee..fd0d3db 100644 --- a/src/app/constants/apiUrls.ts +++ b/src/app/constants/apiUrls.ts @@ -43,11 +43,11 @@ export const getLog = (id: string | number): string => `${BASE_URL}logs/${id}`; export const linkRunToLogUrl = (runNumber: number): string => `${BASE_URL}logs/${runNumber}/runs`; export const postLog = (): string => `${BASE_URL}logs`; export const postAttachment = (logId: string | number): string => `${BASE_URL}logs/${logId}/attachments`; +export const getTagsForLog = (logId: string | number): string => `${BASE_URL}logs/${logId}/tags`; // Tag export const getTags = (query?: string): string => `${BASE_URL}tags${query ? `?${query}` : ''}`; export const getTag = (id: string | number): string => `${BASE_URL}tags/${id}`; -export const getTagsForLog = (logId: string | number): string => `${BASE_URL}tags/${logId}/logs`; export const getTagsForRun = (runId: string | number): string => `${BASE_URL}tags/${runId}/runs`; export const postTag = (): string => `${BASE_URL}tags`; export const updateTag = (id: string | number): string => `${BASE_URL}tags/${id}`; diff --git a/src/app/organisms/Log.tsx b/src/app/organisms/Log.tsx index c4fcab1..b32e990 100644 --- a/src/app/organisms/Log.tsx +++ b/src/app/organisms/Log.tsx @@ -16,6 +16,7 @@ import SuccessMessage from '../atoms/SuccessMessage'; import { store } from '../redux/configureStore'; import { fetchAttachmentsByLog } from '../redux/ducks/attachment/operations'; import { fetchLog, fetchThread } from '../redux/ducks/log/operations'; +import { fetchTagsForLog } from '../redux/ducks/tag/operations'; import { selectCurrentLog, selectIsFetchingLog, selectIsPatchingLinkRunToLog, selectThread @@ -55,6 +56,7 @@ export default class Log extends MithrilTsxComponent { super(); store.dispatch(fetchLog(vnode.attrs.logId)); store.dispatch(fetchAttachmentsByLog(vnode.attrs.logId)); + store.dispatch(fetchTagsForLog(vnode.attrs.logId)); store.dispatch(setFilter(FilterName.Log, 'threadId', vnode.attrs.logId)); const queryString = selectQueryString(store.getState())(FilterName.Log); console.log('fetching thread...'); @@ -87,6 +89,9 @@ export default class Log extends MithrilTsxComponent { const isPatchingLinkRunToLog = selectIsPatchingLinkRunToLog(state); const attachments = selectAttachments(store.getState()); const tagsForLog = selectTagsForLog(store.getState()); + console.log(state); + console.log(attachments); + console.log(tagsForLog); const tags = selectTags(store.getState()); const thread = selectThread(store.getState()); return ( @@ -184,7 +189,9 @@ export default class Log extends MithrilTsxComponent {
  • {tag.tagText} diff --git a/src/app/redux/ducks/tag/reducers.ts b/src/app/redux/ducks/tag/reducers.ts index d9fb711..2923470 100644 --- a/src/app/redux/ducks/tag/reducers.ts +++ b/src/app/redux/ducks/tag/reducers.ts @@ -33,7 +33,7 @@ const attachmentReducer: Reducer return { ...state, isFetchingTags: false, - tags: [...action.payload.data.items] + tagsForLog: [...action.payload.data.items] }; case ActionTypes.CREATE_TAG_REQUEST: return { From 67fe020467ccfbf69affb7df0eaceb1fec42b84a Mon Sep 17 00:00:00 2001 From: Avtonomova Ksenia Date: Fri, 20 Dec 2019 13:48:23 +0300 Subject: [PATCH 2/5] Show tags in selector on Log page --- src/app/organisms/Log.tsx | 6 ++---- src/app/redux/ducks/tag/actions.ts | 13 ++++++++++++- src/app/redux/ducks/tag/operations.ts | 19 +++++++++++++++++-- src/app/redux/ducks/tag/reducers.ts | 11 +++++++++++ src/app/redux/ducks/tag/types.ts | 17 +++++++++++++++-- 5 files changed, 57 insertions(+), 9 deletions(-) diff --git a/src/app/organisms/Log.tsx b/src/app/organisms/Log.tsx index b32e990..290270d 100644 --- a/src/app/organisms/Log.tsx +++ b/src/app/organisms/Log.tsx @@ -16,7 +16,7 @@ import SuccessMessage from '../atoms/SuccessMessage'; import { store } from '../redux/configureStore'; import { fetchAttachmentsByLog } from '../redux/ducks/attachment/operations'; import { fetchLog, fetchThread } from '../redux/ducks/log/operations'; -import { fetchTagsForLog } from '../redux/ducks/tag/operations'; +import { fetchTagsForLog, fetchTags } from '../redux/ducks/tag/operations'; import { selectCurrentLog, selectIsFetchingLog, selectIsPatchingLinkRunToLog, selectThread @@ -57,6 +57,7 @@ export default class Log extends MithrilTsxComponent { store.dispatch(fetchLog(vnode.attrs.logId)); store.dispatch(fetchAttachmentsByLog(vnode.attrs.logId)); store.dispatch(fetchTagsForLog(vnode.attrs.logId)); + store.dispatch(fetchTags()); store.dispatch(setFilter(FilterName.Log, 'threadId', vnode.attrs.logId)); const queryString = selectQueryString(store.getState())(FilterName.Log); console.log('fetching thread...'); @@ -89,9 +90,6 @@ export default class Log extends MithrilTsxComponent { const isPatchingLinkRunToLog = selectIsPatchingLinkRunToLog(state); const attachments = selectAttachments(store.getState()); const tagsForLog = selectTagsForLog(store.getState()); - console.log(state); - console.log(attachments); - console.log(tagsForLog); const tags = selectTags(store.getState()); const thread = selectThread(store.getState()); return ( diff --git a/src/app/redux/ducks/tag/actions.ts b/src/app/redux/ducks/tag/actions.ts index d6cd66e..6adaa23 100644 --- a/src/app/redux/ducks/tag/actions.ts +++ b/src/app/redux/ducks/tag/actions.ts @@ -13,7 +13,9 @@ import { CreateTagRequestAction, CreateTagSuccessAction, SetTagToBeCreatedAction, - ClearTagToBeCreatedAction + ClearTagToBeCreatedAction, + FetchTagsByTagRequestAction, + FetchTagsByTagSuccessAction } from './types'; import { ITag } from '../../../interfaces/Tag'; import { ICollectionSuccessObject } from '../../../interfaces/ResponseObject'; @@ -45,3 +47,12 @@ export const setTagToBeCreated = (attachment: ITag): SetTagToBeCreatedAction => export const clearTagToBeCreated = (): ClearTagToBeCreatedAction => ({ type: ActionTypes.CLEAR_TAG_TO_BE_CREATED }); + +export const fetchTagsRequest = (): FetchTagsByTagRequestAction => ({ + type: ActionTypes.FETCH_TAGS_REQUEST +}); + +export const fetchTagsSuccess = (payload: ICollectionSuccessObject): FetchTagsByTagSuccessAction => ({ + type: ActionTypes.FETCH_TAGS_SUCCESS, + payload +}); diff --git a/src/app/redux/ducks/tag/operations.ts b/src/app/redux/ducks/tag/operations.ts index 27271af..2ffafcd 100644 --- a/src/app/redux/ducks/tag/operations.ts +++ b/src/app/redux/ducks/tag/operations.ts @@ -16,9 +16,11 @@ import { fetchTagsByLogRequest, fetchTagsByLogSuccess, createTagRequest, - createTagSuccess + createTagSuccess, + fetchTagsRequest, + fetchTagsSuccess } from './actions'; -import { getTagsForLog, postTag } from '../../../constants/apiUrls'; +import { getTags, getTagsForLog, postTag } from '../../../constants/apiUrls'; import { addHttpError } from '../error/actions'; import { ErrorAction } from '../error/types'; import { ICollectionSuccessObject } from '../../../interfaces/ResponseObject'; @@ -51,3 +53,16 @@ export const createTag = (tag: ITag): ThunkResult> => dispatch(addHttpError(error)); }); }; + +export const fetchTags = (query?: string): ThunkResult> => + async (dispatch: ThunkDispatch): Promise => { + dispatch(fetchTagsRequest()); + return request({ + method: 'GET', + url: getTags(query) + }).then((result: ICollectionSuccessObject) => { + dispatch(fetchTagsSuccess(result)); + }).catch((error: IHttpError) => { + dispatch(addHttpError(error)); + }); + }; diff --git a/src/app/redux/ducks/tag/reducers.ts b/src/app/redux/ducks/tag/reducers.ts index 2923470..8fb82da 100644 --- a/src/app/redux/ducks/tag/reducers.ts +++ b/src/app/redux/ducks/tag/reducers.ts @@ -55,6 +55,17 @@ const attachmentReducer: Reducer ...state, tagToBeCreated: null }; + case ActionTypes.FETCH_TAGS_REQUEST: + return { + ...state, + isFetchingTags: true + }; + case ActionTypes.FETCH_TAGS_SUCCESS: + return { + ...state, + isFetchingTags: false, + tags: [...action.payload.data.items] + }; default: return state; } diff --git a/src/app/redux/ducks/tag/types.ts b/src/app/redux/ducks/tag/types.ts index d107d30..b30400b 100644 --- a/src/app/redux/ducks/tag/types.ts +++ b/src/app/redux/ducks/tag/types.ts @@ -30,7 +30,9 @@ export enum ActionTypes { CREATE_TAG_REQUEST = 'jiskefet/attachment/CREATE_TAG_REQUEST', CREATE_TAG_SUCCESS = 'jiskefet/attachment/CREATE_TAG_SUCCESS', SET_TAG_TO_BE_CREATED = 'jiskefet/attachment/SET_TAG_TO_BE_CREATED', - CLEAR_TAG_TO_BE_CREATED = 'jiskefet/attachment/CLEAR_TAG_TO_BE_CREATED' + CLEAR_TAG_TO_BE_CREATED = 'jiskefet/attachment/CLEAR_TAG_TO_BE_CREATED', + FETCH_TAGS_REQUEST = 'jiskefet/attachment/FETCH_TAGS_REQUEST', + FETCH_TAGS_SUCCESS = 'jiskefet/attachment/FETCH_TAGS_SUCCESS', } // Action interfaces @@ -60,6 +62,15 @@ export interface ClearTagToBeCreatedAction extends Action { type: ActionTypes.CLEAR_TAG_TO_BE_CREATED; } +export interface FetchTagsByTagRequestAction extends Action { + type: ActionTypes.FETCH_TAGS_REQUEST; +} + +export interface FetchTagsByTagSuccessAction extends Action { + type: ActionTypes.FETCH_TAGS_SUCCESS; + payload: ICollectionSuccessObject; +} + // Combine actions into single type export type TagAction = | FetchTagsByLogRequestAction @@ -67,7 +78,9 @@ export type TagAction = | CreateTagRequestAction | CreateTagSuccessAction | SetTagToBeCreatedAction - | ClearTagToBeCreatedAction; + | ClearTagToBeCreatedAction + | FetchTagsByTagRequestAction + | FetchTagsByTagSuccessAction; // Shorthand type for ThunkAction export type ThunkResult = ThunkAction; From 92e60d3f3a4bed3579b74d5a35c4be4a5aa096d6 Mon Sep 17 00:00:00 2001 From: Avtonomova Ksenia Date: Sat, 21 Dec 2019 00:59:12 +0300 Subject: [PATCH 3/5] Show tags in header on detailed page --- src/app/constants/LogDescription.tsx | 11 +++++++++++ src/app/interfaces/Log.ts | 2 ++ src/app/organisms/Log.tsx | 10 ++++++---- src/app/redux/ducks/log/actions.ts | 13 +++++++++++++ src/app/redux/ducks/log/operations.ts | 20 ++++++++++++++++++-- src/app/redux/ducks/log/reducers.ts | 13 +++++++++++++ src/app/redux/ducks/log/selectors.ts | 2 ++ src/app/redux/ducks/log/types.ts | 18 +++++++++++++++++- 8 files changed, 82 insertions(+), 7 deletions(-) diff --git a/src/app/constants/LogDescription.tsx b/src/app/constants/LogDescription.tsx index abdee74..302fab7 100644 --- a/src/app/constants/LogDescription.tsx +++ b/src/app/constants/LogDescription.tsx @@ -12,6 +12,7 @@ import * as m from 'mithril'; import { IDescription } from '../interfaces/Description'; import { ILog } from '../interfaces/Log'; import { formatDateField } from '../utility/DateUtil'; +import { ITag } from '../interfaces/Tag'; /** * The tab information used by the TabHeader and TabContent of the Log detail page. @@ -62,6 +63,16 @@ const LogDescription: IDescription[] = [ return log.user && log.user.name; } + }, + { + label: 'Tags', + value: (log: ILog): JSX.Element => ( +
    + {log.tags!.map((tag: ITag) => { + return {tag.tagText}, ; + })} +
    + ) } ]; diff --git a/src/app/interfaces/Log.ts b/src/app/interfaces/Log.ts index df1933d..a7f2258 100644 --- a/src/app/interfaces/Log.ts +++ b/src/app/interfaces/Log.ts @@ -9,6 +9,7 @@ import { IAttachmentCreate, IAttachment } from './Attachment'; import { IUser } from './User'; import { IRun } from './Run'; +import { ITag } from './Tag'; /** * Interface with the fields for fetching one or more Log entries. @@ -24,6 +25,7 @@ export interface ILog { user: IUser; runs?: IRun[]; attachments?: IAttachment[]; + tags?: ITag[]; comments?: ILog[]; commentFkRootLogId?: number; commentFkParentLogId?: number; diff --git a/src/app/organisms/Log.tsx b/src/app/organisms/Log.tsx index 290270d..4e75f90 100644 --- a/src/app/organisms/Log.tsx +++ b/src/app/organisms/Log.tsx @@ -16,7 +16,8 @@ import SuccessMessage from '../atoms/SuccessMessage'; import { store } from '../redux/configureStore'; import { fetchAttachmentsByLog } from '../redux/ducks/attachment/operations'; import { fetchLog, fetchThread } from '../redux/ducks/log/operations'; -import { fetchTagsForLog, fetchTags } from '../redux/ducks/tag/operations'; +import { fetchTags } from '../redux/ducks/tag/operations'; +import { fetchTagsForLog } from '../redux/ducks/log/operations'; import { selectCurrentLog, selectIsFetchingLog, selectIsPatchingLinkRunToLog, selectThread @@ -32,7 +33,8 @@ import { selectAttachments } from '../redux/ducks/attachment/selectors'; import { IAttachment } from '../interfaces/Attachment'; import { download } from '../utility/FileUtil'; import AttachmentComponent from '../molecules/Attachment'; -import { selectFetchingTags, selectTagsForLog, selectTags } from '../redux/ducks/tag/selectors'; +import { selectFetchingTags, selectTags } from '../redux/ducks/tag/selectors'; +// import { selectTagsForLog } from '../redux/ducks/log/selectors'; import { ITag, ITagCreate } from '../interfaces/Tag'; import Input from '../atoms/Input'; import FormGroup from '../molecules/FormGroup'; @@ -89,7 +91,7 @@ export default class Log extends MithrilTsxComponent { const isFetchingLog = selectIsFetchingLog(state); const isPatchingLinkRunToLog = selectIsPatchingLinkRunToLog(state); const attachments = selectAttachments(store.getState()); - const tagsForLog = selectTagsForLog(store.getState()); + // const tagsForLog = selectTagsForLog(store.getState()); const tags = selectTags(store.getState()); const thread = selectThread(store.getState()); return ( @@ -183,7 +185,7 @@ export default class Log extends MithrilTsxComponent {

    Currently added tags: