Skip to content

Commit

Permalink
support repository info with app state (Alfresco#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenysVuika authored and dhrn committed Apr 30, 2019
1 parent aa9caee commit 3231d5f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
SetCurrentUrlAction,
SetInitialStateAction,
CloseModalDialogsAction,
SetRepositoryStatusAction,
SetRepositoryInfoAction,
SetUserProfileAction
} from './store/actions';
import {
Expand Down Expand Up @@ -136,7 +136,7 @@ export class AppComponent implements OnInit, OnDestroy {
.getRepositoryInformation()
.subscribe((response: DiscoveryEntry) => {
this.store.dispatch(
new SetRepositoryStatusAction(response.entry.repository.status)
new SetRepositoryInfoAction(response.entry.repository)
);
});
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/extensions/app.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/

import { RuleContext, RepositoryState } from '@alfresco/adf-extensions';
import { RuleContext } from '@alfresco/adf-extensions';
import { AuthenticationService } from '@alfresco/adf-core';
import { RepositoryInfo } from '@alfresco/js-api';

export interface AppRuleContext extends RuleContext {
repository: RepositoryState;
repository: RepositoryInfo;
auth: AuthenticationService;
}
2 changes: 1 addition & 1 deletion src/app/extensions/evaluators/repository.evaluators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ export function hasQuickShareEnabled(
context: AppRuleContext,
...args: RuleParameter[]
): boolean {
return context.repository.isQuickShareEnabled;
return context.repository.status.isQuickShareEnabled;
}
4 changes: 2 additions & 2 deletions src/app/extensions/extension.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ import {
ExtensionService,
ProfileState,
mergeObjects,
RepositoryState,
ExtensionRef
} from '@alfresco/adf-extensions';
import { AppConfigService, AuthenticationService } from '@alfresco/adf-core';
import { DocumentListPresetRef } from './document-list.extensions';
import { BehaviorSubject, Observable } from 'rxjs';
import { IconRef } from './icon.extensions';
import { AppRuleContext } from './app.interface';
import { RepositoryInfo } from '@alfresco/js-api';

@Injectable({
providedIn: 'root'
Expand Down Expand Up @@ -103,7 +103,7 @@ export class AppExtensionService implements AppRuleContext {
selection: SelectionState;
navigation: NavigationState;
profile: ProfileState;
repository: RepositoryState;
repository: RepositoryInfo;

references$: Observable<ExtensionRef[]>;

Expand Down
11 changes: 5 additions & 6 deletions src/app/store/actions/repository.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
*/

import { Action } from '@ngrx/store';
import { RepositoryState } from '@alfresco/adf-extensions';
import { RepositoryInfo } from '@alfresco/js-api';

export const SET_REPOSITORY_STATUS = 'SET_REPOSITORY_STATUS';
export const GET_REPOSITORY_STATUS = 'GET_REPOSITORY_STATUS';
export const SET_REPOSITORY_INFO = 'SET_REPOSITORY_INFO';

export class SetRepositoryStatusAction implements Action {
readonly type = SET_REPOSITORY_STATUS;
constructor(public payload: RepositoryState) {}
export class SetRepositoryInfoAction implements Action {
readonly type = SET_REPOSITORY_INFO;
constructor(public payload: RepositoryInfo) {}
}
12 changes: 5 additions & 7 deletions src/app/store/reducers/app.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import {
SetSelectedNodesAction,
SET_USER_PROFILE,
SetUserProfileAction,
SET_REPOSITORY_STATUS,
SetRepositoryStatusAction,
SET_REPOSITORY_INFO,
SetRepositoryInfoAction,
SET_LANGUAGE_PICKER,
SetLanguagePickerAction,
SET_CURRENT_FOLDER,
Expand Down Expand Up @@ -86,10 +86,8 @@ export function appReducer(
action
));
break;
case SET_REPOSITORY_STATUS:
newState = updateRepositoryStatus(state, <SetRepositoryStatusAction>(
action
));
case SET_REPOSITORY_INFO:
newState = updateRepositoryStatus(state, <SetRepositoryInfoAction>action);
break;
default:
newState = Object.assign({}, state);
Expand Down Expand Up @@ -241,7 +239,7 @@ function setInfoDrawer(state: AppState, action: SetInfoDrawerStateAction) {

function updateRepositoryStatus(
state: AppState,
action: SetRepositoryStatusAction
action: SetRepositoryInfoAction
) {
const newState = Object.assign({}, state);
newState.repository = action.payload;
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/selectors/app.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const repositoryStatus = createSelector(

export const isQuickShareEnabled = createSelector(
repositoryStatus,
status => status.isQuickShareEnabled
info => info.status.isQuickShareEnabled
);

export const isAdmin = createSelector(
Expand Down
12 changes: 7 additions & 5 deletions src/app/store/states/app.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import {
SelectionState,
ProfileState,
NavigationState,
RepositoryState
NavigationState
} from '@alfresco/adf-extensions';
import { RepositoryInfo } from '@alfresco/js-api';

export interface AppState {
appName: string;
Expand All @@ -41,7 +41,7 @@ export interface AppState {
navigation: NavigationState;
infoDrawerOpened: boolean;
documentDisplayMode: string;
repository: RepositoryState;
repository: RepositoryInfo;
}

export const INITIAL_APP_STATE: AppState = {
Expand All @@ -67,8 +67,10 @@ export const INITIAL_APP_STATE: AppState = {
},
infoDrawerOpened: false,
documentDisplayMode: 'list',
repository: {
isQuickShareEnabled: true
repository: <any>{
status: <any>{
isQuickShareEnabled: true
}
}
};

Expand Down

0 comments on commit 3231d5f

Please sign in to comment.